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


PHP WPSEO_Utils::is_url_relative方法代码示例

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


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

示例1: add_image

 /**
  * Display an OpenGraph image tag
  *
  * @param string $img - Source URL to the image
  *
  * @return bool
  */
 private function add_image($img)
 {
     // Filter: 'wpseo_opengraph_image' - Allow changing the OpenGraph image */
     $img = trim(apply_filters('wpseo_opengraph_image', $img));
     if (empty($img)) {
         return false;
     }
     if (WPSEO_Utils::is_url_relative($img) === true) {
         $img = $this->get_relative_path($img);
     }
     if (in_array($img, $this->images)) {
         return false;
     }
     array_push($this->images, $img);
     return true;
 }
开发者ID:goodbayscott,项目名称:wwr-temp,代码行数:23,代码来源:class-opengraph.php

示例2: wpseo_is_url_relative

/**
 * Check whether a url is relative
 *
 * @deprecated 1.6.1
 * @deprecated use WPSEO_Utils::is_url_relative()
 * @see WPSEO_Utils::is_url_relative()
 *
 * @param string $url
 *
 * @return bool
 */
function wpseo_is_url_relative($url)
{
    _deprecated_function(__FUNCTION__, 'WPSEO 1.6.1', 'WPSEO_Utils::is_url_relative()');
    return WPSEO_Utils::is_url_relative($url);
}
开发者ID:presteege,项目名称:presteege.fr,代码行数:16,代码来源:wpseo-functions.php

示例3: get_anchor_count

 /**
  * Count the number of anchors and group them by type.
  *
  * @param object $xpath An XPATH object of the current document.
  *
  * @return array
  */
 function get_anchor_count(&$xpath)
 {
     $query = '//a|//A';
     $dom_objects = $xpath->query($query);
     $count = array('total' => 0, 'internal' => array('nofollow' => 0, 'dofollow' => 0), 'external' => array('nofollow' => 0, 'dofollow' => 0), 'other' => array('nofollow' => 0, 'dofollow' => 0));
     if (is_object($dom_objects) && is_a($dom_objects, 'DOMNodeList') && $dom_objects->length > 0) {
         foreach ($dom_objects as $dom_object) {
             $count['total']++;
             if ($dom_object->attributes->getNamedItem('href')) {
                 $href = $dom_object->attributes->getNamedItem('href')->textContent;
                 $wpurl = get_bloginfo('url');
                 if (WPSEO_Utils::is_url_relative($href) === true || substr($href, 0, strlen($wpurl)) === $wpurl) {
                     $type = 'internal';
                 } elseif (substr($href, 0, 4) == 'http') {
                     $type = 'external';
                 } else {
                     $type = 'other';
                 }
                 if ($dom_object->attributes->getNamedItem('rel')) {
                     $link_rel = $dom_object->attributes->getNamedItem('rel')->textContent;
                     if (stripos($link_rel, 'nofollow') !== false) {
                         $count[$type]['nofollow']++;
                     } else {
                         $count[$type]['dofollow']++;
                     }
                 } else {
                     $count[$type]['dofollow']++;
                 }
             }
         }
     }
     return $count;
 }
开发者ID:Nisha318,项目名称:p3edtech,代码行数:40,代码来源:class-metabox.php

