serving the default cache when they are present * * @since 3.4 * @author Remy Perona * * @return array */ function rocket_get_ignored_parameters() { $params = [ 'utm_source' => 1, 'utm_medium' => 1, 'utm_campaign' => 1, 'utm_expid' => 1, 'utm_term' => 1, 'utm_content' => 1, 'fb_action_ids' => 1, 'fb_action_types' => 1, 'fb_source' => 1, 'fbclid' => 1, 'gclid' => 1, 'age-verified' => 1, 'ao_noptimize' => 1, 'usqp' => 1, 'cn-reloaded' => 1, '_ga' => 1, ]; /** * Filters the ignored parameters * * @since 3.4 * @author Remy Perona * * @param array $params An array of ignored parameters as array keys. */ return apply_filters( 'rocket_cache_ignored_parameters', $params ); } /** * Get all uri we don't cache. * * @since 3.3.2 Exclude embedded URLs * @since 2.6 Using json_get_url_prefix() to auto-exclude the WordPress REST API. * @since 2.4.1 Auto-exclude WordPress REST API. * @since 2.0 * * @return string A pipe separated list of rejected uri. */ function get_rocket_cache_reject_uri() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals static $uris; if ( $uris ) { return $uris; } $uris = get_rocket_option( 'cache_reject_uri', [] ); $uris = is_array( $uris ) ? $uris : []; $home_root = rocket_get_home_dirname(); if ( '' !== $home_root && $uris ) { // The site is not at the domain root, it's in a folder. $home_root_escaped = preg_quote( $home_root, '/' ); $home_root_len = strlen( $home_root ); foreach ( $uris as $i => $uri ) { /** * Since these URIs can be regex patterns like `/homeroot(/.+)/`, we can't simply search for the string `/homeroot/` (nor `/homeroot`). * So this pattern searchs for `/homeroot/` and `/homeroot(/`. */ if ( ! preg_match( '/' . $home_root_escaped . '\(?\//', $uri ) ) { // Reject URIs located outside site's folder. unset( $uris[ $i ] ); continue; } // Remove the home directory. $uris[ $i ] = substr( $uri, $home_root_len ); } } // Exclude feeds. $uris[] = '/(.+/)?' . $GLOBALS['wp_rewrite']->feed_base . '/?'; // Exlude embedded URLs. $uris[] = '/(?:.+/)?embed/'; /** * Filter the rejected uri * * @since 2.1 * * @param array $uris List of rejected uri */ $uris = apply_filters( 'rocket_cache_reject_uri', $uris ); $uris = array_filter( $uris ); if ( ! $uris ) { return ''; } if ( '' !== $home_root ) { foreach ( $uris as $i => $uri ) { if ( preg_match( '/' . $home_root_escaped . '\(?\//', $uri ) ) { // Remove the home directory from the new URIs. $uris[ $i ] = substr( $uri, $home_root_len ); } } } $uris = implode( '|', $uris ); if ( '' !== $home_root ) { // Add the home directory back. $uris = $home_root . '(' . $uris . ')'; } return $uris; } /** * Get all cookie names we don't cache. * * @since 2.0 * * @return string A pipe separated list of rejected cookies. */ function get_rocket_cache_reject_cookies() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals $logged_in_cookie = explode( COOKIEHASH, LOGGED_IN_COOKIE ); $logged_in_cookie = array_map( 'preg_quote', $logged_in_cookie ); $logged_in_cookie = implode( '.+', $logged_in_cookie ); $cookies = get_rocket_option( 'cache_reject_cookies', [] ); $cookies[] = $logged_in_cookie; $cookies[] = 'wp-postpass_'; $cookies[] = 'wptouch_switch_toggle'; $cookies[] = 'comment_author_'; $cookies[] = 'comment_author_email_'; /** * Filter the rejected cookies. * * @since 2.1 * * @param array $cookies List of rejected cookies. */ $cookies = (array) apply_filters( 'rocket_cache_reject_cookies', $cookies ); $cookies = array_filter( $cookies ); $cookies = array_flip( array_flip( $cookies ) ); return implode( '|', $cookies ); } /** * Get list of mandatory cookies to be able to cache pages. * * @since 2.7 * * @return string A pipe separated list of mandatory cookies. */ function get_rocket_cache_mandatory_cookies() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals $cookies = []; /** * Filter list of mandatory cookies. * * @since 2.7 * * @param array $cookies List of mandatory cookies. */ $cookies = (array) apply_filters( 'rocket_cache_mandatory_cookies', $cookies ); $cookies = array_filter( $cookies ); $cookies = array_flip( array_flip( $cookies ) ); return implode( '|', $cookies ); } /** * Get list of dynamic cookies. * * @since 2.7 * * @return array List of dynamic cookies. */ function get_rocket_cache_dynamic_cookies() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals $cookies = []; /** * Filter list of dynamic cookies. * * @since 2.7 * * @param array $cookies List of dynamic cookies. */ $cookies = (array) apply_filters( 'rocket_cache_dynamic_cookies', $cookies ); $cookies = array_filter( $cookies ); $cookies = array_unique( $cookies ); return $cookies; } /** * Get all User-Agent we don't allow to get cache files. * * @since 2.3.5 * * @return string A pipe separated list of rejected User-Agent. */ function get_rocket_cache_reject_ua() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals $ua = get_rocket_option( 'cache_reject_ua', [] ); $ua[] = 'facebookexternalhit'; /** * Filter the rejected User-Agent * * @since 2.3.5 * * @param array $ua List of rejected User-Agent. */ $ua = (array) apply_filters( 'rocket_cache_reject_ua', $ua ); $ua = array_filter( $ua ); $ua = array_flip( array_flip( $ua ) ); $ua = implode( '|', $ua ); return str_replace( [ ' ', '\\\\ ' ], '\\ ', $ua ); } /** * Get all query strings which can be cached. * * @since 2.3 * * @return array List of query strings which can be cached. */ function get_rocket_cache_query_string() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals $query_strings = get_rocket_option( 'cache_query_strings', [] ); /** * Filter query strings which can be cached. * * @since 2.3 * * @param array $query_strings List of query strings which can be cached. */ $query_strings = (array) apply_filters( 'rocket_cache_query_strings', $query_strings ); $query_strings = array_filter( $query_strings ); $query_strings = array_flip( array_flip( $query_strings ) ); return $query_strings; } /** * Get list of JS files to be excluded from defer JS. * * @since 2.10 * @author Remy Perona * * @return array An array of URLs for the JS files to be excluded. */ function get_rocket_exclude_defer_js() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals $exclude_defer_js = [ 'gist.github.com', 'content.jwplatform.com', 'js.hsforms.net', 'www.uplaunch.com', 'google.com/recaptcha', 'widget.reviews.co.uk', 'verify.authorize.net/anetseal', 'lib/admin/assets/lib/webfont/webfont.min.js', 'app.mailerlite.com', ]; if ( get_rocket_option( 'defer_all_js', 0 ) && get_rocket_option( 'defer_all_js_safe', 0 ) ) { $jquery = site_url( wp_scripts()->registered['jquery-core']->src ); $jetpack_jquery = 'c0.wp.com/c/(?:.+)/wp-includes/js/jquery/jquery.js'; $googleapis_jquery = 'ajax.googleapis.com/ajax/libs/jquery/(?:.+)/jquery(?:\.min)?.js'; $cdnjs_jquery = 'cdnjs.cloudflare.com/ajax/libs/jquery/(?:.+)/jquery(?:\.min)?.js'; $exclude_defer_js[] = rocket_clean_exclude_file( $jquery ); $exclude_defer_js[] = $jetpack_jquery; $exclude_defer_js[] = $googleapis_jquery; $exclude_defer_js[] = $cdnjs_jquery; } /** * Filter list of Deferred JavaScript files * * @since 2.10 * @author Remy Perona * * @param array $exclude_defer_js An array of URLs for the JS files to be excluded. */ $exclude_defer_js = apply_filters( 'rocket_exclude_defer_js', $exclude_defer_js ); foreach ( $exclude_defer_js as $i => $exclude ) { $exclude_defer_js[ $i ] = str_replace( '#', '\#', $exclude ); } return $exclude_defer_js; } /** * Get list of CSS files to be excluded from async CSS. * * @since 2.10 * @author Remy Perona * * @return array An array of URLs for the CSS files to be excluded. */ function get_rocket_exclude_async_css() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals /** * Filter list of async CSS files * * @since 2.10 * @author Remy Perona * * @param array $exclude_async_css An array of URLs for the CSS files to be excluded. */ $exclude_async_css = (array) apply_filters( 'rocket_exclude_async_css', [] ); $exclude_async_css = array_filter( $exclude_async_css ); $exclude_async_css = array_flip( array_flip( $exclude_async_css ) ); return $exclude_async_css; } /** * Determine if the key is valid * * @since 2.9 use hash_equals() to compare the hash values * @since 1.0 * * @return bool true if everything is ok, false otherwise */ function rocket_valid_key() { return true; } /** * Determine if the key is valid. * * @since 2.9.7 Remove arguments ($type & $data). * @since 2.9.7 Stop to auto-check the validation each 1 & 30 days. * @since 2.2 The function do the live check and update the option. * * @return bool|array */ function rocket_check_key() { // Recheck the license. $return = rocket_valid_key(); Logger::info( 'LICENSE VALIDATION PROCESS STARTED.', [ 'license validation process' ] ); $response = wp_remote_get( rocket_get_constant( 'WP_ROCKET_WEB_VALID' ), [ 'timeout' => 30, ] ); if ( is_wp_error( $response ) ) { Logger::error( 'License validation failed.', [ 'license validation process', 'request_error' => $response->get_error_messages(), ] ); set_transient( 'rocket_check_key_errors', $response->get_error_messages() ); return $return; } $body = wp_remote_retrieve_body( $response ); $json = json_decode( $body ); if ( null === $json ) { if ( '' === $body ) { Logger::error( 'License validation failed. No body available in response.', [ 'license validation process' ] ); // Translators: %1$s = opening em tag, %2$s = closing em tag, %3$s = opening link tag, %4$s closing link tag. $message = __( 'License validation failed. Our server could not resolve the request from your website.', 'rocket' ) . '
' . sprintf( __( 'Try clicking %1$sSave Changes%2$s below. If the error persists, follow %3$sthis guide%4$s.', 'rocket' ), '', '', '', '' ); set_transient( 'rocket_check_key_errors', [ $message ] ); return $return; } Logger::error( 'License validation failed.', [ 'license validation process', 'response_body' => $body, ] ); if ( 'NULLED' === $body ) { // Translators: %1$s = opening link tag, %2$s = closing link tag. $message = __( 'License validation failed. You may be using a nulled version of the plugin. Please do the following:', 'rocket' ) . '' . sprintf( __( 'If you do not have a WP Rocket account, please %1$spurchase a license%2$s.', 'rocket' ), '', '' ); set_transient( 'rocket_check_key_errors', [ $message ] ); return $return; } if ( 'BAD_USER' === $body ) { // Translators: %1$s = opening link tag, %2$s = closing link tag. $message = __( 'License validation failed. This user account does not exist in our database.', 'rocket' ) . '
' . sprintf( __( 'To resolve, please contact support.', 'rocket' ), '', '' ); set_transient( 'rocket_check_key_errors', [ $message ] ); return $return; } if ( 'USER_BLACKLISTED' === $body ) { // Translators: %1$s = opening link tag, %2$s = closing link tag. $message = __( 'License validation failed. This user account is blacklisted.', 'rocket' ) . '
' . sprintf( __( 'Please see %1$sthis guide%2$s for more info.', 'rocket' ), '', '' ); set_transient( 'rocket_check_key_errors', [ $message ] ); return $return; } // Translators: %1$s = opening em tag, %2$s = closing em tag, %3$s = opening link tag, %4$s closing link tag. $message = __( 'License validation failed. Our server could not resolve the request from your website.', 'rocket' ) . '
' . sprintf( __( 'Try clicking %1$sSave Changes%2$s below. If the error persists, follow %3$sthis guide%4$s.', 'rocket' ), '', '', '', '' ); set_transient( 'rocket_check_key_errors', [ $message ] ); return $return; } $rocket_options = []; $rocket_options['consumer_key'] = $json->data->consumer_key; $rocket_options['consumer_email'] = $json->data->consumer_email; if ( ! $json->success ) { $messages = [ // Translators: %1$s = opening link tag, %2$s = closing link tag. 'BAD_LICENSE' => __( 'Your license is not valid.', 'rocket' ) . '
' . sprintf( __( 'Make sure you have an active %1$sWP Rocket license%2$s.', 'rocket' ), '', '' ), // Translators: %1$s = opening link tag, %2$s = closing link tag, %3$s = opening link tag. 'BAD_NUMBER' => __( 'You have added as many sites as your current license allows.', 'rocket' ) . '
' . sprintf( __( 'Upgrade your %1$saccount%2$s or %3$stransfer your license%2$s to this domain.', 'rocket' ), '', '', '' ), // Translators: %1$s = opening link tag, %2$s = closing link tag. 'BAD_SITE' => __( 'This website is not allowed.', 'rocket' ) . '
' . sprintf( __( 'Please %1$scontact support%2$s.', 'rocket' ), '
', '' ), // Translators: %1$s = opening link tag, %2$s = closing link tag. 'BAD_KEY' => __( 'This license key is not recognized.', 'rocket' ) . '' . sprintf( __( 'If the issue persists, please %1$scontact support%2$s.', 'rocket' ), '', '' ), ]; $rocket_options['secret_key'] = ''; // Translators: %s = error message returned. set_transient( 'rocket_check_key_errors', [ sprintf( __( 'License validation failed: %s', 'rocket' ), $messages[ $json->data->reason ] ) ] ); Logger::error( 'License validation failed.', [ 'license validation process', 'response_error' => $json->data->reason, ] ); set_transient( rocket_get_constant( 'WP_ROCKET_SLUG' ), $rocket_options ); return $rocket_options; } $rocket_options['secret_key'] = $json->data->secret_key; if ( ! get_rocket_option( 'license' ) ) { $rocket_options['license'] = '1'; } Logger::info( 'License validation successful.', [ 'license validation process' ] ); set_transient( rocket_get_constant( 'WP_ROCKET_SLUG' ), $rocket_options ); delete_transient( 'rocket_check_key_errors' ); rocket_delete_licence_data_file(); return $rocket_options; } /** * Deletes the licence-data.php file if it exists * * @since 3.5 * @author Remy Perona * * @return void */ function rocket_delete_licence_data_file() { if ( is_multisite() ) { return; } $rocket_path = rocket_get_constant( 'WP_ROCKET_PATH' ); if ( ! rocket_direct_filesystem()->exists( $rocket_path . 'licence-data.php' ) ) { return; } rocket_direct_filesystem()->delete( $rocket_path . 'licence-data.php' ); } /** * Is WP a MultiSite and a subfolder install? * * @since 3.1.1 * @author Grégory Viguier * * @return bool */ function rocket_is_subfolder_install() { global $wpdb; static $subfolder_install; if ( isset( $subfolder_install ) ) { return $subfolder_install; } if ( is_multisite() ) { $subfolder_install = ! is_subdomain_install(); } elseif ( ! is_null( $wpdb->sitemeta ) ) { $subfolder_install = ! $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery } else { $subfolder_install = false; } return $subfolder_install; } /** * Get the name of the "home directory", in case the home URL is not at the domain's root. * It can be seen like the `RewriteBase` from the .htaccess file, but without the trailing slash. * * @since 3.1.1 * @author Grégory Viguier * * @return string */ function rocket_get_home_dirname() { static $home_root; if ( isset( $home_root ) ) { return $home_root; } $home_root = wp_parse_url( rocket_get_main_home_url() ); if ( ! empty( $home_root['path'] ) ) { $home_root = '/' . trim( $home_root['path'], '/' ); $home_root = rtrim( $home_root, '/' ); } else { $home_root = ''; } return $home_root; } /** * Get the URL of the site's root. It corresponds to the main site's home page URL. * * @since 3.1.1 * @author Grégory Viguier * * @return string */ function rocket_get_main_home_url() { static $root_url; if ( isset( $root_url ) ) { return $root_url; } if ( ! is_multisite() || is_main_site() ) { $root_url = rocket_get_home_url( '/' ); return $root_url; } $current_network = get_network(); if ( $current_network ) { $root_url = set_url_scheme( 'https://' . $current_network->domain . $current_network->path ); $root_url = trailingslashit( $root_url ); } else { $root_url = rocket_get_home_url( '/' ); } return $root_url; }
Fatal error: Uncaught Error: Call to undefined function rocket_valid_key() in /home/payon/public_html/wp-content/plugins/wp-rocket/inc/classes/class-plugin.php:103 Stack trace: #0 /home/payon/public_html/wp-content/plugins/wp-rocket/inc/main.php(40): WP_Rocket\Plugin->load() #1 /home/payon/public_html/wp-includes/class-wp-hook.php(308): rocket_init('') #2 /home/payon/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array) #3 /home/payon/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #4 /home/payon/public_html/wp-settings.php(486): do_action('plugins_loaded') #5 /home/payon/public_html/wp-config.php(92): require_once('/home/payon/pub...') #6 /home/payon/public_html/wp-load.php(50): require_once('/home/payon/pub...') #7 /home/payon/public_html/wp-blog-header.php(13): require_once('/home/payon/pub...') #8 /home/payon/public_html/index.php(17): require('/home/payon/pub...') #9 {main} thrown in /home/payon/public_html/wp-content/plugins/wp-rocket/inc/classes/class-plugin.php on line 103