コード例 #1
0
/**
 * Plugin Name: WP Slack bbPress
 * Plugin URI:  https://github.com/rolfkleef/wp-slack-bbpress
 * Description: Send notifications to Slack channels for events in bbPress.
 * Version:     0.5
 * Author:      Rolf Kleef
 * Author URI:  https://drostan.org
 * License:     GPL2
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: wp-slack-bbpress
 */
function wp_slack_bbpress($events)
{
    $events['wp_slack_bbp_new_topic'] = array('action' => 'bbp_new_topic', 'description' => __('When a new topic is added in bbPress', 'wp-slack-bbpress'), 'message' => function ($topic_id, $forum_id, $anonymous_data, $topic_author) {
        return array(array('fallback' => sprintf(__('<%1$s|New topic "%2$s"> in forum <%3$s|%4$s>', 'wp-slack-bbpress'), bbp_get_topic_permalink($topic_id), bbp_get_topic_title($topic_id), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id)), 'pretext' => sprintf(__('New topic in forum <%1$s|%2$s>', 'wp-slack-bbpress'), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id)), 'author_name' => bbp_get_topic_author_display_name($topic_id), 'author_link' => bbp_get_topic_author_link($topic_id), 'author_icon' => get_avatar_url($topic_author, array('size' => 16)), 'title' => sprintf('%1$s', bbp_get_topic_title($topic_id)), 'title_link' => bbp_get_topic_permalink($topic_id), 'text' => html_entity_decode(bbp_get_topic_excerpt($topic_id, 150))));
    });
    $events['wp_slack_bbp_new_reply'] = array('action' => 'bbp_new_reply', 'description' => __('When a new reply is added in bbPress', 'wp-slack-bbpress'), 'message' => function ($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, $bool, $reply_to) {
        return array(array('fallback' => sprintf(__('<%1$s|New reply> in forum <%2$s|%3$s> on topic <%4$s|%5$s>', 'wp-slack-bbpress'), bbp_get_reply_url($reply_id), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id), bbp_get_topic_permalink($topic_id), bbp_get_topic_title($topic_id)), 'pretext' => sprintf(__('New reply in forum <%1$s|%2$s> on topic <%3$s|%4$s>', 'wp-slack-bbpress'), bbp_get_forum_permalink($forum_id), bbp_get_forum_title($forum_id), bbp_get_topic_permalink($topic_id), bbp_get_topic_title($topic_id)), 'author_name' => bbp_get_reply_author_display_name($reply_id), 'author_link' => bbp_get_reply_author_link($reply_id), 'author_icon' => get_avatar_url($reply_author, array('size' => 16)), 'title' => sprintf(__('New reply to "%1$s"', 'wp-slack-bbpress'), bbp_get_topic_title($topic_id)), 'title_link' => bbp_get_reply_url($reply_id), 'text' => html_entity_decode(bbp_get_reply_excerpt($reply_id, 150))));
    });
    return $events;
}
コード例 #2
0
        function widget($args, $instance)
        {
            extract($args, EXTR_SKIP);
            $title = !empty($instance['title']) ? $instance['title'] : __('Recent Topics');
            $title = apply_filters('widget_title', $title, $instance, $this->id_base);
            $number = !empty($instance['number']) ? absint($instance['number']) : 5;
            $orderby = !empty($instance['number']) ? strip_tags($instance['order_by']) : 'newness';
            if ($orderby == 'newness') {
                $cb_meta_key = $cb_order_by = NULL;
            } elseif ($orderby == 'popular') {
                $cb_meta_key = '_bbp_reply_count';
                $cb_order_by = 'meta_value';
            } elseif ($orderby == 'freshness') {
                $cb_meta_key = '_bbp_last_active_time';
                $cb_order_by = 'meta_value';
            }
            if (!$number) {
                $number = 5;
            }
            $cb_qry = new WP_Query(array('post_type' => bbp_get_topic_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'order' => 'DESC', 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => $cb_meta_key, 'orderby' => $cb_order_by));
            echo $before_widget;
            echo $before_title . $title . $after_title;
            ?>
            <ul class="cb-bbp-recent-topics">

                <?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_number_replies = bbp_get_topic_reply_count($cb_reply_id);
                $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_reply_url . '<div class="cb-bbp-byline">' . __('Started by', 'cubell') . ' ' . $cb_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_number_replies . ' replies</div></div>';
                ?>

                    </li>

                <?php 
            }
            ?>

            </ul>

