| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | Plugin Name: Select2Buttons |
|---|
| 4 | Description: Changes the Dropdown actions on the Admin tables to individual buttons |
|---|
| 5 | Version: 1.0 |
|---|
| 6 | License: GPL |
|---|
| 7 | Author: Dion Hulse |
|---|
| 8 | Author URI: http://dd32.id.au/ |
|---|
| 9 | Plugin URI: http://dd32.id.au/wordpress-plugins/?plugin=select2buttons |
|---|
| 10 | */ |
|---|
| 11 | |
|---|
| 12 | add_filter('table_actions', 'select2buttons_filter', 1000); |
|---|
| 13 | function select2buttons_filter($actions) { |
|---|
| 14 | foreach ( (array)$actions as $action => $text ) { |
|---|
| 15 | if ( empty($action) || -1 == $action ) |
|---|
| 16 | continue; |
|---|
| 17 | echo "<input type='submit' name='select2buttons[{$action}]' value='$text' class='button-secondary action apply' />"; |
|---|
| 18 | } |
|---|
| 19 | return array(); |
|---|
| 20 | } |
|---|
| 21 | add_action('admin_init', 'select2buttons_post'); |
|---|
| 22 | function select2buttons_post() { |
|---|
| 23 | if ( ! isset($_REQUEST['select2buttons']) ) |
|---|
| 24 | return; |
|---|
| 25 | $action = array_keys($_REQUEST['select2buttons']); |
|---|
| 26 | $action = $action[0]; |
|---|
| 27 | $_POST['action'] = $_POST['action2'] = $_GET['action'] = $_GET['action2'] = $_REQUEST['action'] = $action; |
|---|
| 28 | $_POST['doaction'] = $_POST['doaction2'] = $_GET['doaction'] = $_GET['doaction2'] = 'Apply'; |
|---|
| 29 | } |
|---|