当前位置: 首页>>代码示例>>PHP>>正文


PHP Util_Environment::preg_quote方法代码示例

本文整理汇总了PHP中Util_Environment::preg_quote方法的典型用法代码示例。如果您正苦于以下问题:PHP Util_Environment::preg_quote方法的具体用法?PHP Util_Environment::preg_quote怎么用?PHP Util_Environment::preg_quote使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Util_Environment的用法示例。


在下文中一共展示了Util_Environment::preg_quote方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
     $home_url_regexp = Util_Environment::home_url_regexp();
     $path = '';
     if (Util_Environment::is_wpmu() && !Util_Environment::is_wpmu_subdomain()) {
         $path = ltrim(Util_Environment::home_url_uri(), '/');
     }
     foreach ($files as $file) {
         if ($path && strpos($file, $path) === 0) {
             $file = substr($file, strlen($path));
         }
         $this->replaced_scripts[] = $file;
         if (Util_Environment::is_url($file) && !preg_match('~' . $home_url_regexp . '~i', $file)) {
             // external JS files
             $regexps[] = Util_Environment::preg_quote($file);
         } else {
             // local JS files
             $file = ltrim($file, '/');
             if (home_url() == site_url() && ltrim(Util_Environment::site_url_uri(), '/') && strpos($file, ltrim(Util_Environment::site_url_uri(), '/')) === 0) {
                 $file = str_replace(ltrim(Util_Environment::site_url_uri(), '/'), '', $file);
             }
             $file = ltrim(preg_replace('~' . $home_url_regexp . '~i', '', $file), '/\\');
             $regexps[] = '(' . $home_url_regexp . ')?/?' . Util_Environment::preg_quote($file);
         }
     }
     foreach ($regexps as $regexp) {
         $content = preg_replace('~<script\\s+[^<>]*src=["\']?' . $regexp . '["\']?[^<>]*>\\s*</script>~Uis', '', $content);
     }
 }
开发者ID:eduardodomingos,项目名称:eduardodomingos.com,代码行数:37,代码来源:Minify_Plugin.php

示例2: rules_no404wp_generate_apache

 /**
  * Generate rules related to prevent for media 404 error by WP
  *
  * @param Config  $config
  * @return string
  */
 private function rules_no404wp_generate_apache($config)
 {
     $a = $this->get_mime_types();
     $cssjs_types = $a['cssjs'];
     $html_types = $a['html'];
     $other_types = $a['other'];
     $extensions = array_merge(array_keys($cssjs_types), array_keys($html_types), array_keys($other_types));
     $permalink_structure = get_option('permalink_structure');
     $permalink_structure_ext = ltrim(strrchr($permalink_structure, '.'), '.');
     if ($permalink_structure_ext != '') {
         foreach ($extensions as $index => $extension) {
             if (strstr($extension, $permalink_structure_ext) !== false) {
                 $extensions[$index] = preg_replace('~\\|?' . Util_Environment::preg_quote($permalink_structure_ext) . '\\|?~', '', $extension);
             }
         }
     }
     $exceptions = $config->get_array('browsercache.no404wp.exceptions');
     $wp_uri = network_home_url('', 'relative');
     $wp_uri = rtrim($wp_uri, '/');
     $rules = '';
     $rules .= W3TC_MARKER_BEGIN_BROWSERCACHE_NO404WP . "\n";
     $rules .= "<IfModule mod_rewrite.c>\n";
     $rules .= "    RewriteEngine On\n";
     // in subdir - rewrite theme files and similar to upper folder if file exists
     if (Util_Environment::is_wpmu() && !Util_Environment::is_wpmu_subdomain()) {
         $rules .= "    RewriteCond %{REQUEST_FILENAME} !-f\n";
         $rules .= "    RewriteCond %{REQUEST_FILENAME} !-d\n";
         $rules .= "    RewriteCond %{REQUEST_URI} ^{$wp_uri}/([_0-9a-zA-Z-]+/)(.*\\.)(" . implode('|', $extensions) . ")\$ [NC]\n";
         $document_root = Util_Rule::apache_docroot_variable();
         $rules .= '    RewriteCond "' . $document_root . $wp_uri . '/%2%3" -f' . "\n";
         $rules .= "    RewriteRule .* {$wp_uri}/%2%3 [L]\n\n";
     }
     $rules .= "    RewriteCond %{REQUEST_FILENAME} !-f\n";
     $rules .= "    RewriteCond %{REQUEST_FILENAME} !-d\n";
     $imploded = implode('|', $exceptions);
     if (!empty($imploded)) {
         $rules .= "    RewriteCond %{REQUEST_URI} !(" . $imploded . ")\n";
     }
     $rules .= "    RewriteCond %{REQUEST_URI} \\.(" . implode('|', $extensions) . ")\$ [NC]\n";
     $rules .= "    RewriteRule .* - [L]\n";
     $rules .= "</IfModule>\n";
     $rules .= W3TC_MARKER_END_BROWSERCACHE_NO404WP . "\n";
     return $rules;
 }
开发者ID:eduardodomingos,项目名称:eduardodomingos.com,代码行数:50,代码来源:BrowserCache_Environment.php

