| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Polylang |
| 4 |
*/ |
| 5 |
|
| 6 |
namespace WP_Syntex\Polylang\Model; |
| 7 |
|
| 8 |
/** |
| 9 |
* Class to filter the list of languages to only include non-default languages. |
| 10 |
*/ |
| 11 |
class Hide_Default implements Languages_Proxy_Interface { |
| 12 |
/** |
| 13 |
* Returns the proxy's key. |
| 14 |
* |
| 15 |
* @since 3.8 |
| 16 |
* |
| 17 |
* @return string |
| 18 |
*/ |
| 19 |
public function key(): string { |
| 20 |
return 'hide_default'; |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Returns the list of non-default languages after passing it through this proxy. |
| 25 |
* |
| 26 |
* @since 3.8 |
| 27 |
* |
| 28 |
* @param \PLL_Language[] $languages List of languages to filter. |
| 29 |
* @return \PLL_Language[] |
| 30 |
*/ |
| 31 |
public function filter( array $languages ): array { |
| 32 |
return array_filter( |
| 33 |
$languages, |
| 34 |
static function ( $lang ) { |
| 35 |
return ! $lang->is_default; |
| 36 |
} |
| 37 |
); |
| 38 |
} |
| 39 |
} |
| 40 |
|