| @@ -24,9 +24,9 @@ | ||
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Runs on bbPress activation |
| 27 | 27 | * |
| 28 | - * @since 2.0.0 bbPress (r2509) | |
| 28 | + * @since 2.0.0 bbPress (r2464) | |
| 29 | 29 | */ |
| 30 | 30 | function bbp_activation() { |
| 31 | 31 | do_action( 'bbp_activation' ); |
| 32 | 32 | } |
| @@ -33,9 +33,9 @@ | ||
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Runs on bbPress deactivation |
| 36 | 36 | * |
| 37 | - * @since 2.0.0 bbPress (r2509) | |
| 37 | + * @since 2.0.0 bbPress (r2464) | |
| 38 | 38 | */ |
| 39 | 39 | function bbp_deactivation() { |
| 40 | 40 | do_action( 'bbp_deactivation' ); |
| 41 | 41 | } |
| @@ -42,9 +42,9 @@ | ||
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * Runs when uninstalling bbPress |
| 45 | 45 | * |
| 46 | - * @since 2.0.0 bbPress (r2509) | |
| 46 | + * @since 2.0.0 bbPress (r2599) | |
| 47 | 47 | */ |
| 48 | 48 | function bbp_uninstall() { |
| 49 | 49 | do_action( 'bbp_uninstall' ); |
| 50 | 50 | } |
| @@ -98,9 +98,9 @@ | ||
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Register any objects before anything is initialized |
| 101 | 101 | * |
| 102 | - * @since 2.2.0 bbPress (r4180) | |
| 102 | + * @since 2.2.0 bbPress (r4181) | |
| 103 | 103 | */ |
| 104 | 104 | function bbp_register() { |
| 105 | 105 | do_action( 'bbp_register' ); |
| 106 | 106 | } |
| @@ -116,9 +116,9 @@ | ||
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * Initialize the bbPress REST API |
| 119 | 119 | * |
| 120 | - * @since 2.6.17 | |
| 120 | + * @since 2.6.17 bbPress (r7482) | |
| 121 | 121 | */ |
| 122 | 122 | function bbp_rest_api_init() { |
| 123 | 123 | do_action( 'bbp_rest_api_init' ); |
| 124 | 124 | } |
| @@ -125,9 +125,9 @@ | ||
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * Pass an XML-RPC request through bbPress. |
| 128 | 128 | * |
| 129 | - * @since 2.6.17 bbPress | |
| 129 | + * @since 2.6.17 bbPress (r7486) | |
| 130 | 130 | * |
| 131 | 131 | * @param string $method XML-RPC method name. |
| 132 | 132 | * @param array $args XML-RPC method arguments. |
| 133 | 133 | * @param wp_xmlrpc_server $server XML-RPC server instance. |
| @@ -149,9 +149,9 @@ | ||
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | 151 | * Initialize widgets |
| 152 | 152 | * |
| 153 | - * @since 2.0.0 bbPress (r3389) | |
| 153 | + * @since 2.0.0 bbPress (r3391) | |
| 154 | 154 | */ |
| 155 | 155 | function bbp_widgets_init() { |
| 156 | 156 | do_action( 'bbp_widgets_init' ); |
| 157 | 157 | } |
| @@ -161,9 +161,9 @@ | ||
| 161 | 161 | * |
| 162 | 162 | * @link https://bbpress.trac.wordpress.org/ticket/2309 |
| 163 | 163 | * @link https://core.trac.wordpress.org/ticket/24169 |
| 164 | 164 | * |
| 165 | - * @since 2.0.0 bbPress (r2695) | |
| 165 | + * @since 2.0.0 bbPress (r2697) | |
| 166 | 166 | */ |
| 167 | 167 | function bbp_setup_current_user() { |
| 168 | 168 | do_action( 'bbp_setup_current_user' ); |
| 169 | 169 | } |
| @@ -170,9 +170,9 @@ | ||
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | 172 | * Setup the user engagements strategy |
| 173 | 173 | * |
| 174 | - * @since 2.6.0 bbPress (r6875) | |
| 174 | + * @since 2.6.0 bbPress (r6876) | |
| 175 | 175 | */ |
| 176 | 176 | function bbp_setup_engagements() { |
| 177 | 177 | do_action( 'bbp_setup_engagements' ); |
| 178 | 178 | } |
| @@ -181,9 +181,9 @@ | ||
| 181 | 181 | |
| 182 | 182 | /** |
| 183 | 183 | * Load translations for current language |
| 184 | 184 | * |
| 185 | - * @since 2.0.0 bbPress (r2599) | |
| 185 | + * @since 2.0.0 bbPress (r3344) | |
| 186 | 186 | */ |
| 187 | 187 | function bbp_load_textdomain() { |
| 188 | 188 | do_action( 'bbp_load_textdomain' ); |
| 189 | 189 | } |
| @@ -190,9 +190,9 @@ | ||
| 190 | 190 | |
| 191 | 191 | /** |
| 192 | 192 | * Setup the post types |
| 193 | 193 | * |
| 194 | - * @since 2.0.0 bbPress (r2464) | |
| 194 | + * @since 2.0.0 bbPress (r2599) | |
| 195 | 195 | */ |
| 196 | 196 | function bbp_register_post_types() { |
| 197 | 197 | do_action( 'bbp_register_post_types' ); |
| 198 | 198 | } |
| @@ -208,9 +208,9 @@ | ||
| 208 | 208 | |
| 209 | 209 | /** |
| 210 | 210 | * Register the built in bbPress taxonomies |
| 211 | 211 | * |
| 212 | - * @since 2.0.0 bbPress (r2464) | |
| 212 | + * @since 2.0.0 bbPress (r2599) | |
| 213 | 213 | */ |
| 214 | 214 | function bbp_register_taxonomies() { |
| 215 | 215 | do_action( 'bbp_register_taxonomies' ); |
| 216 | 216 | } |
| @@ -226,9 +226,9 @@ | ||
| 226 | 226 | |
| 227 | 227 | /** |
| 228 | 228 | * Register the default bbPress shortcodes |
| 229 | 229 | * |
| 230 | - * @since 2.2.0 bbPress (r4211) | |
| 230 | + * @since 2.0.0 bbPress (r3032) | |
| 231 | 231 | */ |
| 232 | 232 | function bbp_register_shortcodes() { |
| 233 | 233 | do_action( 'bbp_register_shortcodes' ); |
| 234 | 234 | } |
| @@ -235,9 +235,9 @@ | ||
| 235 | 235 | |
| 236 | 236 | /** |
| 237 | 237 | * Register the default bbPress meta-data |
| 238 | 238 | * |
| 239 | - * @since 2.6.0 bbPress (r46300) | |
| 239 | + * @since 2.6.0 bbPress (r6302) | |
| 240 | 240 | */ |
| 241 | 241 | function bbp_register_meta() { |
| 242 | 242 | do_action( 'bbp_register_meta' ); |
| 243 | 243 | } |
| @@ -244,9 +244,9 @@ | ||
| 244 | 244 | |
| 245 | 245 | /** |
| 246 | 246 | * Enqueue bbPress specific CSS and JS |
| 247 | 247 | * |
| 248 | - * @since 2.0.0 bbPress (r3373) | |
| 248 | + * @since 2.0.0 bbPress (r3374) | |
| 249 | 249 | */ |
| 250 | 250 | function bbp_enqueue_scripts() { |
| 251 | 251 | do_action( 'bbp_enqueue_scripts' ); |
| 252 | 252 | } |
| @@ -280,9 +280,9 @@ | ||
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | 282 | * Add the bbPress-specific login forum action |
| 283 | 283 | * |
| 284 | - * @since 2.0.0 bbPress (r2753) | |
| 284 | + * @since 2.1.0 bbPress (r4072) | |
| 285 | 285 | */ |
| 286 | 286 | function bbp_login_form_login() { |
| 287 | 287 | do_action( 'bbp_login_form_login' ); |
| 288 | 288 | } |
| @@ -313,9 +313,9 @@ | ||
| 313 | 313 | |
| 314 | 314 | /** |
| 315 | 315 | * Add the bbPress-specific post updated action. |
| 316 | 316 | * |
| 317 | - * @since 2.6.17 | |
| 317 | + * @since 2.6.17 bbPress (r7454) | |
| 318 | 318 | * |
| 319 | 319 | * @param int $post_id Post ID. |
| 320 | 320 | * @param WP_Post $post_after Post object following the update. |
| 321 | 321 | * @param WP_Post $post_before Post object before the update. |
| @@ -336,9 +336,9 @@ | ||
| 336 | 336 | |
| 337 | 337 | /** |
| 338 | 338 | * The main action for hooking into when a user account is updated |
| 339 | 339 | * |
| 340 | - * @since 2.2.0 bbPress (r4304) | |
| 340 | + * @since 2.2.0 bbPress (r4305) | |
| 341 | 341 | * |
| 342 | 342 | * @param int $user_id ID of user being edited |
| 343 | 343 | * @param array $old_user_data The old, unmodified user data |
| 344 | 344 | */ |
| @@ -348,9 +348,9 @@ | ||
| 348 | 348 | |
| 349 | 349 | /** |
| 350 | 350 | * The main action for hooking into a user being registered |
| 351 | 351 | * |
| 352 | - * @since 2.2.0 bbPress (r4304) | |
| 352 | + * @since 2.2.0 bbPress (r4305) | |
| 353 | 353 | * |
| 354 | 354 | * @param int $user_id ID of user being edited |
| 355 | 355 | */ |
| 356 | 356 | function bbp_user_register( $user_id = 0 ) { |
| @@ -373,9 +373,9 @@ | ||
| 373 | 373 | /** |
| 374 | 374 | * The main action used for redirecting bbPress theme actions that are not |
| 375 | 375 | * permitted by the current_user |
| 376 | 376 | * |
| 377 | - * @since 2.1.0 bbPress (r3605) | |
| 377 | + * @since 2.1.0 bbPress (r3607) | |
| 378 | 378 | */ |
| 379 | 379 | function bbp_template_redirect() { |
| 380 | 380 | do_action( 'bbp_template_redirect' ); |
| 381 | 381 | } |
| @@ -384,9 +384,9 @@ | ||
| 384 | 384 | |
| 385 | 385 | /** |
| 386 | 386 | * The main action used for executing code before the theme has been setup |
| 387 | 387 | * |
| 388 | - * @since 2.1.0 bbPress (r3829) | |
| 388 | + * @since 2.1.0 bbPress (r3830) | |
| 389 | 389 | */ |
| 390 | 390 | function bbp_register_theme_packages() { |
| 391 | 391 | do_action( 'bbp_register_theme_packages' ); |
| 392 | 392 | } |
| @@ -393,9 +393,9 @@ | ||
| 393 | 393 | |
| 394 | 394 | /** |
| 395 | 395 | * The main action used for executing code before the theme has been setup |
| 396 | 396 | * |
| 397 | - * @since 2.1.0 bbPress (r3732) | |
| 397 | + * @since 2.1.0 bbPress (r3754) | |
| 398 | 398 | */ |
| 399 | 399 | function bbp_setup_theme() { |
| 400 | 400 | do_action( 'bbp_setup_theme' ); |
| 401 | 401 | } |
| @@ -402,9 +402,9 @@ | ||
| 402 | 402 | |
| 403 | 403 | /** |
| 404 | 404 | * The main action used for executing code after the theme has been setup |
| 405 | 405 | * |
| 406 | - * @since 2.1.0 bbPress (r3732) | |
| 406 | + * @since 2.1.0 bbPress (r3733) | |
| 407 | 407 | */ |
| 408 | 408 | function bbp_after_setup_theme() { |
| 409 | 409 | do_action( 'bbp_after_setup_theme' ); |
| 410 | 410 | } |
| @@ -411,9 +411,9 @@ | ||
| 411 | 411 | |
| 412 | 412 | /** |
| 413 | 413 | * The main action used for handling theme-side POST requests |
| 414 | 414 | * |
| 415 | - * @since 2.3.0 bbPress (r4550) | |
| 415 | + * @since 2.3.0 bbPress (r4551) | |
| 416 | 416 | */ |
| 417 | 417 | function bbp_post_request() { |
| 418 | 418 | |
| 419 | 419 | // Bail if not a POST action |
| @@ -444,9 +444,9 @@ | ||
| 444 | 444 | |
| 445 | 445 | /** |
| 446 | 446 | * The main action used for handling theme-side GET requests |
| 447 | 447 | * |
| 448 | - * @since 2.3.0 bbPress (r4550) | |
| 448 | + * @since 2.3.0 bbPress (r4551) | |
| 449 | 449 | */ |
| 450 | 450 | function bbp_get_request() { |
| 451 | 451 | |
| 452 | 452 | // Bail if not a POST action |
| @@ -479,9 +479,9 @@ | ||
| 479 | 479 | |
| 480 | 480 | /** |
| 481 | 481 | * Filter the plugin locale and domain. |
| 482 | 482 | * |
| 483 | - * @since 2.2.0 bbPress (r4213) | |
| 483 | + * @since 2.2.0 bbPress (r4214) | |
| 484 | 484 | * |
| 485 | 485 | * @param string $locale |
| 486 | 486 | * @param string $domain |
| 487 | 487 | */ |
| @@ -493,9 +493,9 @@ | ||
| 493 | 493 | |
| 494 | 494 | /** |
| 495 | 495 | * Piggy back filter for WordPress's 'request' filter |
| 496 | 496 | * |
| 497 | - * @since 2.1.0 bbPress (r3758) | |
| 497 | + * @since 2.1.0 bbPress (r3759) | |
| 498 | 498 | * |
| 499 | 499 | * @param array $query_vars |
| 500 | 500 | * @return array |
| 501 | 501 | */ |
| @@ -508,9 +508,9 @@ | ||
| 508 | 508 | /** |
| 509 | 509 | * The main filter used for theme compatibility and displaying custom bbPress |
| 510 | 510 | * theme files. |
| 511 | 511 | * |
| 512 | - * @since 2.0.0 bbPress (r3311) | |
| 512 | + * @since 2.0.0 bbPress (r3032) | |
| 513 | 513 | * |
| 514 | 514 | * @param string $template |
| 515 | 515 | * @return string Template file to use |
| 516 | 516 | */ |
| @@ -568,9 +568,9 @@ | ||
| 568 | 568 | |
| 569 | 569 | /** |
| 570 | 570 | * Filter the arguments used by wp_mail for bbPress specific emails |
| 571 | 571 | * |
| 572 | - * @since 2.6.0 bbPress (r6918) | |
| 572 | + * @since 2.6.0 bbPress (r6919) | |
| 573 | 573 | * |
| 574 | 574 | * @param array $args A compacted array of wp_mail() arguments, including the "to" email, |
| 575 | 575 | * subject, message, headers, and attachments values. |
| 576 | 576 | * |
| @@ -592,5 +592,80 @@ | ||
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | // Filter & return |
| 595 | 595 | return (array) apply_filters( 'bbp_mail', $args ); |
| 596 | +} | |
| 597 | + | |
| 598 | +/** | |
| 599 | + * Check whether bbPress metadata can be exposed in an oEmbed response. | |
| 600 | + * | |
| 601 | + * @since 2.6.19 bbPress (r7636) | |
| 602 | + * | |
| 603 | + * @param int $post_id bbPress post ID. | |
| 604 | + * @return bool Whether the post can be embedded for the current visitor. | |
| 605 | + */ | |
| 606 | +function bbp_user_can_embed_post( $post_id = 0 ) { | |
| 607 | + $post = get_post( $post_id ); | |
| 608 | + if ( empty( $post ) || ! bbp_is_custom_post_type( $post ) || ! is_post_publicly_viewable( $post ) || bbp_is_password_protected( $post->ID ) ) { | |
| 609 | + return false; | |
| 610 | + } | |
| 611 | + | |
| 612 | + if ( bbp_is_forum( $post->ID ) ) { | |
| 613 | + $forum_id = $post->ID; | |
| 614 | + } elseif ( bbp_is_topic( $post->ID ) ) { | |
| 615 | + $forum_id = bbp_get_topic_forum_id( $post->ID ); | |
| 616 | + } else { | |
| 617 | + $topic_id = bbp_get_reply_topic_id( $post->ID ); | |
| 618 | + if ( ! $topic_id || ! is_post_publicly_viewable( $topic_id ) ) { | |
| 619 | + return false; | |
| 620 | + } | |
| 621 | + $forum_id = bbp_get_reply_forum_id( $post->ID ); | |
| 622 | + } | |
| 623 | + | |
| 624 | + if ( ! $forum_id || ! in_array( get_post_status( $forum_id ), array( bbp_get_public_status_id(), bbp_get_private_status_id(), bbp_get_hidden_status_id() ), true ) ) { | |
| 625 | + return false; | |
| 626 | + } | |
| 627 | + | |
| 628 | + return ! bbp_is_forum_restricted_for_user( $forum_id, bbp_get_current_user_id() ); | |
| 629 | +} | |
| 630 | + | |
| 631 | +/** | |
| 632 | + * Prevent object-by-ID oEmbed requests from disclosing restricted posts. | |
| 633 | + * | |
| 634 | + * @since 2.6.19 bbPress (r7636) | |
| 635 | + * | |
| 636 | + * @param int $post_id Resolved post ID. | |
| 637 | + * @return int Resolved post ID, or zero when access is denied. | |
| 638 | + */ | |
| 639 | +function bbp_filter_oembed_request_post_id( $post_id = 0 ) { | |
| 640 | + $post = get_post( $post_id ); | |
| 641 | + if ( $post && bbp_is_custom_post_type( $post ) && ! bbp_user_can_embed_post( $post_id ) ) { | |
| 642 | + return 0; | |
| 643 | + } | |
| 644 | + | |
| 645 | + return $post_id; | |
| 646 | +} | |
| 647 | + | |
| 648 | +/** | |
| 649 | + * Prevent canonical redirects from exposing restricted bbPress permalinks. | |
| 650 | + * | |
| 651 | + * @since 2.6.19 bbPress (r7636) | |
| 652 | + * | |
| 653 | + * @param string $redirect_url Proposed redirect URL. | |
| 654 | + * @param string $requested_url Requested URL. | |
| 655 | + * @return string|false Redirect URL, or false when access is denied. | |
| 656 | + */ | |
| 657 | +function bbp_do_not_redirect_restricted_posts( $redirect_url = '', $requested_url = '' ) { | |
| 658 | + $query = wp_parse_url( $requested_url, PHP_URL_QUERY ); | |
| 659 | + if ( empty( $query ) ) { | |
| 660 | + return $redirect_url; | |
| 661 | + } | |
| 662 | + | |
| 663 | + wp_parse_str( $query, $args ); | |
| 664 | + $post_id = ! empty( $args['p'] ) ? absint( $args['p'] ) : 0; | |
| 665 | + $post = get_post( $post_id ); | |
| 666 | + if ( $post && bbp_is_custom_post_type( $post ) && ! bbp_user_can_embed_post( $post_id ) ) { | |
| 667 | + return false; | |
| 668 | + } | |
| 669 | + | |
| 670 | + return $redirect_url; | |
| 596 | 671 | } |