class-field-choice.php
912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Choice
*/
class WPSEO_Config_Field_Choice extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Choice constructor.
*
* @param string $field Field name to use.
*/
public function __construct( $field ) {
parent::__construct( $field, 'Choice' );
$this->properties['choices'] = array();
}
/**
* Add a choice to the properties
*
* @param string $value Value op the option.
* @param string $label Label to display for the value.
* @param string $screen_reader_text Optional. Screenreader text to use.
*/
public function add_choice( $value, $label, $screen_reader_text = '' ) {
$choice = array(
'label' => $label,
);
if ( $screen_reader_text ) {
$choice['screenReaderText'] = $screen_reader_text;
}
$this->properties['choices'][ $value ] = $choice;
}
}