Skip to content

Commit 39836c6

Browse files
committed
Remove the unused term resyncing functionality which hasn't been used since #106.
1 parent b9945e0 commit 39836c6

File tree

1 file changed

+0
-68
lines changed

1 file changed

+0
-68
lines changed

class-taxonomy.php

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public function __construct() {
4949
$this->add_action( 'init', 'init_early', 0 );
5050
$this->add_action( 'parse_request' );
5151
$this->add_action( 'registered_taxonomy', null, null, 3 );
52-
$this->add_action( 'save_post', null, null, 2 );
5352
$this->add_action( 'set_object_terms', null, null, 5 );
5453
$this->add_filter( 'get_terms' );
5554
$this->add_filter( 'term_link', null, null, 3 );
@@ -263,18 +262,6 @@ public function created_new_shadow_post( $new_post_id, $origin_post_id ) {
263262
$this->no_recursion = false;
264263
}
265264

266-
/**
267-
* Hooks the WP save_post action to resync data
268-
* when requested.
269-
*
270-
* @param int $post_id The ID of the WP post
271-
* @param object $post The WP Post object
272-
* @return void
273-
**/
274-
public function save_post( $post_id, $post ) {
275-
$this->maybe_resync_terms( $post_id, $post );
276-
}
277-
278265
/**
279266
* Hooks the WordPress term_link filter to provide functions to provide
280267
* appropriate links for the shadow taxonomies.
@@ -968,61 +955,6 @@ public function set_transid( $target_term_id, $transid = null ) {
968955
return $transid;
969956
}
970957

971-
/**
972-
* Checks for the relevant POSTed field, then
973-
* resyncs the terms.
974-
*
975-
* @param int $post_id The ID of the WP post
976-
* @param object $post The WP Post object
977-
* @return void
978-
**/
979-
protected function maybe_resync_terms( $post_id, $post ) {
980-
// Check that the fields were included on the screen, we
981-
// can do this by checking for the presence of the nonce.
982-
$nonce = isset( $_POST[ '_bbl_metabox_resync' ] ) ? $_POST[ '_bbl_metabox_resync' ] : false;
983-
984-
985-
if ( ! in_array( $post->post_status, array( 'draft', 'publish' ) ) ) {
986-
return;
987-
}
988-
989-
if ( ! $nonce ) {
990-
return;
991-
}
992-
993-
$posted_id = isset( $_POST[ 'post_ID' ] ) ? $_POST[ 'post_ID' ] : 0;
994-
if ( $posted_id != $post_id ) {
995-
return;
996-
}
997-
// While we're at it, let's check the nonce
998-
check_admin_referer( "bbl_resync_translation-$post_id", '_bbl_metabox_resync' );
999-
1000-
if ( $this->no_recursion ) {
1001-
return;
1002-
}
1003-
$this->no_recursion = true;
1004-
1005-
$taxonomies = get_object_taxonomies( $post->post_type );
1006-
$origin_post = bbl_get_post_in_lang( $post_id, bbl_get_default_lang_code() );
1007-
1008-
// First dissociate all the terms from synced taxonomies from this post
1009-
wp_delete_object_term_relationships( $post_id, $taxonomies );
1010-
1011-
// Now associate terms from synced taxonomies in from the origin post
1012-
foreach ( $taxonomies as $taxonomy ) {
1013-
$origin_taxonomy = $taxonomy;
1014-
if ( $this->is_taxonomy_translated( $taxonomy ) ) {
1015-
$origin_taxonomy = bbl_get_taxonomy_in_lang( $taxonomy, bbl_get_default_lang_code() );
1016-
}
1017-
$term_ids = wp_get_object_terms( $origin_post->ID, $origin_taxonomy, array( 'fields' => 'ids' ) );
1018-
$term_ids = array_map( 'absint', $term_ids );
1019-
$result = wp_set_object_terms( $post_id, $term_ids, $taxonomy );
1020-
if ( is_wp_error( $result, true ) ) {
1021-
throw new exception( "Problem syncing terms: " . print_r( $terms, true ), " Error: " . print_r( $result, true ) );
1022-
}
1023-
}
1024-
}
1025-
1026958
}
1027959

1028960
global $bbl_taxonomies;

0 commit comments

Comments
 (0)