/**
  * 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 false when no link is present.
  */
 function next_saturday_url_grabber($the_content = '')
 {
     if (empty($the_content)) {
         $the_content = get_the_content();
     }
     $url = get_the_post_format_url();
     if (empty($url)) {
         $url = get_content_url($the_content);
     }
     return esc_url_raw($url);
 }
Beispiel #2
0
function duena_get_link_url()
{
    $has_url = get_the_post_format_url();
    return $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
}
 function sf_link_post($postID)
 {
     $link = "";
     $link_icon = apply_filters('sf_link_icon', '<i class="ss-link"></i>');
     if (function_exists('get_the_post_format_url')) {
         $link = get_the_post_format_url();
         $link = '<a href="' . esc_url($link) . '" target="_blank" class="link-post-link">' . $link_icon . $link . '</a>';
     }
     return $link;
 }
/**
 * Return the first link from the post content. If none found, the
 * post permalink is used as a fallback.
 *
 * @return string
 */
function twentyeleven_get_first_url()
{
    $has_url = function_exists('get_the_post_format_url') ? get_the_post_format_url() : false;
    if (!$has_url) {
        $has_url = twentyeleven_url_grabber();
    }
    return $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
}
/**
 * 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.
 *
 * @since Twenty Thirteen 1.0
 * @return string URL
 */
