Skip to content

Commit

Permalink
Sync: Don't sync set object terms action for blacklisted taxonomies (#…
Browse files Browse the repository at this point in the history
…39663)

* Filter out set_object_terms actions with blacklisted taxonomies

* Args in this flow does not have the terms retrieved as objects. Instead we rely directly on the taxonomy

* changelog

* Update projects/packages/sync/src/modules/class-terms.php

Co-authored-by: Foteini Giannaropoulou <[email protected]>

---------

Co-authored-by: Foteini Giannaropoulou <[email protected]>
  • Loading branch information
darssen and fgiannar authored Oct 8, 2024
1 parent 061b353 commit 70eae9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

0 comments on commit 70eae9f

Please sign in to comment.