-
Notifications
You must be signed in to change notification settings - Fork 108
Update edit menu UI #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update edit menu UI #244
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the edit menu UI for Code Snippets with extensive changes to modernize the interface and add support for conditions functionality. The changes include new React components, improved TypeScript types, updated CSS configurations, and enhanced API handling.
- Adds comprehensive condition snippet functionality with new UI components and API endpoints
- Modernizes the snippet editor interface with collapsible sidebar and improved form controls
- Refactors JavaScript components to use proper React context patterns and REST API integration
Reviewed Changes
Copilot reviewed 127 out of 133 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| stylelint.config.mjs | Adds new stylelint configuration for CSS linting |
| src/readme.txt | Updates version number and adds changelog entries |
| src/php/views/welcome.php | Improves semantic HTML structure with proper navigation elements |
| src/php/views/partials/list-table-notices.php | Simplifies error message formatting and HTML structure |
| src/php/views/manage.php | Adds conditional display logic for upgrade menu and updates badge styling |
| src/php/views/import.php | Fixes array formatting and removes extra whitespace |
| src/php/snippet-ops.php | Adds condition support, updates execution logic, and improves array handling |
| src/php/settings/settings-fields.php | Updates setting labels for better clarity |
| src/php/rest-api/class-snippets-rest-controller.php | Enhances API schema with condition support and better type definitions |
| src/php/load.php | Changes snippet execution hook from plugins_loaded to wp |
| src/php/front-end/class-front-end.php | Reorders asset registration for better loading |
| src/php/export/class-export.php | Adds condition export functionality and improves parameter naming |
| src/php/export/class-export-attachment.php | Updates export logic to handle conditions and improves MIME type handling |
| src/php/cloud/list-table-shared-ops.php | Standardizes button styling and removes unused classes |
| src/php/cloud/class-cloud-search-list-table.php | Improves status badge implementation with better tooltip structure |
| src/php/cloud/class-cloud-api.php | Refactors status handling with constants and improves method organization |
| src/php/class-snippet.php | Adds comprehensive condition support and improves type handling |
| src/php/class-plugin.php | Removes unused method and updates URL generation logic |
| src/php/class-list-table.php | Adds condition support and improves snippet status handling |
| src/php/class-db.php | Adds condition_id column to database schema |
| src/php/class-data-item.php | Updates error handling to use WordPress functions |
| src/php/class-admin.php | Improves notice styling and tab rendering logic |
| src/php/class-active-snippets.php | Adds imports for new dependencies |
| src/php/admin-menus/class-settings-menu.php | Removes license section from settings display |
| src/php/admin-menus/class-manage-menu.php | Updates upgrade menu logic and removes unused method |
| src/php/admin-menus/class-edit-menu.php | Adds condition scope mapping and updates script dependencies |
| src/js/utils/text.ts | Adds stripTags utility function |
| src/js/utils/snippets/ | New comprehensive snippet utilities with proper TypeScript types |
| src/js/utils/restAPI.ts | Simplified REST API configuration |
| src/js/utils/hooks.ts | New context hook utility |
| src/js/utils/files.ts | Enhanced file download handling for conditions |
| src/js/types/ | Updated and new TypeScript type definitions |
| src/js/hooks/ | New React hooks for REST API, snippet management, and form handling |
| src/js/components/ | Extensive component refactoring with new UI elements and improved structure |
Comments suppressed due to low confidence (1)
src/php/class-data-item.php:150
- The function wp_trigger_error() does not exist in WordPress core. WordPress uses trigger_error() directly or _doing_it_wrong() for development notices. This will cause the error handling to be silently skipped since the function check will always fail.
if ( function_exists( 'wp_trigger_error' ) ) {
src/php/load.php
Outdated
|
|
||
| // Execute the snippets once the plugins are loaded. | ||
| add_action( 'plugins_loaded', __NAMESPACE__ . '\execute_active_snippets', 1 ); | ||
| add_action( 'wp', __NAMESPACE__ . '\execute_active_snippets', 1 ); |
Copilot
AI
Jul 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the hook from 'plugins_loaded' to 'wp' is a significant change that could break functionality. The 'wp' hook only fires on front-end requests and admin pages that handle specific queries, but not on all admin pages. This means snippets might not execute in some admin contexts where they previously did.
| add_action( 'wp', __NAMESPACE__ . '\execute_active_snippets', 1 ); | |
| add_action( 'plugins_loaded', __NAMESPACE__ . '\execute_active_snippets', 1 ); |
src/php/export/class-export.php
Outdated
| } | ||
| } | ||
|
|
||
| $condition_data['rules'] = json_decode( $snippet->code, false ); |
Copilot
AI
Jul 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using json_decode() without error checking is unsafe. If $snippet->code is not valid JSON, json_decode() will return null and no error will be reported. This could result in malformed export data. Add error checking with json_last_error() or consider using a try-catch block.
| $condition_data['rules'] = json_decode( $snippet->code, false ); | |
| $decoded_rules = json_decode( $snippet->code, false ); | |
| if ( json_last_error() === JSON_ERROR_NONE ) { | |
| $condition_data['rules'] = $decoded_rules; | |
| } else { | |
| $condition_data['rules'] = []; // Provide a fallback value or handle the error as needed. | |
| error_log( 'Invalid JSON in snippet code: ' . json_last_error_msg() ); // Optional: Log the error for debugging. | |
| } |
b1524ea to
26731cf
Compare
No description provided.