本文整理汇总了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>';
}
示例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 '';
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
}
示例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());
}
示例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());
}
示例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());
}
示例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
示例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);
}
示例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);
//.........这里部分代码省略.........
示例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));
}