Skip to content

Protected registered meta keys in block editor sidebar - #4584

Open
girishpanchal30 wants to merge 3 commits into
developmentfrom
bugfix/4574
Open

Protected registered meta keys in block editor sidebar#4584
girishpanchal30 wants to merge 3 commits into
developmentfrom
bugfix/4574

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

Summary

Protected meta keys are not shown in the Custom Fields panel, which would otherwise overwrite the values saved from the Neve sidebar with the ones loaded with the page.

Check before Pull Request is ready:

Closes #4574

@pirate-bot

pirate-bot commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Plugin build for 07b6e50 is ready 🛎️!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds coverage and a fix for the block editor sidebar meta save flow to prevent stale Custom Fields submissions from overwriting recently-saved sidebar meta.

Changes:

  • Introduces WP unit tests that simulate saving sidebar meta via REST and subsequent Custom Fields meta box submission.
  • Marks Neve’s registered sidebar meta keys as protected via is_protected_meta to keep Custom Fields from writing them back.
  • Tracks registered sidebar meta keys in the metabox manager for protection checks.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
tests/test-neve-metabox-meta.php Adds regression tests for REST sidebar meta save + Custom Fields submission behavior.
inc/admin/metabox/manager.php Tracks registered meta keys and protects them from Custom Fields overwrite via is_protected_meta.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/test-neve-metabox-meta.php
Comment thread tests/test-neve-metabox-meta.php Outdated
Comment thread inc/admin/metabox/manager.php Outdated
Comment thread inc/admin/metabox/manager.php Outdated
Comment thread inc/admin/metabox/manager.php
Comment thread inc/admin/metabox/manager.php Outdated
Comment thread inc/admin/metabox/manager.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

tests/test-neve-metabox-meta.php:82

  • The docblock return type is inaccurate: WP_REST_Server::dispatch() can return WP_REST_Response or WP_Error. Either update the docblock (@return WP_REST_Response|WP_Error) or add a test assertion/guard immediately after dispatching so failures produce readable assertion output rather than a fatal when callers invoke $response->get_status().
	/**
	 * Save the sidebar meta the way the editor sidebar does, over the REST API.
	 *
	 * @param string $value the value to save.
	 *
	 * @return WP_REST_Response
	 */
	private function rest_save_sidebar_meta( $value ) {
		$request = new WP_REST_Request( 'POST', '/wp/v2/pages/' . $this->page_id );
		$request->set_body_params( array( 'meta' => array( 'neve_meta_sidebar' => $value ) ) );

		return rest_get_server()->dispatch( $request );
	}

Comment on lines +90 to +102
private function submit_meta_boxes( $meta ) {
$_POST = array(
'post_ID' => $this->page_id,
'post_type' => 'page',
'post_title' => 'Neve meta page',
'post_status' => 'publish',
'meta' => $meta,
);

edit_post();

$_POST = array();
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edit_post() does not contain check_admin_referer() or any nonce handling. It only performs capability checks such as current_user_can( 'edit_post', ... ) and current_user_can( 'edit_post_meta', ... ). The administrator role is set up before each test case, so all test cases pass successfully.

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.

Neve Options (page meta sidebar) silently fail to persist on some sites

5 participants