Plugin Directory: Hide ElasticSearch metabox where unusable + populate post_author for CLI inserts#9
Open
dd32 wants to merge 3 commits into
Open
Plugin Directory: Hide ElasticSearch metabox where unusable + populate post_author for CLI inserts#9dd32 wants to merge 3 commits into
dd32 wants to merge 3 commits into
Conversation
…eful. Skip rendering for draft/pending plugins (nothing is indexed yet) and on local environments without Jetpack Search available (the AJAX call would just report that Jetpack Search is unavailable). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… inserts. The production import-plugin.php --create path calls create_plugin_post() with only post_name, so wp_insert_post() defaults post_author to get_current_user_id(), which is 0 in CLI. This leaves the plugin post with no resolvable author, which in turn produces a string of PHP warnings in the wp-admin Review Tools metabox. Add a local mu-plugin that hooks wp_insert_post_data: when a new plugin post is being inserted in CLI without a post_author, fetch the embedded author from the wp.org REST API and create the matching local user. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Move it into the existing post-approval block (alongside committers, support reps, etc.) so it only renders for plugins that have moved past new/pending, and keep the class_exists guard so it stays hidden when Jetpack Search is not loaded locally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small fixes around the wp-admin plugin edit screen, motivated by PHP warnings showing up when running locally:
Hide the ElasticSearch metabox when it cannot be useful
draftorpendingstatus there is nothing indexed yet, so the metabox just shows "Not indexed" with a Reindex button that will not help.The metabox now registers only when neither of those conditions apply.
Local env mu-plugin: populate post_author for CLI inserts
The production
import-plugin.php --createpath callsPlugin_Directory::create_plugin_post()with onlypost_name, sowp_insert_post()defaultspost_authortoget_current_user_id()— which is0in CLI. Locally-imported plugin posts end up with no resolvable author, which then produces a wall of PHP warnings in the Review Tools metabox ($author->user_email,->user_registered, etc onfalse).The new
environments/mocks/mu-plugins/wporg-plugin-author-import.phphookswp_insert_post_data(CLI-only, new inserts, missing post_author) and resolves the author fromhttps://wordpress.org/plugins/wp-json/wp/v2/plugin?slug=...&_embed=1, creating a matching local user if needed.Test plan
wp eval-file wp-content/plugin-directory/bin/import-plugin.php --plugin=<slug> --createagainst a fresh local DB results in the plugin post being created withpost_authorset to the matching wp.org user (auto-created locally).🤖 Generated with Claude Code