PostTypes icon indicating copy to clipboard operation
PostTypes copied to clipboard

Create custom actions

Open jjgrainger opened this issue 3 years ago • 0 comments

Provide the ability to create custom bulk and row actions with PostTypes. An example of the API could be as follows, but needs further exploration.

// Create a basic event post type.
$event = new PostType('event');

// Create a 'Cancel Event' Bulk Actions
$event->actions()->bulk(
    'cancel-event',     // The unique action name.
    __('Cancel Event'), // The action label.
    function($redirect_url, $action, $post_ids) { // Callback to handle the bulk action request.
        // Do stuff
        return $redirect_url;
    },
    'upload_files' // Optional: Set the capability required to use the bulk action.
);

jjgrainger avatar Jun 15 '22 16:06 jjgrainger