| @@ -17,862 +17,860 @@ | ||
| 17 | 17 | * @since 2.0.0 bbPress (r3031) |
| 18 | 18 | */ |
| 19 | 19 | class BBP_Shortcodes { |
| 20 | 20 | |
| 21 | - /** Vars ******************************************************************/ | |
| 21 | + /** Vars ******************************************************************/ | |
| 22 | 22 | |
| 23 | - /** | |
| 24 | - * Shortcode => function. | |
| 25 | - * | |
| 26 | - * @var array | |
| 27 | - */ | |
| 28 | - public $codes = array(); | |
| 23 | + /** | |
| 24 | + * @var array Shortcode => function | |
| 25 | + */ | |
| 26 | + public $codes = array(); | |
| 29 | 27 | |
| 30 | - /** Functions *************************************************************/ | |
| 28 | + /** Functions *************************************************************/ | |
| 31 | 29 | |
| 32 | - /** | |
| 33 | - * Add the register_shortcodes action to bbp_init | |
| 34 | - * | |
| 35 | - * @since 2.0.0 bbPress (r3031) | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - public function __construct() { | |
| 39 | - $this->setup_globals(); | |
| 40 | - $this->add_shortcodes(); | |
| 41 | - } | |
| 30 | + /** | |
| 31 | + * Add the register_shortcodes action to bbp_init | |
| 32 | + * | |
| 33 | + * @since 2.0.0 bbPress (r3031) | |
| 34 | + * | |
| 35 | + */ | |
| 36 | + public function __construct() { | |
| 37 | + $this->setup_globals(); | |
| 38 | + $this->add_shortcodes(); | |
| 39 | + } | |
| 42 | 40 | |
| 43 | - /** | |
| 44 | - * Shortcode globals | |
| 45 | - * | |
| 46 | - * @since 2.0.0 bbPress (r3143) | |
| 47 | - * | |
| 48 | - * @access private | |
| 49 | - */ | |
| 50 | - private function setup_globals() { | |
| 41 | + /** | |
| 42 | + * Shortcode globals | |
| 43 | + * | |
| 44 | + * @since 2.0.0 bbPress (r3143) | |
| 45 | + * | |
| 46 | + * @access private | |
| 47 | + */ | |
| 48 | + private function setup_globals() { | |
| 51 | 49 | |
| 52 | - // phpcs:disable PEAR.Functions.FunctionCallSignature.CloseBracketLine | |
| 50 | + // phpcs:disable PEAR.Functions.FunctionCallSignature.CloseBracketLine | |
| 53 | 51 | |
| 54 | - // Setup the shortcodes | |
| 55 | - $this->codes = apply_filters( | |
| 56 | - 'bbp_shortcodes', | |
| 57 | - array( | |
| 52 | + // Setup the shortcodes | |
| 53 | + $this->codes = apply_filters( | |
| 54 | + 'bbp_shortcodes', | |
| 55 | + array( | |
| 58 | 56 | |
| 59 | - /** Forums ****************************************************/ | |
| 57 | + /** Forums ********************************************************/ | |
| 60 | 58 | |
| 61 | - 'bbp-forum-index' => array( $this, 'display_forum_index' ), // Forum Index | |
| 62 | - 'bbp-forum-form' => array( $this, 'display_forum_form' ), // Topic form | |
| 63 | - 'bbp-single-forum' => array( $this, 'display_forum' ), // Specific forum - pass an 'id' attribute | |
| 59 | + 'bbp-forum-index' => array( $this, 'display_forum_index' ), // Forum Index | |
| 60 | + 'bbp-forum-form' => array( $this, 'display_forum_form' ), // Topic form | |
| 61 | + 'bbp-single-forum' => array( $this, 'display_forum' ), // Specific forum - pass an 'id' attribute | |
| 64 | 62 | |
| 65 | - /** Topics ****************************************************/ | |
| 63 | + /** Topics ********************************************************/ | |
| 66 | 64 | |
| 67 | - 'bbp-topic-index' => array( $this, 'display_topic_index' ), // Topic index | |
| 68 | - 'bbp-topic-form' => array( $this, 'display_topic_form' ), // Topic form | |
| 69 | - 'bbp-single-topic' => array( $this, 'display_topic' ), // Specific topic - pass an 'id' attribute | |
| 65 | + 'bbp-topic-index' => array( $this, 'display_topic_index' ), // Topic index | |
| 66 | + 'bbp-topic-form' => array( $this, 'display_topic_form' ), // Topic form | |
| 67 | + 'bbp-single-topic' => array( $this, 'display_topic' ), // Specific topic - pass an 'id' attribute | |
| 70 | 68 | |
| 71 | - /** Topic Tags ************************************************/ | |
| 69 | + /** Topic Tags ****************************************************/ | |
| 72 | 70 | |
| 73 | - 'bbp-topic-tags' => array( $this, 'display_topic_tags' ), // All topic tags in a cloud | |
| 74 | - 'bbp-single-tag' => array( $this, 'display_topics_of_tag' ), // Topics of Tag | |
| 71 | + 'bbp-topic-tags' => array( $this, 'display_topic_tags' ), // All topic tags in a cloud | |
| 72 | + 'bbp-single-tag' => array( $this, 'display_topics_of_tag' ), // Topics of Tag | |
| 75 | 73 | |
| 76 | - /** Replies ***************************************************/ | |
| 74 | + /** Replies *******************************************************/ | |
| 77 | 75 | |
| 78 | - 'bbp-reply-form' => array( $this, 'display_reply_form' ), // Reply form | |
| 79 | - 'bbp-single-reply' => array( $this, 'display_reply' ), // Specific reply - pass an 'id' attribute | |
| 76 | + 'bbp-reply-form' => array( $this, 'display_reply_form' ), // Reply form | |
| 77 | + 'bbp-single-reply' => array( $this, 'display_reply' ), // Specific reply - pass an 'id' attribute | |
| 80 | 78 | |
| 81 | - /** Views *****************************************************/ | |
| 79 | + /** Views *********************************************************/ | |
| 82 | 80 | |
| 83 | - 'bbp-single-view' => array( $this, 'display_view' ), // Single view | |
| 81 | + 'bbp-single-view' => array( $this, 'display_view' ), // Single view | |
| 84 | 82 | |
| 85 | - /** Search ****************************************************/ | |
| 83 | + /** Search ********************************************************/ | |
| 86 | 84 | |
| 87 | - 'bbp-search-form' => array( $this, 'display_search_form' ), // Search form | |
| 88 | - 'bbp-search' => array( $this, 'display_search' ), // Search | |
| 85 | + 'bbp-search-form' => array( $this, 'display_search_form' ), // Search form | |
| 86 | + 'bbp-search' => array( $this, 'display_search' ), // Search | |
| 89 | 87 | |
| 90 | - /** Account ***************************************************/ | |
| 88 | + /** Account *******************************************************/ | |
| 91 | 89 | |
| 92 | - 'bbp-login' => array( $this, 'display_login' ), // Login | |
| 93 | - 'bbp-register' => array( $this, 'display_register' ), // Register | |
| 94 | - 'bbp-lost-pass' => array( $this, 'display_lost_pass' ), // Lost Password | |
| 90 | + 'bbp-login' => array( $this, 'display_login' ), // Login | |
| 91 | + 'bbp-register' => array( $this, 'display_register' ), // Register | |
| 92 | + 'bbp-lost-pass' => array( $this, 'display_lost_pass' ), // Lost Password | |
| 95 | 93 | |
| 96 | - /** Others ****************************************************/ | |
| 94 | + /** Others *******************************************************/ | |
| 97 | 95 | |
| 98 | - 'bbp-stats' => array( $this, 'display_stats' ), // Stats | |
| 99 | - ) | |
| 100 | - ); | |
| 96 | + 'bbp-stats' => array( $this, 'display_stats' ), // Stats | |
| 97 | + ) | |
| 98 | + ); | |
| 101 | 99 | |
| 102 | - // phpcs:enable | |
| 103 | - } | |
| 100 | + // phpcs:enable | |
| 101 | + } | |
| 104 | 102 | |
| 105 | - /** | |
| 106 | - * Register the bbPress shortcodes | |
| 107 | - * | |
| 108 | - * @since 2.0.0 bbPress (r3031) | |
| 109 | - */ | |
| 110 | - private function add_shortcodes() { | |
| 111 | - foreach ( (array) $this->codes as $code => $function ) { | |
| 112 | - add_shortcode( $code, $function ); | |
| 113 | - } | |
| 114 | - } | |
| 103 | + /** | |
| 104 | + * Register the bbPress shortcodes | |
| 105 | + * | |
| 106 | + * @since 2.0.0 bbPress (r3031) | |
| 107 | + */ | |
| 108 | + private function add_shortcodes() { | |
| 109 | + foreach ( (array) $this->codes as $code => $function ) { | |
| 110 | + add_shortcode( $code, $function ); | |
| 111 | + } | |
| 112 | + } | |
| 115 | 113 | |
| 116 | - /** | |
| 117 | - * Unset some globals in the $bbp object that hold query related info | |
| 118 | - * | |
| 119 | - * @since 2.0.0 bbPress (r3034) | |
| 120 | - */ | |
| 121 | - private function unset_globals() { | |
| 122 | - $bbp = bbpress(); | |
| 114 | + /** | |
| 115 | + * Unset some globals in the $bbp object that hold query related info | |
| 116 | + * | |
| 117 | + * @since 2.0.0 bbPress (r3034) | |
| 118 | + */ | |
| 119 | + private function unset_globals() { | |
| 120 | + $bbp = bbpress(); | |
| 123 | 121 | |
| 124 | - // Unset global queries | |
| 125 | - $bbp->forum_query = new WP_Query(); | |
| 126 | - $bbp->topic_query = new WP_Query(); | |
| 127 | - $bbp->reply_query = new WP_Query(); | |
| 128 | - $bbp->search_query = new WP_Query(); | |
| 122 | + // Unset global queries | |
| 123 | + $bbp->forum_query = new WP_Query(); | |
| 124 | + $bbp->topic_query = new WP_Query(); | |
| 125 | + $bbp->reply_query = new WP_Query(); | |
| 126 | + $bbp->search_query = new WP_Query(); | |
| 129 | 127 | |
| 130 | - // Unset global ID's | |
| 131 | - $bbp->current_view_id = 0; | |
| 132 | - $bbp->current_forum_id = 0; | |
| 133 | - $bbp->current_topic_id = 0; | |
| 134 | - $bbp->current_reply_id = 0; | |
| 135 | - $bbp->current_topic_tag_id = 0; | |
| 128 | + // Unset global ID's | |
| 129 | + $bbp->current_view_id = 0; | |
| 130 | + $bbp->current_forum_id = 0; | |
| 131 | + $bbp->current_topic_id = 0; | |
| 132 | + $bbp->current_reply_id = 0; | |
| 133 | + $bbp->current_topic_tag_id = 0; | |
| 136 | 134 | |
| 137 | - // Reset the post data | |
| 138 | - wp_reset_postdata(); | |
| 139 | - } | |
| 135 | + // Reset the post data | |
| 136 | + wp_reset_postdata(); | |
| 137 | + } | |
| 140 | 138 | |
| 141 | - /** Output Buffers ********************************************************/ | |
| 139 | + /** Output Buffers ********************************************************/ | |
| 142 | 140 | |
| 143 | - /** | |
| 144 | - * Start an output buffer. | |
| 145 | - * | |
| 146 | - * This is used to put the contents of the shortcode into a variable rather | |
| 147 | - * than outputting the HTML at run-time. This allows shortcodes to appear | |
| 148 | - * in the correct location in the_content() instead of when it's created. | |
| 149 | - * | |
| 150 | - * @since 2.0.0 bbPress (r3079) | |
| 151 | - * | |
| 152 | - * @param string $query_name | |
| 153 | - */ | |
| 154 | - private function start( $query_name = '' ) { | |
| 141 | + /** | |
| 142 | + * Start an output buffer. | |
| 143 | + * | |
| 144 | + * This is used to put the contents of the shortcode into a variable rather | |
| 145 | + * than outputting the HTML at run-time. This allows shortcodes to appear | |
| 146 | + * in the correct location in the_content() instead of when it's created. | |
| 147 | + * | |
| 148 | + * @since 2.0.0 bbPress (r3079) | |
| 149 | + * | |
| 150 | + * @param string $query_name | |
| 151 | + */ | |
| 152 | + private function start( $query_name = '' ) { | |
| 155 | 153 | |
| 156 | - // Set query name | |
| 157 | - bbp_set_query_name( $query_name ); | |
| 154 | + // Set query name | |
| 155 | + bbp_set_query_name( $query_name ); | |
| 158 | 156 | |
| 159 | - // Start output buffer | |
| 160 | - ob_start(); | |
| 161 | - } | |
| 157 | + // Start output buffer | |
| 158 | + ob_start(); | |
| 159 | + } | |
| 162 | 160 | |
| 163 | - /** | |
| 164 | - * Return the contents of the output buffer and flush its contents. | |
| 165 | - * | |
| 166 | - * @since 2.0.0 bbPress (r3079) | |
| 167 | - * | |
| 168 | - * @return string Contents of output buffer. | |
| 169 | - */ | |
| 170 | - private function end() { | |
| 161 | + /** | |
| 162 | + * Return the contents of the output buffer and flush its contents. | |
| 163 | + * | |
| 164 | + * @since 2.0.0 bbPress (r3079) | |
| 165 | + * | |
| 166 | + * @return string Contents of output buffer. | |
| 167 | + */ | |
| 168 | + private function end() { | |
| 171 | 169 | |
| 172 | - // Unset globals | |
| 173 | - $this->unset_globals(); | |
| 170 | + // Unset globals | |
| 171 | + $this->unset_globals(); | |
| 174 | 172 | |
| 175 | - // Get the query name, for filter | |
| 176 | - $query_name = bbp_get_query_name(); | |
| 173 | + // Get the query name, for filter | |
| 174 | + $query_name = bbp_get_query_name(); | |
| 177 | 175 | |
| 178 | - // Reset the query name | |
| 179 | - bbp_reset_query_name(); | |
| 176 | + // Reset the query name | |
| 177 | + bbp_reset_query_name(); | |
| 180 | 178 | |
| 181 | - // Return and flush the output buffer | |
| 182 | - $output = ob_get_clean(); | |
| 179 | + // Return and flush the output buffer | |
| 180 | + $output = ob_get_clean(); | |
| 183 | 181 | |
| 182 | + /** | |
| 183 | + * Filters the contents of the output buffer before returning. | |
| 184 | + * | |
| 185 | + * @since 2.0.0 bbPress (r3079) | |
| 186 | + * | |
| 187 | + * @param string $output The contents of the output buffer. | |
| 188 | + * @param string $query_name The query name used for this output. | |
| 189 | + */ | |
| 190 | + return apply_filters( 'bbp_display_shortcode', $output, $query_name ); | |
| 191 | + } | |
| 192 | + | |
| 193 | + /** Forum shortcodes ******************************************************/ | |
| 194 | + | |
| 184 | 195 | /** |
| 185 | - * Filters the contents of the output buffer before returning. | |
| 196 | + * Display an index of all visible root level forums in an output buffer | |
| 197 | + * and return to ensure that post/page contents are displayed first. | |
| 186 | 198 | * |
| 187 | - * @since 2.0.0 bbPress (r3079) | |
| 199 | + * @since 2.0.0 bbPress (r3031) | |
| 188 | 200 | * |
| 189 | - * @param string $output The contents of the output buffer. | |
| 190 | - * @param string $query_name The query name used for this output. | |
| 201 | + * @return string | |
| 191 | 202 | */ |
| 192 | - return apply_filters( 'bbp_display_shortcode', $output, $query_name ); | |
| 193 | - } | |
| 203 | + public function display_forum_index() { | |
| 194 | 204 | |
| 195 | - /** Forum shortcodes ******************************************************/ | |
| 205 | + // Unset globals | |
| 206 | + $this->unset_globals(); | |
| 196 | 207 | |
| 197 | - /** | |
| 198 | - * Display an index of all visible root level forums in an output buffer | |
| 199 | - * and return to ensure that post/page contents are displayed first. | |
| 200 | - * | |
| 201 | - * @since 2.0.0 bbPress (r3031) | |
| 202 | - * | |
| 203 | - * @return string | |
| 204 | - */ | |
| 205 | - public function display_forum_index() { | |
| 208 | + // Start output buffer | |
| 209 | + $this->start( 'bbp_forum_archive' ); | |
| 206 | 210 | |
| 207 | - // Unset globals | |
| 208 | - $this->unset_globals(); | |
| 211 | + bbp_get_template_part( 'content', 'archive-forum' ); | |
| 209 | 212 | |
| 210 | - // Start output buffer | |
| 211 | - $this->start( 'bbp_forum_archive' ); | |
| 213 | + // Return contents of output buffer | |
| 214 | + return $this->end(); | |
| 215 | + } | |
| 212 | 216 | |
| 213 | - bbp_get_template_part( 'content', 'archive-forum' ); | |
| 217 | + /** | |
| 218 | + * Display the contents of a specific forum ID in an output buffer | |
| 219 | + * and return to ensure that post/page contents are displayed first. | |
| 220 | + * | |
| 221 | + * @since 2.0.0 bbPress (r3031) | |
| 222 | + * | |
| 223 | + * @param array $attr | |
| 224 | + * @param string $content | |
| 225 | + * @return string | |
| 226 | + */ | |
| 227 | + public function display_forum( $attr, $content = '' ) { | |
| 214 | 228 | |
| 215 | - // Return contents of output buffer | |
| 216 | - return $this->end(); | |
| 217 | - } | |
| 229 | + // Sanity check required info | |
| 230 | + if ( ! empty( $content ) || ( empty( $attr['id'] ) || ! is_numeric( $attr['id'] ) ) ) { | |
| 231 | + return $content; | |
| 232 | + } | |
| 218 | 233 | |
| 219 | - /** | |
| 220 | - * Display the contents of a specific forum ID in an output buffer | |
| 221 | - * and return to ensure that post/page contents are displayed first. | |
| 222 | - * | |
| 223 | - * @since 2.0.0 bbPress (r3031) | |
| 224 | - * | |
| 225 | - * @param array $attr | |
| 226 | - * @param string $content | |
| 227 | - * @return string | |
| 228 | - */ | |
| 229 | - public function display_forum( $attr, $content = '' ) { | |
| 234 | + // Set passed attribute to $forum_id for clarity | |
| 235 | + $forum_id = bbpress()->current_forum_id = $attr['id']; | |
| 230 | 236 | |
| 231 | - // Sanity check required info | |
| 232 | - if ( ! empty( $content ) || ( empty( $attr['id'] ) || ! is_numeric( $attr['id'] ) ) ) { | |
| 233 | - return $content; | |
| 234 | - } | |
| 237 | + // Bail if ID passed is not a forum | |
| 238 | + if ( ! bbp_is_forum( $forum_id ) ) { | |
| 239 | + return $content; | |
| 240 | + } | |
| 235 | 241 | |
| 236 | - // Set passed attribute to $forum_id for clarity | |
| 237 | - $forum_id = bbpress()->current_forum_id = $attr['id']; | |
| 242 | + // Start output buffer | |
| 243 | + $this->start( 'bbp_single_forum' ); | |
| 238 | 244 | |
| 239 | - // Bail if ID passed is not a forum | |
| 240 | - if ( ! bbp_is_forum( $forum_id ) ) { | |
| 241 | - return $content; | |
| 242 | - } | |
| 245 | + // Check forum caps | |
| 246 | + if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) { | |
| 247 | + bbp_get_template_part( 'content', 'single-forum' ); | |
| 243 | 248 | |
| 244 | - // Start output buffer | |
| 245 | - $this->start( 'bbp_single_forum' ); | |
| 249 | + // Forum is private and user does not have caps | |
| 250 | + } elseif ( bbp_is_forum_private( $forum_id, false ) ) { | |
| 251 | + bbp_get_template_part( 'feedback', 'no-access' ); | |
| 252 | + } | |
| 246 | 253 | |
| 247 | - // Check forum caps | |
| 248 | - if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) { | |
| 249 | - bbp_get_template_part( 'content', 'single-forum' ); | |
| 254 | + // Return contents of output buffer | |
| 255 | + return $this->end(); | |
| 256 | + } | |
| 250 | 257 | |
| 251 | - // Forum is private and user does not have caps | |
| 252 | - } elseif ( bbp_is_forum_private( $forum_id, false ) ) { | |
| 253 | - bbp_get_template_part( 'feedback', 'no-access' ); | |
| 254 | - } | |
| 258 | + /** | |
| 259 | + * Display the forum form in an output buffer and return to ensure | |
| 260 | + * post/page contents are displayed first. | |
| 261 | + * | |
| 262 | + * @since 2.1.0 bbPress (r3566) | |
| 263 | + */ | |
| 264 | + public function display_forum_form() { | |
| 255 | 265 | |
| 256 | - // Return contents of output buffer | |
| 257 | - return $this->end(); | |
| 258 | - } | |
| 266 | + // Start output buffer | |
| 267 | + $this->start( 'bbp_forum_form' ); | |
| 259 | 268 | |
| 260 | - /** | |
| 261 | - * Display the forum form in an output buffer and return to ensure | |
| 262 | - * post/page contents are displayed first. | |
| 263 | - * | |
| 264 | - * @since 2.1.0 bbPress (r3566) | |
| 265 | - */ | |
| 266 | - public function display_forum_form() { | |
| 269 | + // Output templates | |
| 270 | + bbp_get_template_part( 'form', 'forum' ); | |
| 267 | 271 | |
| 268 | - // Start output buffer | |
| 269 | - $this->start( 'bbp_forum_form' ); | |
| 272 | + // Return contents of output buffer | |
| 273 | + return $this->end(); | |
| 274 | + } | |
| 270 | 275 | |
| 271 | - // Output templates | |
| 272 | - bbp_get_template_part( 'form', 'forum' ); | |
| 276 | + /** Topic shortcodes ******************************************************/ | |
| 273 | 277 | |
| 274 | - // Return contents of output buffer | |
| 275 | - return $this->end(); | |
| 276 | - } | |
| 278 | + /** | |
| 279 | + * Display an index of all visible root level topics in an output buffer | |
| 280 | + * and return to ensure that post/page contents are displayed first. | |
| 281 | + * | |
| 282 | + * @since 2.0.0 bbPress (r3031) | |
| 283 | + * | |
| 284 | + * @return string | |
| 285 | + */ | |
| 286 | + public function display_topic_index() { | |
| 277 | 287 | |
| 278 | - /** Topic shortcodes ******************************************************/ | |
| 288 | + // Unset globals | |
| 289 | + $this->unset_globals(); | |
| 279 | 290 | |
| 280 | - /** | |
| 281 | - * Display an index of all visible root level topics in an output buffer | |
| 282 | - * and return to ensure that post/page contents are displayed first. | |
| 283 | - * | |
| 284 | - * @since 2.0.0 bbPress (r3031) | |
| 285 | - * | |
| 286 | - * @return string | |
| 287 | - */ | |
| 288 | - public function display_topic_index() { | |
| 291 | + // Filter the query | |
| 292 | + if ( ! bbp_is_topic_archive() ) { | |
| 293 | + add_filter( 'bbp_before_has_topics_parse_args', array( $this, 'display_topic_index_query' ) ); | |
| 294 | + } | |
| 289 | 295 | |
| 290 | - // Unset globals | |
| 291 | - $this->unset_globals(); | |
| 296 | + // Start output buffer | |
| 297 | + $this->start( 'bbp_topic_archive' ); | |
| 292 | 298 | |
| 293 | - // Filter the query | |
| 294 | - if ( ! bbp_is_topic_archive() ) { | |
| 295 | - add_filter( 'bbp_before_has_topics_parse_args', array( $this, 'display_topic_index_query' ) ); | |
| 296 | - } | |
| 299 | + // Output template | |
| 300 | + bbp_get_template_part( 'content', 'archive-topic' ); | |
| 297 | 301 | |
| 298 | - // Start output buffer | |
| 299 | - $this->start( 'bbp_topic_archive' ); | |
| 302 | + // Return contents of output buffer | |
| 303 | + return $this->end(); | |
| 304 | + } | |
| 300 | 305 | |
| 301 | - // Output template | |
| 302 | - bbp_get_template_part( 'content', 'archive-topic' ); | |
| 306 | + /** | |
| 307 | + * Display the contents of a specific topic ID in an output buffer | |
| 308 | + * and return to ensure that post/page contents are displayed first. | |
| 309 | + * | |
| 310 | + * @since 2.0.0 bbPress (r3031) | |
| 311 | + * | |
| 312 | + * @param array $attr | |
| 313 | + * @param string $content | |
| 314 | + * @return string | |
| 315 | + */ | |
| 316 | + public function display_topic( $attr, $content = '' ) { | |
| 303 | 317 | |
| 304 | - // Return contents of output buffer | |
| 305 | - return $this->end(); | |
| 306 | - } | |
| 318 | + // Sanity check required info | |
| 319 | + if ( ! empty( $content ) || ( empty( $attr['id'] ) || ! is_numeric( $attr['id'] ) ) ) { | |
| 320 | + return $content; | |
| 321 | + } | |
| 307 | 322 | |
| 308 | - /** | |
| 309 | - * Display the contents of a specific topic ID in an output buffer | |
| 310 | - * and return to ensure that post/page contents are displayed first. | |
| 311 | - * | |
| 312 | - * @since 2.0.0 bbPress (r3031) | |
| 313 | - * | |
| 314 | - * @param array $attr | |
| 315 | - * @param string $content | |
| 316 | - * @return string | |
| 317 | - */ | |
| 318 | - public function display_topic( $attr, $content = '' ) { | |
| 323 | + // Unset globals | |
| 324 | + $this->unset_globals(); | |
| 319 | 325 | |
| 320 | - // Sanity check required info | |
| 321 | - if ( ! empty( $content ) || ( empty( $attr['id'] ) || ! is_numeric( $attr['id'] ) ) ) { | |
| 322 | - return $content; | |
| 323 | - } | |
| 326 | + // Set passed attribute to $forum_id for clarity | |
| 327 | + $topic_id = bbpress()->current_topic_id = $attr['id']; | |
| 328 | + $forum_id = bbp_get_topic_forum_id( $topic_id ); | |
| 324 | 329 | |
| 325 | - // Unset globals | |
| 326 | - $this->unset_globals(); | |
| 330 | + // Bail if ID passed is not a topic | |
| 331 | + if ( ! bbp_is_topic( $topic_id ) ) { | |
| 332 | + return $content; | |
| 333 | + } | |
| 327 | 334 | |
| 328 | - // Set passed attribute to $forum_id for clarity | |
| 329 | - $topic_id = bbpress()->current_topic_id = $attr['id']; | |
| 330 | - $forum_id = bbp_get_topic_forum_id( $topic_id ); | |
| 335 | + // Reset the queries if not in theme compat | |
| 336 | + if ( ! bbp_is_theme_compat_active() ) { | |
| 331 | 337 | |
| 332 | - // Bail if ID passed is not a topic | |
| 333 | - if ( ! bbp_is_topic( $topic_id ) ) { | |
| 334 | - return $content; | |
| 335 | - } | |
| 338 | + $bbp = bbpress(); | |
| 336 | 339 | |
| 337 | - // Reset the queries if not in theme compat | |
| 338 | - if ( ! bbp_is_theme_compat_active() ) { | |
| 340 | + // Reset necessary forum_query attributes for topics loop to function | |
| 341 | + $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); | |
| 342 | + $bbp->forum_query->in_the_loop = true; | |
| 343 | + $bbp->forum_query->post = get_post( $forum_id ); | |
| 339 | 344 | |
| 340 | - $bbp = bbpress(); | |
| 345 | + // Reset necessary topic_query attributes for topics loop to function | |
| 346 | + $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type(); | |
| 347 | + $bbp->topic_query->in_the_loop = true; | |
| 348 | + $bbp->topic_query->post = get_post( $topic_id ); | |
| 349 | + } | |
| 341 | 350 | |
| 342 | - // Reset necessary forum_query attributes for topics loop to function | |
| 343 | - $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); | |
| 344 | - $bbp->forum_query->in_the_loop = true; | |
| 345 | - $bbp->forum_query->post = get_post( $forum_id ); | |
| 351 | + // Start output buffer | |
| 352 | + $this->start( 'bbp_single_topic' ); | |
| 346 | 353 | |
| 347 | - // Reset necessary topic_query attributes for topics loop to function | |
| 348 | - $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type(); | |
| 349 | - $bbp->topic_query->in_the_loop = true; | |
| 350 | - $bbp->topic_query->post = get_post( $topic_id ); | |
| 351 | - } | |
| 354 | + // Check forum caps | |
| 355 | + if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) { | |
| 356 | + bbp_get_template_part( 'content', 'single-topic' ); | |
| 352 | 357 | |
| 353 | - // Start output buffer | |
| 354 | - $this->start( 'bbp_single_topic' ); | |
| 358 | + // Forum is private and user does not have caps | |
| 359 | + } elseif ( bbp_is_forum_private( $forum_id, false ) ) { | |
| 360 | + bbp_get_template_part( 'feedback', 'no-access' ); | |
| 361 | + } | |
| 355 | 362 | |
| 356 | - // Check forum caps | |
| 357 | - if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) { | |
| 358 | - bbp_get_template_part( 'content', 'single-topic' ); | |
| 363 | + // Return contents of output buffer | |
| 364 | + return $this->end(); | |
| 365 | + } | |
| 359 | 366 | |
| 360 | - // Forum is private and user does not have caps | |
| 361 | - } elseif ( bbp_is_forum_private( $forum_id, false ) ) { | |
| 362 | - bbp_get_template_part( 'feedback', 'no-access' ); | |
| 363 | - } | |
| 367 | + /** | |
| 368 | + * Display the topic form in an output buffer and return to ensure | |
| 369 | + * post/page contents are displayed first. | |
| 370 | + * | |
| 371 | + * Supports 'forum_id' attribute to display the topic form for a particular | |
| 372 | + * forum. This currently has styling issues from not being wrapped in | |
| 373 | + * <div id="bbpress-forums" class="bbpress-wrapper"></div> which will need to be sorted out later. | |
| 374 | + * | |
| 375 | + * @since 2.0.0 bbPress (r3031) | |
| 376 | + * | |
| 377 | + * @param array $attr | |
| 378 | + * @param string $content | |
| 379 | + * @return string | |
| 380 | + */ | |
| 381 | + public function display_topic_form( $attr = array(), $content = '' ) { | |
| 364 | 382 | |
| 365 | - // Return contents of output buffer | |
| 366 | - return $this->end(); | |
| 367 | - } | |
| 383 | + // Sanity check supplied info | |
| 384 | + if ( ! empty( $content ) || ( ! empty( $attr['forum_id'] ) && ( ! is_numeric( $attr['forum_id'] ) || ! bbp_is_forum( $attr['forum_id'] ) ) ) ) { | |
| 385 | + return $content; | |
| 386 | + } | |
| 368 | 387 | |
| 369 | - /** | |
| 370 | - * Display the topic form in an output buffer and return to ensure | |
| 371 | - * post/page contents are displayed first. | |
| 372 | - * | |
| 373 | - * Supports 'forum_id' attribute to display the topic form for a particular | |
| 374 | - * forum. This currently has styling issues from not being wrapped in | |
| 375 | - * <div id="bbpress-forums" class="bbpress-wrapper"></div> which will need to be sorted out later. | |
| 376 | - * | |
| 377 | - * @since 2.0.0 bbPress (r3031) | |
| 378 | - * | |
| 379 | - * @param array $attr | |
| 380 | - * @param string $content | |
| 381 | - * @return string | |
| 382 | - */ | |
| 383 | - public function display_topic_form( $attr = array(), $content = '' ) { | |
| 388 | + // Unset globals | |
| 389 | + $this->unset_globals(); | |
| 384 | 390 | |
| 385 | - // Sanity check supplied info | |
| 386 | - if ( ! empty( $content ) || ( ! empty( $attr['forum_id'] ) && ( ! is_numeric( $attr['forum_id'] ) || ! bbp_is_forum( $attr['forum_id'] ) ) ) ) { | |
| 387 | - return $content; | |
| 388 | - } | |
| 391 | + // If forum id is set, use the 'bbp_single_forum' query name | |
| 392 | + if ( ! empty( $attr['forum_id'] ) ) { | |
| 389 | 393 | |
| 390 | - // Unset globals | |
| 391 | - $this->unset_globals(); | |
| 394 | + // Set the global current_forum_id for future requests | |
| 395 | + bbpress()->current_forum_id = $forum_id = bbp_get_forum_id( $attr['forum_id'] ); | |
| 392 | 396 | |
| 393 | - // If forum id is set, use the 'bbp_single_forum' query name | |
| 394 | - if ( ! empty( $attr['forum_id'] ) ) { | |
| 397 | + // Start output buffer | |
| 398 | + $this->start( 'bbp_single_forum' ); | |
| 395 | 399 | |
| 396 | - // Set the global current_forum_id for future requests | |
| 397 | - bbpress()->current_forum_id = $forum_id = bbp_get_forum_id( $attr['forum_id'] ); | |
| 400 | + // No forum id was passed | |
| 401 | + } else { | |
| 398 | 402 | |
| 399 | - // Start output buffer | |
| 400 | - $this->start( 'bbp_single_forum' ); | |
| 403 | + // Set the $forum_id variable to satisfy checks below | |
| 404 | + $forum_id = 0; | |
| 401 | 405 | |
| 402 | - // No forum id was passed | |
| 403 | - } else { | |
| 406 | + // Start output buffer | |
| 407 | + $this->start( 'bbp_topic_form' ); | |
| 408 | + } | |
| 404 | 409 | |
| 405 | - // Set the $forum_id variable to satisfy checks below | |
| 406 | - $forum_id = 0; | |
| 410 | + // If the forum id is set, check forum caps else display normal topic form | |
| 411 | + if ( empty( $forum_id ) || bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) { | |
| 412 | + bbp_get_template_part( 'form', 'topic' ); | |
| 407 | 413 | |
| 408 | - // Start output buffer | |
| 409 | - $this->start( 'bbp_topic_form' ); | |
| 410 | - } | |
| 414 | + // Forum is private and user does not have caps | |
| 415 | + } elseif ( bbp_is_forum_private( $forum_id, false ) ) { | |
| 416 | + bbp_get_template_part( 'feedback', 'no-access' ); | |
| 417 | + } | |
| 411 | 418 | |
| 412 | - // If the forum id is set, check forum caps else display normal topic form | |
| 413 | - if ( empty( $forum_id ) || bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) { | |
| 414 | - bbp_get_template_part( 'form', 'topic' ); | |
| 419 | + // Return contents of output buffer | |
| 420 | + return $this->end(); | |
| 421 | + } | |
| 415 | 422 | |
| 416 | - // Forum is private and user does not have caps | |
| 417 | - } elseif ( bbp_is_forum_private( $forum_id, false ) ) { | |
| 418 | - bbp_get_template_part( 'feedback', 'no-access' ); | |
| 419 | - } | |
| 423 | + /** Replies ***************************************************************/ | |
| 420 | 424 | |
| 421 | - // Return contents of output buffer | |
| 422 | - return $this->end(); | |
| 423 | - } | |
| 425 | + /** | |
| 426 | + * Display the contents of a specific reply ID in an output buffer | |
| 427 | + * and return to ensure that post/page contents are displayed first. | |
| 428 | + * | |
| 429 | + * @since 2.0.0 bbPress (r3031) | |
| 430 | + * | |
| 431 | + * @param array $attr | |
| 432 | + * @param string $content | |
| 433 | + * @return string | |
| 434 | + */ | |
| 435 | + public function display_reply( $attr, $content = '' ) { | |
| 424 | 436 | |
| 425 | - /** Replies ***************************************************************/ | |
| 437 | + // Sanity check required info | |
| 438 | + if ( ! empty( $content ) || ( empty( $attr['id'] ) || ! is_numeric( $attr['id'] ) ) ) { | |
| 439 | + return $content; | |
| 440 | + } | |
| 426 | 441 | |
| 427 | - /** | |
| 428 | - * Display the contents of a specific reply ID in an output buffer | |
| 429 | - * and return to ensure that post/page contents are displayed first. | |
| 430 | - * | |
| 431 | - * @since 2.0.0 bbPress (r3031) | |
| 432 | - * | |
| 433 | - * @param array $attr | |
| 434 | - * @param string $content | |
| 435 | - * @return string | |
| 436 | - */ | |
| 437 | - public function display_reply( $attr, $content = '' ) { | |
| 442 | + // Unset globals | |
| 443 | + $this->unset_globals(); | |
| 438 | 444 | |
| 439 | - // Sanity check required info | |
| 440 | - if ( ! empty( $content ) || ( empty( $attr['id'] ) || ! is_numeric( $attr['id'] ) ) ) { | |
| 441 | - return $content; | |
| 442 | - } | |
| 445 | + // Set passed attribute to $reply_id for clarity | |
| 446 | + $reply_id = bbpress()->current_reply_id = $attr['id']; | |
| 447 | + $forum_id = bbp_get_reply_forum_id( $reply_id ); | |
| 443 | 448 | |
| 444 | - // Unset globals | |
| 445 | - $this->unset_globals(); | |
| 449 | + // Bail if ID passed is not a reply | |
| 450 | + if ( ! bbp_is_reply( $reply_id ) ) { | |
| 451 | + return $content; | |
| 452 | + } | |
| 446 | 453 | |
| 447 | - // Set passed attribute to $reply_id for clarity | |
| 448 | - $reply_id = bbpress()->current_reply_id = $attr['id']; | |
| 449 | - $forum_id = bbp_get_reply_forum_id( $reply_id ); | |
| 454 | + // Reset the queries if not in theme compat | |
| 455 | + if ( ! bbp_is_theme_compat_active() ) { | |
| 450 | 456 | |
| 451 | - // Bail if ID passed is not a reply | |
| 452 | - if ( ! bbp_is_reply( $reply_id ) ) { | |
| 453 | - return $content; | |
| 454 | - } | |
| 457 | + $bbp = bbpress(); | |
| 455 | 458 | |
| 456 | - // Reset the queries if not in theme compat | |
| 457 | - if ( ! bbp_is_theme_compat_active() ) { | |
| 459 | + // Reset necessary forum_query attributes for reply loop to function | |
| 460 | + $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); | |
| 461 | + $bbp->forum_query->in_the_loop = true; | |
| 462 | + $bbp->forum_query->post = get_post( $forum_id ); | |
| 458 | 463 | |
| 459 | - $bbp = bbpress(); | |
| 464 | + // Reset necessary reply_query attributes for reply loop to function | |
| 465 | + $bbp->reply_query->query_vars['post_type'] = bbp_get_reply_post_type(); | |
| 466 | + $bbp->reply_query->in_the_loop = true; | |
| 467 | + $bbp->reply_query->post = get_post( $reply_id ); | |
| 468 | + } | |
| 460 | 469 | |
| 461 | - // Reset necessary forum_query attributes for reply loop to function | |
| 462 | - $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); | |
| 463 | - $bbp->forum_query->in_the_loop = true; | |
| 464 | - $bbp->forum_query->post = get_post( $forum_id ); | |
| 470 | + // Start output buffer | |
| 471 | + $this->start( 'bbp_single_reply' ); | |
| 465 | 472 | |
| 466 | - // Reset necessary reply_query attributes for reply loop to function | |
| 467 | - $bbp->reply_query->query_vars['post_type'] = bbp_get_reply_post_type(); | |
| 468 | - $bbp->reply_query->in_the_loop = true; | |
| 469 | - $bbp->reply_query->post = get_post( $reply_id ); | |
| 470 | - } | |
| 473 | + // Check forum caps | |
| 474 | + if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) { | |
| 475 | + bbp_get_template_part( 'content', 'single-reply' ); | |
| 471 | 476 | |
| 472 | - // Start output buffer | |
| 473 | - $this->start( 'bbp_single_reply' ); | |
| 477 | + // Forum is private and user does not have caps | |
| 478 | + } elseif ( bbp_is_forum_private( $forum_id, false ) ) { | |
| 479 | + bbp_get_template_part( 'feedback', 'no-access' ); | |
| 480 | + } | |
| 474 | 481 | |
| 475 | - // Check forum caps | |
| 476 | - if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) { | |
| 477 | - bbp_get_template_part( 'content', 'single-reply' ); | |
| 482 | + // Return contents of output buffer | |
| 483 | + return $this->end(); | |
| 484 | + } | |
| 478 | 485 | |
| 479 | - // Forum is private and user does not have caps | |
| 480 | - } elseif ( bbp_is_forum_private( $forum_id, false ) ) { | |
| 481 | - bbp_get_template_part( 'feedback', 'no-access' ); | |
| 482 | - } | |
| 486 | + /** | |
| 487 | + * Display the reply form in an output buffer and return to ensure | |
| 488 | + * post/page contents are displayed first. | |
| 489 | + * | |
| 490 | + * @since 2.0.0 bbPress (r3031) | |
| 491 | + */ | |
| 492 | + public function display_reply_form() { | |
| 483 | 493 | |
| 484 | - // Return contents of output buffer | |
| 485 | - return $this->end(); | |
| 486 | - } | |
| 494 | + // Start output buffer | |
| 495 | + $this->start( 'bbp_reply_form' ); | |
| 487 | 496 | |
| 488 | - /** | |
| 489 | - * Display the reply form in an output buffer and return to ensure | |
| 490 | - * post/page contents are displayed first. | |
| 491 | - * | |
| 492 | - * @since 2.0.0 bbPress (r3031) | |
| 493 | - */ | |
| 494 | - public function display_reply_form() { | |
| 497 | + // Output templates | |
| 498 | + bbp_get_template_part( 'form', 'reply' ); | |
| 495 | 499 | |
| 496 | - // Start output buffer | |
| 497 | - $this->start( 'bbp_reply_form' ); | |
| 500 | + // Return contents of output buffer | |
| 501 | + return $this->end(); | |
| 502 | + } | |
| 498 | 503 | |
| 499 | - // Output templates | |
| 500 | - bbp_get_template_part( 'form', 'reply' ); | |
| 504 | + /** Topic Tags ************************************************************/ | |
| 501 | 505 | |
| 502 | - // Return contents of output buffer | |
| 503 | - return $this->end(); | |
| 504 | - } | |
| 506 | + /** | |
| 507 | + * Display a tag cloud of all topic tags in an output buffer and return to | |
| 508 | + * ensure that post/page contents are displayed first. | |
| 509 | + * | |
| 510 | + * @since 2.0.0 bbPress (r3110) | |
| 511 | + * | |
| 512 | + * @return string | |
| 513 | + */ | |
| 514 | + public function display_topic_tags() { | |
| 505 | 515 | |
| 506 | - /** Topic Tags ************************************************************/ | |
| 516 | + // Unset globals | |
| 517 | + $this->unset_globals(); | |
| 507 | 518 | |
| 508 | - /** | |
| 509 | - * Display a tag cloud of all topic tags in an output buffer and return to | |
| 510 | - * ensure that post/page contents are displayed first. | |
| 511 | - * | |
| 512 | - * @since 2.0.0 bbPress (r3110) | |
| 513 | - * | |
| 514 | - * @return string | |
| 515 | - */ | |
| 516 | - public function display_topic_tags() { | |
| 519 | + // Start output buffer | |
| 520 | + $this->start( 'bbp_topic_tags' ); | |
| 517 | 521 | |
| 518 | - // Unset globals | |
| 519 | - $this->unset_globals(); | |
| 522 | + // Output the topic tags | |
| 523 | + wp_tag_cloud( | |
| 524 | + array( | |
| 525 | + 'smallest' => 9, | |
| 526 | + 'largest' => 38, | |
| 527 | + 'number' => 80, | |
| 528 | + 'taxonomy' => bbp_get_topic_tag_tax_id() | |
| 529 | + ) | |
| 530 | + ); | |
| 520 | 531 | |
| 521 | - // Start output buffer | |
| 522 | - $this->start( 'bbp_topic_tags' ); | |
| 532 | + // Return contents of output buffer | |
| 533 | + return $this->end(); | |
| 534 | + } | |
| 523 | 535 | |
| 524 | - // Output the topic tags | |
| 525 | - wp_tag_cloud( | |
| 526 | - array( | |
| 527 | - 'smallest' => 9, | |
| 528 | - 'largest' => 38, | |
| 529 | - 'number' => 80, | |
| 530 | - 'taxonomy' => bbp_get_topic_tag_tax_id() | |
| 531 | - ) | |
| 532 | - ); | |
| 536 | + /** | |
| 537 | + * Display the contents of a specific topic tag in an output buffer | |
| 538 | + * and return to ensure that post/page contents are displayed first. | |
| 539 | + * | |
| 540 | + * @since 2.0.0 bbPress (r3110) | |
| 541 | + * | |
| 542 | + * @param array $attr | |
| 543 | + * @param string $content | |
| 544 | + * @return string | |
| 545 | + */ | |
| 546 | + public function display_topics_of_tag( $attr, $content = '' ) { | |
| 533 | 547 | |
| 534 | - // Return contents of output buffer | |
| 535 | - return $this->end(); | |
| 536 | - } | |
| 548 | + // Sanity check required info | |
| 549 | + if ( ! empty( $content ) || ( empty( $attr['id'] ) || ! is_numeric( $attr['id'] ) ) ) { | |
| 550 | + return $content; | |
| 551 | + } | |
| 537 | 552 | |
| 538 | - /** | |
| 539 | - * Display the contents of a specific topic tag in an output buffer | |
| 540 | - * and return to ensure that post/page contents are displayed first. | |
| 541 | - * | |
| 542 | - * @since 2.0.0 bbPress (r3110) | |
| 543 | - * | |
| 544 | - * @param array $attr | |
| 545 | - * @param string $content | |
| 546 | - * @return string | |
| 547 | - */ | |
| 548 | - public function display_topics_of_tag( $attr, $content = '' ) { | |
| 553 | + // Unset globals | |
| 554 | + $this->unset_globals(); | |
| 549 | 555 | |
| 550 | - // Sanity check required info | |
| 551 | - if ( ! empty( $content ) || ( empty( $attr['id'] ) || ! is_numeric( $attr['id'] ) ) ) { | |
| 552 | - return $content; | |
| 553 | - } | |
| 556 | + // Filter the query | |
| 557 | + if ( ! bbp_is_topic_tag() ) { | |
| 558 | + add_filter( 'bbp_before_has_topics_parse_args', array( $this, 'display_topics_of_tag_query' ) ); | |
| 559 | + } | |
| 554 | 560 | |
| 555 | - // Unset globals | |
| 556 | - $this->unset_globals(); | |
| 561 | + // Start output buffer | |
| 562 | + $this->start( 'bbp_topic_tag' ); | |
| 557 | 563 | |
| 558 | - // Filter the query | |
| 559 | - if ( ! bbp_is_topic_tag() ) { | |
| 560 | - add_filter( 'bbp_before_has_topics_parse_args', array( $this, 'display_topics_of_tag_query' ) ); | |
| 561 | - } | |
| 564 | + // Set passed attribute to $ag_id for clarity | |
| 565 | + bbpress()->current_topic_tag_id = $tag_id = $attr['id']; | |
| 562 | 566 | |
| 563 | - // Start output buffer | |
| 564 | - $this->start( 'bbp_topic_tag' ); | |
| 567 | + // Output template | |
| 568 | + bbp_get_template_part( 'content', 'archive-topic' ); | |
| 565 | 569 | |
| 566 | - // Set passed attribute to $ag_id for clarity | |
| 567 | - bbpress()->current_topic_tag_id = $tag_id = $attr['id']; | |
| 570 | + // Return contents of output buffer | |
| 571 | + return $this->end(); | |
| 572 | + } | |
| 568 | 573 | |
| 569 | - // Output template | |
| 570 | - bbp_get_template_part( 'content', 'archive-topic' ); | |
| 574 | + /** | |
| 575 | + * Display the contents of a specific topic tag in an output buffer | |
| 576 | + * and return to ensure that post/page contents are displayed first. | |
| 577 | + * | |
| 578 | + * @since 2.0.0 bbPress (r3346) | |
| 579 | + * | |
| 580 | + * @return string | |
| 581 | + */ | |
| 582 | + public function display_topic_tag_form() { | |
| 571 | 583 | |
| 572 | - // Return contents of output buffer | |
| 573 | - return $this->end(); | |
| 574 | - } | |
| 584 | + // Unset globals | |
| 585 | + $this->unset_globals(); | |
| 575 | 586 | |
| 576 | - /** | |
| 577 | - * Display the contents of a specific topic tag in an output buffer | |
| 578 | - * and return to ensure that post/page contents are displayed first. | |
| 579 | - * | |
| 580 | - * @since 2.0.0 bbPress (r3346) | |
| 581 | - * | |
| 582 | - * @return string | |
| 583 | - */ | |
| 584 | - public function display_topic_tag_form() { | |
| 587 | + // Start output buffer | |
| 588 | + $this->start( 'bbp_topic_tag_edit' ); | |
| 585 | 589 | |
| 586 | - // Unset globals | |
| 587 | - $this->unset_globals(); | |
| 590 | + // Output template | |
| 591 | + bbp_get_template_part( 'content', 'topic-tag-edit' ); | |
| 588 | 592 | |
| 589 | - // Start output buffer | |
| 590 | - $this->start( 'bbp_topic_tag_edit' ); | |
| 593 | + // Return contents of output buffer | |
| 594 | + return $this->end(); | |
| 595 | + } | |
| 591 | 596 | |
| 592 | - // Output template | |
| 593 | - bbp_get_template_part( 'content', 'topic-tag-edit' ); | |
| 597 | + /** Views *****************************************************************/ | |
| 594 | 598 | |
| 595 | - // Return contents of output buffer | |
| 596 | - return $this->end(); | |
| 597 | - } | |
| 599 | + /** | |
| 600 | + * Display the contents of a specific view in an output buffer and return to | |
| 601 | + * ensure that post/page contents are displayed first. | |
| 602 | + * | |
| 603 | + * @since 2.0.0 bbPress (r3031) | |
| 604 | + * | |
| 605 | + * @param array $attr | |
| 606 | + * @param string $content | |
| 607 | + * @return string | |
| 608 | + */ | |
| 609 | + public function display_view( $attr, $content = '' ) { | |
| 598 | 610 | |
| 599 | - /** Views *****************************************************************/ | |
| 611 | + // Sanity check required info | |
| 612 | + if ( empty( $attr['id'] ) ) { | |
| 613 | + return $content; | |
| 614 | + } | |
| 600 | 615 | |
| 601 | - /** | |
| 602 | - * Display the contents of a specific view in an output buffer and return to | |
| 603 | - * ensure that post/page contents are displayed first. | |
| 604 | - * | |
| 605 | - * @since 2.0.0 bbPress (r3031) | |
| 606 | - * | |
| 607 | - * @param array $attr | |
| 608 | - * @param string $content | |
| 609 | - * @return string | |
| 610 | - */ | |
| 611 | - public function display_view( $attr, $content = '' ) { | |
| 616 | + // Set passed attribute to $view_id for clarity | |
| 617 | + $view_id = $attr['id']; | |
| 612 | 618 | |
| 613 | - // Sanity check required info | |
| 614 | - if ( empty( $attr['id'] ) ) { | |
| 615 | - return $content; | |
| 616 | - } | |
| 619 | + // Start output buffer | |
| 620 | + $this->start( 'bbp_single_view' ); | |
| 617 | 621 | |
| 618 | - // Set passed attribute to $view_id for clarity | |
| 619 | - $view_id = $attr['id']; | |
| 622 | + // Unset globals | |
| 623 | + $this->unset_globals(); | |
| 620 | 624 | |
| 621 | - // Start output buffer | |
| 622 | - $this->start( 'bbp_single_view' ); | |
| 625 | + // Set the current view ID | |
| 626 | + bbpress()->current_view_id = $view_id; | |
| 623 | 627 | |
| 624 | - // Unset globals | |
| 625 | - $this->unset_globals(); | |
| 628 | + // Load the view | |
| 629 | + bbp_view_query( $view_id ); | |
| 626 | 630 | |
| 627 | - // Set the current view ID | |
| 628 | - bbpress()->current_view_id = $view_id; | |
| 631 | + // Output template | |
| 632 | + bbp_get_template_part( 'content', 'single-view' ); | |
| 629 | 633 | |
| 630 | - // Load the view | |
| 631 | - bbp_view_query( $view_id ); | |
| 634 | + // Return contents of output buffer | |
| 635 | + return $this->end(); | |
| 636 | + } | |
| 632 | 637 | |
| 633 | - // Output template | |
| 634 | - bbp_get_template_part( 'content', 'single-view' ); | |
| 638 | + /** Search ****************************************************************/ | |
| 635 | 639 | |
| 636 | - // Return contents of output buffer | |
| 637 | - return $this->end(); | |
| 638 | - } | |
| 640 | + /** | |
| 641 | + * Display the search form in an output buffer and return to ensure | |
| 642 | + * post/page contents are displayed first. | |
| 643 | + * | |
| 644 | + * @since 2.3.0 bbPress (r4585) | |
| 645 | + */ | |
| 646 | + public function display_search_form() { | |
| 639 | 647 | |
| 640 | - /** Search ****************************************************************/ | |
| 648 | + // Bail if search is disabled | |
| 649 | + if ( ! bbp_allow_search() ) { | |
| 650 | + return; | |
| 651 | + } | |
| 641 | 652 | |
| 642 | - /** | |
| 643 | - * Display the search form in an output buffer and return to ensure | |
| 644 | - * post/page contents are displayed first. | |
| 645 | - * | |
| 646 | - * @since 2.3.0 bbPress (r4585) | |
| 647 | - */ | |
| 648 | - public function display_search_form() { | |
| 653 | + // Start output buffer | |
| 654 | + $this->start( 'bbp_search_form' ); | |
| 649 | 655 | |
| 650 | - // Bail if search is disabled | |
| 651 | - if ( ! bbp_allow_search() ) { | |
| 652 | - return; | |
| 653 | - } | |
| 656 | + // Output templates | |
| 657 | + bbp_get_template_part( 'form', 'search' ); | |
| 654 | 658 | |
| 655 | - // Start output buffer | |
| 656 | - $this->start( 'bbp_search_form' ); | |
| 659 | + // Return contents of output buffer | |
| 660 | + return $this->end(); | |
| 661 | + } | |
| 657 | 662 | |
| 658 | - // Output templates | |
| 659 | - bbp_get_template_part( 'form', 'search' ); | |
| 663 | + /** | |
| 664 | + * Display the contents of search results in an output buffer and return to | |
| 665 | + * ensure that post/page contents are displayed first. | |
| 666 | + * | |
| 667 | + * @since 2.3.0 bbPress (r4579) | |
| 668 | + * | |
| 669 | + * @param array $attr | |
| 670 | + * @param string $content | |
| 671 | + */ | |
| 672 | + public function display_search( $attr, $content = '' ) { | |
| 660 | 673 | |
| 661 | - // Return contents of output buffer | |
| 662 | - return $this->end(); | |
| 663 | - } | |
| 674 | + // Sanity check required info | |
| 675 | + if ( ! empty( $content ) ) { | |
| 676 | + return $content; | |
| 677 | + } | |
| 664 | 678 | |
| 665 | - /** | |
| 666 | - * Display the contents of search results in an output buffer and return to | |
| 667 | - * ensure that post/page contents are displayed first. | |
| 668 | - * | |
| 669 | - * @since 2.3.0 bbPress (r4579) | |
| 670 | - * | |
| 671 | - * @param array $attr | |
| 672 | - * @param string $content | |
| 673 | - */ | |
| 674 | - public function display_search( $attr, $content = '' ) { | |
| 679 | + // Bail if search is disabled | |
| 680 | + if ( ! bbp_allow_search() ) { | |
| 681 | + return; | |
| 682 | + } | |
| 675 | 683 | |
| 676 | - // Sanity check required info | |
| 677 | - if ( ! empty( $content ) ) { | |
| 678 | - return $content; | |
| 679 | - } | |
| 684 | + // Trim search attribute if it's set | |
| 685 | + if ( isset( $attr['search'] ) ) { | |
| 686 | + $attr['search'] = trim( $attr['search'] ); | |
| 687 | + } | |
| 680 | 688 | |
| 681 | - // Bail if search is disabled | |
| 682 | - if ( ! bbp_allow_search() ) { | |
| 683 | - return; | |
| 684 | - } | |
| 685 | - | |
| 686 | - // Trim search attribute if it's set | |
| 687 | - if ( isset( $attr['search'] ) ) { | |
| 688 | - $attr['search'] = trim( $attr['search'] ); | |
| 689 | - } | |
| 690 | - | |
| 691 | - // Set passed attribute to $search_terms for clarity | |
| 692 | - $search_terms = empty( $attr['search'] ) | |
| 689 | + // Set passed attribute to $search_terms for clarity | |
| 690 | + $search_terms = empty( $attr['search'] ) | |
| 693 | 691 | ? bbp_get_search_terms() |
| 694 | 692 | : $attr['search']; |
| 695 | 693 | |
| 696 | - // Get the rewrite ID (one time, to avoid repeated calls) | |
| 697 | - $rewrite_id = bbp_get_search_rewrite_id(); | |
| 694 | + // Get the rewrite ID (one time, to avoid repeated calls) | |
| 695 | + $rewrite_id = bbp_get_search_rewrite_id(); | |
| 698 | 696 | |
| 699 | - // Unset globals | |
| 700 | - $this->unset_globals(); | |
| 697 | + // Unset globals | |
| 698 | + $this->unset_globals(); | |
| 701 | 699 | |
| 702 | - // Set terms for query | |
| 703 | - set_query_var( $rewrite_id, $search_terms ); | |
| 700 | + // Set terms for query | |
| 701 | + set_query_var( $rewrite_id, $search_terms ); | |
| 704 | 702 | |
| 705 | - // Start output buffer | |
| 706 | - $this->start( $rewrite_id ); | |
| 703 | + // Start output buffer | |
| 704 | + $this->start( $rewrite_id ); | |
| 707 | 705 | |
| 708 | - // Output template | |
| 709 | - bbp_get_template_part( 'content', 'search' ); | |
| 706 | + // Output template | |
| 707 | + bbp_get_template_part( 'content', 'search' ); | |
| 710 | 708 | |
| 711 | - // Return contents of output buffer | |
| 712 | - return $this->end(); | |
| 713 | - } | |
| 709 | + // Return contents of output buffer | |
| 710 | + return $this->end(); | |
| 711 | + } | |
| 714 | 712 | |
| 715 | - /** Account ***************************************************************/ | |
| 713 | + /** Account ***************************************************************/ | |
| 716 | 714 | |
| 717 | - /** | |
| 718 | - * Display a login form | |
| 719 | - * | |
| 720 | - * @since 2.0.0 bbPress (r3302) | |
| 721 | - * | |
| 722 | - * @return string | |
| 723 | - */ | |
| 724 | - public function display_login() { | |
| 715 | + /** | |
| 716 | + * Display a login form | |
| 717 | + * | |
| 718 | + * @since 2.0.0 bbPress (r3302) | |
| 719 | + * | |
| 720 | + * @return string | |
| 721 | + */ | |
| 722 | + public function display_login() { | |
| 725 | 723 | |
| 726 | - // Unset globals | |
| 727 | - $this->unset_globals(); | |
| 724 | + // Unset globals | |
| 725 | + $this->unset_globals(); | |
| 728 | 726 | |
| 729 | - // Start output buffer | |
| 730 | - $this->start( 'bbp_login' ); | |
| 727 | + // Start output buffer | |
| 728 | + $this->start( 'bbp_login' ); | |
| 731 | 729 | |
| 732 | - // Output templates | |
| 733 | - if ( ! is_user_logged_in() ) { | |
| 734 | - bbp_get_template_part( 'form', 'user-login' ); | |
| 735 | - } else { | |
| 736 | - bbp_get_template_part( 'feedback', 'logged-in' ); | |
| 737 | - } | |
| 730 | + // Output templates | |
| 731 | + if ( ! is_user_logged_in() ) { | |
| 732 | + bbp_get_template_part( 'form', 'user-login' ); | |
| 733 | + } else { | |
| 734 | + bbp_get_template_part( 'feedback', 'logged-in' ); | |
| 735 | + } | |
| 738 | 736 | |
| 739 | - // Return contents of output buffer | |
| 740 | - return $this->end(); | |
| 741 | - } | |
| 737 | + // Return contents of output buffer | |
| 738 | + return $this->end(); | |
| 739 | + } | |
| 742 | 740 | |
| 743 | - /** | |
| 744 | - * Display a register form | |
| 745 | - * | |
| 746 | - * @since 2.0.0 bbPress (r3302) | |
| 747 | - * | |
| 748 | - * @return string | |
| 749 | - */ | |
| 750 | - public function display_register() { | |
| 741 | + /** | |
| 742 | + * Display a register form | |
| 743 | + * | |
| 744 | + * @since 2.0.0 bbPress (r3302) | |
| 745 | + * | |
| 746 | + * @return string | |
| 747 | + */ | |
| 748 | + public function display_register() { | |
| 751 | 749 | |
| 752 | - // Unset globals | |
| 753 | - $this->unset_globals(); | |
| 750 | + // Unset globals | |
| 751 | + $this->unset_globals(); | |
| 754 | 752 | |
| 755 | - // Start output buffer | |
| 756 | - $this->start( 'bbp_register' ); | |
| 753 | + // Start output buffer | |
| 754 | + $this->start( 'bbp_register' ); | |
| 757 | 755 | |
| 758 | - // Output templates | |
| 759 | - if ( ! is_user_logged_in() ) { | |
| 760 | - bbp_get_template_part( 'form', 'user-register' ); | |
| 761 | - } else { | |
| 762 | - bbp_get_template_part( 'feedback', 'logged-in' ); | |
| 763 | - } | |
| 756 | + // Output templates | |
| 757 | + if ( ! is_user_logged_in() ) { | |
| 758 | + bbp_get_template_part( 'form', 'user-register' ); | |
| 759 | + } else { | |
| 760 | + bbp_get_template_part( 'feedback', 'logged-in' ); | |
| 761 | + } | |
| 764 | 762 | |
| 765 | - // Return contents of output buffer | |
| 766 | - return $this->end(); | |
| 767 | - } | |
| 763 | + // Return contents of output buffer | |
| 764 | + return $this->end(); | |
| 765 | + } | |
| 768 | 766 | |
| 769 | - /** | |
| 770 | - * Display a lost password form | |
| 771 | - * | |
| 772 | - * @since 2.0.0 bbPress (r3302) | |
| 773 | - * | |
| 774 | - * @return string | |
| 775 | - */ | |
| 776 | - public function display_lost_pass() { | |
| 767 | + /** | |
| 768 | + * Display a lost password form | |
| 769 | + * | |
| 770 | + * @since 2.0.0 bbPress (r3302) | |
| 771 | + * | |
| 772 | + * @return string | |
| 773 | + */ | |
| 774 | + public function display_lost_pass() { | |
| 777 | 775 | |
| 778 | - // Unset globals | |
| 779 | - $this->unset_globals(); | |
| 776 | + // Unset globals | |
| 777 | + $this->unset_globals(); | |
| 780 | 778 | |
| 781 | - // Start output buffer | |
| 782 | - $this->start( 'bbp_lost_pass' ); | |
| 779 | + // Start output buffer | |
| 780 | + $this->start( 'bbp_lost_pass' ); | |
| 783 | 781 | |
| 784 | - // Output templates | |
| 785 | - if ( ! is_user_logged_in() ) { | |
| 786 | - bbp_get_template_part( 'form', 'user-lost-pass' ); | |
| 787 | - } else { | |
| 788 | - bbp_get_template_part( 'feedback', 'logged-in' ); | |
| 789 | - } | |
| 782 | + // Output templates | |
| 783 | + if ( ! is_user_logged_in() ) { | |
| 784 | + bbp_get_template_part( 'form', 'user-lost-pass' ); | |
| 785 | + } else { | |
| 786 | + bbp_get_template_part( 'feedback', 'logged-in' ); | |
| 787 | + } | |
| 790 | 788 | |
| 791 | - // Return contents of output buffer | |
| 792 | - return $this->end(); | |
| 793 | - } | |
| 789 | + // Return contents of output buffer | |
| 790 | + return $this->end(); | |
| 791 | + } | |
| 794 | 792 | |
| 795 | - /** Other *****************************************************************/ | |
| 793 | + /** Other *****************************************************************/ | |
| 796 | 794 | |
| 797 | - /** | |
| 798 | - * Display forum statistics | |
| 799 | - * | |
| 800 | - * @since 2.3.0 bbPress (r4509) | |
| 801 | - * | |
| 802 | - * @return string | |
| 803 | - */ | |
| 804 | - public function display_stats() { | |
| 795 | + /** | |
| 796 | + * Display forum statistics | |
| 797 | + * | |
| 798 | + * @since 2.3.0 bbPress (r4509) | |
| 799 | + * | |
| 800 | + * @return string | |
| 801 | + */ | |
| 802 | + public function display_stats() { | |
| 805 | 803 | |
| 806 | - // Unset globals | |
| 807 | - $this->unset_globals(); | |
| 804 | + // Unset globals | |
| 805 | + $this->unset_globals(); | |
| 808 | 806 | |
| 809 | - // Start output buffer | |
| 810 | - $this->start(); | |
| 807 | + // Start output buffer | |
| 808 | + $this->start(); | |
| 811 | 809 | |
| 812 | - // Output statistics | |
| 813 | - bbp_get_template_part( 'content', 'statistics' ); | |
| 810 | + // Output statistics | |
| 811 | + bbp_get_template_part( 'content', 'statistics' ); | |
| 814 | 812 | |
| 815 | - // Return contents of output buffer | |
| 816 | - return $this->end(); | |
| 817 | - } | |
| 813 | + // Return contents of output buffer | |
| 814 | + return $this->end(); | |
| 815 | + } | |
| 818 | 816 | |
| 819 | - /** | |
| 820 | - * Display a breadcrumb | |
| 821 | - * | |
| 822 | - * @since 2.0.0 bbPress (r3302) | |
| 823 | - * | |
| 824 | - * @return string | |
| 825 | - */ | |
| 826 | - public function display_breadcrumb() { | |
| 817 | + /** | |
| 818 | + * Display a breadcrumb | |
| 819 | + * | |
| 820 | + * @since 2.0.0 bbPress (r3302) | |
| 821 | + * | |
| 822 | + * @return string | |
| 823 | + */ | |
| 824 | + public function display_breadcrumb() { | |
| 827 | 825 | |
| 828 | - // Unset globals | |
| 829 | - $this->unset_globals(); | |
| 826 | + // Unset globals | |
| 827 | + $this->unset_globals(); | |
| 830 | 828 | |
| 831 | - // Start output buffer | |
| 832 | - $this->start(); | |
| 829 | + // Start output buffer | |
| 830 | + $this->start(); | |
| 833 | 831 | |
| 834 | - // Output breadcrumb | |
| 835 | - bbp_breadcrumb(); | |
| 832 | + // Output breadcrumb | |
| 833 | + bbp_breadcrumb(); | |
| 836 | 834 | |
| 837 | - // Return contents of output buffer | |
| 838 | - return $this->end(); | |
| 839 | - } | |
| 835 | + // Return contents of output buffer | |
| 836 | + return $this->end(); | |
| 837 | + } | |
| 840 | 838 | |
| 841 | - /** Query Filters *********************************************************/ | |
| 839 | + /** Query Filters *********************************************************/ | |
| 842 | 840 | |
| 843 | - /** | |
| 844 | - * Filter the query for the topic index | |
| 845 | - * | |
| 846 | - * @since 2.1.0 bbPress (r3637) | |
| 847 | - * | |
| 848 | - * @param array $args | |
| 849 | - * @return array | |
| 850 | - */ | |
| 851 | - public function display_topic_index_query( $args = array() ) { | |
| 852 | - $args['author'] = 0; | |
| 853 | - $args['show_stickies'] = true; | |
| 854 | - $args['order'] = 'DESC'; | |
| 855 | - return $args; | |
| 856 | - } | |
| 841 | + /** | |
| 842 | + * Filter the query for the topic index | |
| 843 | + * | |
| 844 | + * @since 2.1.0 bbPress (r3637) | |
| 845 | + * | |
| 846 | + * @param array $args | |
| 847 | + * @return array | |
| 848 | + */ | |
| 849 | + public function display_topic_index_query( $args = array() ) { | |
| 850 | + $args['author'] = 0; | |
| 851 | + $args['show_stickies'] = true; | |
| 852 | + $args['order'] = 'DESC'; | |
| 853 | + return $args; | |
| 854 | + } | |
| 857 | 855 | |
| 858 | - /** | |
| 859 | - * Filter the query for topic tags | |
| 860 | - * | |
| 861 | - * @since 2.1.0 bbPress (r3637) | |
| 862 | - * | |
| 863 | - * @param array $args | |
| 864 | - * @return array | |
| 865 | - */ | |
| 866 | - public function display_topics_of_tag_query( $args = array() ) { | |
| 867 | - $args['tax_query'] = array( | |
| 868 | - array( | |
| 869 | - 'taxonomy' => bbp_get_topic_tag_tax_id(), | |
| 870 | - 'field' => 'id', | |
| 871 | - 'terms' => bbpress()->current_topic_tag_id | |
| 872 | - ) | |
| 873 | - ); | |
| 856 | + /** | |
| 857 | + * Filter the query for topic tags | |
| 858 | + * | |
| 859 | + * @since 2.1.0 bbPress (r3637) | |
| 860 | + * | |
| 861 | + * @param array $args | |
| 862 | + * @return array | |
| 863 | + */ | |
| 864 | + public function display_topics_of_tag_query( $args = array() ) { | |
| 865 | + $args['tax_query'] = array( | |
| 866 | + array( | |
| 867 | + 'taxonomy' => bbp_get_topic_tag_tax_id(), | |
| 868 | + 'field' => 'id', | |
| 869 | + 'terms' => bbpress()->current_topic_tag_id | |
| 870 | + ) | |
| 871 | + ); | |
| 874 | 872 | |
| 875 | - return $args; | |
| 876 | - } | |
| 873 | + return $args; | |
| 874 | + } | |
| 877 | 875 | } |
| 878 | 876 | endif; |