示例3: get_regexp_by_mask

 /**
  * Returns regexp by mask
  *
  * @param string  $mask
  * @return string
  */
 function get_regexp_by_mask($mask)
 {
     $mask = trim($mask);
     $mask = Util_Environment::preg_quote($mask);
     $mask = str_replace(array('\\*', '\\?', ';'), array('@ASTERISK@', '@QUESTION@', '|'), $mask);
     $regexp = str_replace(array('@ASTERISK@', '@QUESTION@'), array('[^\\?\\*:\\|"<>]*', '[^\\?\\*:\\|"<>]'), $mask);
     return $regexp;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:14,代码来源:Cdn_Core_Admin.php

示例4: fill_regexps

 private function fill_regexps()
 {
     $regexps = array();
     $site_path = Util_Environment::site_url_uri();
     $domain_url_regexp = Util_Environment::home_domain_root_url_regexp();
     $site_domain_url_regexp = false;
     if ($domain_url_regexp != Util_Environment::get_url_regexp(Util_Environment::url_to_host(site_url()))) {
         $site_domain_url_regexp = Util_Environment::get_url_regexp(Util_Environment::url_to_host(site_url()));
     }
     if ($this->_config->get_boolean('cdn.uploads.enable')) {
         $upload_info = Util_Http::upload_info();
         if ($upload_info) {
             $baseurl = $upload_info['baseurl'];
             if (defined('DOMAIN_MAPPING') && DOMAIN_MAPPING) {
                 $parsed = @parse_url($upload_info['baseurl']);
                 $baseurl = home_url() . $parsed['path'];
             }
             $regexps = $this->make_uploads_regexes($domain_url_regexp, $baseurl, $upload_info, $regexps);
             if ($site_domain_url_regexp) {
                 $regexps = $this->make_uploads_regexes($site_domain_url_regexp, $baseurl, $upload_info, $regexps);
             }
         }
     }
     if ($this->_config->get_boolean('cdn.includes.enable')) {
         $mask = $this->_config->get_string('cdn.includes.files');
         if ($mask != '') {
             $regexps[] = '~(["\'(=])\\s*((' . $domain_url_regexp . ')?(' . Util_Environment::preg_quote($site_path . WPINC) . '/(' . Cdn_Util::get_regexp_by_mask($mask) . ')([^"\'() >]*)))~i';
             if ($site_domain_url_regexp) {
                 $regexps[] = '~(["\'(=])\\s*((' . $site_domain_url_regexp . ')?(' . Util_Environment::preg_quote($site_path . WPINC) . '/(' . Cdn_Util::get_regexp_by_mask($mask) . ')([^"\'() >]*)))~i';
             }
         }
     }
     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 . ')?(' . Util_Environment::preg_quote($theme_dir) . '/(' . Cdn_Util::get_regexp_by_mask($mask) . ')([^"\'() >]*)))~i';
             if ($site_domain_url_regexp) {
                 $theme_dir2 = preg_replace('~' . $site_domain_url_regexp . '~i', '', get_theme_root_uri());
                 $regexps[] = '~(["\'(=])\\s*((' . $site_domain_url_regexp . ')?(' . Util_Environment::preg_quote($theme_dir) . '/(' . Cdn_Util::get_regexp_by_mask($mask) . ')([^"\'() >]*)))~i';
                 $regexps[] = '~(["\'(=])\\s*((' . $site_domain_url_regexp . ')?(' . Util_Environment::preg_quote($theme_dir2) . '/(' . Cdn_Util::get_regexp_by_mask($mask) . ')([^"\'() >]*)))~i';
             }
         }
     }
     if ($this->_config->get_boolean('cdn.custom.enable')) {
         $masks = $this->_config->get_array('cdn.custom.files');
         $masks = array_map(array('\\W3TC\\Cdn_Util', 'replace_folder_placeholders'), $masks);
         $masks = array_map(array('\\W3TC\\Util_Environment', 'parse_path'), $masks);
         if (count($masks)) {
             $mask_regexps = array();
             foreach ($masks as $mask) {
                 if ($mask != '') {
                     $mask = Util_Environment::normalize_file($mask);
                     $mask_regexps[] = Cdn_Util::get_regexp_by_mask($mask);
                 }
             }
             $regexps[] = '~(["\'(=])\\s*((' . $domain_url_regexp . ')?(' . Util_Environment::preg_quote($site_path) . '(' . implode('|', $mask_regexps) . ')([^"\'() >]*)))~i';
             if ($site_domain_url_regexp) {
                 $regexps[] = '~(["\'(=])\\s*((' . $site_domain_url_regexp . ')?(' . Util_Environment::preg_quote($site_path) . '(' . implode('|', $mask_regexps) . ')([^"\'() >]*)))~i';
             }
         }
     }
     $this->_regexps = $regexps;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:64,代码来源:Cdn_Plugin.php

示例5: get_url_regexp

 /**
  * Returns URL regexp from URL
  *
  * @param string  $url
  * @return string
  */
 public static function get_url_regexp($url)
 {
     $url = preg_replace('~(https?:)?//~i', '', $url);
     $url = preg_replace('~^www\\.~i', '', $url);
     $regexp = '(https?:)?//(www\\.)?' . Util_Environment::preg_quote($url);
     return $regexp;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:13,代码来源:Util_Environment.php

示例6: has_rules

 /**
  * Check if rules exist
  *
  * @param string  $rules
  * @param string  $start
  * @param string  $end
  * @return int
  */
 public static function has_rules($rules, $start, $end)
 {
     return preg_match('~' . Util_Environment::preg_quote($start) . "\n.*?" . Util_Environment::preg_quote($end) . "\n*~s", $rules);
 }
开发者ID:eduardodomingos,项目名称:eduardodomingos.com,代码行数:12,代码来源:Util_Rule.php


注:本文中的Util_Environment::preg_quote方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。