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


PHP bbp_get_time_since函数代码示例

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


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

示例1: test_bbp_update_topic_last_active_time

 /**
  * @covers ::bbp_update_topic_last_active_time
  */
 public function test_bbp_update_topic_last_active_time()
 {
     $f = $this->factory->forum->create();
     $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     $r1 = $this->factory->reply->create(array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     $r1_time_raw = get_post_field('post_date', $r1);
     $r1_time_formatted = bbp_get_time_since(bbp_convert_date($r1_time_raw));
     $time = bbp_update_topic_last_active_time($t, $r1_time_raw);
     $this->assertSame($r1_time_raw, $time);
     $time = bbp_get_topic_last_active_time($t);
     $this->assertSame($r1_time_formatted, $time);
     $r2 = $this->factory->reply->create_many(2, array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     $r2_time_raw = get_post_field('post_date', $r2[1]);
     $r2_time_formatted = bbp_get_time_since(bbp_convert_date($r2_time_raw));
     bbp_update_topic_last_active_time($t);
     $time = bbp_get_topic_last_active_time($t);
     $this->assertSame($r2_time_formatted, $time);
 }
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:21,代码来源:update-last-thing.php

示例2: widget

        function widget($args, $instance)
        {
            extract($args, EXTR_SKIP);
            $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments');
            $title = apply_filters('widget_title', $title, $instance, $this->id_base);
            $number = !empty($instance['number']) ? absint($instance['number']) : 5;
            if (!$number) {
                $number = 5;
            }
            $cb_qry = new WP_Query(array('post_type' => bbp_get_reply_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true));
            echo $before_widget;
            echo $before_title . $title . $after_title;
            ?>
            <ul class="cb-bbp-recent-replies">

                <?php 
            while ($cb_qry->have_posts()) {
                $cb_qry->the_post();
                ?>

                    <li>

                        <?php 
                $cb_reply_id = bbp_get_reply_id($cb_qry->post->ID);
                $cb_reply_url = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($cb_reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($cb_reply_id, 50)) . '">' . bbp_get_reply_topic_title($cb_reply_id) . '</a>';
                $cb_author_avatar = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'avatar', 'size' => 60));
                $cb_author_name = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'name'));
                echo $cb_author_avatar . '<div class="cb-bbp-meta">' . $cb_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_reply_url . '<div class="cb-bbp-recent-replies-time">' . bbp_get_time_since(get_the_time('U')) . '</div></div>';
                ?>

                    </li>

                <?php 
            }
            ?>

            </ul>

        <?php 
            echo $after_widget;
            // Reset the $post global
            wp_reset_postdata();
        }
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:43,代码来源:cb-bbp-recent-replies.php

示例3: bbp_get_topic_last_active_time

/**
 * Return the topics last update date/time (aka freshness)
 *
 * @since 2.0.0 bbPress (r2625)
 *
 * @param int $topic_id Optional. Topic id
 * @uses bbp_get_topic_id() To get topic id
 * @uses get_post_meta() To get the topic lst active meta
 * @uses bbp_get_topic_last_reply_id() To get topic last reply id
 * @uses get_post_field() To get the post date of topic/reply
 * @uses bbp_convert_date() To convert date
 * @uses bbp_get_time_since() To get time in since format
 * @uses apply_filters() Calls 'bbp_get_topic_last_active' with topic
 *                        freshness and topic id
 * @return string Topic freshness
 */
