admin管理员组

文章数量:1292306

I'm following this tutorial to add custom bulk actions to my dashboard but I have multiple custom post types. So far I was able to achieve what I want with

// functions.php

// The same line for each Custom Post Type
add_filter( 'bulk_actions-edit-notre_offre', 'custom_bulk_actions' );
add_filter( 'bulk_actions-edit-financements', 'custom_bulk_actions' );
add_filter( 'bulk_actions-edit-le_groupe', 'custom_bulk_actions' );
add_filter( 'bulk_actions-edit-actualites', 'custom_bulk_actions' );
add_filter( 'bulk_actions-edit-ressources', 'custom_bulk_actions' );
add_filter( 'bulk_actions-edit-legal', 'custom_bulk_actions' );
add_filter( 'bulk_actions-edit-page', 'custom_bulk_actions' ); // default WordPress apges

function custom_bulk_actions( $bulk_array ) {
    $bulk_array['custom_bulk_make_draft'] = 'Draft';
    $bulk_array['custom_bulk_publish'] = 'Publish';
    return $bulk_array;
}

// [handler that also uses a bunch of add_filter()'s]

I feel like that's not the optimal way to do it. Is there a way to merge all my add_filter() lines into one? Also, are there any negative effects on performance with the way I currently do this?

本文标签: phpHow do I add custom bulk actions to multiple custom post types