taxonomies.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Views
  6. */
  7. if ( ! defined( 'WPSEO_VERSION' ) ) {
  8. header( 'Status: 403 Forbidden' );
  9. header( 'HTTP/1.1 403 Forbidden' );
  10. exit();
  11. }
  12. $wpseo_taxonomies = get_taxonomies( [ 'public' => true ], 'objects' );
  13. if ( is_array( $wpseo_taxonomies ) && $wpseo_taxonomies !== [] ) {
  14. $view_utils = new Yoast_View_Utils();
  15. $recommended_replace_vars = new WPSEO_Admin_Recommended_Replace_Vars();
  16. $editor_specific_replace_vars = new WPSEO_Admin_Editor_Specific_Replace_Vars();
  17. // Explicitly hide all the core taxonomies we never want to do stuff for.
  18. $wpseo_taxonomies = array_diff_key( $wpseo_taxonomies, array_flip( [ 'link_category', 'nav_menu' ] ) );
  19. foreach ( array_values( $wpseo_taxonomies ) as $wpseo_taxonomy_index => $wpseo_taxonomy ) {
  20. $wpseo_taxonomy_presenter = new WPSEO_Paper_Presenter(
  21. $wpseo_taxonomy->labels->name,
  22. dirname( __FILE__ ) . '/paper-content/taxonomy-content.php',
  23. [
  24. 'collapsible' => true,
  25. 'expanded' => ( $wpseo_taxonomy_index === 0 ),
  26. 'paper_id' => 'settings-' . $wpseo_taxonomy->name,
  27. 'view_data' => [
  28. 'wpseo_taxonomy' => $wpseo_taxonomy,
  29. 'view_utils' => $view_utils,
  30. 'recommended_replace_vars' => $recommended_replace_vars,
  31. 'editor_specific_replace_vars' => $editor_specific_replace_vars,
  32. ],
  33. 'title_after' => ' (<code>' . esc_html( $wpseo_taxonomy->name ) . '</code>)',
  34. 'class' => 'search-appearance',
  35. ]
  36. );
  37. echo $wpseo_taxonomy_presenter->get_output();
  38. }
  39. unset( $wpseo_taxonomy_index, $wpseo_taxonomy_presenter, $view_utils, $recommended_replace_vars );
  40. }
  41. unset( $wpseo_taxonomies );
  42. printf( '<h2>%s</h2>', esc_html__( 'Category URLs', 'wordpress-seo' ) );
  43. require dirname( __FILE__ ) . '/taxonomies/category-url.php';