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-runner.php

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

85 lines 2.0 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 Yoast\WP\SEO\Config\Migration_Status;
6 use Yoast\WP\SEO\Helpers\Options_Helper;
7
8 /**
9 * Runs the Links_Table health check.
10 */
11 class Links_Table_Runner implements Runner_Interface {
12
13 /**
14 * Is set to true when the links table is accessible.
15 *
16 * @var bool
17 */
18 private $links_table_accessible = false;
19
20 /**
21 * The Migration_Status object used to determine whether the links table is accessible.
22 *
23 * @var Migration_Status
24 */
25 private $migration_status;
26
27 /**
28 * The Options_Helper object used to determine whether the health check should run or not.
29 *
30 * @var Options_Helper
31 */
32 private $options_helper;
33
34 /**
35 * Constructor.
36 *
37 * @param Migration_Status $migration_status Object used to determine whether the links table is accessible.
38 * @param Options_Helper $options_helper Object used to determine whether the health check should run.
39 */
40 public function __construct(
41 Migration_Status $migration_status,
42 Options_Helper $options_helper
43 ) {
44 $this->migration_status = $migration_status;
45 $this->options_helper = $options_helper;
46 }
47
48 /**
49 * Runs the health check. Checks if the tagline is set to WordPress' default tagline, or to its set translation.
50 *
51 * @return void
52 */
53 public function run() {
54 if ( ! $this->should_run() ) {
55 return;
56 }
57
58 $this->links_table_accessible = $this->migration_status->is_version( 'free', WPSEO_VERSION );
59 }
60
61 /**
62 * Determines whether the health check should run or not.
63 *
64 * @return bool True if the text link counter feature is enabled.
65 */
66 public function should_run() {
67 $text_link_counter_enabled = $this->options_helper->get( 'enable_text_link_counter' );
68
69 if ( ! is_bool( $text_link_counter_enabled ) ) {
70 return false;
71 }
72
73 return $text_link_counter_enabled;
74 }
75
76 /**
77 * Returns true if the links table is accessible
78 *
79 * @return bool The boolean indicating if the health check was succesful.
80 */
81 public function is_successful() {
82 return $this->links_table_accessible;
83 }
84 }
85