Changeset 1082735
- Timestamp:
- 02/05/2015 01:51:30 AM (11 years ago)
- Location:
- quick-toolbar/trunk
- Files:
-
- 1 added
- 3 edited
-
css/ecmqt-admin-styles.css (added)
-
ecm-quick-toolbar.php (modified) (25 diffs)
-
js/ecmqt-scripts.js (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
quick-toolbar/trunk/ecm-quick-toolbar.php
r1081423 r1082735 4 4 * Plugin URI: http://www.ecommnet.uk 5 5 * Description: Add frequently used menu links and custom links to the Admin Toolbar. 6 * Version: 0. 16 * Version: 0.2 7 7 * Author: Ecommnet 8 8 * Author URI: http://www.ecommnet.uk … … 19 19 * @var string 20 20 */ 21 public $version = '0. 1';21 public $version = '0.2'; 22 22 23 23 /** … … 66 66 67 67 public function enqueue_styles() { 68 wp_ register_style( 'ecm_wp_admin_css', plugin_dir_url( __FILE__ ) . '/css/admin-styles.css', false, $version);69 wp_ enqueue_style( 'ecm_wp_admin_css');70 wp_enqueue_s cript( 'ecmqt_scripts', plugin_dir_url( __FILE__ ) . '/js/ecmqt-scripts.js', array(), $version, true);71 68 wp_enqueue_style( 'dashicons' ); 69 wp_register_style( 'ecmqt_wp_admin_css', plugin_dir_url( __FILE__ ) . '/css/ecmqt-admin-styles.css', false, $this->version ); 70 wp_enqueue_style( 'ecmqt_wp_admin_css' ); 71 wp_enqueue_script( 'ecmqt_scripts', plugin_dir_url( __FILE__ ) . '/js/ecmqt-scripts.js', array(), $this->version, true ); 72 72 } 73 73 … … 78 78 79 79 public function add_admin_menu() { 80 add_menu_page( 'Quick Toolbar Links', 'Quick Toolbar', 'manage_options', 'ecm-quick-toolbar', array($this, 'admin_page'), 'dashicons-admin-links' );80 add_menu_page( 'Quick Toolbar Links', 'Quick Toolbar', 'manage_options', 'ecm-quick-toolbar', array($this, 'admin_page'), 'dashicons-admin-links', 100 ); 81 81 add_submenu_page( 'ecm-quick-toolbar', 'Custom Quick Links', 'Edit Custom Links', 'manage_options', 'ecm-custom-quick-toolbar', array($this, 'admin_custom_page') ); 82 82 } … … 93 93 $decoded = unserialize(base64_decode($option)); 94 94 if (isset($decoded[2]) && !empty($decoded[2])) { 95 if (0 === strpos($decoded[2][3], 'http')) { 96 $title = '<img src="'. $decoded[2][3] . '"/>' . $decoded[2][1]; 97 } else { 98 $title = '<span class="wp-menu-image dashicons-before ' . $decoded[2][3] . '"></span>' . $decoded[2][1]; 99 } 95 100 $allowed = user_can( $user_ID, $decoded[3] ); 96 101 if ($allowed == true) { 97 102 $admin_bar->add_menu( array( 98 103 'id' => 'ecmqt_'.date("Y-m-d-his").$decoded[2][0], 99 'title' => $decoded[2][1],104 'title' => __($title), 100 105 'href' => $decoded[2][2], 101 106 'meta' => array('class' => 'ecmqt-menu-item ecmqt-has-submenu') … … 103 108 } 104 109 } else { 110 if (0 === strpos($decoded[4], 'http')) { 111 $title = '<img src="'. $decoded[4] . '"/>' . $decoded[0]; 112 } else { 113 $title = '<span class="wp-menu-image dashicons-before ' . $decoded[4] . '"></span>' . $decoded[0]; 114 } 105 115 $allowed = user_can( $user_ID, $decoded[3] ); 106 116 if ($allowed == true) { 107 117 $admin_bar->add_menu( array( 108 118 'id' => 'ecmqt_'.date("Y-m-d-his").$j, 109 'title' => $decoded[0],119 'title' => __($title), 110 120 'href' => $decoded[1], 111 121 'meta' => array('class' => 'ecmqt-menu-item') … … 141 151 $co = 3000; 142 152 foreach ($custom_options as $key => $custom_option) { 143 if (isset($custom_options[$key][4]) && !empty($custom_options[$key][4])) { 153 if (empty($custom_options[$key][4]) || !isset($custom_options[$key][4])) { 154 $title = $custom_options[$key][0]; 155 } else { 156 $title = '<img src="'. $custom_options[$key][4] . '" />' . $custom_options[$key][0]; 157 } 158 159 if (isset($custom_options[$key][5]) && !empty($custom_options[$key][5])) { 144 160 if (isset($custom_options[$key][2]) && !empty($custom_options[$key][2]) && $custom_options[$key][2] == true) { 145 161 $meta = array('class' => 'ecmqt-menu-item ecmqt-has-submenu', 'target' => '_blank'); … … 150 166 $admin_bar->add_menu( array( 151 167 'id' => 'ecmqt_'.date("Y-m-d-his").$key, 152 'title' => $ custom_options[$key][0],168 'title' => $title, 153 169 'href' => $custom_options[$key][1], 154 170 'meta' => $meta … … 162 178 $admin_bar->add_menu( array( 163 179 'id' => 'ecmqt_'.date("Y-m-d-his").$co, 164 'title' => $ custom_options[$key][0],180 'title' => $title, 165 181 'href' => $custom_options[$key][1], 166 182 'meta' => $meta … … 172 188 $cos = 4000; 173 189 foreach($custom_options as $custom_option) { 174 if (isset($custom_option[ 4]) && !empty($custom_option[4])) {175 foreach ($custom_option[ 4] as $custom_menu_item) {190 if (isset($custom_option[5]) && !empty($custom_option[5])) { 191 foreach ($custom_option[5] as $custom_menu_item) { 176 192 if (isset($custom_menu_item[2]) && !empty($custom_menu_item[2]) && $custom_menu_item[2] == true) { 177 193 $meta = array('class' => 'ecmqt-submenu-item', 'target' => '_blank'); … … 200 216 if (isset($items) && !empty($items)) { ?> 201 217 <div class="wrap"> 202 <h2>Quick Toolbar Links <a href="<?php echo get_admin_url() . 'admin.php?page=ecm-custom-quick-toolbar';?>" class="add-new-h2 ">Edit Custom Toolbar Links</a></h2>218 <h2>Quick Toolbar Links <a href="<?php echo get_admin_url() . 'admin.php?page=ecm-custom-quick-toolbar';?>" class="add-new-h2 ecmqt-h2"">Edit Custom Toolbar Links</a></h2> 203 219 <br/> 204 220 <form method="post" action="options.php" id="_ecmqt_quicklinks_options"> … … 234 250 echo ''; 235 251 } else { 236 echo '<input id="check_menu_'. $x .'" type="checkbox"' . ' name="_ecmqt_items[]" value="' . base64_encode(serialize(array( $ecm_menu_item['name'] , $ecm_menu_item['link'], '', $ecm_menu_item['permissions'] ))) . '"' . $checked . '/>';252 echo '<input id="check_menu_'. $x .'" type="checkbox"' . ' name="_ecmqt_items[]" value="' . base64_encode(serialize(array( $ecm_menu_item['name'] , $ecm_menu_item['link'], '', $ecm_menu_item['permissions'], $ecm_menu_item['dashicon']))) . '"' . $checked . '/>'; 237 253 } 238 254 echo '</td>' . "\n"; … … 272 288 echo '<tr' . $ecm_class . '>' . "\n"; 273 289 echo '<td> — ' . $ecm_submenu_item['name'] . '</td>' . "\n"; 274 echo '<td><input id="check_menu_'.$x .'" type="checkbox" name="_ecmqt_items[]" value="' . base64_encode(serialize(array( $ecm_submenu_item['name'], $ecm_submenu_item['link'], array($ecm_submenu_item['parent']['id'], $ecm_submenu_item['parent']['name'], $ecm_submenu_item['parent']['link'] ), $ecm_submenu_item['permissions']))) . '"' . $sub_checked . '/></td>' . "\n";290 echo '<td><input id="check_menu_'.$x .'" type="checkbox" name="_ecmqt_items[]" value="' . base64_encode(serialize(array( $ecm_submenu_item['name'], $ecm_submenu_item['link'], array($ecm_submenu_item['parent']['id'], $ecm_submenu_item['parent']['name'], $ecm_submenu_item['parent']['link'], $ecm_submenu_item['parent']['dashicon']), $ecm_submenu_item['permissions']))) . '"' . $sub_checked . '/></td>' . "\n"; 275 291 echo '</tr>' . "\n"; 276 292 $x++; … … 306 322 unset($custom_options[$key]); 307 323 } 308 if (isset($custom_options[$key][ 4]) && !empty($custom_options[$key][4])) {309 foreach ($custom_options[$key][ 4] as $sub_key => $sub_option) {310 $sub_option_id = $custom_options[$key][ 4][$sub_key][3];324 if (isset($custom_options[$key][5]) && !empty($custom_options[$key][5])) { 325 foreach ($custom_options[$key][5] as $sub_key => $sub_option) { 326 $sub_option_id = $custom_options[$key][5][$sub_key][3]; 311 327 if ($sub_option_id == $custom_link) { 312 unset($custom_options[$key][ 4][$sub_key]);328 unset($custom_options[$key][5][$sub_key]); 313 329 } 314 330 } … … 327 343 $target = $_POST["_ecmqt_custom_items_target"]; 328 344 $parent = $_POST["_ecmqt_custom_items_parent"]; 345 $icon = $_POST["_ecmqt_upload_image"]; 329 346 330 347 if ($target == true) { … … 337 354 $unique = date('dmyHis'); 338 355 if ($parent == 'no-parent' || $parent == '') { 339 $custom_options[] = array($title, $link, $new_window, $unique );356 $custom_options[] = array($title, $link, $new_window, $unique, $icon); 340 357 } else { 341 358 foreach ($custom_options as $key => $value) { 342 359 $option_key = '_ecmqt_parent_' . $key; 343 360 if ($option_key == $parent) { 344 $custom_options[$key][ 4][] = array($title, $link, $new_window, $unique, $key);361 $custom_options[$key][5][] = array($title, $link, $new_window, $unique, $key, $icon); 345 362 } 346 363 } … … 355 372 } 356 373 357 public function custom_form() { ?> 374 public function custom_form() { 375 global $pagenow; 376 if ($pagenow == 'admin.php' && $_GET['page'] == 'ecm-custom-quick-toolbar') { 377 wp_enqueue_media(); 378 } ?> 358 379 <div class="wrap"> 359 <h2>Custom Quick Toolbar Links <a href="<?php echo get_admin_url() . 'admin.php?page=ecm-quick-toolbar';?>" class="add-new-h2 ">Edit Quick Toolbar Links</a></h2>360 <form id="_ecmqt_custom_quicklinks_options" name="_ecmqt_custom_quicklinks_options" method="post" action="" >380 <h2>Custom Quick Toolbar Links <a href="<?php echo get_admin_url() . 'admin.php?page=ecm-quick-toolbar';?>" class="add-new-h2 ecmqt-h2">Edit Quick Toolbar Links</a></h2> 381 <form id="_ecmqt_custom_quicklinks_options" name="_ecmqt_custom_quicklinks_options" method="post" action="" enctype="multipart/form-data"> 361 382 <label for="_ecmqt_custom_items_title">Link Title *</label><br/> 362 383 <input type="text" name="_ecmqt_custom_items_title" id="_ecmqt_custom_items_title" maxlength="50" size="40" required><br/><br/> … … 374 395 </select><br/><br/> 375 396 <?php } ?> 397 <input id="_ecmqt_upload_image_button" class="button" type="button" value="Choose Icon Image" /> 398 <input id="_ecmqt_upload_image_label" type="text" size="36" name="_ecmqt_upload_image_label" disabled /><br/> 399 <p class="description">Icons will only be displayed for top level menu items.</p><br/> 376 400 <input name="submit" type="submit" value="Add Custom Quick Link »" class="button button-primary"> 377 401 <input type="hidden" name="_ecmqt_custom_quicklinks_options" value="_ecmqt_custom_quicklinks_options"> 402 <input id="_ecmqt_upload_image" type="hidden" size="36" name="_ecmqt_upload_image" /> 378 403 </form><br/><br/> 379 404 … … 407 432 echo '</tr>'; 408 433 $x++; 409 if (isset($custom_option[ 4]) && !empty($custom_option[4])) {410 foreach ($custom_option[ 4] as $co_submenu) {434 if (isset($custom_option[5]) && !empty($custom_option[5])) { 435 foreach ($custom_option[5] as $co_submenu) { 411 436 $ecm_class = ( ' class="alternate"' == $ecm_class ) ? '' : ' class="alternate"'; 412 437 echo '<tr ' . $ecm_class . '>'; … … 503 528 'name' => $item[0], 504 529 'link' => get_admin_url() . "admin.php?page={$submenu_items[0][2]}", 505 'permissions' => $item[1] 530 'permissions' => $item[1], 531 'dashicon' => $item[6] 506 532 ); 507 533 … … 510 536 'name' => $item[0], 511 537 'link' => get_admin_url() . $submenu_items[0][2], 512 'permissions' => $item[1] 538 'permissions' => $item[1], 539 'dashicon' => $item[6] 513 540 ); 514 541 } … … 524 551 'name' => $item[0], 525 552 'link' => get_admin_url() . "admin.php?page={$item[2]}", 526 'permissions' => $item[1] 553 'permissions' => $item[1], 554 'dashicon' => $item[6] 527 555 ); 528 556 … … 531 559 'name' => $item[0], 532 560 'link' => get_admin_url() . $item[2], 533 'permissions' => $item[1] 561 'permissions' => $item[1], 562 'dashicon' => $item[6] 534 563 ); 535 564 } … … 587 616 'name' => $sub_item[0], 588 617 'link' => get_admin_url() . $sub_item_url, 589 'parent' => array('id' => $key, 'name' => $items[$key]['name'], 'link' => $items[$key]['link'] ),618 'parent' => array('id' => $key, 'name' => $items[$key]['name'], 'link' => $items[$key]['link'], 'dashicon' => $items[$key]['dashicon']), 590 619 'permissions' => $sub_item[1] 591 620 ); … … 595 624 'name' => $sub_item[0], 596 625 'link' => get_admin_url() . $sub_item[2], 597 'parent' => array('id' => $key, 'name' => $items[$key]['name'], 'link' => $items[$key]['link'] ),626 'parent' => array('id' => $key, 'name' => $items[$key]['name'], 'link' => $items[$key]['link'], 'dashicon' => $items[$key]['dashicon']), 598 627 'permissions' => $sub_item[1] 599 628 -
quick-toolbar/trunk/js/ecmqt-scripts.js
r1081423 r1082735 17 17 } 18 18 } 19 20 21 jQuery(document).ready(function($){ 22 23 var custom_uploader; 24 25 $('#_ecmqt_upload_image_button').click(function(e) { 26 e.preventDefault(); 27 28 //If the uploader object has already been created, reopen the dialog 29 if (custom_uploader) { 30 custom_uploader.open(); 31 return; 32 } 33 34 //Extend the wp.media object 35 custom_uploader = wp.media.frames.file_frame = wp.media({ 36 title: 'Choose Image', 37 button: { 38 text: 'Choose Image' 39 }, 40 multiple: false 41 }); 42 43 //When a file is selected, grab the URL and set it as the text field's value 44 custom_uploader.on('select', function() { 45 attachment = custom_uploader.state().get('selection').first().toJSON(); 46 $('#_ecmqt_upload_image').val(attachment.url); 47 $('#_ecmqt_upload_image_label').val(attachment.url); 48 }); 49 50 //Open the uploader dialog 51 custom_uploader.open(); 52 }); 53 }); -
quick-toolbar/trunk/readme.txt
r1081423 r1082735 4 4 Requires at least: 3.3 5 5 Tested up to: 4.1 6 Stable tag: 0. 16 Stable tag: 0.2 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 50 50 = 0.1 = 51 51 * First version of the plugin 52 53 = 0.2 = 54 * Adding Icons to the Quick Toolbar links 55 * Prefixing stylesheet to avoid conflict
Note: See TracChangeset
for help on using the changeset viewer.