|
1 | 1 | <?php
|
2 |
| -/** |
3 |
| - * @package WP-Butler |
4 |
| - * @version 1.1 |
5 |
| - */ |
6 |
| - |
7 | 2 | /*
|
8 |
| -Plugin Name: WP Butler |
9 |
| -Plugin URI: http://wpbutler.com |
10 |
| -Description: WP Butler brings you what you need in the Wordpress Admin. An autocomplete menu to let you jump to all the common tasks you may need to perform. |
11 |
| -Author: Japh Thomson |
12 |
| -Version: 1.1 |
13 |
| -Author URI: http://japh.com.au |
14 |
| -*/ |
15 |
| - |
16 |
| -add_action( 'admin_footer', 'jg_wp_butler' ); |
17 |
| - |
18 |
| -function jg_wp_butler() { |
19 |
| - echo '<div id="butler-dialog" title="WP Butler" style="display: none;"> |
20 |
| - <a id="butler-close-dialog" class="media-modal-close" href="#" title="Close"><span class="media-modal-icon"></span></a> |
21 |
| - <p> |
22 |
| - <p class="butler-question">What would you like to do?</p> |
23 |
| - <form id="wpButler"><input type="text" placeholder="Just start typing..." style="width:90%; font-size:16px;padding:4px 0 6px 10px"id="wpButlerField"><input type="hidden" id="wp-butler-nonce" name="wp-butler-nonce" value="' . wp_create_nonce( 'wp_butler_nonce' ) . '" /></form> |
24 |
| - </p> |
25 |
| -</div>'; |
26 |
| -} |
27 |
| - |
28 |
| -// Enqueue jQuery UI Autocomplete |
29 |
| -function jg_add_autocomplete() { |
30 |
| - if ( is_admin() ) { |
31 |
| - //wp_register_script( 'mousetrap', plugins_url( 'mousetrap/mousetrap.min.js', __FILE__ ), array(), '1.2.2', true ); |
32 |
| - wp_register_script( 'keystroke', plugins_url( 'keystroke/jquery.keystroke.min.js', __FILE__ ), array( 'jquery' ), '0d77ac267da80cbe0e0ca8e6fe8b5b2bb8ee1bac', true ); |
33 |
| - wp_enqueue_script( 'wpbutler', plugins_url( 'wpbutler.js', __FILE__ ), array( 'jquery', 'jquery-ui-autocomplete', 'jquery-ui-dialog', 'keystroke' ), '1.1', true ); |
34 |
| - wp_enqueue_style( 'wp-jquery-ui-dialog' ); |
35 |
| - wp_enqueue_style( 'wpbutler', plugins_url( 'wpbutler.css', __FILE__ ) ); |
36 |
| - } |
37 |
| -}; |
38 |
| - |
39 |
| -add_action( 'admin_enqueue_scripts', 'jg_add_autocomplete' ); |
40 |
| - |
41 |
| -function wp_butler_actions() { |
42 |
| - $return = array(); |
43 |
| - $term = $_REQUEST['term']; |
44 |
| - $nonce = $_REQUEST['_nonce']; |
45 |
| - |
46 |
| - if ( is_admin() && wp_verify_nonce( $nonce, 'wp_butler_nonce' ) ) { |
47 |
| - $butler_actions = array( |
48 |
| - array( "label" => "Go to Dashboard", "url" => "index.php" ), |
49 |
| - array( "label" => "Add Page", "url" => "post-new.php?post_type=page" ), |
50 |
| - array( "label" => "Add Post", "url" => "post-new.php?post_type=post" ), |
51 |
| - array( "label" => "New Page", "url" => "post-new.php?post_type=page" ), |
52 |
| - array( "label" => "New Post", "url" => "post-new.php?post_type=post" ), |
53 |
| - array( "label" => "Edit Posts", "url" => "edit.php" ), |
54 |
| - array( "label" => "Edit Pages", "url" => "edit.php?post_type=page" ), |
55 |
| - array( "label" => "View All Posts", "url" => "edit.php" ), |
56 |
| - array( "label" => "View All Pages", "url" => "edit.php?post_type=page" ), |
57 |
| - array( "label" => "Media Library", "url" => "upload.php" ), |
58 |
| - array( "label" => "Add Media", "url" => "media-new.php" ), |
59 |
| - array( "label" => "Upload Media", "url" => "media-new.php" ), |
60 |
| - array( "label" => "New Media Item", "url" => "media-new.php" ), |
61 |
| - array( "label" => "Approve Comments", "url" => "edit-comments.php" ), |
62 |
| - array( "label" => "View Comments", "url" => "edit-comments.php" ), |
63 |
| - array( "label" => "Change Theme", "url" => "themes.php" ), |
64 |
| - array( "label" => "Install Theme", "url" => "theme-install.php" ), |
65 |
| - array( "label" => "Add Widgets", "url" => "widgets.php" ), |
66 |
| - array( "label" => "Edit Widgets", "url" => "widgets.php" ), |
67 |
| - array( "label" => "Add Menu", "url" => "nav-menus.php" ), |
68 |
| - array( "label" => "Edit Menus", "url" => "nav-menus.php" ), |
69 |
| - array( "label" => "Edit Settings", "url" => "options-general.php" ), |
70 |
| - array( "label" => "Edit Permalinks", "url" => "options-permalink.php" ), |
71 |
| - array( "label" => "Install Plugin", "url" => "plugin-install.php" ), |
72 |
| - array( "label" => "View Plugins", "url" => "plugins.php" ), |
73 |
| - array( "label" => "View Users", "url" => "users.php" ), |
74 |
| - array( "label" => "Add New User", "url" => "user-new.php" ), |
75 |
| - ); |
76 |
| - |
77 |
| - $butler_actions = apply_filters( 'wp_butler_ajax_actions', $butler_actions ); |
78 |
| - |
79 |
| - foreach ( $butler_actions as $value ) { |
80 |
| - if ( preg_match( '/' . $term . '/i', $value['label'] ) ) { |
81 |
| - $return[] = array( |
82 |
| - 'label' => $value['label'], |
83 |
| - 'url' => $value['url'] |
84 |
| - ); |
85 |
| - } |
86 |
| - } |
87 |
| - } |
88 |
| - |
89 |
| - wp_die( json_encode( $return ) ); |
90 |
| -}; |
91 |
| - |
92 |
| -add_action( 'wp_ajax_wp_butler_actions', 'wp_butler_actions' ); |
| 3 | + * Convoluted paths |
| 4 | + * Now brought to your finger tips - |
| 5 | + * How may I help you? |
| 6 | + */ |
0 commit comments