Skip to content

Conversation

@sheabunge
Copy link
Member

@sheabunge sheabunge commented Jul 30, 2025

No description provided.

@sheabunge sheabunge requested a review from Copilot July 30, 2025 07:26
Copy link
Contributor

Copilot AI left a 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 );
Copy link

Copilot AI Jul 30, 2025

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.

Suggested change
add_action( 'wp', __NAMESPACE__ . '\execute_active_snippets', 1 );
add_action( 'plugins_loaded', __NAMESPACE__ . '\execute_active_snippets', 1 );

Copilot uses AI. Check for mistakes.
}
}

$condition_data['rules'] = json_decode( $snippet->code, false );
Copy link

Copilot AI Jul 30, 2025

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.

Suggested change
$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.
}

Copilot uses AI. Check for mistakes.
@sheabunge sheabunge merged commit cef5daf into core Aug 27, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants