Changeset 660262
- Timestamp:
- 01/28/2013 06:42:12 PM (12 years ago)
- Location:
- wp-butler/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-butler/trunk/readme.txt
r659251 r660262 6 6 Requires at least: 3.1 7 7 Tested up to: 3.5 8 Stable tag: 1.98 Stable tag: 9 9 10 10 Provides a text field in the WP Admin allowing you to jump to common WP Actions. … … 44 44 45 45 == Changelog == 46 47 48 49 50 51 52 53 54 55 46 56 47 57 = 1.9 = -
wp-butler/trunk/wp-butler.php
r659251 r660262 4 4 Plugin URI: http://wpbutler.com 5 5 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, just hit <code>shift+alt+b</code>! 6 Version: 1.96 Version: 7 7 Author: Japh 8 8 Author URI: http://japh.com.au … … 26 26 */ 27 27 28 // Check to See if the Class already exists! 28 /** 29 * WP Butler 30 * 31 * WP Butler brings you what you need in the Wordpress Admin. An autocomplete 32 * menu to let you jump to all the common tasks you may need to perform, just 33 * hit `shift+alt+b`! 34 * 35 * @author Japh <wordpress@japh.com.au> 36 * @version 2.0 37 * @package WP-Butler 38 * @license http://opensource.org/licenses/gpl-2.0.php GPL2 39 */ 40 41 // Check to see if the class already exists! 29 42 if ( ! class_exists( 'Japh_Butler' ) ) { 30 43 31 44 /** 45 46 32 47 * @package WP-Butler 33 * @version 1.9 48 * @version 2.0 49 * @since 1.2 34 50 */ 35 51 36 52 class Japh_Butler { 37 53 38 public $version = '1.9'; 54 /** 55 * Version number for WP Butler 56 * 57 * This is for internal reference, should it be needed. 58 * 59 * @since 1.2 60 */ 61 public $version = '2.0'; 62 /** 63 * Array of available post types 64 * @since 1.4 65 */ 39 66 public $post_types = array(); 67 68 69 70 40 71 public $taxonomies = array(); 41 72 73 74 75 76 77 42 78 function __construct() { 43 79 44 80 if ( ! is_admin() ) 45 81 return NULL; 46 82 47 83 load_plugin_textdomain( 'wp-butler', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 48 84 49 85 $this->post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'objects', 'and' ); 50 86 $this->taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'objects', 'and' ); 51 87 52 88 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) ); 53 89 add_action( 'admin_footer', array( $this, 'footer' ) ); 54 90 add_action( 'wp_ajax_wp_butler_actions', array( $this, 'actions' ) ); 55 91 add_action( 'admin_bar_menu', array( $this, 'enhance_admin_bar' ), 9999 ); 56 } 57 92 93 } 94 95 /** 96 * Footer HTML output 97 * 98 * This is the HTML for the WP Butler dialog. 99 * 100 * @since 1.2 101 */ 58 102 function footer() { 59 103 echo '<div id="wp-butler-dialog" title="' . __( "What would you like to do?", "wp-butler" ) . '">'; … … 64 108 } 65 109 110 111 112 113 114 115 116 66 117 function enqueue() { 67 118 // Enqueue styles … … 111 162 } 112 163 113 // Action methods 164 /** 165 * Generic action methods 166 * 167 * @since 1.4 168 * 169 * @param Array $actions Array of current actions for WP Butler 170 */ 114 171 function generate_generic_actions( $actions ) { 115 172 array_push( $actions, array( "label" => __( "Dashboard" ), "url" => "index.php" ) ); … … 145 202 } 146 203 204 205 206 207 208 209 210 147 211 function generate_site_actions( $actions ) { 148 212 if ( current_user_can( 'upload_files' ) ) { … … 179 243 } 180 244 245 246 247 248 249 250 251 181 252 function generate_multisite_actions( $actions ) { 182 253 if ( current_user_can( 'manage_sites' ) ) { … … 195 266 } 196 267 268 269 270 271 272 273 274 197 275 function generate_post_type_actions( $actions ) { 198 276 foreach ( $this->post_types as $post_type => $post_type_object ) { … … 212 290 } 213 291 292 293 294 295 296 297 298 214 299 function generate_taxonomy_actions( $actions ) { 215 300 foreach ( $this->taxonomies as $taxonomy => $taxonomy_object ) { … … 229 314 } 230 315 231 // Keyword methods 316 /** 317 * Keyword methods 318 * 319 * @since 1.7 320 * 321 * @param String $term Term for search keyword 322 * @param Array $actions Array of current actions for WP Butler 323 */ 232 324 function search_keyword( $term, $actions ) { 233 325 $term_words = explode( ' ', $_REQUEST['term'] ); … … 270 362 } 271 363 364 365 366 367 368 369 370 371 272 372 function activate_plugin_keyword( $term, $actions ) { 273 373 $term_words = explode( ' ', $_REQUEST['term'] ); … … 309 409 } 310 410 411 412 413 414 415 416 417 418 311 419 function user_search_keyword( $term, $actions ) { 312 420 $term_words = explode( ' ', $_REQUEST['term'] ); … … 335 443 } 336 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 337 486 function actions() { 338 487 require_once( ABSPATH . '/wp-includes/l10n.php' ); … … 367 516 list( $term, $butler_actions ) = $this->user_search_keyword( $term, $butler_actions ); 368 517 list( $term, $butler_actions ) = $this->activate_plugin_keyword( $term, $butler_actions ); 518 369 519 370 520 list( $term, $butler_actions ) = apply_filters( 'wp_butler_ajax_keyword_actions', array( $term, $butler_actions ) ); 371 521 372 $random_action_url = $butler_actions[mt_rand( 0, count( $butler_actions ) ) - 1]['url']; 373 array_push( $butler_actions, array( "label" => __( "Surprise me!", "wp-butler" ), "url" => $random_action_url ) ); 522 if ( ! empty( $butler_actions ) ) { 523 $random_action_url = $butler_actions[mt_rand( 0, count( $butler_actions ) - 1 )]['url']; 524 array_push( $butler_actions, array( "label" => __( "Surprise me!", "wp-butler" ), "url" => $random_action_url ) ); 525 } 374 526 } 375 527 … … 390 542 * Enhance the admin bar 391 543 * 392 * @param $wp_admin_bar Array544 * @param 393 545 * @return void 394 546 * @author bueltge … … 396 548 */ 397 549 public function enhance_admin_bar( $wp_admin_bar ) { 398 550 global $wp_admin_bar; 551 399 552 if ( ! is_super_admin() || ! is_admin_bar_showing() ) 400 553 return NULL; 401 554 402 555 $classes = apply_filters( 'wp_butler_admin_bar_classes', array() ); 403 556 $classes = implode( ' ', $classes ); 404 405 $wp_admin_bar->add_menu( 406 array( 407 'id' => 'wp-butler', 408 'parent' => 'top-secondary', 409 'secondary' => FALSE, 410 'title' => apply_filters( 'wp_butler_admin_bar_title', __( 'WP Butler', 'wp-butler' ) ), 411 'meta' => array( 'class' => $classes ) 412 ) 557 558 $args = array( 559 'id' => 'wp-butler', 560 'parent' => 'top-secondary', 561 'secondary' => FALSE, 562 'title' => apply_filters( 'wp_butler_admin_bar_title', __( 'WP Butler', 'wp-butler' ) ), 563 'meta' => array( 'class' => $classes ) 413 564 ); 565 566 414 567 } 415 568 … … 418 571 } 419 572 573 574 575 576 577 578 579 580 420 581 function execute_wp_butler() { 421 582 $japh_butler = new Japh_Butler(); -
wp-butler/trunk/wpbutler.css
r659251 r660262 1 1 #wp-butler-dialog { 2 display: none; 3 min-height: inherit !important; 4 } 2 display: none; 3 min-height: inherit !important; } 5 4 6 5 /* Admin Bar item */ 7 6 #wp-admin-bar-wp-butler:hover { 8 cursor: pointer; 9 } 7 cursor: pointer; } 8 9 /* Namespaced Butler Widget */ 10 .butler-ui-widget { 11 padding: 1em; 12 box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.3), 0 0 5px rgba(0, 0, 0, 0.6); } 13 .butler-ui-widget .ui-dialog-titlebar { 14 background: none; 15 border: none; 16 padding: 0; } 17 .butler-ui-widget .ui-dialog-content { 18 padding: 0; } 19 .butler-ui-widget p { 20 display: none; 21 margin: 0; } 22 .butler-ui-widget #wp-butler-field { 23 line-height: 1.2; 24 display: block; 25 width: 100%; 26 -webkit-box-sizing: border-box; 27 -moz-box-sizing: border-box; 28 box-sizing: border-box; 29 margin: 0.5em 0; 30 padding: 0.5em; 31 font-size: 2em; } -
wp-butler/trunk/wpbutler.js
r659251 r660262 6 6 $( "#wp-butler-dialog" ).dialog({ 7 7 modal: true, 8 closeOnEscape: true 9 }); 8 closeOnEscape: true, 9 width: 420 10 }).parent().addClass('butler-ui-widget'); 10 11 11 12 $( "#wp-butler-field" ).focus(); … … 16 17 $( "#wp-butler-dialog" ).dialog( { 17 18 modal: true, 18 closeOnEscape: true 19 }); 19 closeOnEscape: true, 20 width: 420 21 }).parent().addClass('butler-ui-widget'); 20 22 21 23 $( "#wp-butler-field" ).focus();
Note: See TracChangeset
for help on using the changeset viewer.