| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * bbPress Common Functions. | |
| 4 | + * bbPress Common Functions | |
| 5 | 5 | * |
| 6 | 6 | * Common functions are ones that are used by more than one component, like |
| 7 | 7 | * forums, topics, replies, users, topic tags, etc... |
| 8 | 8 | * |
| @@ -13,13 +13,13 @@ | ||
| 13 | 13 | // Exit if accessed directly |
| 14 | 14 | defined( 'ABSPATH' ) || exit; |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * Return array of bbPress registered post type names. | |
| 17 | + * Return array of bbPress registered post types | |
| 18 | 18 | * |
| 19 | 19 | * @since 2.6.0 bbPress (r6814) |
| 20 | 20 | * |
| 21 | - * @param array $args Array of arguments to pass into `get_post_types()`. | |
| 21 | + * @param array $args Array of arguments to pass into `get_post_types()` | |
| 22 | 22 | * |
| 23 | 23 | * @return array |
| 24 | 24 | */ |
| 25 | 25 | function bbp_get_post_types( $args = array() ) { |
| @@ -42,9 +42,9 @@ | ||
| 42 | 42 | * |
| 43 | 43 | * WordPress counts published posts without checking their forum visibility. |
| 44 | 44 | * A published topic or reply may belong to a private or hidden forum. |
| 45 | 45 | * |
| 46 | - * @since 2.6.19 bbPress (r7709) | |
| 46 | + * @since 2.6.19 bbPress (r7710) | |
| 47 | 47 | * |
| 48 | 48 | * @param array $args User query arguments. |
| 49 | 49 | * @param WP_REST_Request|null $request Optional REST request. |
| 50 | 50 | * @return array Filtered user query arguments. |
| @@ -73,9 +73,9 @@ | ||
| 73 | 73 | * |
| 74 | 74 | * The query flag scopes this SQL clause to listings that expose replies |
| 75 | 75 | * outside a single topic, so pagination counts match the visible results. |
| 76 | 76 | * |
| 77 | - * @since 2.6.19 bbPress (r7617) | |
| 77 | + * @since 2.6.19 bbPress (r7618) | |
| 78 | 78 | * |
| 79 | 79 | * @param string $where SQL WHERE clause. |
| 80 | 80 | * @param WP_Query $posts_query Posts query. |
| 81 | 81 | * @return string SQL WHERE clause. |
| @@ -106,13 +106,13 @@ | ||
| 106 | 106 | |
| 107 | 107 | /** URLs **********************************************************************/ |
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | - * Return the unescaped redirect_to request value. | |
| 110 | + * Return the unescaped redirect_to request value | |
| 111 | 111 | * |
| 112 | - * @since 2.3.0 (r4655) | |
| 112 | + * @bbPress (r4655) | |
| 113 | 113 | * |
| 114 | - * @return string The URL to redirect to, if set. | |
| 114 | + * @return string The URL to redirect to, if set | |
| 115 | 115 | */ |
| 116 | 116 | function bbp_get_redirect_to() { |
| 117 | 117 | |
| 118 | 118 | // Check 'redirect_to' request parameter |
| @@ -128,11 +128,11 @@ | ||
| 128 | 128 | * Append 'view=all' to query string if it's already there from referer |
| 129 | 129 | * |
| 130 | 130 | * @since 2.0.0 bbPress (r2957) |
| 131 | 131 | * |
| 132 | - * @param string $original_link Original Link to be modified. | |
| 133 | - * @param bool $force Override bbp_get_view_all() check. | |
| 134 | - * @return string The link with 'view=all' appended if necessary. | |
| 132 | + * @param string $original_link Original Link to be modified | |
| 133 | + * @param bool $force Override bbp_get_view_all() check | |
| 134 | + * @return string The link with 'view=all' appended if necessary | |
| 135 | 135 | */ |
| 136 | 136 | function bbp_add_view_all( $original_link = '', $force = false ) { |
| 137 | 137 | |
| 138 | 138 | // Are we appending the view=all vars? |
| @@ -144,14 +144,14 @@ | ||
| 144 | 144 | return apply_filters( 'bbp_add_view_all', $link, $original_link ); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
| 148 | - * Remove 'view=all' from query string. | |
| 148 | + * Remove 'view=all' from query string | |
| 149 | 149 | * |
| 150 | 150 | * @since 2.0.0 bbPress (r3325) |
| 151 | 151 | * |
| 152 | - * @param string $original_link Original Link to be modified. | |
| 153 | - * @return string The link with 'view=all' appended if necessary. | |
| 152 | + * @param string $original_link Original Link to be modified | |
| 153 | + * @return string The link with 'view=all' appended if necessary | |
| 154 | 154 | */ |
| 155 | 155 | function bbp_remove_view_all( $original_link = '' ) { |
| 156 | 156 | |
| 157 | 157 | // Remove `view' argument |
| @@ -161,14 +161,15 @@ | ||
| 161 | 161 | return apply_filters( 'bbp_remove_view_all', $link, $original_link ); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | - * If current user can and is viewing all topics/replies. | |
| 165 | + * If current user can and is viewing all topics/replies | |
| 166 | 166 | * |
| 167 | 167 | * @since 2.0.0 bbPress (r3325) |
| 168 | 168 | * |
| 169 | - * @param string $cap Capability used to ensure user can view all. | |
| 170 | - * @return bool Whether current user can and is viewing all. | |
| 169 | + * @param string $cap Capability used to ensure user can view all | |
| 170 | + * | |
| 171 | + * @return bool Whether current user can and is viewing all | |
| 171 | 172 | */ |
| 172 | 173 | function bbp_get_view_all( $cap = 'moderate' ) { |
| 173 | 174 | $retval = ( ( ! empty( $_GET['view'] ) && ( 'all' === $_GET['view'] ) && current_user_can( $cap ) ) ); |
| 174 | 175 | |
| @@ -176,13 +177,13 @@ | ||
| 176 | 177 | return (bool) apply_filters( 'bbp_get_view_all', (bool) $retval, $cap ); |
| 177 | 178 | } |
| 178 | 179 | |
| 179 | 180 | /** |
| 180 | - * Assist pagination by returning correct page number. | |
| 181 | + * Assist pagination by returning correct page number | |
| 181 | 182 | * |
| 182 | 183 | * @since 2.0.0 bbPress (r2634) |
| 183 | 184 | * |
| 184 | - * @return int Current page number. | |
| 185 | + * @return int Current page number | |
| 185 | 186 | */ |
| 186 | 187 | function bbp_get_paged() { |
| 187 | 188 | $wp_query = bbp_get_wp_query(); |
| 188 | 189 | |
| @@ -206,59 +207,27 @@ | ||
| 206 | 207 | |
| 207 | 208 | /** Misc **********************************************************************/ |
| 208 | 209 | |
| 209 | 210 | /** |
| 210 | - * Filters whether or not to use the block editor for bbPress post types. | |
| 211 | - * | |
| 212 | - * As of 2.7.0 this is explicitly false, because the `show_in_rest` property | |
| 213 | - * of each post type is now set to true, and because support for blocks in | |
| 214 | - * user-facing forum content is not properly handled yet. | |
| 215 | - * | |
| 216 | - * The default return value of this function is highly likely to change once | |
| 217 | - * the block editor is integrated into the Forum/Topic/Reply experience. | |
| 218 | - * | |
| 219 | - * If you're feeling adventurous or working on this feature, override this | |
| 220 | - * filter with | |
| 221 | - * | |
| 222 | - * @since 2.7.0 bbPress (r7389) | |
| 223 | - * | |
| 224 | - * @param bool $using Optional. Default false. If using. | |
| 225 | - * @param string $post_type Optional. Default empty string. The post type to check. | |
| 226 | - * | |
| 227 | - * @return bool | |
| 228 | - */ | |
| 229 | -function bbp_filter_use_block_editor_for_post_type( $using = false, $post_type = '' ) { | |
| 230 | - | |
| 231 | - // Get bbPress post types | |
| 232 | - $bbp_post_types = bbp_get_post_types(); | |
| 233 | - | |
| 234 | - // Compare post types | |
| 235 | - $is_post_type = in_array( $post_type, $bbp_post_types, true ); | |
| 236 | - $retval = ! $is_post_type; | |
| 237 | - | |
| 238 | - // Filter & return | |
| 239 | - return (bool) apply_filters( 'bbp_filter_use_block_editor_for_post_type', $retval, $is_post_type, $using, $post_type ); | |
| 240 | -} | |
| 241 | - | |
| 242 | -/** | |
| 243 | 211 | * Return the unique non-empty values of an array. |
| 244 | 212 | * |
| 245 | 213 | * @since 2.6.0 bbPress (r6481) |
| 246 | 214 | * |
| 247 | - * @param array $arr Array to get values of. | |
| 215 | + * @param array $array Array to get values of | |
| 248 | 216 | * |
| 249 | 217 | * @return array |
| 250 | 218 | */ |
| 251 | -function bbp_get_unique_array_values( $arr = array() ) { | |
| 252 | - return array_unique( array_filter( array_values( $arr ) ) ); | |
| 219 | +// phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound -- Preserve the public parameter name for PHP 8 named arguments. | |
| 220 | +function bbp_get_unique_array_values( $array = array() ) { | |
| 221 | + return array_unique( array_filter( array_values( $array ) ) ); | |
| 253 | 222 | } |
| 254 | 223 | |
| 255 | 224 | /** |
| 256 | 225 | * Return the non-empty string values of an array. |
| 257 | 226 | * |
| 258 | - * @since 2.6.17 bbPress (r7505) | |
| 227 | + * @since 2.6.17 bbPress (r7506) | |
| 259 | 228 | * |
| 260 | - * @param mixed $arr Value or array to get string values of. | |
| 229 | + * @param mixed $arr Value or array to get string values of | |
| 261 | 230 | * |
| 262 | 231 | * @return array |
| 263 | 232 | */ |
| 264 | 233 | function bbp_get_string_array_values( $arr = array() ) { |
| @@ -273,9 +242,9 @@ | ||
| 273 | 242 | return $retval; |
| 274 | 243 | } |
| 275 | 244 | |
| 276 | 245 | /** |
| 277 | - * Fix post author id on post save. | |
| 246 | + * Fix post author id on post save | |
| 278 | 247 | * |
| 279 | 248 | * When a logged in user changes the status of an anonymous reply or topic, or |
| 280 | 249 | * edits it, the post_author field is set to the logged in user's id. This |
| 281 | 250 | * function fixes that. |
| @@ -281,11 +250,11 @@ | ||
| 281 | 250 | * function fixes that. |
| 282 | 251 | * |
| 283 | 252 | * @since 2.0.0 bbPress (r2734) |
| 284 | 253 | * |
| 285 | - * @param array $data Post data. | |
| 286 | - * @param array $postarr Original post array (includes post id). | |
| 287 | - * @return array Data. | |
| 254 | + * @param array $data Post data | |
| 255 | + * @param array $postarr Original post array (includes post id) | |
| 256 | + * @return array Data | |
| 288 | 257 | */ |
| 289 | 258 | function bbp_fix_post_author( $data = array(), $postarr = array() ) { |
| 290 | 259 | |
| 291 | 260 | // Post is not being updated or the post_author is already 0, return |
| @@ -319,13 +288,13 @@ | ||
| 319 | 288 | * |
| 320 | 289 | * Fixes an issue since WordPress 5.6.0. See |
| 321 | 290 | * {@link https://bbpress.trac.wordpress.org/ticket/3433}. |
| 322 | 291 | * |
| 323 | - * @since 2.6.10 bbPress (r7235) | |
| 292 | + * @since 2.6.10 bbPress (r7234) | |
| 324 | 293 | * |
| 325 | - * @param string $new_status New status to use when untrashing. Default: 'draft'. | |
| 326 | - * @param int $post_id Post ID. | |
| 327 | - * @param string $previous_status Previous post status from '_wp_trash_meta_status' meta key. Default: 'pending'. | |
| 294 | + * @param string $new_status New status to use when untrashing. Default: 'draft' | |
| 295 | + * @param int $post_id Post ID | |
| 296 | + * @param string $previous_status Previous post status from '_wp_trash_meta_status' meta key. Default: 'pending' | |
| 328 | 297 | */ |
| 329 | 298 | function bbp_fix_untrash_post_status( $new_status = 'draft', $post_id = 0, $previous_status = 'pending' ) { |
| 330 | 299 | |
| 331 | 300 | // Bail if not a forum, topic, or reply |
| @@ -343,9 +312,9 @@ | ||
| 343 | 312 | |
| 344 | 313 | /** |
| 345 | 314 | * Update related counts when a topic or reply is created or changes status. |
| 346 | 315 | * |
| 347 | - * @since 2.6.17 bbPress (r7449) | |
| 316 | + * @since 2.6.17 bbPress (r7451) | |
| 348 | 317 | * |
| 349 | 318 | * @param string $new_status New post status. |
| 350 | 319 | * @param string $old_status Old post status. |
| 351 | 320 | * @param WP_Post $post Post object. |
| @@ -358,9 +327,9 @@ | ||
| 358 | 327 | * Returning a non-null value prevents the normal topic and reply count |
| 359 | 328 | * updates. This allows integrations with custom post-status lifecycles or |
| 360 | 329 | * count storage to replace the complete transition operation. |
| 361 | 330 | * |
| 362 | - * @since 2.6.17 bbPress (r7475) | |
| 331 | + * @since 2.6.17 bbPress (r7478) | |
| 363 | 332 | * |
| 364 | 333 | * @param null|bool $check Whether to short-circuit count updates. |
| 365 | 334 | * @param string $new_status New post status. |
| 366 | 335 | * @param string $old_status Old post status. |
| @@ -476,9 +445,9 @@ | ||
| 476 | 445 | * |
| 477 | 446 | * @since 2.0.0 bbPress (r3134) |
| 478 | 447 | * @since 2.6.0 bbPress (r6868) Inverted some logic and added unit tests |
| 479 | 448 | * |
| 480 | - * @param string $datetime Gets run through strtotime(). | |
| 449 | + * @param string $datetime Gets run through strtotime() | |
| 481 | 450 | * @param boolean $utc Default true. Is the timestamp in UTC? |
| 482 | 451 | * |
| 483 | 452 | * @return bool True by default, if date is past, or editing is disabled. |
| 484 | 453 | */ |
| @@ -506,11 +475,9 @@ | ||
| 506 | 475 | $lockable .= ' UTC'; |
| 507 | 476 | } |
| 508 | 477 | |
| 509 | 478 | // Now |
| 510 | - $cur_time = empty( $utc ) | |
| 511 | - ? (int) wp_date( 'U' ) | |
| 512 | - : time(); | |
| 479 | + $cur_time = current_time( 'timestamp', $utc ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested | |
| 513 | 480 | |
| 514 | 481 | // Get the duration in seconds |
| 515 | 482 | $duration = strtotime( $lockable ) - $cur_time; |
| 516 | 483 | |
| @@ -536,10 +503,10 @@ | ||
| 536 | 503 | * immediately. |
| 537 | 504 | * |
| 538 | 505 | * @since 2.6.0 bbPress (r6432) |
| 539 | 506 | * |
| 540 | - * @param string $context Provide context for additional filtering. | |
| 541 | - * @return int Number of days items remain in trash. | |
| 507 | + * @param string $context Provide context for additional filtering | |
| 508 | + * @return int Number of days items remain in trash | |
| 542 | 509 | */ |
| 543 | 510 | function bbp_get_trash_days( $context = 'forum' ) { |
| 544 | 511 | |
| 545 | 512 | // Sanitize the context |
| @@ -556,9 +523,9 @@ | ||
| 556 | 523 | |
| 557 | 524 | /** Statistics ****************************************************************/ |
| 558 | 525 | |
| 559 | 526 | /** |
| 560 | - * Get the forum statistics. | |
| 527 | + * Get the forum statistics | |
| 561 | 528 | * |
| 562 | 529 | * @since 2.0.0 bbPress (r2769) |
| 563 | 530 | * @since 2.6.0 bbPress (r6055) Added: |
| 564 | 531 | * `count_pending_topics` |
| @@ -658,11 +625,11 @@ | ||
| 658 | 625 | $hidden = bbp_get_hidden_status_id(); |
| 659 | 626 | $spam = bbp_get_spam_status_id(); |
| 660 | 627 | $trash = bbp_get_trash_status_id(); |
| 661 | 628 | |
| 662 | - // Users with a forum role on the current site | |
| 629 | + // Users | |
| 663 | 630 | $user_count = ! empty( $r['count_users'] ) |
| 664 | - ? bbp_get_total_forum_users() | |
| 631 | + ? bbp_get_total_users() | |
| 665 | 632 | : 0; |
| 666 | 633 | |
| 667 | 634 | // Forums |
| 668 | 635 | $forum_count = ! empty( $r['count_forums'] ) |
| @@ -813,20 +780,17 @@ | ||
| 813 | 780 | } |
| 814 | 781 | } |
| 815 | 782 | |
| 816 | 783 | // Tally the tallies |
| 817 | - $counts = array_map( | |
| 818 | - 'absint', | |
| 819 | - compact( | |
| 820 | - 'user_count', | |
| 821 | - 'forum_count', | |
| 822 | - 'topic_count', | |
| 823 | - 'topic_count_hidden', | |
| 824 | - 'reply_count', | |
| 825 | - 'reply_count_hidden', | |
| 826 | - 'topic_tag_count', | |
| 827 | - 'empty_topic_tag_count' | |
| 828 | - ) | |
| 784 | + $counts = compact( | |
| 785 | + 'user_count', | |
| 786 | + 'forum_count', | |
| 787 | + 'topic_count', | |
| 788 | + 'topic_count_hidden', | |
| 789 | + 'reply_count', | |
| 790 | + 'reply_count_hidden', | |
| 791 | + 'topic_tag_count', | |
| 792 | + 'empty_topic_tag_count' | |
| 829 | 793 | ); |
| 830 | 794 | |
| 831 | 795 | // Define return value |
| 832 | 796 | $statistics = array(); |
| @@ -848,9 +812,9 @@ | ||
| 848 | 812 | |
| 849 | 813 | /** New/edit topic/reply helpers **********************************************/ |
| 850 | 814 | |
| 851 | 815 | /** |
| 852 | - * Filter anonymous post data. | |
| 816 | + * Filter anonymous post data | |
| 853 | 817 | * |
| 854 | 818 | * We use REMOTE_ADDR here directly. If you are behind a proxy, you should |
| 855 | 819 | * ensure that it is properly set, such as in wp-config.php, for your |
| 856 | 820 | * environment. See {@link https://core.trac.wordpress.org/ticket/9235} |
| @@ -861,10 +825,10 @@ | ||
| 861 | 825 | * If there are any errors, those are directly added to {@link bbPress:errors} |
| 862 | 826 | * |
| 863 | 827 | * @since 2.0.0 bbPress (r2734) |
| 864 | 828 | * |
| 865 | - * @param array $args Optional. If no args are there, then $_POST values are. | |
| 866 | - * @return bool|array False on errors, values in an array on success. | |
| 829 | + * @param array $args Optional. If no args are there, then $_POST values are | |
| 830 | + * @return bool|array False on errors, values in an array on success | |
| 867 | 831 | */ |
| 868 | 832 | function bbp_filter_anonymous_post_data( $args = array() ) { |
| 869 | 833 | |
| 870 | 834 | // Parse arguments against default values |
| @@ -900,9 +864,9 @@ | ||
| 900 | 864 | return (array) apply_filters( 'bbp_filter_anonymous_post_data', $r, $args ); |
| 901 | 865 | } |
| 902 | 866 | |
| 903 | 867 | /** |
| 904 | - * Sanitize an array of anonymous post author data. | |
| 868 | + * Sanitize an array of anonymous post author data | |
| 905 | 869 | * |
| 906 | 870 | * @since 2.6.0 bbPress (r6400) |
| 907 | 871 | * |
| 908 | 872 | * @param array $anonymous_data |
| @@ -939,9 +903,9 @@ | ||
| 939 | 903 | return (array) apply_filters( 'bbp_sanitize_anonymous_post_author', $r, $anonymous_data ); |
| 940 | 904 | } |
| 941 | 905 | |
| 942 | 906 | /** |
| 943 | - * Update the relevant meta-data for an anonymous post author. | |
| 907 | + * Update the relevant meta-data for an anonymous post author | |
| 944 | 908 | * |
| 945 | 909 | * @since 2.6.0 bbPress (r6400) |
| 946 | 910 | * |
| 947 | 911 | * @param int $post_id |
| @@ -985,16 +949,16 @@ | ||
| 985 | 949 | } |
| 986 | 950 | } |
| 987 | 951 | |
| 988 | 952 | /** |
| 989 | - * Check for duplicate topics/replies. | |
| 953 | + * Check for duplicate topics/replies | |
| 990 | 954 | * |
| 991 | - * Check to make sure that a user is not making a duplicate post. | |
| 955 | + * Check to make sure that a user is not making a duplicate post | |
| 992 | 956 | * |
| 993 | 957 | * @since 2.0.0 bbPress (r2763) |
| 994 | 958 | * |
| 995 | - * @param array $post_data Contains information about the comment. | |
| 996 | - * @return bool True if it is not a duplicate, false if it is. | |
| 959 | + * @param array $post_data Contains information about the comment | |
| 960 | + * @return bool True if it is not a duplicate, false if it is | |
| 997 | 961 | */ |
| 998 | 962 | function bbp_check_for_duplicate( $post_data = array() ) { |
| 999 | 963 | |
| 1000 | 964 | // Parse arguments against default values |
| @@ -1078,9 +1042,9 @@ | ||
| 1078 | 1042 | return true; |
| 1079 | 1043 | } |
| 1080 | 1044 | |
| 1081 | 1045 | /** |
| 1082 | - * Check for flooding. | |
| 1046 | + * Check for flooding | |
| 1083 | 1047 | * |
| 1084 | 1048 | * Check to make sure that a user is not making too many posts in a short amount |
| 1085 | 1049 | * of time. |
| 1086 | 1050 | * |
| @@ -1087,12 +1051,12 @@ | ||
| 1087 | 1051 | * @since 2.0.0 bbPress (r2734) |
| 1088 | 1052 | * |
| 1089 | 1053 | * @param array $anonymous_data Optional - if it's an anonymous post. Do not |
| 1090 | 1054 | * supply if supplying $author_id. Should be |
| 1091 | - * sanitized (see {@link bbp_filter_anonymous_post_data()}. | |
| 1055 | + * sanitized (see {@link bbp_filter_anonymous_post_data()} | |
| 1092 | 1056 | * @param int $author_id Optional. Supply if it's a post by a logged in user. |
| 1093 | 1057 | * Do not supply if supplying $anonymous_data. |
| 1094 | - * @return bool True if there is no flooding, false if there is. | |
| 1058 | + * @return bool True if there is no flooding, false if there is | |
| 1095 | 1059 | */ |
| 1096 | 1060 | function bbp_check_for_flood( $anonymous_data = array(), $author_id = 0 ) { |
| 1097 | 1061 | |
| 1098 | 1062 | // Allow for flood check to be skipped |
| @@ -1129,9 +1093,9 @@ | ||
| 1129 | 1093 | return true; |
| 1130 | 1094 | } |
| 1131 | 1095 | |
| 1132 | 1096 | /** |
| 1133 | - * Checks topics and replies against the discussion moderation of blocked keys. | |
| 1097 | + * Checks topics and replies against the discussion moderation of blocked keys | |
| 1134 | 1098 | * |
| 1135 | 1099 | * @since 2.1.0 bbPress (r3581) |
| 1136 | 1100 | * |
| 1137 | 1101 | * @param array $anonymous_data Optional - if it's an anonymous post. Do not |
| @@ -1136,14 +1100,14 @@ | ||
| 1136 | 1100 | * |
| 1137 | 1101 | * @param array $anonymous_data Optional - if it's an anonymous post. Do not |
| 1138 | 1102 | * supply if supplying $author_id. Should be |
| 1139 | 1103 | * sanitized (see {@link bbp_filter_anonymous_post_data()} |
| 1140 | - * @param int $author_id Topic or reply author ID. | |
| 1141 | - * @param string $title The title of the content. | |
| 1142 | - * @param string $content The content being posted. | |
| 1104 | + * @param int $author_id Topic or reply author ID | |
| 1105 | + * @param string $title The title of the content | |
| 1106 | + * @param string $content The content being posted | |
| 1143 | 1107 | * @param mixed $strict False for moderation_keys. True for disallowed_keys. |
| 1144 | 1108 | * String for custom keys. |
| 1145 | - * @return bool True if test is passed, false if fail. | |
| 1109 | + * @return bool True if test is passed, false if fail | |
| 1146 | 1110 | */ |
| 1147 | 1111 | function bbp_check_for_moderation( $anonymous_data = array(), $author_id = 0, $title = '', $content = '', $strict = false ) { |
| 1148 | 1112 | |
| 1149 | 1113 | // Custom moderation option key |
| @@ -1160,9 +1124,9 @@ | ||
| 1160 | 1124 | $strict = false; |
| 1161 | 1125 | } |
| 1162 | 1126 | } |
| 1163 | 1127 | |
| 1164 | - // Strict mode uses WordPress "disallow" settings | |
| 1128 | + // Strict mode uses WordPress "blacklist" settings | |
| 1165 | 1129 | if ( true === $strict ) { |
| 1166 | 1130 | $hook_name = 'blacklist'; |
| 1167 | 1131 | $option_name = 'disallowed_keys'; |
| 1168 | 1132 | |
| @@ -1354,9 +1318,9 @@ | ||
| 1354 | 1318 | * Subscription relationships can outlive a user's access to a forum. Check |
| 1355 | 1319 | * current access immediately before preparing a notification so restricted |
| 1356 | 1320 | * content is not sent to former participants. |
| 1357 | 1321 | * |
| 1358 | - * @since 2.6.17 bbPress (r7493) | |
| 1322 | + * @since 2.6.17 bbPress (r7494) | |
| 1359 | 1323 | * |
| 1360 | 1324 | * @param array $user_ids Subscriber user IDs. |
| 1361 | 1325 | * @param int $forum_id Forum ID. |
| 1362 | 1326 | * @param int $topic_id Topic ID. |
| @@ -1373,9 +1337,9 @@ | ||
| 1373 | 1337 | |
| 1374 | 1338 | /** |
| 1375 | 1339 | * Filters whether a subscription recipient can view a forum. |
| 1376 | 1340 | * |
| 1377 | - * @since 2.6.17 bbPress (r7493) | |
| 1341 | + * @since 2.6.17 bbPress (r7494) | |
| 1378 | 1342 | * |
| 1379 | 1343 | * @param bool $can_view Whether the user can view the forum. |
| 1380 | 1344 | * @param int $user_id User ID. |
| 1381 | 1345 | * @param int $forum_id Forum ID. |
| @@ -1402,12 +1366,12 @@ | ||
| 1402 | 1366 | return $user_ids; |
| 1403 | 1367 | } |
| 1404 | 1368 | |
| 1405 | 1369 | /** |
| 1406 | - * Sends notification emails for new replies to subscribed topics. | |
| 1370 | + * Sends notification emails for new replies to subscribed topics | |
| 1407 | 1371 | * |
| 1408 | 1372 | * Gets new post ID and check if there are subscribed users to that topic, and |
| 1409 | - * if there are, send notifications. | |
| 1373 | + * if there are, send notifications | |
| 1410 | 1374 | * |
| 1411 | 1375 | * Note: in bbPress 2.6, we've moved away from 1 email per subscriber to 1 email |
| 1412 | 1376 | * with everyone BCC'd. This may have negative repercussions for email services |
| 1413 | 1377 | * that limit the number of addresses in a BCC field (often to around 500.) In |
| @@ -1415,16 +1379,16 @@ | ||
| 1415 | 1379 | * custom email script. |
| 1416 | 1380 | * |
| 1417 | 1381 | * @since 2.6.0 bbPress (r5413) |
| 1418 | 1382 | * |
| 1419 | - * @param int $reply_id ID of the newly made reply. | |
| 1420 | - * @param int $topic_id ID of the topic of the reply. | |
| 1421 | - * @param int $forum_id ID of the forum of the reply. | |
| 1383 | + * @param int $reply_id ID of the newly made reply | |
| 1384 | + * @param int $topic_id ID of the topic of the reply | |
| 1385 | + * @param int $forum_id ID of the forum of the reply | |
| 1422 | 1386 | * @param array $anonymous_data Optional - if it's an anonymous post. Do not |
| 1423 | 1387 | * supply if supplying $author_id. Should be |
| 1424 | - * sanitized (see {@link bbp_filter_anonymous_post_data()}. | |
| 1425 | - * @param int $reply_author ID of the topic author ID. | |
| 1426 | - * @return bool True on success, false on failure. | |
| 1388 | + * sanitized (see {@link bbp_filter_anonymous_post_data()} | |
| 1389 | + * @param int $reply_author ID of the topic author ID | |
| 1390 | + * @return bool True on success, false on failure | |
| 1427 | 1391 | */ |
| 1428 | 1392 | function bbp_notify_topic_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = array(), $reply_author = 0 ) { |
| 1429 | 1393 | |
| 1430 | 1394 | // Bail if subscriptions are turned off |
| @@ -1497,10 +1461,10 @@ | ||
| 1497 | 1461 | bbp_remove_all_filters( 'bbp_get_topic_title' ); |
| 1498 | 1462 | bbp_remove_all_filters( 'the_title' ); |
| 1499 | 1463 | |
| 1500 | 1464 | // Strip tags from text and setup mail data |
| 1501 | - $forum_title = wp_specialchars_decode( wp_strip_all_tags( bbp_get_forum_title( $forum_id ) ), ENT_QUOTES ); | |
| 1502 | - $topic_title = wp_specialchars_decode( wp_strip_all_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); | |
| 1465 | + $forum_title = wp_specialchars_decode( strip_tags( bbp_get_forum_title( $forum_id ) ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1466 | + $topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1503 | 1467 | $reply_url = bbp_get_reply_url( $reply_id ); |
| 1504 | 1468 | |
| 1505 | 1469 | // Do not include protected content in subscription emails |
| 1506 | 1470 | if ( ! empty( $password_protected ) ) { |
| @@ -1523,10 +1487,10 @@ | ||
| 1523 | 1487 | ); |
| 1524 | 1488 | |
| 1525 | 1489 | // Include the reply details in normal subscription emails |
| 1526 | 1490 | } else { |
| 1527 | - $reply_author_name = wp_specialchars_decode( wp_strip_all_tags( $reply_author_name ), ENT_QUOTES ); | |
| 1528 | - $reply_content = wp_specialchars_decode( wp_strip_all_tags( bbp_get_reply_content( $reply_id ) ), ENT_QUOTES ); | |
| 1491 | + $reply_author_name = wp_specialchars_decode( strip_tags( $reply_author_name ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1492 | + $reply_content = wp_specialchars_decode( strip_tags( bbp_get_reply_content( $reply_id ) ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1529 | 1493 | $message = sprintf( |
| 1530 | 1494 | |
| 1531 | 1495 | /* translators: 1: Reply author name, 2: Reply content, 3: Reply URL */ |
| 1532 | 1496 | esc_html__( |
| @@ -1609,12 +1573,12 @@ | ||
| 1609 | 1573 | return true; |
| 1610 | 1574 | } |
| 1611 | 1575 | |
| 1612 | 1576 | /** |
| 1613 | - * Sends notification emails for new topics to subscribed forums. | |
| 1577 | + * Sends notification emails for new topics to subscribed forums | |
| 1614 | 1578 | * |
| 1615 | 1579 | * Gets new post ID and check if there are subscribed users to that forum, and |
| 1616 | - * if there are, send notifications. | |
| 1580 | + * if there are, send notifications | |
| 1617 | 1581 | * |
| 1618 | 1582 | * Note: in bbPress 2.6, we've moved away from 1 email per subscriber to 1 email |
| 1619 | 1583 | * with everyone BCC'd. This may have negative repercussions for email services |
| 1620 | 1584 | * that limit the number of addresses in a BCC field (often to around 500.) In |
| @@ -1622,15 +1586,15 @@ | ||
| 1622 | 1586 | * custom email script. |
| 1623 | 1587 | * |
| 1624 | 1588 | * @since 2.5.0 bbPress (r5156) |
| 1625 | 1589 | * |
| 1626 | - * @param int $topic_id ID of the newly made reply. | |
| 1627 | - * @param int $forum_id ID of the forum for the topic. | |
| 1590 | + * @param int $topic_id ID of the newly made reply | |
| 1591 | + * @param int $forum_id ID of the forum for the topic | |
| 1628 | 1592 | * @param array $anonymous_data Optional - if it's an anonymous post. Do not |
| 1629 | 1593 | * supply if supplying $author_id. Should be |
| 1630 | 1594 | * sanitized (see {@link bbp_filter_anonymous_post_data()} |
| 1631 | - * @param int $topic_author ID of the topic author ID. | |
| 1632 | - * @return bool True on success, false on failure. | |
| 1595 | + * @param int $topic_author ID of the topic author ID | |
| 1596 | + * @return bool True on success, false on failure | |
| 1633 | 1597 | */ |
| 1634 | 1598 | function bbp_notify_forum_subscribers( $topic_id = 0, $forum_id = 0, $anonymous_data = array(), $topic_author = 0 ) { |
| 1635 | 1599 | |
| 1636 | 1600 | // Bail if subscriptions are turned off |
| @@ -1657,9 +1621,9 @@ | ||
| 1657 | 1621 | $user_id = 0; |
| 1658 | 1622 | |
| 1659 | 1623 | /** Topic *****************************************************************/ |
| 1660 | 1624 | |
| 1661 | - // Bail if topic is not public (both open/closed are public) | |
| 1625 | + // Bail if topic is not public (includes closed) | |
| 1662 | 1626 | if ( ! bbp_is_topic_public( $topic_id ) ) { |
| 1663 | 1627 | return false; |
| 1664 | 1628 | } |
| 1665 | 1629 | |
| @@ -1702,11 +1666,11 @@ | ||
| 1702 | 1666 | bbp_remove_all_filters( 'bbp_get_topic_title' ); |
| 1703 | 1667 | bbp_remove_all_filters( 'the_title' ); |
| 1704 | 1668 | |
| 1705 | 1669 | // Strip tags from text and setup mail data |
| 1706 | - $forum_title = wp_specialchars_decode( wp_strip_all_tags( bbp_get_forum_title( $forum_id ) ), ENT_QUOTES ); | |
| 1707 | - $topic_title = wp_specialchars_decode( wp_strip_all_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); | |
| 1708 | - $topic_url = bbp_get_topic_permalink( $topic_id ); | |
| 1670 | + $forum_title = wp_specialchars_decode( strip_tags( bbp_get_forum_title( $forum_id ) ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1671 | + $topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1672 | + $topic_url = get_permalink( $topic_id ); | |
| 1709 | 1673 | |
| 1710 | 1674 | // Do not include protected content in subscription emails |
| 1711 | 1675 | if ( ! empty( $password_protected ) ) { |
| 1712 | 1676 | $message = sprintf( |
| @@ -1728,10 +1692,10 @@ | ||
| 1728 | 1692 | ); |
| 1729 | 1693 | |
| 1730 | 1694 | // Include the topic details in normal subscription emails |
| 1731 | 1695 | } else { |
| 1732 | - $topic_author_name = wp_specialchars_decode( wp_strip_all_tags( $topic_author_name ), ENT_QUOTES ); | |
| 1733 | - $topic_content = wp_specialchars_decode( wp_strip_all_tags( bbp_get_topic_content( $topic_id ) ), ENT_QUOTES ); | |
| 1696 | + $topic_author_name = wp_specialchars_decode( strip_tags( $topic_author_name ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1697 | + $topic_content = wp_specialchars_decode( strip_tags( bbp_get_topic_content( $topic_id ) ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1734 | 1698 | $message = sprintf( |
| 1735 | 1699 | |
| 1736 | 1700 | /* translators: 1: Topic author name, 2: Topic content, 3: Topic URL */ |
| 1737 | 1701 | esc_html__( |
| @@ -1814,25 +1778,25 @@ | ||
| 1814 | 1778 | return true; |
| 1815 | 1779 | } |
| 1816 | 1780 | |
| 1817 | 1781 | /** |
| 1818 | - * Sends notification emails for new replies to subscribed topics. | |
| 1782 | + * Sends notification emails for new replies to subscribed topics | |
| 1819 | 1783 | * |
| 1820 | - * This function is deprecated. Please use: bbp_notify_topic_subscribers(). | |
| 1784 | + * This function is deprecated. Please use: bbp_notify_topic_subscribers() | |
| 1821 | 1785 | * |
| 1822 | 1786 | * @since 2.0.0 bbPress (r2668) |
| 1823 | 1787 | * |
| 1824 | 1788 | * @deprecated 2.6.0 bbPress (r5412) |
| 1825 | 1789 | * |
| 1826 | - * @param int $reply_id ID of the newly made reply. | |
| 1827 | - * @param int $topic_id ID of the topic of the reply. | |
| 1828 | - * @param int $forum_id ID of the forum of the reply. | |
| 1790 | + * @param int $reply_id ID of the newly made reply | |
| 1791 | + * @param int $topic_id ID of the topic of the reply | |
| 1792 | + * @param int $forum_id ID of the forum of the reply | |
| 1829 | 1793 | * @param array $anonymous_data Optional - if it's an anonymous post. Do not |
| 1830 | 1794 | * supply if supplying $author_id. Should be |
| 1831 | - * sanitized (see {@link bbp_filter_anonymous_post_data()}. | |
| 1832 | - * @param int $reply_author ID of the topic author ID. | |
| 1795 | + * sanitized (see {@link bbp_filter_anonymous_post_data()} | |
| 1796 | + * @param int $reply_author ID of the topic author ID | |
| 1833 | 1797 | * |
| 1834 | - * @return bool True on success, false on failure. | |
| 1798 | + * @return bool True on success, false on failure | |
| 1835 | 1799 | */ |
| 1836 | 1800 | function bbp_notify_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = array(), $reply_author = 0 ) { |
| 1837 | 1801 | return bbp_notify_topic_subscribers( $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author ); |
| 1838 | 1802 | } |
| @@ -1837,9 +1801,9 @@ | ||
| 1837 | 1801 | return bbp_notify_topic_subscribers( $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author ); |
| 1838 | 1802 | } |
| 1839 | 1803 | |
| 1840 | 1804 | /** |
| 1841 | - * Return an array of user email addresses from an array of user IDs. | |
| 1805 | + * Return an array of user email addresses from an array of user IDs | |
| 1842 | 1806 | * |
| 1843 | 1807 | * @since 2.6.0 bbPress (r6725) |
| 1844 | 1808 | * |
| 1845 | 1809 | * @param array $user_ids |
| @@ -1980,9 +1944,9 @@ | ||
| 1980 | 1944 | |
| 1981 | 1945 | /** Login *********************************************************************/ |
| 1982 | 1946 | |
| 1983 | 1947 | /** |
| 1984 | - * Return a clean and reliable logout URL. | |
| 1948 | + * Return a clean and reliable logout URL | |
| 1985 | 1949 | * |
| 1986 | 1950 | * This function is used to filter `logout_url`. If no $redirect_to value is |
| 1987 | 1951 | * passed, it will default to the request uri, then the forum root. |
| 1988 | 1952 | * |
| @@ -1989,12 +1953,12 @@ | ||
| 1989 | 1953 | * See: `wp_logout_url()` |
| 1990 | 1954 | * |
| 1991 | 1955 | * @since 2.0.0 bbPress (r2815) |
| 1992 | 1956 | * |
| 1993 | - * @param string $url URL used to log out. | |
| 1957 | + * @param string $url URL used to log out | |
| 1994 | 1958 | * @param string $redirect_to Where to redirect to? |
| 1995 | 1959 | * |
| 1996 | - * @return string The url. | |
| 1960 | + * @return string The url | |
| 1997 | 1961 | */ |
| 1998 | 1962 | function bbp_logout_url( $url = '', $redirect_to = '' ) { |
| 1999 | 1963 | |
| 2000 | 1964 | // If there is no redirect in the URL, let's add one... |
| @@ -2008,16 +1972,11 @@ | ||
| 2008 | 1972 | |
| 2009 | 1973 | // Check for a valid referer |
| 2010 | 1974 | $redirect_to = wp_get_referer(); |
| 2011 | 1975 | |
| 2012 | - // Maybe use current host | |
| 2013 | - if ( ( false === $redirect_to ) && ! empty( $_SERVER['HTTP_HOST'] ) ) { | |
| 2014 | - $redirect_to = bbp_get_url_scheme() . $_SERVER['HTTP_HOST']; | |
| 2015 | - | |
| 2016 | - // Maybe also use request URI | |
| 2017 | - if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { | |
| 2018 | - $redirect_to .= $_SERVER['REQUEST_URI']; | |
| 2019 | - } | |
| 1976 | + // Fallback to request uri if invalid referer | |
| 1977 | + if ( false === $redirect_to ) { | |
| 1978 | + $redirect_to = bbp_get_url_scheme() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |
| 2020 | 1979 | } |
| 2021 | 1980 | } |
| 2022 | 1981 | |
| 2023 | 1982 | // Filter the $redirect_to destination |
| @@ -2028,9 +1987,9 @@ | ||
| 2028 | 1987 | |
| 2029 | 1988 | // Assemble $redirect_to and add it (encoded) to full $url |
| 2030 | 1989 | $appended = add_query_arg( array( 'loggedout' => 'true' ), $validated ); |
| 2031 | 1990 | $encoded = urlencode( $appended ); |
| 2032 | - $url = add_query_arg( array( 'redirect_to' => $encoded ), $url ); | |
| 1991 | + $url = add_query_arg( array( 'redirect_to' => $encoded ), $url ); | |
| 2033 | 1992 | } |
| 2034 | 1993 | |
| 2035 | 1994 | // Filter & return |
| 2036 | 1995 | return apply_filters( 'bbp_logout_url', $url, $redirect_to ); |
| @@ -2047,11 +2006,11 @@ | ||
| 2047 | 2006 | * optional $filter_key parameter. |
| 2048 | 2007 | * |
| 2049 | 2008 | * @since 2.1.0 bbPress (r3840) |
| 2050 | 2009 | * |
| 2051 | - * @param string|array $args Value to merge with $defaults. | |
| 2010 | + * @param string|array $args Value to merge with $defaults | |
| 2052 | 2011 | * @param array $defaults Array that serves as the defaults. |
| 2053 | - * @param string $filter_key String to key the filters from. | |
| 2012 | + * @param string $filter_key String to key the filters from | |
| 2054 | 2013 | * @return array Merged user defined values with defaults. |
| 2055 | 2014 | */ |
| 2056 | 2015 | function bbp_parse_args( $args, $defaults = array(), $filter_key = '' ) { |
| 2057 | 2016 | |
| @@ -2083,9 +2042,9 @@ | ||
| 2083 | 2042 | return $r; |
| 2084 | 2043 | } |
| 2085 | 2044 | |
| 2086 | 2045 | /** |
| 2087 | - * Adds ability to include or exclude specific post_parent ID's. | |
| 2046 | + * Adds ability to include or exclude specific post_parent ID's | |
| 2088 | 2047 | * |
| 2089 | 2048 | * @since 2.0.0 bbPress (r2997) |
| 2090 | 2049 | * |
| 2091 | 2050 | * @deprecated 2.5.8 bbPress (r5814) |
| @@ -2091,12 +2050,12 @@ | ||
| 2091 | 2050 | * @deprecated 2.5.8 bbPress (r5814) |
| 2092 | 2051 | * |
| 2093 | 2052 | * @global WP $wp |
| 2094 | 2053 | * @param string $where |
| 2095 | - * @param WP_Query $query | |
| 2054 | + * @param WP_Query $object | |
| 2096 | 2055 | * @return string |
| 2097 | 2056 | */ |
| 2098 | -function bbp_query_post_parent__in( $where, $query = '' ) { | |
| 2057 | +function bbp_query_post_parent__in( $where, $object = '' ) { | |
| 2099 | 2058 | global $wp; |
| 2100 | 2059 | |
| 2101 | 2060 | // Noop if WP core supports this already |
| 2102 | 2061 | if ( in_array( 'post_parent__in', $wp->private_query_vars, true ) ) { |
| @@ -2103,14 +2062,14 @@ | ||
| 2103 | 2062 | return $where; |
| 2104 | 2063 | } |
| 2105 | 2064 | |
| 2106 | 2065 | // Bail if no object passed |
| 2107 | - if ( empty( $query ) ) { | |
| 2066 | + if ( empty( $object ) ) { | |
| 2108 | 2067 | return $where; |
| 2109 | 2068 | } |
| 2110 | 2069 | |
| 2111 | 2070 | // Only 1 post_parent so return $where |
| 2112 | - if ( is_numeric( $query->query_vars['post_parent'] ) ) { | |
| 2071 | + if ( is_numeric( $object->query_vars['post_parent'] ) ) { | |
| 2113 | 2072 | return $where; |
| 2114 | 2073 | } |
| 2115 | 2074 | |
| 2116 | 2075 | // Get the DB |
| @@ -2116,15 +2075,15 @@ | ||
| 2116 | 2075 | // Get the DB |
| 2117 | 2076 | $bbp_db = bbp_db(); |
| 2118 | 2077 | |
| 2119 | 2078 | // Including specific post_parent's |
| 2120 | - if ( ! empty( $query->query_vars['post_parent__in'] ) ) { | |
| 2121 | - $ids = implode( ',', wp_parse_id_list( $query->query_vars['post_parent__in'] ) ); | |
| 2079 | + if ( ! empty( $object->query_vars['post_parent__in'] ) ) { | |
| 2080 | + $ids = implode( ',', wp_parse_id_list( $object->query_vars['post_parent__in'] ) ); | |
| 2122 | 2081 | $where .= " AND {$bbp_db->posts}.post_parent IN ($ids)"; |
| 2123 | 2082 | |
| 2124 | 2083 | // Excluding specific post_parent's |
| 2125 | - } elseif ( ! empty( $query->query_vars['post_parent__not_in'] ) ) { | |
| 2126 | - $ids = implode( ',', wp_parse_id_list( $query->query_vars['post_parent__not_in'] ) ); | |
| 2084 | + } elseif ( ! empty( $object->query_vars['post_parent__not_in'] ) ) { | |
| 2085 | + $ids = implode( ',', wp_parse_id_list( $object->query_vars['post_parent__not_in'] ) ); | |
| 2127 | 2086 | $where .= " AND {$bbp_db->posts}.post_parent NOT IN ($ids)"; |
| 2128 | 2087 | } |
| 2129 | 2088 | |
| 2130 | 2089 | // Return possibly modified $where |
| @@ -2131,9 +2090,9 @@ | ||
| 2131 | 2090 | return $where; |
| 2132 | 2091 | } |
| 2133 | 2092 | |
| 2134 | 2093 | /** |
| 2135 | - * Query the DB and get the last public post_id that has parent_id as post_parent. | |
| 2094 | + * Query the DB and get the last public post_id that has parent_id as post_parent | |
| 2136 | 2095 | * |
| 2137 | 2096 | * @since 2.0.0 bbPress (r2868) |
| 2138 | 2097 | * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects |
| 2139 | 2098 | * |
| @@ -2138,9 +2097,9 @@ | ||
| 2138 | 2097 | * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects |
| 2139 | 2098 | * |
| 2140 | 2099 | * @param int $parent_id Parent id. |
| 2141 | 2100 | * @param string $post_type Post type. Defaults to 'post'. |
| 2142 | - * @return int The last active post_id. | |
| 2101 | + * @return int The last active post_id | |
| 2143 | 2102 | */ |
| 2144 | 2103 | function bbp_get_public_child_last_id( $parent_id = 0, $post_type = 'post' ) { |
| 2145 | 2104 | |
| 2146 | 2105 | // Bail if nothing passed |
| @@ -2195,9 +2154,9 @@ | ||
| 2195 | 2154 | return (int) apply_filters( 'bbp_get_public_child_last_id', $child_id, $parent_id, $post_type ); |
| 2196 | 2155 | } |
| 2197 | 2156 | |
| 2198 | 2157 | /** |
| 2199 | - * Query the database for child counts, grouped by type & status. | |
| 2158 | + * Query the database for child counts, grouped by type & status | |
| 2200 | 2159 | * |
| 2201 | 2160 | * @since 2.6.0 bbPress (r6827) |
| 2202 | 2161 | * |
| 2203 | 2162 | * @param int $parent_id |
| @@ -2266,15 +2225,15 @@ | ||
| 2266 | 2225 | return (array) apply_filters( 'bbp_get_child_counts', $retval, $parent_id ); |
| 2267 | 2226 | } |
| 2268 | 2227 | |
| 2269 | 2228 | /** |
| 2270 | - * Filter a list of child counts, from `bbp_get_child_counts()`. | |
| 2229 | + * Filter a list of child counts, from `bbp_get_child_counts()` | |
| 2271 | 2230 | * |
| 2272 | 2231 | * @since 2.6.0 bbPress (r6827) |
| 2273 | 2232 | * |
| 2274 | - * @param int $parent_id ID of post to get child counts from. | |
| 2275 | - * @param array $types Optional. An array of post types to filter by. | |
| 2276 | - * @param array $statuses Optional. An array of post statuses to filter by. | |
| 2233 | + * @param int $parent_id ID of post to get child counts from | |
| 2234 | + * @param array $types Optional. An array of post types to filter by | |
| 2235 | + * @param array $statuses Optional. An array of post statuses to filter by | |
| 2277 | 2236 | * |
| 2278 | 2237 | * @return array A list of objects or object fields. |
| 2279 | 2238 | */ |
| 2280 | 2239 | function bbp_filter_child_counts_list( $parent_id = 0, $types = array( 'post' ), $statuses = array() ) { |
| @@ -2306,9 +2265,9 @@ | ||
| 2306 | 2265 | return (array) apply_filters( 'bbp_filter_child_counts_list', $retval, $parent_id, $types, $statuses ); |
| 2307 | 2266 | } |
| 2308 | 2267 | |
| 2309 | 2268 | /** |
| 2310 | - * Query the DB and get a count of public children. | |
| 2269 | + * Query the DB and get a count of public children | |
| 2311 | 2270 | * |
| 2312 | 2271 | * @since 2.0.0 bbPress (r2868) |
| 2313 | 2272 | * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects |
| 2314 | 2273 | * |
| @@ -2313,9 +2272,9 @@ | ||
| 2313 | 2272 | * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects |
| 2314 | 2273 | * |
| 2315 | 2274 | * @param int $parent_id Parent id. |
| 2316 | 2275 | * @param string $post_type Post type. Defaults to 'post'. |
| 2317 | - * @return int The number of children. | |
| 2276 | + * @return int The number of children | |
| 2318 | 2277 | */ |
| 2319 | 2278 | function bbp_get_public_child_count( $parent_id = 0, $post_type = 'post' ) { |
| 2320 | 2279 | |
| 2321 | 2280 | // Bail if nothing passed |
| @@ -2352,16 +2311,16 @@ | ||
| 2352 | 2311 | // Filter & return |
| 2353 | 2312 | return (int) apply_filters( 'bbp_get_public_child_count', $child_count, $parent_id, $post_type ); |
| 2354 | 2313 | } |
| 2355 | 2314 | /** |
| 2356 | - * Query the DB and get a count of public children. | |
| 2315 | + * Query the DB and get a count of public children | |
| 2357 | 2316 | * |
| 2358 | 2317 | * @since 2.6.0 bbPress (r6827) |
| 2359 | - * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects. | |
| 2318 | + * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects | |
| 2360 | 2319 | * |
| 2361 | 2320 | * @param int $parent_id Parent id. |
| 2362 | 2321 | * @param string $post_type Post type. Defaults to 'post'. |
| 2363 | - * @return int The number of children. | |
| 2322 | + * @return int The number of children | |
| 2364 | 2323 | */ |
| 2365 | 2324 | function bbp_get_non_public_child_count( $parent_id = 0, $post_type = 'post' ) { |
| 2366 | 2325 | |
| 2367 | 2326 | // Bail if nothing passed |
| @@ -2403,9 +2362,9 @@ | ||
| 2403 | 2362 | return (int) apply_filters( 'bbp_get_non_public_child_count', $child_count, $parent_id, $post_type ); |
| 2404 | 2363 | } |
| 2405 | 2364 | |
| 2406 | 2365 | /** |
| 2407 | - * Query the DB and get the child id's of public children. | |
| 2366 | + * Query the DB and get the child id's of public children | |
| 2408 | 2367 | * |
| 2409 | 2368 | * @since 2.0.0 bbPress (r2891) |
| 2410 | 2369 | * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects |
| 2411 | 2370 | * |
| @@ -2411,9 +2370,9 @@ | ||
| 2411 | 2370 | * |
| 2412 | 2371 | * @param int $parent_id Parent id. |
| 2413 | 2372 | * @param string $post_type Post type. Defaults to 'post'. |
| 2414 | 2373 | * |
| 2415 | - * @return array The array of children. | |
| 2374 | + * @return array The array of children | |
| 2416 | 2375 | */ |
| 2417 | 2376 | function bbp_get_public_child_ids( $parent_id = 0, $post_type = 'post' ) { |
| 2418 | 2377 | |
| 2419 | 2378 | // Bail if nothing passed |
| @@ -2473,16 +2432,16 @@ | ||
| 2473 | 2432 | return (array) apply_filters( 'bbp_get_public_child_ids', $child_ids, $parent_id, $post_type ); |
| 2474 | 2433 | } |
| 2475 | 2434 | |
| 2476 | 2435 | /** |
| 2477 | - * Query the DB and get the child id's of all children. | |
| 2436 | + * Query the DB and get the child id's of all children | |
| 2478 | 2437 | * |
| 2479 | 2438 | * @since 2.0.0 bbPress (r3325) |
| 2480 | 2439 | * |
| 2481 | - * @param int $parent_id Parent id. | |
| 2482 | - * @param string $post_type Post type. Defaults to 'post'. | |
| 2440 | + * @param int $parent_id Parent id | |
| 2441 | + * @param string $post_type Post type. Defaults to 'post' | |
| 2483 | 2442 | * |
| 2484 | - * @return array The array of children. | |
| 2443 | + * @return array The array of children | |
| 2485 | 2444 | */ |
| 2486 | 2445 | function bbp_get_all_child_ids( $parent_id = 0, $post_type = 'post' ) { |
| 2487 | 2446 | |
| 2488 | 2447 | // Bail if nothing passed |
| @@ -2543,11 +2502,11 @@ | ||
| 2543 | 2502 | * Also see: bbp_update_post_author_caches() |
| 2544 | 2503 | * |
| 2545 | 2504 | * @since 2.6.0 bbPress (r6700) |
| 2546 | 2505 | * |
| 2547 | - * @param array $objects Array of objects, fresh from a query. | |
| 2506 | + * @param array $objects Array of objects, fresh from a query | |
| 2548 | 2507 | * |
| 2549 | - * @return bool True if some IDs were cached. | |
| 2508 | + * @return bool True if some IDs were cached | |
| 2550 | 2509 | */ |
| 2551 | 2510 | function bbp_update_post_family_caches( $objects = array() ) { |
| 2552 | 2511 | |
| 2553 | 2512 | // Bail if no posts |
| @@ -2616,11 +2575,11 @@ | ||
| 2616 | 2575 | * This is triggered when a `update_post_author_cache` argument is set to true. |
| 2617 | 2576 | * |
| 2618 | 2577 | * @since 2.6.0 bbPress (r6700) |
| 2619 | 2578 | * |
| 2620 | - * @param array $objects Array of objects, fresh from a query. | |
| 2579 | + * @param array $objects Array of objects, fresh from a query | |
| 2621 | 2580 | * |
| 2622 | - * @return bool True if some IDs were cached. | |
| 2581 | + * @return bool True if some IDs were cached | |
| 2623 | 2582 | */ |
| 2624 | 2583 | function bbp_update_post_author_caches( $objects = array() ) { |
| 2625 | 2584 | |
| 2626 | 2585 | // Bail if no posts |
| @@ -2661,17 +2620,17 @@ | ||
| 2661 | 2620 | |
| 2662 | 2621 | /** Globals *******************************************************************/ |
| 2663 | 2622 | |
| 2664 | 2623 | /** |
| 2665 | - * Get the unfiltered value of a global $post's key. | |
| 2624 | + * Get the unfiltered value of a global $post's key | |
| 2666 | 2625 | * |
| 2667 | - * Used most frequently when editing a forum/topic/reply. | |
| 2626 | + * Used most frequently when editing a forum/topic/reply | |
| 2668 | 2627 | * |
| 2669 | 2628 | * @since 2.1.0 bbPress (r3702) |
| 2670 | 2629 | * |
| 2671 | - * @param string $field Name of the key. | |
| 2672 | - * @param string $context How to sanitize - raw|edit|db|display|attribute|js. | |
| 2673 | - * @return string Field value. | |
| 2630 | + * @param string $field Name of the key | |
| 2631 | + * @param string $context How to sanitize - raw|edit|db|display|attribute|js | |
| 2632 | + * @return string Field value | |
| 2674 | 2633 | */ |
| 2675 | 2634 | function bbp_get_global_post_field( $field = 'ID', $context = 'edit' ) { |
| 2676 | 2635 | |
| 2677 | 2636 | // Get the post, and maybe get a field from it |
| @@ -2692,10 +2651,10 @@ | ||
| 2692 | 2651 | * To avoid security exploits within the theme. |
| 2693 | 2652 | * |
| 2694 | 2653 | * @since 2.1.0 bbPress (r4023) |
| 2695 | 2654 | * |
| 2696 | - * @param string $action Action nonce. | |
| 2697 | - * @param string $query_arg where to look for nonce in $_REQUEST. | |
| 2655 | + * @param string $action Action nonce | |
| 2656 | + * @param string $query_arg where to look for nonce in $_REQUEST | |
| 2698 | 2657 | */ |
| 2699 | 2658 | function bbp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) { |
| 2700 | 2659 | |
| 2701 | 2660 | /** Home URL **************************************************************/ |
| @@ -2770,9 +2729,9 @@ | ||
| 2770 | 2729 | * |
| 2771 | 2730 | * Mirrors the handling in WordPress's get_the_content_feed() while preserving |
| 2772 | 2731 | * bbPress's topic and reply content filters. |
| 2773 | 2732 | * |
| 2774 | - * @since 2.6.19 bbPress (r7619) | |
| 2733 | + * @since 2.6.19 bbPress (r7620) | |
| 2775 | 2734 | * |
| 2776 | 2735 | * @param string $content Feed content. |
| 2777 | 2736 | * @return string Content safe to include in a CDATA section. |
| 2778 | 2737 | */ |
| @@ -3021,14 +2980,14 @@ | ||
| 3021 | 2980 | |
| 3022 | 2981 | /** Templates ******************************************************************/ |
| 3023 | 2982 | |
| 3024 | 2983 | /** |
| 3025 | - * Used to guess if page exists at requested path. | |
| 2984 | + * Used to guess if page exists at requested path | |
| 3026 | 2985 | * |
| 3027 | 2986 | * @since 2.0.0 bbPress (r3304) |
| 3028 | 2987 | * |
| 3029 | 2988 | * @param string $path |
| 3030 | - * @return mixed False if no page, Page object if true. | |
| 2989 | + * @return mixed False if no page, Page object if true | |
| 3031 | 2990 | */ |
| 3032 | 2991 | function bbp_get_page_by_path( $path = '' ) { |
| 3033 | 2992 | |
| 3034 | 2993 | // Default to false |
| @@ -3058,9 +3017,9 @@ | ||
| 3058 | 3017 | * bbPress post types are excluded from search because their visibility depends |
| 3059 | 3018 | * on forum access. Older versions of WordPress may otherwise guess a restricted |
| 3060 | 3019 | * forum or topic permalink from a partial slug and expose its full title. |
| 3061 | 3020 | * |
| 3062 | - * @since 2.6.17 bbPress (r7499) | |
| 3021 | + * @since 2.6.17 bbPress (r7500) | |
| 3063 | 3022 | * |
| 3064 | 3023 | * @param bool $do_redirect_guess Whether to attempt to guess a redirect URL. |
| 3065 | 3024 | * |
| 3066 | 3025 | * @return bool Whether to attempt to guess a redirect URL. |
| @@ -3082,11 +3041,11 @@ | ||
| 3082 | 3041 | * |
| 3083 | 3042 | * @since 2.0.0 bbPress (r3051) |
| 3084 | 3043 | * @since 2.6.0 bbPress (r6583) Use status_header() & nocache_headers() |
| 3085 | 3044 | * |
| 3086 | - * @param WP_Query $query The query being checked. | |
| 3045 | + * @param WP_Query $query The query being checked | |
| 3087 | 3046 | * |
| 3088 | - * @return bool Always returns true. | |
| 3047 | + * @return bool Always returns true | |
| 3089 | 3048 | */ |
| 3090 | 3049 | function bbp_set_404( $query = null ) { |
| 3091 | 3050 | |
| 3092 | 3051 | // Global fallback |
| @@ -3111,9 +3070,9 @@ | ||
| 3111 | 3070 | status_header( 200 ); |
| 3112 | 3071 | } |
| 3113 | 3072 | |
| 3114 | 3073 | /** |
| 3115 | - * Maybe handle the default 404 handling for some bbPress conditions. | |
| 3074 | + * Maybe handle the default 404 handling for some bbPress conditions | |
| 3116 | 3075 | * |
| 3117 | 3076 | * Some conditions (like private/hidden forums and edits) have their own checks |
| 3118 | 3077 | * on `bbp_template_redirect` and are not currently 404s. |
| 3119 | 3078 | * |
| @@ -3118,12 +3077,12 @@ | ||
| 3118 | 3077 | * on `bbp_template_redirect` and are not currently 404s. |
| 3119 | 3078 | * |
| 3120 | 3079 | * @since 2.6.0 bbPress (r6554) |
| 3121 | 3080 | * |
| 3122 | - * @param bool $override Whether to override the default handler. | |
| 3123 | - * @param WP_Query $wp_query The posts query being referenced. | |
| 3081 | + * @param bool $override Whether to override the default handler | |
| 3082 | + * @param WP_Query $wp_query The posts query being referenced | |
| 3124 | 3083 | * |
| 3125 | - * @return bool False to leave alone, true to override. | |
| 3084 | + * @return bool False to leave alone, true to override | |
| 3126 | 3085 | */ |
| 3127 | 3086 | function bbp_pre_handle_404( $override = false, $wp_query = false ) { |
| 3128 | 3087 | |
| 3129 | 3088 | // Handle a bbPress 404 condition |
| @@ -3151,9 +3110,9 @@ | ||
| 3151 | 3110 | * currently only used to avoid calling the main query when it's not necessary. |
| 3152 | 3111 | * |
| 3153 | 3112 | * @since 2.6.0 bbPress (r6583) |
| 3154 | 3113 | * |
| 3155 | - * @param mixed $posts Default null. Array of posts (possibly empty). | |
| 3114 | + * @param mixed $posts Default null. Array of posts (possibly empty) | |
| 3156 | 3115 | * @param WP_Query $wp_query |
| 3157 | 3116 | * |
| 3158 | 3117 | * @return mixed Null if no override. Array if overridden. |
| 3159 | 3118 | */ |
| @@ -3185,12 +3144,10 @@ | ||
| 3185 | 3144 | |
| 3186 | 3145 | /** |
| 3187 | 3146 | * Is a title longer that the maximum title length? |
| 3188 | 3147 | * |
| 3189 | - * Uses mb_strlen() in `utf-8` mode to treat strings as is. This differs from | |
| 3190 | - * the behavior present in Comments, PHPMailer, RandomCompat, and others, | |
| 3191 | - * because the database column used by titles (posts.post_title) is | |
| 3192 | - * TEXT (characters) and not VARCHAR (bytes). | |
| 3148 | + * Uses mb_strlen() in `8bit` mode to treat strings as raw. This matches the | |
| 3149 | + * behavior present in Comments, PHPMailer, RandomCompat, and others. | |
| 3193 | 3150 | * |
| 3194 | 3151 | * @since 2.6.0 bbPress (r6784) |
| 3195 | 3152 | * |
| 3196 | 3153 | * @param string $title |
| @@ -3197,9 +3154,9 @@ | ||
| 3197 | 3154 | * @return bool |
| 3198 | 3155 | */ |
| 3199 | 3156 | function bbp_is_title_too_long( $title = '' ) { |
| 3200 | 3157 | $max = bbp_get_title_max_length(); |
| 3201 | - $len = mb_strlen( $title, 'utf-8' ); | |
| 3158 | + $len = mb_strlen( $title, '8bit' ); | |
| 3202 | 3159 | $result = ( $len > $max ); |
| 3203 | 3160 | |
| 3204 | 3161 | // Filter & return |
| 3205 | 3162 | return (bool) apply_filters( 'bbp_is_title_too_long', $result, $title, $max, $len ); |