| @@ -54,19 +54,8 @@ | ||
| 54 | 54 | add_action( "pll_save_{$this->meta_type}", array( $this, 'save_object' ), 10, 3 ); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | - * Removes "added_{$this->meta_type}_meta" action | |
| 59 | - * | |
| 60 | - * @since 2.3 | |
| 61 | - * | |
| 62 | - * @return void | |
| 63 | - */ | |
| 64 | - protected function remove_add_meta_action() { | |
| 65 | - remove_action( "added_{$this->meta_type}_meta", array( $this, 'add_meta' ) ); | |
| 66 | - } | |
| 67 | - | |
| 68 | - /** | |
| 69 | 58 | * Removes all meta synchronization actions and filters |
| 70 | 59 | * |
| 71 | 60 | * @since 2.3 |
| 72 | 61 | * |
| @@ -72,9 +61,9 @@ | ||
| 72 | 61 | * |
| 73 | 62 | * @return void |
| 74 | 63 | */ |
| 75 | 64 | public function remove_all_meta_actions() { |
| 76 | - $this->remove_add_meta_action(); | |
| 65 | + remove_action( "added_{$this->meta_type}_meta", array( $this, 'add_meta' ) ); | |
| 77 | 66 | |
| 78 | 67 | remove_filter( "update_{$this->meta_type}_metadata", array( $this, 'update_metadata' ), 999 ); |
| 79 | 68 | remove_action( "update_{$this->meta_type}_meta", array( $this, 'update_meta' ) ); |
| 80 | 69 | |
| @@ -82,19 +71,8 @@ | ||
| 82 | 71 | remove_action( "deleted_{$this->meta_type}_meta", array( $this, 'delete_meta' ) ); |
| 83 | 72 | } |
| 84 | 73 | |
| 85 | 74 | /** |
| 86 | - * Adds "added_{$this->meta_type}_meta" action | |
| 87 | - * | |
| 88 | - * @since 2.3 | |
| 89 | - * | |
| 90 | - * @return void | |
| 91 | - */ | |
| 92 | - protected function restore_add_meta_action() { | |
| 93 | - add_action( "added_{$this->meta_type}_meta", array( $this, 'add_meta' ), 10, 4 ); | |
| 94 | - } | |
| 95 | - | |
| 96 | - /** | |
| 97 | 75 | * Adds meta synchronization actions and filters |
| 98 | 76 | * |
| 99 | 77 | * @since 2.3 |
| 100 | 78 | * |
| @@ -100,9 +78,9 @@ | ||
| 100 | 78 | * |
| 101 | 79 | * @return void |
| 102 | 80 | */ |
| 103 | 81 | public function add_all_meta_actions() { |
| 104 | - $this->restore_add_meta_action(); | |
| 82 | + add_action( "added_{$this->meta_type}_meta", array( $this, 'add_meta' ), 10, 4 ); | |
| 105 | 83 | |
| 106 | 84 | add_filter( "update_{$this->meta_type}_metadata", array( $this, 'update_metadata' ), 999, 5 ); // Very late in case a filter prevents the meta to be updated |
| 107 | 85 | add_action( "update_{$this->meta_type}_meta", array( $this, 'update_meta' ), 10, 4 ); |
| 108 | 86 | |
| @@ -263,9 +241,9 @@ | ||
| 263 | 241 | |
| 264 | 242 | $prev_meta = get_metadata_by_mid( $this->meta_type, $mid ); |
| 265 | 243 | |
| 266 | 244 | if ( $prev_meta ) { |
| 267 | - $this->remove_add_meta_action(); // We don't want to sync back the new metas | |
| 245 | + $this->remove_all_meta_actions(); // We don't want to sync back the new metas | |
| 268 | 246 | $tr_ids = $this->model->{$this->meta_type}->get_translations( $id ); |
| 269 | 247 | |
| 270 | 248 | foreach ( $tr_ids as $lang => $tr_id ) { |
| 271 | 249 | if ( $tr_id != $id && in_array( $meta_key, $this->get_metas_to_copy( $id, $tr_id, $lang, true ) ) ) { |
| @@ -275,12 +253,11 @@ | ||
| 275 | 253 | update_metadata( $this->meta_type, $tr_id, wp_slash( $meta_key ), is_object( $meta_value ) ? $meta_value : wp_slash( $meta_value ), $prev_value ); |
| 276 | 254 | } |
| 277 | 255 | } |
| 278 | 256 | } |
| 279 | - $this->restore_add_meta_action(); | |
| 257 | + $this->add_all_meta_actions(); | |
| 280 | 258 | } |
| 281 | 259 | |
| 282 | - unset( $this->prev_value[ $hash ] ); | |
| 283 | 260 | $avoid_recursion = false; |
| 284 | 261 | } |
| 285 | 262 | } |
| 286 | 263 | |