WPSEO_Taxonomy_Settings_Fields

This class parses all the values for the general tab in the Yoast SEO settings metabox.

Defined (1)

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

/admin/taxonomy/class-taxonomy-settings-fields.php  
  1. class WPSEO_Taxonomy_Settings_Fields extends WPSEO_Taxonomy_Fields { 
  2.  
  3. /** 
  4. * @var array Options array for the no-index options, including translated labels 
  5. */ 
  6. private $no_index_options = array(); 
  7.  
  8. /** 
  9. * @var array Options array for the sitemap_include options, including translated labels 
  10. */ 
  11. private $sitemap_include_options = array(); 
  12.  
  13. /** 
  14. * @param stdClass $term The currenct taxonomy. 
  15. */ 
  16. public function __construct( $term ) { 
  17. parent::__construct( $term ); 
  18. $this->translate_meta_options(); 
  19.  
  20. /** 
  21. * Returns array with the fields for the general tab 
  22. * @return array 
  23. */ 
  24. public function get() { 
  25. $fields = array( 
  26. 'metakey' => $this->get_field_config( 
  27. __( 'Meta keywords', 'wordpress-seo' ),  
  28. esc_html__( 'Meta keywords used on the archive page for this term.', 'wordpress-seo' ),  
  29. 'text',  
  30. '',  
  31. $this->options['usemetakeywords'] !== true 
  32. ),  
  33. 'noindex' => $this->get_field_config( 
  34. esc_html__( 'Meta robots index', 'wordpress-seo' ),  
  35. esc_html__( 'This taxonomy follows the indexation rules set under Metas and Titles, you can override it here.', 'wordpress-seo' ),  
  36. 'select',  
  37. $this->get_noindex_options() 
  38. ),  
  39. 'sitemap_include' => $this->get_field_config( 
  40. esc_html__( 'Include in Sitemap?', 'wordpress-seo' ),  
  41. '',  
  42. 'select',  
  43. $this->sitemap_include_options 
  44. ),  
  45. 'bctitle' => $this->get_field_config( 
  46. __( 'Breadcrumbs Title', 'wordpress-seo' ),  
  47. esc_html__( 'The Breadcrumbs Title is used in the breadcrumbs where this taxonomy appears.', 'wordpress-seo' ),  
  48. 'text',  
  49. '',  
  50. $this->options['breadcrumbs-enable'] !== true 
  51. ),  
  52. 'canonical' => $this->get_field_config( 
  53. __( 'Canonical URL', 'wordpress-seo' ),  
  54. esc_html__( 'The canonical link is shown on the archive page for this term.', 'wordpress-seo' ) 
  55. ),  
  56. ); 
  57.  
  58. return $this->filter_hidden_fields( $fields ); 
  59.  
  60. /** 
  61. * Translate options text strings for use in the select fields 
  62. * @internal IMPORTANT: if you want to add a new string (option) somewhere, make sure you add 
  63. * that array key to the main options definition array in the class WPSEO_Taxonomy_Meta() as well!!!! 
  64. */ 
  65. private function translate_meta_options() { 
  66. $this->no_index_options = WPSEO_Taxonomy_Meta::$no_index_options; 
  67. $this->sitemap_include_options = WPSEO_Taxonomy_Meta::$sitemap_include_options; 
  68.  
  69. /** translators: %s expands to the current taxonomy index value */ 
  70. $this->no_index_options['default'] = __( 'Default for this taxonomy type, currently: %s', 'wordpress-seo' ); 
  71. $this->no_index_options['index'] = __( 'Index', 'wordpress-seo' ); 
  72. $this->no_index_options['noindex'] = __( 'Noindex', 'wordpress-seo' ); 
  73.  
  74. $this->sitemap_include_options['-'] = __( 'Auto detect', 'wordpress-seo' ); 
  75. $this->sitemap_include_options['always'] = __( 'Always include', 'wordpress-seo' ); 
  76. $this->sitemap_include_options['never'] = __( 'Never include', 'wordpress-seo' ); 
  77.  
  78. /** 
  79. * Getting the data for the noindex fields 
  80. * @return array 
  81. */ 
  82. private function get_noindex_options() { 
  83. $noindex_options['options'] = $this->no_index_options; 
  84. $noindex_options['options']['default'] = sprintf( $noindex_options['options']['default'], $this->get_robot_index() ); 
  85.  
  86. if ( get_option( 'blog_public' ) === 0 ) { 
  87. $noindex_options['description'] = '<br /><span class="error-message">' . esc_html__( 'Warning: even though you can set the meta robots setting here, the entire site is set to noindex in the sitewide privacy settings, so these settings won\'t have an effect.', 'wordpress-seo' ) . '</span>'; 
  88.  
  89. return $noindex_options; 
  90.  
  91. /** 
  92. * Returns the current robot index value for the taxonomy 
  93. * @return string 
  94. */ 
  95. private function get_robot_index() { 
  96. $robot_index = 'index'; 
  97. $index_option = 'noindex-tax-' . $this->term->taxonomy; 
  98. if ( isset( $this->options[ $index_option ] ) && $this->options[ $index_option ] === true ) { 
  99. $robot_index = 'noindex'; 
  100.  
  101. return $robot_index;