Skip to content

Commit

Permalink
Added the proper functionality for post-id-based jobs to controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
RadoslavGeorgiev committed Apr 18, 2018
1 parent eb9c20b commit aff72a1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
19 changes: 18 additions & 1 deletion core/classes/Controller/Post_Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,27 @@ public function save_post( $post_id ) {

# Gather all post types
foreach( $combination[ 'locations' ] as $location ) {
$enqueue = false;

$post_types = $location->get_post_types();
$ids = $location->get_ids();
$parents = $location->get_parents();

# Check if the container is being saved
if( ! in_array( $post->post_type, $post_types ) ) {
if( ! empty( $post_types ) && ! in_array( $post->post_type, $post_types ) ) {
continue;
}

# Check for IDs
if( empty( $post_types ) && empty( $ids ) && empty( $parents ) ) {
continue;
}

if( ! empty( $ids ) && ! $location->check_single_value( $post_id, $ids ) ) {
continue;
}

if( ! empty( $parents ) && ! $location->check_single_value( $post_id, $parents ) ) {
continue;
}

Expand Down
12 changes: 12 additions & 0 deletions core/classes/Location/Post_Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,18 @@ public function works_with( $source ) {
return false;
}

if( ! empty( $this->ids ) ) {
return $this->check_single_value( $post->ID, $this->ids )
? $post
: false;
}

if( ! empty( $this->parents ) ) {
return $this->check_single_value( $post->ID, $this->parents )
? $post
: false;
}

# Check the post type
if( ! in_array( $post->post_type, $this->post_types ) ) {
return false;
Expand Down

0 comments on commit aff72a1

Please sign in to comment.