PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.2
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.2
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 28.2, at src/services/health-check/postname-permalink-reports.php

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