Ticket #2246: 2246.diff
File 2246.diff, 8.8 KB (added by , 8 years ago) |
---|
-
includes/admin/replies.php
64 64 // Messages 65 65 add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) ); 66 66 67 // Topic bulk actions. 68 add_filter( 'bulk_actions-edit-reply', array( $this, 'bulk_actions' ) ); 69 add_filter( 'handle_bulk_actions-edit-reply', array( $this, 'handle_bulk_actions' ), 10, 3 ); 70 add_filter( 'bulk_post_updated_messages', array( $this, 'bulk_post_updated_messages' ), 10, 2 ); 71 67 72 // Reply column headers. 68 73 add_filter( 'manage_' . $this->post_type . '_posts_columns', array( $this, 'column_headers' ) ); 69 74 … … 247 252 } 248 253 249 254 /** 255 * Add spam/unspam bulk actions to the bulk action dropdown 256 * 257 * @param array $actions The list of bulk actions 258 * @return array The filtered list of bulk actions 259 */ 260 public function bulk_actions( $actions ) { 261 262 if ( $this->bail() ) { 263 return $actions; 264 } 265 266 if ( current_user_can( 'moderate' ) ) { 267 if ( bbp_get_spam_status_id() === get_query_var( 'post_status' ) ) { 268 $actions['unspam'] = __( 'Unspam', 'bbpress' ); 269 } else { 270 $actions['spam'] = __( 'Spam', 'bbpress' ); 271 } 272 } 273 274 return $actions; 275 } 276 277 /** 278 * Add custom bulk action updated messages for replies. 279 * 280 * @param array $bulk_messages Arrays of messages, each keyed by the corresponding post type 281 * @param array $bulk_counts Array of item counts for each message, used to build internationalized strings 282 */ 283 public function bulk_post_updated_messages( $bulk_messages, $bulk_counts ) { 284 285 if ( $this->bail() ) { 286 return $bulk_messages; 287 } 288 289 $bulk_messages['reply']['updated'] = _n( '%s reply updated.', '%s replies updated.', $bulk_counts['updated'] ); 290 $bulk_messages['reply']['locked'] = ( 1 == $bulk_counts['locked'] ) ? __( '1 reply not updated, somebody is editing it.' ) : 291 _n( '%s reply not updated, somebody is editing it.', '%s replies not updated, somebody is editing them.', $bulk_counts['locked'] ); 292 return $bulk_messages; 293 } 294 295 /** 296 * Handle spam/unspam bulk actions 297 * 298 * @param string $sendback The sendback URL 299 * @param string $doaction The action to be taken 300 * @param array $post_ids The post IDS to take the action on 301 * @uses remove_query_arg To remove custom args from the URL 302 * @uses current_user_can() To check if the current user is capable of 303 * editing the reply 304 * @uses wp_check_post_lock() To check if the reply is locked 305 * @uses wp_die() To die if the user isn't capable or the post wasn't 306 * found 307 * @uses bbp_unspam_reply() To unmark the reply as spam 308 * @uses bbp_spam_reply() To mark the reply as spam 309 * @uses add_query_arg() To add custom args to the url 310 * @return string The sendback URL 311 */ 312 public function handle_bulk_actions( $sendback, $doaction, $post_ids ) { 313 314 if ( $this->bail() ) { 315 return $sendback; 316 } 317 318 $sendback = remove_query_arg( array( 'spam', 'unspam' ), $sendback ); 319 $updated = $locked = 0; 320 321 if ( 'spam' === $doaction ) { 322 323 foreach ( (array) $post_ids as $post_id ) { 324 if ( ! current_user_can( 'moderate', $post_id ) ) { 325 wp_die( __( 'Sorry, you are not allowed to spam this item.', 'bbpress' ) ); 326 } 327 328 if ( wp_check_post_lock( $post_id ) ) { 329 $locked++; 330 continue; 331 } 332 333 if ( ! bbp_spam_reply( $post_id ) ) { 334 wp_die( __( 'Error in spamming reply.', 'bbpress' ) ); 335 } 336 337 $updated++; 338 } 339 340 $sendback = add_query_arg( array( 'updated' => $updated, 'ids' => join( ',', $post_ids ), 'locked' => $locked ), $sendback ); 341 342 } elseif ( 'unspam' === $doaction ) { 343 344 foreach ( (array) $post_ids as $post_id ) { 345 if ( ! current_user_can( 'moderate', $post_id ) ) { 346 wp_die( __( 'Sorry, you are not allowed to unspam this reply.', 'bbpress' ) ); 347 } 348 349 if ( wp_check_post_lock( $post_id ) ) { 350 $locked++; 351 continue; 352 } 353 354 if ( ! bbp_unspam_reply( $post_id ) ) { 355 wp_die( __( 'Error in unspamming reply.', 'bbpress' ) ); 356 } 357 358 $updated++; 359 } 360 361 $sendback = add_query_arg( array( 'updated' => $updated, 'ids' => join( ',', $post_ids ), 'locked' => $locked ), $sendback ); 362 } 363 364 return $sendback; 365 } 366 367 /** 250 368 * Add the reply attributes metabox 251 369 * 252 370 * @since 2.0.0 bbPress (r2746) -
includes/admin/topics.php
64 64 // Messages 65 65 add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) ); 66 66 67 // Topic bulk actions. 68 add_filter( 'bulk_actions-edit-topic', array( $this, 'bulk_actions' ) ); 69 add_filter( 'handle_bulk_actions-edit-topic', array( $this, 'handle_bulk_actions' ), 10, 3 ); 70 add_filter( 'bulk_post_updated_messages', array( $this, 'bulk_post_updated_messages' ), 10, 2 ); 71 67 72 // Topic column headers. 68 73 add_filter( 'manage_' . $this->post_type . '_posts_columns', array( $this, 'column_headers' ) ); 69 74 … … 249 254 } 250 255 251 256 /** 257 * Add spam/unspam bulk actions to the bulk action dropdown 258 * 259 * @param array $actions The list of bulk actions 260 * @return array The filtered list of bulk actions 261 */ 262 public function bulk_actions( $actions ) { 263 264 if ( $this->bail() ) { 265 return $actions; 266 } 267 268 if ( current_user_can( 'moderate' ) ) { 269 if ( bbp_get_spam_status_id() === get_query_var( 'post_status' ) ) { 270 $actions['unspam'] = __( 'Unspam', 'bbpress' ); 271 } else { 272 $actions['spam'] = __( 'Spam', 'bbpress' ); 273 } 274 } 275 276 return $actions; 277 } 278 279 /** 280 * Add custom bulk action updated messages for topics. 281 * 282 * @param array $bulk_messages Arrays of messages, each keyed by the corresponding post type 283 * @param array $bulk_counts Array of item counts for each message, used to build internationalized strings 284 */ 285 public function bulk_post_updated_messages( $bulk_messages, $bulk_counts ) { 286 287 if ( $this->bail() ) { 288 return $bulk_messages; 289 } 290 291 $bulk_messages['topic']['updated'] = _n( '%s topic updated.', '%s topics updated.', $bulk_counts['updated'] ); 292 $bulk_messages['topic']['locked'] = ( 1 == $bulk_counts['locked'] ) ? __( '1 topic not updated, somebody is editing it.' ) : 293 _n( '%s topic not updated, somebody is editing it.', '%s topics not updated, somebody is editing them.', $bulk_counts['locked'] ); 294 return $bulk_messages; 295 } 296 297 /** 298 * Handle spam/unspam bulk actions 299 * 300 * @param string $sendback The sendback URL 301 * @param string $doaction The action to be taken 302 * @param array $post_ids The post IDS to take the action on 303 * @uses remove_query_arg To remove custom args from the URL 304 * @uses current_user_can() To check if the current user is capable of 305 * editing the topic 306 * @uses wp_check_post_lock() To check if the topic is locked 307 * @uses wp_die() To die if the user isn't capable or the post wasn't 308 * found 309 * @uses bbp_unspam_topic() To unmark the topic as spam 310 * @uses bbp_spam_topic() To mark the topic as spam 311 * @uses add_query_arg() To add custom args to the url 312 * @return string The sendback URL 313 */ 314 public function handle_bulk_actions( $sendback, $doaction, $post_ids ) { 315 316 if ( $this->bail() ) { 317 return $sendback; 318 } 319 320 $sendback = remove_query_arg( array( 'spam', 'unspam' ), $sendback ); 321 $updated = $locked = 0; 322 323 if ( 'spam' === $doaction ) { 324 325 foreach ( (array) $post_ids as $post_id ) { 326 if ( ! current_user_can( 'moderate', $post_id ) ) { 327 wp_die( __( 'Sorry, you are not allowed to spam this item.', 'bbpress' ) ); 328 } 329 330 if ( wp_check_post_lock( $post_id ) ) { 331 $locked++; 332 continue; 333 } 334 335 if ( ! bbp_spam_topic( $post_id ) ) { 336 wp_die( __( 'Error in spamming topic.', 'bbpress' ) ); 337 } 338 339 $updated++; 340 } 341 342 $sendback = add_query_arg( array( 'updated' => $updated, 'ids' => join( ',', $post_ids ), 'locked' => $locked ), $sendback ); 343 344 } elseif ( 'unspam' === $doaction ) { 345 346 foreach ( (array) $post_ids as $post_id ) { 347 if ( ! current_user_can( 'moderate', $post_id ) ) { 348 wp_die( __( 'Sorry, you are not allowed to unspam this topic.', 'bbpress' ) ); 349 } 350 351 if ( wp_check_post_lock( $post_id ) ) { 352 $locked++; 353 continue; 354 } 355 356 if ( ! bbp_unspam_topic( $post_id ) ) { 357 wp_die( __( 'Error in unspamming topic.', 'bbpress' ) ); 358 } 359 360 $updated++; 361 } 362 363 $sendback = add_query_arg( array( 'updated' => $updated, 'ids' => join( ',', $post_ids ), 'locked' => $locked ), $sendback ); 364 } 365 366 return $sendback; 367 } 368 /** 252 369 * Add the topic attributes metabox 253 370 * 254 371 * @since 2.0.0 bbPress (r2744)