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 / links-table-reports.php

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

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