PluginProbe
Polylang / 2.6.3
Polylang v2.6.3
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | admin/admin-filters-term.php +25 -38 2.7.42.6.3 View file →
@@ -78,9 +78,8 @@
78 78 $dropdown = new PLL_Walker_Dropdown();
79 79
80 80 $dropdown_html = $dropdown->walk(
81 81 $this->model->get_languages_list(),
82 - -1,
83 82 array(
84 83 'name' => 'term_lang_choice',
85 84 'value' => 'term_id',
86 85 'selected' => $lang ? $lang->term_id : '',
@@ -132,10 +131,10 @@
132 131 if ( ! post_type_exists( $post_type ) ) {
133 132 return;
134 133 }
135 134
136 - $term_id = $tag->term_id;
137 - $taxonomy = $tag->taxonomy; // phpcs:ignore WordPressVIPMinimum.Variables.VariableAnalysis.UnusedVariable
135 + $term_id = $tag->term_id;
136 + $taxonomy = $tag->taxonomy;
138 137
139 138 $lang = $this->model->term->get_language( $term_id );
140 139 $lang = empty( $lang ) ? $this->pref_lang : $lang;
141 140
@@ -145,9 +144,8 @@
145 144 $dropdown = new PLL_Walker_Dropdown();
146 145
147 146 $dropdown_html = $dropdown->walk(
148 147 $this->model->get_languages_list(),
149 - -1,
150 148 array(
151 149 'name' => 'term_lang_choice',
152 150 'value' => 'term_id',
153 151 'selected' => $lang ? $lang->term_id : '',
@@ -270,12 +268,10 @@
270 268 );
271 269
272 270 // If we have several terms with the same name, they are translations of each other
273 271 if ( count( $terms ) > 1 ) {
274 - $translations = array();
275 -
276 272 foreach ( $terms as $term ) {
277 - $translations[ $this->model->term->get_language( $term->term_id )->slug ] = $term->term_id;
273 + $translations[ $this->model->term->get_language( $term->term_id )->slug ] = $term->term_id;
278 274 }
279 275
280 276 $this->model->term->save_translations( $term_id, $translations );
281 277 }
@@ -369,9 +365,9 @@
369 365 if ( current_user_can( $tax->cap->edit_terms ) || ( isset( $_POST['tax_input'][ $taxonomy ] ) && current_user_can( $tax->cap->assign_terms ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
370 366 $this->save_language( $term_id, $taxonomy );
371 367
372 368 if ( isset( $_POST['term_tr_lang'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
373 - $this->save_translations( $term_id );
369 + $translations = $this->save_translations( $term_id );
374 370 }
375 371 }
376 372 }
377 373
@@ -434,11 +430,11 @@
434 430 if ( ! isset( $_POST['taxonomy'], $_POST['post_type'], $_POST['lang'] ) ) {
435 431 wp_die( 0 );
436 432 }
437 433
438 - $lang = $this->model->get_language( sanitize_key( $_POST['lang'] ) );
439 - $term_id = isset( $_POST['term_id'] ) ? (int) $_POST['term_id'] : null; // phpcs:ignore WordPressVIPMinimum.Variables.VariableAnalysis.UnusedVariable
440 - $taxonomy = sanitize_key( $_POST['taxonomy'] ); // phpcs:ignore WordPressVIPMinimum.Variables.VariableAnalysis.UnusedVariable
434 + $lang = $this->model->get_language( sanitize_key( $_POST['lang'] ) );
435 + $term_id = isset( $_POST['term_id'] ) ? (int) $_POST['term_id'] : null;
436 + $taxonomy = sanitize_key( $_POST['taxonomy'] );
441 437 $post_type = sanitize_key( $_POST['post_type'] );
442 438
443 439 if ( ! post_type_exists( $post_type ) || ! taxonomy_exists( $taxonomy ) ) {
444 440 wp_die( 0 );
@@ -503,9 +499,9 @@
503 499 }
504 500
505 501 $s = wp_unslash( $_GET['term'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
506 502 $post_type = sanitize_key( $_GET['post_type'] );
507 - $taxonomy = sanitize_key( $_GET['taxonomy'] );
503 + $taxonomy = sanitize_key( $_GET['taxonomy'] );
508 504
509 505 if ( ! post_type_exists( $post_type ) || ! taxonomy_exists( $taxonomy ) ) {
510 506 wp_die( 0 );
511 507 }
@@ -512,42 +508,34 @@
512 508
513 509 $term_language = $this->model->get_language( sanitize_key( $_GET['term_language'] ) );
514 510 $translation_language = $this->model->get_language( sanitize_key( $_GET['translation_language'] ) );
515 511
516 - $terms = array();
517 512 $return = array();
518 513
519 - // Add current translation in list.
520 - // Not in add term as term_id is not set.
521 - if ( isset( $_GET['term_id'] ) && 'undefined' !== $_GET['term_id'] && $term_id = $this->model->term->get_translation( (int) $_GET['term_id'], $translation_language ) ) {
522 - $terms = array( get_term( $term_id, $taxonomy ) );
523 - }
524 -
525 - // It is more efficient to use one common query for all languages as soon as there are more than 2.
514 + // It is more efficient to use one common query for all languages as soon as there are more than 2
526 515 foreach ( get_terms( $taxonomy, 'hide_empty=0&lang=0&name__like=' . $s ) as $term ) {
527 516 $lang = $this->model->term->get_language( $term->term_id );
528 517
529 518 if ( $lang && $lang->slug == $translation_language->slug && ! $this->model->term->get_translation( $term->term_id, $term_language ) ) {
530 - $terms[] = $term;
519 + $return[] = array(
520 + 'id' => $term->term_id,
521 + 'value' => $term->name,
522 + 'link' => $this->links->edit_term_translation_link( $term->term_id, $taxonomy, $post_type ),
523 + );
531 524 }
532 525 }
533 526
534 - // Format the ajax response.
535 - foreach ( $terms as $term ) {
536 - $return[] = array(
537 - 'id' => $term->term_id,
538 - 'value' => rtrim( // Trim the seperator added at the end by WP.
539 - get_term_parents_list(
540 - $term->term_id,
541 - $term->taxonomy,
542 - array(
543 - 'separator' => ' > ',
544 - 'link' => false,
545 - )
546 - ),
547 - ' >'
548 - ),
549 - 'link' => $this->links->edit_term_translation_link( $term->term_id, $term->taxonomy, $post_type ),
527 + // Add current translation in list
528 + // Not in add term as term_id is not set
529 + if ( isset( $_GET['term_id'] ) && 'undefined' !== $_GET['term_id'] && $term_id = $this->model->term->get_translation( (int) $_GET['term_id'], $translation_language ) ) {
530 + $term = get_term( $term_id, $taxonomy );
531 + array_unshift(
532 + $return,
533 + array(
534 + 'id' => $term_id,
535 + 'value' => $term->name,
536 + 'link' => $this->links->edit_term_translation_link( $term->term_id, $taxonomy, $post_type ),
537 + )
550 538 );
551 539 }
552 540
553 541 wp_die( wp_json_encode( $return ) );
@@ -616,9 +604,8 @@
616 604 }
617 605
618 606 $avoid_recursion = true;
619 607 $lang = $this->model->term->get_language( $term_id );
620 - $translations = array();
621 608
622 609 foreach ( $this->model->term->get_translations( $term_id ) as $key => $tr_id ) {
623 610 if ( $lang->slug == $key ) {
624 611 $translations[ $key ] = $new_term_id;