| 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 |
|