本文整理汇总了PHP中Util_Environment::remove_query_all方法的典型用法代码示例。如果您正苦于以下问题:PHP Util_Environment::remove_query_all方法的具体用法?PHP Util_Environment::remove_query_all怎么用?PHP Util_Environment::remove_query_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Util_Environment
的用法示例。
在下文中一共展示了Util_Environment::remove_query_all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_file_for_minification
/**
* URL file filter
*
* @param string $file
* @return bool
*/
public function is_file_for_minification($file)
{
static $external;
if (!isset($external)) {
$external = $this->config->get_array('minify.cache.files');
}
foreach ($external as $ext) {
if (preg_match('#' . Util_Environment::get_url_regexp($ext) . '#', $file)) {
if ($this->debug) {
Minify_Core::log('is_file_for_minification: whilelisted ' . $file);
}
return true;
}
}
$file_normalized = Util_Environment::remove_query_all($file);
$ext = strrchr($file_normalized, '.');
if ($ext != '.js' && $ext != '.css') {
if ($this->debug) {
Minify_Core::log('is_file_for_minification: unknown extension ' . $ext . ' for ' . $file);
}
return false;
}
if (Util_Environment::is_url($file_normalized)) {
if ($this->debug) {
Minify_Core::log('is_file_for_minification: its url ' . $file);
}
return false;
}
$path = Util_Environment::document_root() . '/' . $file;
if (!file_exists($path)) {
if ($this->debug) {
Minify_Core::log('is_file_for_minification: file doesnt exists ' . $path);
}
return false;
}
if ($this->debug) {
Minify_Core::log('is_file_for_minification: true for file ' . $file . ' path ' . $path);
}
return true;
}
示例2: url_to_docroot_filename
/**
* Normalizes file name for minify
* Relative to document root!
*
* @param string $file
* @return string
*/
public static function url_to_docroot_filename($url)
{
$data = array('home_url' => get_home_url(), 'url' => $url);
$data = apply_filters('w3tc_url_to_docroot_filename', $data);
$home_url = $data['home_url'];
$normalized_url = $data['url'];
$normalized_url = Util_Environment::remove_query_all($normalized_url);
// cut protocol
$normalized_url = preg_replace('~^http(s)?://~', '//', $normalized_url);
$home_url = preg_replace('~^http(s)?://~', '//', $home_url);
if (substr($normalized_url, 0, strlen($home_url)) != $home_url) {
// not a home url, return unchanged since cant be
// converted to filename
return $url;
} else {
$path_relative_to_home = str_replace($home_url, '', $normalized_url);
$home = set_url_scheme(get_option('home'), 'http');
$siteurl = set_url_scheme(get_option('siteurl'), 'http');
$home_path = rtrim(Util_Environment::site_path(), '/');
// adjust home_path if site is not is home
if (!empty($home) && 0 !== strcasecmp($home, $siteurl)) {
// $siteurl - $home
$wp_path_rel_to_home = rtrim(str_ireplace($home, '', $siteurl), '/');
if (substr($home_path, -strlen($wp_path_rel_to_home)) == $wp_path_rel_to_home) {
$home_path = substr($home_path, 0, -strlen($wp_path_rel_to_home));
}
}
// common encoded characters
$path_relative_to_home = str_replace('%20', ' ', $path_relative_to_home);
$full_filename = $home_path . DIRECTORY_SEPARATOR . trim($path_relative_to_home, DIRECTORY_SEPARATOR);
$docroot = Util_Environment::document_root();
if (substr($full_filename, 0, strlen($docroot)) == $docroot) {
$docroot_filename = substr($full_filename, strlen($docroot));
} else {
$docroot_filename = $path_relative_to_home;
}
}
// sometimes urls (coming from other plugins/themes)
// contain multiple "/" like "my-folder//myfile.js" which
// fails to recognize by filesystem, while url is accessible
$docroot_filename = str_replace('//', DIRECTORY_SEPARATOR, $docroot_filename);
return ltrim($docroot_filename, DIRECTORY_SEPARATOR);
}