Skip to content

Commit 4a39cbb

Browse files
authored
Merge pull request #67 from s3rgiosan/feature/post-ui-query-filter
Additional filters for the Post UI queries
2 parents 33de81a + 73abab7 commit 4a39cbb

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

includes/UI/PostToPost.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public function filter_data( $data, $post ) {
2222
$final_posts = array();
2323

2424
$args = array(
25-
'post_type' => (array) $other_post_type,
25+
'post_type' => (array) $other_post_type,
2626
'relationship_query' => array(
27-
'name' => $this->relationship->name,
27+
'name' => $this->relationship->name,
2828
'related_to_post' => $post->ID,
2929
),
3030
);
@@ -33,14 +33,24 @@ public function filter_data( $data, $post ) {
3333
$args['orderby'] = 'relationship';
3434
}
3535

36+
/**
37+
* Filters the Post UI query args.
38+
*
39+
* @since 1.6.0
40+
* @param array $args The \WP_Query args.
41+
* @param \WP_Post $post The post object.
42+
* @return array
43+
*/
44+
$args = apply_filters( 'tenup_content_connect_post_ui_query_args', $args, $post );
45+
3646
$query = new \WP_Query( $args );
3747

3848
if ( $query->have_posts() ) {
3949
while ( $query->have_posts() ) {
4050
$post = $query->next_post();
4151

4252
$final_post = array(
43-
'ID' => $post->ID,
53+
'ID' => $post->ID,
4454
'name' => $post->post_title,
4555
);
4656

includes/UI/PostToUser.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function filter_data( $data, $post ) {
2020

2121
$args = array(
2222
'relationship_query' => array(
23-
'name' => $this->relationship->name,
23+
'name' => $this->relationship->name,
2424
'related_to_post' => $post->ID,
2525
),
2626
);
@@ -29,14 +29,24 @@ public function filter_data( $data, $post ) {
2929
$args['orderby'] = 'relationship';
3030
}
3131

32+
/**
33+
* Filters the Post UI user query args.
34+
*
35+
* @since 1.6.0
36+
* @param array $args The \WP_User_Query args.
37+
* @param \WP_Post $post The post object.
38+
* @return array
39+
*/
40+
$args = apply_filters( 'tenup_content_connect_post_ui_user_query_args', $args, $post );
41+
3242
$query = new \WP_User_Query( $args );
3343

3444
$users = $query->get_results();
3545
if ( ! empty( $users ) ) {
3646
foreach ( $users as $user ) {
3747

3848
$final_user = array(
39-
'ID' => $user->ID,
49+
'ID' => $user->ID,
4050
'name' => $user->display_name,
4151
);
4252

0 commit comments

Comments
 (0)