function twentythirteen_get_link_url()
{
    $has_url = get_the_post_format_url();
    return $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
}
Beispiel #6
0
 /**
  * Captures the HTML code with the featured media based on featured media linking method.
  *
  * @param				array $args
  * @return				string
  */
 function g1_capture_entry_featured_media($args)
 {
     // Prepare arguments
     $defaults = array('size' => '', 'lightbox_group' => '', 'force_placeholder' => true);
     $r = wp_parse_args($args, $defaults);
     /* We need a static counter to generate unique ids for inline lightboxes */
     static $inline_lightbox_counter = 0;
     global $post;
     $url = '';
     $linking = '';
     $holder = '';
     $placeholder = '';
     $out = '';
     // Try to return a placeholder when an entry is password protected
     if (post_password_required($post)) {
         if (!$r['force_placeholder']) {
             return '';
         }
         $out = sprintf('[placeholder icon="lock" size="%s"]', $r['size']);
     } else {
         $post_format = get_post_format($post->ID);
         switch ($post_format) {
             case 'audio':
                 $audio = g1_capture_post_audio($post->ID, $r['size']);
                 $audio = do_shortcode($audio);
                 $js_id = 'g1_var_' . rand();
                 $js = '<script id="' . esc_attr($js_id) . '" class="g1-var">' . 'var ' . $js_id . ' = ' . json_encode(array('html_code' => $audio)) . ';' . '</script>';
                 // Thumbnail image triggers an inline lightbox with the audio player
                 if (has_post_thumbnail($post->ID)) {
                     $thumb = get_the_post_thumbnail($post->ID, $r['size']);
                     // Compose the template
                     $out = '<figure class="entry-featured-media">' . '[frame link="%LINK%"]' . '%THUMB%' . '[/frame]' . $js . '</figure>';
                     // Fill in the template
                     $out = str_replace(array('%LINK%', '%THUMB%'), array('#', $thumb), $out);
                 } else {
                     if ($r['force_placeholder']) {
                         $placeholder = '[placeholder size="' . $r['size'] . '"]';
                     }
                     $out = '<figure class="entry-featured-media">' . $audio . $placeholder . $js . '</figure>';
                 }
                 break;
             case 'image':
                 // Thumbnail image triggers the full version
                 if (has_post_thumbnail($post->ID)) {
                     $thumb = get_the_post_thumbnail($post->ID, $r['size']);
                     $image = get_post_meta($post->ID, '_format_image', true);
                     // @todo get url from $image
                     $url = $image;
                     if (!strlen($url)) {
                         $url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
                         $url = $url[0];
                     }
                     // Compose the template
                     $out = '<figure class="entry-featured-media">' . '[frame link="%LINK%"]' . '%THUMB%' . '[/frame]' . '</figure>';
                     // Fill in the template
                     $out = str_replace(array('%LINK%', '%THUMB%'), array($url, $thumb), $out);
                 }
                 // WP 3.6 post format
                 if (empty($out)) {
                     $image = get_post_meta($post->ID, '_format_image', true);
                     if (!empty($image)) {
                         if (is_html_code($image)) {
                             $out = '<figure class="entry-featured-media">' . $image . '</figure>';
                         } else {
                             $out = '<figure class="entry-featured-media">' . '<img src="' . $image . '" alt="' . $post->post_title . '" />' . '</figure>';
                         }
                     }
                 }
                 // post fromat < WP 3.6
                 if (empty($out)) {
                     // first img tag
                     $img_tag = G1_Post_Format::find_html_tag('img', $post->post_content);
                     // first link tag
                     $url = get_content_url($post->post_content);
                     if (!empty($img_tag)) {
                         $out = '<figure class="entry-featured-media">' . $img_tag . '</figure>';
                     } else {
                         if (!empty($url)) {
                             $out = '<figure class="entry-featured-media">' . '<img src="' . $url . '" alt="' . $post->post_title . '" />' . '</figure>';
                         }
                     }
                 }
                 break;
             case 'gallery':
                 // Thumbnail image triggers the full gallery
                 if (has_post_thumbnail($post->ID)) {
                     $thumb = get_the_post_thumbnail($post->ID, $r['size']);
                     $url = apply_filters('the_permalink', get_permalink($post->ID));
                     $items = g1_get_post_format_gallery($post->ID, 'full');
                     // Compose gallery as a list of links
                     $gallery_data = '';
                     foreach ($items as $item) {
                         $gallery_data .= str_replace(array('%URL%', '%WIDTH%', '%HEIGHT%'), array(esc_url($item['url']), absint($item['width']), absint($item['height'])), '<li><a href="%URL%" data-g1-width="%WIDTH%" data-g1-height="%HEIGHT%"></a></li>');
                     }
                     // Compose the template
                     $out = '<figure class="entry-featured-media">' . '[frame link="%LINK%"]' . '%THUMB%' . '[/frame]' . '<ul class="g1-gallery-data">' . '%GALLERY_DATA%' . '</ul>' . '</figure>';
                     // Fill in the template
                     $out = str_replace(array('%LINK%', '%THUMB%', '%GALLERY_DATA%'), array(esc_url($url), $thumb, $gallery_data), $out);
                 } else {
                     $items = g1_get_post_format_gallery($post->ID, $r['size']);
                     $gallery = '';
                     foreach ($items as $item) {
                         $gallery .= str_replace(array('%URL%', '%WIDTH%', '%HEIGHT%'), array(esc_url($item['url']), absint($item['width']), absint($item['height'])), '<li><img src="%URL%" width="%WIDTH%" height="%HEIGHT%" alt=""/></li>');
                     }
                     // Compose gallery as a list of links
                     $items = g1_get_post_format_gallery($post->ID, 'full');
                     $gallery_data = '';
                     foreach ($items as $item) {
                         $gallery_data .= str_replace(array('%URL%', '%WIDTH%', '%HEIGHT%'), array(esc_url($item['url']), absint($item['width']), absint($item['height'])), '<li><a href="%URL%" data-g1-width="%WIDTH%" data-g1-height="%HEIGHT%"></a></li>');
                     }
                     $out = '<figure class="entry-featured-media">' . '<ul class="g1-gallery-items">' . $gallery . '</ul>' . '<ul class="g1-gallery-data">' . $gallery_data . '</ul>' . '</figure>';
                 }
                 break;
             case 'video':
                 $big_video = g1_capture_post_video($post->ID, 'g1_max');
                 $big_video = do_shortcode($big_video);
                 $js_id = 'g1_var_' . rand();
                 $js = '<script id="' . esc_attr($js_id) . '" class="g1-var">' . 'var ' . $js_id . ' = ' . json_encode(array('html_code' => $big_video)) . ';' . '</script>';
                 // Thumbnail image triggers the video
                 if (has_post_thumbnail($post->ID)) {
                     $thumb = get_the_post_thumbnail($post->ID, $r['size']);
                     // Compose the template
                     $out = '<figure class="entry-featured-media">' . "\n" . '[frame link="%LINK%"]' . '%THUMB%' . '[/frame]' . "\n" . $js . '</figure>';
                     $embed = get_post_meta($post->ID, '_format_video_embed', true);
                     if (false === strpos($embed, 'http://') && false === strpos($embed, 'https://')) {
                         $embed = the_permalink($post->ID);
                     }
                     // Fill in the template
                     $out = str_replace(array('%LINK%', '%THUMB%'), array(esc_url($embed), $thumb), $out);
                 } else {
                     $small_video = g1_capture_post_video($post->ID, $r['size']);
                     $small_video = do_shortcode($small_video);
                     $out = '<figure class="entry-featured-media">' . $small_video . $js . '</figure>';
                 }
                 break;
             case 'link':
                 $linking = 'new-window';
                 // first link tag
                 $url = get_content_url($post->post_content);
             default:
                 if (!has_post_thumbnail($post->ID)) {
                     if (!$r['force_placeholder']) {
                         return '';
                     }
                     $placeholder = sprintf('[placeholder size="%s" icon="post-format"]', $r['size']);
                 } else {
                     $holder = get_the_post_thumbnail($post->ID, $r['size']);
                 }
                 if (empty($url)) {
                     $has_url = get_the_post_format_url($post->ID);
                     $url = $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
                 }
                 // Compose the template
                 $out = '<figure class="entry-featured-media">' . "\n" . '[frame link="%LINK%" linking="%LINKING%"]' . '%HOLDER%' . '%PLACEHOLDER%' . '[/frame]' . "\n" . '</figure>';
                 // Fill in the template
                 $out = str_replace(array('%LINK%', '%LINKING%', '%HOLDER%', '%PLACEHOLDER%'), array($url, $linking, $holder, $placeholder), $out);
                 break;
         }
     }
     // Apply shortcodes
     $out = do_shortcode($out);
     return $out;
 }
