当前位置: 首页>>代码示例>>PHP>>正文


PHP has_post_format函数代码示例

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


在下文中一共展示了has_post_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: tarski_link_pages

/**
 * Passes some Tarski-specific arguments to wp_link_pages.
 *
 * @since 2.0
 *
 * @uses wp_link_pages
 */
function tarski_link_pages()
{
    $arguments = array('before' => '<p class="link-pages"><strong>' . __('Pages:', 'tarski') . '</strong>', 'after' => '</p>', 'next_or_number' => 'number', 'nextpagelink' => __('Next page', 'tarski'), 'previouspagelink' => __('Previous page', 'tarski'), 'pagelink' => '%', 'more_file' => '', 'echo' => true);
    if (!(has_post_format('aside') || in_category(get_tarski_option('asidescategory')))) {
        wp_link_pages($arguments);
    }
}
开发者ID:aleksking,项目名称:sherrill,代码行数:14,代码来源:content_helper.php

示例2: adjust_content_width

function adjust_content_width()
{
    global $content_width;
    if (has_post_format('video')) {
        $content_width = 960;
    }
}
开发者ID:Jocker666z,项目名称:hepouf,代码行数:7,代码来源:extras.php

示例3: matraman_lite_post_type

function matraman_lite_post_type()
{
    if (has_post_format('gallery')) {
        echo '<i class="icon post-type icon-photos-pictures"></i>';
    }
    if (has_post_format('audio')) {
        echo '<i class="icon post-type icon-headphone"></i>';
    }
    if (has_post_format('chat')) {
        echo '<i class="icon post-type icon-chat-talk"></i>';
    }
    if (has_post_format('image')) {
        echo '<i class="icon post-type icon-camera"></i>';
    }
    if (has_post_format('link')) {
        echo '<i class="icon post-type icon-link"></i>';
    }
    if (has_post_format('quote')) {
        echo '<i class="icon post-type icon-quote-left"></i>';
    }
    if (has_post_format('video')) {
        echo '<i class="icon post-type icon-film-maker"></i>';
    }
    if (has_post_format('status')) {
        echo '<i class="icon post-type icon-message-talk"></i>';
    }
    if (!get_post_format() && !is_sticky()) {
        echo '<i class="icon post-type icon-book"></i>';
    }
    if (is_sticky()) {
        echo '<i class="icon post-type icon-pin"></i>';
    }
}
开发者ID:ComEnYns,项目名称:Web-Projects,代码行数:33,代码来源:themeta.php

示例4: thim_post_formats_content

/**
 * Remove images in post content if it has post format 'image'
 *
 * @param string $content
 *
 * @return string
 * @since 1.0
 */
function thim_post_formats_content($content)
{
    if (has_post_format('image')) {
        $content = preg_replace('|<img[^>]*>|i', '', $content);
    }
    if (has_post_format('link')) {
        $url = thim_meta('thim_url');
        $text = thim_meta('thim_text');
        if ($url && $text) {
            $content = '<p><a class="link" href="' . esc_url($url) . '">' . esc_attr($text) . '</a></p>';
        }
    }
    if (has_post_format('quote')) {
        $quote = thim_meta('thim_quote');
        $author = thim_meta('thim_author');
        $author_url = thim_meta('thim_author_url');
        if ($author_url) {
            $author = '<a href="' . esc_url($author_url) . '">' . esc_attr($author) . '</a>';
        }
        if ($quote && $author) {
            $content = "<blockquote>{$quote}<cite>{$author}</cite></blockquote>";
        }
    }
    return $content;
}
开发者ID:vinhnq1211,项目名称:funy,代码行数:33,代码来源:post-formats.php

示例5: post_format_icon

function post_format_icon()
{
    if (has_post_format('gallery')) {
        $icon = 'stack';
    } else {
        if (has_post_format('quote')) {
            $icon = 'quotes-left';
        } else {
            if (has_post_format('video')) {
                $icon = 'play';
            } else {
                if (has_post_format('link')) {
                    $icon = 'link';
                } else {
                    if (has_post_format('audio')) {
                        $icon = 'headphones';
                    } else {
                        if (has_post_format('status')) {
                            $icon = 'twitter';
                        } else {
                            $icon = false;
                        }
                    }
                }
            }
        }
    }
    return $icon;
}
开发者ID:annegrundhoefer,项目名称:courtney,代码行数:29,代码来源:functions.php

示例6: post_format_image_featured

