Skip to content

Posts: Allow posts to be both sticky and password protected across all interfaces. - #15708

Open
wppoland wants to merge 2 commits into
WordPress:trunkfrom
wppoland:trac/64810-allow-sticky-password
Open

wppoland wants to merge 2 commits into
WordPress:trunkfrom
wppoland:trac/64810-allow-sticky-password

Conversation

@wppoland

@wppoland wppoland commented Nov 6, 2026

Copy link
Copy Markdown

Allows password-protected posts to be sticky across all interfaces in WordPress core, following the direction proposed by @wildworks in comment:29 and verified by @jolanc in comment:33 and comment:34:

  • REST API (WP_REST_Posts_Controller): Removes the 400 rest_invalid_field rejection when creating or updating a post with both a password and sticky = true.
  • Admin (edit_post() and wp_write_post()): Stops unsetting sticky when visibility is password (private posts remain non-sticky).
  • XML-RPC (wp_xmlrpc_server::_toggle_sticky()): Relaxes the sticky guard so only private posts are rejected.
  • Classic Editor UI (post_submit_meta_box() and src/js/_enqueues/admin/post.js): Keeps the "Stick this post to the front page" checkbox available when "Password protected" is selected and displays Password protected, Sticky when active.
  • Tests: Updates and adds PHPUnit coverage across WP_REST_Posts_Controller, edit_post(), and wp_xmlrpc_server::wp_newPost().

Note: PR #13246 implements the narrower alternative (unsticking on Quick Edit when a password is set). Both PRs are available depending on final committer sign-off on Trac.

Trac ticket: https://core.trac.wordpress.org/ticket/64810


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

…l interfaces.

Unifies behavior across core by allowing password protected posts to be sticky:
- Removes the sticky/password rejection in WP_REST_Posts_Controller.
- Avoids unsetting the sticky flag in edit_post() and write_post() when visibility is password.
- Relaxes the sticky restriction in wp_xmlrpc_server::_toggle_sticky() so only private posts cannot be sticky.
- Updates the Classic Editor visibility UI to display and maintain sticky status for password-protected posts.
- Updates REST API, admin, and XML-RPC unit tests.

See #64810.
@github-actions

github-actions Bot commented Nov 6, 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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props motylanogha.

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

…word protected.

The three update tests still asserted the old 400 rest_invalid_field
response. The duplicate of the update case already covered by
test_update_post_with_password_and_sticky_succeeds() is removed; the
other two now assert that the request succeeds and the post keeps both
its password and its sticky state.

See #64810.
@wppoland

wppoland commented Nov 6, 2026

Copy link
Copy Markdown
Author

The first CI run had 3 failures, all in WP_Test_REST_Posts_Controller: three update tests still expected the old 400 rest_invalid_field response that this PR removes.

Fixed in 179542e:

  • test_update_post_with_password_and_sticky_fails() is removed. It duplicated test_update_post_with_password_and_sticky_succeeds(), added earlier in this PR.
  • test_update_stick_post_with_password_fails() is now test_update_stick_post_with_password_succeeds(): a sticky post that gets a password returns 200 and keeps both.
  • test_update_password_protected_post_with_sticky_fails() is now test_update_password_protected_post_with_sticky_succeeds(): a password protected post that is made sticky returns 200 and is sticky.

Locally, all 288 WP_Test_REST_Posts_Controller tests pass, as do the edit_post() tests in tests/admin/includesPost.php and the xmlrpc group (sticky and password filters). PHPCS is clean on the changed file.

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.

1 participant