PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 2.0.4
Adminify – White Label, Admin Menu Editor, Login Customizer v2.0.4
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Inc / Modules / NotificationBar / NotificationBar.php

NotificationBar.php in Adminify – White Label, Admin Menu Editor, Login Customizer 2.0.4, at Inc/Modules/NotificationBar/NotificationBar.php

163 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPAdminify\Inc\Modules\NotificationBar;
4
5 use WPAdminify\Inc\Modules\NotificationBar\Inc\Notification_Customize;
6 use WPAdminify\Inc\Modules\NotificationBar\Inc\Notificationbar_Output;
7
8 // no direct access allowed
9 if (!defined('ABSPATH')) exit;
10
11 /**
12 * WP Adminify
13 * Module: Notification Bar
14 *
15 * @author Jewel Theme <support@jeweltheme.com>
16 */
17
18 if (!class_exists('NotificationBar')) {
19 class NotificationBar
20 {
21 public $url;
22 public $prefix;
23
24 public function __construct()
25 {
26 $this->url = WP_ADMINIFY_URL . 'Inc/Modules/NotificationBar';
27 $this->prefix = '_adminify_notification_bar';
28
29 add_action('admin_menu', [$this, 'notification_bar_submenu'], 45);
30 add_action('admin_init', [$this, 'notification_bar_redirect_customizer']);
31
32 // Setup customizer.
33 add_action('customize_register', [$this, 'notification_bar_register_panels']);
34 add_action('customize_register', [$this, 'notification_bar_register_sections']);
35
36 // Enqueue Assets
37 add_action('customize_controls_print_styles', [$this, 'notification_bar_control_styles'], 9999);
38 add_action('customize_controls_enqueue_scripts', [$this, 'notification_bar_control_scripts'], 9999);
39 add_action('customize_preview_init', [$this, 'notification_bar_preview_script'], 99);
40
41
42 new Notification_Customize();
43 new Notificationbar_Output();
44 }
45
46 /**
47 * Notification Bar: Control Styles
48 */
49 public function notification_bar_control_styles()
50 {
51 wp_enqueue_style('adminify-notification-bar-controls', WP_ADMINIFY_ASSETS . 'css/controls.css', null, WP_ADMINIFY_VER);
52 }
53
54
55 /**
56 * Notification Bar: Control Styles
57 */
58 public function notification_bar_control_scripts()
59 {
60 wp_enqueue_script('adminify-notification-bar-customizer', $this->url . '/assets/js/notification-bar-customizer.js', array('jquery', 'customize-controls'), WP_ADMINIFY_VER, true);
61 wp_localize_script('adminify-notification-bar-customizer', 'WPAdminifyNotificationBar', $this->jltwp_adminify_create_js_object());
62 }
63
64
65 /**
66 * Notification Bar: Preview JS
67 */
68 public function notification_bar_preview_script()
69 {
70
71 if (!is_customize_preview()) {
72 return;
73 }
74 wp_enqueue_script('adminify-notification-bar-preview', $this->url . '/assets/js/notification-bar-preview.js', array('jquery', 'customize-preview'), WP_ADMINIFY_VER, true);
75 wp_localize_script('adminify-notification-bar-preview', 'WPAdminifyNotificationBar', $this->jltwp_adminify_create_js_object());
76 }
77
78 /**
79 * Create JS Object
80 *
81 * @return void
82 */
83 public function jltwp_adminify_create_js_object()
84 {
85 return array(
86 'homeUrl' => home_url(),
87 'notificationBarUrl' => home_url('wp-adminify-notification-bar'),
88 'pluginUrl' => rtrim(WP_ADMINIFY_URL, '/'),
89 'moduleUrl' => $this->url,
90 'assetUrl' => $this->url . '/assets',
91 'isProActive' => false
92 );
93 }
94
95 /**
96 * Customizer Redirect
97 *
98 */
99 public function notification_bar_redirect_customizer()
100 {
101
102 if (!empty($_GET['page'])) {
103 if ('wp-adminify-notification-bar' === $_GET['page']) {
104 // Redirect URL
105 $url = add_query_arg(
106 array(
107 'autofocus[panel]' => 'jltwp_notification_bar_panel',
108 ),
109 admin_url('customize.php')
110 );
111
112 wp_safe_redirect($url);
113 }
114 }
115 }
116
117
118
119 /**
120 * Notification bar Sub Menu
121 */
122 public function notification_bar_submenu()
123 {
124 add_submenu_page(
125 'wp-adminify-settings',
126 esc_html__('Notification Bar by WP Adminify', WP_ADMINIFY_TD),
127 esc_html__('Notification Bar', WP_ADMINIFY_TD),
128 apply_filters('jltwp_adminify_capability', 'manage_options'),
129 admin_url('customize.php?autofocus[panel]=jltwp_notification_bar_panel')
130 );
131 }
132
133
134 /**
135 * Register Panels
136 */
137 public function notification_bar_register_panels($wp_customize)
138 {
139 $wp_customize->add_panel(
140 'jltwp_notification_bar_panel',
141 array(
142 'title' => __('Notification Bar - WP Adminify', WP_ADMINIFY_TD),
143 'description' => __('Customize Notification Bar with WP Adminify :)', WP_ADMINIFY_TD),
144 'capability' => apply_filters('jltwp_adminify_capability', 'manage_options'),
145 'priority' => 11,
146 )
147 );
148 }
149
150 /**
151 * Notification Bar Sections
152 *
153 * @param [type] $wp_customize
154 *
155 * @return void
156 */
157 public function notification_bar_register_sections($wp_customize)
158 {
159 notification_bar_sections($wp_customize);
160 }
161 }
162 }
163