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


PHP Util_Environment::url_to_docroot_filename方法代码示例

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


在下文中一共展示了Util_Environment::url_to_docroot_filename方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: minify_filename_to_filenames_for_minification

 /**
  * Returns custom files
  *
  * @param string  $hash
  * @param string  $type
  * @return array
  */
 function minify_filename_to_filenames_for_minification($hash, $type)
 {
     // if bad data passed as get parameter - it shouldn't fire internal errors
     try {
         $files = Minify_Core::minify_filename_to_urls_for_minification($hash, $type);
     } catch (Exception $e) {
         $files = array();
     }
     $result = array();
     if (is_array($files) && count($files) > 0) {
         foreach ($files as $file) {
             $file = Util_Environment::url_to_docroot_filename($file);
             if (Util_Environment::is_url($file)) {
                 $precached_file = $this->_precache_file($file, $type);
                 if ($precached_file) {
                     $result[] = $precached_file;
                 } else {
                     Minify_Core::debug_error(sprintf('Unable to cache remote file: "%s"', $file));
                 }
             } else {
                 $path = Util_Environment::document_root() . '/' . $file;
                 if (file_exists($path)) {
                     $result[] = $file;
                 } else {
                     Minify_Core::debug_error(sprintf('File "%s" doesn\'t exist', $path));
                 }
             }
         }
     } else {
         Minify_Core::debug_error(sprintf('Unable to fetch custom files list: "%s.%s"', $hash, $type), false, 404);
     }
     return $result;
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:40,代码来源:Minify_MinifiedFileRequestHandler.php

示例2: process_script_tag

 /**
  * Processes script tag
  *
  * @param unknown $script_tag
  * @return void
  */
 private function process_script_tag($script_tag, $script_tag_number)
 {
     if ($this->debug) {
         Minify_Core::log('processing tag ' . substr($script_tag, 0, 150));
     }
     $tag_pos = strpos($this->buffer, $script_tag);
     if ($tag_pos === false) {
         // script is external but not found, skip processing it
         error_log('script not found:' . $script_tag);
         Minify_Core::log('script not found:' . $script_tag);
         return;
     }
     $match = null;
     if (!preg_match('~<script\\s+[^<>]*src=["\']?([^"\'> ]+)["\'> ]~is', $script_tag, $match)) {
         $match = null;
     }
     if (is_null($match)) {
         $data = array('script_tag_original' => $script_tag, 'script_tag_new' => $script_tag, 'script_tag_number' => $script_tag_number, 'script_tag_pos' => $tag_pos, 'should_replace' => false, 'buffer' => $this->buffer);
         $data = apply_filters('w3tc_minify_js_do_local_script_minification', $data);
         $this->buffer = $data['buffer'];
         if ($data['should_replace']) {
             $this->buffer = substr_replace($this->buffer, $data['script_tag_new'], $tag_pos, strlen($script_tag));
         }
         // it's not external script, have to flush what we have before it
         if ($this->debug) {
             Minify_Core::log('its not src=, flushing');
         }
         $this->flush_collected($script_tag);
         if (preg_match('~</head>~is', $script_tag, $match)) {
             $this->group_type = 'body';
         }
         return;
     }
     $script_src = $match[1];
     $script_src = Util_Environment::url_relative_to_full($script_src);
     $file = Util_Environment::url_to_docroot_filename($script_src);
     $step1 = $this->minify_helpers->is_file_for_minification($file);
     $step2 = !in_array($file, $this->ignore_js_files);
     $do_tag_minification = $step1 && $step2;
     $do_tag_minification = apply_filters('w3tc_minify_js_do_tag_minification', $do_tag_minification, $script_tag, $file);
     if (!$do_tag_minification) {
         if ($this->debug) {
             Minify_Core::log('file ' . $file . ' didnt pass minification check:' . ' file_for_min: ' . ($step1 ? 'true' : 'false') . ' ignore_js_files: ' . ($step2 ? 'true' : 'false'));
         }
         $data = array('script_tag_original' => $script_tag, 'script_tag_new' => $script_tag, 'script_tag_number' => $script_tag_number, 'script_tag_pos' => $tag_pos, 'script_src' => $script_src, 'should_replace' => false, 'buffer' => $this->buffer);
         $data = apply_filters('w3tc_minify_js_do_excluded_tag_script_minification', $data);
         $this->buffer = $data['buffer'];
         if ($data['should_replace']) {
             $this->buffer = substr_replace($this->buffer, $data['script_tag_new'], $tag_pos, strlen($script_tag));
         }
         $this->flush_collected($script_tag);
         return;
     }
     $this->debug_minified_urls[] = $file;
     $this->buffer = substr_replace($this->buffer, '', $tag_pos, strlen($script_tag));
     // for head group - put minified file at the place of first script
     // for body - put at the place of last script, to make as more DOM
     // objects available as possible
     if (count($this->files_to_minify) <= 0 || $this->group_type == 'body') {
         $this->embed_pos = $tag_pos;
     }
     $this->files_to_minify[] = $file;
 }
开发者ID:eduardodomingos,项目名称:eduardodomingos.com,代码行数:69,代码来源:Minify_Plugin.php

示例3: 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)
 {
     $docroot_filename = Util_Environment::url_to_docroot_filename($url);
     $filename = Util_Environment::document_root() . '/' . $docroot_filename;
     $a = parse_url($url);
     $uri = $a['path'];
     $remote_file_name = $this->uri_to_cdn_uri($uri);
     $this->queue_add($filename, $remote_file_name, W3TC_CDN_COMMAND_UPLOAD, 'Pending');
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:16,代码来源:Cdn_Core.php


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