indexable_repository = $indexable_repository; $this->options_helper = $options_helper; } /** * Registers the hooks with WordPress. * * @return void */ public function register_hooks() { \add_action( 'wpseo_saved_indexable', [ $this, 'check_for_default_seo_data' ], 10, 1 ); } /** * Checks for default SEO data in the saved indexable and the most recently modified posts. * * @param Indexable $saved_indexable The saved indexable. * * @return void */ public function check_for_default_seo_data( $saved_indexable ): void { // We have activated this feature only for posts for now. if ( $saved_indexable->object_type !== 'post' || $saved_indexable->object_sub_type !== 'post' ) { return; } // If the title or description is null, it means it's not default SEO data so let's reset the options. if ( $saved_indexable->title !== null ) { $this->options_helper->set( 'default_seo_title', [] ); } if ( $saved_indexable->description !== null ) { $this->options_helper->set( 'default_seo_meta_desc', [] ); } } }