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

Query loop / Post template: Enable post format filter #64167

Merged
merged 65 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
1bbceed
Enable post format filter in the query loop
carolinan Aug 1, 2024
d12d992
try to fix CS issues
carolinan Aug 1, 2024
e803527
how about this cs fix then?
carolinan Aug 1, 2024
ada8db4
Create a new option for post formats
carolinan Aug 2, 2024
63883ac
Update the control to use the post format theme support
carolinan Aug 5, 2024
800ee24
Post template preview: Get the ID of the post format to use in the qu…
carolinan Aug 5, 2024
ac44e6f
Filter the query loop vars to support post formats on the front.
carolinan Aug 6, 2024
63bad0f
Remove the post type from PostFormatControls
carolinan Aug 6, 2024
6f6e3e8
PHPCS fixes
carolinan Aug 6, 2024
d5ad75b
Merge branch 'trunk' into try/post-format-query
carolinan Aug 12, 2024
7482122
Update the condition for when then post format control should show
carolinan Aug 13, 2024
d3fa212
WIP: Try to add format to the REST API posts controller through a cus…
carolinan Aug 13, 2024
ca718ef
Merge branch 'trunk' into try/post-format-query
carolinan Aug 13, 2024
4ab896c
Update since
carolinan Aug 13, 2024
367f6c1
Regenerate the fixture for the query loop, including postFormat.
carolinan Aug 13, 2024
2f6e716
Revert removing the post formats from TaxonomyControls
carolinan Aug 13, 2024
def06f2
Update class-gutenberg-rest-posts-controller-6-7.php
carolinan Aug 13, 2024
8d87706
Combine the post format with the tax_query array instead of replacing…
carolinan Aug 13, 2024
7a989f9
WIP: comment out breaking code to allow testing.
carolinan Aug 13, 2024
976bb04
Merge branch 'trunk' into try/post-format-query
carolinan Aug 22, 2024
7008f76
edit.js: Don't convert the post format to a string
carolinan Aug 22, 2024
7c6ac16
Update edit.js
carolinan Aug 22, 2024
5154069
Simplify the format array in get_item_schema
carolinan Aug 22, 2024
c09d093
Remove the changes to get_collection_params()
carolinan Aug 22, 2024
713786e
Allow filtering for the standard post format
carolinan Aug 22, 2024
c7d7c88
Filter register_post_type_args instead of using rest_api_init
carolinan Aug 22, 2024
96b408b
Merge branch 'trunk' into try/post-format-query
carolinan Aug 27, 2024
c13e920
Rename "postFormat" parameter to "format"
carolinan Aug 27, 2024
bf67232
Merge branch 'trunk' into try/post-format-query
carolinan Aug 29, 2024
a1a561b
Add format to get_collection_params()
carolinan Aug 29, 2024
b87d25c
Update lib/compat/wordpress-6.7/class-gutenberg-rest-posts-controller…
carolinan Aug 29, 2024
4786c24
Update class-gutenberg-rest-posts-controller-6-7.php
carolinan Aug 29, 2024
c41fbbb
Merge branch 'try/post-format-query' of https://github.com/WordPress/…
carolinan Aug 29, 2024
78470b0
PHPCS: remove white space
carolinan Aug 29, 2024
8f32caf
Remove get_item_schema()
carolinan Aug 29, 2024
deab94c
Update the logic for the standard post format in gutenberg_filter_qu…
carolinan Aug 29, 2024
c4d9e1d
Replace SelectControl with FormTokenField
carolinan Aug 30, 2024
f2f9045
Merge branch 'trunk' into try/post-format-query
carolinan Aug 31, 2024
e2b82d3
Set the constant format to an empty array when format is not queried
carolinan Aug 31, 2024
5739bf3
Hide the control and reset the format value if the post type does not…
carolinan Sep 1, 2024
90fbdd9
Rename postFormatSupportMap to postTypeFormatSupportMap
carolinan Sep 1, 2024
1573c10
Merge branch 'trunk' into try/post-format-query
carolinan Sep 1, 2024
33119d7
Merge branch 'trunk' into try/post-format-query
carolinan Sep 3, 2024
a1017ef
Fix REST API controller override condition
Mamaduka Sep 4, 2024
601644f
Don't set the default post format in the schema
Mamaduka Sep 4, 2024
8eab071
Satisfy PHP linter
Mamaduka Sep 4, 2024
8121870
Update the 'FormatsControl' to match suggestion labels to their stati…
Mamaduka Sep 4, 2024
1b291ed
Refactor showFormatControl logic
Mamaduka Sep 4, 2024
d31086d
Merge branch 'trunk' into try/post-format-query
carolinan Sep 5, 2024
e798f3b
gutenberg_filter_query_loop_block_query_vars_post_format: Switch to u…
carolinan Sep 5, 2024
664b745
Update lib/compat/wordpress-6.7/post-formats.php
carolinan Sep 5, 2024
812c372
End the comment with a full stop.
carolinan Sep 5, 2024
2e7e901
Merge branch 'trunk' into try/post-format-query
carolinan Sep 9, 2024
ce0583b
Update doc blocks and replace aray_diff with unset and array_search.
carolinan Sep 9, 2024
83d02bc
Update doc block
carolinan Sep 9, 2024
9cbe2ad
Add backport changelog
carolinan Sep 9, 2024
4b46ea2
Oops: Fix the copy-paste typo in the changelog entry.
carolinan Sep 9, 2024
d98fbaa
Update lib/compat/wordpress-6.7/class-gutenberg-rest-posts-controller…
carolinan Sep 10, 2024
9514a05
Rename gutenberg_filter_query_loop_block_query_vars_post_format to gu…
carolinan Sep 10, 2024
a702271
Gutenberg_REST_Posts_Controller_6_7 get_items: remove the array conve…
carolinan Sep 10, 2024
4df4639
Add two checks that help fail gracefully when errors occur
carolinan Sep 11, 2024
25ceeec
Update the docBlock for gutenberg_add_format_query_vars_to_query_loop…
carolinan Sep 11, 2024
a85a919
FormatControls: simplify array conversion
carolinan Sep 11, 2024
f182af0
Merge branch 'trunk' into try/post-format-query
carolinan Sep 13, 2024
8031da7
Merge branch 'trunk' into try/post-format-query
carolinan Sep 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/compat/wordpress-6.7/taxonomy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Temporary compatibility code for post formats.
*
* @package gutenberg
*/

