Skip to content

Check REST visibility for content resizing posts#658

Open
yusufhay wants to merge 3 commits into
WordPress:developfrom
yusufhay:fix/content-resizing-rest-post-type-check
Open

Check REST visibility for content resizing posts#658
yusufhay wants to merge 3 commits into
WordPress:developfrom
yusufhay:fix/content-resizing-rest-post-type-check

Conversation

@yusufhay

@yusufhay yusufhay commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

What?

Adds a REST visibility check to the Content Resizing ability permission callback when a post ID is supplied.

Why?

Similar text abilities already prevent execution for posts whose post type is not exposed in REST. Content Resizing checked whether the user could edit the post, but did not apply that post type visibility check, leaving the ability inconsistent with the rest of the plugin.

How?

After confirming the post exists and the current user can edit it, the permission callback now checks the post type and returns false if the post type is missing or not exposed in REST.

Use of AI Tools

AI assistance: Yes
Tool(s): Codex / ChatGPT
Model(s): GPT-5
Used for: Comparing permission callbacks across similar abilities and drafting the consistency fix. I reviewed the change and PR description before submitting.

Testing Instructions

  1. Install and activate this PR build of the AI plugin.
  2. Enable the Content Resizing experiment.
  3. Open a normal REST-exposed post type, such as a post, and confirm content resizing still works for editable content.
  4. Register or use a post type that is not exposed in REST.
  5. Attempt to run the Content Resizing ability with a post ID from that post type.
  6. Confirm permission is denied instead of allowing the ability to run.

Screenshots or screencast

Not applicable. This PR does not change the UI.

Changelog Entry

Fixed - Restrict content resizing to REST-exposed post types when a post ID is provided.

Open WordPress Playground Preview

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

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: yusufhay <yusufmudagal@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>

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

@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.75%. Comparing base (64e8032) to head (31193b2).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #658      +/-   ##
=============================================
+ Coverage      74.57%   74.75%   +0.17%     
- Complexity      1754     1755       +1     
=============================================
  Files             85       85              
  Lines           7548     7553       +5     
=============================================
+ Hits            5629     5646      +17     
+ Misses          1919     1907      -12     
Flag Coverage Δ
unit 74.75% <100.00%> (+0.17%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

Comment thread includes/Abilities/Content_Resizing/Content_Resizing.php Outdated

@dkotter dkotter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There are a handful of PHPCS and PHPStan errors here that need cleaned up before we merge this

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