Beispiel #1
0
/**
 * Parse post content for pagination
 *
 * @since 3.6.0
 *
 * @uses paginate_content()
 *
 * @param object $post The post object.
 * @param bool $remaining Whether to parse post formats from the content. Defaults to false.
 * @return array An array of values used for paginating the parsed content.
 */
function wp_parse_post_content($post, $remaining = false)
{
    $numpages = 1;
    if ($remaining) {
        $format = get_post_format($post);
        if ($format && in_array($format, array('image', 'audio', 'video', 'quote'))) {
            // Call get_the_post_format_*() to set $post->split_content
            switch ($format) {
                case 'image':
                    get_the_post_format_image('full', $post);
                    break;
                case 'audio':
                    get_the_post_format_media('audio', $post, 1);
                    break;
                case 'video':
                    get_the_post_format_media('video', $post, 1);
                    break;
                case 'quote':
                    get_the_post_format_quote($post);
                    break;
            }
        }
    }
    if (strpos($post->post_content, '<!--nextpage-->')) {
        $multipage = 1;
        if ($remaining && isset($post->split_content)) {
            $pages = paginate_content($post->split_content);
        } else {
            $pages = paginate_content($post->post_content);
        }
        $numpages = count($pages);
    } else {
        if ($remaining && isset($post->split_content)) {
            $pages = array($post->split_content);
        } else {
            $pages = array($post->post_content);
        }
        $multipage = 0;
    }
    return compact('multipage', 'pages', 'numpages');
}
Beispiel #2
0
 /**
  * Return the first audio file found for a post.
  *
  * @param int $post_id ID for parent post.
  * @return string Path to audio file.
  */
 function pinktouch_audio_grabber($post_id)
 {
     $null = null;
     preg_match('/src=[\'"](.+?)[\'"]/is', get_the_post_format_media('audio', $null, 1), $matches);
     return isset($matches[1]) ? esc_url($matches[1]) : '';
 }
/**
 * Output the first audio  in the current (@global) post's content
 *
 * @since 3.6.0
 *
 */
function the_post_format_audio()
{
    $null = null;
    echo get_the_post_format_media('audio', $null, 1);
}
 function sf_audio_post($postID)
 {
     $audio = "";
     if (function_exists('get_the_post_format_media')) {
         $audio = do_shortcode(get_the_post_format_media('audio', $null, 1));
     }
     return $audio;
 }
/**
 * Set up global post data.
 *
 * @since 1.5.0
 *
 * @param object $post Post data.
 * @uses do_action_ref_array() Calls 'the_post'
 * @return bool True when finished.
 */