/**
 * Attempt to output a URL from a post's content
 *
 * @since 3.6.0
 *.
 */
function the_post_format_url()
{
    echo esc_url(get_the_post_format_url());
}
Beispiel #8
0
 function ishyoboy_get_post_format_url()
 {
     if (function_exists('get_the_post_format_url')) {
         /**
          *   Adding support fo WP >= 3.6.0
          */
         $url = get_the_post_format_url();
         return $url ? $url : apply_filters('the_permalink', get_permalink());
     } else {
         /**
          *   WP <= 3.5.9
          */
         switch (get_post_format()) {
             case 'quote':
                 $url = IshYoMetaBox::get('ishyoboy_post_quote_url');
                 break;
             default:
                 $url = IshYoMetaBox::get('ishyoboy_post_url');
                 break;
         }
         return $url ? $url : apply_filters('the_permalink', get_permalink());
     }
 }
Beispiel #9
0
 /**
  * Returns the URL from the link post format.
  *
  * Falls back to the post permalink if no URL is found in the post.
  *
  * @since  3.3
  * @return string URL
  */
 function standard_get_link_url()
 {
     return get_the_post_format_url() ? get_the_post_format_url() : apply_filters('the_permalink', get_permalink());
 }
Beispiel #10
0
    /**
     * the_post_format_*() alias
     */
    public function format($format, $params = null)
    {
        $output = '';
        $this->setupData();
        $null = null;
        // variable pass by reference
        global $wp_version;
        if (version_compare($wp_version, "3.6beta", ">=")) {
            // wp-includes/post-formats.php:599
            if ($format == 'chat') {
                $output = '<dl class="chat">';
                $stanzas = get_the_post_format_chat();
                foreach ($stanzas as $stanza) {
                    foreach ($stanza as $row) {
                        $time = '';
                        if (!empty($row['time'])) {
                            $time = sprintf('<time class="chat-timestamp">%s</time>', esc_html($row['time']));
                        }
                        $output .= sprintf('<dt class="chat-author chat-author-%1$s vcard">%2$s <cite class="fn">%3$s</cite>: </dt>
								<dd class="chat-text">%4$s</dd>
							', esc_attr(sanitize_title_with_dashes($row['author'])), $time, esc_html($row['author']), $row['message']);
                    }
                }
                $output .= '</dl><!-- .chat -->';
            } elseif ($format == 'video') {
                $output = get_the_post_format_media('video', $null, 1);
            } elseif ($format == 'audio') {
                $output = get_the_post_format_media('audio', $null, 1);
            } elseif ($format == 'image') {
                $output = get_the_post_format_image($params, $null);
            } elseif ($format == 'gallery') {
                $output = get_post_gallery();
            } elseif ($format == 'link') {
                $has_url = get_the_post_format_url();
                return $has_url ? $has_url : apply_filters('the_permalink', get_permalink());
            }
        } else {
            $output = $this->content();
        }
        return $output;
    }