<?php 
            echo $after_widget;
            // Reset the $post global
            wp_reset_postdata();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
		<?php 
do_action('bbp_theme_after_reply_author_details');
?>

	</div><!-- .bbp-reply-author -->

	<div class="bbp-reply-content">

		<div class="mom-bbp-reply-author mom-main-font">
			<span class="mom-main-color">
			<?php 
if (class_exists('userpro_api')) {
    /* Integrating UserPro */
    global $userpro;
    $link = preg_replace("/(?<=href=(\"|'))[^\"']+(?=(\"|'))/", $userpro->permalink(bbp_get_reply_author_id()), bbp_get_reply_author_link(array('sep' => '', 'size' => 0)));
    echo $link . userpro_show_badges(bbp_get_reply_author_id());
} else {
    bbp_reply_author_link(array('sep' => '', 'show_role' => false, 'type' => 'name'));
}
?>
			</span> <?php 
_e('on:', 'framework');
?>
 <?php 
bbp_reply_post_date();
?>
			<a href="<?php 
bbp_reply_url();
?>
" class="bbp-reply-permalink alignright">#<?php 
コード例 #5
0
ファイル: template.php プロジェクト: danielcoats/schoolpress
/**
 * Output the author link of the reply
 *
 * @since bbPress (r2717)
 *
 * @param mixed $args Optional. If it is an integer, it is used as reply id.
 * @uses bbp_get_reply_author_link() To get the reply author link
 */
function bbp_reply_author_link($args = '')
{
    echo bbp_get_reply_author_link($args);
}
コード例 #6
0
/**
 * Return the author link of the post
 *
 * @since 2.0.0 bbPress (r2875)
 *
 * @param array $args Optional. If an integer, it is used as reply id.
 * @uses bbp_is_topic() To check if it's a topic page
 * @uses bbp_get_topic_author_link() To get the topic author link
 * @uses bbp_is_reply() To check if it's a reply page
 * @uses bbp_get_reply_author_link() To get the reply author link
 * @uses get_post_field() To get the post author
 * @uses bbp_is_reply_anonymous() To check if the reply is by an
 *                                 anonymous user
 * @uses get_the_author_meta() To get the author name
 * @uses bbp_get_user_profile_url() To get the author profile url
 * @uses get_avatar() To get the author avatar
 * @uses apply_filters() Calls 'bbp_get_reply_author_link' with the
 *                        author link and args
 * @return string Author link of reply
 */
