features.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Views
  6. */
  7. /**
  8. * @var Yoast_Form $yform
  9. */
  10. if ( ! defined( 'WPSEO_VERSION' ) ) {
  11. header( 'Status: 403 Forbidden' );
  12. header( 'HTTP/1.1 403 Forbidden' );
  13. exit();
  14. }
  15. $xml_sitemap_extra = false;
  16. if ( WPSEO_Options::get( 'enable_xml_sitemap' ) ) {
  17. $xml_sitemap_extra = '<a href="' . esc_url( WPSEO_Sitemaps_Router::get_base_url( 'sitemap_index.xml' ) )
  18. . '" target="_blank">' . esc_html__( 'See the XML sitemap.', 'wordpress-seo' ) . '</a>';
  19. }
  20. $feature_toggles = array(
  21. (object) array(
  22. 'name' => __( 'SEO analysis', 'wordpress-seo' ),
  23. 'setting' => 'keyword_analysis_active',
  24. 'label' => __( 'The SEO analysis offers suggestions to improve the SEO of your text.', 'wordpress-seo' ),
  25. 'read_more_label' => __( 'Learn how the SEO analysis can help you rank.', 'wordpress-seo' ),
  26. 'read_more_url' => 'https://yoa.st/2ak',
  27. 'order' => 10,
  28. ),
  29. (object) array(
  30. 'name' => __( 'Readability analysis', 'wordpress-seo' ),
  31. 'setting' => 'content_analysis_active',
  32. 'label' => __( 'The readability analysis offers suggestions to improve the structure and style of your text.', 'wordpress-seo' ),
  33. 'read_more_label' => __( 'Discover why readability is important for SEO.', 'wordpress-seo' ),
  34. 'read_more_url' => 'https://yoa.st/2ao',
  35. 'order' => 20,
  36. ),
  37. (object) array(
  38. 'name' => __( 'Cornerstone content', 'wordpress-seo' ),
  39. 'setting' => 'enable_cornerstone_content',
  40. 'label' => __( 'The cornerstone content feature lets you to mark and filter cornerstone content on your website.', 'wordpress-seo' ),
  41. 'read_more_label' => __( 'Find out how cornerstone content can help you improve your site structure.', 'wordpress-seo' ),
  42. 'read_more_url' => 'https://yoa.st/dashboard-help-cornerstone',
  43. 'order' => 30,
  44. ),
  45. (object) array(
  46. 'name' => __( 'Text link counter', 'wordpress-seo' ),
  47. 'setting' => 'enable_text_link_counter',
  48. 'label' => __( 'The text link counter helps you improve your site structure.', 'wordpress-seo' ),
  49. 'read_more_label' => __( 'Find out how the text link counter can enhance your SEO.', 'wordpress-seo' ),
  50. 'read_more_url' => 'https://yoa.st/2aj',
  51. 'order' => 40,
  52. ),
  53. (object) array(
  54. 'name' => __( 'XML sitemaps', 'wordpress-seo' ),
  55. 'setting' => 'enable_xml_sitemap',
  56. /* translators: %s expands to Yoast SEO */
  57. 'label' => sprintf( __( 'Enable the XML sitemaps that %s generates.', 'wordpress-seo' ), 'Yoast SEO' ),
  58. 'read_more_label' => __( 'Read why XML Sitemaps are important for your site.', 'wordpress-seo' ),
  59. 'read_more_url' => 'https://yoa.st/2a-',
  60. 'extra' => $xml_sitemap_extra,
  61. 'order' => 60,
  62. ),
  63. (object) array(
  64. /* translators: %s expands to Ryte. */
  65. 'name' => sprintf( __( '%s integration', 'wordpress-seo' ), 'Ryte' ),
  66. 'setting' => 'onpage_indexability',
  67. /* translators: %1$s expands to Ryte. */
  68. 'label' => sprintf( __( '%1$s will check weekly if your site is still indexable by search engines and Yoast SEO will notify you when this is not the case.', 'wordpress-seo' ), 'Ryte' ),
  69. /* translators: %s expands to Ryte. */
  70. 'read_more_label' => sprintf( __( 'Read more about how %s works.', 'wordpress-seo' ), 'Ryte ' ),
  71. 'read_more_url' => 'https://yoa.st/2an',
  72. 'order' => 70,
  73. ),
  74. (object) array(
  75. 'name' => __( 'Admin bar menu', 'wordpress-seo' ),
  76. 'setting' => 'enable_admin_bar_menu',
  77. /* translators: %1$s expands to Yoast SEO */
  78. 'label' => sprintf( __( 'The %1$s admin bar menu contains useful links to third-party tools for analyzing pages and makes it easy to see if you have new notifications.', 'wordpress-seo' ), 'Yoast SEO' ),
  79. 'order' => 80,
  80. ),
  81. (object) array(
  82. 'name' => __( 'Security: no advanced settings for authors', 'wordpress-seo' ),
  83. 'setting' => 'disableadvanced_meta',
  84. 'label' => sprintf(
  85. /* translators: %1$s expands to Yoast SEO, %2$s expands to the translated version of "Off" */
  86. __( 'The advanced section of the %1$s meta box allows a user to remove posts from the search results or change the canonical. These are things you might not want any author to do. That\'s why, by default, only editors and administrators can do this. Setting to "%2$s" allows all users to change these settings.', 'wordpress-seo' ),
  87. 'Yoast SEO',
  88. __( 'Off', 'wordpress-seo' )
  89. ),
  90. 'order' => 90,
  91. ),
  92. );
  93. /**
  94. * Filter to add feature toggles from add-ons.
  95. *
  96. * @param array $feature_toggles Array with feature toggle objects where each object should have a `name`, `setting` and `label` property.
  97. */
  98. $feature_toggles = apply_filters( 'wpseo_feature_toggles', $feature_toggles );
  99. ?>
  100. <h2><?php esc_html_e( 'Features', 'wordpress-seo' ); ?></h2>
  101. <div style="max-width:600px">
  102. <?php
  103. echo sprintf(
  104. /* translators: %1$s expands to Yoast SEO */
  105. esc_html__( '%1$s comes with a lot of features. You can enable / disable some of them below. Clicking the question mark gives more information about the feature.', 'wordpress-seo' ),
  106. 'Yoast SEO'
  107. );
  108. /**
  109. * Simple sorting function used for usort straight below.
  110. *
  111. * @param object $feature_a Feature A.
  112. * @param object $feature_b Feature B.
  113. *
  114. * @return bool Whether order for feature A is bigger than for feature B.
  115. */
  116. function wpseo_cmp_order( $feature_a, $feature_b ) {
  117. return ( $feature_a->order > $feature_b->order );
  118. }
  119. usort( $feature_toggles, 'wpseo_cmp_order' );
  120. foreach ( $feature_toggles as $feature ) {
  121. $help_text = esc_html( $feature->label );
  122. if ( ! empty( $feature->extra ) ) {
  123. $help_text .= ' ' . $feature->extra;
  124. }
  125. if ( ! empty( $feature->read_more_label ) ) {
  126. $help_text .= ' ';
  127. $help_text .= sprintf(
  128. '<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a>',
  129. esc_url( WPSEO_Shortlinker::get( $feature->read_more_url ) ),
  130. esc_html( $feature->read_more_label )
  131. );
  132. }
  133. $feature_help = new WPSEO_Admin_Help_Panel(
  134. $feature->setting,
  135. /* translators: %s expands to a feature's name */
  136. sprintf( esc_html__( 'Help on: %s', 'wordpress-seo' ), esc_html( $feature->name ) ),
  137. $help_text
  138. );
  139. $yform->toggle_switch(
  140. $feature->setting,
  141. array(
  142. 'on' => __( 'On', 'wordpress-seo' ),
  143. 'off' => __( 'Off', 'wordpress-seo' ),
  144. ),
  145. '<strong>' . $feature->name . $feature_help->get_button_html() . '</strong>' . $feature_help->get_panel_html()
  146. );
  147. }
  148. ?>
  149. </div>
  150. <?php
  151. // Required to prevent our settings framework from saving the default because the field isn't explicitly set when saving the Dashboard page.
  152. $yform->hidden( 'show_onboarding_notice', 'wpseo_show_onboarding_notice' );