本文整理汇总了PHP中get_comments_number_text函数的典型用法代码示例。如果您正苦于以下问题:PHP get_comments_number_text函数的具体用法?PHP get_comments_number_text怎么用?PHP get_comments_number_text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_comments_number_text函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_get_comments_number_text_declension_with_custom_args
/**
* @ticket 13651
* @dataProvider data_get_comments_number_text_declension
*/
function test_get_comments_number_text_declension_with_custom_args($number, $input, $output)
{
$post_id = $this->factory->post->create();
$permalink = get_permalink($post_id);
$this->factory->comment->create_post_comments($post_id, $number);
$this->go_to($permalink);
add_filter('gettext_with_context', array($this, '_enable_comment_number_declension'), 10, 4);
$this->assertEquals($output, get_comments_number_text(false, false, $input));
remove_filter('gettext_with_context', array($this, '_enable_comment_number_declension'), 10, 4);
}
示例2: comments_link
function comments_link($zero = false, $one = false, $more = false, $class = '', $none = false)
{
// Default values lifted from WordPress core
if (false === $zero) {
$zero = esc_html__('No Comments', 'ubik');
}
if (false === $one) {
$one = esc_html__('1 Comment', 'ubik');
}
if (false === $more) {
$more = esc_html__('% Comments', 'ubik');
}
if (false === $none) {
$none = esc_html__('Comments Off', 'ubik');
}
// Setup everything we need using WordPress core functions where appropriate
$id = get_the_ID();
$number = get_comments_number($id);
$href = get_comments_link($id);
$text = get_comments_number_text($zero, $one, $more);
// Custom class handling; automatically add a `comments-link` class but allow for themes to override this
$class = apply_filters('ubik_comments_link_class', trim('comments-link ' . $class));
// Password-protected content
if (post_password_required()) {
if (option('comments_link_protected')) {
$href = '';
// The link will be displayed with all relevant information but no interaction will be possible
$class .= ' disabled';
} else {
return;
// No link will be displayed
}
}
// No comments found
if ($number == 0) {
// Comments and pingbacks are closed AND there aren't any comments
if (!comments_open() && !pings_open()) {
if (option('comments_link_show_none')) {
$text = $none;
// Switch the text to show "Comments Off"
$href = '';
// Disable the link (otherwise we'd be linking to content that doesn't exist)
$class .= ' disabled';
} else {
return;
// No button will be displayed
}
} else {
$href = get_permalink() . '#respond';
// Link to the response form, not the comments area as a whole
}
}
// Assemble the comments link markup
return sprintf('<a%s%s>%s</a>', $href ? sprintf(' href="%s"', esc_url($href)) : '', $class ? sprintf(' class="%s"', esc_attr($class)) : '', apply_filters('ubik_comments_link_text', $text));
}
示例3: enlightenment_comments_number
function enlightenment_comments_number($args = null)
{
$defaults = array('container' => 'h3', 'container_class' => 'comments-title', 'container_id' => '', 'format' => __('%1$s for “%2$s”', 'enlightenment'), 'zero' => __('No Comments', 'enlightenment'), 'one' => __('1 Comment', 'enlightenment'), 'more' => __('% Comments', 'enlightenment'), 'echo' => true);
$defaults = apply_filters('enlightenment_comments_number_args', $defaults);
$args = wp_parse_args($args, $defaults);
$comments_number = get_comments_number_text($args['zero'], $args['one'], $args['more']);
$output = enlightenment_open_tag($args['container'], $args['container_class'], $args['container_id']);
$output .= sprintf($args['format'], $comments_number, get_the_title());
$output .= enlightenment_close_tag($args['container']);
$output = apply_filters('enlightenment_comments_number', $output, $args);
if (!$args['echo']) {
return $output;
}
echo $output;
}
示例4: screenr_posted_on
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function screenr_posted_on($echo = true)
{
$html = $posted_on = $byline = $cat = $comment = '';
if (get_theme_mod('show_post_date', 1)) {
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
$time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date()));
$posted_on = '<a href="' . esc_url(get_permalink()) . '" rel="bookmark">' . $time_string . '</a>';
}
// show_post_author
if (get_theme_mod('show_post_author', 1)) {
$byline = sprintf(esc_html_x('Author: %s', 'post author', 'screenr'), '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>');
}
if (get_theme_mod('show_post_cate', 1)) {
$category = get_the_category();
if ($category[0]) {
$cat = sprintf(esc_html_x('Category: %s', 'category', 'screenr'), '<a href="' . esc_url(get_category_link($category[0]->term_id)) . '">' . $category[0]->cat_name . '</a>');
}
}
if (get_post_meta('show_post_comment', 1)) {
if (!post_password_required() && (comments_open() || get_comments_number())) {
$comment .= '<span class="comments-link">';
$comment .= '<i class="fa fa-comments-o"></i> ';
$comment .= get_comments_number_text(0, 1, '%');
$comment .= '</span>';
}
}
if ($posted_on != '') {
$html .= '<span class="posted-on"><i aria-hidden="true" class="fa fa-clock-o"></i> ' . $posted_on . '</span>';
}
if ($byline) {
$html .= '<span class="byline"> ' . $byline . '</span> ';
}
if ($cat) {
$html .= '<span class="meta-cate">' . $cat . '</span>';
}
if ($comment) {
$html .= $comment;
}
if ($echo) {
echo $html;
}
return $html;
}
示例5: waves_get_comments_popup_link
function waves_get_comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false)
{
global $wpcommentspopupfile, $wpcommentsjavascript;
$id = get_the_ID();
$title = get_the_title();
$number = get_comments_number($id);
if (false === $zero) {
/* translators: %s: post title */
$zero = sprintf(__('No Comments<span class="screen-reader-text"> on %s</span>', 'waves'), $title);
}
if (false === $one) {
/* translators: %s: post title */
$one = sprintf(__('1 Comment<span class="screen-reader-text"> on %s</span>', 'waves'), $title);
}
if (false === $more) {
/* translators: 1: Number of comments 2: post title */
$more = _n('%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number, 'waves');
$more = sprintf($more, number_format_i18n($number), $title);
}
if (false === $none) {
/* translators: %s: post title */
$none = sprintf(__('Comments Off<span class="screen-reader-text"> on %s</span>', 'waves'), $title);
}
if (0 == $number && !comments_open() && !pings_open()) {
return '<span' . (!empty($css_class) ? ' class="' . esc_attr($css_class) . '"' : '') . '>' . $none . '</span>';
}
if (post_password_required()) {
return __('Enter your password to view comments.', 'waves');
}
$link_anchor = '<a href="';
if ($wpcommentsjavascript) {
if (empty($wpcommentspopupfile)) {
$home = home_url();
} else {
$home = get_option('siteurl');
}
$link_anchor .= $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
$link_anchor .= '" onclick="wpopen(this.href); return false"';
} else {
if (0 == $number) {
$link_anchor .= get_permalink() . '#respond';
} else {
$link_anchor .= get_comments_link();
}
$link_anchor .= '"';
}
if (!empty($css_class)) {
$link_anchor .= ' class="' . $css_class . '" ';
}
$attributes = '';
$link_anchor .= apply_filters('comments_popup_link_attributes', $attributes);
$link_anchor .= '>';
$link_anchor .= get_comments_number_text($zero, $one, $more);
$link_anchor .= '</a>';
return $link_anchor;
}
示例6: comments_number
/**
* Display the language string for the number of comments the current post has.
*
* @since 0.71
*
* @param string $zero Optional. Text for no comments. Default false.
* @param string $one Optional. Text for one comment. Default false.
* @param string $more Optional. Text for more than one comment. Default false.
* @param string $deprecated Not used.
*/
function comments_number($zero = false, $one = false, $more = false, $deprecated = '')
{
if (!empty($deprecated)) {
_deprecated_argument(__FUNCTION__, '1.3');
}
echo get_comments_number_text($zero, $one, $more);
}
示例7: get_post_details
function get_post_details($class = '', $type = 'posts')
{
$comments_in_author = YSettings::g($type . '_show_author', 1) == 1 && YSettings::g($type . '_show_cat', 1) == 1;
$content = '<ul class="post_details ' . $class . '">';
if (is_sticky() && is_home() && !is_paged()) {
$content .= '<li><span class="highlight highlight-color"><i class="icon-pin"></i> <strong>' . __('Sticky', THEME_NAME) . '</strong></span></li>';
}
if (YSettings::g($type . '_show_author', 1) == 1) {
$content .= '<li><span>' . __('by', THEME_NAME) . '</span> <a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_the_author() . '</a> ';
if ($comments_in_author) {
$categories = '';
foreach (get_the_category() as $category) {
$categories .= '<li><a href="' . esc_url(get_category_link($category->term_id)) . '" title="' . $category->name . '">' . $category->name . '</a></li>';
}
$content .= '<span>' . __('in', THEME_NAME) . '</span> <ul>' . $categories . '</ul>';
}
$content .= '</li>';
}
if (!$comments_in_author) {
if (YSettings::g($type . '_show_cat', 1) == 1) {
$categories = '';
foreach (get_the_category() as $category) {
$categories .= '<li><a href="' . esc_url(get_category_link($category->term_id)) . '" title="' . $category->name . '">' . $category->name . '</a></li>';
}
$content .= '<li><ul>' . $categories . '</ul></li>';
}
}
if (YSettings::g($type . '_show_comments', 1) == 1) {
$content .= '<li><a href="' . esc_url(get_comments_link()) . '" title="">' . get_comments_number_text() . '</a></li>';
}
$content .= '</ul>';
return $content;
}
示例8: get_the_date
if ($show_date) {
?>
<div class="rpwwt-post-date"><?php
echo get_the_date();
?>
</div><?php
}
if ($show_excerpt) {
?>
<div class="rpwwt-post-excerpt"><?php
echo $this->get_the_trimmed_excerpt($excerpt_length, $excerpt_more);
?>
</div><?php
}
if ($show_comments_number) {
?>
<div class="rpwwt-post-comments-number"><?php
echo get_comments_number_text();
?>
</div><?php
}
?>
</li>
<?php
}
?>
</ul>
<?php
echo $after_widget;
?>
</div>
示例9: getCommentsNumberText
public function getCommentsNumberText($zero = false, $one = false, $more = false)
{
return get_comments_number_text($zero, $one, $more);
}
示例10: get_comments_popup_link
function get_comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false)
{
global $wpcommentspopupfile, $wpcommentsjavascript;
$id = get_the_ID();
$title = get_the_title();
$number = get_comments_number($id);
if (false === $zero) {
/* translators: %s: post title */
$zero = sprintf(__('No Comments<span class="screen-reader-text"> on %s</span>'), $title);
}
if (false === $one) {
/* translators: %s: post title */
$one = sprintf(__('1 Comment<span class="screen-reader-text"> on %s</span>'), $title);
}
if (false === $more) {
/* translators: 1: Number of comments 2: post title */
$more = _n('%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number);
$more = sprintf($more, number_format_i18n($number), $title);
}
if (false === $none) {
/* translators: %s: post title */
$none = sprintf(__('Comments Off<span class="screen-reader-text"> on %s</span>'), $title);
}
$out = '';
if (0 == $number && !comments_open() && !pings_open()) {
$out .= '<span' . (!empty($css_class) ? ' class="' . esc_attr($css_class) . '"' : '') . '>' . $none . '</span>';
return;
}
if (post_password_required()) {
_e('Enter your password to view comments.');
return;
}
$out .= '<a href="';
if ($wpcommentsjavascript) {
if (empty($wpcommentspopupfile)) {
$home = home_url();
} else {
$home = get_option('siteurl');
}
$out .= $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
$out .= '" onclick="wpopen(this.href); return false"';
} else {
// if comments_popup_script() is not in the template, display simple comment link
if (0 == $number) {
$respond_link = get_permalink() . '#respond';
/**
* Filter the respond link when a post has no comments.
*
* @since 4.4.0
*
* @param string $respond_link The default response link.
* @param integer $id The post ID.
*/
$out .= apply_filters('respond_link', $respond_link, $id);
} else {
$out .= get_comments_link();
}
$out .= '"';
}
if (!empty($css_class)) {
$out .= ' class="' . $css_class . '" ';
}
$attributes = '';
/**
* Filter the comments popup link attributes for display.
*
* @since 2.5.0
*
* @param string $attributes The comments popup link attributes. Default empty.
*/
echo apply_filters('comments_popup_link_attributes', $attributes);
$out .= '>';
$out .= get_comments_number_text($zero, $one, $more);
$out .= '</a>';
return $out;
}
示例11: get_comments_number_text
<?php
if (post_password_required()) {
return;
}
?>
<div id="comments" class="comments-area">
<?php
if (have_comments()) {
?>
<h3 class="title comment-title"><?php
echo get_comments_number_text(false, 'Comment (1)', 'Comments (%)');
?>
</h3>
<?php
if (get_comment_pages_count() > 1 && get_option('page_comments')) {
?>
<nav id="comment-nav-above" class="navigation comment-navigation" role="navigation">
<h1 class="screen-reader-text"><?php
_e('Comment navigation', 'mTheme');
?>
</h1>
<div class="nav-previous"><?php
previous_comments_link(__('← Older Comments', 'mTheme'));
?>
</div>
<div class="nav-next"><?php
next_comments_link(__('Newer Comments →', 'mTheme'));
示例12: carelib_get_entry_comments_link
/**
* Produces a formatted link to the current entry comments.
*
* Supported arguments are:
* - after (output after link, default is empty string),
* - before (output before link, default is empty string),
* - hide_if_off (hide link if comments are off, default is 'enabled' (true)),
* - more (text when there is more than 1 comment, use % character as placeholder
* for actual number, default is '% Comments')
* - one (text when there is exactly one comment, default is '1 Comment'),
* - zero (text when there are no comments, default is 'Leave a Comment').
*
* Output passes through "{$GLOBALS['carelib_prefix']}_get_entry_comments_link" filter before returning.
*
* @since 1.0.0
* @param array $args Empty array if no arguments.
* @return string output
*/
function carelib_get_entry_comments_link($args = array())
{
$defaults = apply_filters("{$GLOBALS['carelib_prefix']}_entry_comments_link_defaults", array('hide_if_off' => 'enabled', 'attr' => 'entry-comments-link', 'more' => __('% Comments', 'carelib'), 'one' => __('1 Comment', 'carelib'), 'zero' => __('Leave a Comment', 'carelib'), 'before' => '', 'after' => ''));
$args = wp_parse_args($args, $defaults);
$required = isset($args['hide_if_off'], $args['attr'], $args['more'], $args['one'], $args['zero']);
// Bail if required args have been removed via a filter or comments are closed.
if (!$required || !(comments_open() && 'enabled' === $args['hide_if_off'])) {
return false;
}
$link = get_comments_link();
$text = get_comments_number_text($args['zero'], $args['one'], $args['more']);
$html = '';
$html .= isset($args['before']) ? $args['before'] : '';
$html .= sprintf('<span %s><a rel="nofollow" href="%s">%s</a></span>', carelib_get_attr($args['attr']), $link, $text);
$html .= isset($args['after']) ? $args['after'] : '';
return apply_filters("{$GLOBALS['carelib_prefix']}_entry_comments_link", $html, $link, $text, $args);
}
示例13: vantage_posted_on
/**
* Prints HTML with meta information for the current post-date/time and author.
*
* @since vantage 1.0
*/
function vantage_posted_on()
{
$date_time = '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a><time class="updated" datetime="%5$s">%6$s</time>';
$date_time = sprintf($date_time, esc_url(get_permalink()), esc_attr(get_the_time()), esc_attr(get_the_date('c')), apply_filters('vantage_post_on_date', esc_html(get_the_date())), esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date()));
$author = sprintf('<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>', esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf(__('View all posts by %s', 'vantage'), get_the_author())), get_the_author());
$comments_link = '<span class="comments-link"><a href="' . get_comments_link() . '">' . get_comments_number_text('Leave a comment') . '</a></span>';
$posted_on_parts = array('on' => sprintf(__('Posted on %s', 'vantage'), $date_time), 'by' => sprintf(__('<span class="byline"> by %s</span>', 'vantage'), $author), 'with' => ' | ' . $comments_link);
$posted_on_parts = apply_filters('vantage_post_on_parts', $posted_on_parts);
$posted_on = implode(' ', $posted_on_parts);
echo apply_filters('vantage_posted_on', $posted_on);
}
示例14: cb_byline
function cb_byline($cb_cat = true, $cb_post_id = NULL, $cb_short_comment_line = false, $cb_posts_on = false, $cb_post_views_off = false)
{
if ($cb_post_id == NULL) {
global $post;
$cb_post_id = $post->ID;
}
$cb_meta_onoff = ot_get_option('cb_meta_onoff', 'on');
$cb_byline_author = ot_get_option('cb_byline_author', 'on');
$cb_byline_date = ot_get_option('cb_byline_date', 'on');
$cb_byline_category = ot_get_option('cb_byline_category', 'on');
$cb_byline_comments = ot_get_option('cb_byline_comments', 'on');
$cb_byline_postviews = ot_get_option('cb_byline_postviews', 'off');
$cb_disqus_code = ot_get_option('cb_disqus_shortname', NULL);
$cb_byline = $cb_cat_output = $cb_comments = $cb_post_views = NULL;
$cb_cats = get_the_category($cb_post_id);
if (isset($cb_cats) && $cb_cat == true) {
$cb_cat_output = ' <div class="cb-category cb-byline-element"><i class="fa fa-folder"></i> ';
$i = 1;
foreach ($cb_cats as $category) {
if ($i != 1) {
$cb_cat_output .= ', ';
}
$cb_cat_output .= ' <a href="' . get_category_link($category->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), $category->name)) . '">' . $category->cat_name . '</a>';
$i++;
}
$cb_cat_output .= '</div>';
}
if ($cb_disqus_code == NULL) {
if (get_comments_number($cb_post_id) > 0) {
if ($cb_short_comment_line == true) {
$cb_comments = ' <div class="cb-comments cb-byline-element"><span><i class="fa fa-comment"></i><a href="' . get_comments_link($cb_post_id) . '">' . number_format_i18n(get_comments_number($cb_post_id)) . '</a></span></div>';
} else {
$cb_comment_line = __('Comment', 'cubell');
$cb_comments_line = __('Comments', 'cubell');
$cb_comments = ' <div class="cb-comments cb-byline-element"><span><i class="fa fa-comment"></i><a href="' . get_comments_link($cb_post_id) . '">' . number_format_i18n(get_comments_number($cb_post_id)) . ' ' . get_comments_number_text($cb_comment_line, $cb_comment_line, $cb_comments_line) . '</a></span></div>';
}
}
} else {
$cb_comments = ' <div class="cb-comments cb-byline-element"><span><i class="fa fa-comment"></i><a href="' . get_permalink($cb_post_id) . '#disqus_thread"></a></span></div>';
}
if ($cb_post_views_off == false) {
$cb_post_view_count = cb_get_post_viewcount($cb_post_id);
if ($cb_post_view_count > 0) {
$cb_post_views = '<div class="cb-post-views cb-byline-element"><span><i class="fa fa-eye"></i> ' . $cb_post_view_count . '</span></div>';
}
}
$cb_author = '<div class="cb-author cb-byline-element">';
if (function_exists('coauthors_posts_links')) {
$cb_author .= '<i class="fa fa-user"></i> ' . coauthors_posts_links(null, null, null, null, false);
} else {
$cb_author .= '<i class="fa fa-user"></i> <a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_the_author() . '</a>';
}
$cb_author .= '</div>';
$cb_date = ' <div class="cb-date cb-byline-element"><i class="fa fa-clock-o"></i> <time class="updated" datetime="' . get_the_time('Y-m-d', $cb_post_id) . '">' . date_i18n(get_option('date_format'), strtotime(get_the_time("Y-m-d", $cb_post_id))) . '</time></div>';
if ($cb_byline_date == 'off') {
$cb_date = NULL;
}
if ($cb_byline_author == 'off') {
$cb_author = NULL;
}
if ($cb_byline_category == 'off') {
$cb_cat_output = NULL;
}
if ($cb_byline_comments == 'off') {
$cb_comments = NULL;
}
if ($cb_byline_postviews == 'off') {
$cb_post_views = NULL;
}
if ($cb_meta_onoff == 'on' || $cb_posts_on == true) {
$cb_byline = '<div class="cb-byline">' . $cb_author . $cb_date . $cb_cat_output . $cb_comments . $cb_post_views . '</div>';
}
return $cb_byline;
}
示例15: cb_get_post_meta
function cb_get_post_meta($cb_post_id, $cb_override = NULL)
{
$cb_comments = $cb_views = $cb_cat_output = NULL;
$cb_meta_onoff = ot_get_option('cb_meta_onoff', 'on');
if ($cb_meta_onoff == 'off') {
return;
}
$cb_post_meta_category = ot_get_option('cb_byline_category', 'on');
$cb_post_meta_views = ot_get_option('cb_byline_postviews', 'on');
$cb_post_meta_comments = ot_get_option('cb_byline_comments', 'on');
$cb_disqus_code = ot_get_option('cb_disqus_shortname', NULL);
if ($cb_post_meta_category != 'off') {
$cb_cats = get_the_category($cb_post_id);
if (isset($cb_cats)) {
foreach ($cb_cats as $cb_cat => $cb_val) {
$cb_cat_output .= '<span class="cb-category cb-element"><a href="' . esc_url(get_category_link($cb_val->term_id)) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), $cb_val->name)) . '">' . $cb_val->cat_name . '</a></span>';
}
}
}
if ($cb_post_meta_comments != 'off') {
if ($cb_disqus_code == NULL) {
$cb_comments = '<span class="cb-comments cb-element"><a href="' . get_comments_link($cb_post_id) . '">' . get_comments_number_text(__('0 Comments', 'cubell')) . '</a></span>';
} else {
$cb_comments = '<span class="cb-comments cb-element"><a href="' . get_permalink($cb_post_id) . '#disqus_thread"></a></span>';
}
}
if ($cb_post_meta_views != 'off') {
$cb_view_count = cb_get_post_viewcount($cb_post_id);
if ($cb_view_count != NULL) {
$cb_views = '<span class="cb-views cb-element">' . $cb_view_count . '</span>';
}
}
if ($cb_meta_onoff == 'on' || $cb_override == true) {
return '<div class="cb-post-meta">' . $cb_cat_output . $cb_comments . $cb_views . '</div>';
}
}