Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Add option to ignore sticky posts in Query block #8265

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

Mamaduka
Copy link
Member

@Mamaduka Mamaduka commented Feb 6, 2025

Introduce a new ignore value for the sticky query argument. When this value is used, the query will not prepend sticky posts at the top but display them in the natural order.

Related: #8228
Gutenberg PR: WordPress/gutenberg#69057
Trac ticket: https://core.trac.wordpress.org/ticket/62908#ticket


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.

Introduce a new `ignore` value for the `sticky` query argument. When this value is used, the query won't prepend sticky posts at the top; instead, it will display them in the natural order of the query.
@Mamaduka Mamaduka self-assigned this Feb 6, 2025
Copy link

github-actions bot commented Feb 6, 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.

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

Props mamaduka, peterwilsoncc, audrasjb.

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

Copy link

github-actions bot commented Feb 6, 2025

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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • 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.

Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

A couple of nit picks inline but this looks good to me.

I've taken the liberty of pushing some tests to your branch to ensure each of the settings work as expected. On trunk the tests fail, on this branch they pass.

The trunk results are:

$ ./vendor/bin/phpunit --group 62908
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 9.6.21 by Sebastian Bergmann and contributors.

Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

..F                                                                 3 / 3 (100%)

Time: 00:00.203, Memory: 193.00 MB

There was 1 failure:

1) Tests_Blocks_wpBlock::test_build_query_vars_from_block_query_ignore_sticky_posts
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
     'post_type' => 'post'
     'order' => 'DESC'
     'orderby' => 'date'
-    'post__not_in' => Array &1 ()
+    'post__not_in' => Array &1 (
+        0 => 21
+    )
     'tax_query' => Array &2 ()
-    'ignore_sticky_posts' => 1
 )

/vagrant/wordpress-develop/tests/phpunit/tests/blocks/wpBlock.php:877

FAILURES!
Tests: 3, Assertions: 8, Failures: 1.

@Mamaduka
Copy link
Member Author

Thanks for pushing the tests, @peterwilsoncc 🙇

@audrasjb
Copy link
Contributor

Appart from the couple wpcs issues reported by Peter this looks good to me 👍 Concerning the post__not_in specific concern, this will need to be documented at least in a dev note, but I think an inline comment somewhere would be ideal.

@Mamaduka
Copy link
Member Author

@peterwilsoncc, @audrasjb let me know if this is good to commit.

Copy link
Contributor

@audrasjb audrasjb left a comment

Choose a reason for hiding this comment

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

Thanks @Mamaduka 👍

Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

Thanks George, this looks good for commit.

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.

3 participants