3 ) { // Maximum class file path depth in this project is 3. $classPath = array_slice( $classPath, 0, 3 ); } $filePath = W3TC_LIB_DIR . DIRECTORY_SEPARATOR . implode( '/', $classPath ) . '.php'; require $filePath; return; } if ( !is_null( $base ) ) { $file = $base . strtr( $class, "\\_", DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR ) . '.php'; if ( is_readable( $file ) ) require_once $file; } else if ( substr( $class, 0, 5 ) == 'W3TC\\' ) { $filename = W3TC_DIR . DIRECTORY_SEPARATOR . substr( $class, 5 ) . '.php'; if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { if ( !file_exists( $filename ) ) { debug_print_backtrace(); } } require $filename; } } spl_autoload_register( 'w3tc_class_autoload' ); /** * W3 Total Cache plugins API */ /** * Returns config * */ function w3tc_config() { $config = \W3TC\Dispatcher::config(); return $config; } /** * Shortcut for url varnish flush */ function w3tc_flush_all() { $o = \W3TC\Dispatcher::component( 'CacheFlush' ); $o->flush_all(); } /** * Purges/Flushes post page */ function w3tc_flush_post( $post_id ) { $o = \W3TC\Dispatcher::component( 'CacheFlush' ); $o->flush_post( $post_id ); } /** * Purges/Flushes all posts */ function w3tc_flush_posts() { $o = \W3TC\Dispatcher::component( 'CacheFlush' ); $o->flush_posts(); } /** * Purges/Flushes url */ function w3tc_flush_url( $url ) { $o = \W3TC\Dispatcher::component( 'CacheFlush' ); $o->flush_url( $url ); } /** * deprecated * Shortcut for page cache flush * * @return boolean */ function w3tc_pgcache_flush() { return w3tc_flush_posts(); } /** * deprecated * Shortcut for page post cache flush * * @param integer $post_id * @return boolean */ function w3tc_pgcache_flush_post( $post_id ) { return w3tc_flush_post( $post_id ); } /** * deprecated * Shortcut for refreshing the media query string. */ function w3tc_browsercache_flush() { $o = \W3TC\Dispatcher::component( 'CacheFlush' ); return $o->browsercache_flush(); } /** * deprecated * Shortcut for database cache flush * */ function w3tc_dbcache_flush() { $o = \W3TC\Dispatcher::component( 'CacheFlush' ); $o->dbcache_flush(); } /** * deprecated * Shortcut for minify cache flush * */ function w3tc_minify_flush() { $o = \W3TC\Dispatcher::component( 'CacheFlush' ); $o->minifycache_flush(); } /** * deprecated * Shortcut for objectcache cache flush * */ function w3tc_objectcache_flush() { $o = \W3TC\Dispatcher::component( 'CacheFlush' ); $o->objectcache_flush(); } /** * deprecated * Shortcut for CDN purge files * * @param array $files Array consisting of uri paths (i.e wp-content/uploads/image.pnp) * @return mixed */ function w3tc_cdn_purge_files( $files ) { $o = \W3TC\Dispatcher::component( 'CacheFlush' ); return $o->cdn_purge_files( $files ); } /** * deprecated * Prints script tag for scripts group * * @param string $location * @retun void */ function w3tc_minify_script_group( $location ) { $o = \W3TC\Dispatcher::component( 'Minify_Plugin' ); $o->printed_scripts[] = $location; echo $o->get_script_group( $location ); } /** * deprecated * Prints style tag for styles group * * @param string $location * @retun void */ function w3tc_minify_style_group( $location ) { $o = \W3TC\Dispatcher::component( 'Minify_Plugin' ); $o->printed_styles[] = $location; echo $o->get_style_group( $location ); } /** * deprecated * Prints script tag for custom scripts * * @param string|array $files * @param boolean $blocking * @return void */ function w3tc_minify_script_custom( $files, $blocking = true ) { $o = \W3TC\Dispatcher::component( 'Minify_Plugin' ); echo $o->get_script_custom( $files, $blocking ); } /** * deprecated * Prints style tag for custom styles * * @param string|array $files * @return void */ function w3tc_minify_style_custom( $files ) { $o = \W3TC\Dispatcher::component( 'Minify_Plugin' ); echo $o->get_style_custom( $files ); } /** * deprecated * Use Util_Theme::get_themes() to get a list themenames to use with user agent groups * * @param unknown $group_name * @param string $theme the themename default is default theme. For childtheme it should be parentthemename/childthemename * @param string $redirect * @param array $agents Remember to escape special characters like spaces, dots or dashes with a backslash. Regular expressions are also supported. * @param bool $enabled */ function w3tc_save_user_agent_group( $group_name, $theme = 'default', $redirect = '', $agents = array(), $enabled = false ) { $o = \W3TC\Dispatcher::component( 'Mobile_UserAgent' ); $o->save_group( $group_name, $theme, $redirect, $agents, $enabled ); } /** * deprecated * * @param unknown $group */ function w3tc_delete_user_agent_group( $group ) { $o = \W3TC\Dispatcher::component( 'Mobile_UserAgent' ); $o->delete_group( $group ); } /** * deprecated * * @param unknown $group * @return mixed */ function w3tc_get_user_agent_group( $group ) { $o = \W3TC\Dispatcher::component( 'Mobile_UserAgent' ); return $o->get_group_values( $group ); } /** * deprecated * Use Util_Theme::get_themes() to get a list themenames to use with referrer groups * * @param unknown $group_name * @param string $theme the themename default is default theme. For childtheme it should be parentthemename/childthemename * @param string $redirect * @param array $referrers Remember to escape special characters like spaces, dots or dashes with a backslash. Regular expressions are also supported. * @param bool $enabled */ function w3tc_save_referrer_group( $group_name, $theme = 'default', $redirect = '', $referrers = array(), $enabled = false ) { $o = \W3TC\Dispatcher::component( 'Mobile_Referrer' ); $o->save_group( $group_name, $theme, $redirect, $referrers, $enabled ); } /** * deprecated * * @param unknown $group */ function w3tc_delete_referrer_group( $group ) { $o = \W3TC\Dispatcher::component( 'Mobile_Referrer' ); $o->delete_group( $group ); } /** * deprecated * * @param unknown $group * @return mixed */ function w3tc_get_referrer_group( $group ) { $o = \W3TC\Dispatcher::component( 'Mobile_Referrer' ); return $o->get_group_values( $group ); } /** * deprecated * Flushes files from opcache. * * @param bool $http if delete request should be made over http to current site. Default false. * @return mixed */ function w3tc_opcache_flush( $http = false ) { if ( !$http ) { $o = \W3TC\Dispatcher::component( 'CacheFlush' ); return $o->opcache_flush(); } else { $url = WP_PLUGIN_URL . '/' . dirname( W3TC_FILE ) . '/pub/opcache.php'; $path = parse_url( $url, PHP_URL_PATH ); $post = array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'body' => array( 'nonce' => wp_hash( $path ), 'command' => 'flush' ), ); $result = wp_remote_post( $url, $post ); if ( is_wp_error( $result ) ) { return $result; } elseif ( $result['response']['code'] != '200' ) { return $result['response']['code']; } return true; } } /** * deprecated * Reloads files. * * @param string[] $files list of files supports, fullpath, from root, wp-content * @param bool $http if delete request should be made over http to current site. Default false. * @return mixed */ function w3tc_opcache_flush_file( $file, $http = false ) { if ( !$http ) { $o = \W3TC\Dispatcher::component( 'CacheFlush' ); return $o->opcache_flush_file( $file ); } else { $url = WP_PLUGIN_URL . '/' . dirname( W3TC_FILE ) . '/pub/opcache.php'; $path = parse_url( $url, PHP_URL_PATH ); $post = array( 'method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'body' => array( 'nonce' => wp_hash( $path ), 'command' => 'flush_file', 'file' => $file ), ); $result = wp_remote_post( $url, $post ); if ( is_wp_error( $result ) ) { return $result; } elseif ( $result['response']['code'] != '200' ) { return $result['response']['code']; } return true; } }