PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.9
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.9
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / services / health-check / postname-permalink-reports.php

postname-permalink-reports.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.9, at src/services/health-check/postname-permalink-reports.php

74 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Services\Health_Check;
4
5 /**
6 * Presents a set of different messages for the Postname_Permalink health check.
7 */
8 class Postname_Permalink_Reports {
9 use Reports_Trait;
10
11 /**
12 * Constructor.
13 *
14 * @param Report_Builder_Factory $report_builder_factory The factory for result builder objects. This class uses the report builder to generate WordPress-friendly health check results.
15 */
16 public function __construct( Report_Builder_Factory $report_builder_factory ) {
17 $this->report_builder_factory = $report_builder_factory;
18 }
19
20 /**
21 * Returns the report for when permalinks are set to contain the post name.
22 *
23 * @return string[] The message as a WordPress site status report.
24 */
25 public function get_success_result() {
26 return $this->get_report_builder()
27 ->set_label( esc_html__( 'Your permalink structure includes the post name', 'wordpress-seo' ) )
28 ->set_status_good()
29 ->set_description( __( 'You do have your postname in the URL of your posts and pages.', 'wordpress-seo' ) )
30 ->build();
31 }
32
33 /**
34 * Returns the report for when permalinks are not set to contain the post name.
35 *
36 * @return string[] The message as a WordPress site status report.
37 */
38 public function get_has_no_postname_in_permalink_result() {
39 return $this->get_report_builder()
40 ->set_label( __( 'You do not have your postname in the URL of your posts and pages', 'wordpress-seo' ) )
41 ->set_status_recommended()
42 ->set_description( $this->get_has_no_postname_in_permalink_description() )
43 ->set_actions( $this->get_has_no_postname_in_permalink_actions() )
44 ->build();
45 }
46
47 /**
48 * Returns the description for when permalinks are not set to contain the post name.
49 *
50 * @return string The description as a string.
51 */
52 private function get_has_no_postname_in_permalink_description() {
53 return sprintf(
54 /* translators: %s expands to '/%postname%/' */
55 __( 'It\'s highly recommended to have your postname in the URL of your posts and pages. Consider setting your permalink structure to %s.', 'wordpress-seo' ),
56 '<strong>/%postname%/</strong>'
57 );
58 }
59
60 /**
61 * Returns the actions for when permalinks are not set to contain the post name.
62 *
63 * @return string The actions as a string.
64 */
65 private function get_has_no_postname_in_permalink_actions() {
66 return sprintf(
67 /* translators: %1$s is a link start tag to the permalink settings page, %2$s is the link closing tag. */
68 __( 'You can fix this on the %1$sPermalink settings page%2$s.', 'wordpress-seo' ),
69 '<a href="' . admin_url( 'options-permalink.php' ) . '">',
70 '</a>'
71 );
72 }
73 }
74