PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.6 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 All 130 releases
← All changes | src/integrations/watchers/indexable-home-page-watcher.php +26 -7 19.0 → trunk View file →
@@ -3,8 +3,9 @@
3 3 namespace Yoast\WP\SEO\Integrations\Watchers;
4 4
5 5 use Yoast\WP\SEO\Builders\Indexable_Builder;
6 6 use Yoast\WP\SEO\Conditionals\Migrations_Conditional;
7 +use Yoast\WP\SEO\Helpers\Indexable_Helper;
7 8 use Yoast\WP\SEO\Integrations\Integration_Interface;
8 9 use Yoast\WP\SEO\Repositories\Indexable_Repository;
9 10
10 11 /**
@@ -10,10 +11,8 @@
10 11 /**
11 12 * Home page watcher to save the meta data to an Indexable.
12 13 *
13 14 * Watches the home page options to save the meta information when updated.
14 - *
15 - * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded -- 4 words is fine.
16 15 */
17 16 class Indexable_Home_Page_Watcher implements Integration_Interface {
18 17
19 18 /**
@@ -23,8 +22,15 @@
23 22 */
24 23 protected $repository;
25 24
26 25 /**
26 + * The indexable helper.
27 + *
28 + * @var Indexable_Helper
29 + */
30 + protected $indexable_helper;
31 +
32 + /**
27 33 * The indexable builder.
28 34 *
29 35 * @var Indexable_Builder
30 36 */
@@ -41,14 +47,20 @@
41 47
42 48 /**
43 49 * Indexable_Home_Page_Watcher constructor.
44 50 *
45 - * @param Indexable_Repository $repository The repository to use.
46 - * @param Indexable_Builder $builder The post builder to use.
51 + * @param Indexable_Repository $repository The repository to use.
52 + * @param Indexable_Helper $indexable_helper The indexable helper.
53 + * @param Indexable_Builder $builder The post builder to use.
47 54 */
48 - public function __construct( Indexable_Repository $repository, Indexable_Builder $builder ) {
49 - $this->repository = $repository;
50 - $this->builder = $builder;
55 + public function __construct(
56 + Indexable_Repository $repository,
57 + Indexable_Helper $indexable_helper,
58 + Indexable_Builder $builder
59 + ) {
60 + $this->repository = $repository;
61 + $this->indexable_helper = $indexable_helper;
62 + $this->builder = $builder;
51 63 }
52 64
53 65 /**
54 66 * Initializes the integration.
@@ -53,8 +65,10 @@
53 65 /**
54 66 * Initializes the integration.
55 67 *
56 68 * This is the place to register hooks and filters.
69 + *
70 + * @return void
57 71 */
58 72 public function register_hooks() {
59 73 \add_action( 'update_option_wpseo_titles', [ $this, 'check_option' ], 15, 3 );
60 74 \add_action( 'update_option_wpseo_social', [ $this, 'check_option' ], 15, 3 );
@@ -107,8 +121,13 @@
107 121 * @return void
108 122 */
109 123 public function build_indexable() {
110 124 $indexable = $this->repository->find_for_home_page( false );
125 +
126 + if ( $indexable === false && ! $this->indexable_helper->should_index_indexables() ) {
127 + return;
128 + }
129 +
111 130 $indexable = $this->builder->build_for_home_page( $indexable );
112 131
113 132 if ( $indexable ) {
114 133 $indexable->object_last_modified = \max( $indexable->object_last_modified, \current_time( 'mysql' ) );