Skip to content

Commit

Permalink
Merge pull request #57 from CodeProKid/CI-5582
Browse files Browse the repository at this point in the history
CI-5582 additions
  • Loading branch information
David Leal authored Sep 6, 2018
2 parents 976efee + ec6ef83 commit 44369fd
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions src/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public function setup() {
add_filter( 'option_jetpack_sync_settings_post_types_blacklist', [ $this, 'blacklist_post_type' ] );
add_filter( 'default_option_jetpack_sync_settings_post_types_blacklist', [ $this, 'blacklist_post_type' ] );

// Performance improvement for VIP
add_filter( 'wpcom_async_transition_post_status_schedule_async', [ $this, 'disable_post_transition' ], 10, 2 );

}

/**
Expand Down Expand Up @@ -130,12 +133,36 @@ public function register_post_type() {
* @access public
*/
public function blacklist_post_type( $post_types ) {
if ( is_array( $post_types ) ) {
$post_types[] = 'wpqt-task';
} else {
$post_types = [ 'wpqt-task' ];
if ( ! is_array( $post_types ) ) {
$post_types = [];
}

$post_types[] = 'wpqt-task';

return $post_types;
}

/**
* Disables the post transition cron event for the wpqt-task post type on WordPress VIP
*
* @param bool $value Whether or not to run the event
* @param array $args The arguments normally going to the cron event
*
* @return bool
* @access public
*/
public function disable_post_transition( $value, $args ) {

if ( empty( $args['post_id'] ) ) {
return $value;
}

if ( 'wpqt-task' === get_post_type( absint( $args['post_id'] ) ) ) {
$value = false;
}

return $value;

}

}

0 comments on commit 44369fd

Please sign in to comment.