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

Additional filters for the Post UI queries #67

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 13 additions & 3 deletions includes/UI/PostToPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public function filter_data( $data, $post ) {
$final_posts = array();

$args = array(
'post_type' => (array) $other_post_type,
'post_type' => (array) $other_post_type,
'relationship_query' => array(
'name' => $this->relationship->name,
'name' => $this->relationship->name,
'related_to_post' => $post->ID,
),
);
Expand All @@ -33,14 +33,24 @@ public function filter_data( $data, $post ) {
$args['orderby'] = 'relationship';
}

/**
* Filters the Post UI query args.
*
* @since 1.6.0
* @param array $args The \WP_Query args.
* @param \WP_Post $post The post object.
* @return array
*/
$args = apply_filters( 'tenup_content_connect_post_ui_query_args', $args, $post );

$query = new \WP_Query( $args );

if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$post = $query->next_post();

$final_post = array(
'ID' => $post->ID,
'ID' => $post->ID,
'name' => $post->post_title,
);

Expand Down
14 changes: 12 additions & 2 deletions includes/UI/PostToUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function filter_data( $data, $post ) {

$args = array(
'relationship_query' => array(
'name' => $this->relationship->name,
'name' => $this->relationship->name,
'related_to_post' => $post->ID,
),
);
Expand All @@ -29,14 +29,24 @@ public function filter_data( $data, $post ) {
$args['orderby'] = 'relationship';
}

/**
* Filters the Post UI user query args.
*
* @since 1.6.0
* @param array $args The \WP_User_Query args.
* @param \WP_Post $post The post object.
* @return array
*/
$args = apply_filters( 'tenup_content_connect_post_ui_user_query_args', $args, $post );

$query = new \WP_User_Query( $args );

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

$final_user = array(
'ID' => $user->ID,
'ID' => $user->ID,
'name' => $user->display_name,
);

Expand Down