PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.1
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.1
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 3.2.1, at Inc/Modules/NotificationBar/NotificationBar.php

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