Skip to content

Conversation

gziolo
Copy link
Member

@gziolo gziolo commented Oct 9, 2025

Move show_in_rest to meta in the registration process.

Example:

// Ability that does not show in REST.
wp_register_ability(
	'test/not-show-in-rest',
	array(
		'label'               => 'Hidden from REST',
		'description'         => 'It does not show in REST.',
		'execute_callback'    => static function (): int {
			return 0;
		},
		'permission_callback' => '__return_true',
		'meta'                => array(
			'show_in_rest' => false,
		),
	)
);

I also included the proposal in 8f937a6 to change the default value to true, so all abilities are exposed in REST API by default. The decision was made in #107 (comment) to keep show_in_rest defaulting to false.

I also replaced show_in_rest() method with a more generalized helper get_meta_item(). Example usage:

$ability->get_meta_item( 'non_existing' ); // returns null
$ability->get_meta_item( 'non_existing', 'default_value' ); // returns 'default_value'
$ability->get_meta_item( 'show_in_rest' ); // returns false

@gziolo gziolo self-assigned this Oct 9, 2025
@gziolo gziolo added the [Type] Bug Something isn't working label Oct 9, 2025
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.27%. Comparing base (76f9cea) to head (207146e).
⚠️ Report is 1 commits behind head on trunk.

Additional details and impacted files
@@             Coverage Diff              @@
##              trunk     #107      +/-   ##
============================================
+ Coverage     86.17%   86.27%   +0.10%     
- Complexity      110      111       +1     
============================================
  Files            16       16              
  Lines           803      809       +6     
  Branches         86       86              
============================================
+ Hits            692      698       +6     
  Misses          111      111              
Flag Coverage Δ
javascript 92.62% <ø> (ø)
unit 83.95% <100.00%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

github-actions bot commented Oct 9, 2025

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: gziolo <[email protected]>
Co-authored-by: JasonTheAdams <[email protected]>
Co-authored-by: felixarntz <[email protected]>
Co-authored-by: justlevine <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Member

@JasonTheAdams JasonTheAdams left a comment

Choose a reason for hiding this comment

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

Looking mostly good, just one question on the default, @gziolo.

@gziolo gziolo force-pushed the update/meta-annotations-show-in-rest branch from 8f937a6 to 583da4c Compare October 10, 2025 05:06
@gziolo gziolo force-pushed the update/meta-annotations-show-in-rest branch from 055a87b to fee5c3c Compare October 10, 2025 05:43
@gziolo
Copy link
Member Author

gziolo commented Oct 10, 2025

The decision was made in #107 (comment) to keep show_in_rest defaulting to false. I addressed all other feedback, too.

@gziolo gziolo force-pushed the update/meta-annotations-show-in-rest branch from fee5c3c to 207146e Compare October 10, 2025 06:53
@gziolo gziolo merged commit 124d8be into trunk Oct 10, 2025
21 checks passed
@gziolo gziolo deleted the update/meta-annotations-show-in-rest branch October 10, 2025 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants