Changeset 6101 for trunk/src/includes/admin/topics.php
- Timestamp:
- 10/13/2016 03:27:09 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/topics.php
r6099 r6101 48 48 * 49 49 * @since 2.0.0 bbPress (r2646) 50 * @since 2.6.0 bbPress (r6101) Added bulk actions 50 51 * 51 52 * @access private … … 64 65 // Messages 65 66 add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) ); 67 68 // Topic bulk actions, added in WordPress 4.7, see #WP16031. 69 if ( bbp_get_major_wp_version() >= 4.7 ) { 70 add_filter( 'bulk_actions-edit-topic', array( $this, 'bulk_actions' ) ); 71 add_filter( 'handle_bulk_actions-edit-topic', array( $this, 'handle_bulk_actions' ), 10, 3 ); 72 add_filter( 'bulk_post_updated_messages', array( $this, 'bulk_post_updated_messages' ), 10, 2 ); 73 } 66 74 67 75 // Topic column headers. … … 178 186 'title' => __( 'Bulk Actions', 'bbpress' ), 179 187 'content' => 180 '<p>' . __( 'You can also edit or move multiple topics to the trash at once. Select the topics you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.', 'bbpress' ) . '</p>' .188 '<p>' . __( 'You can also edit, spam, or move multiple topics to the trash at once. Select the topics you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.', 'bbpress' ) . '</p>' . 181 189 '<p>' . __( 'When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected topics at once. To remove a topic from the grouping, just click the x next to its name in the Bulk Edit area that appears.', 'bbpress' ) . '</p>' 182 190 ) ); … … 249 257 } 250 258 259 /** 260 * Add spam/unspam bulk actions to the bulk action dropdown. 261 * 262 * @since 2.6.0 bbPress (r6101) 263 * 264 * @param array $actions The list of bulk actions. 265 * @return array The filtered list of bulk actions. 266 */ 267 public function bulk_actions( $actions ) { 268 269 if ( $this->bail() ) { 270 return $actions; 271 } 272 273 if ( current_user_can( 'moderate' ) ) { 274 if ( bbp_get_spam_status_id() === get_query_var( 'post_status' ) ) { 275 $actions['unspam'] = __( 'Unspam', 'bbpress' ); 276 } else { 277 $actions['spam'] = __( 'Spam', 'bbpress' ); 278 } 279 } 280 281 return $actions; 282 } 283 284 /** 285 * Add custom bulk action updated messages for topics. 286 * 287 * @since 2.6.0 bbPress (r6101) 288 * 289 * @param array $bulk_messages Arrays of messages, each keyed by the corresponding post type. 290 * @param array $bulk_counts Array of item counts for each message, used to build internationalized strings. 291 */ 292 public function bulk_post_updated_messages( $bulk_messages, $bulk_counts ) { 293 294 if ( $this->bail() ) { 295 return $bulk_messages; 296 } 297 298 $bulk_messages['topic']['updated'] = _n( '%s topic updated.', '%s topics updated.', $bulk_counts['updated'] ); 299 $bulk_messages['topic']['locked'] = ( 1 === $bulk_counts['locked'] ) ? __( '1 topic not updated, somebody is editing it.' ) : 300 _n( '%s topic not updated, somebody is editing it.', '%s topics not updated, somebody is editing them.', $bulk_counts['locked'] ); 301 return $bulk_messages; 302 } 303 304 /** 305 * Handle spam/unspam bulk actions. 306 * 307 * @since 2.6.0 bbPress (r6101) 308 * 309 * @param string $sendback The sendback URL. 310 * @param string $doaction The action to be taken. 311 * @param array $post_ids The post IDS to take the action on. 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 } 251 368 /** 252 369 * Add the topic attributes metabox
Note: See TracChangeset
for help on using the changeset viewer.