PluginProbe
Polylang / trunk
Polylang vtrunk
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 / Switcher / Element / Select.php

Select.php in Polylang trunk, at src/Switcher/Element/Select.php

51 lines 831 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\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