| @@ -15,9 +15,9 @@ | ||
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Return array of bbPress registered post types |
| 18 | 18 | * |
| 19 | - * @since 2.6.0 bbPress (r6813) | |
| 19 | + * @since 2.6.0 bbPress (r6814) | |
| 20 | 20 | * |
| 21 | 21 | * @param array $args Array of arguments to pass into `get_post_types()` |
| 22 | 22 | * |
| 23 | 23 | * @return array |
| @@ -36,8 +36,75 @@ | ||
| 36 | 36 | // Return post types |
| 37 | 37 | return get_post_types( $r ); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | +/** | |
| 41 | + * Exclude bbPress content from WordPress public author discovery. | |
| 42 | + * | |
| 43 | + * WordPress counts published posts without checking their forum visibility. | |
| 44 | + * A published topic or reply may belong to a private or hidden forum. | |
| 45 | + * | |
| 46 | + * @since 2.6.19 bbPress (r7710) | |
| 47 | + * | |
| 48 | + * @param array $args User query arguments. | |
| 49 | + * @param WP_REST_Request|null $request Optional REST request. | |
| 50 | + * @return array Filtered user query arguments. | |
| 51 | + */ | |
| 52 | +function bbp_exclude_forum_posts_from_user_query( $args, $request = null ) { | |
| 53 | + if ( $request instanceof WP_REST_Request && current_user_can( 'list_users' ) ) { | |
| 54 | + return $args; | |
| 55 | + } | |
| 56 | + | |
| 57 | + if ( empty( $args['has_published_posts'] ) || ! is_array( $args['has_published_posts'] ) ) { | |
| 58 | + return $args; | |
| 59 | + } | |
| 60 | + | |
| 61 | + $args['has_published_posts'] = array_values( array_diff( $args['has_published_posts'], bbp_get_post_types() ) ); | |
| 62 | + | |
| 63 | + // An empty post-type list would otherwise remove the author restriction. | |
| 64 | + if ( empty( $args['has_published_posts'] ) ) { | |
| 65 | + $args['include'] = array( 0 ); | |
| 66 | + } | |
| 67 | + | |
| 68 | + return $args; | |
| 69 | +} | |
| 70 | + | |
| 71 | +/** | |
| 72 | + * Exclude replies in non-public topics from public bbPress queries. | |
| 73 | + * | |
| 74 | + * The query flag scopes this SQL clause to listings that expose replies | |
| 75 | + * outside a single topic, so pagination counts match the visible results. | |
| 76 | + * | |
| 77 | + * @since 2.6.19 bbPress (r7618) | |
| 78 | + * | |
| 79 | + * @param string $where SQL WHERE clause. | |
| 80 | + * @param WP_Query $posts_query Posts query. | |
| 81 | + * @return string SQL WHERE clause. | |
| 82 | + */ | |
| 83 | +function bbp_public_topic_replies_where( $where = '', $posts_query = null ) { | |
| 84 | + if ( ! $posts_query instanceof WP_Query || ! $posts_query->get( '_bbp_public_topic_replies' ) ) { | |
| 85 | + return $where; | |
| 86 | + } | |
| 87 | + | |
| 88 | + $bbp_db = bbp_db(); | |
| 89 | + $statuses = bbp_get_public_topic_statuses(); | |
| 90 | + if ( $posts_query->get( '_bbp_search_private_topic_replies' ) && current_user_can( 'read_private_topics' ) && ! is_feed() && ! $posts_query->is_feed() ) { | |
| 91 | + $statuses[] = bbp_get_private_status_id(); | |
| 92 | + } | |
| 93 | + | |
| 94 | + if ( empty( $statuses ) ) { | |
| 95 | + return $where . $bbp_db->prepare( " AND {$bbp_db->posts}.post_type <> %s", bbp_get_reply_post_type() ); | |
| 96 | + } | |
| 97 | + | |
| 98 | + $placeholders = implode( ', ', array_fill( 0, count( $statuses ), '%s' ) ); | |
| 99 | + $where .= $bbp_db->prepare( | |
| 100 | + " AND ( {$bbp_db->posts}.post_type <> %s OR EXISTS ( SELECT 1 FROM {$bbp_db->posts} AS bbp_parent_topic WHERE bbp_parent_topic.ID = {$bbp_db->posts}.post_parent AND bbp_parent_topic.post_type = %s AND bbp_parent_topic.post_status IN ({$placeholders}) ) )", | |
| 101 | + array_merge( array( bbp_get_reply_post_type(), bbp_get_topic_post_type() ), $statuses ) | |
| 102 | + ); | |
| 103 | + | |
| 104 | + return $where; | |
| 105 | +} | |
| 106 | + | |
| 40 | 107 | /** URLs **********************************************************************/ |
| 41 | 108 | |
| 42 | 109 | /** |
| 43 | 110 | * Return the unescaped redirect_to request value |
| @@ -59,9 +126,9 @@ | ||
| 59 | 126 | |
| 60 | 127 | /** |
| 61 | 128 | * Append 'view=all' to query string if it's already there from referer |
| 62 | 129 | * |
| 63 | - * @since 2.0.0 bbPress (r3325) | |
| 130 | + * @since 2.0.0 bbPress (r2957) | |
| 64 | 131 | * |
| 65 | 132 | * @param string $original_link Original Link to be modified |
| 66 | 133 | * @param bool $force Override bbp_get_view_all() check |
| 67 | 134 | * @return string The link with 'view=all' appended if necessary |
| @@ -112,9 +179,9 @@ | ||
| 112 | 179 | |
| 113 | 180 | /** |
| 114 | 181 | * Assist pagination by returning correct page number |
| 115 | 182 | * |
| 116 | - * @since 2.0.0 bbPress (r2628) | |
| 183 | + * @since 2.0.0 bbPress (r2634) | |
| 117 | 184 | * |
| 118 | 185 | * @return int Current page number |
| 119 | 186 | */ |
| 120 | 187 | function bbp_get_paged() { |
| @@ -148,8 +215,9 @@ | ||
| 148 | 215 | * @param array $array Array to get values of |
| 149 | 216 | * |
| 150 | 217 | * @return array |
| 151 | 218 | */ |
| 219 | +// phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound -- Preserve the public parameter name for PHP 8 named arguments. | |
| 152 | 220 | function bbp_get_unique_array_values( $array = array() ) { |
| 153 | 221 | return array_unique( array_filter( array_values( $array ) ) ); |
| 154 | 222 | } |
| 155 | 223 | |
| @@ -155,9 +223,9 @@ | ||
| 155 | 223 | |
| 156 | 224 | /** |
| 157 | 225 | * Return the non-empty string values of an array. |
| 158 | 226 | * |
| 159 | - * @since 2.6.17 bbPress | |
| 227 | + * @since 2.6.17 bbPress (r7506) | |
| 160 | 228 | * |
| 161 | 229 | * @param mixed $arr Value or array to get string values of |
| 162 | 230 | * |
| 163 | 231 | * @return array |
| @@ -220,9 +288,9 @@ | ||
| 220 | 288 | * |
| 221 | 289 | * Fixes an issue since WordPress 5.6.0. See |
| 222 | 290 | * {@link https://bbpress.trac.wordpress.org/ticket/3433}. |
| 223 | 291 | * |
| 224 | - * @since 2.6.10 bbPress (r7233) | |
| 292 | + * @since 2.6.10 bbPress (r7234) | |
| 225 | 293 | * |
| 226 | 294 | * @param string $new_status New status to use when untrashing. Default: 'draft' |
| 227 | 295 | * @param int $post_id Post ID |
| 228 | 296 | * @param string $previous_status Previous post status from '_wp_trash_meta_status' meta key. Default: 'pending' |
| @@ -244,9 +312,9 @@ | ||
| 244 | 312 | |
| 245 | 313 | /** |
| 246 | 314 | * Update related counts when a topic or reply is created or changes status. |
| 247 | 315 | * |
| 248 | - * @since 2.6.17 | |
| 316 | + * @since 2.6.17 bbPress (r7451) | |
| 249 | 317 | * |
| 250 | 318 | * @param string $new_status New post status. |
| 251 | 319 | * @param string $old_status Old post status. |
| 252 | 320 | * @param WP_Post $post Post object. |
| @@ -259,9 +327,9 @@ | ||
| 259 | 327 | * Returning a non-null value prevents the normal topic and reply count |
| 260 | 328 | * updates. This allows integrations with custom post-status lifecycles or |
| 261 | 329 | * count storage to replace the complete transition operation. |
| 262 | 330 | * |
| 263 | - * @since 2.6.17 | |
| 331 | + * @since 2.6.17 bbPress (r7478) | |
| 264 | 332 | * |
| 265 | 333 | * @param null|bool $check Whether to short-circuit count updates. |
| 266 | 334 | * @param string $new_status New post status. |
| 267 | 335 | * @param string $old_status Old post status. |
| @@ -374,9 +442,9 @@ | ||
| 374 | 442 | * |
| 375 | 443 | * It is recommended to leave $utc set to true and to work with UTC/GMT dates. |
| 376 | 444 | * Turning this off will use the WordPress offset which is likely undesirable. |
| 377 | 445 | * |
| 378 | - * @since 2.0.0 bbPress (r3133) | |
| 446 | + * @since 2.0.0 bbPress (r3134) | |
| 379 | 447 | * @since 2.6.0 bbPress (r6868) Inverted some logic and added unit tests |
| 380 | 448 | * |
| 381 | 449 | * @param string $datetime Gets run through strtotime() |
| 382 | 450 | * @param boolean $utc Default true. Is the timestamp in UTC? |
| @@ -433,9 +501,9 @@ | ||
| 433 | 501 | * Get number of days something should remain trashed for before it is cleaned |
| 434 | 502 | * up by WordPress Cron. If set to 0, items will skip trash and be deleted |
| 435 | 503 | * immediately. |
| 436 | 504 | * |
| 437 | - * @since 2.6.0 bbPress (r6424) | |
| 505 | + * @since 2.6.0 bbPress (r6432) | |
| 438 | 506 | * |
| 439 | 507 | * @param string $context Provide context for additional filtering |
| 440 | 508 | * @return int Number of days items remain in trash |
| 441 | 509 | */ |
| @@ -482,9 +550,9 @@ | ||
| 482 | 550 | * user has edit_others_topics cap) |
| 483 | 551 | * - count_private_topics: Count private topics? (only counted if the current |
| 484 | 552 | * user has read_private_topics cap) |
| 485 | 553 | * - count_hidden_topics: Count hidden topics? (only counted if the current |
| 486 | - * user has read_hidden_topics cap) | |
| 554 | + * user has read_hidden_forums cap) | |
| 487 | 555 | * - count_spam_topics: Count spam topics? (only counted if the current |
| 488 | 556 | * user has edit_others_topics cap) |
| 489 | 557 | * - count_trash_topics: Count trash topics? (only counted if the current |
| 490 | 558 | * user has view_trash cap) |
| @@ -494,9 +562,9 @@ | ||
| 494 | 562 | * user has edit_others_replies cap) |
| 495 | 563 | * - count_private_replies: Count private replies? (only counted if the current |
| 496 | 564 | * user has read_private_replies cap) |
| 497 | 565 | * - count_hidden_replies: Count hidden replies? (only counted if the current |
| 498 | - * user has read_hidden_replies cap) | |
| 566 | + * user has read_hidden_forums cap) | |
| 499 | 567 | * - count_spam_replies: Count spam replies? (only counted if the current |
| 500 | 568 | * user has edit_others_replies cap) |
| 501 | 569 | * - count_trash_replies: Count trash replies? (only counted if the current |
| 502 | 570 | * user has view_trash cap) |
| @@ -571,8 +639,9 @@ | ||
| 571 | 639 | // Default capabilities |
| 572 | 640 | $caps = array( |
| 573 | 641 | 'view_trash' => false, |
| 574 | 642 | 'read_private_topics' => false, |
| 643 | + 'read_hidden_forums' => false, | |
| 575 | 644 | 'edit_others_topics' => false, |
| 576 | 645 | 'read_private_replies' => false, |
| 577 | 646 | 'edit_others_replies' => false, |
| 578 | 647 | 'edit_topic_tags' => false |
| @@ -578,10 +647,10 @@ | ||
| 578 | 647 | 'edit_topic_tags' => false |
| 579 | 648 | ); |
| 580 | 649 | |
| 581 | 650 | // Get capabilities |
| 582 | - foreach ( $caps as $key => $cap ) { | |
| 583 | - $caps[ $key ] = current_user_can( $cap ); | |
| 651 | + foreach ( array_keys( $caps ) as $cap ) { | |
| 652 | + $caps[ $cap ] = current_user_can( $cap ); | |
| 584 | 653 | } |
| 585 | 654 | |
| 586 | 655 | // Topics |
| 587 | 656 | if ( ! empty( $r['count_topics'] ) ) { |
| @@ -609,9 +678,9 @@ | ||
| 609 | 678 | $topic_titles[ $private ] = sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $private ] ) ); |
| 610 | 679 | } |
| 611 | 680 | |
| 612 | 681 | // Hidden |
| 613 | - if ( ! empty( $r['count_hidden_topics'] ) && ! empty( $caps['read_hidden_topics'] ) ) { | |
| 682 | + if ( ! empty( $r['count_hidden_topics'] ) && ! empty( $caps['read_hidden_forums'] ) ) { | |
| 614 | 683 | $topics[ $hidden ] = bbp_number_not_negative( $all_topics->{$hidden} ); |
| 615 | 684 | /* translators: %s: Number of hidden topics */ |
| 616 | 685 | $topic_titles[ $hidden ] = sprintf( esc_html__( 'Hidden: %s', 'bbpress' ), bbp_number_format_i18n( $topics[ $hidden ] ) ); |
| 617 | 686 | } |
| @@ -663,9 +732,9 @@ | ||
| 663 | 732 | $reply_titles[ $private ] = sprintf( esc_html__( 'Private: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $private ] ) ); |
| 664 | 733 | } |
| 665 | 734 | |
| 666 | 735 | // Hidden |
| 667 | - if ( ! empty( $r['count_hidden_replies'] ) && ! empty( $caps['read_hidden_replies'] ) ) { | |
| 736 | + if ( ! empty( $r['count_hidden_replies'] ) && ! empty( $caps['read_hidden_forums'] ) ) { | |
| 668 | 737 | $replies[ $hidden ] = bbp_number_not_negative( $all_replies->{$hidden} ); |
| 669 | 738 | /* translators: %s: Number of hidden replies */ |
| 670 | 739 | $reply_titles[ $hidden ] = sprintf( esc_html__( 'Hidden: %s', 'bbpress' ), bbp_number_format_i18n( $replies[ $hidden ] ) ); |
| 671 | 740 | } |
| @@ -705,9 +774,9 @@ | ||
| 705 | 774 | ) |
| 706 | 775 | ); |
| 707 | 776 | |
| 708 | 777 | // Empty tags |
| 709 | - if ( ! empty( $r['count_empty_tags'] ) && ! empty( 'edit_topic_tags' ) ) { | |
| 778 | + if ( ! empty( $r['count_empty_tags'] ) && ! empty( $caps['edit_topic_tags'] ) ) { | |
| 710 | 779 | $empty_topic_tag_count = wp_count_terms( $tt_id ) - $topic_tag_count; |
| 711 | 780 | } |
| 712 | 781 | } |
| 713 | 782 | |
| @@ -1116,9 +1185,9 @@ | ||
| 1116 | 1185 | |
| 1117 | 1186 | /** |
| 1118 | 1187 | * Filters the bbPress moderation keys. |
| 1119 | 1188 | * |
| 1120 | - * @since 2.6.0 bbPress (r6050) | |
| 1189 | + * @since 2.6.0 bbPress (r6855) | |
| 1121 | 1190 | * |
| 1122 | 1191 | * @param string $moderation List of moderation keys. One per new line. |
| 1123 | 1192 | */ |
| 1124 | 1193 | $moderation = apply_filters( "bbp_{$hook_name}_keys", trim( get_option( $option_name ) ) ); |
| @@ -1200,9 +1269,9 @@ | ||
| 1200 | 1269 | |
| 1201 | 1270 | /** |
| 1202 | 1271 | * Deprecated. Use bbp_check_for_moderation() with strict flag set. |
| 1203 | 1272 | * |
| 1204 | - * @since 2.0.0 bbPress (r3446) | |
| 1273 | + * @since 2.0.0 bbPress (r3447) | |
| 1205 | 1274 | * @since 2.6.0 bbPress (r6854) |
| 1206 | 1275 | * @deprecated 2.6.0 Use bbp_check_for_moderation() with strict flag set |
| 1207 | 1276 | */ |
| 1208 | 1277 | function bbp_check_for_blacklist( $anonymous_data = array(), $author_id = 0, $title = '', $content = '' ) { |
| @@ -1217,11 +1286,10 @@ | ||
| 1217 | 1286 | * We make some educated guesses here based on the home URL. Filters are |
| 1218 | 1287 | * available to customize this address further. In the future, we may consider |
| 1219 | 1288 | * using `admin_email` instead, though this is not normally publicized. |
| 1220 | 1289 | * |
| 1221 | - * We use `$_SERVER['SERVER_NAME']` here to mimic similar functionality in | |
| 1222 | - * WordPress core. Previously, we used `get_home_url()` to use already validated | |
| 1223 | - * user input, but it was causing issues in some installations. | |
| 1290 | + * Use the parsed home URL host to preserve mapped domains without including | |
| 1291 | + * paths or relying on a request-supplied server name. | |
| 1224 | 1292 | * |
| 1225 | 1293 | * @since 2.6.0 bbPress (r5409) |
| 1226 | 1294 | * |
| 1227 | 1295 | * @see wp_mail |
| @@ -1230,9 +1298,13 @@ | ||
| 1230 | 1298 | * |
| 1231 | 1299 | * @return string |
| 1232 | 1300 | */ |
| 1233 | 1301 | function bbp_get_do_not_reply_address() { |
| 1234 | - $sitename = strtolower( $_SERVER['SERVER_NAME'] ); | |
| 1302 | + $sitename = wp_parse_url( home_url(), PHP_URL_HOST ); | |
| 1303 | + if ( empty( $sitename ) ) { | |
| 1304 | + $sitename = wp_parse_url( site_url(), PHP_URL_HOST ); | |
| 1305 | + } | |
| 1306 | + $sitename = strtolower( (string) $sitename ); | |
| 1235 | 1307 | if ( substr( $sitename, 0, 4 ) === 'www.' ) { |
| 1236 | 1308 | $sitename = substr( $sitename, 4 ); |
| 1237 | 1309 | } |
| 1238 | 1310 | |
| @@ -1246,9 +1318,9 @@ | ||
| 1246 | 1318 | * Subscription relationships can outlive a user's access to a forum. Check |
| 1247 | 1319 | * current access immediately before preparing a notification so restricted |
| 1248 | 1320 | * content is not sent to former participants. |
| 1249 | 1321 | * |
| 1250 | - * @since 2.6.17 | |
| 1322 | + * @since 2.6.17 bbPress (r7494) | |
| 1251 | 1323 | * |
| 1252 | 1324 | * @param array $user_ids Subscriber user IDs. |
| 1253 | 1325 | * @param int $forum_id Forum ID. |
| 1254 | 1326 | * @param int $topic_id Topic ID. |
| @@ -1265,9 +1337,9 @@ | ||
| 1265 | 1337 | |
| 1266 | 1338 | /** |
| 1267 | 1339 | * Filters whether a subscription recipient can view a forum. |
| 1268 | 1340 | * |
| 1269 | - * @since 2.6.17 | |
| 1341 | + * @since 2.6.17 bbPress (r7494) | |
| 1270 | 1342 | * |
| 1271 | 1343 | * @param bool $can_view Whether the user can view the forum. |
| 1272 | 1344 | * @param int $user_id User ID. |
| 1273 | 1345 | * @param int $forum_id Forum ID. |
| @@ -1443,8 +1515,11 @@ | ||
| 1443 | 1515 | |
| 1444 | 1516 | // For plugins to filter messages per reply/topic/user |
| 1445 | 1517 | $message = apply_filters( 'bbp_subscription_mail_message', $message, $reply_id, $topic_id ); |
| 1446 | 1518 | if ( empty( $message ) ) { |
| 1519 | + bbp_restore_all_filters( 'bbp_get_reply_content' ); | |
| 1520 | + bbp_restore_all_filters( 'bbp_get_topic_title' ); | |
| 1521 | + bbp_restore_all_filters( 'the_title' ); | |
| 1447 | 1522 | return; |
| 1448 | 1523 | } |
| 1449 | 1524 | |
| 1450 | 1525 | // For plugins to filter titles per reply/topic/user |
| @@ -1449,8 +1524,11 @@ | ||
| 1449 | 1524 | |
| 1450 | 1525 | // For plugins to filter titles per reply/topic/user |
| 1451 | 1526 | $subject = apply_filters( 'bbp_subscription_mail_title', '[' . $forum_title . '] ' . $topic_title, $reply_id, $topic_id ); |
| 1452 | 1527 | if ( empty( $subject ) ) { |
| 1528 | + bbp_restore_all_filters( 'bbp_get_reply_content' ); | |
| 1529 | + bbp_restore_all_filters( 'bbp_get_topic_title' ); | |
| 1530 | + bbp_restore_all_filters( 'the_title' ); | |
| 1453 | 1531 | return; |
| 1454 | 1532 | } |
| 1455 | 1533 | |
| 1456 | 1534 | /** Headers ***************************************************************/ |
| @@ -1487,9 +1565,9 @@ | ||
| 1487 | 1565 | // After |
| 1488 | 1566 | do_action( 'bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids ); |
| 1489 | 1567 | |
| 1490 | 1568 | // Restore previously removed filters |
| 1491 | - bbp_restore_all_filters( 'bbp_get_topic_content' ); | |
| 1569 | + bbp_restore_all_filters( 'bbp_get_reply_content' ); | |
| 1492 | 1570 | bbp_restore_all_filters( 'bbp_get_topic_title' ); |
| 1493 | 1571 | bbp_restore_all_filters( 'the_title' ); |
| 1494 | 1572 | |
| 1495 | 1573 | return true; |
| @@ -1642,8 +1720,11 @@ | ||
| 1642 | 1720 | |
| 1643 | 1721 | // For plugins to filter messages per reply/topic/user |
| 1644 | 1722 | $message = apply_filters( 'bbp_forum_subscription_mail_message', $message, $topic_id, $forum_id, $user_id ); |
| 1645 | 1723 | if ( empty( $message ) ) { |
| 1724 | + bbp_restore_all_filters( 'bbp_get_topic_content' ); | |
| 1725 | + bbp_restore_all_filters( 'bbp_get_topic_title' ); | |
| 1726 | + bbp_restore_all_filters( 'the_title' ); | |
| 1646 | 1727 | return; |
| 1647 | 1728 | } |
| 1648 | 1729 | |
| 1649 | 1730 | // For plugins to filter titles per reply/topic/user |
| @@ -1648,8 +1729,11 @@ | ||
| 1648 | 1729 | |
| 1649 | 1730 | // For plugins to filter titles per reply/topic/user |
| 1650 | 1731 | $subject = apply_filters( 'bbp_forum_subscription_mail_title', '[' . $forum_title . '] ' . $topic_title, $topic_id, $forum_id, $user_id ); |
| 1651 | 1732 | if ( empty( $subject ) ) { |
| 1733 | + bbp_restore_all_filters( 'bbp_get_topic_content' ); | |
| 1734 | + bbp_restore_all_filters( 'bbp_get_topic_title' ); | |
| 1735 | + bbp_restore_all_filters( 'the_title' ); | |
| 1652 | 1736 | return; |
| 1653 | 1737 | } |
| 1654 | 1738 | |
| 1655 | 1739 | /** Headers ***************************************************************/ |
| @@ -1719,9 +1803,9 @@ | ||
| 1719 | 1803 | |
| 1720 | 1804 | /** |
| 1721 | 1805 | * Return an array of user email addresses from an array of user IDs |
| 1722 | 1806 | * |
| 1723 | - * @since 2.6.0 bbPress (r6722) | |
| 1807 | + * @since 2.6.0 bbPress (r6725) | |
| 1724 | 1808 | * |
| 1725 | 1809 | * @param array $user_ids |
| 1726 | 1810 | * @return array |
| 1727 | 1811 | */ |
| @@ -1793,9 +1877,9 @@ | ||
| 1793 | 1877 | * The default "chunk" size is 40 users per iteration, and can be filtered if |
| 1794 | 1878 | * desired. A future version of bbPress will introduce a setting to more easily |
| 1795 | 1879 | * tune this. |
| 1796 | 1880 | * |
| 1797 | - * @since 2.6.0 bbPress (r6918) | |
| 1881 | + * @since 2.6.0 bbPress (r6919) | |
| 1798 | 1882 | * |
| 1799 | 1883 | * @param array $args Original arguments passed to wp_mail(). |
| 1800 | 1884 | * @return array |
| 1801 | 1885 | */ |
| @@ -1867,9 +1951,9 @@ | ||
| 1867 | 1951 | * passed, it will default to the request uri, then the forum root. |
| 1868 | 1952 | * |
| 1869 | 1953 | * See: `wp_logout_url()` |
| 1870 | 1954 | * |
| 1871 | - * @since 2.1.0 bbPress (2815) | |
| 1955 | + * @since 2.0.0 bbPress (r2815) | |
| 1872 | 1956 | * |
| 1873 | 1957 | * @param string $url URL used to log out |
| 1874 | 1958 | * @param string $redirect_to Where to redirect to? |
| 1875 | 1959 | * |
| @@ -1901,9 +1985,9 @@ | ||
| 1901 | 1985 | // Validate $redirect_to, default to root |
| 1902 | 1986 | $validated = wp_validate_redirect( $filtered, $forum_root ); |
| 1903 | 1987 | |
| 1904 | 1988 | // Assemble $redirect_to and add it (encoded) to full $url |
| 1905 | - $appended = add_query_arg( array( 'loggedout' => 'true' ), $validated ); | |
| 1989 | + $appended = add_query_arg( array( 'loggedout' => 'true' ), $validated ); | |
| 1906 | 1990 | $encoded = urlencode( $appended ); |
| 1907 | 1991 | $url = add_query_arg( array( 'redirect_to' => $encoded ), $url ); |
| 1908 | 1992 | } |
| 1909 | 1993 | |
| @@ -1920,9 +2004,9 @@ | ||
| 1920 | 2004 | * to be merged into another array. It is identical to wp_parse_args() except |
| 1921 | 2005 | * it allows for arguments to be passively or aggressively filtered using the |
| 1922 | 2006 | * optional $filter_key parameter. |
| 1923 | 2007 | * |
| 1924 | - * @since 2.1.0 bbPress (r3839) | |
| 2008 | + * @since 2.1.0 bbPress (r3840) | |
| 1925 | 2009 | * |
| 1926 | 2010 | * @param string|array $args Value to merge with $defaults |
| 1927 | 2011 | * @param array $defaults Array that serves as the defaults. |
| 1928 | 2012 | * @param string $filter_key String to key the filters from |
| @@ -1960,9 +2044,9 @@ | ||
| 1960 | 2044 | |
| 1961 | 2045 | /** |
| 1962 | 2046 | * Adds ability to include or exclude specific post_parent ID's |
| 1963 | 2047 | * |
| 1964 | - * @since 2.0.0 bbPress (r2996) | |
| 2048 | + * @since 2.0.0 bbPress (r2997) | |
| 1965 | 2049 | * |
| 1966 | 2050 | * @deprecated 2.5.8 bbPress (r5814) |
| 1967 | 2051 | * |
| 1968 | 2052 | * @global WP $wp |
| @@ -2072,9 +2156,9 @@ | ||
| 2072 | 2156 | |
| 2073 | 2157 | /** |
| 2074 | 2158 | * Query the database for child counts, grouped by type & status |
| 2075 | 2159 | * |
| 2076 | - * @since 2.6.0 bbPress (r6826) | |
| 2160 | + * @since 2.6.0 bbPress (r6827) | |
| 2077 | 2161 | * |
| 2078 | 2162 | * @param int $parent_id |
| 2079 | 2163 | */ |
| 2080 | 2164 | function bbp_get_child_counts( $parent_id = 0 ) { |
| @@ -2143,9 +2227,9 @@ | ||
| 2143 | 2227 | |
| 2144 | 2228 | /** |
| 2145 | 2229 | * Filter a list of child counts, from `bbp_get_child_counts()` |
| 2146 | 2230 | * |
| 2147 | - * @since 2.6.0 bbPress (r6826) | |
| 2231 | + * @since 2.6.0 bbPress (r6827) | |
| 2148 | 2232 | * |
| 2149 | 2233 | * @param int $parent_id ID of post to get child counts from |
| 2150 | 2234 | * @param array $types Optional. An array of post types to filter by |
| 2151 | 2235 | * @param array $statuses Optional. An array of post statuses to filter by |
| @@ -2229,9 +2313,9 @@ | ||
| 2229 | 2313 | } |
| 2230 | 2314 | /** |
| 2231 | 2315 | * Query the DB and get a count of public children |
| 2232 | 2316 | * |
| 2233 | - * @since 2.0.0 bbPress (r2868) | |
| 2317 | + * @since 2.6.0 bbPress (r6827) | |
| 2234 | 2318 | * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects |
| 2235 | 2319 | * |
| 2236 | 2320 | * @param int $parent_id Parent id. |
| 2237 | 2321 | * @param string $post_type Post type. Defaults to 'post'. |
| @@ -2280,9 +2364,9 @@ | ||
| 2280 | 2364 | |
| 2281 | 2365 | /** |
| 2282 | 2366 | * Query the DB and get the child id's of public children |
| 2283 | 2367 | * |
| 2284 | - * @since 2.0.0 bbPress (r2868) | |
| 2368 | + * @since 2.0.0 bbPress (r2891) | |
| 2285 | 2369 | * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects |
| 2286 | 2370 | * |
| 2287 | 2371 | * @param int $parent_id Parent id. |
| 2288 | 2372 | * @param string $post_type Post type. Defaults to 'post'. |
| @@ -2416,9 +2500,9 @@ | ||
| 2416 | 2500 | * This is triggered when a `update_post_family_cache` argument is set to true. |
| 2417 | 2501 | * |
| 2418 | 2502 | * Also see: bbp_update_post_author_caches() |
| 2419 | 2503 | * |
| 2420 | - * @since 2.6.0 bbPress (r6699) | |
| 2504 | + * @since 2.6.0 bbPress (r6700) | |
| 2421 | 2505 | * |
| 2422 | 2506 | * @param array $objects Array of objects, fresh from a query |
| 2423 | 2507 | * |
| 2424 | 2508 | * @return bool True if some IDs were cached |
| @@ -2489,9 +2573,9 @@ | ||
| 2489 | 2573 | * WP_Query calls themselves. |
| 2490 | 2574 | * |
| 2491 | 2575 | * This is triggered when a `update_post_author_cache` argument is set to true. |
| 2492 | 2576 | * |
| 2493 | - * @since 2.6.0 bbPress (r6699) | |
| 2577 | + * @since 2.6.0 bbPress (r6700) | |
| 2494 | 2578 | * |
| 2495 | 2579 | * @param array $objects Array of objects, fresh from a query |
| 2496 | 2580 | * |
| 2497 | 2581 | * @return bool True if some IDs were cached |
| @@ -2540,9 +2624,9 @@ | ||
| 2540 | 2624 | * Get the unfiltered value of a global $post's key |
| 2541 | 2625 | * |
| 2542 | 2626 | * Used most frequently when editing a forum/topic/reply |
| 2543 | 2627 | * |
| 2544 | - * @since 2.1.0 bbPress (r3694) | |
| 2628 | + * @since 2.1.0 bbPress (r3702) | |
| 2545 | 2629 | * |
| 2546 | 2630 | * @param string $field Name of the key |
| 2547 | 2631 | * @param string $context How to sanitize - raw|edit|db|display|attribute|js |
| 2548 | 2632 | * @return string Field value |
| @@ -2565,9 +2649,9 @@ | ||
| 2565 | 2649 | * Makes sure the user requested an action from another page on this site. |
| 2566 | 2650 | * |
| 2567 | 2651 | * To avoid security exploits within the theme. |
| 2568 | 2652 | * |
| 2569 | - * @since 2.1.0 bbPress (r4022) | |
| 2653 | + * @since 2.1.0 bbPress (r4023) | |
| 2570 | 2654 | * |
| 2571 | 2655 | * @param string $action Action nonce |
| 2572 | 2656 | * @param string $query_arg where to look for nonce in $_REQUEST |
| 2573 | 2657 | */ |
| @@ -2576,9 +2660,9 @@ | ||
| 2576 | 2660 | /** Home URL **************************************************************/ |
| 2577 | 2661 | |
| 2578 | 2662 | // Parse home_url() into pieces to remove query-strings, strange characters, |
| 2579 | 2663 | // and other funny things that plugins might to do to it. |
| 2580 | - $parsed_home = parse_url( home_url( '/', ( is_ssl() ? 'https' : 'http' ) ) ); | |
| 2664 | + $parsed_home = wp_parse_url( home_url( '/', ( is_ssl() ? 'https' : 'http' ) ) ); | |
| 2581 | 2665 | |
| 2582 | 2666 | // Maybe include the port, if it's included |
| 2583 | 2667 | if ( isset( $parsed_home['port'] ) ) { |
| 2584 | 2668 | $parsed_host = $parsed_home['host'] . ':' . $parsed_home['port']; |
| @@ -2640,8 +2724,23 @@ | ||
| 2640 | 2724 | |
| 2641 | 2725 | /** Feeds *********************************************************************/ |
| 2642 | 2726 | |
| 2643 | 2727 | /** |
| 2728 | + * Escape CDATA terminators in bbPress feed content. | |
| 2729 | + * | |
| 2730 | + * Mirrors the handling in WordPress's get_the_content_feed() while preserving | |
| 2731 | + * bbPress's topic and reply content filters. | |
| 2732 | + * | |
| 2733 | + * @since 2.6.19 bbPress (r7620) | |
| 2734 | + * | |
| 2735 | + * @param string $content Feed content. | |
| 2736 | + * @return string Content safe to include in a CDATA section. | |
| 2737 | + */ | |
| 2738 | +function bbp_escape_feed_cdata( $content = '' ) { | |
| 2739 | + return str_replace( ']]>', ']]>', $content ); | |
| 2740 | +} | |
| 2741 | + | |
| 2742 | +/** | |
| 2644 | 2743 | * This function is hooked into the WordPress 'request' action and is |
| 2645 | 2744 | * responsible for sniffing out the query vars and serving up RSS2 feeds if |
| 2646 | 2745 | * the stars align and the user has requested a feed of any bbPress type. |
| 2647 | 2746 | * |
| @@ -2898,9 +2997,14 @@ | ||
| 2898 | 2997 | if ( ! empty( $path ) ) { |
| 2899 | 2998 | |
| 2900 | 2999 | // Pretty permalinks are on so path might exist |
| 2901 | 3000 | if ( get_option( 'permalink_structure' ) ) { |
| 2902 | - $retval = get_page_by_path( $path ); | |
| 3001 | + $page = get_page_by_path( $path ); | |
| 3002 | + | |
| 3003 | + // Only public pages can provide archive titles and content. | |
| 3004 | + if ( ! empty( $page ) && ( 'page' === $page->post_type ) && is_post_publicly_viewable( $page ) && empty( $page->post_password ) ) { | |
| 3005 | + $retval = $page; | |
| 3006 | + } | |
| 2903 | 3007 | } |
| 2904 | 3008 | } |
| 2905 | 3009 | |
| 2906 | 3010 | // Filter & return |
| @@ -2913,9 +3017,9 @@ | ||
| 2913 | 3017 | * bbPress post types are excluded from search because their visibility depends |
| 2914 | 3018 | * on forum access. Older versions of WordPress may otherwise guess a restricted |
| 2915 | 3019 | * forum or topic permalink from a partial slug and expose its full title. |
| 2916 | 3020 | * |
| 2917 | - * @since 2.6.17 bbPress | |
| 3021 | + * @since 2.6.17 bbPress (r7500) | |
| 2918 | 3022 | * |
| 2919 | 3023 | * @param bool $do_redirect_guess Whether to attempt to guess a redirect URL. |
| 2920 | 3024 | * |
| 2921 | 3025 | * @return bool Whether to attempt to guess a redirect URL. |
| @@ -2971,9 +3075,9 @@ | ||
| 2971 | 3075 | * |
| 2972 | 3076 | * Some conditions (like private/hidden forums and edits) have their own checks |
| 2973 | 3077 | * on `bbp_template_redirect` and are not currently 404s. |
| 2974 | 3078 | * |
| 2975 | - * @since 2.6.0 bbPress (r6555) | |
| 3079 | + * @since 2.6.0 bbPress (r6554) | |
| 2976 | 3080 | * |
| 2977 | 3081 | * @param bool $override Whether to override the default handler |
| 2978 | 3082 | * @param WP_Query $wp_query The posts query being referenced |
| 2979 | 3083 | * |
| @@ -3004,9 +3108,9 @@ | ||
| 3004 | 3108 | * |
| 3005 | 3109 | * This effectively short-circuits the default query for posts, which is |
| 3006 | 3110 | * currently only used to avoid calling the main query when it's not necessary. |
| 3007 | 3111 | * |
| 3008 | - * @since 2.6.0 bbPress (r6580) | |
| 3112 | + * @since 2.6.0 bbPress (r6583) | |
| 3009 | 3113 | * |
| 3010 | 3114 | * @param mixed $posts Default null. Array of posts (possibly empty) |
| 3011 | 3115 | * @param WP_Query $wp_query |
| 3012 | 3116 | * |
| @@ -3025,9 +3129,9 @@ | ||
| 3025 | 3129 | |
| 3026 | 3130 | /** |
| 3027 | 3131 | * Get scheme for a URL based on is_ssl() results. |
| 3028 | 3132 | * |
| 3029 | - * @since 2.6.0 bbPress (r6759) | |
| 3133 | + * @since 2.6.0 bbPress (r6760) | |
| 3030 | 3134 | * |
| 3031 | 3135 | * @return string https:// if is_ssl(), otherwise http:// |
| 3032 | 3136 | */ |
| 3033 | 3137 | function bbp_get_url_scheme() { |
| @@ -3043,9 +3147,9 @@ | ||
| 3043 | 3147 | * |
| 3044 | 3148 | * Uses mb_strlen() in `8bit` mode to treat strings as raw. This matches the |
| 3045 | 3149 | * behavior present in Comments, PHPMailer, RandomCompat, and others. |
| 3046 | 3150 | * |
| 3047 | - * @since 2.6.0 bbPress (r6783) | |
| 3151 | + * @since 2.6.0 bbPress (r6784) | |
| 3048 | 3152 | * |
| 3049 | 3153 | * @param string $title |
| 3050 | 3154 | * @return bool |
| 3051 | 3155 | */ |