本文整理汇总了PHP中TimberURLHelper::is_absolute方法的典型用法代码示例。如果您正苦于以下问题:PHP TimberURLHelper::is_absolute方法的具体用法?PHP TimberURLHelper::is_absolute怎么用?PHP TimberURLHelper::is_absolute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimberURLHelper
的用法示例。
在下文中一共展示了TimberURLHelper::is_absolute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_external_content
/**
* This function is slightly different from the one below in the case of:
* an image hosted on the same domain BUT on a different site than the
* Wordpress install will be reported as external content.
*
* @param string $url a URL to evaluate against
* @return boolean if $url points to an external location returns true
*/
public static function is_external_content($url)
{
// using content_url() instead of site_url or home_url is IMPORTANT
// otherwise you run into errors with sites that:
// 1. use WPML plugin
// 2. or redefine upload directory
$is_external = TimberURLHelper::is_absolute($url) && !strstr($url, content_url());
return $is_external;
}
示例2: init
/**
* @param int $iid
*/
function init($iid = false)
{
if (!is_numeric($iid) && is_string($iid)) {
if (strstr($iid, '://')) {
$this->init_with_url($iid);
return;
}
if (strstr($iid, ABSPATH)) {
$this->init_with_file_path($iid);
return;
}
if (strstr(strtolower($iid), '.jpg')) {
$this->init_with_relative_path($iid);
return;
}
}
$image_info = $this->get_image_info($iid);
$this->import($image_info);
$basedir = self::wp_upload_dir();
$basedir = $basedir['basedir'];
if (isset($this->file)) {
$this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file;
} else {
if (isset($this->_wp_attached_file)) {
$this->file = reset($this->_wp_attached_file);
$this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file;
} else {
if (isset($this->guid)) {
if (TimberURLHelper::is_absolute($this->guid)) {
$this->file_loc = TimberURLHelper::url_to_file_system($this->guid);
}
}
}
}
if (isset($image_info['id'])) {
$this->ID = $image_info['id'];
} else {
if (is_numeric($iid)) {
$this->ID = $iid;
}
}
if (isset($this->ID)) {
$custom = get_post_custom($this->ID);
foreach ($custom as $key => $value) {
$this->{$key} = $value[0];
}
} else {
if (is_array($iid)) {
TimberHelper::error_log('Not able to init in TimberImage with iid=');
TimberHelper::error_log($iid);
} else {
TimberHelper::error_log('Not able to init in TimberImage with iid=' . $iid);
}
}
}
示例3: analyze_url
/**
* Takes in an URL and breaks it into components,
* that will then be used in the different steps of image processing.
* The image is expected to be either part of a theme, plugin, or an upload.
*
* @param string $url an URL (absolute or relative) pointing to an image
* @return array an array (see keys in code below)
*/
private static function analyze_url($url)
{
$result = array('url' => $url, 'absolute' => TimberURLHelper::is_absolute($url), 'base' => 0, 'subdir' => '', 'filename' => '', 'extension' => '', 'basename' => '');
$upload_dir = wp_upload_dir();
$tmp = $url;
if (0 === strpos($tmp, ABSPATH)) {
// we've been given a dir, not an url
$result['absolute'] = true;
if (0 === strpos($tmp, $upload_dir['basedir'])) {
$result['base'] = self::BASE_UPLOADS;
// upload based
$tmp = str_replace($upload_dir['basedir'], '', $tmp);
}
if (0 === strpos($tmp, WP_CONTENT_DIR)) {
$result['base'] = self::BASE_CONTENT;
// content based
$tmp = str_replace(WP_CONTENT_DIR, '', $tmp);
}
} else {
if (!$result['absolute']) {
$tmp = home_url() . $tmp;
}
if (0 === strpos($tmp, $upload_dir['baseurl'])) {
$result['base'] = self::BASE_UPLOADS;
// upload based
$tmp = str_replace($upload_dir['baseurl'], '', $tmp);
}
if (0 === strpos($tmp, content_url())) {
$result['base'] = self::BASE_CONTENT;
// content-based
$tmp = str_replace(content_url(), '', $tmp);
}
}
$parts = pathinfo($tmp);
$result['subdir'] = $parts['dirname'];
$result['filename'] = $parts['filename'];
$result['extension'] = $parts['extension'];
$result['basename'] = $parts['basename'];
// todo filename
return $result;
}
示例4: is_external_content
/**
* This function is slightly different from the one below in the case of:
* an image hosted on the same domain BUT on a different site than the
* Wordpress install will be reported as external content.
*
* @param string $url a URL to evaluate against
* @return boolean if $url points to an external location returns true
*/
public static function is_external_content($url)
{
$is_external = TimberURLHelper::is_absolute($url) && !TimberURLHelper::is_internal_content($url);
return $is_external;
}