function setup_postdata($post)
{
    global $id, $authordata, $currentday, $currentmonth, $page, $pages, $format_pages, $multipage, $more, $numpages;
    $id = (int) $post->ID;
    $authordata = get_userdata($post->post_author);
    $currentday = mysql2date('d.m.y', $post->post_date, false);
    $currentmonth = mysql2date('m', $post->post_date, false);
    $numpages = 1;
    $page = get_query_var('page');
    if (!$page) {
        $page = 1;
    }
    if (is_single() || is_page() || is_feed()) {
        $more = 1;
    }
    $split_content = $content = $post->post_content;
    $format = get_post_format($post);
    if ($format && in_array($format, array('image', 'audio', 'video', 'quote'))) {
        switch ($format) {
            case 'image':
                get_the_post_format_image('full', $post);
                if (isset($post->split_content)) {
                    $split_content = $post->split_content;
                }
                break;
            case 'audio':
                get_the_post_format_media('audio', $post, 1);
                if (isset($post->split_content)) {
                    $split_content = $post->split_content;
                }
                break;
            case 'video':
                get_the_post_format_media('video', $post, 1);
                if (isset($post->split_content)) {
                    $split_content = $post->split_content;
                }
                break;
            case 'quote':
                get_the_post_format_quote($post);
                if (isset($post->split_content)) {
                    $split_content = $post->split_content;
                }
                break;
        }
    }
    if (strpos($content, '<!--nextpage-->')) {
        if ($page > 1) {
            $more = 1;
        }
        $multipage = 1;
        $pages = paginate_content($content);
        $format_pages = paginate_content($split_content);
        $numpages = count($pages);
    } else {
        $pages = array($post->post_content);
        $format_pages = array($split_content);
        $multipage = 0;
    }
    do_action_ref_array('the_post', array(&$post));
    return true;
}
Beispiel #6
0
    function ishyoboy_the_post_video($id)
    {
        global $content_width;
        if (function_exists('get_the_post_format_media')) {
            /**
             *   Adding support fo WP >= 3.6.0
             */
            $video = get_the_post_format_media('video');
            if ('' != $video) {
                echo '<div class="post-video-content">', $video, '</div>';
            }
        } else {
            /**
             *   WP <= 3.5.9
             */
            if ('true' == IshYoMetaBox::get('ishyoboy_post_embedded_video', true, $id)) {
                ?>

            <?php 
                $video = IshYoMetaBox::get('ishyoboy_post_video', true, $id);
                if ('' != $video) {
                    ?>
                <div class="post-video-content">
                    <!-- EMBEDDED VIDEO BEGIN -->
                    <?php 
                    if (substr($video, 0, 4) == "http") {
                        global $wp_embed;
                        echo do_shortcode($wp_embed->run_shortcode('[embed]' . $video . '[/embed]'));
                    } else {
                        echo str_replace('&', '&amp;', $video);
                    }
                    ?>
                    <!-- EMBEDDED VIDEO END -->
                </div>
            <?php 
                } else {
                    ?>
                <div class="main-post-image">
                    <a href="<?php 
                    the_permalink();
                    ?>
">
                        <?php 
                    if (function_exists('has_post_thumbnail') && has_post_thumbnail()) {
                        ?>
                            <?php 
                        echo get_the_post_thumbnail($id, 'theme-large');
                        ?>
                        <?php 
                    }
                    ?>
                    </a>
                </div>
            <?php 
                }
                ?>

        <?php 
            } else {
                ?>

            <?php 
                if ('' != IshYoMetaBox::get('ishyoboy_post_video_mp4', true, $id) || '' != IshYoMetaBox::get('ishyoboy_post_video_webm', true, $id)) {
                    ?>
                <div class="post-video-content">
                    <!-- HTML5 VIDEO BEGIN -->
                    <video class="video-js vjs-default-skin" controls preload="none" width="<?php 
                    echo $content_width;
                    ?>
" <?php 
                    if ('' != IshYoMetaBox::get('ishyoboy_post_video_poster', true, $id)) {
                        echo 'poster="' . IshYoMetaBox::get('ishyoboy_post_video_poster', true, $id) . '"';
                    }
                    ?>
>
                        <?php 
                    if ('' != IshYoMetaBox::get('ishyoboy_post_video_mp4', true, $id)) {
                        echo '<source src="' . IshYoMetaBox::get('ishyoboy_post_video_mp4', true, $id) . '" type="video/mp4"/>';
                    }
                    ?>
                        <?php 
                    if ('' != IshYoMetaBox::get('ishyoboy_post_video_webm', true, $id)) {
                        echo '<source src="' . IshYoMetaBox::get('ishyoboy_post_video_webm', true, $id) . '" type="video/webm"/>';
                    }
                    ?>
                    </video>
                    <!-- HTML5 VIDEO END -->
                </div>
            <?php 
                } else {
                    ?>
                <div class="main-post-image">
                    <a href="<?php 
                    the_permalink();
                    ?>
">
                        <?php 
                    if (function_exists('has_post_thumbnail') && has_post_thumbnail()) {
                        ?>
                            <?php 
                        echo get_the_post_thumbnail($id, 'theme-large');
                        ?>
                        <?php 
                    }
                    ?>
                    </a>
                </div>
            <?php 
                }
                ?>



        <?php 
            }
        }
    }
Beispiel #7
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;
    }