flare\CloudflareSubscriber::set_varnish_purge_request_host()' ); return wp_parse_url( home_url(), PHP_URL_HOST ); } /** * Send data to Varnish * * @since 2.6.8 * @deprecated 3.5 * * @param string $url The URL to purge. * @return void */ function rocket_varnish_http_purge( $url ) { _deprecated_function( __FUNCTION__ . '()', '3.5', 'WP_Rocket\Addons\Varnish\Varnish::purge()' ); $parse_url = get_rocket_parse_url( $url ); $varnish_x_purgemethod = 'default'; $regex = ''; if ( 'vregex' === $parse_url['query'] ) { $varnish_x_purgemethod = 'regex'; $regex = '.*'; } /** * Filter the Varnish IP to call * * @since 2.6.8 * @param string The Varnish IP */ $varnish_ip = apply_filters( 'rocket_varnish_ip', '' ); if ( defined( 'WP_ROCKET_VARNISH_IP' ) && ! $varnish_ip ) { $varnish_ip = WP_ROCKET_VARNISH_IP; } /** * Filter the HTTP protocol (scheme) * * @since 2.7.3 * @param string The HTTP protocol */ $scheme = apply_filters( 'rocket_varnish_http_purge_scheme', 'http' ); $parse_url['host'] = ( $varnish_ip ) ? $varnish_ip : $parse_url['host']; $purgeme = $scheme . '://' . $parse_url['host'] . $parse_url['path'] . $regex; wp_remote_request( $purgeme, array( 'method' => 'PURGE', 'blocking' => false, 'redirection' => 0, /** * Filters the headers to send with the Varnish purge request * * @since 3.1 * @author Remy Perona * * @param array $headers Headers to send. */ 'headers' => apply_filters( 'rocket_varnish_purge_headers', [ /** * Filters the host value passed in the request headers * * @since 2.8.15 * @param string The host */ 'host' => apply_filters( 'rocket_varnish_purge_request_host', $parse_url['host'] ), 'X-Purge-Method' => $varnish_x_purgemethod, ] ), ) ); } /** * Display a warning notice if WP Rocket scheduled events are not running properly * * @since 3.5.4 deprecated * @since 3.3.7 * @author Remy Perona * * @return void */ function rocket_warning_cron() { _deprecated_function( __FUNCTION__ . '()', '3.5.4', 'WP_Rocket\Engine\Admin\HealthCheck::missed_cron()' ); $screen = get_current_screen(); // This filter is documented in inc/admin-bar.php. if ( ! current_user_can( apply_filters( 'rocket_capacity', 'manage_options' ) ) ) { return; } if ( 'settings_page_wprocket' !== $screen->id ) { return; } $boxes = get_user_meta( get_current_user_id(), 'rocket_boxes', true ); if ( in_array( __FUNCTION__, (array) $boxes, true ) ) { return; } if ( 0 === (int) get_rocket_option( 'purge_cron_interval' ) && 0 === get_rocket_option( 'async_css' ) && 0 === get_rocket_option( 'manual_preload' ) && 0 === get_rocket_option( 'schedule_automatic_cleanup' ) ) { return; } $events = [ 'rocket_purge_time_event' => 'Scheduled Cache Purge', 'rocket_database_optimization_time_event' => 'Scheduled Database Optimization', 'rocket_database_optimization_cron_interval' => 'Database Optimization Process', 'rocket_preload_cron_interval' => 'Preload', 'rocket_critical_css_generation_cron_interval' => 'Critical Path CSS Generation Process', ]; foreach ( $events as $event => $description ) { $timestamp = wp_next_scheduled( $event ); if ( false === $timestamp ) { unset( $events[ $event ] ); continue; } if ( $timestamp - time() > 0 ) { unset( $events[ $event ] ); continue; } } if ( empty( $events ) ) { return; } $message = '
' . _n( 'The following scheduled event failed to run. This may indicate the CRON system is not running properly, which can prevent some WP Rocket features from working as intended:', 'The following scheduled events failed to run. This may indicate the CRON system is not running properly, which can prevent some WP Rocket features from working as intended:', count( $events ), 'rocket' ) . '
'; $message .= '' . __( 'Please contact your host to check if CRON is working.', 'rocket' ) . '
'; rocket_notice_html( [ 'status' => 'warning', 'dismissible' => '', 'message' => $message, 'dismiss_button' => __FUNCTION__, ] ); } /** * Add a link "Purge this cache" in the taxonomy edit area * * @since 3.5.5 deprecated * @since 1.0 * * @param array $actions An array of row action links. * @param object $term The term object. * @return array Updated array of row action links */ function rocket_tag_row_actions( $actions, $term ) { _deprecated_function( __FUNCTION__ . '()', '3.5.5', 'WP_Rocket\Engine\Cache\AdminSubscriber::add_purge_term_link()' ); global $taxnow; if ( ! current_user_can( 'rocket_purge_terms' ) ) { return $actions; } $url = wp_nonce_url( admin_url( 'admin-post.php?action=purge_cache&type=term-' . $term->term_id . '&taxonomy=' . $taxnow ), 'purge_cache_term-' . $term->term_id ); $actions['rocket_purge'] = sprintf( '%s', $url, __( 'Clear this cache', 'rocket' ) ); return $actions; }