PluginProbe
Polylang / 3.7.1
Polylang v3.7.1
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
polylang / admin / admin-default-term.php

admin-default-term.php in Polylang 3.7.1, at admin/admin-default-term.php

49 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Polylang
4 */
5
6 /**
7 * Manages filters and actions related to default terms.
8 *
9 * @since 3.1
10 * @since 3.7 Extends `PLL_Default_Term`, most of the code is moved to it.
11 */
12 class PLL_Admin_Default_Term extends PLL_Default_Term {
13
14 /**
15 * Setups filters and actions needed.
16 *
17 * @since 3.1
18 *
19 * @return void
20 */
21 public function add_hooks() {
22 parent::add_hooks();
23
24 foreach ( $this->taxonomies as $taxonomy ) {
25 if ( 'category' === $taxonomy ) {
26 // Adds the language column in the 'Terms' table.
27 add_filter( 'pll_first_language_term_column', array( $this, 'first_language_column' ), 10, 2 );
28 }
29 }
30 }
31
32 /**
33 * Identifies the default term in the terms list table to disable the language dropdown in JS.
34 *
35 * @since 3.7
36 *
37 * @param string $out The output.
38 * @param int $term_id The term id.
39 * @return string The HTML string.
40 */
41 public function first_language_column( $out, $term_id ) {
42 if ( $this->is_default_term( $term_id ) ) {
43 $out .= sprintf( '<div class="hidden" id="default_cat_%1$d">%1$d</div>', intval( $term_id ) );
44 }
45
46 return $out;
47 }
48 }
49