本文整理汇总了PHP中w3_get_home_path函数的典型用法代码示例。如果您正苦于以下问题:PHP w3_get_home_path函数的具体用法?PHP w3_get_home_path怎么用?PHP w3_get_home_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了w3_get_home_path函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_frontpage_urls
/**
* Returns full urls for frontpage including older pages
* @param int $limit_post_pages default is 10
* @return array
*/
function get_frontpage_urls($limit_post_pages = 10)
{
if (!isset($this->frontpage_urls[$limit_post_pages])) {
$front_page = get_option('show_on_front');
$full_urls = array();
$home_path = w3_get_home_path();
$site_path = w3_get_site_path();
$full_urls[] = $this->home_url . '/';
if ($site_path != $home_path) {
$full_urls[] = w3_get_site_url() . '/';
}
if ($front_page == 'posts') {
$full_urls = array_merge($full_urls, $this->get_older_pages($home_path, $limit_post_pages));
}
$this->frontpage_urls[$limit_post_pages] = $full_urls;
}
return $this->frontpage_urls[$limit_post_pages];
}
开发者ID:getupcloud,项目名称:wordpress-ex,代码行数:23,代码来源:PageUrls.php
示例2: remove_scripts
/**
* Remove script tags from the source
*
* @param string $content
* @param array $files
* @return void
*/
function remove_scripts(&$content, $files)
{
$regexps = array();
$home_url_regexp = w3_get_home_url_regexp();
$path = '';
if (w3_is_network() && !w3_is_subdomain_install()) {
$path = ltrim(w3_get_home_path(), '/');
}
foreach ($files as $file) {
if ($path && strpos($file, $path) === 0) {
$file = substr($file, strlen($path));
}
$this->replaced_scripts[] = $file;
if (w3_is_url($file) && !preg_match('~' . $home_url_regexp . '~i', $file)) {
// external JS files
$regexps[] = w3_preg_quote($file);
} else {
// local JS files
$file = ltrim($file, '/');
if (ltrim(w3_get_site_path(), '/') && strpos($file, ltrim(w3_get_site_path(), '/')) === 0) {
$file = str_replace(ltrim(w3_get_site_path(), '/'), '', $file);
}
$file = ltrim(preg_replace('~' . $home_url_regexp . '~i', '', $file), '/\\');
$regexps[] = '(' . $home_url_regexp . ')?/?' . w3_preg_quote($file);
}
}
foreach ($regexps as $regexp) {
$content = preg_replace('~<script\\s+[^<>]*src=["\']?' . $regexp . '["\']?[^<>]*>\\s*</script>~Uis', '', $content);
}
}
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:37,代码来源:Minify.php
示例3: flush_post
/**
* Flushes post cache
*
* @param integer $post_id
* @return boolean
*/
function flush_post($post_id = null)
{
if (!$post_id) {
$post_id = $this->_detect_post_id();
}
if ($post_id) {
$uris = array();
$domain_url = w3_get_domain_url();
$feeds = $this->_config->get_array('pgcache.purge.feed.types');
if ($this->_config->get_boolean('pgcache.purge.terms') || $this->_config->get_boolean('pgcache.purge.feed.terms')) {
$taxonomies = get_post_taxonomies($post_id);
$terms = nxt_get_post_terms($post_id, $taxonomies);
}
switch (true) {
case $this->_config->get_boolean('pgcache.purge.author'):
case $this->_config->get_boolean('pgcache.purge.archive.daily'):
case $this->_config->get_boolean('pgcache.purge.archive.monthly'):
case $this->_config->get_boolean('pgcache.purge.archive.yearly'):
case $this->_config->get_boolean('pgcache.purge.feed.author'):
$post = get_post($post_id);
}
/**
* Home URL
*/
if ($this->_config->get_boolean('pgcache.purge.home')) {
$home_path = w3_get_home_path();
$site_path = w3_get_site_path();
$uris[] = $home_path;
if ($site_path != $home_path) {
$uris[] = $site_path;
}
}
/**
* Post URL
*/
if ($this->_config->get_boolean('pgcache.purge.post')) {
$post_link = post_permalink($post_id);
$post_uri = str_replace($domain_url, '', $post_link);
$uris[] = $post_uri;
}
/**
* Post comments URLs
*/
if ($this->_config->get_boolean('pgcache.purge.comments') && function_exists('get_comments_pagenum_link')) {
$comments_number = get_comments_number($post_id);
$comments_per_page = get_option('comments_per_page');
$comments_pages_number = @ceil($comments_number / $comments_per_page);
for ($pagenum = 1; $pagenum <= $comments_pages_number; $pagenum++) {
$comments_pagenum_link = $this->_get_comments_pagenum_link($post_id, $pagenum);
$comments_pagenum_uri = str_replace($domain_url, '', $comments_pagenum_link);
$uris[] = $comments_pagenum_uri;
}
}
/**
* Post author URLs
*/
if ($this->_config->get_boolean('pgcache.purge.author') && $post) {
$posts_number = count_user_posts($post->post_author);
$posts_per_page = get_option('posts_per_page');
$posts_pages_number = @ceil($posts_number / $posts_per_page);
$author_link = get_author_link(false, $post->post_author);
$author_uri = str_replace($domain_url, '', $author_link);
for ($pagenum = 1; $pagenum <= $posts_pages_number; $pagenum++) {
$author_pagenum_link = $this->_get_pagenum_link($author_uri, $pagenum);
$author_pagenum_uri = str_replace($domain_url, '', $author_pagenum_link);
$uris[] = $author_pagenum_uri;
}
}
/**
* Post terms URLs
*/
if ($this->_config->get_boolean('pgcache.purge.terms')) {
$posts_per_page = get_option('posts_per_page');
foreach ($terms as $term) {
$term_link = get_term_link($term, $term->taxonomy);
$term_uri = str_replace($domain_url, '', $term_link);
$posts_pages_number = @ceil($term->count / $posts_per_page);
for ($pagenum = 1; $pagenum <= $posts_pages_number; $pagenum++) {
$term_pagenum_link = $this->_get_pagenum_link($term_uri, $pagenum);
$term_pagenum_uri = str_replace($domain_url, '', $term_pagenum_link);
$uris[] = $term_pagenum_uri;
}
}
}
/**
* Daily archive URLs
*/
if ($this->_config->get_boolean('pgcache.purge.archive.daily') && $post) {
$post_date = strtotime($post->post_date);
$post_year = gmdate('Y', $post_date);
$post_month = gmdate('m', $post_date);
$post_day = gmdate('d', $post_date);
$posts_per_page = get_option('posts_per_page');
$posts_number = $this->_get_archive_posts_count($post_year, $post_month, $post_day);
//.........这里部分代码省略.........
开发者ID:nxtclass,项目名称:NXTClass,代码行数:101,代码来源:PgCacheFlush.php
示例4: w3_get_home_root
/**
* Returns absolute path to home directory
*
* Example:
*
* DOCUMENT_ROOT=/var/www/vhosts/domain.com
* Install dir=/var/www/vhosts/domain.com/site/blog
* home=http://domain.com/site
* siteurl=http://domain.com/site/blog
* return /var/www/vhosts/domain.com/site
*
* No trailing slash!
*
* @return string
*/
function w3_get_home_root()
{
if (w3_is_network()) {
$path = w3_get_base_path();
} else {
$path = w3_get_home_path();
}
$home_root = w3_get_document_root() . $path;
$home_root = realpath($home_root);
$home_root = w3_path($home_root);
return $home_root;
}
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:27,代码来源:define.php
示例5: rules_core_generate_apache
/**
* Generates rules for WP dir
*
* @param W3_Config $config
* @return string
*/
private function rules_core_generate_apache($config)
{
$is_network = w3_is_network();
$base_path = w3_get_base_path();
$home_path = w3_get_home_path();
$rewrite_base = $is_network ? $base_path : $home_path;
$cache_dir = w3_path(W3TC_CACHE_PAGE_ENHANCED_DIR);
$permalink_structure = get_option('permalink_structure');
$current_user = get_currentuserinfo();
/**
* Auto reject cookies
*/
$reject_cookies = array('comment_author', 'wp-postpass');
if ($config->get_string('pgcache.engine') == 'file_generic') {
$reject_cookies[] = 'w3tc_logged_out';
}
/**
* Reject cache for logged in users
* OR
* Reject cache for roles if any
*/
if ($config->get_boolean('pgcache.reject.logged')) {
$reject_cookies = array_merge($reject_cookies, array('wordpress_logged_in'));
} elseif ($config->get_boolean('pgcache.reject.logged_roles')) {
$new_cookies = array();
foreach ($config->get_array('pgcache.reject.roles') as $role) {
$new_cookies[] = 'w3tc_logged_' . md5(NONCE_KEY . $role);
}
$reject_cookies = array_merge($reject_cookies, $new_cookies);
}
/**
* Custom config
*/
$reject_cookies = array_merge($reject_cookies, $config->get_array('pgcache.reject.cookie'));
w3_array_trim($reject_cookies);
$reject_user_agents = $config->get_array('pgcache.reject.ua');
if ($config->get_boolean('pgcache.compatibility')) {
$reject_user_agents = array_merge(array(W3TC_POWERED_BY), $reject_user_agents);
}
w3_array_trim($reject_user_agents);
/**
* Generate directives
*/
$env_W3TC_UA = '';
$env_W3TC_REF = '';
$env_W3TC_SSL = '';
$env_W3TC_ENC = '';
$rules = '';
$rules .= W3TC_MARKER_BEGIN_PGCACHE_CORE . "\n";
$rules .= "<IfModule mod_rewrite.c>\n";
$rules .= " RewriteEngine On\n";
$rules .= " RewriteBase " . $rewrite_base . "\n";
if ($config->get_boolean('pgcache.debug')) {
$rules .= " RewriteRule ^(.*\\/)?w3tc_rewrite_test/?\$ \$1?w3tc_rewrite_test=1 [L]\n";
}
/**
* Check for mobile redirect
*/
if ($config->get_boolean('mobile.enabled')) {
$mobile_groups = $config->get_array('mobile.rgroups');
foreach ($mobile_groups as $mobile_group => $mobile_config) {
$mobile_enabled = isset($mobile_config['enabled']) ? (bool) $mobile_config['enabled'] : false;
$mobile_agents = isset($mobile_config['agents']) ? (array) $mobile_config['agents'] : '';
$mobile_redirect = isset($mobile_config['redirect']) ? $mobile_config['redirect'] : '';
if ($mobile_enabled && count($mobile_agents) && $mobile_redirect) {
$rules .= " RewriteCond %{HTTP_USER_AGENT} (" . implode('|', $mobile_agents) . ") [NC]\n";
$rules .= " RewriteRule .* " . $mobile_redirect . " [R,L]\n";
}
}
}
/**
* Check for referrer redirect
*/
if ($config->get_boolean('referrer.enabled')) {
$referrer_groups = $config->get_array('referrer.rgroups');
foreach ($referrer_groups as $referrer_group => $referrer_config) {
$referrer_enabled = isset($referrer_config['enabled']) ? (bool) $referrer_config['enabled'] : false;
$referrer_referrers = isset($referrer_config['referrers']) ? (array) $referrer_config['referrers'] : '';
$referrer_redirect = isset($referrer_config['redirect']) ? $referrer_config['redirect'] : '';
if ($referrer_enabled && count($referrer_referrers) && $referrer_redirect) {
$rules .= " RewriteCond %{HTTP_COOKIE} w3tc_referrer=.*(" . implode('|', $referrer_referrers) . ") [NC]\n";
$rules .= " RewriteRule .* " . $referrer_redirect . " [R,L]\n";
}
}
}
/**
* Set mobile groups
*/
if ($config->get_boolean('mobile.enabled')) {
$mobile_groups = array_reverse($config->get_array('mobile.rgroups'));
foreach ($mobile_groups as $mobile_group => $mobile_config) {
$mobile_enabled = isset($mobile_config['enabled']) ? (bool) $mobile_config['enabled'] : false;
$mobile_agents = isset($mobile_config['agents']) ? (array) $mobile_config['agents'] : '';
$mobile_redirect = isset($mobile_config['redirect']) ? $mobile_config['redirect'] : '';
//.........这里部分代码省略.........
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:101,代码来源:PgCacheAdminEnvironment.php
示例6: 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
示例7: generate_rules_core_apache
/**
* Generates rules for WP dir
*
* @return string
*/
function generate_rules_core_apache()
{
$is_network = w3_is_network();
$is_vhost = w3_is_subdomain_install();
$base_path = w3_get_base_path();
$home_path = w3_get_home_path();
$rewrite_base = $is_network ? $base_path : $home_path;
$cache_dir = w3_path(W3TC_CACHE_FILE_PGCACHE_DIR);
$permalink_structure = get_option('permalink_structure');
/**
* Auto reject cookies
*/
$reject_cookies = array('comment_author', 'wp-postpass');
/**
* Auto reject URIs
*/
$reject_uris = array('\\/wp-admin\\/', '\\/xmlrpc.php', '\\/wp-(app|cron|login|register|mail)\\.php');
/**
* Reject cache for logged in users
*/
if ($this->_config->get_boolean('pgcache.reject.logged')) {
$reject_cookies = array_merge($reject_cookies, array('wordpress_[a-f0-9]+', 'wordpress_logged_in'));
}
/**
* Reject cache for home page
*/
if (!$this->_config->get_boolean('pgcache.cache.home')) {
$reject_uris[] = '^(\\/|\\/index.php)$';
}
/**
* Reject cache for feeds
*/
if (!$this->_config->get_boolean('pgcache.cache.feed')) {
$reject_uris[] = '\\/feed\\/';
}
/**
* Custom config
*/
$reject_cookies = array_merge($reject_cookies, $this->_config->get_array('pgcache.reject.cookie'));
$reject_uris = array_merge($reject_uris, $this->_config->get_array('pgcache.reject.uri'));
$reject_uris = array_map('w3_parse_path', $reject_uris);
$reject_user_agents = array_merge(array(W3TC_POWERED_BY), $this->_config->get_array('pgcache.reject.ua'));
$accept_uris = $this->_config->get_array('pgcache.accept.uri');
$accept_files = $this->_config->get_array('pgcache.accept.files');
/**
* Generate directives
*/
$rules = '';
$rules .= W3TC_MARKER_BEGIN_PGCACHE_CORE . "\n";
$rules .= "<IfModule mod_rewrite.c>\n";
$rules .= " RewriteEngine On\n";
$rules .= " RewriteBase " . $rewrite_base . "\n";
$rules .= " RewriteRule ^(.*\\/)?w3tc_rewrite_test\$ \$1?w3tc_rewrite_test=1 [L]\n";
/**
* Check for mobile redirect
*/
if ($this->_config->get_boolean('mobile.enabled')) {
$mobile_groups = $this->_config->get_array('mobile.rgroups');
foreach ($mobile_groups as $mobile_group => $mobile_config) {
$mobile_enabled = isset($mobile_config['enabled']) ? (bool) $mobile_config['enabled'] : false;
$mobile_agents = isset($mobile_config['agents']) ? (array) $mobile_config['agents'] : '';
$mobile_redirect = isset($mobile_config['redirect']) ? $mobile_config['redirect'] : '';
if ($mobile_enabled && count($mobile_agents) && $mobile_redirect) {
$rules .= " RewriteCond %{HTTP_USER_AGENT} (" . implode('|', $mobile_agents) . ") [NC]\n";
$rules .= " RewriteRule .* " . $mobile_redirect . " [R,L]\n";
}
}
}
/**
* Check for referrer redirect
*/
if ($this->_config->get_boolean('referrer.enabled')) {
$referrer_groups = $this->_config->get_array('referrer.rgroups');
foreach ($referrer_groups as $referrer_group => $referrer_config) {
$referrer_enabled = isset($referrer_config['enabled']) ? (bool) $referrer_config['enabled'] : false;
$referrer_referrers = isset($referrer_config['referrers']) ? (array) $referrer_config['referrers'] : '';
$referrer_redirect = isset($referrer_config['redirect']) ? $referrer_config['redirect'] : '';
if ($referrer_enabled && count($referrer_referrers) && $referrer_redirect) {
$rules .= " RewriteCond %{HTTP_COOKIE} w3tc_referrer=.*(" . implode('|', $referrer_referrers) . ") [NC]\n";
$rules .= " RewriteRule .* " . $referrer_redirect . " [R,L]\n";
}
}
}
/**
* Network mode rules
*/
if ($is_network) {
/**
* Detect domain
*/
$rules .= " RewriteCond %{HTTP_HOST} ^(www\\.)?([a-z0-9\\-\\.]+\\.[a-z]+)\\.?(:[0-9]+)?\$\n";
$rules .= " RewriteRule .* - [E=W3TC_DOMAIN:%2]\n";
$replacement = '/w3tc-%{ENV:W3TC_DOMAIN}/';
/**
* If VHOST is off, detect blogname from URI
//.........这里部分代码省略.........
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:101,代码来源:PgCacheAdmin.php
示例8: queue_upload_url
/**
* Queues file upload.
* Links wp_cron call to do that by the end of request processing
*
* @param string $url
* @return void
*/
function queue_upload_url($url)
{
/**
* Get filesystem file name by url
*/
$home_url_ssl = w3_get_home_url_ssl();
if (substr($url, 0, strlen($home_url_ssl)) == $home_url_ssl) {
if (!w3_is_multisite()) {
$home_url_ssl = str_replace(trim(w3_get_home_path(), '/'), '', $home_url_ssl);
}
$path = str_replace($home_url_ssl, '', $url);
$file_name = w3_get_document_root() . '/' . trim($path, '/');
} else {
// unknown url for uploading
return;
}
$document_root = w3_get_document_root() . '/';
/*
* Define remote filename
*/
if (!substr($file_name, 0, strlen($document_root)) == $document_root) {
// unexpected file name
return;
}
$remote_file_name = $this->uri_to_cdn_uri($this->docroot_filename_to_uri(substr($file_name, strlen($document_root))));
/*
* Queue uploading
*/
$this->queue_add($file_name, $remote_file_name, W3TC_CDN_COMMAND_UPLOAD, 'Pending');
if (!$this->_upload_scheduled) {
wp_schedule_single_event(time() - 100, 'w3_cdn_cron_queue_process');
add_action('shutdown', 'wp_cron');
$this->_upload_scheduled = true;
}
}
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:42,代码来源:CdnCommon.php
注:本文中的w3_get_home_path函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论