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


PHP get_url_in_content函数代码示例

本文整理汇总了PHP中get_url_in_content函数的典型用法代码示例。如果您正苦于以下问题:PHP get_url_in_content函数的具体用法?PHP get_url_in_content怎么用?PHP get_url_in_content使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: post_grid_get_link_url

function post_grid_get_link_url()
{
    $content = get_the_content();
    $has_url = get_url_in_content($content);
    $link = $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
    return '<a href="' . $link . '">' . $link . '</a>';
}
开发者ID:NallelyFlores89,项目名称:cronica-ambiental,代码行数:7,代码来源:post-grid-functions.php

示例2: chunk_url_grabber

 /**
  * Return the URL for the first link found in this post.
  *
  * @param string the_content Post content, falls back to current post content if empty.
  * @return string URL or empty string when no link is present.
  */
 function chunk_url_grabber($the_content = '')
 {
     if (empty($the_content)) {
         $the_content = make_clickable(get_the_content());
     }
     if (function_exists('get_url_in_content')) {
         return get_url_in_content($the_content);
     }
     if (preg_match('/<a\\s[^>]*?href=([\'"])(.+?)\\1/is', $the_content, $matches)) {
         return esc_url_raw($matches[1]);
     }
     return '';
 }
开发者ID:jun200,项目名称:wordpress,代码行数:19,代码来源:content-grabbers.php

示例3: simple_boostrap_the_link_url

function simple_boostrap_the_link_url()
{
    $has_url = get_url_in_content(get_the_content());
    echo $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
}
开发者ID:publicdisplay,项目名称:wordpress-simple-bootstrap-panopticdev,代码行数:5,代码来源:functions.php

示例4: metro_creativex_link_post_format

/**
 * Returns the URL from the post.
 */
