config = $config; $this->cache_manager = $cache_manager; $this->xml_manager = $xml_manager; } /** * Returns the namespace of this command. * * @return string */ public static function get_namespace() { return Main::WP_CLI_NAMESPACE; } /** * Aggregates the schema for a certain site. * * ## OPTIONS * * [--post_type=] * : The current page to process. * [--page=] * : The current page to process. * --- * ## EXAMPLES * * wp yoast aggregate_site_schema_clear_cache * * @when after_wp_load * * @param array|null $args The arguments. * @param array|null $assoc_args The associative arguments. * * @throws ExitException When the input args are invalid. * @return void */ public function aggregate_site_schema_clear_cache( $args = null, $assoc_args = null ) { if ( ( isset( $assoc_args['page'] ) && (int) $assoc_args['page'] >= 1 ) && isset( $assoc_args['post_type'] ) ) { $this->cache_manager->invalidate( $assoc_args['post_type'], $assoc_args['page'] ); $this->xml_manager->invalidate(); WP_CLI::log( \__( 'The site schema cache has been cleared successfully.', 'wordpress-seo' ), ); return; } $this->cache_manager->invalidate_all(); $this->xml_manager->invalidate(); WP_CLI::log( \__( 'All site schema cache has been cleared successfully.', 'wordpress-seo' ), ); } }