breadcrumbs-content.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Views\Breadcrumbs
  6. *
  7. * @var Yoast_Form $yform
  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. $yform->toggle_switch( 'breadcrumbs-boldlast', array(
  25. 'on' => __( 'Bold', 'wordpress-seo' ),
  26. 'off' => __( 'Regular', 'wordpress-seo' ),
  27. ), __( 'Bold the last page', 'wordpress-seo' ) );
  28. echo '<br/><br/>';
  29. /*
  30. * WPSEO_Post_Type::get_accessible_post_types() should *not* be used here.
  31. * Even posts that are not indexed, should be able to get breadcrumbs for accessibility/usability.
  32. */
  33. $post_types = get_post_types( array( 'public' => true ), 'objects' );
  34. if ( is_array( $post_types ) && $post_types !== array() ) {
  35. echo '<h2>' . esc_html__( 'Taxonomy to show in breadcrumbs for content types', 'wordpress-seo' ) . '</h2>';
  36. foreach ( $post_types as $pt ) {
  37. $taxonomies = get_object_taxonomies( $pt->name, 'objects' );
  38. if ( is_array( $taxonomies ) && $taxonomies !== array() ) {
  39. $values = array( 0 => __( 'None', 'wordpress-seo' ) );
  40. foreach ( $taxonomies as $tax ) {
  41. if ( ! $tax->public ) {
  42. continue;
  43. }
  44. $values[ $tax->name ] = $tax->labels->singular_name;
  45. }
  46. $label = $pt->labels->name . ' (<code>' . $pt->name . '</code>)';
  47. $yform->select( 'post_types-' . $pt->name . '-maintax', $label, $values );
  48. unset( $values, $tax );
  49. }
  50. unset( $taxonomies );
  51. }
  52. unset( $pt );
  53. }
  54. echo '<br/>';
  55. $taxonomies = get_taxonomies(
  56. array(
  57. 'public' => true,
  58. '_builtin' => false,
  59. ),
  60. 'objects'
  61. );
  62. if ( is_array( $taxonomies ) && $taxonomies !== array() ) {
  63. echo '<h2>' . esc_html__( 'Content type archive to show in breadcrumbs for taxonomies', 'wordpress-seo' ) . '</h2>';
  64. foreach ( $taxonomies as $tax ) {
  65. $values = array( 0 => __( 'None', 'wordpress-seo' ) );
  66. if ( get_option( 'show_on_front' ) === 'page' && get_option( 'page_for_posts' ) > 0 ) {
  67. $values['post'] = __( 'Blog', 'wordpress-seo' );
  68. }
  69. if ( is_array( $post_types ) && $post_types !== array() ) {
  70. foreach ( $post_types as $pt ) {
  71. if ( WPSEO_Post_Type::has_archive( $pt ) ) {
  72. $values[ $pt->name ] = $pt->labels->name;
  73. }
  74. }
  75. unset( $pt );
  76. }
  77. $label = $tax->labels->singular_name . ' (<code>' . $tax->name . '</code>)';
  78. $yform->select( 'taxonomy-' . $tax->name . '-ptparent', $label, $values );
  79. unset( $values, $tax );
  80. }
  81. }
  82. unset( $taxonomies, $post_types );
  83. ?>
  84. <br class="clear"/>
  85. </div>
  86. <h2><?php esc_html_e( 'How to insert breadcrumbs in your theme', 'wordpress-seo' ); ?></h2>
  87. <p>
  88. <?php
  89. printf(
  90. /* translators: %1$s / %2$s: links to the breadcrumbs implementation page on the Yoast knowledgebase */
  91. esc_html__( 'Usage of this breadcrumbs feature is explained in %1$sour knowledge-base article on breadcrumbs implementation%2$s.', 'wordpress-seo' ),
  92. '<a href="' . esc_url( WPSEO_Shortlinker::get( 'http://yoa.st/breadcrumbs' ) ) . '" target="_blank">',
  93. '</a>'
  94. );
  95. ?>
  96. </p>