示例4: generate_canonical

 /**
  * This function normally outputs the canonical but is also used in other places to retrieve
  * the canonical URL for the current page.
  *
  * @return void
  */
 private function generate_canonical()
 {
     $canonical = false;
     $canonical_override = false;
     // Set decent canonicals for homepage, singulars and taxonomy pages
     if (is_singular()) {
         $obj = get_queried_object();
         $canonical = get_permalink($obj->ID);
         $this->canonical_unpaged = $canonical;
         $canonical_override = WPSEO_Meta::get_value('canonical');
         // Fix paginated pages canonical, but only if the page is truly paginated.
         if (get_query_var('page') > 1) {
             $num_pages = substr_count($obj->post_content, '<!--nextpage-->') + 1;
             if ($num_pages && get_query_var('page') <= $num_pages) {
                 if (!$GLOBALS['wp_rewrite']->using_permalinks()) {
                     $canonical = add_query_arg('page', get_query_var('page'), $canonical);
                 } else {
                     $canonical = user_trailingslashit(trailingslashit($canonical) . get_query_var('page'));
                 }
             }
         }
     } else {
         if (is_search()) {
             $canonical = get_search_link();
         } elseif (is_front_page()) {
             $canonical = home_url();
         } elseif ($this->is_posts_page()) {
             $canonical = get_permalink(get_option('page_for_posts'));
         } elseif (is_tax() || is_tag() || is_category()) {
             $term = get_queried_object();
             $canonical_override = WPSEO_Taxonomy_Meta::get_term_meta($term, $term->taxonomy, 'canonical');
             $canonical = get_term_link($term, $term->taxonomy);
         } elseif (is_post_type_archive()) {
             $post_type = get_query_var('post_type');
             if (is_array($post_type)) {
                 $post_type = reset($post_type);
             }
             $canonical = get_post_type_archive_link($post_type);
         } elseif (is_author()) {
             $canonical = get_author_posts_url(get_query_var('author'), get_query_var('author_name'));
         } elseif (is_archive()) {
             if (is_date()) {
                 if (is_day()) {
                     $canonical = get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day'));
                 } elseif (is_month()) {
                     $canonical = get_month_link(get_query_var('year'), get_query_var('monthnum'));
                 } elseif (is_year()) {
                     $canonical = get_year_link(get_query_var('year'));
                 }
             }
         }
         $this->canonical_unpaged = $canonical;
         if ($canonical && get_query_var('paged') > 1) {
             global $wp_rewrite;
             if (!$wp_rewrite->using_permalinks()) {
                 if (is_front_page()) {
                     $canonical = trailingslashit($canonical);
                 }
                 $canonical = add_query_arg('paged', get_query_var('paged'), $canonical);
             } else {
                 if (is_front_page()) {
                     $canonical = wpseo_xml_sitemaps_base_url('');
                 }
                 $canonical = user_trailingslashit(trailingslashit($canonical) . trailingslashit($wp_rewrite->pagination_base) . get_query_var('paged'));
             }
         }
     }
     $this->canonical_no_override = $canonical;
     if (is_string($canonical) && $canonical !== '') {
         // Force canonical links to be absolute, relative is NOT an option.
         if (WPSEO_Utils::is_url_relative($canonical) === true) {
             $canonical = $this->base_url($canonical);
         }
     }
     /**
      * Filter: 'wpseo_canonical' - Allow filtering of the canonical URL put out by WP SEO
      *
      * @api string $canonical The canonical URL
      */
     $canonical = apply_filters('wpseo_canonical', $canonical);
     if (is_string($canonical_override) && $canonical_override !== '') {
         $this->canonical = $canonical_override;
     } else {
         $this->canonical = $canonical;
     }
 }
开发者ID:shellygraham,项目名称:livestock-framing,代码行数:92,代码来源:class-frontend.php

示例5: build_post_type_map