function metro_creativex_link_post_format()
{
    $content = get_the_content();
    $has_url = get_url_in_content($content);
    return $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:9,代码来源:functions.php

示例5: flat_responsive_get_link_url

/**
 * Return the post URL.
 *
 * @uses get_url_in_content() to get the URL in the post meta (if it exists) or
 * the first link found in the post content.
 *
 * Falls back to the post permalink if no URL is found in the post.
 *
 */
function flat_responsive_get_link_url()
{
    $content = get_the_content();
    $has_url = get_url_in_content($content);
    return $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
}
开发者ID:un1coin,项目名称:ovn-space,代码行数:15,代码来源:template-tags.php

示例6: mr_tailor_get_link_url

function mr_tailor_get_link_url()
{
    $content = get_the_content();
    $has_url = get_url_in_content($content);
    return $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
}
开发者ID:radscheit,项目名称:unicorn,代码行数:6,代码来源:post-meta.php

示例7: et_get_link_url

 function et_get_link_url()
 {
     if ('' !== ($link_url = get_post_meta(get_the_ID(), '_format_link_url', true))) {
         return $link_url;
     }
     $content = get_the_content();
     $has_url = get_url_in_content($content);
     return $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
 }
开发者ID:ahmedghazi,项目名称:tpls,代码行数:9,代码来源:functions.php

示例8: bootstrapBasicGetLinkInContent

 /**
  * get the link in content
  * 
  * @return string
  */
 function bootstrapBasicGetLinkInContent()
 {
     $content = get_the_content();
     $has_url = get_url_in_content($content);
     if ($has_url) {
         return $has_url;
     } else {
         return apply_filters('the_permalink', get_permalink());
     }
 }
开发者ID:breonwilliams,项目名称:rainbowme-theme,代码行数:15,代码来源:template-tags.php

示例9: edin_get_link_url

/**
 * Returns the URL from the post.
 *
 * @uses get_the_link() to get the URL in the post meta (if it exists) or
 * the first link found in the post content.
 *
 * Falls back to the post permalink if no URL is found in the post.
 *
 * @return string URL
 */
function edin_get_link_url()
{
    $content = get_the_content();
    $has_url = get_url_in_content($content);
    return $has_url && has_post_format('link') ? $has_url : apply_filters('the_permalink', get_permalink());
}
开发者ID:JuriShimizu,项目名称:wp-theme-animal-hospital,代码行数:16,代码来源:extras.php

示例10: direitoacidade_get_link_url

/**
 * Return the post URL.
 * @uses get_url_in_content() to get the URL in the post meta (if it exists) or
 * the first link found in the post content.
 * Falls back to the post permalink if no URL is found in the post.
 * @since Twenty Thirteen 1.0
 * @return string The Link format URL.
 */
function direitoacidade_get_link_url()
{
    $content = get_the_content();
    $has_url = get_url_in_content($content);
    return $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
}
开发者ID:brasadesign,项目名称:direitoacidade,代码行数:14,代码来源:functions.php

示例11: zn_get_link_url

 function zn_get_link_url($current_post)
 {
     $has_url = get_url_in_content($current_post['content']);
     return $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
 }
开发者ID:fjbeteiligung,项目名称:development,代码行数:5,代码来源:functions.php

示例12: get_url_in_content

<?php

/**
 * @package firmasite
 */
global $firmasite_settings, $post;
$has_url = get_url_in_content(get_the_content());
?>

<article id="post-<?php 
the_ID();
?>
" <?php 
post_class("loop_list format_link");
?>
>
 <div class="panel panel-default">
   <div class="panel-body clearfix">
	<?php 
if (has_post_thumbnail()) {
    ?>
	<div class="entry-thumbnail col-xs-4 col-md-4 pull-left fs-content-thumbnail">
      <?php 
    the_post_thumbnail('medium');
    ?>
	</div>
	<?php 
}
?>
    <div class="fs-have-thumbnail">
		<?php 
开发者ID:bonnbonito,项目名称:adkins-theme,代码行数:31,代码来源:loop-link.php

示例13: test_get_url_in_content

    /**
     * @ticket 23570
     */
    function test_get_url_in_content()
    {
        $link = 'http://nytimes.com';
        $commentary = 'This is my favorite link';
        $link_with_commentary = <<<DATA
{$link}

{$commentary}
DATA;
        $href = '<a href="http://nytimes.com">NYT</a>';
        $href_with_commentary = <<<DATA
{$href}

{$commentary}
DATA;
        $link_post_id = $this->factory->post->create(array('post_content' => $link));
        $content_link = get_url_in_content(get_post_field('post_content', $link_post_id));
        $this->assertEquals(false, $content_link);
        $link_with_post_id = $this->factory->post->create(array('post_content' => $link_with_commentary));
        $content_link = get_url_in_content(get_post_field('post_content', $link_with_post_id));
        $this->assertEquals(false, $content_link);
        $content_link = get_url_in_content(get_post_field('post_content', $link_post_id));
        $this->assertEquals(false, $content_link);
        $content_link = get_url_in_content(get_post_field('post_content', $link_with_post_id));
        $this->assertEquals(false, $content_link);
        $empty_post_id = $this->factory->post->create(array('post_content' => ''));
        $content_link = get_url_in_content(get_post_field('post_content', $empty_post_id));
        $this->assertEquals(false, $content_link);
        $comm_post_id = $this->factory->post->create(array('post_content' => $commentary));
        $content_link = get_url_in_content(get_post_field('post_content', $comm_post_id));
        $this->assertEquals(false, $content_link);
        // Now with an href
        $href_post_id = $this->factory->post->create(array('post_content' => $href));
        $content_link = get_url_in_content(get_post_field('post_content', $href_post_id));
        $this->assertEquals($link, $content_link);
        $href_with_post_id = $this->factory->post->create(array('post_content' => $href_with_commentary));
        $content_link = get_url_in_content(get_post_field('post_content', $href_with_post_id));
        $this->assertEquals($link, $content_link);
        $content_link = get_url_in_content(get_post_field('post_content', $href_post_id));
        $this->assertEquals($link, $content_link);
        $content_link = get_url_in_content(get_post_field('post_content', $href_with_post_id));
        $this->assertEquals($link, $content_link);
        $empty_post_id = $this->factory->post->create(array('post_content' => ''));
        $content_link = get_url_in_content(get_post_field('post_content', $empty_post_id));
        $this->assertEquals(false, $content_link);
        $comm_post_id = $this->factory->post->create(array('post_content' => $commentary));
        $content_link = get_url_in_content(get_post_field('post_content', $comm_post_id));
        $this->assertEquals(false, $content_link);
    }
开发者ID:boonebgorges,项目名称:wp,代码行数:52,代码来源:formats.php

示例14: laborator_extract_post_content

function laborator_extract_post_content($type, $replace_original = false, $meta = array())
{
    global $post, $post_title, $post_excerpt, $post_content, $blog_post_formats;
    $content = array('content' => '', 'data' => array());
    if (!($post && $blog_post_formats)) {
        return $content;
    }
    //$post_content = apply_filters('the_content', $post->post_content); # Currently Removed
    switch ($type) {
        case 'quote':
            if (preg_match("/^\\s*<blockquote.*?>(.*?)<\\/blockquote>/s", $post_content, $matches)) {
                $blockquote = lab_esc_script(wpautop($matches[1]));
                // Replace Original Content
                if ($replace_original) {
                    $post_excerpt = laborator_get_excerpt(str_replace($matches[0], '', $post_content));
                    $post_content = str_replace($matches[0], '', $post_content);
                }
                if (preg_match("/(<br.*?>\\s*)?<cite>(.*?)<\\/cite>/s", $blockquote, $blockquote_matches)) {
                    $cite = $blockquote_matches[2];
                    $blockquote = str_replace($blockquote_matches[0], '', $blockquote);
                    // Add attributes
                    $content['data']['cite'] = $cite;
                }
                // Set content
                $content['content'] = $blockquote;
            } else {
                $post_content_lines = explode(PHP_EOL, $post_content);
                $blockquote = reset($post_content_lines);
                $content['content'] = $blockquote;
                // Replace Original Content
                if ($replace_original) {
                    $post_content = str_replace($blockquote, '', $post_content);
                    $post_excerpt = laborator_get_excerpt($post_content);
                }
            }
            break;
        case 'image':
            if (preg_match("/<img(.*?)>/s", $post_content, $matches)) {
                $image_args = wp_parse_args(str_replace(" ", "&", $matches[1]));
                if (isset($image_args['src'])) {
                    $src = trim($image_args['src'], "\"'");
                    $content['content'] = $src;
                }
                // Is inside a href
                $img = $matches[0];
                if (preg_match("/((<a.*?>)(.*)?(<img.*?>)(.*)?<\\/a>)/s", $post_content, $a_matches)) {
                    if ($a_matches[4] == $img) {
                        $a_args = wp_parse_args(trim(str_replace(array('<a', '>'), array('', '', '&'), $a_matches[2])));
                        if (isset($a_args['href'])) {
                            $a_href = trim($a_args['href'], "\"'");
                            $content['data']['href'] = $a_href;
                        }
                    }
                }
                if ($replace_original) {
                    $what_to_replace = $matches[0];
                    if (isset($content['data']['href'])) {
                        $what_to_replace = $a_matches[0];
                    }
                    $post_content = str_replace(array($matches[0], '<p></p>'), '', $post_content);
                }
            } else {
                $post_content_lines = explode(PHP_EOL, $post_content);
                $first_line = strip_tags(trim(reset($post_content_lines)));
                if (preg_match("/https?:\\/\\/.*/s", $first_line, $matches)) {
                    $content['content'] = $matches[0];
                }
                if ($replace_original && count($matches)) {
                    $post_content = str_replace($first_line, '', $post_content);
                    $post_excerpt = laborator_get_excerpt($post_content);
                }
            }
            break;
        case 'link':
            $has_url = get_url_in_content(get_the_content());
            $has_url = $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
            $content['content'] = $has_url;
            break;
        case 'video':
            switch (get_data('blog_post_formats_video_player_skin')) {
                case '_2':
                    $player_skin = 'vjs-sublime-skin';
                    break;
                case '_1':
                default:
                    $player_skin = 'vjs-default-skin';
                    break;
            }
            if (preg_match("/\\[video.*?\\[\\/video\\]/s", $post->post_content, $matches)) {
                $videojs_atts = "data-setup=\"{}\" preload=\"auto\"";
                if (isset($meta['poster'])) {
                    $videojs_atts .= ' poster="' . $meta['poster'] . '"';
                }
                $video_shortcode = do_shortcode($matches[0]);
                $video_shortcode = preg_replace(array('/<div.*?>.*?(<video.*?<\\/video>).*?<\\/div.*?>/s', '/(width|height)=".*?"\\s?/'), array('\\1', ''), $video_shortcode);
                $video_shortcode = str_replace(array('wp-video-shortcode', '<video'), array('video-js ' . $player_skin, '<video ' . $videojs_atts), $video_shortcode);
                $content['content'] = $video_shortcode;
                $content['data']['type'] = 'native';
                if ($replace_original && count($matches)) {
                    $post_content = str_replace($matches[0], '', $post->post_content);
//.........这里部分代码省略.........
开发者ID:adrienlementheour,项目名称:AliceRouat,代码行数:101,代码来源:laborator_functions.php

示例15: test_get_url_in_content

 /**
  * Validate the get_url_in_content function
  * @dataProvider get_input_output
  */
 function test_get_url_in_content($in_str, $exp_str)
 {
     $this->assertEquals($exp_str, get_url_in_content($in_str));
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:8,代码来源:GetUrlInContent.php


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