Make WordPress Core

Ticket #7957: select2buttons.php

File select2buttons.php, 1.0 KB (added by DD32, 18 years ago)

Plugin which replaces selects with buttons

Line 
1<?php
2/*
3Plugin Name: Select2Buttons
4Description: Changes the Dropdown actions on the Admin tables to individual buttons
5Version: 1.0
6License: GPL
7Author: Dion Hulse
8Author URI: http://dd32.id.au/
9Plugin URI: http://dd32.id.au/wordpress-plugins/?plugin=select2buttons
10*/
11
12add_filter('table_actions', 'select2buttons_filter', 1000);
13function 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}
21add_action('admin_init', 'select2buttons_post');
22function 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}