function bbp_get_topic_last_active_time($topic_id = 0)
{
    $topic_id = bbp_get_topic_id($topic_id);
    // Try to get the most accurate freshness time possible
    $last_active = get_post_meta($topic_id, '_bbp_last_active_time', true);
    if (empty($last_active)) {
        $reply_id = bbp_get_topic_last_reply_id($topic_id);
        if (!empty($reply_id)) {
            $last_active = get_post_field('post_date', $reply_id);
        } else {
            $last_active = get_post_field('post_date', $topic_id);
        }
    }
    $last_active = !empty($last_active) ? bbp_get_time_since(bbp_convert_date($last_active)) : '';
    // Return the time since
    return apply_filters('bbp_get_topic_last_active', $last_active, $topic_id);
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:33,代码来源:template.php

示例4: bbp_get_reply_revision_log

/**
 * Return the formatted revision log of the reply
 *
 * @since bbPress (r2782)
 *
 * @param int $reply_id Optional. Reply id
 * @uses bbp_get_reply_id() To get the reply id
 * @uses bbp_get_reply_revisions() To get the reply revisions
 * @uses bbp_get_reply_raw_revision_log() To get the raw revision log
 * @uses bbp_get_reply_author_display_name() To get the reply author
 * @uses bbp_get_reply_author_link() To get the reply author link
 * @uses bbp_convert_date() To convert the date
 * @uses bbp_get_time_since() To get the time in since format
 * @uses apply_filters() Calls 'bbp_get_reply_revision_log' with the
 *                        log and reply id
 * @return string Revision log of the reply
 */
function bbp_get_reply_revision_log($reply_id = 0)
{
    // Create necessary variables
    $reply_id = bbp_get_reply_id($reply_id);
    // Show the topic reply log if this is a topic in a reply loop
    if (bbp_is_topic($reply_id)) {
        return bbp_get_topic_revision_log($reply_id);
    }
    // Get the reply revision log (out of post meta
    $revision_log = bbp_get_reply_raw_revision_log($reply_id);
    // Check reply and revision log exist
    if (empty($reply_id) || empty($revision_log) || !is_array($revision_log)) {
        return false;
    }
    // Get the actual revisions
    $revisions = bbp_get_reply_revisions($reply_id);
    if (empty($revisions)) {
        return false;
    }
    $r = "\n\n" . '<ul id="bbp-reply-revision-log-' . esc_attr($reply_id) . '" class="bbp-reply-revision-log">' . "\n\n";
    // Loop through revisions
    foreach ((array) $revisions as $revision) {
        if (empty($revision_log[$revision->ID])) {
            $author_id = $revision->post_author;
            $reason = '';
        } else {
            $author_id = $revision_log[$revision->ID]['author'];
            $reason = $revision_log[$revision->ID]['reason'];
        }
        $author = bbp_get_author_link(array('size' => 14, 'link_text' => bbp_get_reply_author_display_name($revision->ID), 'post_id' => $revision->ID));
        $since = bbp_get_time_since(bbp_convert_date($revision->post_modified));
        $r .= "\t" . '<li id="bbp-reply-revision-log-' . esc_attr($reply_id) . '-item-' . esc_attr($revision->ID) . '" class="bbp-reply-revision-log-item">' . "\n";
        if (!empty($reason)) {
            $r .= "\t\t" . sprintf(esc_html__('This reply was modified %1$s by %2$s. Reason: %3$s', 'bbpress'), esc_html($since), $author, esc_html($reason)) . "\n";
        } else {
            $r .= "\t\t" . sprintf(esc_html__('This reply was modified %1$s by %2$s.', 'bbpress'), esc_html($since), $author) . "\n";
        }
        $r .= "\t" . '</li>' . "\n";
    }
    $r .= "\n" . '</ul>' . "\n\n";
    return apply_filters('bbp_get_reply_revision_log', $r, $reply_id);
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:59,代码来源:template.php

示例5: test_bbp_time_since_timezone

 /**
  * @covers ::bbp_time_since
  * @covers ::bbp_get_time_since
  */
 public function test_bbp_time_since_timezone()
 {
     $now = time();
     $then = $now - 1 * HOUR_IN_SECONDS;
     $since = '1 hour ago';
     // Backup timezone.
     $tz_backup = date_default_timezone_get();
     // Set timezone to something other than UTC.
     date_default_timezone_set('Europe/Paris');
     // Output.
     $this->expectOutputString($since);
     bbp_time_since($then, $now);
     // Formatted.
     $this->assertSame($since, bbp_get_time_since($then, $now, true));
     // Revert timezone back to normal.
     if ($tz_backup) {
         date_default_timezone_set($tz_backup);
     }
 }
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:23,代码来源:functions.php

示例6: bbp_time_since

/**
 * Output formatted time to display human readable time difference.
 *
 * @since 2.0.0 bbPress (r2544)
 *
 * @param string $older_date Unix timestamp from which the difference begins.
 * @param string $newer_date Optional. Unix timestamp from which the
 *                            difference ends. False for current time.
 * @param int $gmt Optional. Whether to use GMT timezone. Default is false.
 * @uses bbp_get_time_since() To get the formatted time
 */
function bbp_time_since($older_date, $newer_date = false, $gmt = false)
{
    echo bbp_get_time_since($older_date, $newer_date, $gmt);
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:15,代码来源:functions.php

示例7: bbp_get_forum_last_active_time

/**
 * Return the forums last update date/time (aka freshness)
 *
 * @since bbPress (r2464)
 *
 * @param int $forum_id Optional. Forum id
 * @uses bbp_get_forum_id() To get the forum id
 * @uses get_post_meta() To retrieve forum last active meta
 * @uses bbp_get_forum_last_reply_id() To get forum's last reply id
 * @uses get_post_field() To get the post date of the reply
 * @uses bbp_get_forum_last_topic_id() To get forum's last topic id
 * @uses bbp_get_topic_last_active_time() To get time when the topic was
 *                                    last active
 * @uses bbp_convert_date() To convert the date
 * @uses bbp_get_time_since() To get time in since format
 * @uses apply_filters() Calls 'bbp_get_forum_last_active' with last
 *                        active time and forum id
 * @return string Forum last update date/time (freshness)
 */
function bbp_get_forum_last_active_time($forum_id = 0)
{
    $forum_id = bbp_get_forum_id($forum_id);
    $last_active = get_post_meta($forum_id, '_bbp_last_active_time', true);
    if (empty($last_active)) {
        $reply_id = bbp_get_forum_last_reply_id($forum_id);
        if (!empty($reply_id)) {
            $last_active = get_post_field('post_date', $reply_id);
        } else {
            $topic_id = bbp_get_forum_last_topic_id($forum_id);
            if (!empty($topic_id)) {
                $last_active = bbp_get_topic_last_active_time($topic_id);
            }
        }
    }
    $last_active = !empty($last_active) ? bbp_get_time_since(bbp_convert_date($last_active)) : '';
    return apply_filters('bbp_get_forum_last_active', $last_active, $forum_id);
}
开发者ID:hscale,项目名称:webento,代码行数:37,代码来源:bbp-forum-template.php

示例8: widget

    /**
     * Displays the output, the replies list
     *
     * @since bbPress (r2653)
     *
     * @param mixed $args
     * @param array $instance
     * @uses apply_filters() Calls 'bbp_reply_widget_title' with the title
     * @uses bbp_get_reply_author_link() To get the reply author link
     * @uses bbp_get_reply_author() To get the reply author name
     * @uses bbp_get_reply_id() To get the reply id
     * @uses bbp_get_reply_url() To get the reply url
     * @uses bbp_get_reply_excerpt() To get the reply excerpt
     * @uses bbp_get_reply_topic_title() To get the reply topic title
     * @uses get_the_date() To get the date of the reply
     * @uses get_the_time() To get the time of the reply
     */
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('bbp_replies_widget_title', $instance['title']);
        $max_shown = !empty($instance['max_shown']) ? $instance['max_shown'] : '5';
        $show_date = !empty($instance['show_date']) ? 'on' : false;
        $show_user = !empty($instance['show_user']) ? 'on' : false;
        $post_types = !empty($instance['post_type']) ? array(bbp_get_topic_post_type(), bbp_get_reply_post_type()) : bbp_get_reply_post_type();
        // Note: private and hidden forums will be excluded via the
        // bbp_pre_get_posts_exclude_forums filter and function.
        $widget_query = new WP_Query(array('post_type' => $post_types, 'post_status' => join(',', array(bbp_get_public_status_id(), bbp_get_closed_status_id())), 'posts_per_page' => $max_shown, 'meta_query' => array(bbp_exclude_forum_ids('meta_query'))));
        // Get replies and display them
        if ($widget_query->have_posts()) {
            echo $before_widget;
            echo $before_title . $title . $after_title;
            ?>

			<ul>

				<?php 
            while ($widget_query->have_posts()) {
                $widget_query->the_post();
                ?>

					<li>

						<?php 
                $reply_id = bbp_get_reply_id($widget_query->post->ID);
                $author_link = bbp_get_reply_author_link(array('post_id' => $reply_id, 'type' => 'both', 'size' => 14));
                $reply_link = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($reply_id)) . '" title="' . bbp_get_reply_excerpt($reply_id, 50) . '">' . bbp_get_reply_topic_title($reply_id) . '</a>';
                // Reply author, link, and timestamp
                if ('on' == $show_date && 'on' == $show_user) {
                    // translators: 1: reply author, 2: reply link, 3: reply timestamp
                    printf(_x('%1$s on %2$s %3$s', 'widgets', 'bbpress'), $author_link, $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
                    // Reply link and timestamp
                } elseif ($show_date == 'on') {
                    // translators: 1: reply link, 2: reply timestamp
                    printf(_x('%1$s %2$s', 'widgets', 'bbpress'), $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
                    // Reply author and title
                } elseif ($show_user == 'on') {
                    // translators: 1: reply author, 2: reply link
                    printf(_x('%1$s on %2$s', 'widgets', 'bbpress'), $author_link, $reply_link);
                    // Only the reply title
                } else {
                    // translators: 1: reply link
                    printf(_x('%1$s', 'widgets', 'bbpress'), $reply_link);
                }
                ?>

					</li>

				<?php 
            }
            ?>

			</ul>

			<?php 
            echo $after_widget;
            // Reset the $post global
            wp_reset_postdata();
        }
    }
开发者ID:rmccue,项目名称:bbPress,代码行数:80,代码来源:bbp-core-widgets.php

示例9: widget

    /**
     * Displays the output, the replies list
     *
     * @since bbPress (r2653)
     *
     * @param mixed $args
     * @param array $instance
     * @uses apply_filters() Calls 'bbp_reply_widget_title' with the title
     * @uses bbp_get_reply_author_link() To get the reply author link
     * @uses bbp_get_reply_id() To get the reply id
     * @uses bbp_get_reply_url() To get the reply url
     * @uses bbp_get_reply_excerpt() To get the reply excerpt
     * @uses bbp_get_reply_topic_title() To get the reply topic title
     * @uses get_the_date() To get the date of the reply
     * @uses get_the_time() To get the time of the reply
     */
    public function widget($args, $instance)
    {
        // Get widget settings
        $settings = $this->parse_settings($instance);
        // Typical WordPress filter
        $settings['title'] = apply_filters('widget_title', $settings['title'], $instance, $this->id_base);
        // bbPress filter
        $settings['title'] = apply_filters('bbp_replies_widget_title', $settings['title'], $instance, $this->id_base);
        // Note: private and hidden forums will be excluded via the
        // bbp_pre_get_posts_normalize_forum_visibility action and function.
        $widget_query = new WP_Query(array('post_type' => bbp_get_reply_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => (int) $settings['max_shown'], 'ignore_sticky_posts' => true, 'no_found_rows' => true));
        // Bail if no replies
        if (!$widget_query->have_posts()) {
            return;
        }
        echo $args['before_widget'];
        if (!empty($settings['title'])) {
            echo $args['before_title'] . $settings['title'] . $args['after_title'];
        }
        ?>

		<ul>

			<?php 
        while ($widget_query->have_posts()) {
            $widget_query->the_post();
            ?>

				<li>

					<?php 
            // Verify the reply ID
            $reply_id = bbp_get_reply_id($widget_query->post->ID);
            $reply_link = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($reply_id, 50)) . '">' . bbp_get_reply_topic_title($reply_id) . '</a>';
            // Only query user if showing them
            if (!empty($settings['show_user'])) {
                $author_link = bbp_get_reply_author_link(array('post_id' => $reply_id, 'type' => 'both', 'size' => 14));
            } else {
                $author_link = false;
            }
            // Reply author, link, and timestamp
            if (!empty($settings['show_date']) && !empty($author_link)) {
                // translators: 1: reply author, 2: reply link, 3: reply timestamp
                printf(_x('%1$s on %2$s %3$s', 'widgets', 'bbpress'), $author_link, $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
                // Reply link and timestamp
            } elseif (!empty($settings['show_date'])) {
                // translators: 1: reply link, 2: reply timestamp
                printf(_x('%1$s %2$s', 'widgets', 'bbpress'), $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
                // Reply author and title
            } elseif (!empty($author_link)) {
                // translators: 1: reply author, 2: reply link
                printf(_x('%1$s on %2$s', 'widgets', 'bbpress'), $author_link, $reply_link);
                // Only the reply title
            } else {
                // translators: 1: reply link
                printf(_x('%1$s', 'widgets', 'bbpress'), $reply_link);
            }
            ?>

				</li>

			<?php 
        }
        ?>

		</ul>

		<?php 
        echo $args['after_widget'];
        // Reset the $post global
        wp_reset_postdata();
    }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:88,代码来源:widgets.php

示例10: widget

    /**
     * Displays the output, the replies list
     *
     * @since bbPress (r2653)
     *
     * @param mixed $args
     * @param array $instance
     * @uses apply_filters() Calls 'bbp_reply_widget_title' with the title
     * @uses bbp_get_reply_author_link() To get the reply author link
     * @uses bbp_get_reply_author() To get the reply author name
     * @uses bbp_get_reply_id() To get the reply id
     * @uses bbp_get_reply_url() To get the reply url
     * @uses bbp_get_reply_excerpt() To get the reply excerpt
     * @uses bbp_get_reply_topic_title() To get the reply topic title
     * @uses get_the_date() To get the date of the reply
     * @uses get_the_time() To get the time of the reply
     */
    public function widget($args, $instance)
    {
        // Get widget settings
        $settings = $this->parse_settings($instance);
        // Typical WordPress filter
        $settings['title'] = apply_filters('widget_title', $settings['title'], $instance, $this->id_base);
        // bbPress filter
        $settings['title'] = apply_filters('pg_replies_widget_title', $settings['title'], $instance, $this->id_base);
        // Note: private and hidden forums will be excluded via the
        // bbp_pre_get_posts_exclude_forums filter and function.
        $query_data = array('post_type' => bbp_get_reply_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => '50');
        //PRIVATE GROUPS Get an array of IDs which the current user has permissions to view
        $allowed_posts = private_groups_get_permitted_post_ids(new WP_Query($query_data));
        // The default forum query with allowed forum ids array added
        $query_data['post__in'] = $allowed_posts;
        //now set max posts
        $query_data['posts_per_page'] = (int) $settings['max_shown'];
        $widget_query = new WP_Query($query_data);
        // Bail if no replies
        if (!$widget_query->have_posts()) {
            return;
        }
        echo $args['before_widget'];
        if (!empty($settings['title'])) {
            echo $args['before_title'] . $settings['title'] . $args['after_title'];
        }
        ?>

        <ul>

            <?php 
        while ($widget_query->have_posts()) {
            $widget_query->the_post();
            ?>

                <li>

                    <?php 
            // Verify the reply ID
            $reply_id = bbp_get_reply_id($widget_query->post->ID);
            $reply_link = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($reply_id, 50)) . '">' . bbp_get_reply_topic_title($reply_id) . '</a>';
            // Only query user if showing them
            if ('on' == $settings['show_user']) {
                $author_link = bbp_get_reply_author_link(array('post_id' => $reply_id, 'type' => 'both', 'size' => 14));
            } else {
                $author_link = false;
            }
            // Reply author, link, and timestamp
            if ('on' == $settings['show_date'] && !empty($author_link)) {
                // translators: 1: reply author, 2: reply link, 3: reply timestamp
                printf(_x('%1$s on %2$s %3$s', 'widgets', 'bbpress'), $author_link, $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
                // Reply link and timestamp
            } elseif ('on' == $settings['show_date']) {
                // translators: 1: reply link, 2: reply timestamp
                printf(_x('%1$s %2$s', 'widgets', 'bbpress'), $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
                // Reply author and title
            } elseif (!empty($author_link)) {
                // translators: 1: reply author, 2: reply link
                printf(_x('%1$s on %2$s', 'widgets', 'bbpress'), $author_link, $reply_link);
                // Only the reply title
            } else {
                // translators: 1: reply link
                printf(_x('%1$s', 'widgets', 'bbpress'), $reply_link);
            }
            ?>

                </li>

            <?php 
        }
        ?>

        </ul>

        <?php 
        echo $args['after_widget'];
        // Reset the $post global
        wp_reset_postdata();
    }
开发者ID:USSLomaPrieta,项目名称:usslomaprieta.org,代码行数:96,代码来源:pg_forum_widgets.php


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