WPSEO_Config_Field

Class WPSEO_Config_Field.

Defined (1)

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

/admin/config-ui/fields/class-field.php  
  1. class WPSEO_Config_Field { 
  2. /** @var string Field name */ 
  3. protected $field; 
  4.  
  5. /** @var string Component to use */ 
  6. protected $component; 
  7.  
  8. /** @var array Properties of this field */ 
  9. protected $properties = array(); 
  10.  
  11. /** @var array Field requirements */ 
  12. protected $requires = array(); 
  13.  
  14. /** @var array|mixed Value of this field */ 
  15. protected $data = array(); 
  16.  
  17. /** 
  18. * WPSEO_Config_Field constructor. 
  19. * @param string $field The field name. 
  20. * @param string $component The component to use. 
  21. */ 
  22. public function __construct( $field, $component ) { 
  23. $this->field = $field; 
  24. $this->component = $component; 
  25.  
  26. /** 
  27. * Get the identifier 
  28. * @return string 
  29. */ 
  30. public function get_identifier() { 
  31. return $this->field; 
  32.  
  33. /** 
  34. * Get the component 
  35. * @return string 
  36. */ 
  37. public function get_component() { 
  38. return $this->component; 
  39.  
  40. /** 
  41. * Set a property value 
  42. * @param string $name Property to set. 
  43. * @param mixed $value Value to apply. 
  44. */ 
  45. public function set_property( $name, $value ) { 
  46. $this->properties[ $name ] = $value; 
  47.  
  48. /** 
  49. * Get all the properties 
  50. * @return array 
  51. */ 
  52. public function get_properties() { 
  53. return $this->properties; 
  54.  
  55. /** 
  56. * Get the data 
  57. * @return mixed 
  58. */ 
  59. public function get_data() { 
  60. return $this->data; 
  61.  
  62. /** 
  63. * Array representation of this object. 
  64. * @return array 
  65. */ 
  66. public function to_array() { 
  67. $output = array( 
  68. 'componentName' => $this->get_component(),  
  69. ); 
  70.  
  71. $properties = $this->get_properties(); 
  72. if ( $properties ) { 
  73. $output['properties'] = $properties; 
  74.  
  75. $requires = $this->get_requires(); 
  76. if ( ! empty( $requires ) ) { 
  77. $output['requires'] = $requires; 
  78.  
  79. return $output; 
  80.  
  81. /** 
  82. * Set the adapter to use 
  83. * @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on. 
  84. */ 
  85. public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) { 
  86.  
  87. /** 
  88. * Requires another field to have a certain value. 
  89. * @param string $field Field to check for a certain value. 
  90. * @param mixed $value Value of the field. 
  91. */ 
  92. public function set_requires( $field, $value ) { 
  93. $this->requires = array( 
  94. 'field' => $field,  
  95. 'value' => $value,  
  96. ); 
  97.  
  98. /** 
  99. * Get the required field settings (if present) 
  100. * @return array 
  101. */ 
  102. public function get_requires() { 
  103. return $this->requires;