function post_format_image_featured()
{
    if (has_post_format('image') && has_post_thumbnail() && is_singular('post')) {
        $img = genesis_get_image(array('format' => 'html', 'size' => genesis_get_option('image_size'), 'attr' => array('class' => 'post-image')));
        printf('<a href="%s" id="featured-post-image" title="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), $img);
    }
}
开发者ID:MarioGiancini,项目名称:thedbz-theme,代码行数:7,代码来源:functions.php

示例7: widget

    /**
     * Displays the widget content
     *
     * @author	Konstantin Obeland
     * @since	1.1.0 - 08.03.2012
     * @access	public
     *
     * @param	array	$args
     * @param	array	$instance
     *
     * @return	void
     */
    public function widget($args, $instance)
    {
        if (!has_post_format('gallery', $instance['post_id'])) {
            return;
        }
        $attachments = get_children(array('post_parent' => $instance['post_id'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
        if (empty($attachments)) {
            return;
        }
        extract($args);
        echo str_replace('well ', '', $before_widget);
        if ($title = get_the_title($instance['post_id'])) {
            echo $before_title . '<a href="' . get_permalink($instance['post_id']) . '" title="' . sprintf(esc_attr__('Permalink to %s', 'the-bootstrap'), strip_tags($title)) . '" rel="bookmark">' . $title . '</a>' . $after_title;
        }
        ?>
		<div id="sidebar-gallery-slider" class="carousel slide">

			<!-- Carousel items -->
			<div class="carousel-inner">
				<?php 
        foreach ($attachments as $attachment) {
            ?>
				<figure class="item">
					<?php 
            echo wp_get_attachment_image($attachment->ID, array(370, 278));
            if (has_excerpt($attachment->ID)) {
                ?>
					<figcaption class="carousel-caption">
						<h4><?php 
                echo get_the_title($attachment->ID);
                ?>
</h4>
						<p><?php 
                echo apply_filters('get_the_excerpt', $attachment->post_excerpt);
                ?>
</p>
					</figcaption>
					<?php 
            }
            ?>
				</figure>
				<?php 
        }
        ?>
			</div><!-- .carousel-inner -->
		
			<!-- Carousel nav -->
			<a class="carousel-control left" href="#sidebar-gallery-slider" data-slide="prev"><?php 
        _ex('&lsaquo;', 'carousel-control', 'the-bootstrap');
        ?>
</a>
			<a class="carousel-control right" href="#sidebar-gallery-slider" data-slide="next"><?php 
        _ex('&rsaquo;', 'carousel-control', 'the-bootstrap');
        ?>
</a>
		</div><!-- #sidebar-gallery-slider .carousel .slide -->
		<?php 
        echo $after_widget;
    }
开发者ID:Covert-Inferno,项目名称:the-bootstrap,代码行数:71,代码来源:the-bootstrap-gallery-widget.php

示例8: material_design_par_amauri_chat_content

/**
 * This function filters the post content when viewing a post with the "chat" post format.  It formats the 
 * content with structured HTML markup to make it easy for theme developers to style chat posts.  The 
 * advantage of this solution is that it allows for more than two speakers (like most solutions).  You can 
 * have 100s of speakers in your chat post, each with their own, unique classes for styling.
 *
 * @author David Chandra
 * @link http://www.turtlepod.org
 * @author Justin Tadlock
 * @link http://justintadlock.com
 * @copyright Copyright (c) 2012
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * @link http://justintadlock.com/archives/2012/08/21/post-formats-chat
 *
 * @global array $_post_format_chat_ids An array of IDs for the chat rows based on the author.
 * @param string $content The content of the post.
 * @return string $chat_output The formatted content of the post.
 */
function material_design_par_amauri_chat_content($content)
{
    global $_post_format_chat_ids;
    /* If this is not a 'chat' post, return the content. */
    if (!has_post_format('chat')) {
        return $content;
    }
    /* Set the global variable of speaker IDs to a new, empty array for this chat. */
    $_post_format_chat_ids = array();
    $speaker_id_save = 0;
    $pair_save = '';
    /* Allow the separator (separator for speaker/text) to be filtered. */
    $separator = apply_filters('my_post_format_chat_separator', ':');
    /* Open the chat transcript div and give it a unique ID based on the post ID. */
    $chat_output = "\n\t\t\t" . '<div id="chat-transcript-' . esc_attr(get_the_ID()) . '" class="chat-transcript">';
    /* Split the content to get individual chat rows. */
    $chat_rows = preg_split("/(\r?\n)+|(<br\\s*\\/?>\\s*)+/", $content);
    /* Loop through each row and format the output. */
    foreach ($chat_rows as $chat_row) {
        /* If a speaker is found, create a new chat row with speaker and text. */
        if (strpos($chat_row, $separator)) {
            /* Split the chat row into author/text. */
            $chat_row_split = explode($separator, trim($chat_row), 2);
            /* Get the chat author and strip tags. */
            $chat_author = strip_tags(trim($chat_row_split[0]));
            /* Get the chat text. */
            $chat_text = trim($chat_row_split[1]);
            /* Get the chat row ID (based on chat author) to give a specific class to each row for styling. */
            $speaker_id = material_design_par_amauri_chat_row_id($chat_author);
            /* Open the chat row. */
            $pair = 'chat-right';
            if ($speaker_id % 2) {
                $pair = 'chat-left';
            }
            $chat_output .= "\n\t\t\t\t" . '<div class="' . $pair . ' chat-row ' . sanitize_html_class("chat-speak-{$speaker_id}") . '">';
            /* Add the chat row text. */
            $chat_output .= "\n\t\t\t\t\t" . '<div class="chat-text">' . str_replace(array("\r", "\n", "\t"), '', apply_filters('material_design_par_amauri_format_chat_text', $chat_text, $chat_author, $speaker_id)) . '</div>';
            /* Add the chat row author. */
            $chat_output .= '<div class="chat-author ' . sanitize_html_class(strtolower("chat-author-{$chat_author}")) . ' vcard"><cite class="fn">' . apply_filters('my_post_format_chat_author', $chat_author, $speaker_id) . '</cite></div>';
            /* Close the chat row. */
            $chat_output .= '</div><!-- .chat-row --><div class="clear"></div>';
        } else {
            /* Make sure we have text. */
            if (!empty($chat_row)) {
                /* Open the chat row. */
                $chat_output .= "\n\t\t\t\t" . '<div class="chat-row ' . sanitize_html_class("chat-speaker-{$speaker_id}") . '">';
                /* Don't add a chat row author.  The label for the previous row should suffice. */
                /* Add the chat row text. */
                $chat_output .= "\n\t\t\t\t\t" . '<div class="chat-text">' . str_replace(array("\r", "\n", "\t"), '', apply_filters('material_design_par_amauri_format_chat_text', $chat_row, $chat_author, $speaker_id)) . '</div>';
                /* Close the chat row. */
                $chat_output .= "\n\t\t\t</div><!-- .chat-row -->";
            }
        }
    }
    /* Close the chat transcript div. */
    $chat_output .= "\n\t\t\t</div><!-- .chat-transcript -->\n";
    /* Return the chat content and apply filters for developers. */
    return apply_filters('my_post_format_chat_content', $chat_output);
}
开发者ID:henlz,项目名称:WCode-WebSite,代码行数:77,代码来源:chat-transcript.php

示例9: related_posts

function related_posts($count, $type, $post_id)
{
    $out = $categories = $param = '';
    if ($type == 'category') {
        $categories = get_the_category($post_id);
        $param = 'category__in';
    } else {
        $categories = wp_get_post_tags($post_id);
        $param = 'tag__in';
    }
    if ($categories) {
        $category_ids = array();
        foreach ($categories as $individual_category) {
            $category_ids[] = $individual_category->term_id;
        }
        $args = array('post_type' => 'post', $param => $category_ids, 'post__not_in' => array($post_id), 'posts_per_page' => $count, 'ignore_sticky_posts ' => 1);
        $related = new WP_Query($args);
        if ($related->have_posts() && $related->found_posts >= 1) {
            $out .= '<div class="related-posts mts clearfix">';
            $out .= '<div class="element-title"><h3>' . __('Related Articles ', 'corporative') . '</h3></div>';
            $out .= '<ul class="row_inner">';
            $count = 1;
            while ($related->have_posts()) {
                $related->the_post();
                $gallery = $audioURL = $videoURL = $format = '';
                if (get_field('post_gallery')) {
                    $gallery = get_field('post_gallery');
                }
                if (get_field('post_video')) {
                    $videoURL = get_field('post_video');
                }
                if (get_field('post_audio')) {
                    $audioURL = get_field('post_audio');
                }
                if (has_post_format('video')) {
                    $format = 'Video';
                } elseif (has_post_format('audio')) {
                    $format = 'Audio';
                } elseif (has_post_format('gallery')) {
                    $format = 'Gallery';
                } else {
                    $format = 'Standard';
                }
                $out .= '<li class="grid_3 grid_item no_title_thumb">';
                $out .= mediaholder_caption('', $format, 243, 160, 'carousel', $videoURL, $audioURL, $gallery);
                $out .= '<h2 class="post_title"><a href="' . get_permalink() . '" title="">' . get_the_title() . '</a></h2>';
                $out .= '</li>';
                if ($count % 4 == 0) {
                    $out .= '<div class="clear"></div>';
                }
                $count++;
            }
            $out .= '</ul>';
            $out .= '</div>';
        }
    }
    wp_reset_postdata();
    return $out;
}
开发者ID:devmoonshine,项目名称:development,代码行数:59,代码来源:related-posts.php

示例10: ktz_require_videojs

/**
 * Add Js Require For VideoJS
 */
function ktz_require_videojs()
{
    if (is_single() && has_post_format('video')) {
        echo '<script type="text/javascript">';
        echo 'videojs.options.flash.swf = "' . ktz_url . 'includes/assets/video-js/video-js.swf";';
        echo '</script>';
    }
}
开发者ID:jjpango,项目名称:JJTeam,代码行数:11,代码来源:_js_ktz.php

示例11: xinwp_single_post_link

 function xinwp_single_post_link()
 {
     if (!is_single()) {
         if (has_post_format('aside') || has_post_format('quote') || '' == the_title_attribute('echo=0')) {
             printf('<a class="single-post-link" href="%1$s" title="%1$s"><i class="icon-chevron-right"></i></a>', get_permalink(), get_the_title());
         }
     }
 }
开发者ID:jimdough,项目名称:Roadmaster,代码行数:8,代码来源:lib-content.php

示例12: ascetica_disable_sidebars

/**
 * Disables sidebars if viewing a two-column - wide page, or a gallery post.
 *
 */
function ascetica_disable_sidebars($sidebars_widgets)
{
    global $wp_query;
    if (is_page_template('page-template-wide.php') || is_singular() && has_post_format('gallery', get_queried_object_id())) {
        $sidebars_widgets['secondary'] = false;
    }
    return $sidebars_widgets;
}
开发者ID:arturo-mayorga,项目名称:am_com,代码行数:12,代码来源:functions.php

示例13: twentyfourteen_mute_content_filters

/**
 * Removes sharing markup from post content if we're not in the loop and it's a
 * formatted post.
 *
 * @param bool $show Whether to show sharing options.
 * @param WP_Post $post The post to share.
 * @return bool
 */
function twentyfourteen_mute_content_filters($show, $post)
{
    $formats = get_theme_support('post-formats');
    if (!in_the_loop() && has_post_format($formats[0], $post)) {
        $show = false;
    }
    return $show;
}
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:16,代码来源:twentyfourteen.php

示例14: edin_improved_post_thumbnail

/**
   Improve post thumbnails e.g. for use on grid page, by hiding them with CSS
   to reveal an identical background image. This allows realigning of the background
   image easily with CSS property background-position. Requires user to set the
   custom field "image_focus" in each page, as required.
*/
function edin_improved_post_thumbnail()
{
    $postid = get_the_ID();
    if (post_password_required() || is_attachment() || !has_post_thumbnail() || has_post_format()) {
        return;
    }
    $ratio = get_theme_mod('edin_thumbnail_style');
    switch ($ratio) {
        case 'square':
            ?>
<a class="post-thumbnail edin-improved-post-thumbnail edin-improved-post-thumbnail-square" <?php 
            ?>
href="<?php 
            the_permalink();
            ?>
" <?php 
            break;
        default:
            ?>
<a class="post-thumbnail edin-improved-post-thumbnail edin-improved-post-thumbnail-landscape" <?php 
            ?>
href="<?php 
            the_permalink();
            ?>
" <?php 
    }
    ?>
style="background-image: url('<?php 
    $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($postid), 'edin-thumbnail-landscape');
    echo esc_url($thumbnail[0]);
    ?>
');
  background-repeat: no-repeat;
  background-size: cover;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-position: <?php 
    echo get_post_meta($postid, 'image_focus', 1);
    ?>
 ;">
  <img class="edin-improved-post-thumbnail" src="<?php 
    echo esc_url($thumbnail[0]);
    ?>
">
  <?php 
    ?>
</a><?php 
    /*
      FIXME Should detect if image_focus is not sent.
      However, CSS errors fail gracefully.
    */
    /*
      Instead of using the thumbnail image on top of the background image,
      could use a transparent PNG instead:
      <img class="edin-improved-post-thumbnail" src="<?php echo '' . get_stylesheet_directory_uri() . '/transparent.png' ?>">
    */
}
开发者ID:austinjp,项目名称:edin-child-theme,代码行数:64,代码来源:functions.php

示例15: constructent_post_formats_content

/**
 * Remove images in post content if it has post format 'image'
 *
 * @param string $content
 *
 * @return string
 * @since 1.0
 */
function constructent_post_formats_content($content)
{
    if (has_post_format('image')) {
        $content = preg_replace('|<img[^>]*>|i', '', $content);
    }
    if (has_post_format('quote') || has_post_format('link')) {
        $content = '';
    }
    return $content;
}
开发者ID:GTACSolutions,项目名称:Telios,代码行数:18,代码来源:post-formats.php


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