Skip to content
Merged
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
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;

}

}