//.........这里部分代码省略.........
                  * @api string $url URL to use in the XML sitemap
                  *
                  * @param object $p Post object for the URL
                  */
                 $url['loc'] = apply_filters('wpseo_xml_sitemap_post_url', $url['loc'], $p);
                 $url['chf'] = $this->filter_frequency($post_type . '_single', 'weekly', $url['loc']);
                 /**
                  * Do not include external URLs.
                  * @see https://wordpress.org/plugins/page-links-to/ can rewrite permalinks to external URLs.
                  */
                 if (false === strpos($url['loc'], $this->home_url)) {
                     continue;
                 }
                 $canonical = WPSEO_Meta::get_value('canonical', $p->ID);
                 if ($canonical !== '' && $canonical !== $url['loc']) {
                     /* Let's assume that if a canonical is set for this page and it's different from
                        the URL of this post, that page is either already in the XML sitemap OR is on
                        an external site, either way, we shouldn't include it here. */
                     continue;
                 } else {
                     if ($this->options['trailingslash'] === true && $p->post_type != 'post') {
                         $url['loc'] = trailingslashit($url['loc']);
                     }
                 }
                 unset($canonical);
                 $url['pri'] = $this->calculate_priority($p);
                 $url['images'] = array();
                 $content = $p->post_content;
                 $content = '<p><img src="' . $this->image_url(get_post_thumbnail_id($p->ID)) . '" alt="' . $p->post_title . '" /></p>' . $content;
                 if (preg_match_all('`<img [^>]+>`', $content, $matches)) {
                     foreach ($matches[0] as $img) {
                         if (preg_match('`src=["\']([^"\']+)["\']`', $img, $match)) {
                             $src = $match[1];
                             if (WPSEO_Utils::is_url_relative($src) === true) {
                                 if ($src[0] !== '/') {
                                     continue;
                                 } else {
                                     // The URL is relative, we'll have to make it absolute
                                     $src = $this->home_url . $src;
                                 }
                             } elseif (strpos($src, 'http') !== 0) {
                                 // Protocol relative url, we add the scheme as the standard requires a protocol
                                 $src = $scheme . ':' . $src;
                             }
                             if (strpos($src, $host) === false) {
                                 continue;
                             }
                             if ($src != esc_url($src)) {
                                 continue;
                             }
                             if (isset($url['images'][$src])) {
                                 continue;
                             }
                             $image = array('src' => apply_filters('wpseo_xml_sitemap_img_src', $src, $p));
                             if (preg_match('`title=["\']([^"\']+)["\']`', $img, $title_match)) {
                                 $image['title'] = str_replace(array('-', '_'), ' ', $title_match[1]);
                             }
                             unset($title_match);
                             if (preg_match('`alt=["\']([^"\']+)["\']`', $img, $alt_match)) {
                                 $image['alt'] = str_replace(array('-', '_'), ' ', $alt_match[1]);
                             }
                             unset($alt_match);
                             $image = apply_filters('wpseo_xml_sitemap_img', $image, $p);
                             $url['images'][] = $image;
                         }
                         unset($match, $src);
开发者ID:BennyHudson,项目名称:foundations,代码行数:67,代码来源:class-sitemaps.php

示例6: yoast_wpseo_video_is_url_relative

 /**
  * Fallback function for WP SEO functionality, is_url_relative
  *
  * @param $url
  *
  * @return mixed
  */
 public static function yoast_wpseo_video_is_url_relative($url)
 {
     if (method_exists('WPSEO_Utils', 'is_url_relative')) {
         return WPSEO_Utils::is_url_relative($url);
     }
     return wpseo_is_url_relative($url);
 }
开发者ID:bitrecruiter,项目名称:wordpress-stackable,代码行数:14,代码来源:video-seo.php

示例7: parse_matched_images

 /**
  * Parsing the matched images
  *
  * @param array  $matches
  * @param object $p
  * @param string $scheme
  * @param string $host
  *
  * @return array
  */
 private function parse_matched_images($matches, $p, $scheme, $host)
 {
     $return = array();
     foreach ($matches[0] as $img) {
         if (preg_match('`src=["\']([^"\']+)["\']`', $img, $match)) {
             $src = $match[1];
             if (WPSEO_Utils::is_url_relative($src) === true) {
                 if ($src[0] !== '/') {
                     continue;
                 } else {
                     // The URL is relative, we'll have to make it absolute.
                     $src = $this->home_url . $src;
                 }
             } elseif (strpos($src, 'http') !== 0) {
                 // Protocol relative url, we add the scheme as the standard requires a protocol.
                 $src = $scheme . ':' . $src;
             }
             if (strpos($src, $host) === false) {
                 continue;
             }
             if ($src != esc_url($src)) {
                 continue;
             }
             if (isset($return[$src])) {
                 continue;
             }
             $image = array('src' => apply_filters('wpseo_xml_sitemap_img_src', $src, $p));
             if (preg_match('`title=["\']([^"\']+)["\']`', $img, $title_match)) {
                 $image['title'] = str_replace(array('-', '_'), ' ', $title_match[1]);
             }
             unset($title_match);
             if (preg_match('`alt=["\']([^"\']+)["\']`', $img, $alt_match)) {
                 $image['alt'] = str_replace(array('-', '_'), ' ', $alt_match[1]);
             }
             unset($alt_match);
             $image = apply_filters('wpseo_xml_sitemap_img', $image, $p);
             $return[] = $image;
         }
         unset($match, $src);
     }
     return $return;
 }
开发者ID:flasomm,项目名称:Montkailash,代码行数:52,代码来源:class-sitemaps.php

示例8: get_absolute_url

 /**
  * Make absolute URL for domain or protocol-relative one.
  *
  * @param string $src URL to process.
  *
  * @return string
  */
 protected function get_absolute_url($src)
 {
     if (WPSEO_Utils::is_url_relative($src) === true) {
         if ($src[0] !== '/') {
             return $src;
         }
         // The URL is relative, we'll have to make it absolute.
         return $this->home_url . $src;
     }
     if (strpos($src, 'http') !== 0) {
         // Protocol relative url, we add the scheme as the standard requires a protocol.
         return $this->scheme . ':' . $src;
     }
     return $src;
 }
开发者ID:Garth619,项目名称:Femi9,代码行数:22,代码来源:class-sitemap-image-parser.php

示例9: image_output

 /**
  * Display an OpenGraph image tag
  *
  * @param string $img Source URL to the image
  *
  * @return bool
  */
 public function image_output($img)
 {
     /**
      * Filter: 'wpseo_opengraph_image' - Allow changing the OpenGraph image
      *
      * @api string $img Image URL string
      */
     $img = trim(apply_filters('wpseo_opengraph_image', $img));
     if (empty($img)) {
         return false;
     }
     if (WPSEO_Utils::is_url_relative($img) === true) {
         if ($img[0] != '/') {
             return false;
         }
         // If it's a relative URL, it's relative to the domain, not necessarily to the WordPress install, we
         // want to preserve domain name and URL scheme (http / https) though.
         $parsed_url = parse_url(home_url());
         $img = $parsed_url['scheme'] . '://' . $parsed_url['host'] . $img;
     }
     if (in_array($img, $this->shown_images)) {
         return false;
     }
     array_push($this->shown_images, $img);
     $this->og_tag('og:image', esc_url($img));
     return true;
 }
开发者ID:BennyHudson,项目名称:foundations,代码行数:34,代码来源:class-opengraph.php

示例10: parse_matched_images

 /**
  * Parsing the matched images
  *
  * @param array  $matches Set of matches.
  * @param object $post    Post object.
  *
  * @return array
  */
 private function parse_matched_images($matches, $post)
 {
     $return = array();
     foreach ($matches as $img) {
         if (!preg_match('`src=["\']([^"\']+)["\']`', $img, $match)) {
             continue;
         }
         $src = $match[1];
         if (WPSEO_Utils::is_url_relative($src) === true) {
             if ($src[0] !== '/') {
                 continue;
             }
             // The URL is relative, we'll have to make it absolute.
             $src = $this->home_url . $src;
         } elseif (strpos($src, 'http') !== 0) {
             // Protocol relative url, we add the scheme as the standard requires a protocol.
             $src = $this->scheme . ':' . $src;
         }
         if (strpos($src, $this->host) === false) {
             continue;
         }
         if ($src !== esc_url($src)) {
             continue;
         }
         if (isset($return[$src])) {
             continue;
         }
         $image = array('src' => apply_filters('wpseo_xml_sitemap_img_src', $src, $post));
         if (preg_match('`title=["\']([^"\']+)["\']`', $img, $title_match)) {
             $image['title'] = str_replace(array('-', '_'), ' ', $title_match[1]);
         }
         unset($title_match);
         if (preg_match('`alt=["\']([^"\']+)["\']`', $img, $alt_match)) {
             $image['alt'] = str_replace(array('-', '_'), ' ', $alt_match[1]);
         }
         unset($alt_match);
         /**
          * Filter image data to be included in XML sitemap for the post.
          *
          * @param array $image {
          *     Array of image data.
          *
          *     @type string $src Image URL.
          *     @type string $title Image title attribute (optional).
          *     @type string $alt Image alt attribute (optional).
          * }
          * @param object $post  Post object.
          */
         $image = apply_filters('wpseo_xml_sitemap_img', $image, $post);
         $return[] = $image;
         unset($match, $src);
     }
     return $return;
 }
开发者ID:Friends-School-Atlanta,项目名称:Deployable-WordPress,代码行数:62,代码来源:class-sitemap-image-parser.php

示例11: image_output

 /**
  * Outputs a Twitter image tag for a given image
  *
  * @param string  $img The source URL to the image.
  * @param boolean $tag Deprecated argument, previously used for gallery images.
  *
  * @return bool
  */
 protected function image_output($img, $tag = false)
 {
     if ($tag) {
         _deprecated_argument(__METHOD__, 'WPSEO 2.4');
     }
     /**
      * Filter: 'wpseo_twitter_image' - Allow changing the Twitter Card image
      *
      * @api string $img Image URL string
      */
     $img = apply_filters('wpseo_twitter_image', $img);
     if (WPSEO_Utils::is_url_relative($img) === true && $img[0] === '/') {
         $parsed_url = parse_url(home_url());
         $img = $parsed_url['scheme'] . '://' . $parsed_url['host'] . $img;
     }
     $escaped_img = esc_url($img);
     if (in_array($escaped_img, $this->shown_images)) {
         return false;
     }
     if (is_string($escaped_img) && $escaped_img !== '') {
         $this->output_metatag('image', $escaped_img, true);
         array_push($this->shown_images, $escaped_img);
         return true;
     }
     return false;
 }
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:34,代码来源:class-twitter.php


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