| 1 | <?php |
|---|
| 2 | // Add the button to the bulk action dropdown. |
|---|
| 3 | add_action( 'bulk_actions-edit-post', function($actions) { |
|---|
| 4 | $actions['glerf'] = 'Glerf'; |
|---|
| 5 | return $actions; |
|---|
| 6 | }); |
|---|
| 7 | |
|---|
| 8 | // Add a form submission handler. |
|---|
| 9 | add_action( 'handle_bulk_actions-edit-post', function($action) { |
|---|
| 10 | if ( $action !== 'glerf') { |
|---|
| 11 | return; |
|---|
| 12 | } |
|---|
| 13 | // do something productive here |
|---|
| 14 | }); |
|---|
| 15 | |
|---|
| 16 | // Add a filter on the "sendback" URL, to give the next List Table load statefulness |
|---|
| 17 | // about what happened. Then we could display an admin message to tell the user |
|---|
| 18 | // about what happened here. |
|---|
| 19 | add_filter( 'after_handle_bulk_actions_sendback_link-edit-post', function($sendback, $action) { |
|---|
| 20 | if ( $action !== 'glerf' ) { |
|---|
| 21 | return $sendback; |
|---|
| 22 | } |
|---|
| 23 | $sendback = add_query_arg('glerfed', 1, $sendback); |
|---|
| 24 | return $sendback; |
|---|
| 25 | }, 10, 2); |
|---|