本文整理汇总了PHP中w3_get_domain_url_regexp函数的典型用法代码示例。如果您正苦于以下问题:PHP w3_get_domain_url_regexp函数的具体用法?PHP w3_get_domain_url_regexp怎么用?PHP w3_get_domain_url_regexp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了w3_get_domain_url_regexp函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove_scripts
/**
* Remove script tags from the source
*
* @param string $content
* @param array $files
* @return void
*/
function remove_scripts(&$content, $files)
{
$regexps = array();
$domain_url_regexp = w3_get_domain_url_regexp();
foreach ($files as $file) {
$this->replaced_scripts[] = $file;
if (w3_is_url($file) && !preg_match('~' . $domain_url_regexp . '~i', $file)) {
// external JS files
$regexps[] = w3_preg_quote($file);
} else {
// local JS files
$file = ltrim(preg_replace('~' . $domain_url_regexp . '~i', '', $file), '/\\');
$regexps[] = '(' . $domain_url_regexp . ')?/?' . w3_preg_quote($file);
}
}
foreach ($regexps as $regexp) {
$content = preg_replace('~<script\\s+[^<>]*src=["\']?' . $regexp . '["\']?[^<>]*>\\s*</script>~Uis', '', $content);
}
}
示例2: ob_callback
/**
* Output buffer callback
*
* @param string $buffer
* @return mixed
*/
function ob_callback(&$buffer)
{
if ($buffer != '' && w3_is_xml($buffer)) {
$domain_url_regexp = w3_get_domain_url_regexp();
$buffer = preg_replace_callback('~(href|src|action|extsrc|asyncsrc|w3tc_load_js\\()=?[\'"]((' . $domain_url_regexp . ')?(/[^\'"]*\\.([a-z-_]+)(\\?[^\'"]*)?))[\'"]~Ui', array(&$this, 'link_replace_callback'), $buffer);
}
return $buffer;
}
示例3: 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;
}
示例4: 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;
}
示例5: ob_callback
/**
* Output buffering callback
*
* @param string $buffer
* @return string
*/
function ob_callback(&$buffer)
{
global $wpdb;
if ($buffer != '' && w3_is_xml($buffer)) {
if (w3_is_database_error($buffer)) {
@header('HTTP/1.1 503 Service Unavailable');
} else {
/**
* Replace links for preview mode
*/
if (w3_is_preview_mode() && isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] != W3TC_POWERED_BY) {
$domain_url_regexp = w3_get_domain_url_regexp();
$buffer = preg_replace_callback('~(href|src|action)=([\'"])(' . $domain_url_regexp . ')?(/[^\'"]*)~', array(&$this, 'link_replace_callback'), $buffer);
}
/**
* Add footer comment
*/
$date = date_i18n('Y-m-d H:i:s');
$host = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost';
if ($this->is_supported()) {
$buffer .= sprintf("\r\n<!-- Served from: %s @ %s by W3 Total Cache -->", w3_escape_comment($host), $date);
} else {
$strings = array();
if ($this->_config->get_boolean('minify.enabled') && !$this->_config->get_boolean('minify.debug')) {
require_once W3TC_LIB_W3_DIR . '/Plugin/Minify.php';
$w3_plugin_minify =& W3_Plugin_Minify::instance();
$strings[] = sprintf("Minified using %s%s", w3_get_engine_name($this->_config->get_string('minify.engine')), $w3_plugin_minify->minify_reject_reason != '' ? sprintf(' (%s)', $w3_plugin_minify->minify_reject_reason) : '');
}
if ($this->_config->get_boolean('pgcache.enabled') && !$this->_config->get_boolean('pgcache.debug')) {
require_once W3TC_LIB_W3_DIR . '/PgCache.php';
$w3_pgcache =& W3_PgCache::instance();
$strings[] = sprintf("Page Caching using %s%s", w3_get_engine_name($this->_config->get_string('pgcache.engine')), $w3_pgcache->cache_reject_reason != '' ? sprintf(' (%s)', $w3_pgcache->cache_reject_reason) : '');
}
if ($this->_config->get_boolean('dbcache.enabled') && !$this->_config->get_boolean('dbcache.debug') && is_a($wpdb, 'W3_Db')) {
$append = is_user_logged_in() ? ' (user is logged in)' : '';
if ($wpdb->query_hits) {
$strings[] = sprintf("Database Caching %d/%d queries in %.3f seconds using %s%s", $wpdb->query_hits, $wpdb->query_total, $wpdb->time_total, w3_get_engine_name($this->_config->get_string('dbcache.engine')), $append);
} else {
$strings[] = sprintf("Database Caching using %s%s", w3_get_engine_name($this->_config->get_string('dbcache.engine')), $append);
}
}
if ($this->_config->get_boolean('objectcache.enabled') && !$this->_config->get_boolean('objectcache.debug')) {
require_once W3TC_LIB_W3_DIR . '/ObjectCache.php';
$w3_objectcache =& W3_ObjectCache::instance();
$strings[] = sprintf("Object Caching %d/%d objects using %s", $w3_objectcache->cache_hits, $w3_objectcache->cache_total, w3_get_engine_name($this->_config->get_string('objectcache.engine')));
}
if ($this->_config->get_boolean('cdn.enabled') && !$this->_config->get_boolean('cdn.debug')) {
require_once W3TC_LIB_W3_DIR . '/Plugin/Cdn.php';
$w3_plugin_cdn =& W3_Plugin_Cdn::instance();
$cdn =& $w3_plugin_cdn->get_cdn();
$via = $cdn->get_via();
$strings[] = sprintf("Content Delivery Network via %s%s", $via ? $via : 'N/A', $w3_plugin_cdn->cdn_reject_reason != '' ? sprintf(' (%s)', $w3_plugin_cdn->cdn_reject_reason) : '');
}
$buffer .= "\r\n<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/\r\n";
if (count($strings)) {
$buffer .= "\r\n" . implode("\r\n", $strings) . "\r\n";
}
$buffer .= sprintf("\r\nServed from: %s @ %s -->", w3_escape_comment($host), $date);
}
}
}
return $buffer;
}
示例6: ob_callback
/**
* OB Callback
*
* @param string $buffer
* @return string
*/
function ob_callback(&$buffer)
{
if ($buffer != '' && w3_is_xml($buffer)) {
if ($this->can_cdn2($buffer)) {
$regexps = array();
$site_path = w3_get_site_path();
$domain_url_regexp = w3_get_domain_url_regexp();
if ($this->_config->get_boolean('cdn.uploads.enable')) {
require_once W3TC_INC_DIR . '/functions/http.php';
$upload_info = w3_upload_info();
if ($upload_info) {
if (preg_match('~' . $domain_url_regexp . '~i', $upload_info['baseurl'])) {
$regexps[] = '~(["\'])((' . $domain_url_regexp . ')?(' . w3_preg_quote($upload_info['baseurlpath']) . '([^"\'>]+)))~';
} else {
$regexps[] = '~(["\'])((' . w3_preg_quote($upload_info['baseurl']) . ')(([^"\'>]+)))~';
}
}
}
if ($this->_config->get_boolean('cdn.includes.enable')) {
$mask = $this->_config->get_string('cdn.includes.files');
if ($mask != '') {
$regexps[] = '~(["\'])((' . $domain_url_regexp . ')?(' . w3_preg_quote($site_path . WPINC) . '/(' . $this->get_regexp_by_mask($mask) . ')))~';
}
}
if ($this->_config->get_boolean('cdn.theme.enable')) {
$theme_dir = preg_replace('~' . $domain_url_regexp . '~i', '', get_theme_root_uri());
$mask = $this->_config->get_string('cdn.theme.files');
if ($mask != '') {
$regexps[] = '~(["\'])((' . $domain_url_regexp . ')?(' . w3_preg_quote($theme_dir) . '/(' . $this->get_regexp_by_mask($mask) . ')))~';
}
}
if ($this->_config->get_boolean('cdn.minify.enable')) {
if ($this->_config->get_boolean('minify.auto')) {
$regexps[] = '~(["\'])((' . $domain_url_regexp . ')?(' . w3_preg_quote($site_path . W3TC_CONTENT_MINIFY_DIR_NAME) . '/[a-f0-9]+\\.[a-f0-9]+\\.(css|js)))~U';
} else {
$regexps[] = '~(["\'])((' . $domain_url_regexp . ')?(' . w3_preg_quote($site_path . W3TC_CONTENT_MINIFY_DIR_NAME) . '/[a-f0-9]+/.+\\.include(-(footer|body))?(-nb)?\\.[a-f0-9]+\\.(css|js)))~U';
}
}
if ($this->_config->get_boolean('cdn.custom.enable')) {
$masks = $this->_config->get_array('cdn.custom.files');
$masks = array_map('w3_parse_path', $masks);
if (count($masks)) {
$mask_regexps = array();
foreach ($masks as $mask) {
if ($mask != '') {
$mask = w3_normalize_file($mask);
$mask_regexps[] = $this->get_regexp_by_mask($mask);
}
}
$regexps[] = '~(["\'])((' . $domain_url_regexp . ')?(' . w3_preg_quote($site_path) . '(' . implode('|', $mask_regexps) . ')))~i';
}
}
foreach ($regexps as $regexp) {
$buffer = preg_replace_callback($regexp, array(&$this, 'link_replace_callback'), $buffer);
}
}
if ($this->_config->get_boolean('cdn.debug')) {
$buffer .= "\r\n\r\n" . $this->get_debug_info();
}
}
return $buffer;
}
示例7: clean_scripts
/**
* Cleans scripts
*
* @param string $content
* @return string
*/
function clean_scripts($content)
{
$regexps = array();
$groups = $this->_config->get_array('minify.js.groups');
$domain_url_regexp = w3_get_domain_url_regexp();
foreach ($groups as $group => $locations) {
foreach ((array) $locations as $location => $config) {
if (!empty($config['files'])) {
foreach ((array) $config['files'] as $file) {
if (w3_is_url($file) && !preg_match('~' . $domain_url_regexp . '~i', $file)) {
// external JS files
$regexps[] = w3_preg_quote($file);
} else {
// local JS files
$file = ltrim(preg_replace('~' . $domain_url_regexp . '~i', '', $file), '/\\');
$regexps[] = '(' . $domain_url_regexp . ')?/?' . w3_preg_quote($file);
}
}
}
}
}
foreach ($regexps as $regexp) {
$content = preg_replace('~<script\\s+[^<>]*src=["\']?' . $regexp . '["\']?[^<>]*>\\s*</script>~is', '', $content);
}
return $content;
}
示例8: ob_callback
/**
* OB Callback
*
* @param string $buffer
* @return string
*/
function ob_callback(&$buffer)
{
if ($buffer != '' && w3_is_xml($buffer)) {
if ($this->can_cdn2($buffer)) {
$regexps = array();
$site_path = w3_get_site_path();
$domain_url_regexp = w3_get_domain_url_regexp();
if ($this->_config->get_boolean('cdn.uploads.enable')) {
w3_require_once(W3TC_INC_DIR . '/functions/http.php');
$upload_info = w3_upload_info();
if ($upload_info) {
if (preg_match('~' . $domain_url_regexp . '~i', $upload_info['baseurl'])) {
$regexps[] = '~(["\'(])\\s*((' . $domain_url_regexp . ')?(' . w3_preg_quote($upload_info['baseurlpath']) . '([^"\')>]+)))~';
} else {
$parsed = @parse_url($upload_info['baseurl']);
$upload_url_domain_regexp = isset($parsed['host']) ? w3_get_url_regexp($parsed['scheme'] . '://' . $parsed['host']) : '';
$baseurlpath = isset($parsed['path']) ? rtrim($parsed['path'], '/') : '';
if ($baseurlpath) {
$regexps[] = '~(["\'])\\s*((' . $upload_url_domain_regexp . ')?(' . w3_preg_quote($baseurlpath) . '([^"\'>]+)))~';
} else {
$regexps[] = '~(["\'])\\s*((' . $upload_url_domain_regexp . ')([^"\'>]+))~';
}
}
}
}
if ($this->_config->get_boolean('cdn.includes.enable')) {
$mask = $this->_config->get_string('cdn.includes.files');
if ($mask != '') {
$regexps[] = '~(["\'(])\\s*((' . $domain_url_regexp . ')?(' . w3_preg_quote($site_path . WPINC) . '/(' . $this->get_regexp_by_mask($mask) . ')))~';
}
}
if ($this->_config->get_boolean('cdn.theme.enable')) {
$theme_dir = preg_replace('~' . $domain_url_regexp . '~i', '', get_theme_root_uri());
$mask = $this->_config->get_string('cdn.theme.files');
if ($mask != '') {
$regexps[] = '~(["\'(])\\s*((' . $domain_url_regexp . ')?(' . w3_preg_quote($theme_dir) . '/(' . $this->get_regexp_by_mask($mask) . ')))~';
}
}
if ($this->_config->get_boolean('cdn.custom.enable')) {
$masks = $this->_config->get_array('cdn.custom.files');
$masks = array_map('w3_parse_path', $masks);
if (count($masks)) {
$mask_regexps = array();
foreach ($masks as $mask) {
if ($mask != '') {
$mask = w3_normalize_file($mask);
$mask_regexps[] = $this->get_regexp_by_mask($mask);
}
}
$regexps[] = '~(["\'(])\\s*((' . $domain_url_regexp . ')?(' . w3_preg_quote($site_path) . '(' . implode('|', $mask_regexps) . ')))~i';
}
}
foreach ($regexps as $regexp) {
$buffer = preg_replace_callback($regexp, array(&$this, 'link_replace_callback'), $buffer);
}
if ($this->_config->get_boolean('cdn.minify.enable')) {
if ($this->_config->get_boolean('minify.auto')) {
$regexp = '~(["\'(])\\s*' . $this->_minify_url_regexp('/[a-zA-Z0-9-_]+\\.(css|js)') . '~U';
if (w3_is_cdn_mirror($this->_config->get_string('cdn.engine'))) {
$processor = 'link_replace_callback';
} else {
$processor = 'minify_auto_pushcdn_link_replace_callback';
}
} else {
$regexp = '~(["\'(])\\s*' . $this->_minify_url_regexp('/[a-z0-9]+/.+\\.include(-(footer|body))?(-nb)?\\.[a-f0-9]+\\.(css|js)') . '~U';
$processor = 'link_replace_callback';
}
$buffer = preg_replace_callback($regexp, array(&$this, $processor), $buffer);
}
}
if ($this->_config->get_boolean('cdn.debug')) {
$buffer .= "\r\n\r\n" . $this->get_debug_info();
}
}
return $buffer;
}
示例9: wpseo_cdn_filter
/**
* Hook into WordPress SEO sitemap image filter.
* @param $uri
* @return string
*/
function wpseo_cdn_filter($uri)
{
$site_path = w3_get_site_path();
$domain_url_regexp = w3_get_domain_url_regexp();
$cdn = $this->_get_common()->get_cdn();
$parsed = parse_url($uri);
$path = $parsed['path'];
$remote_path = $this->_get_common()->uri_to_cdn_uri($path);
$new_url = $cdn->format_url($remote_path);
return $new_url;
}
示例10: w3_normalize_file
/**
* Converts file path to relative
*
* @param string $file
* @return string
*/
function w3_normalize_file($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);
}
} else {
$abspath = w3_path(ABSPATH);
$file = w3_path($file);
$file = str_replace($abspath, '', $file);
}
$file = ltrim($file, '/');
return $file;
}
示例11: ob_callback
/**
* Output buffering callback
*
* @param string $buffer
* @return string
*/
function ob_callback(&$buffer)
{
global $wpdb;
if ($buffer != '' && w3_is_xml($buffer)) {
if (w3_is_database_error($buffer)) {
status_header(503);
} else {
/**
* Replace links for preview mode
*/
if (w3_is_preview_mode() && isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] != W3TC_POWERED_BY) {
$domain_url_regexp = w3_get_domain_url_regexp();
$buffer = preg_replace_callback('~(href|src|action)=([\'"])(' . $domain_url_regexp . ')?(/[^\'"]*)~', array(&$this, 'link_replace_callback'), $buffer);
}
/**
* Add footer comment
*/
$date = date_i18n('Y-m-d H:i:s');
$host = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost';
if ($this->_config->get_string('common.support') != '' || $this->_config->get_boolean('common.tweeted')) {
$buffer .= sprintf("\r\n<!-- Served from: %s @ %s by W3 Total Cache -->", w3_escape_comment($host), $date);
} else {
$strings = array();
if ($this->_config->get_boolean('minify.enabled') && !$this->_config->get_boolean('minify.debug')) {
$w3_plugin_minify = w3_instance('W3_Plugin_Minify');
$strings[] = sprintf("Minified using %s%s", w3_get_engine_name($this->_config->get_string('minify.engine')), $w3_plugin_minify->minify_reject_reason != '' ? sprintf(' (%s)', $w3_plugin_minify->minify_reject_reason) : '');
}
if ($this->_config->get_boolean('pgcache.enabled') && !$this->_config->get_boolean('pgcache.debug')) {
$w3_pgcache = w3_instance('W3_PgCache');
$strings[] = sprintf("Page Caching using %s%s", w3_get_engine_name($this->_config->get_string('pgcache.engine')), $w3_pgcache->cache_reject_reason != '' ? sprintf(' (%s)', $w3_pgcache->cache_reject_reason) : '');
}
if ($this->_config->get_boolean('dbcache.enabled') && !$this->_config->get_boolean('dbcache.debug')) {
$db = w3_instance('W3_DbCache');
$append = !is_null($db->cache_reject_reason) ? sprintf(' (%s)', $db->cache_reject_reason) : '';
if ($db->query_hits) {
$strings[] = sprintf("Database Caching %d/%d queries in %.3f seconds using %s%s", $db->query_hits, $db->query_total, $db->time_total, w3_get_engine_name($this->_config->get_string('dbcache.engine')), $append);
} else {
$strings[] = sprintf("Database Caching using %s%s", w3_get_engine_name($this->_config->get_string('dbcache.engine')), $append);
}
}
if (w3_is_dbcluster()) {
$db_cluster = w3_instance('W3_Enterprise_DbCluster');
$strings[] = $db_cluster->status_message();
}
if ($this->_config->get_boolean('objectcache.enabled') && !$this->_config->get_boolean('objectcache.debug')) {
$w3_objectcache = w3_instance('W3_ObjectCache');
$append = $w3_objectcache->cache_reject_reason != '' ? sprintf(' (%s)', $w3_objectcache->cache_reject_reason) : '';
$strings[] = sprintf("Object Caching %d/%d objects using %s%s", $w3_objectcache->cache_hits, $w3_objectcache->cache_total, w3_get_engine_name($this->_config->get_string('objectcache.engine')), $append);
}
if ($this->_config->get_boolean('fragmentcache.enabled') && !$this->_config->get_boolean('fragmentcache.debug')) {
$w3_fragmentcache = w3_instance('W3_Pro_FragmentCache');
$append = $w3_fragmentcache->cache_reject_reason != '' ? sprintf(' (%s)', $w3_fragmentcache->cache_reject_reason) : '';
$strings[] = sprintf("Fragment Caching %d/%d fragments using %s%s", $w3_fragmentcache->cache_hits, $w3_fragmentcache->cache_total, w3_get_engine_name($this->_config->get_string('fragmentcache.engine')), $append);
}
if ($this->_config->get_boolean('cdn.enabled') && !$this->_config->get_boolean('cdn.debug')) {
$w3_plugin_cdn = w3_instance('W3_Plugin_Cdn');
$w3_plugin_cdncommon = w3_instance('W3_Plugin_CdnCommon');
$cdn =& $w3_plugin_cdncommon->get_cdn();
$via = $cdn->get_via();
$strings[] = sprintf("Content Delivery Network via %s%s", $via ? $via : 'N/A', $w3_plugin_cdn->cdn_reject_reason != '' ? sprintf(' (%s)', $w3_plugin_cdn->cdn_reject_reason) : '');
}
if ($this->_config->get_boolean('newrelic.enabled')) {
$w3_newrelic = w3_instance('W3_Plugin_NewRelic');
$append = $w3_newrelic->newrelic_reject_reason != '' ? sprintf(' (%s)', $w3_newrelic->newrelic_reject_reason) : '';
$strings[] = sprintf(__("Application Monitoring using New Relic%s", 'w3-total-cache'), $append);
}
$buffer .= "\r\n<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/\r\n";
if (count($strings)) {
$buffer .= "\r\n" . implode("\r\n", $strings) . "\r\n";
}
$buffer .= sprintf("\r\n Served from: %s @ %s by W3 Total Cache -->", w3_escape_comment($host), $date);
}
if ($this->is_debugging()) {
if ($this->_config->get_boolean('dbcache.enabled') && $this->_config->get_boolean('dbcache.debug')) {
$db = w3_instance('W3_DbCache');
$buffer .= "\r\n\r\n" . $db->_get_debug_info();
}
if ($this->_config->get_boolean('objectcache.enabled') && $this->_config->get_boolean('objectcache.debug')) {
$w3_objectcache = w3_instance('W3_ObjectCache');
$buffer .= "\r\n\r\n" . $w3_objectcache->_get_debug_info();
}
if ($this->_config->get_boolean('fragmentcache.enabled') && $this->_config->get_boolean('fragmentcache.debug')) {
$w3_fragmentcache = w3_instance('W3_Pro_FragmentCache');
$buffer .= "\r\n\r\n" . $w3_fragmentcache->_get_debug_info();
}
}
}
}
return $buffer;
}