本文整理汇总了PHP中w3_get_document_root函数的典型用法代码示例。如果您正苦于以下问题:PHP w3_get_document_root函数的具体用法?PHP w3_get_document_root怎么用?PHP w3_get_document_root使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了w3_get_document_root函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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']);
}
示例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);
}
示例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'];
}
//.........这里部分代码省略.........
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}