breadcrumbs-content.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Views\Breadcrumbs
  6. *
  7. * @uses Yoast_Form $yform Form object.
  8. */
  9. if ( ! current_theme_supports( 'yoast-seo-breadcrumbs' ) ) {
  10. $yform->light_switch( 'breadcrumbs-enable', __( 'Enable Breadcrumbs', 'wordpress-seo' ) );
  11. echo '<br/>';
  12. }
  13. echo '<div id="breadcrumbsinfo">';
  14. $yform->textinput( 'breadcrumbs-sep', __( 'Separator between breadcrumbs', 'wordpress-seo' ) );
  15. $yform->textinput( 'breadcrumbs-home', __( 'Anchor text for the Homepage', 'wordpress-seo' ) );
  16. $yform->textinput( 'breadcrumbs-prefix', __( 'Prefix for the breadcrumb path', 'wordpress-seo' ) );
  17. $yform->textinput( 'breadcrumbs-archiveprefix', __( 'Prefix for Archive breadcrumbs', 'wordpress-seo' ) );
  18. $yform->textinput( 'breadcrumbs-searchprefix', __( 'Prefix for Search Page breadcrumbs', 'wordpress-seo' ) );
  19. $yform->textinput( 'breadcrumbs-404crumb', __( 'Breadcrumb for 404 Page', 'wordpress-seo' ) );
  20. echo '<br/>';
  21. if ( get_option( 'show_on_front' ) === 'page' && get_option( 'page_for_posts' ) > 0 ) {
  22. $yform->show_hide_switch( 'breadcrumbs-display-blog-page', __( 'Show Blog page', 'wordpress-seo' ) );
  23. }
  24. $yoast_free_breadcrumb_bold_texts = [
  25. 'on' => __( 'Bold', 'wordpress-seo' ),
  26. 'off' => __( 'Regular', 'wordpress-seo' ),
  27. ];
  28. $yform->toggle_switch(
  29. 'breadcrumbs-boldlast',
  30. $yoast_free_breadcrumb_bold_texts,
  31. __( 'Bold the last page', 'wordpress-seo' )
  32. );
  33. echo '<br/><br/>';
  34. /*
  35. * WPSEO_Post_Type::get_accessible_post_types() should *not* be used here.
  36. * Even posts that are not indexed, should be able to get breadcrumbs for accessibility/usability.
  37. */
  38. $post_types = get_post_types( [ 'public' => true ], 'objects' );
  39. if ( is_array( $post_types ) && $post_types !== [] ) {
  40. echo '<h2>' . esc_html__( 'Taxonomy to show in breadcrumbs for content types', 'wordpress-seo' ) . '</h2>';
  41. foreach ( $post_types as $pt ) {
  42. $taxonomies = get_object_taxonomies( $pt->name, 'objects' );
  43. if ( is_array( $taxonomies ) && $taxonomies !== [] ) {
  44. $values = [ 0 => __( 'None', 'wordpress-seo' ) ];
  45. foreach ( $taxonomies as $tax ) {
  46. if ( ! $tax->public ) {
  47. continue;
  48. }
  49. $values[ $tax->name ] = $tax->labels->singular_name;
  50. }
  51. $label = $pt->labels->name . ' (<code>' . $pt->name . '</code>)';
  52. $yform->select( 'post_types-' . $pt->name . '-maintax', $label, $values );
  53. unset( $values, $tax );
  54. }
  55. unset( $taxonomies );
  56. }
  57. unset( $pt );
  58. }
  59. echo '<br/>';
  60. $taxonomies = get_taxonomies(
  61. [
  62. 'public' => true,
  63. ],
  64. 'objects'
  65. );
  66. if ( is_array( $taxonomies ) && $taxonomies !== [] ) {
  67. echo '<h2>' . esc_html__( 'Content type archive to show in breadcrumbs for taxonomies', 'wordpress-seo' ) . '</h2>';
  68. foreach ( $taxonomies as $tax ) {
  69. $values = [ 0 => __( 'None', 'wordpress-seo' ) ];
  70. if ( get_option( 'show_on_front' ) === 'page' && get_option( 'page_for_posts' ) > 0 ) {
  71. $values['post'] = __( 'Blog', 'wordpress-seo' );
  72. }
  73. if ( is_array( $post_types ) && $post_types !== [] ) {
  74. foreach ( $post_types as $pt ) {
  75. if ( WPSEO_Post_Type::has_archive( $pt ) ) {
  76. $values[ $pt->name ] = $pt->labels->name;
  77. }
  78. }
  79. unset( $pt );
  80. }
  81. $label = $tax->labels->singular_name . ' (<code>' . $tax->name . '</code>)';
  82. $yform->select( 'taxonomy-' . $tax->name . '-ptparent', $label, $values );
  83. unset( $values, $tax );
  84. }
  85. }
  86. unset( $taxonomies, $post_types );
  87. ?>
  88. <br class="clear"/>
  89. </div>
  90. <h2><?php esc_html_e( 'How to insert breadcrumbs in your theme', 'wordpress-seo' ); ?></h2>
  91. <p>
  92. <?php
  93. printf(
  94. /* translators: %1$s / %2$s: links to the breadcrumbs implementation page on the Yoast knowledgebase */
  95. esc_html__( 'Usage of this breadcrumbs feature is explained in %1$sour knowledge-base article on breadcrumbs implementation%2$s.', 'wordpress-seo' ),
  96. '<a href="' . esc_url( WPSEO_Shortlinker::get( 'http://yoa.st/breadcrumbs' ) ) . '" target="_blank">',
  97. '</a>'
  98. );
  99. ?>
  100. </p>