PluginProbe
Premmerce / 1.3.12
Premmerce v1.3.12
trunk 1.0 1.1 1.2 1.2.1 1.3 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.19 1.3.2 1.3.20 1.3.21 1.3.22 1.3.23 1.3.3 1.3.4 1.3.5 1.3.6 All 28 releases
premmerce / src / Admin / Handlers / ToolbarHandler.php

ToolbarHandler.php in Premmerce 1.3.12, at src/Admin/Handlers/ToolbarHandler.php

76 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Premmerce\Premmerce\Admin\Handlers;
4
5 use Premmerce\Premmerce\Api\PluginApi ;
6 use Premmerce\Premmerce\Api\WizardApi ;
7 class ToolbarHandler
8 {
9 const META_KEY_USE_MENU = 'premmerce_use_menu' ;
10 const AME_PLUGIN = 'admin-menu-editor' ;
11 /**
12 * @var WizardApi
13 */
14 private $wizard ;
15 /**
16 * @var PluginApi
17 */
18 private $api ;
19 /**
20 * ToolbarHandler constructor.
21 *
22 * @param PluginApi $api
23 * @param WizardApi $wizard
24 */
25 public function __construct( PluginApi $api, WizardApi $wizard )
26 {
27 $this->api = $api;
28 $this->wizard = $wizard;
29 }
30
31 /**
32 * Add premmerce to top admin bar
33 */
34 public function renderAdminBarItem()
35 {
36 /** @var \WP_Admin_Bar $wp_admin_bar */
37 global $wp_admin_bar ;
38 $uncompleted = (int) $this->wizard->getUncompletedTipsCount();
39 $uncompleted = "<div class='wp-core-ui wp-ui-notification premmerce-wizard-counter count-{$uncompleted}' ><span class='plugin-count' data-premmerce-count>{$uncompleted}<span></div>";
40 $svg = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="20" height="16" viewBox="0 0 20 16"><g id="Rectangle_7"> <path d="M17.8,4l-0.5,1C15.8,7.3,14.4,8,14,8c0,0,0,0,0,0H8h0V4.3C8,4.1,8.1,4,8.3,4H17.8 M4,0H1C0.4,0,0,0.4,0,1c0,0.6,0.4,1,1,1 h1.7C2.9,2,3,2.1,3,2.3V12c0,0.6,0.4,1,1,1c0.6,0,1-0.4,1-1V1C5,0.4,4.6,0,4,0L4,0z M18,2H7.3C6.6,2,6,2.6,6,3.3V12 c0,0.6,0.4,1,1,1c0.6,0,1-0.4,1-1v-1.7C8,10.1,8.1,10,8.3,10H14c1.1,0,3.2-1.1,5-4l0.7-1.4C20,4,20,3.2,19.5,2.6 C19.1,2.2,18.6,2,18,2L18,2z M14,11h-4c-0.6,0-1,0.4-1,1c0,0.6,0.4,1,1,1h4c0.6,0,1-0.4,1-1C15,11.4,14.6,11,14,11L14,11z M14,14 c-0.6,0-1,0.4-1,1c0,0.6,0.4,1,1,1c0.6,0,1-0.4,1-1C15,14.4,14.6,14,14,14L14,14z M4,14c-0.6,0-1,0.4-1,1c0,0.6,0.4,1,1,1 c0.6,0,1-0.4,1-1C5,14.4,4.6,14,4,14L4,14z"/></g></svg>';
41 $title = '<div class="premmerce-toolbar-icon ab-icon">' . $svg . '</div>' . $uncompleted;
42 $wp_admin_bar->add_menu( array(
43 'id' => 'premmerce_toolbar',
44 'title' => $title,
45 'href' => menu_page_url( 'premmerce', false ),
46 'meta' => array(
47 'class' => 'premmerce_admin_bar_wizard',
48 ),
49 ) );
50 $wp_admin_bar->add_menu( array(
51 'parent' => 'premmerce_toolbar',
52 'id' => 'premmerce_toolbar_wizard',
53 'title' => __( 'Incomplete', 'premmerce' ) . $uncompleted,
54 'href' => menu_page_url( 'premmerce', false ),
55 ) );
56 $wp_admin_bar->add_menu( array(
57 'parent' => 'premmerce_toolbar',
58 'id' => 'premmerce_toolbar_plugins',
59 'title' => __( 'Plugins', 'premmerce' ),
60 'href' => menu_page_url( 'premmerce', false ) . '&tab=plugins',
61 ) );
62 $wp_admin_bar->add_menu( array(
63 'parent' => 'premmerce_toolbar',
64 'id' => 'premmerce_toolbar_settings',
65 'title' => __( 'Settings', 'premmerce' ),
66 'href' => menu_page_url( 'premmerce', false ) . '&tab=settings',
67 ) );
68 $wp_admin_bar->add_menu( array(
69 'parent' => 'premmerce_toolbar',
70 'id' => 'premmerce_toolbar_addons',
71 'title' => __( 'Addons', 'premmerce' ),
72 'href' => menu_page_url( 'premmerce', false ) . '&tab=addons',
73 ) );
74 }
75
76 }