/admin/config-ui/fields/class-field-choice.php

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