PluginProbe
Polylang / 3.8
Polylang v3.8
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 / src / Model / Hide_Empty.php

Hide_Empty.php in Polylang 3.8, at src/Model/Hide_Empty.php

40 lines 781 B
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 namespace WP_Syntex\Polylang\Model;
7
8 /**
9 * Class to filter the list of languages to only include non-empty languages.
10 */
11 class Hide_Empty 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_empty';
21 }
22
23 /**
24 * Returns the list of non-empty 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[] Filtered languages.
30 */
31 public function filter( array $languages ): array {
32 return array_filter(
33 $languages,
34 static function ( $lang ) {
35 return $lang->get_tax_prop( 'language', 'count' ) > 0;
36 }
37 );
38 }
39 }
40