diff -r c7c0fbc09788 -r 5e8dcbe22c24 web/wp-content/plugins/bbpress/includes/common/widgets.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/wp-content/plugins/bbpress/includes/common/widgets.php Tue Dec 04 18:43:10 2012 -0800 @@ -0,0 +1,863 @@ + 'bbp_widget_login', + 'description' => __( 'A simple login form with optional links to sign-up and lost password pages.', 'bbpress' ) + ) ); + + parent::__construct( false, __( '(bbPress) Login Widget', 'bbpress' ), $widget_ops ); + } + + /** + * Register the widget + * + * @since bbPress (r3389) + * + * @uses register_widget() + */ + public static function register_widget() { + register_widget( 'BBP_Login_Widget' ); + } + + /** + * Displays the output, the login form + * + * @since bbPress (r2827) + * + * @param mixed $args Arguments + * @param array $instance Instance + * @uses apply_filters() Calls 'bbp_login_widget_title' with the title + * @uses get_template_part() To get the login/logged in form + */ + public function widget( $args, $instance ) { + extract( $args ); + + $title = apply_filters( 'bbp_login_widget_title', $instance['title'] ); + $register = apply_filters( 'bbp_login_widget_register', $instance['register'] ); + $lostpass = apply_filters( 'bbp_login_widget_lostpass', $instance['lostpass'] ); + + echo $before_widget; + + if ( !empty( $title ) ) + echo $before_title . $title . $after_title; + + if ( !is_user_logged_in() ) : ?> + +
+
+ + +
+ + +
+ +
+ + +
+ +
+ id="rememberme" tabindex="" /> + +
+ +
+ + + + + + + +
+ + + + + + + +
+
+ + + +
+ +

+ + +
+ + + +

+ +

+ +

+ +

+ +

+ +

+ + 'widget_display_views', + 'description' => __( 'A list of registered optional topic views.', 'bbpress' ) + ) ); + + parent::__construct( false, __( '(bbPress) Topic Views List', 'bbpress' ), $widget_ops ); + } + + /** + * Register the widget + * + * @since bbPress (r3389) + * + * @uses register_widget() + */ + public static function register_widget() { + register_widget( 'BBP_Views_Widget' ); + } + + /** + * Displays the output, the view list + * + * @since bbPress (r3020) + * + * @param mixed $args Arguments + * @param array $instance Instance + * @uses apply_filters() Calls 'bbp_view_widget_title' with the title + * @uses bbp_get_views() To get the views + * @uses bbp_view_url() To output the view url + * @uses bbp_view_title() To output the view title + */ + public function widget( $args, $instance ) { + + // Only output widget contents if views exist + if ( bbp_get_views() ) : + + extract( $args ); + + $title = apply_filters( 'bbp_view_widget_title', $instance['title'] ); + + echo $before_widget; + echo $before_title . $title . $after_title; ?> + + + + + +

+ +

+ + 'widget_display_forums', + 'description' => __( 'A list of forums with an option to set the parent.', 'bbpress' ) + ) ); + + parent::__construct( false, __( '(bbPress) Forums List', 'bbpress' ), $widget_ops ); + } + + /** + * Register the widget + * + * @since bbPress (r3389) + * + * @uses register_widget() + */ + public static function register_widget() { + register_widget( 'BBP_Forums_Widget' ); + } + + /** + * Displays the output, the forum list + * + * @since bbPress (r2653) + * + * @param mixed $args Arguments + * @param array $instance Instance + * @uses apply_filters() Calls 'bbp_forum_widget_title' with the title + * @uses get_option() To get the forums per page option + * @uses current_user_can() To check if the current user can read + * private() To resety name + * @uses bbp_has_forums() The main forum loop + * @uses bbp_forums() To check whether there are more forums available + * in the loop + * @uses bbp_the_forum() Loads up the current forum in the loop + * @uses bbp_forum_permalink() To display the forum permalink + * @uses bbp_forum_title() To display the forum title + */ + public function widget( $args, $instance ) { + extract( $args ); + + $title = apply_filters( 'bbp_forum_widget_title', $instance['title'] ); + $parent_forum = !empty( $instance['parent_forum'] ) ? $instance['parent_forum'] : '0'; + + // 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_parent' => $parent_forum, + 'post_type' => bbp_get_forum_post_type(), + 'posts_per_page' => get_option( '_bbp_forums_per_page', 50 ), + 'orderby' => 'menu_order', + 'order' => 'ASC' + ) ); + + if ( $widget_query->have_posts() ) : + + echo $before_widget; + echo $before_title . $title . $after_title; ?> + + + + + +

+ +

+ +

+ + +
+ + +

+ + 'widget_display_topics', + 'description' => __( 'A list of recent topics, sorted by popularity or freshness.', 'bbpress' ) + ) ); + + parent::__construct( false, __( '(bbPress) Recent Topics', 'bbpress' ), $widget_ops ); + } + + /** + * Register the widget + * + * @since bbPress (r3389) + * + * @uses register_widget() + */ + public static function register_widget() { + register_widget( 'BBP_Topics_Widget' ); + } + + /** + * Displays the output, the topic list + * + * @since bbPress (r2653) + * + * @param mixed $args + * @param array $instance + * @uses apply_filters() Calls 'bbp_topic_widget_title' with the title + * @uses bbp_topic_permalink() To display the topic permalink + * @uses bbp_topic_title() To display the topic title + * @uses bbp_get_topic_last_active_time() To get the topic last active + * time + * @uses bbp_get_topic_id() To get the topic id + */ + public function widget( $args, $instance ) { + + extract( $args ); + + $title = apply_filters( 'bbp_topic_widget_title', $instance['title'] ); + $max_shown = !empty( $instance['max_shown'] ) ? (int) $instance['max_shown'] : 5; + $show_date = !empty( $instance['show_date'] ) ? 'on' : false; + $show_user = !empty( $instance['show_user'] ) ? 'on' : false; + $parent_forum = !empty( $instance['parent_forum'] ) ? $instance['parent_forum'] : 'any'; + $order_by = !empty( $instance['order_by'] ) ? $instance['order_by'] : false; + + // How do we want to order our results? + switch ( $order_by ) { + + // Order by most recent replies + case 'freshness' : + $topics_query = array( + 'author' => 0, + 'post_type' => bbp_get_topic_post_type(), + 'post_parent' => $parent_forum, + 'posts_per_page' => $max_shown, + 'post_status' => join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ), + 'show_stickes' => false, + 'meta_key' => '_bbp_last_active_time', + 'orderby' => 'meta_value', + 'order' => 'DESC', + 'meta_query' => array( bbp_exclude_forum_ids( 'meta_query' ) ) + ); + break; + + // Order by total number of replies + case 'popular' : + $topics_query = array( + 'author' => 0, + 'post_type' => bbp_get_topic_post_type(), + 'post_parent' => $parent_forum, + 'posts_per_page' => $max_shown, + 'post_status' => join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ), + 'show_stickes' => false, + 'meta_key' => '_bbp_reply_count', + 'orderby' => 'meta_value', + 'order' => 'DESC', + 'meta_query' => array( bbp_exclude_forum_ids( 'meta_query' ) ) + ); + break; + + // Order by which topic was created most recently + case 'newness' : + default : + $topics_query = array( + 'author' => 0, + 'post_type' => bbp_get_topic_post_type(), + 'post_parent' => $parent_forum, + 'posts_per_page' => $max_shown, + 'post_status' => join( ',', array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ), + 'show_stickes' => false, + 'order' => 'DESC', + 'meta_query' => array( bbp_exclude_forum_ids( 'meta_query' ) ) + ); + break; + } + + // Note: private and hidden forums will be excluded via the + // bbp_pre_get_posts_exclude_forums filter and function. + $widget_query = new WP_Query( $topics_query ); + + // Topics exist + if ( $widget_query->have_posts() ) : + + echo $before_widget; + echo $before_title . $title . $after_title; ?> + + + + + +

+

+

+

+ +

+ + +

+ + 'widget_display_replies', + 'description' => __( 'A list of the most recent replies.', 'bbpress' ) + ) ); + + parent::__construct( false, __( '(bbPress) Recent Replies', 'bbpress' ), $widget_ops ); + } + + /** + * Register the widget + * + * @since bbPress (r3389) + * + * @uses register_widget() + */ + public static function register_widget() { + register_widget( 'BBP_Replies_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; ?> + + + + + +

+

+

+

+ +