PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.9
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.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 / links-table-reports.php

links-table-reports.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.9, at src/services/health-check/links-table-reports.php

106 lines 3.4 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 use WPSEO_Admin_Utils;
6 use WPSEO_Shortlinker;
7
8 /**
9 * Presents a set of different messages for the Links_Table health check.
10 */
11 class Links_Table_Reports {
12
13 use Reports_Trait;
14
15 /**
16 * Shortlinker object used to create short links for reports.
17 *
18 * @var WPSEO_Shortlinker
19 */
20 private $shortlinker;
21
22 /**
23 * Constructor
24 *
25 * @param Report_Builder_Factory $report_builder_factory The factory for result builder objects.
26 * This class uses the report builder to generate WordPress-friendly
27 * health check results.
28 * @param WPSEO_Shortlinker $shortlinker Object used to add short links to the report description.
29 */
30 public function __construct(
31 Report_Builder_Factory $report_builder_factory,
32 WPSEO_Shortlinker $shortlinker
33 ) {
34 $this->report_builder_factory = $report_builder_factory;
35 $this->shortlinker = $shortlinker;
36 }
37
38 /**
39 * Returns the message for a successful health check.
40 *
41 * @return string[] The message as a WordPress site status report.
42 */
43 public function get_success_result() {
44 return $this->get_report_builder()
45 ->set_label( \__( 'The text link counter is working as expected', 'wordpress-seo' ) )
46 ->set_status_good()
47 ->set_description( $this->get_success_description() )
48 ->build();
49 }
50
51 /**
52 * Returns the message for a failed health check.
53 *
54 * @return string[] The message as a WordPress site status report.
55 */
56 public function get_links_table_not_accessible_result() {
57 return $this->get_report_builder()
58 ->set_label( \__( 'The text link counter feature is not working as expected', 'wordpress-seo' ) )
59 ->set_status_recommended()
60 ->set_description( $this->get_links_table_not_accessible_description() )
61 ->set_actions( $this->get_actions() )
62 ->build();
63 }
64
65 /**
66 * Returns the description for when the health check was successful.
67 *
68 * @return string The description as a string.
69 */
70 private function get_success_description() {
71 return \sprintf(
72 /* translators: 1: Link to the Yoast SEO blog, 2: Link closing tag. */
73 \esc_html__( 'The text link counter helps you improve your site structure. %1$sFind out how the text link counter can enhance your SEO%2$s.', 'wordpress-seo' ),
74 '<a href="' . $this->shortlinker->get( 'https://yoa.st/3zw' ) . '" target="_blank">',
75 WPSEO_Admin_Utils::get_new_tab_message() . '</a>',
76 );
77 }
78
79 /**
80 * Returns the description for when the health couldn't access the links table.
81 *
82 * @return string The description as a string.
83 */
84 private function get_links_table_not_accessible_description() {
85 return \sprintf(
86 /* translators: 1: Yoast SEO. */
87 \__( 'For this feature to work, %1$s needs to create a table in your database. We were unable to create this table automatically.', 'wordpress-seo' ),
88 'Yoast SEO',
89 );
90 }
91
92 /**
93 * Returns the actions that the user should take when the links table is not accessible.
94 *
95 * @return string The actions as a string.
96 */
97 private function get_actions() {
98 return \sprintf(
99 /* translators: 1: Link to the Yoast help center, 2: Link closing tag. */
100 \esc_html__( '%1$sFind out how to solve this problem on our help center%2$s.', 'wordpress-seo' ),
101 '<a href="' . $this->shortlinker->get( 'https://yoa.st/3zv' ) . '" target="_blank">',
102 WPSEO_Admin_Utils::get_new_tab_message() . '</a>',
103 );
104 }
105 }
106