. sprintf( _n( 'Preload: %1$s uncached page has now been preloaded. (refresh to see progress)', 'Preload: %1$s uncached pages have now been preloaded. (refresh to see progress)', $running, 'rocket' ), number_format_i18n( $running ) ); $message .= ' - (' . date_i18n( get_option( 'date_format' ) ) . ' @ ' . date_i18n( get_option( 'time_format' ) ) . ')

'; if ( defined( 'WP_ROCKET_DEBUG' ) && WP_ROCKET_DEBUG ) { $errors = get_transient( 'rocket_preload_errors' ); if ( false !== $errors ) { $status = 'warning'; $message .= '

' . _n( 'The following error happened during gathering of the URLs to preload:', 'The following errors happened during gathering of the URLs to preload:', count( $errors['errors'] ), 'rocket' ) . '

'; foreach ( $errors['errors'] as $error ) { $message .= '

' . $error . '

'; } } } \rocket_notice_html( [ 'status' => $status, 'message' => $message, 'dismissible' => 'notice-preload-running', 'action' => 'stop_preload', ] ); } /** * This notice is displayed after the sitemap preload is complete * * @since 3.2 * @author Remy Perona */ public function notice_preload_complete() { if ( ! current_user_can( 'rocket_preload_cache' ) ) { return; } $screen = get_current_screen(); if ( 'settings_page_wprocket' !== $screen->id ) { return; } $result = get_transient( 'rocket_preload_complete' ); if ( false === $result ) { return; } $result_timestamp = get_transient( 'rocket_preload_complete_time' ); if ( false === $result_timestamp ) { return; } delete_transient( 'rocket_preload_complete' ); delete_transient( 'rocket_preload_errors' ); delete_transient( 'rocket_preload_complete_time' ); // translators: %d is the number of pages preloaded. $notice_message = sprintf( __( 'Preload complete: %d pages have been cached.', 'rocket' ), $result ); $notice_message .= ' (' . $result_timestamp . ') '; \rocket_notice_html( [ 'message' => $notice_message, ] ); } /** * Stops currently running preload from the notice action button * * @since 3.2 * @author Remy Perona */ public function do_admin_post_stop_preload() { if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'rocket_stop_preload' ) ) { wp_nonce_ays( '' ); } if ( ! current_user_can( 'rocket_preload_cache' ) ) { wp_safe_redirect( wp_get_referer() ); die(); } $this->homepage_preloader->cancel_preload(); wp_safe_redirect( wp_get_referer() ); die(); } /** * Stops homepage preload. * * @since 3.10 * * @return void */ public function stop_homepage_preload() { $this->homepage_preloader->cancel_preload(); } }