WPSEO_Taxonomy_Fields

Class WPSEO_Taxonomy_Tab.

Defined (1)

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

/admin/taxonomy/class-taxonomy-fields.php  
  1. abstract class WPSEO_Taxonomy_Fields { 
  2.  
  3. /** 
  4. * The Yoast SEO configuration from the WPSEO_Options 
  5. * @var array 
  6. */ 
  7. protected $options = array(); 
  8.  
  9. /** 
  10. * The current term data 
  11. * @var stdClass 
  12. */ 
  13. protected $term; 
  14.  
  15. /** 
  16. * Setting the class properties 
  17. * @param stdClass $term The current term. 
  18. * @param array $options The options. 
  19. */ 
  20. public function __construct( $term, array $options = null ) { 
  21. $this->term = $term; 
  22. if ( $options !== null ) { 
  23. $this->options = $options; 
  24. else { 
  25. $this->options = WPSEO_Options::get_options( array( 
  26. 'wpseo_titles',  
  27. 'wpseo_internallinks',  
  28. 'wpseo_social',  
  29. ) ); 
  30.  
  31. /** 
  32. * This method should return the fields 
  33. * @return array 
  34. */ 
  35. abstract public function get(); 
  36.  
  37. /** 
  38. * Returns array with the field data 
  39. * @param string $label The label displayed before the field. 
  40. * @param string $description Description which will explain the field. 
  41. * @param string $type The field type, for example: input, select. 
  42. * @param string|array $options Optional. Array with additional options. 
  43. * @param bool $hide Should the field be hidden. 
  44. * @return array 
  45. */ 
  46. protected function get_field_config( $label, $description, $type = 'text', $options = '', $hide = false ) { 
  47. return array( 
  48. 'label' => $label,  
  49. 'description' => $description,  
  50. 'type' => $type,  
  51. 'options' => $options,  
  52. 'hide' => $hide,  
  53. ); 
  54.  
  55. /** 
  56. * Filter the hidden fields. 
  57. * @param array $fields Array with the form fields that has will be filtered. 
  58. * @return array 
  59. */ 
  60. protected function filter_hidden_fields( array $fields ) { 
  61. foreach ( $fields as $field_name => $field_options ) { 
  62. if ( ! empty( $field_options['hide'] ) ) { 
  63. unset( $fields[ $field_name ] ); 
  64.  
  65. return $fields;