WPSEO_Config_Field_Choice

Class WPSEO_Config_Field_Choice.

Defined (1)

The class is defined in the following location(s).

/admin/config-ui/fields/class-field-choice.php  
  1. class WPSEO_Config_Field_Choice extends WPSEO_Config_Field { 
  2.  
  3. /** 
  4. * WPSEO_Config_Field_Choice constructor. 
  5. * @param string $field Field name to use. 
  6. */ 
  7. public function __construct( $field ) { 
  8. parent::__construct( $field, 'Choice' ); 
  9.  
  10. $this->properties['choices'] = array(); 
  11.  
  12. /** 
  13. * Add a choice to the properties 
  14. * @param string $value Value op the option. 
  15. * @param string $label Label to display for the value. 
  16. * @param string $screen_reader_text Optional. Screenreader text to use. 
  17. */ 
  18. public function add_choice( $value, $label, $screen_reader_text = '' ) { 
  19. $choice = array( 
  20. 'label' => $label,  
  21. ); 
  22.  
  23. if ( $screen_reader_text ) { 
  24. $choice['screenReaderText'] = $screen_reader_text; 
  25.  
  26. $this->properties['choices'][ $value ] = $choice;