Skip to content

Commit 44369fd

Browse files
author
David Leal
authored
Merge pull request #57 from CodeProKid/CI-5582
CI-5582 additions
2 parents 976efee + ec6ef83 commit 44369fd

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

src/Register.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public function setup() {
2121
add_filter( 'option_jetpack_sync_settings_post_types_blacklist', [ $this, 'blacklist_post_type' ] );
2222
add_filter( 'default_option_jetpack_sync_settings_post_types_blacklist', [ $this, 'blacklist_post_type' ] );
2323

24+
// Performance improvement for VIP
25+
add_filter( 'wpcom_async_transition_post_status_schedule_async', [ $this, 'disable_post_transition' ], 10, 2 );
26+
2427
}
2528

2629
/**
@@ -130,12 +133,36 @@ public function register_post_type() {
130133
* @access public
131134
*/
132135
public function blacklist_post_type( $post_types ) {
133-
if ( is_array( $post_types ) ) {
134-
$post_types[] = 'wpqt-task';
135-
} else {
136-
$post_types = [ 'wpqt-task' ];
136+
if ( ! is_array( $post_types ) ) {
137+
$post_types = [];
137138
}
139+
140+
$post_types[] = 'wpqt-task';
141+
138142
return $post_types;
139143
}
140144

145+
/**
146+
* Disables the post transition cron event for the wpqt-task post type on WordPress VIP
147+
*
148+
* @param bool $value Whether or not to run the event
149+
* @param array $args The arguments normally going to the cron event
150+
*
151+
* @return bool
152+
* @access public
153+
*/
154+
public function disable_post_transition( $value, $args ) {
155+
156+
if ( empty( $args['post_id'] ) ) {
157+
return $value;
158+
}
159+
160+
if ( 'wpqt-task' === get_post_type( absint( $args['post_id'] ) ) ) {
161+
$value = false;
162+
}
163+
164+
return $value;
165+
166+
}
167+
141168
}

0 commit comments

Comments
 (0)