本文整理汇总了PHP中w3_get_document_root函数的典型用法代码示例。如果您正苦于以下问题:PHP w3_get_document_root函数的具体用法?PHP w3_get_document_root怎么用?PHP w3_get_document_root使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了w3_get_document_root函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: w3_get_nginx_rules_path
/**
* Returns nginx rules path
*
* @return string
*/
function w3_get_nginx_rules_path()
{
$config = w3_instance('W3_Config');
$path = $config->get_string('config.path');
if (!$path) {
$path = w3_get_document_root() . '/nginx.conf';
}
return $path;
}
开发者ID:easinewe,项目名称:Avec2016,代码行数:14,代码来源:rule.php
示例2: create
/**
* @throws FilesystemWriteException
* @throws FilesystemWriteException
*/
public function create()
{
$path = trim(w3_get_wp_sitepath(), "/");
if ($path) {
$path .= '/';
}
$file_data = "\n<?php\n if (W3TC_WP_LOADING)\n require_once '" . w3_get_document_root() . '/' . $path . "wp-load.php';\n";
$filename = W3TC_WP_LOADER;
$data = $file_data;
w3_require_once(W3TC_INC_DIR . '/functions/rule.php');
$current_data = @file_get_contents($filename);
if (strstr(w3_clean_rules($current_data), w3_clean_rules($data)) !== false) {
return;
}
w3_require_once(W3TC_INC_DIR . '/functions/activation.php');
w3_wp_write_to_file($filename, $data, '', $_SERVER['REQUEST_URI']);
}
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:21,代码来源:WpLoader.php
示例3: abspath_to_relative_path
/**
* Taks an absolute path and converts to a relative path to root
* @param $path
* @return mixed
*/
function abspath_to_relative_path($path)
{
return str_replace(w3_get_document_root(), '', $path);
}
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:9,代码来源:CdnCommon.php
示例4: import_library
/**
* Imports library
*
* @param integer $limit
* @param integer $offset
* @param integer $count
* @param integer $total
* @param array $results
* @return boolean
*/
function import_library($limit, $offset, &$count, &$total, &$results)
{
global $wpdb;
$count = 0;
$total = 0;
$results = array();
$upload_info = w3_upload_info();
$uploads_use_yearmonth_folders = get_option('uploads_use_yearmonth_folders');
$document_root = w3_get_document_root();
@set_time_limit($this->_config->get_integer('timelimit.cdn_import'));
if ($upload_info) {
/**
* Search for posts with links or images
*/
$sql = sprintf('SELECT
ID,
post_content,
post_date
FROM
%sposts
WHERE
post_status = "publish"
AND (post_type = "post" OR post_type = "page")
AND (post_content LIKE "%%src=%%"
OR post_content LIKE "%%href=%%")
', $wpdb->prefix);
if ($limit) {
$sql .= sprintf(' LIMIT %d', $limit);
if ($offset) {
$sql .= sprintf(' OFFSET %d', $offset);
}
}
$posts = $wpdb->get_results($sql);
if ($posts) {
$count = count($posts);
$total = $this->get_import_posts_count();
$regexp = '~(' . $this->get_regexp_by_mask($this->_config->get_string('cdn.import.files')) . ')$~';
$import_external = $this->_config->get_boolean('cdn.import.external');
foreach ($posts as $post) {
$matches = null;
$replaced = array();
$attachments = array();
$post_content = $post->post_content;
/**
* Search for all link and image sources
*/
if (preg_match_all('~(href|src)=[\'"]?([^\'"<>\\s]+)[\'"]?~', $post_content, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
list($search, $attribute, $origin) = $match;
/**
* Check if $search is already replaced
*/
if (isset($replaced[$search])) {
continue;
}
$error = '';
$result = false;
$src = w3_normalize_file_minify($origin);
$dst = '';
/**
* Check if file exists in the library
*/
if (stristr($origin, $upload_info['baseurl']) === false) {
/**
* Check file extension
*/
$check_src = $src;
if (w3_is_url($check_src)) {
$qpos = strpos($check_src, '?');
if ($qpos !== false) {
$check_src = substr($check_src, 0, $qpos);
}
}
if (preg_match($regexp, $check_src)) {
/**
* Check for already uploaded attachment
*/
if (isset($attachments[$src])) {
list($dst, $dst_url) = $attachments[$src];
$result = true;
} else {
if ($uploads_use_yearmonth_folders) {
$upload_subdir = date('Y/m', strtotime($post->post_date));
$upload_dir = sprintf('%s/%s', $upload_info['basedir'], $upload_subdir);
$upload_url = sprintf('%s/%s', $upload_info['baseurl'], $upload_subdir);
} else {
$upload_subdir = '';
$upload_dir = $upload_info['basedir'];
$upload_url = $upload_info['baseurl'];
}
//.........这里部分代码省略.........
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:101,代码来源:CdnAdmin.php
示例5: w3_normalize_file_minify
function w3_normalize_file_minify($file)
{
global $wp_rewrite;
$hmwp = new HideMyWP();
$hmwp->init();
$hmwp->add_rewrite_rules($wp_rewrite);
$file = $hmwp->reverse_partial_filter($file);
if (w3_is_url($file)) {
if (strstr($file, '?') === false) {
$domain_url_regexp = '~' . w3_get_domain_url_regexp() . '~i';
$file = preg_replace($domain_url_regexp, '', $file);
}
}
if (!w3_is_url($file)) {
$file = w3_path($file);
$file = str_replace(w3_get_document_root(), '', $file);
$file = ltrim($file, '/');
}
return $file;
}
开发者ID:roycocup,项目名称:enclothed,代码行数:20,代码来源:hide-my-wp.php
示例6: is_file_for_minification
/**
* URL file filter
*
* @param string $file
* @return bool
*/
public function is_file_for_minification($file)
{
static $external;
$ext = strrchr($file, '.');
if ($ext != '.js' && $ext != '.css') {
return false;
}
if (!isset($external)) {
$external = $this->config->get_array('minify.cache.files');
}
foreach ($external as $ext) {
if (preg_match('#' . w3_get_url_regexp($ext) . '#', $file)) {
return true;
}
}
if (w3_is_url($file)) {
return false;
}
/** @var W3_MinifyFileTool $file_tool */
$file_tool = w3_instance('W3_MinifyFileTool');
$file_tool->setDocumentRoot(w3_get_document_root());
if (!$file_tool->fileExists($file)) {
return false;
}
return true;
}
开发者ID:jcastilloa,项目名称:w3tc-transparentcdn,代码行数:32,代码来源:Minify.php
示例7: _minify_path_replacements
/**
* Paths used to minify minifyfile paths
* @return array
*/
private function _minify_path_replacements()
{
$theme = get_theme_root();
return array(ltrim(str_replace(w3_get_document_root(), '', w3_path($theme)), '/'), ltrim(str_replace(w3_get_document_root(), '', w3_path(WP_PLUGIN_DIR)), '/'), ltrim(str_replace(w3_get_document_root(), '', w3_path(WPMU_PLUGIN_DIR)), '/'), WPINC . '/js/jquery', WPINC . '/js', WPINC . '/css', WPINC);
}
开发者ID:easinewe,项目名称:Avec2016,代码行数:9,代码来源:Minify.php
示例8: w3_normalize_file_minify
/**
* Normalizes file name for minify
*
* Relative to document root!
*
* @param string $file
* @return string
*/
function w3_normalize_file_minify($file)
{
if (w3_is_url($file)) {
if (strstr($file, '?') === false) {
$domain_url_regexp = '~' . w3_get_domain_url_regexp() . '~i';
$file = preg_replace($domain_url_regexp, '', $file);
}
}
if (!w3_is_url($file)) {
$file = w3_path($file);
$file = str_replace(w3_get_document_root(), '', $file);
$file = ltrim($file, '/');
}
return $file;
}
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:23,代码来源:define.php
示例9: 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);
foreach ($custom_files as $custom_file) {
if ($custom_file != '') {
$custom_file = w3_normalize_file($custom_file);
$dir = trim(dirname($custom_file), '/\\');
if ($dir == '.') {
$dir = '';
}
$mask = basename($custom_file);
$files = array_merge($files, $this->search_files($document_root . '/' . $dir, $dir, $mask));
}
}
return $files;
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:24,代码来源:Cdn.php
示例10: w3tc_loader_file_data
public function w3tc_loader_file_data()
{
$filename = W3TC_WP_LOADER;
$data = "\n<?php\n if (W3TC_WP_LOADING)\n require_once '" . w3_get_document_root() . '/' . trim(w3_get_site_path(), "/") . "/wp-load.php';\n";
return array('filename' => $filename, 'data' => $data);
}
开发者ID:getupcloud,项目名称:wordpress-ex,代码行数:6,代码来源:Setup.php
示例11: _minify_path_replacements
/**
* Paths used to minify minifyfile paths
* @return array
*/
private function _minify_path_replacements()
{
if (w3_is_network()) {
$theme = get_theme_root();
} else {
$theme = get_stylesheet_directory();
}
return array(ltrim(str_replace(w3_get_document_root(), '', w3_path($theme)), '/'), ltrim(str_replace(w3_get_document_root(), '', w3_path(WP_PLUGIN_DIR)), '/'), ltrim(str_replace(w3_get_document_root(), '', w3_path(WPMU_PLUGIN_DIR)), '/'), WPINC . '/js/jquery', WPINC . '/js', WPINC . '/css', WPINC);
}
开发者ID:Creative-Srijon,项目名称:top10bestwp,代码行数:13,代码来源:Minify.php
示例12: 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;
}
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:44,代码来源:Cdn.php
示例13: _replace_folder_placeholders
private function _replace_folder_placeholders($file)
{
static $content_dir, $plugin_dir, $upload_dir;
if (empty($content_dir)) {
$content_dir = str_replace(w3_get_document_root(), '', WP_CONTENT_DIR);
$content_dir = trim($content_dir, '/');
if (defined('WP_PLUGIN_DIR')) {
$plugin_dir = str_replace(w3_get_document_root(), '', WP_PLUGIN_DIR);
$plugin_dir = trim($plugin_dir, '/');
} else {
$plugin_dir = str_replace(w3_get_document_root(), '', WP_CONTENT_DIR . '/plugins');
$plugin_dir = trim($plugin_dir, '/');
}
$upload_dir = wp_upload_dir();
$upload_dir = str_replace(w3_get_document_root(), '', $upload_dir['basedir']);
$upload_dir = trim($upload_dir, '/');
}
$file = str_replace('{wp_content_dir}', $content_dir, $file);
$file = str_replace('{plugins_dir}', $plugin_dir, $file);
$file = str_replace('{uploads_dir}', $upload_dir, $file);
return $file;
}
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:22,代码来源:Cdn.php
示例14: w3_get_site_path
/**
* Returns blog path
*
* @return string
*/
function w3_get_site_path()
{
$document_root = w3_get_document_root();
$path = str_replace($document_root, '', w3_path(ABSPATH));
$path = '/' . ltrim($path, '/');
if (substr($path, -1) != '/') {
$path .= '/';
}
return $path;
}
开发者ID:alx,项目名称:SBek-Arak,代码行数:15,代码来源:define.php
示例15: 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;
}
开发者ID:easinewe,项目名称:Avec2016,代码行数:24,代码来源:SupportActionsAdmin.php
示例16: rules_cache_generate_nginx
/**
* Generates directives for file cache dir
*
* @param W3_Config $config
* @return string
*/
private function rules_cache_generate_nginx($config)
{
$cache_root = w3_path(W3TC_CACHE_PAGE_ENHANCED_DIR);
$cache_dir = rtrim(str_replace(w3_get_document_root(), '', $cache_root), '/');
if (w3_is_network()) {
$cache_dir = preg_replace('~/w3tc.*?/~', '/w3tc.*?/', $cache_dir, 1);
}
$browsercache = $config->get_boolean('browsercache.enabled');
$compression = $browsercache && $config->get_boolean('browsercache.html.compression');
$expires = $browsercache && $config->get_boolean('browsercache.html.expires');
$lifetime = $browsercache ? $config->get_integer('browsercache.html.lifetime') : 0;
$cache_control = $browsercache && $config->get_boolean('browsercache.html.cache.control');
$w3tc = $browsercache && $config->get_integer('browsercache.html.w3tc');
$common_rules = '';
if ($expires) {
$common_rules .= " expires modified " . $lifetime . "s;\n";
}
if ($w3tc) {
$common_rules .= " add_header X-Powered-By \"" . W3TC_POWERED_BY . "\";\n";
}
if ($compression) {
$common_rules .= " add_header Vary \"Accept-Encoding, Cookie\";\n";
} else {
$common_rules .= " add_header Vary Cookie;\n";
}
if ($cache_control) {
$cache_policy = $config->get_string('browsercache.html.cache.policy');
switch ($cache_policy) {
case 'cache':
$common_rules .= " add_header Pragma \"public\";\n";
$common_rules .= " add_header Cache-Control \"public\";\n";
break;
case 'cache_public_maxage':
$common_rules .= " add_header Pragma \"public\";\n";
$common_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public\";\n";
break;
case 'cache_validation':
$common_rules .= " add_header Pragma \"public\";\n";
$common_rules .= " add_header Cache-Control \"public, must-revalidate, proxy-revalidate\";\n";
break;
case 'cache_noproxy':
$common_rules .= " add_header Pragma \"public\";\n";
$common_rules .= " add_header Cache-Control \"private, must-revalidate\";\n";
break;
case 'cache_maxage':
$common_rules .= " add_header Pragma \"public\";\n";
$common_rules .= " add_header Cache-Control \"max-age=" . $lifetime . ", public, must-revalidate, proxy-revalidate\";\n";
break;
case 'no_cache':
$common_rules .= " add_header Pragma \"no-cache\";\n";
$common_rules .= " add_header Cache-Control \"max-age=0, private, no-store, no-cache, must-revalidate\";\n";
break;
}
}
$rules = '';
$rules .= W3TC_MARKER_BEGIN_PGCACHE_CACHE . "\n";
$rules .= "location ~ " . $cache_dir . ".*html\$ {\n";
$rules .= $common_rules;
$rules .= "}\n";
if ($compression) {
$rules .= "location ~ " . $cache_dir . ".*gzip\$ {\n";
$rules .= " gzip off;\n";
$rules .= " types {}\n";
$rules .= " default_type text/html;\n";
$rules .= $common_rules;
$rules .= " add_header Content-Encoding gzip;\n";
$rules .= "}\n";
}
$rules .= W3TC_MARKER_END_PGCACHE_CACHE . "\n";
return $rules;
}
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:77,代码来源:PgCacheAdminEnvironment.php
示例17: action_cdn_test
/**
* CDN Test action
*
* @return void
*/
function action_cdn_test()
{
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
w3_require_once(W3TC_LIB_W3_DIR . '/Cdn.php');
$engine = W3_Request::get_string('engine');
$config = W3_Request::get_array('config');
//TODO: Workaround to support test case cdn/a04
if (!isset($config['host'])) {
$config = W3_Request::get_string('config');
$config = json_decode($config, true);
}
$config = array_merge($config, array('debug' => false));
if (!is_array($config['domain'])) {
$config['domain'] = explode(',', $config['domain']);
}
if (w3_is_cdn_engine($engine)) {
$result = true;
$error = null;
} else {
$result = false;
$error = __('Incorrect engine.', 'w3-total-cache');
}
if (!isset($config['docroot'])) {
$config['docroot'] = w3_get_document_root();
}
if ($result) {
$w3_cdn = W3_Cdn::instance($engine, $config);
@set_time_limit($this->_config->get_integer('timelimit.cdn_test'));
if ($w3_cdn->test($error)) {
$result = true;
$error = __('Test passed', 'w3-total-cache');
} else {
$result = false;
$error = sprintf(__('Error: %s', 'w3-total-cache'), $error);
}
}
$response = array('result' => $result, 'error' => $error);
echo json_encode($response);
}
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:44,代码来源:CdnActionsAdmin.php
示例18: _filter_files
/**
* URL file filter
*
* @param string $file
* @return bool
*/
function _filter_files($file)
{
if (w3_is_url($file)) {
return false;
}
$ext = strrchr($file, '.');
if ($ext != '.js' && $ext != '.css') {
return false;
}
$path = w3_get_document_root() . '/' . $file;
if (!file_exists($path)) {
return false;
}
return true;
}
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:21,代码来源:Minify.php
示例19: get_sources_custom
/**
* Returns array of custom sources
*
* @param string $hash
* @param string $type
* @return array
*/
function get_sources_custom($hash, $type)
{
$sources = array();
$files = $this->get_custom_files($hash, $type);
if (count($files)) {
$document_root = w3_get_document_root();
foreach ($files as $file) {
$sources[] = $document_root . '/' . $file;
}
}
return $sources;
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:19,代码来源:Minify.php
示例20: _filter_files
/**
* URL file filter
*
* @param string $file
* @return bool
*/
function _filter_files($file)
{
static $external;
$ext = strrchr($file, '.');
if ($ext != '.js' && $ext != '.css') {
return false;
}
if (!isset($external)) {
$external = $this->_config->get_array('minify.cache.files');
}
foreach ($external as $ext) {
if (preg_match('#' . w3_get_url_regexp($ext) . '#', $file)) {
return true;
}
}
if (w3_is_url($file)) {
return false;
}
$path = w3_get_document_root() . '/' . $file;
if (!file_exists($path)) {
return false;
}
return true;
}
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:30,代码来源:Minify.php
注:本文中的w3_get_document_root函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论