/**
* Add support for the post format taxonomy in the REST API.
* See wp-includes/taxonomy.php line 170.
*
* Needed to add post formats to the taxonomy filter in the query loop.
*
* @since 6.7.0
*/
add_filter(
'register_post_format_taxonomy_args',
function ( $args ) {
$args['show_in_rest'] = true;
carolinan marked this conversation as resolved.
Show resolved Hide resolved
return $args;
}
);
1 change: 1 addition & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ function gutenberg_is_experiment_enabled( $name ) {
// WordPress 6.7 compat.
require __DIR__ . '/compat/wordpress-6.7/blocks.php';
require __DIR__ . '/compat/wordpress-6.7/block-bindings.php';
require __DIR__ . '/compat/wordpress-6.7/taxonomy.php';

// Experimental features.
require __DIR__ . '/experimental/block-editor-settings-mobile.php';
Expand Down
14 changes: 13 additions & 1 deletion packages/block-library/src/post-template/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,19 @@ export default function PostTemplateEdit( {
( { slug } ) => slug === taxonomySlug
);
if ( taxonomy?.rest_base ) {
accumulator[ taxonomy?.rest_base ] = terms;
// Convert post format term ID's to a comma separated string,
// otherwise the Rest API will return a "rest_invalid_param" error
// and there will be a PHP fatal error from _post_format_request.
if (
taxonomy.rest_base === 'post_format' &&
Array.isArray( terms ) &&
terms.length > 0
) {
accumulator[ taxonomy.rest_base ] =
terms.join( ',' );
} else {
accumulator[ taxonomy.rest_base ] = terms;
}
}
return accumulator;
},
Expand Down
Loading