PluginProbe
Polylang / trunk
Polylang vtrunk
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 | src/admin/admin-filters-term.php +22 -20 3.8.9 → trunk View file →
@@ -73,10 +73,10 @@
73 73 // Adds the language field and translations tables in the 'Edit Category' and 'Edit Tag' panels
74 74 add_action( $tax . '_edit_form_fields', array( $this, 'edit_term_form' ) );
75 75 }
76 76
77 - // Adds actions related to languages when creating or saving categories and post tags
78 - add_filter( 'wp_dropdown_cats', array( $this, 'wp_dropdown_cats' ) );
77 + // Adds actions related to languages when creating or saving categories and post tags.
78 + add_filter( 'taxonomy_parent_dropdown_args', array( $this, 'taxonomy_parent_dropdown_args' ), 10, 3 );
79 79 add_action( 'create_term', array( $this, 'save_term' ), 900, 3 );
80 80 add_action( 'edit_term', array( $this, 'save_term' ), 900, 3 ); // Late as it may conflict with other plugins, see http://wordpress.org/support/topic/polylang-and-wordpress-seo-by-yoast
81 81 add_action( 'pre_post_update', array( $this, 'pre_post_update' ) );
82 82 add_filter( 'pll_inserted_term_language', array( $this, 'get_inserted_term_language' ) );
@@ -221,31 +221,33 @@
221 221 echo '</tr>' . "\n";
222 222 }
223 223
224 224 /**
225 - * Translates term parent if exists when using "Add new" ( translation )
225 + * Translates the term parent if it exists when using "Add new".
226 226 *
227 - * @since 0.7
227 + * @since 3.9
228 228 *
229 - * @param string $output html markup for dropdown list of categories
230 - * @return string modified html
229 + * @param array $args The taxonomy parent dropdown arguments.
230 + * @param string $taxonomy The taxonomy name.
231 + * @param string $context The filter context, 'new' or 'edit'.
232 + * @return array
231 233 */
232 - public function wp_dropdown_cats( $output ) {
233 - if ( isset( $_GET['taxonomy'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
234 - $taxonomy = sanitize_key( $_GET['taxonomy'] ); // phpcs:ignore WordPress.Security.NonceVerification
234 + public function taxonomy_parent_dropdown_args( $args, $taxonomy, $context ) {
235 + if ( ! isset( $_GET['from_tag'], $_GET['new_lang'] ) || 'new' !== $context ) { // phpcs:ignore WordPress.Security.NonceVerification
236 + return $args;
235 237 }
236 238
237 - if ( isset( $taxonomy, $_GET['from_tag'], $_GET['new_lang'] ) && taxonomy_exists( $taxonomy ) ) { // phpcs:ignore WordPress.Security.NonceVerification
238 - $term = get_term( (int) $_GET['from_tag'], $taxonomy ); // phpcs:ignore WordPress.Security.NonceVerification
239 + $term = get_term( (int) $_GET['from_tag'], $taxonomy ); // phpcs:ignore WordPress.Security.NonceVerification
239 240
240 - if ( $term instanceof WP_Term && $id = $term->parent ) {
241 - $lang = $this->model->get_language( sanitize_key( $_GET['new_lang'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
242 - if ( $parent = $this->model->term->get_translation( $id, $lang ) ) {
243 - return str_replace( '"' . $parent . '"', '"' . $parent . '" selected="selected"', $output );
244 - }
245 - }
241 + if ( ! $term instanceof WP_Term || ! $term->parent ) {
242 + return $args;
246 243 }
247 - return $output;
244 +
245 + $lang = $this->model->get_language( sanitize_key( $_GET['new_lang'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
246 +
247 + $args['selected'] = $this->model->term->get_translation( $term->parent, $lang );
248 +
249 + return $args;
248 250 }
249 251
250 252 /**
251 253 * Stores the current post_id when bulk editing posts for use in save_language and get_inserted_term_language.
@@ -506,9 +508,9 @@
506 508 }
507 509 }
508 510
509 511 // Flag
510 - $x->Add( array( 'what' => 'flag', 'data' => empty( $lang->flag ) ? esc_html( $lang->slug ) : $lang->flag ) );
512 + $x->Add( array( 'what' => 'flag', 'data' => $lang->get_admin_flag( 'aria-hidden' ) ) );
511 513
512 514 $x->send();
513 515 }
514 516
@@ -584,9 +586,9 @@
584 586 'link' => $this->links->get_edit_term_link_html( $term, $post_type ),
585 587 );
586 588 }
587 589
588 - wp_die( wp_json_encode( $return ) );
590 + wp_die( wp_json_encode( $return ) ?: '[]' );
589 591 }
590 592
591 593 /**
592 594 * Updates the translations term ids when splitting a shared term