| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Polylang |
| 4 |
*/ |
| 5 |
|
| 6 |
namespace WP_Syntex\Polylang\Switcher\Element; |
| 7 |
|
| 8 |
defined( 'ABSPATH' ) || exit; |
| 9 |
|
| 10 |
/** |
| 11 |
* Data representing an item. |
| 12 |
* |
| 13 |
* @since 3.9 |
| 14 |
*/ |
| 15 |
class Select extends Abstract_Element { |
| 16 |
/** |
| 17 |
* Returns the markup of a row. |
| 18 |
* |
| 19 |
* @since 3.9 |
| 20 |
* |
| 21 |
* @return string |
| 22 |
*/ |
| 23 |
public function get(): string { |
| 24 |
$item_atts = sprintf( |
| 25 |
'lang="%1$s" value="%2$s"%3$s', |
| 26 |
esc_attr( $this->locale ), |
| 27 |
esc_url( $this->url ), |
| 28 |
selected( $this->is_current, true, false ) |
| 29 |
); |
| 30 |
|
| 31 |
if ( ! empty( $this->item_classes ) ) { |
| 32 |
$item_atts .= sprintf( |
| 33 |
' class="%s"', |
| 34 |
esc_attr( implode( ' ', $this->item_classes ) ) |
| 35 |
); |
| 36 |
} |
| 37 |
|
| 38 |
$out = sprintf( |
| 39 |
'<option %s>%s</option>', |
| 40 |
$item_atts, |
| 41 |
$this->get_label() |
| 42 |
); |
| 43 |
|
| 44 |
if ( ! $this->settings->preserve_spacing ) { |
| 45 |
return $out; |
| 46 |
} |
| 47 |
|
| 48 |
return "\t{$out}\n"; |
| 49 |
} |
| 50 |
} |
| 51 |
|