| @@ -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 (r6813) |
| 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() ) { |
| @@ -39,13 +39,13 @@ | ||
| 39 | 39 | |
| 40 | 40 | /** URLs **********************************************************************/ |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | - * Return the unescaped redirect_to request value. | |
| 43 | + * Return the unescaped redirect_to request value | |
| 44 | 44 | * |
| 45 | - * @since bbPress (r4655) | |
| 45 | + * @bbPress (r4655) | |
| 46 | 46 | * |
| 47 | - * @return string The URL to redirect to, if set. | |
| 47 | + * @return string The URL to redirect to, if set | |
| 48 | 48 | */ |
| 49 | 49 | function bbp_get_redirect_to() { |
| 50 | 50 | |
| 51 | 51 | // Check 'redirect_to' request parameter |
| @@ -61,11 +61,11 @@ | ||
| 61 | 61 | * Append 'view=all' to query string if it's already there from referer |
| 62 | 62 | * |
| 63 | 63 | * @since 2.0.0 bbPress (r3325) |
| 64 | 64 | * |
| 65 | - * @param string $original_link Original Link to be modified. | |
| 66 | - * @param bool $force Override bbp_get_view_all() check. | |
| 67 | - * @return string The link with 'view=all' appended if necessary. | |
| 65 | + * @param string $original_link Original Link to be modified | |
| 66 | + * @param bool $force Override bbp_get_view_all() check | |
| 67 | + * @return string The link with 'view=all' appended if necessary | |
| 68 | 68 | */ |
| 69 | 69 | function bbp_add_view_all( $original_link = '', $force = false ) { |
| 70 | 70 | |
| 71 | 71 | // Are we appending the view=all vars? |
| @@ -77,14 +77,14 @@ | ||
| 77 | 77 | return apply_filters( 'bbp_add_view_all', $link, $original_link ); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | - * Remove 'view=all' from query string. | |
| 81 | + * Remove 'view=all' from query string | |
| 82 | 82 | * |
| 83 | 83 | * @since 2.0.0 bbPress (r3325) |
| 84 | 84 | * |
| 85 | - * @param string $original_link Original Link to be modified. | |
| 86 | - * @return string The link with 'view=all' appended if necessary. | |
| 85 | + * @param string $original_link Original Link to be modified | |
| 86 | + * @return string The link with 'view=all' appended if necessary | |
| 87 | 87 | */ |
| 88 | 88 | function bbp_remove_view_all( $original_link = '' ) { |
| 89 | 89 | |
| 90 | 90 | // Remove `view' argument |
| @@ -94,14 +94,15 @@ | ||
| 94 | 94 | return apply_filters( 'bbp_remove_view_all', $link, $original_link ); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | - * If current user can and is viewing all topics/replies. | |
| 98 | + * If current user can and is viewing all topics/replies | |
| 99 | 99 | * |
| 100 | 100 | * @since 2.0.0 bbPress (r3325) |
| 101 | 101 | * |
| 102 | - * @param string $cap Capability used to ensure user can view all. | |
| 103 | - * @return bool Whether current user can and is viewing all. | |
| 102 | + * @param string $cap Capability used to ensure user can view all | |
| 103 | + * | |
| 104 | + * @return bool Whether current user can and is viewing all | |
| 104 | 105 | */ |
| 105 | 106 | function bbp_get_view_all( $cap = 'moderate' ) { |
| 106 | 107 | $retval = ( ( ! empty( $_GET['view'] ) && ( 'all' === $_GET['view'] ) && current_user_can( $cap ) ) ); |
| 107 | 108 | |
| @@ -109,13 +110,13 @@ | ||
| 109 | 110 | return (bool) apply_filters( 'bbp_get_view_all', (bool) $retval, $cap ); |
| 110 | 111 | } |
| 111 | 112 | |
| 112 | 113 | /** |
| 113 | - * Assist pagination by returning correct page number. | |
| 114 | + * Assist pagination by returning correct page number | |
| 114 | 115 | * |
| 115 | 116 | * @since 2.0.0 bbPress (r2628) |
| 116 | 117 | * |
| 117 | - * @return int Current page number. | |
| 118 | + * @return int Current page number | |
| 118 | 119 | */ |
| 119 | 120 | function bbp_get_paged() { |
| 120 | 121 | $wp_query = bbp_get_wp_query(); |
| 121 | 122 | |
| @@ -139,51 +140,18 @@ | ||
| 139 | 140 | |
| 140 | 141 | /** Misc **********************************************************************/ |
| 141 | 142 | |
| 142 | 143 | /** |
| 143 | - * Filters whether or not to use the block editor for bbPress post types. | |
| 144 | - * | |
| 145 | - * As of 2.7.0 this is explicitly false, because the `show_in_rest` property | |
| 146 | - * of each post type is now set to true, and because support for blocks in | |
| 147 | - * user-facing forum content is not properly handled yet. | |
| 148 | - * | |
| 149 | - * The default return value of this function is highly likely to change once | |
| 150 | - * the block editor is integrated into the Forum/Topic/Reply experience. | |
| 151 | - * | |
| 152 | - * If you're feeling adventurous or working on this feature, override this | |
| 153 | - * filter with | |
| 154 | - * | |
| 155 | - * @since 2.7.0 bbPress (r7388) | |
| 156 | - * | |
| 157 | - * @param bool $using Optional. Default false. If using. | |
| 158 | - * @param string $post_type Optional. Default empty string. The post type to check. | |
| 159 | - * | |
| 160 | - * @return bool | |
| 161 | - */ | |
| 162 | -function bbp_filter_use_block_editor_for_post_type( $using = false, $post_type = '' ) { | |
| 163 | - | |
| 164 | - // Get bbPress post types | |
| 165 | - $bbp_post_types = bbp_get_post_types(); | |
| 166 | - | |
| 167 | - // Compare post types | |
| 168 | - $is_post_type = in_array( $post_type, $bbp_post_types, true ); | |
| 169 | - $retval = ! $is_post_type; | |
| 170 | - | |
| 171 | - // Filter & return | |
| 172 | - return (bool) apply_filters( 'bbp_filter_use_block_editor_for_post_type', $retval, $is_post_type, $using, $post_type ); | |
| 173 | -} | |
| 174 | - | |
| 175 | -/** | |
| 176 | 144 | * Return the unique non-empty values of an array. |
| 177 | 145 | * |
| 178 | 146 | * @since 2.6.0 bbPress (r6481) |
| 179 | 147 | * |
| 180 | - * @param array $arr Array to get values of. | |
| 148 | + * @param array $array Array to get values of | |
| 181 | 149 | * |
| 182 | 150 | * @return array |
| 183 | 151 | */ |
| 184 | -function bbp_get_unique_array_values( $arr = array() ) { | |
| 185 | - return array_unique( array_filter( array_values( $arr ) ) ); | |
| 152 | +function bbp_get_unique_array_values( $array = array() ) { | |
| 153 | + return array_unique( array_filter( array_values( $array ) ) ); | |
| 186 | 154 | } |
| 187 | 155 | |
| 188 | 156 | /** |
| 189 | 157 | * Return the non-empty string values of an array. |
| @@ -189,9 +157,9 @@ | ||
| 189 | 157 | * Return the non-empty string values of an array. |
| 190 | 158 | * |
| 191 | 159 | * @since 2.6.17 bbPress |
| 192 | 160 | * |
| 193 | - * @param mixed $arr Value or array to get string values of. | |
| 161 | + * @param mixed $arr Value or array to get string values of | |
| 194 | 162 | * |
| 195 | 163 | * @return array |
| 196 | 164 | */ |
| 197 | 165 | function bbp_get_string_array_values( $arr = array() ) { |
| @@ -206,9 +174,9 @@ | ||
| 206 | 174 | return $retval; |
| 207 | 175 | } |
| 208 | 176 | |
| 209 | 177 | /** |
| 210 | - * Fix post author id on post save. | |
| 178 | + * Fix post author id on post save | |
| 211 | 179 | * |
| 212 | 180 | * When a logged in user changes the status of an anonymous reply or topic, or |
| 213 | 181 | * edits it, the post_author field is set to the logged in user's id. This |
| 214 | 182 | * function fixes that. |
| @@ -214,11 +182,11 @@ | ||
| 214 | 182 | * function fixes that. |
| 215 | 183 | * |
| 216 | 184 | * @since 2.0.0 bbPress (r2734) |
| 217 | 185 | * |
| 218 | - * @param array $data Post data. | |
| 219 | - * @param array $postarr Original post array (includes post id). | |
| 220 | - * @return array Data. | |
| 186 | + * @param array $data Post data | |
| 187 | + * @param array $postarr Original post array (includes post id) | |
| 188 | + * @return array Data | |
| 221 | 189 | */ |
| 222 | 190 | function bbp_fix_post_author( $data = array(), $postarr = array() ) { |
| 223 | 191 | |
| 224 | 192 | // Post is not being updated or the post_author is already 0, return |
| @@ -254,11 +222,11 @@ | ||
| 254 | 222 | * {@link https://bbpress.trac.wordpress.org/ticket/3433}. |
| 255 | 223 | * |
| 256 | 224 | * @since 2.6.10 bbPress (r7233) |
| 257 | 225 | * |
| 258 | - * @param string $new_status New status to use when untrashing. Default: 'draft'. | |
| 259 | - * @param int $post_id Post ID. | |
| 260 | - * @param string $previous_status Previous post status from '_wp_trash_meta_status' meta key. Default: 'pending'. | |
| 226 | + * @param string $new_status New status to use when untrashing. Default: 'draft' | |
| 227 | + * @param int $post_id Post ID | |
| 228 | + * @param string $previous_status Previous post status from '_wp_trash_meta_status' meta key. Default: 'pending' | |
| 261 | 229 | */ |
| 262 | 230 | function bbp_fix_untrash_post_status( $new_status = 'draft', $post_id = 0, $previous_status = 'pending' ) { |
| 263 | 231 | |
| 264 | 232 | // Bail if not a forum, topic, or reply |
| @@ -409,9 +377,9 @@ | ||
| 409 | 377 | * |
| 410 | 378 | * @since 2.0.0 bbPress (r3133) |
| 411 | 379 | * @since 2.6.0 bbPress (r6868) Inverted some logic and added unit tests |
| 412 | 380 | * |
| 413 | - * @param string $datetime Gets run through strtotime(). | |
| 381 | + * @param string $datetime Gets run through strtotime() | |
| 414 | 382 | * @param boolean $utc Default true. Is the timestamp in UTC? |
| 415 | 383 | * |
| 416 | 384 | * @return bool True by default, if date is past, or editing is disabled. |
| 417 | 385 | */ |
| @@ -439,11 +407,9 @@ | ||
| 439 | 407 | $lockable .= ' UTC'; |
| 440 | 408 | } |
| 441 | 409 | |
| 442 | 410 | // Now |
| 443 | - $cur_time = empty( $utc ) | |
| 444 | - ? (int) wp_date( 'U' ) | |
| 445 | - : time(); | |
| 411 | + $cur_time = current_time( 'timestamp', $utc ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested | |
| 446 | 412 | |
| 447 | 413 | // Get the duration in seconds |
| 448 | 414 | $duration = strtotime( $lockable ) - $cur_time; |
| 449 | 415 | |
| @@ -469,10 +435,10 @@ | ||
| 469 | 435 | * immediately. |
| 470 | 436 | * |
| 471 | 437 | * @since 2.6.0 bbPress (r6424) |
| 472 | 438 | * |
| 473 | - * @param string $context Provide context for additional filtering. | |
| 474 | - * @return int Number of days items remain in trash. | |
| 439 | + * @param string $context Provide context for additional filtering | |
| 440 | + * @return int Number of days items remain in trash | |
| 475 | 441 | */ |
| 476 | 442 | function bbp_get_trash_days( $context = 'forum' ) { |
| 477 | 443 | |
| 478 | 444 | // Sanitize the context |
| @@ -489,9 +455,9 @@ | ||
| 489 | 455 | |
| 490 | 456 | /** Statistics ****************************************************************/ |
| 491 | 457 | |
| 492 | 458 | /** |
| 493 | - * Get the forum statistics. | |
| 459 | + * Get the forum statistics | |
| 494 | 460 | * |
| 495 | 461 | * @since 2.0.0 bbPress (r2769) |
| 496 | 462 | * @since 2.6.0 bbPress (r6055) Added: |
| 497 | 463 | * `count_pending_topics` |
| @@ -591,11 +557,11 @@ | ||
| 591 | 557 | $hidden = bbp_get_hidden_status_id(); |
| 592 | 558 | $spam = bbp_get_spam_status_id(); |
| 593 | 559 | $trash = bbp_get_trash_status_id(); |
| 594 | 560 | |
| 595 | - // Users with a forum role on the current site | |
| 561 | + // Users | |
| 596 | 562 | $user_count = ! empty( $r['count_users'] ) |
| 597 | - ? bbp_get_total_forum_users() | |
| 563 | + ? bbp_get_total_users() | |
| 598 | 564 | : 0; |
| 599 | 565 | |
| 600 | 566 | // Forums |
| 601 | 567 | $forum_count = ! empty( $r['count_forums'] ) |
| @@ -745,20 +711,17 @@ | ||
| 745 | 711 | } |
| 746 | 712 | } |
| 747 | 713 | |
| 748 | 714 | // Tally the tallies |
| 749 | - $counts = array_map( | |
| 750 | - 'absint', | |
| 751 | - compact( | |
| 752 | - 'user_count', | |
| 753 | - 'forum_count', | |
| 754 | - 'topic_count', | |
| 755 | - 'topic_count_hidden', | |
| 756 | - 'reply_count', | |
| 757 | - 'reply_count_hidden', | |
| 758 | - 'topic_tag_count', | |
| 759 | - 'empty_topic_tag_count' | |
| 760 | - ) | |
| 715 | + $counts = compact( | |
| 716 | + 'user_count', | |
| 717 | + 'forum_count', | |
| 718 | + 'topic_count', | |
| 719 | + 'topic_count_hidden', | |
| 720 | + 'reply_count', | |
| 721 | + 'reply_count_hidden', | |
| 722 | + 'topic_tag_count', | |
| 723 | + 'empty_topic_tag_count' | |
| 761 | 724 | ); |
| 762 | 725 | |
| 763 | 726 | // Define return value |
| 764 | 727 | $statistics = array(); |
| @@ -780,9 +743,9 @@ | ||
| 780 | 743 | |
| 781 | 744 | /** New/edit topic/reply helpers **********************************************/ |
| 782 | 745 | |
| 783 | 746 | /** |
| 784 | - * Filter anonymous post data. | |
| 747 | + * Filter anonymous post data | |
| 785 | 748 | * |
| 786 | 749 | * We use REMOTE_ADDR here directly. If you are behind a proxy, you should |
| 787 | 750 | * ensure that it is properly set, such as in wp-config.php, for your |
| 788 | 751 | * environment. See {@link https://core.trac.wordpress.org/ticket/9235} |
| @@ -793,10 +756,10 @@ | ||
| 793 | 756 | * If there are any errors, those are directly added to {@link bbPress:errors} |
| 794 | 757 | * |
| 795 | 758 | * @since 2.0.0 bbPress (r2734) |
| 796 | 759 | * |
| 797 | - * @param array $args Optional. If no args are there, then $_POST values are. | |
| 798 | - * @return bool|array False on errors, values in an array on success. | |
| 760 | + * @param array $args Optional. If no args are there, then $_POST values are | |
| 761 | + * @return bool|array False on errors, values in an array on success | |
| 799 | 762 | */ |
| 800 | 763 | function bbp_filter_anonymous_post_data( $args = array() ) { |
| 801 | 764 | |
| 802 | 765 | // Parse arguments against default values |
| @@ -832,9 +795,9 @@ | ||
| 832 | 795 | return (array) apply_filters( 'bbp_filter_anonymous_post_data', $r, $args ); |
| 833 | 796 | } |
| 834 | 797 | |
| 835 | 798 | /** |
| 836 | - * Sanitize an array of anonymous post author data. | |
| 799 | + * Sanitize an array of anonymous post author data | |
| 837 | 800 | * |
| 838 | 801 | * @since 2.6.0 bbPress (r6400) |
| 839 | 802 | * |
| 840 | 803 | * @param array $anonymous_data |
| @@ -871,9 +834,9 @@ | ||
| 871 | 834 | return (array) apply_filters( 'bbp_sanitize_anonymous_post_author', $r, $anonymous_data ); |
| 872 | 835 | } |
| 873 | 836 | |
| 874 | 837 | /** |
| 875 | - * Update the relevant meta-data for an anonymous post author. | |
| 838 | + * Update the relevant meta-data for an anonymous post author | |
| 876 | 839 | * |
| 877 | 840 | * @since 2.6.0 bbPress (r6400) |
| 878 | 841 | * |
| 879 | 842 | * @param int $post_id |
| @@ -917,16 +880,16 @@ | ||
| 917 | 880 | } |
| 918 | 881 | } |
| 919 | 882 | |
| 920 | 883 | /** |
| 921 | - * Check for duplicate topics/replies. | |
| 884 | + * Check for duplicate topics/replies | |
| 922 | 885 | * |
| 923 | - * Check to make sure that a user is not making a duplicate post. | |
| 886 | + * Check to make sure that a user is not making a duplicate post | |
| 924 | 887 | * |
| 925 | 888 | * @since 2.0.0 bbPress (r2763) |
| 926 | 889 | * |
| 927 | - * @param array $post_data Contains information about the comment. | |
| 928 | - * @return bool True if it is not a duplicate, false if it is. | |
| 890 | + * @param array $post_data Contains information about the comment | |
| 891 | + * @return bool True if it is not a duplicate, false if it is | |
| 929 | 892 | */ |
| 930 | 893 | function bbp_check_for_duplicate( $post_data = array() ) { |
| 931 | 894 | |
| 932 | 895 | // Parse arguments against default values |
| @@ -1010,9 +973,9 @@ | ||
| 1010 | 973 | return true; |
| 1011 | 974 | } |
| 1012 | 975 | |
| 1013 | 976 | /** |
| 1014 | - * Check for flooding. | |
| 977 | + * Check for flooding | |
| 1015 | 978 | * |
| 1016 | 979 | * Check to make sure that a user is not making too many posts in a short amount |
| 1017 | 980 | * of time. |
| 1018 | 981 | * |
| @@ -1019,12 +982,12 @@ | ||
| 1019 | 982 | * @since 2.0.0 bbPress (r2734) |
| 1020 | 983 | * |
| 1021 | 984 | * @param array $anonymous_data Optional - if it's an anonymous post. Do not |
| 1022 | 985 | * supply if supplying $author_id. Should be |
| 1023 | - * sanitized (see {@link bbp_filter_anonymous_post_data()}. | |
| 986 | + * sanitized (see {@link bbp_filter_anonymous_post_data()} | |
| 1024 | 987 | * @param int $author_id Optional. Supply if it's a post by a logged in user. |
| 1025 | 988 | * Do not supply if supplying $anonymous_data. |
| 1026 | - * @return bool True if there is no flooding, false if there is. | |
| 989 | + * @return bool True if there is no flooding, false if there is | |
| 1027 | 990 | */ |
| 1028 | 991 | function bbp_check_for_flood( $anonymous_data = array(), $author_id = 0 ) { |
| 1029 | 992 | |
| 1030 | 993 | // Allow for flood check to be skipped |
| @@ -1061,9 +1024,9 @@ | ||
| 1061 | 1024 | return true; |
| 1062 | 1025 | } |
| 1063 | 1026 | |
| 1064 | 1027 | /** |
| 1065 | - * Checks topics and replies against the discussion moderation of blocked keys. | |
| 1028 | + * Checks topics and replies against the discussion moderation of blocked keys | |
| 1066 | 1029 | * |
| 1067 | 1030 | * @since 2.1.0 bbPress (r3581) |
| 1068 | 1031 | * |
| 1069 | 1032 | * @param array $anonymous_data Optional - if it's an anonymous post. Do not |
| @@ -1068,14 +1031,14 @@ | ||
| 1068 | 1031 | * |
| 1069 | 1032 | * @param array $anonymous_data Optional - if it's an anonymous post. Do not |
| 1070 | 1033 | * supply if supplying $author_id. Should be |
| 1071 | 1034 | * sanitized (see {@link bbp_filter_anonymous_post_data()} |
| 1072 | - * @param int $author_id Topic or reply author ID. | |
| 1073 | - * @param string $title The title of the content. | |
| 1074 | - * @param string $content The content being posted. | |
| 1035 | + * @param int $author_id Topic or reply author ID | |
| 1036 | + * @param string $title The title of the content | |
| 1037 | + * @param string $content The content being posted | |
| 1075 | 1038 | * @param mixed $strict False for moderation_keys. True for disallowed_keys. |
| 1076 | 1039 | * String for custom keys. |
| 1077 | - * @return bool True if test is passed, false if fail. | |
| 1040 | + * @return bool True if test is passed, false if fail | |
| 1078 | 1041 | */ |
| 1079 | 1042 | function bbp_check_for_moderation( $anonymous_data = array(), $author_id = 0, $title = '', $content = '', $strict = false ) { |
| 1080 | 1043 | |
| 1081 | 1044 | // Custom moderation option key |
| @@ -1092,9 +1055,9 @@ | ||
| 1092 | 1055 | $strict = false; |
| 1093 | 1056 | } |
| 1094 | 1057 | } |
| 1095 | 1058 | |
| 1096 | - // Strict mode uses WordPress "disallow" settings | |
| 1059 | + // Strict mode uses WordPress "blacklist" settings | |
| 1097 | 1060 | if ( true === $strict ) { |
| 1098 | 1061 | $hook_name = 'blacklist'; |
| 1099 | 1062 | $option_name = 'disallowed_keys'; |
| 1100 | 1063 | |
| @@ -1331,12 +1294,12 @@ | ||
| 1331 | 1294 | return $user_ids; |
| 1332 | 1295 | } |
| 1333 | 1296 | |
| 1334 | 1297 | /** |
| 1335 | - * Sends notification emails for new replies to subscribed topics. | |
| 1298 | + * Sends notification emails for new replies to subscribed topics | |
| 1336 | 1299 | * |
| 1337 | 1300 | * Gets new post ID and check if there are subscribed users to that topic, and |
| 1338 | - * if there are, send notifications. | |
| 1301 | + * if there are, send notifications | |
| 1339 | 1302 | * |
| 1340 | 1303 | * Note: in bbPress 2.6, we've moved away from 1 email per subscriber to 1 email |
| 1341 | 1304 | * with everyone BCC'd. This may have negative repercussions for email services |
| 1342 | 1305 | * that limit the number of addresses in a BCC field (often to around 500.) In |
| @@ -1344,16 +1307,16 @@ | ||
| 1344 | 1307 | * custom email script. |
| 1345 | 1308 | * |
| 1346 | 1309 | * @since 2.6.0 bbPress (r5413) |
| 1347 | 1310 | * |
| 1348 | - * @param int $reply_id ID of the newly made reply. | |
| 1349 | - * @param int $topic_id ID of the topic of the reply. | |
| 1350 | - * @param int $forum_id ID of the forum of the reply. | |
| 1311 | + * @param int $reply_id ID of the newly made reply | |
| 1312 | + * @param int $topic_id ID of the topic of the reply | |
| 1313 | + * @param int $forum_id ID of the forum of the reply | |
| 1351 | 1314 | * @param array $anonymous_data Optional - if it's an anonymous post. Do not |
| 1352 | 1315 | * supply if supplying $author_id. Should be |
| 1353 | - * sanitized (see {@link bbp_filter_anonymous_post_data()}. | |
| 1354 | - * @param int $reply_author ID of the topic author ID. | |
| 1355 | - * @return bool True on success, false on failure. | |
| 1316 | + * sanitized (see {@link bbp_filter_anonymous_post_data()} | |
| 1317 | + * @param int $reply_author ID of the topic author ID | |
| 1318 | + * @return bool True on success, false on failure | |
| 1356 | 1319 | */ |
| 1357 | 1320 | function bbp_notify_topic_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = array(), $reply_author = 0 ) { |
| 1358 | 1321 | |
| 1359 | 1322 | // Bail if subscriptions are turned off |
| @@ -1426,10 +1389,10 @@ | ||
| 1426 | 1389 | bbp_remove_all_filters( 'bbp_get_topic_title' ); |
| 1427 | 1390 | bbp_remove_all_filters( 'the_title' ); |
| 1428 | 1391 | |
| 1429 | 1392 | // Strip tags from text and setup mail data |
| 1430 | - $forum_title = wp_specialchars_decode( wp_strip_all_tags( bbp_get_forum_title( $forum_id ) ), ENT_QUOTES ); | |
| 1431 | - $topic_title = wp_specialchars_decode( wp_strip_all_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); | |
| 1393 | + $forum_title = wp_specialchars_decode( strip_tags( bbp_get_forum_title( $forum_id ) ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1394 | + $topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1432 | 1395 | $reply_url = bbp_get_reply_url( $reply_id ); |
| 1433 | 1396 | |
| 1434 | 1397 | // Do not include protected content in subscription emails |
| 1435 | 1398 | if ( ! empty( $password_protected ) ) { |
| @@ -1452,10 +1415,10 @@ | ||
| 1452 | 1415 | ); |
| 1453 | 1416 | |
| 1454 | 1417 | // Include the reply details in normal subscription emails |
| 1455 | 1418 | } else { |
| 1456 | - $reply_author_name = wp_specialchars_decode( wp_strip_all_tags( $reply_author_name ), ENT_QUOTES ); | |
| 1457 | - $reply_content = wp_specialchars_decode( wp_strip_all_tags( bbp_get_reply_content( $reply_id ) ), ENT_QUOTES ); | |
| 1419 | + $reply_author_name = wp_specialchars_decode( strip_tags( $reply_author_name ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1420 | + $reply_content = wp_specialchars_decode( strip_tags( bbp_get_reply_content( $reply_id ) ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1458 | 1421 | $message = sprintf( |
| 1459 | 1422 | |
| 1460 | 1423 | /* translators: 1: Reply author name, 2: Reply content, 3: Reply URL */ |
| 1461 | 1424 | esc_html__( |
| @@ -1532,12 +1495,12 @@ | ||
| 1532 | 1495 | return true; |
| 1533 | 1496 | } |
| 1534 | 1497 | |
| 1535 | 1498 | /** |
| 1536 | - * Sends notification emails for new topics to subscribed forums. | |
| 1499 | + * Sends notification emails for new topics to subscribed forums | |
| 1537 | 1500 | * |
| 1538 | 1501 | * Gets new post ID and check if there are subscribed users to that forum, and |
| 1539 | - * if there are, send notifications. | |
| 1502 | + * if there are, send notifications | |
| 1540 | 1503 | * |
| 1541 | 1504 | * Note: in bbPress 2.6, we've moved away from 1 email per subscriber to 1 email |
| 1542 | 1505 | * with everyone BCC'd. This may have negative repercussions for email services |
| 1543 | 1506 | * that limit the number of addresses in a BCC field (often to around 500.) In |
| @@ -1545,15 +1508,15 @@ | ||
| 1545 | 1508 | * custom email script. |
| 1546 | 1509 | * |
| 1547 | 1510 | * @since 2.5.0 bbPress (r5156) |
| 1548 | 1511 | * |
| 1549 | - * @param int $topic_id ID of the newly made reply. | |
| 1550 | - * @param int $forum_id ID of the forum for the topic. | |
| 1512 | + * @param int $topic_id ID of the newly made reply | |
| 1513 | + * @param int $forum_id ID of the forum for the topic | |
| 1551 | 1514 | * @param array $anonymous_data Optional - if it's an anonymous post. Do not |
| 1552 | 1515 | * supply if supplying $author_id. Should be |
| 1553 | 1516 | * sanitized (see {@link bbp_filter_anonymous_post_data()} |
| 1554 | - * @param int $topic_author ID of the topic author ID. | |
| 1555 | - * @return bool True on success, false on failure. | |
| 1517 | + * @param int $topic_author ID of the topic author ID | |
| 1518 | + * @return bool True on success, false on failure | |
| 1556 | 1519 | */ |
| 1557 | 1520 | function bbp_notify_forum_subscribers( $topic_id = 0, $forum_id = 0, $anonymous_data = array(), $topic_author = 0 ) { |
| 1558 | 1521 | |
| 1559 | 1522 | // Bail if subscriptions are turned off |
| @@ -1580,9 +1543,9 @@ | ||
| 1580 | 1543 | $user_id = 0; |
| 1581 | 1544 | |
| 1582 | 1545 | /** Topic *****************************************************************/ |
| 1583 | 1546 | |
| 1584 | - // Bail if topic is not public (both open/closed are public) | |
| 1547 | + // Bail if topic is not public (includes closed) | |
| 1585 | 1548 | if ( ! bbp_is_topic_public( $topic_id ) ) { |
| 1586 | 1549 | return false; |
| 1587 | 1550 | } |
| 1588 | 1551 | |
| @@ -1625,11 +1588,11 @@ | ||
| 1625 | 1588 | bbp_remove_all_filters( 'bbp_get_topic_title' ); |
| 1626 | 1589 | bbp_remove_all_filters( 'the_title' ); |
| 1627 | 1590 | |
| 1628 | 1591 | // Strip tags from text and setup mail data |
| 1629 | - $forum_title = wp_specialchars_decode( wp_strip_all_tags( bbp_get_forum_title( $forum_id ) ), ENT_QUOTES ); | |
| 1630 | - $topic_title = wp_specialchars_decode( wp_strip_all_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); | |
| 1631 | - $topic_url = bbp_get_topic_permalink( $topic_id ); | |
| 1592 | + $forum_title = wp_specialchars_decode( strip_tags( bbp_get_forum_title( $forum_id ) ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1593 | + $topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1594 | + $topic_url = get_permalink( $topic_id ); | |
| 1632 | 1595 | |
| 1633 | 1596 | // Do not include protected content in subscription emails |
| 1634 | 1597 | if ( ! empty( $password_protected ) ) { |
| 1635 | 1598 | $message = sprintf( |
| @@ -1651,10 +1614,10 @@ | ||
| 1651 | 1614 | ); |
| 1652 | 1615 | |
| 1653 | 1616 | // Include the topic details in normal subscription emails |
| 1654 | 1617 | } else { |
| 1655 | - $topic_author_name = wp_specialchars_decode( wp_strip_all_tags( $topic_author_name ), ENT_QUOTES ); | |
| 1656 | - $topic_content = wp_specialchars_decode( wp_strip_all_tags( bbp_get_topic_content( $topic_id ) ), ENT_QUOTES ); | |
| 1618 | + $topic_author_name = wp_specialchars_decode( strip_tags( $topic_author_name ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1619 | + $topic_content = wp_specialchars_decode( strip_tags( bbp_get_topic_content( $topic_id ) ), ENT_QUOTES ); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags | |
| 1657 | 1620 | $message = sprintf( |
| 1658 | 1621 | |
| 1659 | 1622 | /* translators: 1: Topic author name, 2: Topic content, 3: Topic URL */ |
| 1660 | 1623 | esc_html__( |
| @@ -1731,25 +1694,25 @@ | ||
| 1731 | 1694 | return true; |
| 1732 | 1695 | } |
| 1733 | 1696 | |
| 1734 | 1697 | /** |
| 1735 | - * Sends notification emails for new replies to subscribed topics. | |
| 1698 | + * Sends notification emails for new replies to subscribed topics | |
| 1736 | 1699 | * |
| 1737 | - * This function is deprecated. Please use: bbp_notify_topic_subscribers(). | |
| 1700 | + * This function is deprecated. Please use: bbp_notify_topic_subscribers() | |
| 1738 | 1701 | * |
| 1739 | 1702 | * @since 2.0.0 bbPress (r2668) |
| 1740 | 1703 | * |
| 1741 | 1704 | * @deprecated 2.6.0 bbPress (r5412) |
| 1742 | 1705 | * |
| 1743 | - * @param int $reply_id ID of the newly made reply. | |
| 1744 | - * @param int $topic_id ID of the topic of the reply. | |
| 1745 | - * @param int $forum_id ID of the forum of the reply. | |
| 1706 | + * @param int $reply_id ID of the newly made reply | |
| 1707 | + * @param int $topic_id ID of the topic of the reply | |
| 1708 | + * @param int $forum_id ID of the forum of the reply | |
| 1746 | 1709 | * @param array $anonymous_data Optional - if it's an anonymous post. Do not |
| 1747 | 1710 | * supply if supplying $author_id. Should be |
| 1748 | - * sanitized (see {@link bbp_filter_anonymous_post_data()}. | |
| 1749 | - * @param int $reply_author ID of the topic author ID. | |
| 1711 | + * sanitized (see {@link bbp_filter_anonymous_post_data()} | |
| 1712 | + * @param int $reply_author ID of the topic author ID | |
| 1750 | 1713 | * |
| 1751 | - * @return bool True on success, false on failure. | |
| 1714 | + * @return bool True on success, false on failure | |
| 1752 | 1715 | */ |
| 1753 | 1716 | function bbp_notify_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = array(), $reply_author = 0 ) { |
| 1754 | 1717 | return bbp_notify_topic_subscribers( $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author ); |
| 1755 | 1718 | } |
| @@ -1754,9 +1717,9 @@ | ||
| 1754 | 1717 | return bbp_notify_topic_subscribers( $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author ); |
| 1755 | 1718 | } |
| 1756 | 1719 | |
| 1757 | 1720 | /** |
| 1758 | - * Return an array of user email addresses from an array of user IDs. | |
| 1721 | + * Return an array of user email addresses from an array of user IDs | |
| 1759 | 1722 | * |
| 1760 | 1723 | * @since 2.6.0 bbPress (r6722) |
| 1761 | 1724 | * |
| 1762 | 1725 | * @param array $user_ids |
| @@ -1897,9 +1860,9 @@ | ||
| 1897 | 1860 | |
| 1898 | 1861 | /** Login *********************************************************************/ |
| 1899 | 1862 | |
| 1900 | 1863 | /** |
| 1901 | - * Return a clean and reliable logout URL. | |
| 1864 | + * Return a clean and reliable logout URL | |
| 1902 | 1865 | * |
| 1903 | 1866 | * This function is used to filter `logout_url`. If no $redirect_to value is |
| 1904 | 1867 | * passed, it will default to the request uri, then the forum root. |
| 1905 | 1868 | * |
| @@ -1906,12 +1869,12 @@ | ||
| 1906 | 1869 | * See: `wp_logout_url()` |
| 1907 | 1870 | * |
| 1908 | 1871 | * @since 2.1.0 bbPress (2815) |
| 1909 | 1872 | * |
| 1910 | - * @param string $url URL used to log out. | |
| 1873 | + * @param string $url URL used to log out | |
| 1911 | 1874 | * @param string $redirect_to Where to redirect to? |
| 1912 | 1875 | * |
| 1913 | - * @return string The url. | |
| 1876 | + * @return string The url | |
| 1914 | 1877 | */ |
| 1915 | 1878 | function bbp_logout_url( $url = '', $redirect_to = '' ) { |
| 1916 | 1879 | |
| 1917 | 1880 | // If there is no redirect in the URL, let's add one... |
| @@ -1925,16 +1888,11 @@ | ||
| 1925 | 1888 | |
| 1926 | 1889 | // Check for a valid referer |
| 1927 | 1890 | $redirect_to = wp_get_referer(); |
| 1928 | 1891 | |
| 1929 | - // Maybe use current host | |
| 1930 | - if ( ( false === $redirect_to ) && ! empty( $_SERVER['HTTP_HOST'] ) ) { | |
| 1931 | - $redirect_to = bbp_get_url_scheme() . $_SERVER['HTTP_HOST']; | |
| 1932 | - | |
| 1933 | - // Maybe also use request URI | |
| 1934 | - if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { | |
| 1935 | - $redirect_to .= $_SERVER['REQUEST_URI']; | |
| 1936 | - } | |
| 1892 | + // Fallback to request uri if invalid referer | |
| 1893 | + if ( false === $redirect_to ) { | |
| 1894 | + $redirect_to = bbp_get_url_scheme() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |
| 1937 | 1895 | } |
| 1938 | 1896 | } |
| 1939 | 1897 | |
| 1940 | 1898 | // Filter the $redirect_to destination |
| @@ -1943,11 +1901,11 @@ | ||
| 1943 | 1901 | // Validate $redirect_to, default to root |
| 1944 | 1902 | $validated = wp_validate_redirect( $filtered, $forum_root ); |
| 1945 | 1903 | |
| 1946 | 1904 | // Assemble $redirect_to and add it (encoded) to full $url |
| 1947 | - $appended = add_query_arg( array( 'loggedout' => 'true' ), $validated ); | |
| 1905 | + $appended = add_query_arg( array( 'loggedout' => 'true' ), $validated ); | |
| 1948 | 1906 | $encoded = urlencode( $appended ); |
| 1949 | - $url = add_query_arg( array( 'redirect_to' => $encoded ), $url ); | |
| 1907 | + $url = add_query_arg( array( 'redirect_to' => $encoded ), $url ); | |
| 1950 | 1908 | } |
| 1951 | 1909 | |
| 1952 | 1910 | // Filter & return |
| 1953 | 1911 | return apply_filters( 'bbp_logout_url', $url, $redirect_to ); |
| @@ -1964,11 +1922,11 @@ | ||
| 1964 | 1922 | * optional $filter_key parameter. |
| 1965 | 1923 | * |
| 1966 | 1924 | * @since 2.1.0 bbPress (r3839) |
| 1967 | 1925 | * |
| 1968 | - * @param string|array $args Value to merge with $defaults. | |
| 1926 | + * @param string|array $args Value to merge with $defaults | |
| 1969 | 1927 | * @param array $defaults Array that serves as the defaults. |
| 1970 | - * @param string $filter_key String to key the filters from. | |
| 1928 | + * @param string $filter_key String to key the filters from | |
| 1971 | 1929 | * @return array Merged user defined values with defaults. |
| 1972 | 1930 | */ |
| 1973 | 1931 | function bbp_parse_args( $args, $defaults = array(), $filter_key = '' ) { |
| 1974 | 1932 | |
| @@ -2000,9 +1958,9 @@ | ||
| 2000 | 1958 | return $r; |
| 2001 | 1959 | } |
| 2002 | 1960 | |
| 2003 | 1961 | /** |
| 2004 | - * Adds ability to include or exclude specific post_parent ID's. | |
| 1962 | + * Adds ability to include or exclude specific post_parent ID's | |
| 2005 | 1963 | * |
| 2006 | 1964 | * @since 2.0.0 bbPress (r2996) |
| 2007 | 1965 | * |
| 2008 | 1966 | * @deprecated 2.5.8 bbPress (r5814) |
| @@ -2008,12 +1966,12 @@ | ||
| 2008 | 1966 | * @deprecated 2.5.8 bbPress (r5814) |
| 2009 | 1967 | * |
| 2010 | 1968 | * @global WP $wp |
| 2011 | 1969 | * @param string $where |
| 2012 | - * @param WP_Query $query | |
| 1970 | + * @param WP_Query $object | |
| 2013 | 1971 | * @return string |
| 2014 | 1972 | */ |
| 2015 | -function bbp_query_post_parent__in( $where, $query = '' ) { | |
| 1973 | +function bbp_query_post_parent__in( $where, $object = '' ) { | |
| 2016 | 1974 | global $wp; |
| 2017 | 1975 | |
| 2018 | 1976 | // Noop if WP core supports this already |
| 2019 | 1977 | if ( in_array( 'post_parent__in', $wp->private_query_vars, true ) ) { |
| @@ -2020,14 +1978,14 @@ | ||
| 2020 | 1978 | return $where; |
| 2021 | 1979 | } |
| 2022 | 1980 | |
| 2023 | 1981 | // Bail if no object passed |
| 2024 | - if ( empty( $query ) ) { | |
| 1982 | + if ( empty( $object ) ) { | |
| 2025 | 1983 | return $where; |
| 2026 | 1984 | } |
| 2027 | 1985 | |
| 2028 | 1986 | // Only 1 post_parent so return $where |
| 2029 | - if ( is_numeric( $query->query_vars['post_parent'] ) ) { | |
| 1987 | + if ( is_numeric( $object->query_vars['post_parent'] ) ) { | |
| 2030 | 1988 | return $where; |
| 2031 | 1989 | } |
| 2032 | 1990 | |
| 2033 | 1991 | // Get the DB |
| @@ -2033,15 +1991,15 @@ | ||
| 2033 | 1991 | // Get the DB |
| 2034 | 1992 | $bbp_db = bbp_db(); |
| 2035 | 1993 | |
| 2036 | 1994 | // Including specific post_parent's |
| 2037 | - if ( ! empty( $query->query_vars['post_parent__in'] ) ) { | |
| 2038 | - $ids = implode( ',', wp_parse_id_list( $query->query_vars['post_parent__in'] ) ); | |
| 1995 | + if ( ! empty( $object->query_vars['post_parent__in'] ) ) { | |
| 1996 | + $ids = implode( ',', wp_parse_id_list( $object->query_vars['post_parent__in'] ) ); | |
| 2039 | 1997 | $where .= " AND {$bbp_db->posts}.post_parent IN ($ids)"; |
| 2040 | 1998 | |
| 2041 | 1999 | // Excluding specific post_parent's |
| 2042 | - } elseif ( ! empty( $query->query_vars['post_parent__not_in'] ) ) { | |
| 2043 | - $ids = implode( ',', wp_parse_id_list( $query->query_vars['post_parent__not_in'] ) ); | |
| 2000 | + } elseif ( ! empty( $object->query_vars['post_parent__not_in'] ) ) { | |
| 2001 | + $ids = implode( ',', wp_parse_id_list( $object->query_vars['post_parent__not_in'] ) ); | |
| 2044 | 2002 | $where .= " AND {$bbp_db->posts}.post_parent NOT IN ($ids)"; |
| 2045 | 2003 | } |
| 2046 | 2004 | |
| 2047 | 2005 | // Return possibly modified $where |
| @@ -2048,9 +2006,9 @@ | ||
| 2048 | 2006 | return $where; |
| 2049 | 2007 | } |
| 2050 | 2008 | |
| 2051 | 2009 | /** |
| 2052 | - * Query the DB and get the last public post_id that has parent_id as post_parent. | |
| 2010 | + * Query the DB and get the last public post_id that has parent_id as post_parent | |
| 2053 | 2011 | * |
| 2054 | 2012 | * @since 2.0.0 bbPress (r2868) |
| 2055 | 2013 | * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects |
| 2056 | 2014 | * |
| @@ -2055,9 +2013,9 @@ | ||
| 2055 | 2013 | * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects |
| 2056 | 2014 | * |
| 2057 | 2015 | * @param int $parent_id Parent id. |
| 2058 | 2016 | * @param string $post_type Post type. Defaults to 'post'. |
| 2059 | - * @return int The last active post_id. | |
| 2017 | + * @return int The last active post_id | |
| 2060 | 2018 | */ |
| 2061 | 2019 | function bbp_get_public_child_last_id( $parent_id = 0, $post_type = 'post' ) { |
| 2062 | 2020 | |
| 2063 | 2021 | // Bail if nothing passed |
| @@ -2112,9 +2070,9 @@ | ||
| 2112 | 2070 | return (int) apply_filters( 'bbp_get_public_child_last_id', $child_id, $parent_id, $post_type ); |
| 2113 | 2071 | } |
| 2114 | 2072 | |
| 2115 | 2073 | /** |
| 2116 | - * Query the database for child counts, grouped by type & status. | |
| 2074 | + * Query the database for child counts, grouped by type & status | |
| 2117 | 2075 | * |
| 2118 | 2076 | * @since 2.6.0 bbPress (r6826) |
| 2119 | 2077 | * |
| 2120 | 2078 | * @param int $parent_id |
| @@ -2183,15 +2141,15 @@ | ||
| 2183 | 2141 | return (array) apply_filters( 'bbp_get_child_counts', $retval, $parent_id ); |
| 2184 | 2142 | } |
| 2185 | 2143 | |
| 2186 | 2144 | /** |
| 2187 | - * Filter a list of child counts, from `bbp_get_child_counts()`. | |
| 2145 | + * Filter a list of child counts, from `bbp_get_child_counts()` | |
| 2188 | 2146 | * |
| 2189 | 2147 | * @since 2.6.0 bbPress (r6826) |
| 2190 | 2148 | * |
| 2191 | - * @param int $parent_id ID of post to get child counts from. | |
| 2192 | - * @param array $types Optional. An array of post types to filter by. | |
| 2193 | - * @param array $statuses Optional. An array of post statuses to filter by. | |
| 2149 | + * @param int $parent_id ID of post to get child counts from | |
| 2150 | + * @param array $types Optional. An array of post types to filter by | |
| 2151 | + * @param array $statuses Optional. An array of post statuses to filter by | |
| 2194 | 2152 | * |
| 2195 | 2153 | * @return array A list of objects or object fields. |
| 2196 | 2154 | */ |
| 2197 | 2155 | function bbp_filter_child_counts_list( $parent_id = 0, $types = array( 'post' ), $statuses = array() ) { |
| @@ -2223,9 +2181,9 @@ | ||
| 2223 | 2181 | return (array) apply_filters( 'bbp_filter_child_counts_list', $retval, $parent_id, $types, $statuses ); |
| 2224 | 2182 | } |
| 2225 | 2183 | |
| 2226 | 2184 | /** |
| 2227 | - * Query the DB and get a count of public children. | |
| 2185 | + * Query the DB and get a count of public children | |
| 2228 | 2186 | * |
| 2229 | 2187 | * @since 2.0.0 bbPress (r2868) |
| 2230 | 2188 | * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects |
| 2231 | 2189 | * |
| @@ -2230,9 +2188,9 @@ | ||
| 2230 | 2188 | * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects |
| 2231 | 2189 | * |
| 2232 | 2190 | * @param int $parent_id Parent id. |
| 2233 | 2191 | * @param string $post_type Post type. Defaults to 'post'. |
| 2234 | - * @return int The number of children. | |
| 2192 | + * @return int The number of children | |
| 2235 | 2193 | */ |
| 2236 | 2194 | function bbp_get_public_child_count( $parent_id = 0, $post_type = 'post' ) { |
| 2237 | 2195 | |
| 2238 | 2196 | // Bail if nothing passed |
| @@ -2269,16 +2227,16 @@ | ||
| 2269 | 2227 | // Filter & return |
| 2270 | 2228 | return (int) apply_filters( 'bbp_get_public_child_count', $child_count, $parent_id, $post_type ); |
| 2271 | 2229 | } |
| 2272 | 2230 | /** |
| 2273 | - * Query the DB and get a count of public children. | |
| 2231 | + * Query the DB and get a count of public children | |
| 2274 | 2232 | * |
| 2275 | 2233 | * @since 2.0.0 bbPress (r2868) |
| 2276 | - * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects. | |
| 2234 | + * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects | |
| 2277 | 2235 | * |
| 2278 | 2236 | * @param int $parent_id Parent id. |
| 2279 | 2237 | * @param string $post_type Post type. Defaults to 'post'. |
| 2280 | - * @return int The number of children. | |
| 2238 | + * @return int The number of children | |
| 2281 | 2239 | */ |
| 2282 | 2240 | function bbp_get_non_public_child_count( $parent_id = 0, $post_type = 'post' ) { |
| 2283 | 2241 | |
| 2284 | 2242 | // Bail if nothing passed |
| @@ -2320,9 +2278,9 @@ | ||
| 2320 | 2278 | return (int) apply_filters( 'bbp_get_non_public_child_count', $child_count, $parent_id, $post_type ); |
| 2321 | 2279 | } |
| 2322 | 2280 | |
| 2323 | 2281 | /** |
| 2324 | - * Query the DB and get the child id's of public children. | |
| 2282 | + * Query the DB and get the child id's of public children | |
| 2325 | 2283 | * |
| 2326 | 2284 | * @since 2.0.0 bbPress (r2868) |
| 2327 | 2285 | * @since 2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects |
| 2328 | 2286 | * |
| @@ -2328,9 +2286,9 @@ | ||
| 2328 | 2286 | * |
| 2329 | 2287 | * @param int $parent_id Parent id. |
| 2330 | 2288 | * @param string $post_type Post type. Defaults to 'post'. |
| 2331 | 2289 | * |
| 2332 | - * @return array The array of children. | |
| 2290 | + * @return array The array of children | |
| 2333 | 2291 | */ |
| 2334 | 2292 | function bbp_get_public_child_ids( $parent_id = 0, $post_type = 'post' ) { |
| 2335 | 2293 | |
| 2336 | 2294 | // Bail if nothing passed |
| @@ -2390,16 +2348,16 @@ | ||
| 2390 | 2348 | return (array) apply_filters( 'bbp_get_public_child_ids', $child_ids, $parent_id, $post_type ); |
| 2391 | 2349 | } |
| 2392 | 2350 | |
| 2393 | 2351 | /** |
| 2394 | - * Query the DB and get the child id's of all children. | |
| 2352 | + * Query the DB and get the child id's of all children | |
| 2395 | 2353 | * |
| 2396 | 2354 | * @since 2.0.0 bbPress (r3325) |
| 2397 | 2355 | * |
| 2398 | - * @param int $parent_id Parent id. | |
| 2399 | - * @param string $post_type Post type. Defaults to 'post'. | |
| 2356 | + * @param int $parent_id Parent id | |
| 2357 | + * @param string $post_type Post type. Defaults to 'post' | |
| 2400 | 2358 | * |
| 2401 | - * @return array The array of children. | |
| 2359 | + * @return array The array of children | |
| 2402 | 2360 | */ |
| 2403 | 2361 | function bbp_get_all_child_ids( $parent_id = 0, $post_type = 'post' ) { |
| 2404 | 2362 | |
| 2405 | 2363 | // Bail if nothing passed |
| @@ -2460,11 +2418,11 @@ | ||
| 2460 | 2418 | * Also see: bbp_update_post_author_caches() |
| 2461 | 2419 | * |
| 2462 | 2420 | * @since 2.6.0 bbPress (r6699) |
| 2463 | 2421 | * |
| 2464 | - * @param array $objects Array of objects, fresh from a query. | |
| 2422 | + * @param array $objects Array of objects, fresh from a query | |
| 2465 | 2423 | * |
| 2466 | - * @return bool True if some IDs were cached. | |
| 2424 | + * @return bool True if some IDs were cached | |
| 2467 | 2425 | */ |
| 2468 | 2426 | function bbp_update_post_family_caches( $objects = array() ) { |
| 2469 | 2427 | |
| 2470 | 2428 | // Bail if no posts |
| @@ -2533,11 +2491,11 @@ | ||
| 2533 | 2491 | * This is triggered when a `update_post_author_cache` argument is set to true. |
| 2534 | 2492 | * |
| 2535 | 2493 | * @since 2.6.0 bbPress (r6699) |
| 2536 | 2494 | * |
| 2537 | - * @param array $objects Array of objects, fresh from a query. | |
| 2495 | + * @param array $objects Array of objects, fresh from a query | |
| 2538 | 2496 | * |
| 2539 | - * @return bool True if some IDs were cached. | |
| 2497 | + * @return bool True if some IDs were cached | |
| 2540 | 2498 | */ |
| 2541 | 2499 | function bbp_update_post_author_caches( $objects = array() ) { |
| 2542 | 2500 | |
| 2543 | 2501 | // Bail if no posts |
| @@ -2578,17 +2536,17 @@ | ||
| 2578 | 2536 | |
| 2579 | 2537 | /** Globals *******************************************************************/ |
| 2580 | 2538 | |
| 2581 | 2539 | /** |
| 2582 | - * Get the unfiltered value of a global $post's key. | |
| 2540 | + * Get the unfiltered value of a global $post's key | |
| 2583 | 2541 | * |
| 2584 | - * Used most frequently when editing a forum/topic/reply. | |
| 2542 | + * Used most frequently when editing a forum/topic/reply | |
| 2585 | 2543 | * |
| 2586 | 2544 | * @since 2.1.0 bbPress (r3694) |
| 2587 | 2545 | * |
| 2588 | - * @param string $field Name of the key. | |
| 2589 | - * @param string $context How to sanitize - raw|edit|db|display|attribute|js. | |
| 2590 | - * @return string Field value. | |
| 2546 | + * @param string $field Name of the key | |
| 2547 | + * @param string $context How to sanitize - raw|edit|db|display|attribute|js | |
| 2548 | + * @return string Field value | |
| 2591 | 2549 | */ |
| 2592 | 2550 | function bbp_get_global_post_field( $field = 'ID', $context = 'edit' ) { |
| 2593 | 2551 | |
| 2594 | 2552 | // Get the post, and maybe get a field from it |
| @@ -2609,10 +2567,10 @@ | ||
| 2609 | 2567 | * To avoid security exploits within the theme. |
| 2610 | 2568 | * |
| 2611 | 2569 | * @since 2.1.0 bbPress (r4022) |
| 2612 | 2570 | * |
| 2613 | - * @param string $action Action nonce. | |
| 2614 | - * @param string $query_arg where to look for nonce in $_REQUEST. | |
| 2571 | + * @param string $action Action nonce | |
| 2572 | + * @param string $query_arg where to look for nonce in $_REQUEST | |
| 2615 | 2573 | */ |
| 2616 | 2574 | function bbp_verify_nonce_request( $action = '', $query_arg = '_wpnonce' ) { |
| 2617 | 2575 | |
| 2618 | 2576 | /** Home URL **************************************************************/ |
| @@ -2618,9 +2576,9 @@ | ||
| 2618 | 2576 | /** Home URL **************************************************************/ |
| 2619 | 2577 | |
| 2620 | 2578 | // Parse home_url() into pieces to remove query-strings, strange characters, |
| 2621 | 2579 | // and other funny things that plugins might to do to it. |
| 2622 | - $parsed_home = wp_parse_url( home_url( '/', ( is_ssl() ? 'https' : 'http' ) ) ); | |
| 2580 | + $parsed_home = parse_url( home_url( '/', ( is_ssl() ? 'https' : 'http' ) ) ); | |
| 2623 | 2581 | |
| 2624 | 2582 | // Maybe include the port, if it's included |
| 2625 | 2583 | if ( isset( $parsed_home['port'] ) ) { |
| 2626 | 2584 | $parsed_host = $parsed_home['host'] . ':' . $parsed_home['port']; |
| @@ -2923,14 +2881,14 @@ | ||
| 2923 | 2881 | |
| 2924 | 2882 | /** Templates ******************************************************************/ |
| 2925 | 2883 | |
| 2926 | 2884 | /** |
| 2927 | - * Used to guess if page exists at requested path. | |
| 2885 | + * Used to guess if page exists at requested path | |
| 2928 | 2886 | * |
| 2929 | 2887 | * @since 2.0.0 bbPress (r3304) |
| 2930 | 2888 | * |
| 2931 | 2889 | * @param string $path |
| 2932 | - * @return mixed False if no page, Page object if true. | |
| 2890 | + * @return mixed False if no page, Page object if true | |
| 2933 | 2891 | */ |
| 2934 | 2892 | function bbp_get_page_by_path( $path = '' ) { |
| 2935 | 2893 | |
| 2936 | 2894 | // Default to false |
| @@ -2979,11 +2937,11 @@ | ||
| 2979 | 2937 | * |
| 2980 | 2938 | * @since 2.0.0 bbPress (r3051) |
| 2981 | 2939 | * @since 2.6.0 bbPress (r6583) Use status_header() & nocache_headers() |
| 2982 | 2940 | * |
| 2983 | - * @param WP_Query $query The query being checked. | |
| 2941 | + * @param WP_Query $query The query being checked | |
| 2984 | 2942 | * |
| 2985 | - * @return bool Always returns true. | |
| 2943 | + * @return bool Always returns true | |
| 2986 | 2944 | */ |
| 2987 | 2945 | function bbp_set_404( $query = null ) { |
| 2988 | 2946 | |
| 2989 | 2947 | // Global fallback |
| @@ -3008,9 +2966,9 @@ | ||
| 3008 | 2966 | status_header( 200 ); |
| 3009 | 2967 | } |
| 3010 | 2968 | |
| 3011 | 2969 | /** |
| 3012 | - * Maybe handle the default 404 handling for some bbPress conditions. | |
| 2970 | + * Maybe handle the default 404 handling for some bbPress conditions | |
| 3013 | 2971 | * |
| 3014 | 2972 | * Some conditions (like private/hidden forums and edits) have their own checks |
| 3015 | 2973 | * on `bbp_template_redirect` and are not currently 404s. |
| 3016 | 2974 | * |
| @@ -3015,12 +2973,12 @@ | ||
| 3015 | 2973 | * on `bbp_template_redirect` and are not currently 404s. |
| 3016 | 2974 | * |
| 3017 | 2975 | * @since 2.6.0 bbPress (r6555) |
| 3018 | 2976 | * |
| 3019 | - * @param bool $override Whether to override the default handler. | |
| 3020 | - * @param WP_Query $wp_query The posts query being referenced. | |
| 2977 | + * @param bool $override Whether to override the default handler | |
| 2978 | + * @param WP_Query $wp_query The posts query being referenced | |
| 3021 | 2979 | * |
| 3022 | - * @return bool False to leave alone, true to override. | |
| 2980 | + * @return bool False to leave alone, true to override | |
| 3023 | 2981 | */ |
| 3024 | 2982 | function bbp_pre_handle_404( $override = false, $wp_query = false ) { |
| 3025 | 2983 | |
| 3026 | 2984 | // Handle a bbPress 404 condition |
| @@ -3048,9 +3006,9 @@ | ||
| 3048 | 3006 | * currently only used to avoid calling the main query when it's not necessary. |
| 3049 | 3007 | * |
| 3050 | 3008 | * @since 2.6.0 bbPress (r6580) |
| 3051 | 3009 | * |
| 3052 | - * @param mixed $posts Default null. Array of posts (possibly empty). | |
| 3010 | + * @param mixed $posts Default null. Array of posts (possibly empty) | |
| 3053 | 3011 | * @param WP_Query $wp_query |
| 3054 | 3012 | * |
| 3055 | 3013 | * @return mixed Null if no override. Array if overridden. |
| 3056 | 3014 | */ |
| @@ -3082,12 +3040,10 @@ | ||
| 3082 | 3040 | |
| 3083 | 3041 | /** |
| 3084 | 3042 | * Is a title longer that the maximum title length? |
| 3085 | 3043 | * |
| 3086 | - * Uses mb_strlen() in `utf-8` mode to treat strings as is. This differs from | |
| 3087 | - * the behavior present in Comments, PHPMailer, RandomCompat, and others, | |
| 3088 | - * because the database column used by titles (posts.post_title) is | |
| 3089 | - * TEXT (characters) and not VARCHAR (bytes). | |
| 3044 | + * Uses mb_strlen() in `8bit` mode to treat strings as raw. This matches the | |
| 3045 | + * behavior present in Comments, PHPMailer, RandomCompat, and others. | |
| 3090 | 3046 | * |
| 3091 | 3047 | * @since 2.6.0 bbPress (r6783) |
| 3092 | 3048 | * |
| 3093 | 3049 | * @param string $title |
| @@ -3094,9 +3050,9 @@ | ||
| 3094 | 3050 | * @return bool |
| 3095 | 3051 | */ |
| 3096 | 3052 | function bbp_is_title_too_long( $title = '' ) { |
| 3097 | 3053 | $max = bbp_get_title_max_length(); |
| 3098 | - $len = mb_strlen( $title, 'utf-8' ); | |
| 3054 | + $len = mb_strlen( $title, '8bit' ); | |
| 3099 | 3055 | $result = ( $len > $max ); |
| 3100 | 3056 | |
| 3101 | 3057 | // Filter & return |
| 3102 | 3058 | return (bool) apply_filters( 'bbp_is_title_too_long', $result, $title, $max, $len ); |