function rocket_new_upgrade($wp_rocket_version, $actual_version) { if (version_compare($actual_version, '1.0.1', '<')) { wp_clear_scheduled_hook('rocket_check_event'); } if (version_compare($actual_version, '1.2.0', '<')) { // Delete old WP Rocket cache dir rocket_rrmdir(WP_ROCKET_PATH . 'cache'); // Create new WP Rocket cache dir if (!is_dir(WP_ROCKET_CACHE_PATH)) { mkdir(WP_ROCKET_CACHE_PATH); } } if (version_compare($actual_version, '1.3.0', '<')) { rocket_dismiss_box('rocket_warning_plugin_modification'); } if (version_compare($actual_version, '1.3.3', '<')) { // Clean cache rocket_clean_domain(); // Create cache files run_rocket_bot('cache-preload'); } if (version_compare($actual_version, '2.0', '<')) { // Add secret cache key $options = get_option(WP_ROCKET_SLUG); $options['secret_cache_key'] = create_rocket_uniqid(); update_option(WP_ROCKET_SLUG, $options); global $wp_filesystem; if (!$wp_filesystem) { require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php'; $wp_filesystem = new WP_Filesystem_Direct(new StdClass()); } // Get chmod of old folder cache $chmod = is_dir(WP_CONTENT_DIR . '/wp-rocket-cache') ? substr(sprintf('%o', fileperms(WP_CONTENT_DIR . '/wp-rocket-cache')), -4) : CHMOD_WP_ROCKET_CACHE_DIRS; // Check and create cache folder in wp-content if not already exist if (!$wp_filesystem->is_dir(WP_CONTENT_DIR . '/cache')) { $wp_filesystem->mkdir(WP_CONTENT_DIR . '/cache', octdec($chmod)); } $wp_filesystem->mkdir(WP_CONTENT_DIR . '/cache/wp-rocket', octdec($chmod)); // Move old cache folder in new path @rename(WP_CONTENT_DIR . '/wp-rocket-cache', WP_CONTENT_DIR . '/cache/wp-rocket'); // Add WP_CACHE constant in wp-config.php set_rocket_wp_cache_define(true); // Create advanced-cache.php file rocket_generate_advanced_cache_file(); // Create config file rocket_generate_config_file(); } if (version_compare($actual_version, '2.1', '<')) { rocket_reset_white_label_values(false); // Create minify cache folder if not exist if (!is_dir(WP_ROCKET_MINIFY_CACHE_PATH)) { rocket_mkdir_p(WP_ROCKET_MINIFY_CACHE_PATH); } // Create config domain folder if not exist if (!is_dir(WP_ROCKET_CONFIG_PATH)) { rocket_mkdir_p(WP_ROCKET_CONFIG_PATH); } // Create advanced-cache.php file rocket_generate_advanced_cache_file(); // Create config file rocket_generate_config_file(); } if (version_compare($actual_version, '2.3.3', '<')) { // Clean cache rocket_clean_domain(); // Create cache files run_rocket_bot('cache-preload'); } if (version_compare($actual_version, '2.3.9', '<')) { // Regenerate config file rocket_generate_config_file(); } if (version_compare($actual_version, '2.4.1', '<')) { // Regenerate advanced-cache.php file rocket_generate_advanced_cache_file(); delete_transient('rocket_ask_for_update'); } if (version_compare($actual_version, '2.6', '<')) { // Activate Inline CSS & JS minification if HTML minification is activated $options = get_option(WP_ROCKET_SLUG); if (!empty($options['minify_html'])) { $options['minify_html_inline_css'] = 1; $options['minify_html_inline_js'] = 1; } update_option(WP_ROCKET_SLUG, $options); // Regenerate advanced-cache.php file rocket_generate_advanced_cache_file(); } }
function do_rocket_purge_cron() { // Purge domain cache files rocket_clean_domain(); // Purge minify cache files rocket_clean_minify(); // Run WP Rocket Bot for preload cache files run_rocket_bot('cache-preload'); }
/** * Run WP Rocket Bot for preload cache files * * ## EXAMPLES * * wp rocket preload * * @subcommand preload */ public function preload($args = array(), $assoc_args = array()) { if (rocket_has_translation_plugin_active()) { run_rocket_bot_for_all_langs(); } else { run_rocket_bot('cache-preload'); } WP_CLI::success('Finished WP Rocket preload cache files.'); }
/** * Launch the Cache Preload Robot for a selected lang * * @since 2.0 * @deprecated 2.2 * @deprecated Use run_rocket_bot() * */ function run_rocket_bot_for_selected_lang($lang) { _deprecated_function(__FUNCTION__, '2.2', "run_rocket_bot()"); return run_rocket_bot('cache-preload', $lang); }
function __rocket_run_rocket_bot_after_wpengine() { if (function_exists('wpe_param') && wpe_param('purge-all') && defined('PWP_NAME') && check_admin_referer(PWP_NAME . '-config')) { // Preload cache run_rocket_bot('cache-preload'); } }
function preload_cache() { if (function_exists('run_rocket_bot')) { run_rocket_bot('cache-preload', ''); return array('result' => 'SUCCESS'); } else { return array('error' => 'function_not_exist'); } }
function rocket_preload_cache() { if (isset($_GET['_wpnonce'])) { if (!wp_verify_nonce($_GET['_wpnonce'], 'preload')) { wp_nonce_ays(''); } $lang = isset($_GET['lang']) && $_GET['lang'] != 'all' ? sanitize_key($_GET['lang']) : ''; run_rocket_bot('cache-preload', $lang); wp_redirect(wp_get_referer()); die; } }