function bbp_get_author_link($args = array())
{
    $post_id = is_numeric($args) ? (int) $args : 0;
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('post_id' => $post_id, 'link_title' => '', 'type' => 'both', 'size' => 80), 'get_author_link');
    // Confirmed topic
    if (bbp_is_topic($r['post_id'])) {
        return bbp_get_topic_author_link($r);
        // Confirmed reply
    } elseif (bbp_is_reply($r['post_id'])) {
        return bbp_get_reply_author_link($r);
    }
    // Get the post author and proceed
    $user_id = get_post_field('post_author', $r['post_id']);
    // Neither a reply nor a topic, so could be a revision
    if (!empty($r['post_id'])) {
        // Generate title with the display name of the author
        if (empty($r['link_title'])) {
            $r['link_title'] = sprintf(!bbp_is_reply_anonymous($r['post_id']) ? __('View %s\'s profile', 'bbpress') : __('Visit %s\'s website', 'bbpress'), get_the_author_meta('display_name', $user_id));
        }
        // Assemble some link bits
        $link_title = !empty($r['link_title']) ? ' title="' . esc_attr($r['link_title']) . '"' : '';
        $anonymous = bbp_is_reply_anonymous($r['post_id']);
        // Declare empty array
        $author_links = array();
        // Get avatar
        if ('avatar' === $r['type'] || 'both' === $r['type']) {
            $author_links[] = get_avatar($user_id, $r['size']);
        }
        // Get display name
        if ('name' === $r['type'] || 'both' === $r['type']) {
            $author_links[] = esc_html(get_the_author_meta('display_name', $user_id));
        }
        // Add links if not anonymous
        if (empty($anonymous) && bbp_user_has_profile($user_id)) {
            $author_url = bbp_get_user_profile_url($user_id);
            foreach ($author_links as $link_text) {
                $author_link[] = sprintf('<a href="%1$s"%2$s>%3$s</a>', esc_url($author_url), $link_title, $link_text);
            }
            $author_link = implode('&nbsp;', $author_link);
            // No links if anonymous
        } else {
            $author_link = implode('&nbsp;', $author_links);
        }
        // No post so link is empty
    } else {
        $author_link = '';
    }
    return apply_filters('bbp_get_author_link', $author_link, $r);
}
コード例 #7
0
/**
 * Output the author link of the reply
 *
 * @since 2.0.0 bbPress (r2717)
 *
 * @param array $args Optional. If it is an integer, it is used as reply id.
 * @uses bbp_get_reply_author_link() To get the reply author link
 */
function bbp_reply_author_link($args = array())
{
    echo bbp_get_reply_author_link($args);
}
コード例 #8
0
ファイル: bbp-core-widgets.php プロジェクト: rmccue/bbPress
    /**
     * 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();
        }
    }
コード例 #9
0
function teamop_get_last_poster_block_topics()
{
    $output .= "<div class='last-posted-topic-user'>";
    $output .= bbp_get_reply_author_link(array('post_id' => bbp_get_topic_last_active_id(), 'size' => '14'));
    $output .= "</div>";
    $output .= "<div class='last-posted-topic-time'>";
    $output .= bbp_get_topic_last_active_time(bbp_get_topic_last_active_id());
    $output .= "</div>";
    return $output;
}
コード例 #10
0
ファイル: widgets.php プロジェクト: sdh100shaun/pantheon
    /**
     * 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();
    }
コード例 #11
0
ファイル: bbp-user-template.php プロジェクト: rmccue/bbPress
/**
 * Return the author link of the post
 *
 * @since bbPress (r2875)
 *
 * @param mixed $args Optional. If an integer, it is used as reply id.
 * @uses bbp_is_topic() To check if it's a topic page
 * @uses bbp_get_topic_author_link() To get the topic author link
 * @uses bbp_is_reply() To check if it's a reply page
 * @uses bbp_get_reply_author_link() To get the reply author link
 * @uses get_post_field() To get the post author
 * @uses bbp_is_reply_anonymous() To check if the reply is by an
 *                                 anonymous user
 * @uses get_the_author_meta() To get the author name
 * @uses bbp_get_user_profile_url() To get the author profile url
 * @uses get_avatar() To get the author avatar
 * @uses apply_filters() Calls 'bbp_get_reply_author_link' with the
 *                        author link and args
 * @return string Author link of reply
 */
