)V Ec*V G*V Gc*V Gc*V  G`)V ; *V <`*V `+p&*V 0 )V@*p&*VP 00+V0@ H+VH*V H+VH0+V Ha*V H9+VPt *V@<d.VP@pF.VP``*V`@++*V0 >-V` -Vp )V EQ.VPPB *V<d.V,Vp p*V Pt *V<d.V-V`` -VP p.VPpQ+V (Rb.V)V@E*V Pt*V`tQ.VpB *V <d.V )V@9`)V`H=)VPPE*V`PtQ.V`B *VP<,VPPu*.V`uO.VpC`)V2+V@:pF.Vp*Vp`*V`+p.VPpQb.V` )V@*PL*VYkM-Vp"P-V`{*V`.*Vp*V4@*V, K-V``*V@++*V>)V`E,Vd-V`i^,VP*V``t*VPpt *V<d.V,Vp,Vd-V` ^,V P,V'#p-V0+V0@G9+V@Pt *VP<,VPP`Ga*V@P`H-V@`H9+V``t*V<+*V>~ӷӷAӷXAPӷXAAӷ5AAA ӷqӷ5Aӷ`xA0Apёӷӷ8=Aӷhӷ8ӷAӷӷaAӷAaApӷӷ(AӷкAA8ӷ@ӷӷPAhA`[ӷsӷxӷhA%ӷ$ӷPtӷ tӷx%ӷAHsAXA`VV8 8zM90.4 183.6c6.7-17.6 26.7-26.7 44.9-21.9l7.1 1.9 2-7.1c5-18.1 22.8-30.9 41.5-27.9 21.4 3.4 3Conventions.PrefixAllGlobals $langs = [ 'fr_FR' => 'fr.', ]; $lang = get_locale(); $prefix = isset( $langs[ $lang ] ) ? $langs[ $lang ] : ''; $url = "https://{$prefix}docs.wp-rocket.me/?utm_source=wp_plugin&utm_medium=wp_rocket"; return $url; } /** * Get WP Rocket FAQ URL * * @since 2.10 * @author Remy Perona * * @return string URL in the correct language */ function get_rocket_faq_url() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals $langs = [ 'de' => 1, 'es' => 1, 'fr' => 1, 'it' => 1, ]; $locale = explode( '_', get_locale() ); $lang = isset( $langs[ $locale[0] ] ) ? $locale[0] . '/' : ''; $url = WP_ROCKET_WEB_MAIN . "{$lang}faq/?utm_source=wp_plugin&utm_medium=wp_rocket"; return $url; } /** * Get the Activation Link for a given plugin * * @since 2.7.3 * @author Geoffrey Crofte * * @param string $plugin the given plugin folder/file.php (e.i. "imagify/imagify.php"). * @return string URL to activate the plugin */ function rocket_get_plugin_activation_link( $plugin ) { $activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin ); return $activation_url; } /** * Check if a given plugin is installed but not necessarily activated * Note: get_plugins( $folder ) from WP Core doesn't work * * @since 2.7.3 * @author Geoffrey Crofte * * @param string $plugin a plugin folder/file.php (e.i. "imagify/imagify.php"). * @return bool True if installed, false otherwise */ function rocket_is_plugin_installed( $plugin ) { $installed_plugins = get_plugins(); return isset( $installed_plugins[ $plugin ] ); } /** * When Woocommerce, EDD, iThemes Exchange, Jigoshop & WP-Shop options are saved or deleted, * we update .htaccess & config file to get the right checkout page to exclude to the cache. * * @since 2.9.3 Support for SF Move Login moved to 3rd party file * @since 2.6 Add support with SF Move Login & WPS Hide Login to exclude login pages * @since 2.4 * * @param array $old_value An array of previous settings values. * @param array $value An array of submitted settings values. */ function rocket_after_update_single_options( $old_value, $value ) { if ( $old_value !== $value ) { // Update .htaccess file rules. flush_rocket_htaccess(); // Update config file. rocket_generate_config_file(); } } /** * We need to regenerate the config file + htaccess depending on some plugins * * @since 2.9.3 Support for SF Move Login moved to 3rd party file * @since 2.6.5 Add support with SF Move Login & WPS Hide Login * * @param array $old_value An array of previous settings values. * @param array $value An array of submitted settings values. */ function rocket_after_update_array_options( $old_value, $value ) { $options = [ 'purchase_page', 'jigoshop_cart_page_id', 'jigoshop_checkout_page_id', 'jigoshop_myaccount_page_id', ]; foreach ( $options as $val ) { if ( ( ! isset( $old_value[ $val ] ) && isset( $value[ $val ] ) ) || ( isset( $old_value[ $val ], $value[ $val ] ) && $old_value[ $val ] !== $value[ $val ] ) ) { // Update .htaccess file rules. flush_rocket_htaccess(); // Update config file. rocket_generate_config_file(); break; } } } /** * Check if a mobile plugin is active * * @since 2.10 * @author Remy Perona * * @return bool true if a mobile plugin in the list is active, false otherwise. **/ function rocket_is_mobile_plugin_active() { return \WP_Rocket\Subscriber\Third_Party\Plugins\Mobile_Subscriber::is_mobile_plugin_active(); } /** * Allow upload of JSON file. * * @since 2.10.7 * @author Remy Perona * * @param array $wp_get_mime_types Array of allowed mime types. * @return array Updated array of allowed mime types */ function rocket_allow_json_mime_type( $wp_get_mime_types ) { $wp_get_mime_types['json'] = 'application/json'; return $wp_get_mime_types; } /** * Forces the correct file type for JSON file if the WP checks is incorrect * * @since 3.2.3.1 * @author Gregory Viguier * * @param array $wp_check_filetype_and_ext File data array containing 'ext', 'type', and * 'proper_filename' keys. * @param string $file Full path to the file. * @param string $filename The name of the file (may differ from $file due to * $file being in a tmp directory). * @param array $mimes Key is the file extension with value as the mime type. * @return array */ function rocket_check_json_filetype( $wp_check_filetype_and_ext, $file, $filename, $mimes ) { if ( ! empty( $wp_check_filetype_and_ext['ext'] ) && ! empty( $wp_check_filetype_and_ext['type'] ) ) { return $wp_check_filetype_and_ext; } $wp_filetype = wp_check_filetype( $filename, $mimes ); if ( 'json' !== $wp_filetype['ext'] ) { return $wp_check_filetype_and_ext; } if ( empty( $wp_filetype['type'] ) ) { // In case some other filter messed it up. $wp_filetype['type'] = 'application/json'; } if ( ! extension_loaded( 'fileinfo' ) ) { return $wp_check_filetype_and_ext; } $finfo = finfo_open( FILEINFO_MIME_TYPE ); $real_mime = finfo_file( $finfo, $file ); finfo_close( $finfo ); // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated if ( 'text/plain' !== $real_mime ) { return $wp_check_filetype_and_ext; } $wp_check_filetype_and_ext = array_merge( $wp_check_filetype_and_ext, $wp_filetype ); return $wp_check_filetype_and_ext; } /** * Lists Data collected for analytics * * @since 2.11 * @author Caspar Hübinger * * @return string HTML list table */ function rocket_data_collection_preview_table() { $data = rocket_analytics_data(); if ( ! $data ) { return; } $html = ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= '
'; $html .= sprintf( '%s', __( 'Server type:', 'rocket' ) ); $html .= ''; $html .= sprintf( '%s', $data['web_server'] ); $html .= '
'; $html .= sprintf( '%s', __( 'PHP version number:', 'rocket' ) ); $html .= ''; $html .= sprintf( '%s', $data['php_version'] ); $html .= '
'; $html .= sprintf( '%s', __( 'WordPress version number:', 'rocket' ) ); $html .= ''; $html .= sprintf( '%s', $data['wordpress_version'] ); $html .= '
'; $html .= sprintf( '%s', __( 'WordPress multisite:', 'rocket' ) ); $html .= ''; $html .= sprintf( '%s', $data['multisite'] ? 'true' : 'false' ); $html .= '
'; $html .= sprintf( '%s', __( 'Current theme:', 'rocket' ) ); $html .= ''; $html .= sprintf( '%s', $data['current_theme'] ); $html .= '
'; $html .= sprintf( '%s', __( 'Current site language:', 'rocket' ) ); $html .= ''; $html .= sprintf( '%s', $data['locale'] ); $html .= '
'; $html .= sprintf( '%s', __( 'Active plugins:', 'rocket' ) ); $html .= ''; $html .= sprintf( '%s', __( 'Plugin names of all active plugins', 'rocket' ) ); $html .= '
'; $html .= sprintf( '%s', __( 'Anonymized WP Rocket settings:', 'rocket' ) ); $html .= ''; $html .= sprintf( '%s', __( 'Which WP Rocket settings are active', 'rocket' ) ); $html .= '
'; $html .= sprintf( '%s', __( 'Anonymized WP Rocket statistics:', 'rocket' ) ); $html .= ''; $html .= sprintf( '%s', __( 'How WP Rocket features function and perform.', 'rocket' ) ); $html .= '
'; $html .= sprintf( '%s', __( 'WP Rocket license type', 'rocket' ) ); $html .= ''; $html .= sprintf( '%s', $data['license_type'] ); $html .= '
'; return $html; } /** * Adds error message after settings import and redirects. * * @since 3.0 * @author Remy Perona * * @param string $message Message to display in the error notice. * @param string $status Status of the error. * @return void */ function rocket_settings_import_redirect( $message, $status ) { add_settings_error( 'general', 'settings_updated', $message, $status ); set_transient( 'settings_errors', get_settings_errors(), 30 ); $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); wp_safe_redirect( esc_url_raw( $goback ) ); die(); } /** * Check if WPR options should be displayed. * * @return bool */ function rocket_can_display_options() { $disallowed_post_status = [ 'draft', 'trash', 'private', 'future', 'pending', ]; $post_status = get_post_status(); if ( in_array( $post_status, $disallowed_post_status, true ) ) { return false; } if ( function_exists( 'get_current_screen' ) && is_object( get_current_screen() ) && 'add' === get_current_screen()->action ) { return false; } return true; } /** * Create a hash from wp rocket options. * * @param array $value options. * * @return string */ function rocket_create_options_hash( $value ) { $removed = [ 'cache_mobile' => true, 'purge_cron_interval' => true, 'purge_cron_unit' => true, 'database_revisions' => true, 'database_auto_drafts' => true, 'database_trashed_posts' => true, 'database_spam_comments' => true, 'database_trashed_comments' => true, 'database_all_transients' => true, 'database_optimize_tables' => true, 'schedule_automatic_cleanup' => true, 'automatic_cleanup_frequency' => true, 'do_cloudflare' => true, 'cloudflare_email' => true, 'cloudflare_api_key' => true, 'cloudflare_zone_id' => true, 'cloudflare_devmode' => true, 'cloudflare_auto_settings' => true, 'cloudflare_old_settings' => true, 'heartbeat_admin_behavior' => true, 'heartbeat_editor_behavior' => true, 'varnish_auto_purge' => true, 'analytics_enabled' => true, 'sucury_waf_cache_sync' => true, 'sucury_waf_api_key' => true, 'manual_preload' => true, 'preload_excluded_uri' => true, 'cache_reject_uri' => true, 'version' => true, ]; // Create 2 arrays to compare. $value_diff = array_diff_key( $value, $removed ); ksort( $value_diff ); return md5( wp_json_encode( $value_diff ) ); } /** * This function returns the license type for a customer. * * @param object $customer_data customer data as an object. * @return string the type of the license the user has. */ function rocket_get_license_type( $customer_data ) { if ( false === $customer_data || ! isset( $customer_data->licence_account ) ) { return __( 'Unavailable', 'rocket' ); } if ( isset( $customer_data->licence->is_revoked ) && $customer_data->licence->is_revoked ) { return __( 'Revoked', 'rocket' ); } // The licence name directly from User endpoint. if ( ! empty( $customer_data->licence->name ) ) { return esc_html( $customer_data->licence->name ); } // Fallback to licence account. if ( 1 <= $customer_data->licence_account && $customer_data->licence_account < 3 ) { return 'Single'; } elseif ( -1 === (int) $customer_data->licence_account ) { return 'Infinite'; } return 'Plus'; } /** * Fires callback attached to a deprecated filter hook. * * @param string $new_hook The hook that should have been used. * @param array $args Array of additional function arguments to be passed. * @param string $version The version of WPR that deprecated the hook. * @param string $old_hook Name of the original filter hook. * * @return mixed The filtered value after all hooked functions are applied to it. */ function rocket_apply_filter_and_deprecated( string $new_hook, array $args, string $version, string $old_hook ) { $filtered_value = apply_filters_deprecated( $old_hook, $args, $version, $new_hook ); $args[0] = $filtered_value; return apply_filters_ref_array( $new_hook, $args ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals } /** * Fires callback attached to a deprecated action hook. * * @param string $new_hook The hook that should have been used. * @param array $args Array of additional function arguments to be passed. * @param string $version The version of WPR that deprecated the hook. * @param string $old_hook The name of the action hook. * * @return void */ function rocket_do_action_and_deprecated( string $new_hook, array $args, string $version, string $old_hook ): void { do_action_deprecated( $old_hook, $args, $version, $new_hook ); do_action_ref_array( $new_hook, $args ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals }