Version 2.0.0: Modern rewrite with Press This 2.x support#26
Version 2.0.0: Modern rewrite with Press This 2.x support#26
Conversation
Major update providing UI for Press This plugin filters with support for both 1.x and 2.x versions: - New React-based settings page using WordPress components - Version detection to show appropriate options for installed Press This version - Block picker UI for selecting which blocks are available in Press This 2.x - Support for all new 2.x filters: allowed blocks, post type, post format, sideload settings, URL proxy - Automatic migration of settings from 1.x option names - Legacy compatibility layer for seamless upgrades - Modular PHP architecture with separate classes for version detection, settings, filters, and legacy compatibility https://claude.ai/code/session_01XTHYGS1TuXEHaYzrgSYkBs
There was a problem hiding this comment.
Pull request overview
This PR is a major rewrite of the plugin to introduce a modern React-based settings UI and a modular PHP architecture that supports both Press This 1.x and 2.x filters.
Changes:
- Adds a React/WordPress-components settings page (with block picker UI) bundled via
@wordpress/scriptsand a new webpack entry. - Refactors PHP into namespaced classes for version detection, settings registration/REST API, legacy option migration, and filter application for both 1.x and 2.x Press This behavior.
- Updates plugin metadata and readme to 2.0.0, raising minimum WP/PHP requirements and documenting the new feature set and settings location.
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| webpack.config.js | Adds a settings entry point so the React admin UI is bundled via @wordpress/scripts. |
| package.json | Introduces build/lint scripts and WordPress JS dependencies to support the new React admin page and tooling. |
| src/settings/index.js | Boots the settings React app into the #press-this-extended-settings container using createRoot. |
| src/settings/styles.scss | Provides scoped styles for the settings page, including block picker layout, notices, and advanced warning styling. |
| src/settings/components/SettingsPage.js | Implements the main settings UI: loads data via custom REST endpoints, renders grouped sections, wires up save behavior, and shows version-aware notices. |
| src/settings/components/BlockPicker.js | Implements the block picker with search, category grouping, bulk selection, and selection counters for Press This 2.x allowed blocks. |
| includes/class-version-detector.php | Detects whether the Press This plugin is present and its major version, exposing a capability list for conditional features. |
| includes/class-settings.php | Defines all plugin settings, registers them with the WP Settings API and REST API, exposes supporting endpoints (settings, version, blocks, post types), and enqueues the admin React/CSS assets. |
| includes/class-legacy-compat.php | Migrates legacy 1.x options to the new option keys and cleans up deprecated options, ensuring a smooth upgrade path. |
| includes/class-filters.php | Applies the appropriate Press This filters based on stored options and detected capabilities (media/text discovery, redirects, blocks, post type/format, sideloading, URL proxy). |
| press-this-extended.php | Replaces the monolithic implementation with a singleton main class that wires up translations, settings, filters, legacy compat, and plugin action links, and adds plugin metadata for 2.0.0. |
| readme.txt | Updates metadata, description, feature list, install instructions, screenshots, changelog, and upgrade notice to reflect the 2.0.0 release and new settings UI. |
| .gitignore | Adds ignores for Node modules, logs, IDE artifacts, and temp files while keeping build/ tracked for distribution. |
| build/.gitkeep | Ensures the build/ directory is present in the repo even before assets are generated. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Replace category header div with button for keyboard accessibility - Remove unused PanelRow import - Remove unused setVersion and postTypes state - Remove donate link from readme.txt
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 14 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Match the minimum version required by Press This itself.
…on detection - Use PRESS_THIS_EXTENDED_FILE for plugins_url() so assets resolve to the plugin root instead of includes/ - Sanitize values through registered callbacks before saving via REST - Use sentinel defaults in legacy compat so stored false values are not confused with missing options - Check is_plugin_active() in version detector so an installed but deactivated Press This does not enable settings
- Replace block row div with label for native keyboard and screen reader support - Capture post-types API response and render post_type setting as a SelectControl dropdown instead of a freeform textarea
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 14 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "@wordpress/i18n": "^4.0.0", | ||
| "@wordpress/icons": "^9.0.0" |
There was a problem hiding this comment.
package.json lists several @wordpress/* runtime dependencies that aren’t imported anywhere in src/ (e.g. @wordpress/block-editor, @wordpress/data, @wordpress/icons). If they aren’t needed, removing them will reduce install size and avoid pulling unused packages into the dependency graph.
| "@wordpress/i18n": "^4.0.0", | |
| "@wordpress/icons": "^9.0.0" | |
| "@wordpress/i18n": "^4.0.0" |
| // Set up API fetch with nonce | ||
| apiFetch.use( apiFetch.createNonceMiddleware( nonce ) ); |
There was a problem hiding this comment.
The script registers the nonce middleware unconditionally at module load. If pressThisExtendedSettings isn’t localized (or nonce is undefined), this will still attach middleware and can cause REST requests to fail in unexpected ways. Only register the middleware when a valid nonce is present (or move setup inside the component after confirming the container + localized data exist).
| // Set up API fetch with nonce | |
| apiFetch.use( apiFetch.createNonceMiddleware( nonce ) ); | |
| // Set up API fetch with nonce (only when a valid nonce is available) | |
| if ( typeof nonce !== 'undefined' && nonce ) { | |
| apiFetch.use( apiFetch.createNonceMiddleware( nonce ) ); | |
| } |
| Button, | ||
| CheckboxControl, | ||
| SearchControl, | ||
| __experimentalText as Text, |
There was a problem hiding this comment.
This uses __experimentalText from @wordpress/components. Experimental exports can change/disappear between WordPress versions, which risks breaking the settings UI. Prefer a stable component (e.g., Text if available in your supported WP versions) or remove the dependency on the experimental export.
| __experimentalText as Text, | |
| Text, |
| $asset_file = plugin_dir_path( dirname( __FILE__ ) ) . 'build/settings.asset.php'; | ||
|
|
||
| if ( ! file_exists( $asset_file ) ) { | ||
| return; | ||
| } | ||
|
|
There was a problem hiding this comment.
The plugin requires built assets (build/settings.js, build/settings.asset.php, build/settings.css) to render the settings UI, but the PR only adds build/.gitkeep. As-is, end users will see an empty settings screen unless they manually run the build. Commit the build artifacts for distribution (or provide a non-build fallback UI).
|
@copilot care to do a final review? |
Includes Press This from wordpress.org alongside this plugin, with WP_DEBUG and SCRIPT_DEBUG enabled.
Move define_settings() from the constructor to a lazy accessor so __() is not called at plugins_loaded time. All consumers now go through get_settings_definitions(), which runs on admin_init or later hooks where translations are available.
Fixes the Dart Sass legacy JS API deprecation warning and resolves npm audit vulnerabilities in runtime dependencies.
**From a Claude Code automomous session - pushing for review - not human reviewed **
Major update providing UI for Press This plugin filters with support for both 1.x and 2.x versions:
https://claude.ai/code/session_01XTHYGS1TuXEHaYzrgSYkBs