Пример #1
0
    function sf_chat_post($postID)
    {
        $chat = "";
        if (function_exists('get_the_post_format_chat')) {
            $chat = '<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']));
                    }
                    $chat .= 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']);
                }
            }
            $chat .= '</dl><!-- .chat -->';
        }
        return $chat;
    }
Пример #2
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;
    }