Skip to content

Permalinks: Preserve post status in sample permalink filters#12577

Draft
ArkaPrabhaChowdhury wants to merge 1 commit into
WordPress:trunkfrom
ArkaPrabhaChowdhury:trac-50002-sample-permalink-status
Draft

Permalinks: Preserve post status in sample permalink filters#12577
ArkaPrabhaChowdhury wants to merge 1 commit into
WordPress:trunkfrom
ArkaPrabhaChowdhury:trac-50002-sample-permalink-status

Conversation

@ArkaPrabhaChowdhury

Copy link
Copy Markdown

get_sample_permalink() currently changes draft, pending, future, and auto-draft posts to publish before generating the permalink. This causes the pre_post_link and post_link filters to receive an inaccurate post status.

This changes the function to use a separate published status only when determining a unique sample slug, while keeping the WP_Post status unchanged. It also preserves pretty sample permalinks for auto-drafts through wp_force_plain_post_permalink().

The regression test verifies that both permalink filters receive the original draft status and that the generated sample permalink remains unchanged.

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

Testing

  • npm run test:php -- --filter=Tests_Admin_IncludesPost
  • php -d xdebug.mode=off vendor/bin/phpcbf src/wp-admin/includes/post.php src/wp-includes/link-template.php tests/phpunit/tests/admin/includesPost.php
  • php -d xdebug.mode=off vendor/bin/phpcs --warning-severity=0 src/wp-admin/includes/post.php src/wp-includes/link-template.php tests/phpunit/tests/admin/includesPost.php

Use of AI Tools

AI assistance: Yes
Tool(s): Codex
Model(s): GPT-5
Used for: Investigating the current code path, implementing the fix and regression test, and running validation. The final changes were reviewed and verified against the focused test suite.


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.

@github-actions

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.

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