Yoast\WP\SEO\Commands
Cleanup_Command::cleanup_current_site()
Performs the cleanup for a single site.
Метод класса: Cleanup_Command{}
Хуки из метода
Возвращает
int
. The number of cleaned up records.
Использование
// private - только в коде основоного (родительского) класса $result = $this->cleanup_current_site( $assoc_args );
- $assoc_args(массив|null) (обязательный)
- The associative arguments.
Код Cleanup_Command::cleanup_current_site() Cleanup Command::cleanup current site Yoast 22.4
private function cleanup_current_site( $assoc_args ) { $site_url = \site_url(); $total_removed = 0; if ( ! \is_plugin_active( \WPSEO_BASENAME ) ) { /* translators: %1$s is the site url of the site that is skipped. %2$s is Yoast SEO. */ WP_CLI::warning( \sprintf( \__( 'Skipping %1$s. %2$s is not active on this site.', 'wordpress-seo' ), $site_url, 'Yoast SEO' ) ); return $total_removed; } // Make sure the DB is up to date first. \do_action( '_yoast_run_migrations' ); $tasks = $this->cleanup_integration->get_cleanup_tasks(); $limit = (int) $assoc_args['batch-size']; $interval = (int) $assoc_args['interval']; /* translators: %1$s is the site url of the site that is cleaned up. %2$s is the name of the cleanup task that is currently running. */ $progress_bar_title_format = \__( 'Cleaning up %1$s [%2$s]', 'wordpress-seo' ); $progress = Utils\make_progress_bar( \sprintf( $progress_bar_title_format, $site_url, \key( $tasks ) ), \count( $tasks ) ); foreach ( $tasks as $task_name => $task ) { // Update the progressbar title with the current task name. $progress->tick( 0, \sprintf( $progress_bar_title_format, $site_url, $task_name ) ); do { $items_cleaned = $task( $limit ); if ( \is_int( $items_cleaned ) ) { $total_removed += $items_cleaned; } \usleep( $interval ); // Update the timer. $progress->tick( 0 ); } while ( $items_cleaned !== false && $items_cleaned > 0 ); $progress->tick(); } $progress->finish(); $this->cleanup_integration->reset_cleanup(); WP_CLI::log( \sprintf( /* translators: %1$d is the number of records that were removed. %2$s is the site url. */ \_n( 'Cleaned up %1$d record from %2$s.', 'Cleaned up %1$d records from %2$s.', $total_removed, 'wordpress-seo' ), $total_removed, $site_url ) ); return $total_removed; }