Skip to content

Commit ca791ef

Browse files
committed
Pass $query to customize_object_selector_result
Since $query is a superset of $post_query_args it is more useful as context. Also add phpdoc for filter.
1 parent 38a6610 commit ca791ef

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

php/class-plugin.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ public function query_posts( $post_query_args ) {
598598
$is_multiple_post_types = count( $query->get( 'post_type' ) ) > 1;
599599

600600
$results = array_map(
601-
function( $post ) use ( $is_multiple_post_types, $post_query_args ) {
601+
function( $post ) use ( $is_multiple_post_types, $post_query_args, $query ) {
602602
$title = htmlspecialchars_decode( html_entity_decode( $post->post_title ), ENT_QUOTES );
603603
$post_type_obj = get_post_type_object( $post->post_type );
604604
$post_status_obj = get_post_status_object( $post->post_status );
@@ -641,7 +641,16 @@ function( $post ) use ( $is_multiple_post_types, $post_query_args ) {
641641
$result['featured_image'] = null;
642642
}
643643
}
644-
return apply_filters( 'customize_object_selector_result', $result, $post, $post_query_args );
644+
645+
/**
646+
* Filters a result from querying posts for the customize object selector component.
647+
*
648+
* @param array $result Result returned to Select2.
649+
* @param \WP_Post $post Post.
650+
* @param \WP_Query $query Query.
651+
*/
652+
$result = apply_filters( 'customize_object_selector_result', $result, $post, $query );
653+
return $result;
645654
},
646655
$query->posts
647656
);

0 commit comments

Comments
 (0)