<?php
// Add the button to the bulk action dropdown.
add_action( 'bulk_actions-edit-post', function($actions) {
	$actions['glerf'] = 'Glerf';
	return $actions;
});

// Add a form submission handler.
add_action( 'handle_bulk_actions-edit-post', function($action) {
	if ( $action !== 'glerf') {
		return;
	}
	// do something productive here
});

// Add a filter on the "sendback" URL, to give the next List Table load statefulness
// about what happened. Then we could display an admin message to tell the user
// about what happened here.
add_filter( 'after_handle_bulk_actions_sendback_link-edit-post', function($sendback, $action) {
	if ( $action !== 'glerf' ) {
		return $sendback;
	}
	$sendback = add_query_arg('glerfed', 1, $sendback);
	return $sendback;
}, 10, 2);
