本文整理汇总了PHP中w3_get_site_root函数的典型用法代码示例。如果您正苦于以下问题:PHP w3_get_site_root函数的具体用法?PHP w3_get_site_root怎么用?PHP w3_get_site_root使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了w3_get_site_root函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_groups
/**
* Returns minify groups
*
* @param string $theme
* @param string $template
* @param string $type
* @return array
*/
function get_groups($theme, $template, $type)
{
$result = array();
switch ($type) {
case 'css':
$groups = $this->_config->get_array('minify.css.groups');
break;
case 'js':
$groups = $this->_config->get_array('minify.js.groups');
break;
default:
return $result;
}
if (isset($groups[$theme]['default'])) {
$locations = (array) $groups[$theme]['default'];
} else {
$locations = array();
}
if ($template != 'default' && isset($groups[$theme][$template])) {
$locations = array_merge_recursive($locations, (array) $groups[$theme][$template]);
}
foreach ($locations as $location => $config) {
if (!empty($config['files'])) {
foreach ((array) $config['files'] as $file) {
$file = w3_normalize_file_minify2($file);
if (w3_is_url($file)) {
$precached_file = $this->_precache_file($file, $type);
if ($precached_file) {
$result[$location][$file] = $precached_file;
} else {
$this->error(sprintf('Unable to cache remote file: "%s"', $file));
}
} else {
if (!w3_is_multisite() && strpos(trailingslashit(WP_CONTENT_DIR), trailingslashit(w3_get_site_root())) !== false) {
$file = ltrim(w3_get_site_path(), '/') . str_replace(ltrim(w3_get_site_path(), '/'), '', $file);
}
$path = w3_get_document_root() . '/' . $file;
if (file_exists($path)) {
$result[$location][$file] = '//' . $file;
} else {
$this->error(sprintf('File "%s" doesn\'t exist', $path));
}
}
}
}
}
return $result;
}
示例2: w3_normalize_file
/**
* Normalizes file name
*
* Relative to site root!
*
* @param string $file
* @return string
*/
function w3_normalize_file($file)
{
if (w3_is_url($file)) {
if (strstr($file, '?') === false) {
$home_url_regexp = '~' . w3_get_home_url_regexp() . '~i';
$file = preg_replace($home_url_regexp, '', $file);
}
}
if (!w3_is_url($file)) {
$file = w3_path($file);
$file = str_replace(w3_get_site_root(), '', $file);
$file = ltrim($file, '/');
}
return $file;
}
示例3: get_server_info
/**
* Returns server info
*
* @return array
*/
function get_server_info()
{
global $wp_version, $wp_db_version, $wpdb;
$wordpress_plugins = get_plugins();
$wordpress_plugins_active = array();
foreach ($wordpress_plugins as $wordpress_plugin_file => $wordpress_plugin) {
if (is_plugin_active($wordpress_plugin_file)) {
$wordpress_plugins_active[$wordpress_plugin_file] = $wordpress_plugin;
}
}
$mysql_version = $wpdb->get_var('SELECT VERSION()');
$mysql_variables_result = (array) $wpdb->get_results('SHOW VARIABLES', ARRAY_N);
$mysql_variables = array();
foreach ($mysql_variables_result as $mysql_variables_row) {
$mysql_variables[$mysql_variables_row[0]] = $mysql_variables_row[1];
}
$server_info = array('w3tc' => array('version' => W3TC_VERSION, 'server' => !empty($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : 'Unknown', 'dir' => W3TC_DIR, 'cache_dir' => W3TC_CACHE_DIR, 'blog_id' => w3_get_blog_id(), 'document_root' => w3_get_document_root(), 'home_root' => w3_get_home_root(), 'site_root' => w3_get_site_root(), 'base_path' => w3_get_base_path(), 'home_path' => w3_get_home_path(), 'site_path' => w3_get_site_path()), 'wp' => array('version' => $wp_version, 'db_version' => $wp_db_version, 'abspath' => ABSPATH, 'home' => get_option('home'), 'siteurl' => get_option('siteurl'), 'email' => get_option('admin_email'), 'upload_info' => (array) w3_upload_info(), 'theme' => w3tc_get_current_theme(), 'wp_cache' => defined('WP_CACHE') && WP_CACHE ? 'true' : 'false', 'plugins' => $wordpress_plugins_active), 'mysql' => array('version' => $mysql_version, 'variables' => $mysql_variables));
return $server_info;
}
示例4: get_files_minify
/**
* Exports min files to CDN
*
* @return array
*/
function get_files_minify()
{
$files = array();
if (W3TC_PHP5 && $this->_config->get_boolean('minify.rewrite') && (!$this->_config->get_boolean('minify.auto') || w3_is_cdn_mirror($this->_config->get_string('cdn.engine')))) {
require_once W3TC_INC_DIR . '/functions/http.php';
$minify =& w3_instance('W3_Plugin_Minify');
$document_root = w3_get_document_root();
$site_root = w3_get_site_root();
$minify_root = w3_path(W3TC_CACHE_FILE_MINIFY_DIR);
$minify_path = ltrim(str_replace($site_root, rtrim(w3_get_site_path(), '/'), $minify_root), '/');
$urls = $minify->get_urls();
if ($this->_config->get_string('minify.engine') == 'file') {
foreach ($urls as $url) {
w3_http_get($url);
}
$files = $this->search_files($minify_root, $minify_path, '*.css;*.js');
} else {
foreach ($urls as $url) {
$file = w3_normalize_file_minify($url);
$file = w3_translate_file($file);
if (!w3_is_url($file)) {
$file = $document_root . '/' . $file;
$file = ltrim(str_replace($minify_root, '', $file), '/');
$dir = dirname($file);
if ($dir) {
w3_mkdir($dir, 0777, $minify_root);
}
if (w3_download($url, $minify_root . '/' . $file) !== false) {
$files[] = $minify_path . '/' . $file;
}
}
}
}
}
return $files;
}
示例5: get_files_custom
/**
* Exports custom files to CDN
*
* @return array
*/
function get_files_custom()
{
$files = array();
$document_root = w3_get_document_root();
$custom_files = $this->_config->get_array('cdn.custom.files');
$custom_files = array_map('w3_parse_path', $custom_files);
$site_root = w3_get_site_root();
$path = w3_get_site_path();
if (strstr(WP_CONTENT_DIR, w3_get_site_root()) === false) {
$site_root = w3_get_document_root();
$path = '';
}
$content_path = trim(substr(WP_CONTENT_DIR, strlen($site_root)), '/\\');
$wp_content_folder = basename(WP_CONTENT_DIR);
foreach ($custom_files as $custom_file) {
if ($custom_file != '') {
$custom_file = w3_normalize_file($custom_file);
if (!w3_is_multisite()) {
$dir = trim(dirname($path . $custom_file), '/\\');
$rel_path = trim(dirname($custom_file), '/\\');
} else {
$rel_path = $dir = trim(dirname($custom_file), '/\\');
}
if (strpos($dir, '<currentblog>') != false) {
$rel_path = $dir = str_replace('<currentblog>', 'blogs.dir/' . w3_get_blog_id(), $dir);
}
if ($content_path && $content_path != $wp_content_folder) {
$dir = str_replace($wp_content_folder, $content_path, $dir);
$rel_path = str_replace($wp_content_folder, $content_path, $rel_path);
}
if ($dir == '.') {
$rel_path = $dir = '';
}
$mask = basename($custom_file);
$files = array_merge($files, $this->search_files($document_root . '/' . $dir, $rel_path, $mask));
}
}
return $files;
}
示例6: w3_disable_maintenance_mode
/**
* Deletes maintenance mode file
*/
function w3_disable_maintenance_mode()
{
w3_wp_delete_file(w3_get_site_root() . '/.maintenance');
}