function bbp_get_author_link($args = '')
{
    // Default arguments
    $defaults = array('post_id' => 0, 'link_title' => '', 'type' => 'both', 'size' => 80);
    $r = bbp_parse_args($args, $defaults, 'get_author_link');
    extract($r);
    // Used as reply_id
    if (is_numeric($args)) {
        $post_id = $args;
    }
    // Confirmed topic
    if (bbp_is_topic($post_id)) {
        return bbp_get_topic_author_link($args);
    } elseif (bbp_is_reply($post_id)) {
        return bbp_get_reply_author_link($args);
    } else {
        $user_id = get_post_field('post_author', $post_id);
    }
    // Neither a reply nor a topic, so could be a revision
    if (!empty($post_id)) {
        // Generate title with the display name of the author
        if (empty($link_title)) {
            $link_title = sprintf(!bbp_is_reply_anonymous($post_id) ? __('View %s\'s profile', 'bbpress') : __('Visit %s\'s website', 'bbpress'), get_the_author_meta('display_name', $user_id));
        }
        // Assemble some link bits
        $link_title = !empty($link_title) ? ' title="' . $link_title . '"' : '';
        $author_url = bbp_get_user_profile_url($user_id);
        $anonymous = bbp_is_reply_anonymous($post_id);
        // Get avatar
        if ('avatar' == $type || 'both' == $type) {
            $author_links[] = get_avatar($user_id, $size);
        }
        // Get display name
        if ('name' == $type || 'both' == $type) {
            $author_links[] = get_the_author_meta('display_name', $user_id);
        }
        // Add links if not anonymous
        if (empty($anonymous)) {
            foreach ($author_links as $link_text) {
                $author_link[] = sprintf('<a href="%1$s"%2$s>%3$s</a>', $author_url, $link_title, $link_text);
            }
            $author_link = join('&nbsp;', $author_link);
            // No links if anonymous
        } else {
            $author_link = join('&nbsp;', $author_links);
        }
        // No post so link is empty
    } else {
        $author_link = '';
    }
    return apply_filters('bbp_get_author_link', $author_link, $args);
}
コード例 #12
0
</li>

  <li class="bbp-forum-freshness">

    <div class="author-avatar">
      <?php 
bbp_reply_author_avatar(bbp_get_forum_last_reply_id(), 50);
?>
    </div>
    <div class="topic-desc">
      <?php 
do_action('bbp_theme_before_topic_freshness_author');
?>

      <span class="bbp-topic-freshness-author"><?php 
echo bbp_get_reply_author_link(bbp_get_forum_last_reply_id(), 50);
?>
</span>

      <?php 
do_action('bbp_theme_after_topic_freshness_author');
?>

      <?php 
do_action('bbp_theme_before_topic_freshness_link');
?>

      <p><?php 
