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


PHP TimberURLHelper::is_absolute方法代码示例

本文整理汇总了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;
 }
开发者ID:nitwitt10,项目名称:wp-test,代码行数:17,代码来源:timber-url-helper.php

示例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);
         }
     }
 }
开发者ID:Kilbourne,项目名称:restart,代码行数:58,代码来源:timber-image.php

示例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;
 }
开发者ID:Butterwell,项目名称:timber,代码行数:49,代码来源:timber-image-helper.php

示例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;
 }
开发者ID:Butterwell,项目名称:timber,代码行数:13,代码来源:timber-url-helper.php


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