Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync: Don't sync set object terms action for blacklisted taxonomies #39663

Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Sync: Ensure we don't sync set_object_terms action for terms with blacklisted taxonomies
8 changes: 6 additions & 2 deletions projects/packages/sync/src/modules/class-terms.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,16 @@ public function filter_blacklisted_taxonomies( $args ) {
}

/**
* Filter out set_object_terms actions where the terms have not changed.
* Filter out set_object_terms actions with blacklisted taxonomies or where the terms have not changed.
*
* @param array $args Hook args.
* @return array|boolean False if no change in terms, the original hook args otherwise.
* @return array|boolean False if blacklisted taxonomy or no change in terms, the original hook args otherwise.
*/
public function filter_set_object_terms_no_update( $args ) {
// Check if the taxonomy is blacklisted. $args[3] is the taxonomy.
if ( isset( $args[3] ) && in_array( $args[3], Settings::get_setting( 'taxonomies_blacklist' ), true ) ) {
return false;
}
// There is potential for other plugins to modify args, therefore lets validate # of and types.
// $args[2] is $tt_ids, $args[5] is $old_tt_ids see wp-includes/taxonomy.php L2740.
if ( 6 === count( $args ) && is_array( $args[2] ) && is_array( $args[5] ) ) {
Expand Down
Loading