Skip to content

Commit

Permalink
Bring in 10up#2861 (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccahum authored Aug 5, 2022
1 parent ac032bd commit d655394
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function setup() {
add_filter( 'ep_indexable_post_types', [ $this, 'post_types' ], 10, 1 );
add_filter( 'ep_post_formatted_args', [ $this, 'exclude_protected_posts' ], 10, 2 );
add_filter( 'ep_search_post_return_args', [ $this, 'return_post_password' ] );
add_filter( 'ep_skip_autosave_sync', '__return_false' );
add_filter( 'ep_index_posts_args', [ $this, 'query_password_protected_posts' ] );
add_filter( 'ep_post_sync_args', [ $this, 'include_post_password' ], 10, 2 );

Expand Down
80 changes: 64 additions & 16 deletions includes/classes/Indexable/Post/SyncManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,22 @@ public function action_queue_meta_sync( $meta_id, $object_id, $meta_key, $meta_v
$indexable_post_statuses = $indexable->get_indexable_post_status();
$post_type = get_post_type( $object_id );

if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
// Bypass saving if doing autosave
// @codeCoverageIgnoreStart
return;
// @codeCoverageIgnoreEnd
/**
* Filter to whether skip a sync during autosave, defaults to true
*
* @hook ep_skip_autosave_sync
* @since 4.3.0
* @param {bool} $skip True means to disable sync for autosaves
* @param {string} $function Function applying filter
* @return {boolean} New value
*/
if ( apply_filters( 'ep_skip_autosave_sync', true, __FUNCTION__ ) ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
// Bypass saving if doing autosave
// @codeCoverageIgnoreStart
return;
// @codeCoverageIgnoreEnd
}
}

$post = get_post( $object_id );
Expand Down Expand Up @@ -166,9 +177,22 @@ public function action_queue_meta_sync( $meta_id, $object_id, $meta_key, $meta_v
public function action_edited_term( $term_id, $tt_id, $taxonomy ) {
global $wpdb;

if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
// Bypass saving if doing autosave
return;
/**
* Filter to whether skip a sync during autosave, defaults to true
*
* @hook ep_skip_autosave_sync
* @since 4.3.0
* @param {bool} $skip True means to disable sync for autosaves
* @param {string} $function Function applying filter
* @return {boolean} New value
*/
if ( apply_filters( 'ep_skip_autosave_sync', true, __FUNCTION__ ) ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
// Bypass saving if doing autosave
// @codeCoverageIgnoreStart
return;
// @codeCoverageIgnoreEnd
}
}

/**
Expand Down Expand Up @@ -271,9 +295,22 @@ public function action_set_object_terms( $object_id, $terms, $tt_ids, $taxonomy,
$indexable = Indexables::factory()->get( 'post' );
$post_type = get_post_type( $post_id );

if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
// Bypass saving if doing autosave
return;
/**
* Filter to whether skip a sync during autosave, defaults to true
*
* @hook ep_skip_autosave_sync
* @since 4.3.0
* @param {bool} $skip True means to disable sync for autosaves
* @param {string} $function Function applying filter
* @return {boolean} New value
*/
if ( apply_filters( 'ep_skip_autosave_sync', true, __FUNCTION__ ) ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
// Bypass saving if doing autosave
// @codeCoverageIgnoreStart
return;
// @codeCoverageIgnoreEnd
}
}

$post = get_post( $post_id );
Expand Down Expand Up @@ -377,11 +414,22 @@ public function action_sync_on_update( $post_id ) {
$indexable = Indexables::factory()->get( $this->indexable_slug );
$post_type = get_post_type( $post_id );

if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
// Bypass saving if doing autosave
// @codeCoverageIgnoreStart
return;
// @codeCoverageIgnoreEnd
/**
* Filter to whether skip a sync during autosave, defaults to true
*
* @hook ep_skip_autosave_sync
* @since 4.3.0
* @param {bool} $skip True means to disable sync for autosaves
* @param {string} $function Function applying filter
* @return {boolean} New value
*/
if ( apply_filters( 'ep_skip_autosave_sync', true, __FUNCTION__ ) ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
// Bypass saving if doing autosave
// @codeCoverageIgnoreStart
return;
// @codeCoverageIgnoreEnd
}
}

/**
Expand Down

0 comments on commit d655394

Please sign in to comment.