bbp_forum_freshness_link();
?>
</p>
コード例 #13
0
    /**
     * 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();
    }
コード例 #14
0
ファイル: setup-bbpress.php プロジェクト: pab44/pab44
 function wm_bbp_large_topic()
 {
     global $paged;
     //Requirements check
     if (!(bbp_is_single_topic() || bbp_is_single_reply())) {
         return;
     }
     //Helper variables
     $output = array();
     $post_id = bbp_is_single_reply() ? bbp_get_reply_topic_id() : get_the_id();
     //Preparing output
     $output[10] = '<div class="bbp-large-topic">';
     $output[20] = '<div class="wrap-inner">';
     $output[30] = '<div class="content-area site-content pane twelve">';
     $output[100] = '<div ' . bbp_get_reply_class() . wm_schema_org('article') . '>';
     //Author
     $output[110] = '<div class="bbp-reply-author">';
     $output[120] = bbp_get_reply_author_link(array('post_id' => $post_id, 'sep' => '<br />', 'show_role' => true));
     $output[130] = '</div>';
     // /.bbp-reply-author
     //Heading and content
     $output[200] = '<div class="bbp-reply-content">';
     $output[210] = '<h1 class="bbp-topic-title">';
     if (1 < $paged) {
         $output[210] .= '<a href="' . get_permalink($post_id) . '">';
     }
     $output[210] .= bbp_get_topic_title($post_id);
     if (1 < $paged) {
         $output[210] .= '</a> ' . wm_paginated_suffix('small');
     }
     $output[210] .= '</h1>';
     $output[220] = bbp_get_topic_tag_list($post_id);
     if (!post_password_required($post_id)) {
         $output[230] = '<div class="bbp-content-container">';
         setup_postdata(get_post($post_id));
         $output[240] = apply_filters('wmhook_content_filters', bbp_get_topic_content($post_id), $post_id);
         wp_reset_postdata();
         $output[250] = '</div>';
         // /.bbp-content-container
     }
     $output[260] = '</div>';
     // /.bbp-reply-content
     //Meta
     $output[300] = '<div class="bbp-meta">';
     $output[310] = '<span class="bbp-reply-post-date">' . bbp_get_reply_post_date($post_id) . '</span>';
     if (bbp_is_single_user_replies()) {
         $output[320] = '<span class="bbp-header">';
         $output[330] = __('in reply to: ', 'mustang');
         $output[340] = '<a class="bbp-topic-permalink" href="' . bbp_get_topic_permalink(bbp_get_reply_topic_id($post_id)) . '">';
         $output[350] = bbp_get_topic_title(bbp_get_reply_topic_id($post_id));
         $output[360] = '</a>';
         // /.bbp-topic-permalink
         $output[370] = '</span>';
         // /.bbp-header
     }
     $output[380] = bbp_get_reply_admin_links(array('id' => $post_id));
     $output[390] = '</div>';
     // /.bbp-meta
     $output[500] = '</div>';
     // /.bbp_get_reply_class()
     $output[600] = '</div>';
     // /.content-area
     $output[610] = '</div>';
     // /.wrap-inner
     $output[620] = '</div>';
     // /.bbp-large-topic
     //Output
     $output = apply_filters('wmhook_wm_bbp_large_topic_output', $output, $post_id);
     echo implode('', $output);
 }
コード例 #15
0
function pg_get_author_link()
{
    $user_id2 = wp_get_current_user()->ID;
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('post_id' => $post_id, 'link_title' => '', 'type' => 'both', 'size' => 14), 'pg_get_author_link');
    //confirmed topic
    if (bbp_is_topic($post_id)) {
        $topic = bbp_get_topic_post_type();
        $forum_id_check = private_groups_get_forum_id_from_post_id($post_id, $topic);
        //now we can check if the user can view this
        if (!private_groups_can_user_view_post($user_id2, $forum_id_check)) {
            return;
        }
        return bbp_get_topic_author_link($r);
        // Confirmed reply
    } elseif (bbp_is_reply($post_id)) {
        $reply = bbp_get_reply_post_type();
        $forum_id_check = private_groups_get_forum_id_from_post_id($post_id, $reply);
        //now we can check if the user can view this
        if (!private_groups_can_user_view_post($user_id2, $forum_id_check)) {
            return;
        }
        return bbp_get_reply_author_link($r);
    }
    // Neither a reply nor a topic, so could be a revision
    //if it isn't a topic or reply, not sure so better to just not display the author in this case
    //could be revised to look up the post_parent of this post and then churn that round the code above if required return ;
    return;
}
コード例 #16
0
ファイル: loop-forums.php プロジェクト: hakkens/davehakkens
                if ($last_reply_avatar != '') {
                    echo $last_reply_avatar;
                } else {
                    echo bbp_get_topic_author_avatar($sub_forum->ID, 50);
                }
                ?>
            </div>

            <div class="topic-desc">
              <?php 
                do_action('bbp_theme_before_topic_freshness_author');
                ?>


              <span class="bbp-topic-freshness-author"><?php 
                $last_reply_link = bbp_get_reply_author_link(bbp_get_forum_last_reply_id($sub_forum->ID), 50);
                if ($last_reply_link != '') {
                    echo $last_reply_link;
                } else {
                    echo bbp_get_topic_author_link($sub_forum->ID, 50);
                }
                //echo bbp_get_reply_author_link(bbp_get_forum_last_reply_id($sub_forum->ID), 50);
                ?>
</span>
<!--              <span class="bbp-topic-freshness-author">--><?php 
                //echo bbp_get_author_link( array( 'post_id' => $sub_forum->ID, 'size' => 14 ) );
                ?>
<!--</span>-->

              <?php 
                do_action('bbp_theme_after_topic_freshness_author');