Changeset 10859
- Timestamp:
- 06/01/2016 09:12:44 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-moderation.php
r10825 r10859 48 48 * 49 49 * @since 1.6.0 50 * 51 * @param int $user_id Topic or reply author ID. 52 * @param string $title The title of the content. 53 * @param string $content The content being posted. 50 * @since 2.6.0 Added $error_type parameter. 51 * 52 * @param int $user_id User ID. 53 * @param string $title The title of the content. 54 * @param string $content The content being posted. 55 * @param string $error_type The error type to return. Either 'bool' or 'wp_error'. 54 56 * @return bool True if test is passed, false if fail. 55 57 */ 56 function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = '' ) {58 function bp_core_check_for_moderation( $user_id = 0, $title = '', $content = '', $error_type = 'bool' ) { 57 59 58 60 /** … … 128 130 // Das ist zu viele links! 129 131 if ( $num_links >= $max_links ) { 130 return false; 132 if ( 'bool' === $error_type ) { 133 return false; 134 } else { 135 return new WP_Error( 'bp_moderation_too_many_links', __( 'You have inputted too many links', 'buddypress' ) ); 136 } 131 137 } 132 138 } … … 165 171 // Check each user data for current word. 166 172 if ( preg_match( $pattern, $post_data ) ) { 167 168 // Post does not pass. 169 return false; 173 if ( 'bool' === $error_type ) { 174 return false; 175 } else { 176 return new WP_Error( 'bp_moderation_word_match', _x( 'You have inputted an inappropriate word.', 'Comment moderation', 'buddypress' ) ); 177 } 170 178 } 171 179 } … … 181 189 * 182 190 * @since 1.6.0 183 * 184 * @param int $user_id Topic or reply author ID. 185 * @param string $title The title of the content. 186 * @param string $content The content being posted. 191 * @since 2.6.0 Added $error_type parameter. 192 * 193 * @todo Why don't we use wp_blacklist_check() for this? 194 * 195 * @param int $user_id User ID. 196 * @param string $title The title of the content. 197 * @param string $content The content being posted. 198 * @param string $error_type The error type to return. Either 'bool' or 'wp_error'. 187 199 * @return bool True if test is passed, false if fail. 188 200 */ 189 function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '' ) {201 function bp_core_check_for_blacklist( $user_id = 0, $title = '', $content = '', $error_type = 'bool' ) { 190 202 191 203 /** … … 272 284 // Check each user data for current word. 273 285 if ( preg_match( $pattern, $post_data ) ) { 274 275 // Post does not pass. 276 return false; 286 if ( 'bool' === $error_type ) { 287 return false; 288 } else { 289 return new WP_Error( 'bp_moderation_blacklist_match', _x( 'You have inputted an inappropriate word.', 'Comment blacklist', 'buddypress' ) ); 290 } 277 291 } 278 292 }
Note: See TracChangeset
for help on using the changeset viewer.