• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_url_in_content函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: 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 3.1.0
  * @todo wp_extract_urls()
  *
  * @param int|WP_Post $post Optional. Post ID or object. Defaults to the current post.
  * @return string     The Link format URL.
  */
 public function get_link_url($post = 0)
 {
     $post = get_post($post);
     $has_url = get_url_in_content($post->post_content);
     return $has_url ? $has_url : apply_filters('the_permalink', get_permalink($post->ID));
 }
开发者ID:TyRichards,项目名称:ty_the_band,代码行数:20,代码来源:class-cedaro-theme-postmedia.php


示例17: get_the_content

		<?php 
}
?>

		<div class="wc-shortcodes-post-content">
			<?php 
if ($atts['title']) {
    ?>
			<div class="wc-shortcodes-entry-header">
				<<?php 
    echo $atts['heading_type'];
    ?>
 class="wc-shortcodes-entry-title">
					<?php 
    $content = get_the_content();
    $has_url = get_url_in_content($content);
    $link = $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
    ?>
					<a href="<?php 
    echo esc_url($link);
    ?>
"><?php 
    the_title();
    ?>
</a>
				</<?php 
    echo $atts['heading_type'];
    ?>
>
			</div><!-- .entry-header -->
			<?php 
开发者ID:Arkon13,项目名称:magazin2,代码行数:31,代码来源:content-link.php


示例18: avia_link_content_filter

 function avia_link_content_filter($current_post)
 {
     //retrieve the link for the post
     $link = "";
     $newlink = false;
     $pattern1 = '$^\\b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]$i';
     $pattern2 = "!^\\<a.+?<\\/a>!";
     $pattern3 = "!\\<a.+?<\\/a>!";
     //if the url is at the begnning of the content extract it
     preg_match($pattern1, $current_post['content'], $link);
     if (!empty($link[0])) {
         $link = $link[0];
         $markup = avia_markup_helper(array('context' => 'entry_title', 'echo' => false));
         $current_post['title'] = "<a href='{$link}' rel='bookmark' title='" . __('Link to:', 'avia_framework') . " " . the_title_attribute('echo=0') . "' {$markup}>" . get_the_title() . "</a>";
         $current_post['content'] = preg_replace("!" . str_replace("?", "\\?", $link) . "!", "", $current_post['content'], 1);
     } else {
         preg_match($pattern2, $current_post['content'], $link);
         if (!empty($link[0])) {
             $link = $link[0];
             $current_post['title'] = $link;
             $current_post['content'] = preg_replace("!" . str_replace("?", "\\?", $link) . "!", "", $current_post['content'], 1);
             $newlink = get_url_in_content($link);
         } else {
             preg_match($pattern3, $current_post['content'], $link);
             if (!empty($link[0])) {
                 $current_post['title'] = $link[0];
                 $newlink = get_url_in_content($link[0]);
             }
         }
     }
     if ($link) {
         if (is_array($link)) {
             $link = $link[0];
         }
         if ($newlink) {
             $link = $newlink;
         }
         $heading = is_singular() ? "h1" : "h2";
         //$current_post['title'] = "<{$heading} class='post-title entry-title ". avia_offset_class('meta', false). "'>".$current_post['title']."</{$heading}>";
         $current_post['title'] = "<{$heading} class='post-title entry-title' " . avia_markup_helper(array('context' => 'entry_title', 'echo' => false)) . ">" . $current_post['title'] . "</{$heading}>";
         //needs to be set for masonry
         $current_post['url'] = $link;
     } else {
         $current_post = avia_default_title_filter($current_post);
     }
     return $current_post;
 }
开发者ID:erikdukker,项目名称:medisom,代码行数:47,代码来源:helper-post-format.php


示例19: tec_get_link_url

 /**
  * Return the post URL.
  *
  * Falls back to the post permalink if no URL is found in the post.
  *
  * @since tec 1.0
  *
  * @see get_url_in_content()
  *
  * @return string The Link format URL.
  */
 function tec_get_link_url()
 {
     $has_url = get_url_in_content(get_the_content());
     return $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
 }
开发者ID:train147369,项目名称:tec,代码行数:16,代码来源:template-tags.php


示例20: twentyeleven_get_first_url

/**
 * Return the first link from the post content. If none found, the
 * post permalink is used as a fallback.
 *
 * @since Twenty Eleven 1.0
 *
 * @uses get_url_in_content() to get the first URL from the post content.
 *
 * @return string The first link.
 */
function twentyeleven_get_first_url()
{
    $content = get_the_content();
    $has_url = function_exists('get_url_in_content') ? get_url_in_content($content) : false;
    if (!$has_url) {
        $has_url = twentyeleven_url_grabber();
    }
    //duplicate_hook
    return $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
}
开发者ID:openify,项目名称:wordpress-composer,代码行数:20,代码来源:functions.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_urlkey函数代码示例发布时间:2022-05-15
下一篇:
PHP get_url_image_siswa函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap