PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.4.5
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.4.5
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 / Classes / AdminBar.php

AdminBar.php in Adminify – White Label, Admin Menu Editor, Login Customizer 3.2.4.5, at Inc/Classes/AdminBar.php

1,374 lines 56.3 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\Classes;
4
5 use WPAdminify\Inc\Utils;
6 use WPAdminify\Inc\Admin\AdminSettings;
7 use WPAdminify\Inc\Classes\DarkModeConflicts;
8 use WPAdminify\Inc\Admin\AdminSettingsModel;
9 // no direct access allowed
10 if ( !defined( 'ABSPATH' ) ) {
11 exit;
12 }
13 class AdminBar extends AdminSettingsModel {
14 public $options;
15
16 public $post_types;
17
18 public $adminify_ui;
19
20 public function __construct() {
21 $this->options = (array) AdminSettings::get_instance()->get( 'admin_bar_settings' );
22 $this->adminify_ui = AdminSettings::get_instance()->get( 'admin_ui' );
23 $admin_bar_mode = AdminSettings::get_instance()->get( 'admin_bar_mode' );
24 if ( $admin_bar_mode != 'light' ) {
25 new DarkModeConflicts();
26 }
27 // $admin_bar_user_roles = !empty($this->options['admin_bar_user_roles']) ? $this->options['admin_bar_user_roles'] : '';
28 // if (Utils::restricted_for($admin_bar_user_roles)) {
29 // return;
30 // }
31 // Disable the default admin bar
32 // add_filter('show_admin_bar', '__return_false');
33 // Add admin-bar support if not already activated
34 // add_theme_support('admin-bar', ['callback' => '__return_false']);
35 // Check Adminify Setup Wizard Page
36 if ( !empty( $_GET['page'] ) && 'wp-adminify-setup-wizard' == $_GET['page'] ) {
37 return;
38 }
39 add_action( 'plugins_loaded', [$this, 'initialize'] );
40 add_action( 'wp_admin_bar_class', [$this, 'load_wp_admin_bar_class'] );
41 if ( !empty( $this->options['admin_bar_search'] ) ) {
42 add_action( 'adminify/before/secondary_menu', [$this, 'before_secondary_menu'] );
43 }
44 if ( is_admin() ) {
45 // Switcher for Default UI
46 if ( empty( $this->adminify_ui ) ) {
47 add_action( 'admin_bar_menu', [$this, 'jltwp_adminify_dark_mode_switcher_icon'] );
48 }
49 }
50 }
51
52 // Add Switcher Icon on Admin Bar Secondary
53 public function jltwp_adminify_dark_mode_switcher_icon( $wp_admin_bar ) {
54 if ( empty( $this->options['admin_bar_dark_light_btn'] ) ) {
55 return;
56 }
57 $color_mode = ( !empty( $this->options['admin_bar_mode'] ) ? $this->options['admin_bar_mode'] : 'light' );
58 $adminbar_switcher_icon = '<div id="wp-adminify-color-mode-wrapper">
59 <div class="mode-icon adminify-color-mode-' . esc_attr( $color_mode ) . '-active">
60 <svg viewBox="0 0 24 24" width="24" height="24" class="darkIcon" ><path fill="currentColor" d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg>
61 <svg viewBox="0 0 24 24" width="24" height="24" class="lightIcon"><path fill="currentColor" d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"></path></svg>
62 <svg width="16" height="16" viewBox="0 0 22 18" fill="none" xmlns="http://www.w3.org/2000/svg" class="systemIcon">
63 <path d="M20 13V4.2C20 3.0799 20 2.51984 19.782 2.09202C19.5903 1.71569 19.2843 1.40973 18.908 1.21799C18.4802 1 17.9201 1 16.8 1H5.2C4.07989 1 3.51984 1 3.09202 1.21799C2.71569 1.40973 2.40973 1.71569 2.21799 2.09202C2 2.51984 2 3.0799 2 4.2V13M3.66667 17H18.3333C18.9533 17 19.2633 17 19.5176 16.9319C20.2078 16.7469 20.7469 16.2078 20.9319 15.5176C21 15.2633 21 14.9533 21 14.3333C21 14.0233 21 13.8683 20.9659 13.7412C20.8735 13.3961 20.6039 13.1265 20.2588 13.0341C20.1317 13 19.9767 13 19.6667 13H2.33333C2.02334 13 1.86835 13 1.74118 13.0341C1.39609 13.1265 1.12654 13.3961 1.03407 13.7412C1 13.8683 1 14.0233 1 14.3333C1 14.9533 1 15.2633 1.06815 15.5176C1.25308 16.2078 1.79218 16.7469 2.48236 16.9319C2.73669 17 3.04669 17 3.66667 17Z" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
64 </svg>
65 </div>
66 <div class="light-dark-dropdown">
67 <div class="light">
68 <svg viewBox="0 0 24 24" width="24" height="24" class="lightIcon"><path fill="currentColor" d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"></path></svg>
69 <span>Light</span>
70 </div>
71 <div class="dark">
72 <svg viewBox="0 0 24 24" width="24" height="24" class="darkIcon"><path fill="currentColor" d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg>
73 <span>Dark</span>
74 </div>
75 <div class="system">
76 <svg width="16" height="16" viewBox="0 0 22 18" fill="none" xmlns="http://www.w3.org/2000/svg" class="systemIcon">
77 <path d="M20 13V4.2C20 3.0799 20 2.51984 19.782 2.09202C19.5903 1.71569 19.2843 1.40973 18.908 1.21799C18.4802 1 17.9201 1 16.8 1H5.2C4.07989 1 3.51984 1 3.09202 1.21799C2.71569 1.40973 2.40973 1.71569 2.21799 2.09202C2 2.51984 2 3.0799 2 4.2V13M3.66667 17H18.3333C18.9533 17 19.2633 17 19.5176 16.9319C20.2078 16.7469 20.7469 16.2078 20.9319 15.5176C21 15.2633 21 14.9533 21 14.3333C21 14.0233 21 13.8683 20.9659 13.7412C20.8735 13.3961 20.6039 13.1265 20.2588 13.0341C20.1317 13 19.9767 13 19.6667 13H2.33333C2.02334 13 1.86835 13 1.74118 13.0341C1.39609 13.1265 1.12654 13.3961 1.03407 13.7412C1 13.8683 1 14.0233 1 14.3333C1 14.9533 1 15.2633 1.06815 15.5176C1.25308 16.2078 1.79218 16.7469 2.48236 16.9319C2.73669 17 3.04669 17 3.66667 17Z" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
78 </svg>
79 <span>System</span>
80 </div>
81 </div>
82 </div>';
83 // $user_id = get_current_user_id();
84 // if ( ! $user_id ) {
85 // return;
86 // }
87 // $adminbar_switcher_icon_toggle = get_user_meta( $user_id, 'adminbar_switcher_icon_toggle', true );
88 // $admin_bar_mode = !empty($this->options['admin_bar_mode']) ? $this->options['admin_bar_mode'] : '';
89 // if ( $adminbar_switcher_icon_toggle == 'off' ) {
90 // return;
91 // }
92 $args = [
93 'parent' => 'top-secondary',
94 'id' => 'wp-adminify-admin-bar-switcher',
95 'title' => $adminbar_switcher_icon,
96 'meta' => false,
97 ];
98 $wp_admin_bar->add_node( $args );
99 }
100
101 public function initialize() {
102 $admin_bar_position = ( !empty( $this->options['admin_bar_position'] ) ? $this->options['admin_bar_position'] : 'top' );
103 if ( is_admin() ) {
104 if ( $admin_bar_position == 'top' || $admin_bar_position == 'bottom' ) {
105 if ( !empty( $this->adminify_ui ) ) {
106 add_action( 'admin_init', [$this, 'jltwp_adminify_add_admin_bar'] );
107 } else {
108 add_action( 'admin_head', [$this, 'jltwp_adminify_legacy_admin_bar_positon'] );
109 }
110 }
111 add_action( 'admin_enqueue_scripts', [$this, 'jltwp_adminify_admin_scripts'], 100 );
112 // Remove Unnecessary Menus from Admin bar
113 // add_action('wp_before_admin_bar_render', [$this, 'jltma_adminify_remove_admin_bar_menus'], 0);
114 add_filter( 'admin_body_class', [$this, 'admin_bar_body_class'] );
115 add_action( 'admin_head', [$this, 'jltwp_adminify_admin_bar_css'], 999 );
116 add_action( 'wp_ajax_adminify_all_search', [$this, 'adminify_all_search'] );
117 add_action( 'wp_ajax_wp_adminify_color_mode', [$this, 'wp_adminify_color_mode'] );
118 // Screen Option and Help Tab
119 add_action(
120 'admin_head',
121 [$this, 'jltwp_adminify_remove_screen_options'],
122 10,
123 3
124 );
125 add_action( 'admin_head', [$this, 'jltwp_adminify_remove_help_tab'] );
126 } else {
127 // Admin bar Frontend settings
128 $frontend_admin = ( !empty( $this->options['admin_bar_hide_frontend'] ) ? $this->options['admin_bar_hide_frontend'] : 'show' );
129 $this->jltwp_adminify_front_bar();
130 if ( $admin_bar_position == 'bottom' ) {
131 add_action( 'init', [$this, 'admin_bar_front_style_init'] );
132 }
133 if ( $frontend_admin == 'hide' ) {
134 add_filter( 'show_admin_bar', '__return_false' );
135 }
136 }
137 }
138
139 public function before_secondary_menu() {
140 ?>
141 <div class="wp-adminify-top-header--search--form">
142 <form class="top-header--search--form" action="$">
143 <span class="adminify-search-expand"><i class="icon-magnifier icons"></i></span>
144 <input id="top-header-search-input" class="top-header-search-input" type="search" placeholder="Search here">
145 </form>
146
147 <div id="top-header-search-results" class=" top-header-search-results" style="display: none;">
148 <div class="top-header-results-wrapper">
149 </div>
150 </div>
151 </div>
152 <?php
153 }
154
155 public function load_wp_admin_bar_class() {
156 return 'WPAdminify\\Inc\\Classes\\Adminify_Admin_Bar';
157 }
158
159 public function jltwp_adminify_front_bar() {
160 add_action( 'admin_init', [$this, 'jltwp_adminify_add_admin_bar'] );
161 add_filter( 'body_class', [$this, 'admin_bar_body_class'] );
162 }
163
164 public function admin_bar_front_style_init() {
165 add_filter( 'wp_enqueue_scripts', [$this, 'admin_bar_front_style'] );
166 }
167
168 // Frontend Admin bar style
169 public function admin_bar_front_style() {
170 $admin_bar_css = '';
171 $admin_bar_css .= '.admin-bar-position-bottom #wpadminbar{
172 top:auto;
173 bottom: 0;
174 }
175 .admin-bar-position-bottom #wpadminbar .menupop .ab-sub-wrapper{
176 bottom: 32px;
177 }
178 @media all and (max-width:600px){
179 body.logged-in.admin-bar-position-bottom {
180 position: relative;
181 }
182 }';
183 wp_add_inline_style( 'admin-bar', $admin_bar_css );
184 }
185
186 // Remove Screen Options
187 public function jltwp_adminify_remove_screen_options() {
188 $enable_screen_tab = Utils::get_user_preference( 'screen_options_tab' );
189 if ( $enable_screen_tab ) {
190 add_filter( 'screen_options_show_screen', '__return_false' );
191 }
192 }
193
194 // Contextual Help Tab Remove
195 public function jltwp_adminify_remove_help_tab() {
196 $enable_screen_tab = Utils::get_user_preference( 'adminify_help_tab' );
197 if ( $enable_screen_tab ) {
198 $screen = get_current_screen();
199 $screen->remove_help_tabs();
200 }
201 }
202
203 // Get All registered WP Admin Menus
204 public static function get_wp_admin_menus( $thismenu, $thissubmenu ) {
205 $options = [];
206 if ( !empty( $thismenu ) && is_array( $thismenu ) ) {
207 foreach ( $thismenu as $item ) {
208 if ( !empty( $item[0] ) ) {
209 // the preg_replace removes "Comments" & "Plugins" menu spans.
210 $options[$item[2]] = preg_replace( '/\\<span.*?>.*?\\<\\/span><\\/span>/s', '', $item[0] );
211 }
212 }
213 }
214 if ( !empty( $thissubmenu ) && is_array( $thissubmenu ) ) {
215 foreach ( $thissubmenu as $items ) {
216 foreach ( $items as $item ) {
217 if ( !empty( $item[0] ) ) {
218 $options[$item[1]] = preg_replace( '/\\<span.*?>.*?\\<\\/span><\\/span>/s', '', $item[0] );
219 }
220 }
221 }
222 }
223 return $options;
224 }
225
226 public function jltwp_adminify_admin_scripts() {
227 global $pagenow;
228 // 21-2-24
229 // if (!is_user_logged_in() && $pagenow != 'wp-login.php') {
230 if ( $pagenow == 'wp-login.php' || $pagenow == 'wp-register.php' || $pagenow == 'customize.php' ) {
231 return;
232 }
233 // if (is_admin_bar_showing()) { }
234 if ( !empty( $this->adminify_ui ) ) {
235 wp_enqueue_style( 'wp-adminify-admin-bar' );
236 $this->admin_topbar_loader_css();
237 }
238 wp_localize_script( 'wp-adminify-admin', 'WPAdminify', $this->adminify_create_admin_bar_js_object() );
239 // wp_enqueue_style('wp-adminify-admin-bar', WP_ADMINIFY_ASSETS . 'css/admin-bar.css', false, WP_ADMINIFY_VER);
240 // wp_enqueue_script('wp-adminify-admin', WP_ADMINIFY_ASSETS . 'js/wp-adminify.js', ['jquery'], WP_ADMINIFY_VER, true);
241 // wp_localize_script('wp-adminify-admin', 'WPAdminify', $this->adminify_create_admin_bar_js_object());
242 }
243
244 public function adminify_create_admin_bar_js_object() {
245 return [
246 'ajax_url' => admin_url( 'admin-ajax.php' ),
247 'security_nonce' => wp_create_nonce( 'adminify-admin-bar-security-nonce' ),
248 'notice_nonce' => wp_create_nonce( 'adminify-notice-nonce' ),
249 ];
250 }
251
252 /**
253 * Preloader
254 *
255 * @return void
256 */
257 public function admin_topbar_loader_css() {
258 $output_css = '';
259 $topbar_wireframe_img = WP_ADMINIFY_ASSETS_IMAGE . 'topbar-wireframe.svg';
260 $output_css .= '.js .wp-adminify-topbar-loader{background: url(' . esc_url( $topbar_wireframe_img ) . '); }';
261 echo '<style>' . wp_strip_all_tags( $output_css ) . '</style>';
262 ?>
263
264 <script>
265 window.addEventListener('load', function() {
266 const isFullscreenMode = wp.data.select('core/edit-post').isFeatureActive('fullscreenMode');
267
268 if (isFullscreenMode) {
269 // wp.data.dispatch('core/edit-post').toggleFeature('fullscreenMode');
270 console.log('yes its it');
271 jQuery('.adminify-top_bar').css({
272 'display': 'none !important'
273 });
274 }
275 });
276 </script>
277
278 <?php
279 }
280
281 /**
282 * Save Color Mode by Ajax
283 *
284 * @return void
285 */
286 public function wp_adminify_color_mode() {
287 if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'adminify-admin-bar-security-nonce', 'security' ) > 0 ) {
288 $admin_bar_mode = AdminSettings::get_instance()->get();
289 if ( !empty( $_POST['key'] ) ) {
290 $key = sanitize_key( $_POST['key'] );
291 $value = Utils::clean_ajax_input( wp_unslash( $_POST['value'] ) );
292 if ( $key == '' ) {
293 $message = __( 'No Color Mode supplied to save', 'adminify' );
294 echo Utils::ajax_error_message( $message );
295 die;
296 }
297 }
298 // Light/Dark Mode
299 if ( $key === 'color_mode' ) {
300 $admin_bar_mode['admin_bar_mode'] = $value;
301 $admin_bar_mode['enable_schedule_dark_mode'] = false;
302 if ( $value == 'system' ) {
303 $admin_bar_mode['enable_schedule_dark_mode'] = true;
304 $admin_bar_mode['schedule_dark_mode_type'] = 'system';
305 }
306 update_option( '_wpadminify', $admin_bar_mode );
307 die;
308 }
309 // Screen Options, Help Tabs and WP Hide Links
310 if ( $key === 'screen_options_tab' || $key === 'hide_wp_links' || $key === 'adminify_help_tab' ) {
311 $userid = get_current_user_id();
312 $current = get_user_meta( $userid, '_wpadminify_preferences', true );
313 if ( is_array( $current ) ) {
314 $current[$key] = $value;
315 } else {
316 $current = [];
317 $current[$key] = $value;
318 }
319 $state = update_user_meta( $userid, '_wpadminify_preferences', $current );
320 if ( $state ) {
321 $returndata = [];
322 $returndata['success'] = true;
323 $returndata['message'] = __( 'Preferences saved', 'adminify' );
324 echo json_encode( $returndata );
325 } else {
326 $message = __( 'Unable to save user preferences', 'adminify' );
327 echo Utils::ajax_error_message( $message );
328 die;
329 }
330 }
331 }
332 }
333
334 /**
335 * Search Everything
336 *
337 * @return void
338 */
339 public function adminify_all_search() {
340 if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'adminify-admin-bar-security-nonce', 'security' ) > 0 ) {
341 if ( !empty( $_POST['search'] ) ) {
342 $term = sanitize_text_field( wp_unslash( $_POST['search'] ) );
343 }
344 // Search Arguments
345 $args = [
346 'numberposts' => -1,
347 's' => $term,
348 'post_status' => [
349 'publish',
350 'pending',
351 'draft',
352 'future',
353 'private',
354 'inherit'
355 ],
356 ];
357 // All Post Types
358 $post_types = $this->get_post_types();
359 foreach ( $post_types as $type ) {
360 $args['post_type'][] = $type->name;
361 }
362 // All Categories/Taxonomies
363 $all_taxonomies = get_taxonomies();
364 // Get Comments
365 $all_comments = get_comments();
366 // Get All Users
367 $all_users = get_users();
368 // All Users
369 // $blogusers = get_users();
370 // foreach ($blogusers as $type) {
371 // $name = $type->user_login;
372 // $id = $type->ID;
373 // $args['author__in'][] = $type->ID;
374 // }
375 // // All Menus
376 // $all_admin_menus = self::get_wp_admin_menus();
377 // All Plugins
378 if ( !function_exists( 'get_plugins' ) ) {
379 require_once ABSPATH . 'wp-admin/includes/plugin.php';
380 }
381 $all_plugins = get_plugins();
382 $foundposts = get_posts( $args );
383 // $count_items = '';
384 // if (count($foundposts) > 0) {
385 // $count_items .= count($foundposts);
386 // } elseif (count($all_plugins)) {
387 // $count_items .= count($all_plugins);
388 // }
389 ob_start();
390 ?>
391
392 <p><span class="count"></span><?php
393 echo count( $foundposts ) . wp_kses_post( ' item<span>s</span> found' );
394 ?></p>
395
396 <table class="top-header-result-table" style="height:500px;">
397 <thead>
398 <tr class="has-text-left">
399 <th><?php
400 esc_html_e( 'Title', 'adminify' );
401 ?></th>
402 <th><?php
403 esc_html_e( 'Type', 'adminify' );
404 ?></th>
405 <th><?php
406 esc_html_e( 'User', 'adminify' );
407 ?></th>
408 <th><?php
409 esc_html_e( 'Date', 'adminify' );
410 ?></th>
411 </tr>
412 </thead>
413 <tbody>
414
415 <?php
416 foreach ( $foundposts as $item ) {
417 $author_id = $item->post_author;
418 $editurl = get_edit_post_link( $item );
419 $public = get_permalink( $item );
420 ?>
421 <tr>
422 <td><span class="table-title"><a href="<?php
423 echo esc_url( $editurl );
424 ?>"><?php
425 echo wp_kses_post( get_the_title( $item ) );
426 ?></a></span></td>
427 <td><span class="type"><?php
428 echo wp_kses_post( get_post_type( $item ) );
429 ?></span></td>
430 <td><span class="user"><?php
431 echo wp_kses_post( the_author_meta( 'user_login', $author_id ) );
432 ?></span></td>
433 <td><span class="date"><?php
434 echo wp_kses_post( get_the_date( get_option( 'date_format' ), $item ) );
435 ?></span></td>
436 </tr>
437 <?php
438 }
439 ?>
440
441 <?php
442 foreach ( $all_taxonomies as $tax_name ) {
443 $terms = get_terms( [
444 'taxonomy' => $tax_name,
445 'hide_empty' => 1,
446 ] );
447 foreach ( $terms as $cat ) {
448 if ( strpos( strtolower( $cat->name ), strtolower( $term ) ) === false ) {
449 continue;
450 }
451 // $user = get_userdata($cat->term_id);
452 ?>
453 <tr>
454 <td>
455 <span class="table-title">
456 <a href="<?php
457 echo esc_url( get_term_link( $cat->slug, $cat->taxonomy ) );
458 ?>">
459 <?php
460 echo esc_html( $cat->name );
461 ?>
462 </a>
463 </span>
464 </td>
465 <td>
466 <span class="type"><?php
467 echo esc_html( $cat->taxonomy );
468 ?></span>
469 </td>
470 <td>
471 <span class="user">
472 <?php
473 esc_html_e( 'N/A', 'adminify' );
474 ?>
475 </span>
476 </td>
477 <td>
478 <span class="date">
479 <?php
480 esc_html_e( 'N/A', 'adminify' );
481 ?>
482 </span>
483 </td>
484 <td>
485 </td>
486 </tr>
487 <?php
488 }
489 }
490 ?>
491
492
493 <!-- Get Comments -->
494 <?php
495 foreach ( $all_comments as $comment ) {
496 if ( strpos( strtolower( $comment->comment_content ), strtolower( $term ) ) === false ) {
497 continue;
498 }
499 ?>
500 <tr>
501 <td>
502 <span class="table-title">
503 <a href="<?php
504 echo esc_url_raw( admin_url( 'comment.php?action=editcomment&c=' . esc_attr( $comment->comment_ID ) ) );
505 ?>">
506 <?php
507 echo wp_kses_post( $comment->comment_content );
508 ?>
509 </a>
510 </span>
511 </td>
512 <td>
513 <span class="type">
514 <?php
515 echo wp_kses_post( ucwords( $comment->comment_type ) );
516 ?>
517 </span>
518 </td>
519 <td>
520 <span class="user">
521 <?php
522 echo wp_kses_post( the_author_meta( 'display_name', $comment->user_id ) );
523 ?>
524 </span>
525 </td>
526 <td>
527 <span class="date">
528 <?php
529 echo esc_html( get_the_date( get_option( 'date_format' ), $comment->comment_date ) );
530 ?>
531 </span>
532 </td>
533 </tr>
534 <?php
535 }
536 ?>
537
538
539
540 <!-- Get Users -->
541 <?php
542 foreach ( $all_users as $user ) {
543 if ( strpos( strtolower( $user->user_login ), strtolower( $term ) ) === false ) {
544 continue;
545 }
546 ?>
547 <tr>
548 <td>
549 <span class="table-title">
550 <a href="<?php
551 echo esc_url( admin_url( 'user-edit.php?user_id=' . $user->ID ) );
552 ?>">
553 <?php
554 echo esc_html( $user->display_name );
555 ?>
556 </a>
557 </span>
558 </td>
559 <td>
560 <span class="type">
561 <?php
562 esc_html_e( 'User', 'adminify' );
563 ?>
564 </span>
565 </td>
566 <td>
567 <span class="user">
568 <?php
569 echo wp_kses_post( the_author_meta( 'display_name', $user->ID ) );
570 ?>
571 </span>
572 </td>
573 <td>
574 <span class="date">
575 <?php
576 echo wp_kses_post( get_the_date( get_option( 'date_format' ), $user->user_registered ) );
577 ?>
578 </span>
579 </td>
580 </tr>
581 <?php
582 }
583 ?>
584
585
586
587 <!-- Get Plugins -->
588 <?php
589 foreach ( $all_plugins as $plugin ) {
590 if ( strpos( strtolower( $plugin['Name'] ), strtolower( $term ) ) === false ) {
591 continue;
592 }
593 ?>
594 <tr>
595 <td>
596 <span class="table-title">
597 <a href="<?php
598 echo esc_url( admin_url( 'plugins.php' ) );
599 ?>">
600 <?php
601 echo esc_html( $plugin['Name'] );
602 ?>
603 </a>
604 </span>
605 </td>
606 <td>
607 <span class="type">
608 <?php
609 esc_html_e( 'Plugin', 'adminify' );
610 ?>
611 </span>
612 </td>
613 <td>
614 <span class="user">
615 <?php
616 echo esc_html( $plugin['AuthorName'] );
617 ?>
618 </span>
619 </td>
620 <td>
621 <span class="date">
622 <?php
623 esc_html_e( 'N/A', 'adminify' );
624 ?>
625 </span>
626 </td>
627 </tr>
628 <?php
629 }
630 ?>
631
632
633 </tbody>
634 </table>
635
636
637 <?php
638 $output_data = ob_get_clean();
639 echo json_encode( $output_data );
640 }
641 die;
642 }
643
644 public function jltwp_adminify_admin_bar_css() {
645 $current_screen = get_current_screen();
646 $admin_bar_mode = AdminSettings::get_instance()->get();
647 $admin_bar_mode = ( !empty( $admin_bar_mode['admin_bar_mode'] ) ? $admin_bar_mode['admin_bar_mode'] : '' );
648 $output_css = '';
649 $output_css .= '<style type="text/css">';
650 if ( !empty( $current_screen->is_block_editor ) ) {
651 $output_css .= '.wp-adminify.adminify-ui.block-editor-page:not(.wp-adminify.is-fullscreen-mode) .interface-interface-skeleton { top: 90px !important; left: 244px !important; border-top: 0 !important; border-left: 0 !important; }';
652 $output_css .= '.wp-adminify.block-editor-page.is-fullscreen-mode.block-editor-page .interface-interface-skeleton { top: 0 !important; left: 0 !important; border-top: 0 !important; border-left: 0 !important; }';
653 }
654 $admin_bar_container = ( !empty( $this->options['admin_bar_container'] ) ? $this->options['admin_bar_container'] : 'full_container' );
655 if ( $admin_bar_mode === 'light' ) {
656 $light_bg_type = ( !empty( $this->options['admin_bar_light_bg'] ) ? $this->options['admin_bar_light_bg'] : 'color' );
657 $light_bg_color = ( !empty( $this->options['admin_bar_light_bg_color'] ) ? $this->options['admin_bar_light_bg_color'] : '' );
658 // Full Container Colors
659 if ( $admin_bar_container == 'full_container' ) {
660 if ( $light_bg_type === 'color' ) {
661 $output_css .= '.wp-adminify.adminify-light-mode .adminify-top_bar nav.navbar, .wp-adminify .wp-adminify-horizontal-menu { background-color:' . esc_attr( $light_bg_color ) . ' ; }';
662 }
663 } elseif ( $admin_bar_container == 'admin_bar_only' ) {
664 // Admin Bar Colors
665 if ( $light_bg_type === 'color' ) {
666 if ( !empty( $this->options['admin_bar_light_bg_color'] ) ) {
667 $output_css .= '.wp-adminify.adminify-light-mode .adminify-top_bar nav.navbar { background-color:' . esc_attr( $light_bg_color ) . ' }';
668 }
669 }
670 }
671 if ( !empty( $admin_bar_colors['icon_color'] ) ) {
672 $output_css .= '.adminify-top_bar nav.navbar .navbar-menu .topbar-icon { fill: ' . esc_attr( $admin_bar_colors['icon_color'] ) . ' }';
673 }
674 } elseif ( $admin_bar_mode === 'dark' ) {
675 $dark_bg_type = ( isset( $this->options['admin_bar_dark_bg'] ) ? $this->options['admin_bar_dark_bg'] : 'color' );
676 if ( $admin_bar_container == 'full_container' ) {
677 if ( $dark_bg_type === 'color' ) {
678 $dark_bg_color = $this->options['admin_bar_dark_bg_color'];
679 $output_css .= '.wp-adminify.adminify-dark-mode .adminify-top_bar nav.navbar, .wp-adminify .wp-adminify-horizontal-menu{ background-color:' . esc_attr( $dark_bg_color ) . ' }';
680 } elseif ( $dark_bg_type === 'gradient' ) {
681 $dark_gradient_bg_color = $this->options['admin_bar_dark_bg_gradient']['background-color'];
682 $dark_gradient_color = $this->options['admin_bar_dark_bg_gradient']['background-gradient-color'];
683 $dark_gradient_color_dir = $this->options['admin_bar_dark_bg_gradient']['background-gradient-direction'];
684 $output_css .= '.wp-adminify.adminify-dark-mode .adminify-top_bar nav.navbar, .wp-adminify .wp-adminify-horizontal-menu{ background-image : linear-gradient(' . esc_attr( $dark_gradient_color_dir ) . ', ' . esc_attr( $dark_gradient_bg_color ) . ' , ' . esc_attr( $dark_gradient_color ) . '); }';
685 }
686 } elseif ( $admin_bar_container == 'admin_bar_only' ) {
687 if ( $dark_bg_type === 'color' ) {
688 $dark_bg_color = $this->options['admin_bar_dark_bg_color'];
689 $output_css .= '.wp-adminify.adminify-dark-mode .adminify-top_bar nav.navbar{ background-color:' . esc_attr( $dark_bg_color ) . ' }';
690 }
691 }
692 }
693 // "New" Button Colors
694 $new_btn_colors = ( !empty( $this->options['admin_bar_link_color'] ) ? $this->options['admin_bar_link_color'] : '' );
695 if ( !empty( $new_btn_colors['link_color'] ) ) {
696 $output_css .= '.wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-content > .ab-item .ab-label, .wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-content .ab-item .ab-icon:before { color:' . esc_attr( $new_btn_colors['link_color'] ) . ' !important; }';
697 }
698 if ( !empty( $new_btn_colors['hover_color'] ) ) {
699 $output_css .= '.wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-content > .ab-item:hover .ab-label, .wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-content .ab-item:hover .ab-icon:before{ color:' . esc_attr( $new_btn_colors['hover_color'] ) . ' !important; }';
700 }
701 if ( !empty( $new_btn_colors['bg_color'] ) ) {
702 $output_css .= '.wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-content > .ab-item, .wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-content:hover > .ab-item { background:' . esc_attr( $new_btn_colors['bg_color'] ) . ' !important;}';
703 }
704 // "New" Button Hover Colors
705 $new_btn_dropwon = ( !empty( $this->options['admin_bar_link_dropdown_color'] ) ? $this->options['admin_bar_link_dropdown_color'] : '' );
706 if ( !empty( $new_btn_dropwon['wrapper_bg'] ) ) {
707 $output_css .= '.wp-adminify #wpadminbar .ab-top-menu .ab-sub-wrapper, .wp-adminify #wpadminbar .ab-top-menu .ab-sub-wrapper .ab-submenu, .wp-adminify #wpadminbar .ab-top-menu .ab-sub-wrapper .ab-submenu .ab-item { background-color:' . esc_attr( $new_btn_dropwon['wrapper_bg'] ) . ' !important;}';
708 }
709 if ( !empty( $new_btn_dropwon['bg_color'] ) ) {
710 $output_css .= '.wp-adminify #wpadminbar .ab-top-menu .ab-sub-wrapper .ab-submenu .ab-item:hover { background-color:' . esc_attr( $new_btn_dropwon['bg_color'] ) . ' !important;}';
711 }
712 if ( !empty( $new_btn_dropwon['link_color'] ) ) {
713 $output_css .= '.wp-adminify #wpadminbar .ab-top-menu .ab-sub-wrapper .ab-submenu .ab-item { color:' . esc_attr( $new_btn_dropwon['link_color'] ) . ' !important }';
714 }
715 if ( !empty( $new_btn_dropwon['hover_color'] ) ) {
716 $output_css .= '.wp-adminify #wpadminbar .ab-top-menu .ab-sub-wrapper .ab-submenu .ab-item:hover { color:' . esc_attr( $new_btn_dropwon['hover_color'] ) . ' !important }';
717 }
718 // Text Color
719 if ( !empty( $this->options['admin_bar_text_color'] ) ) {
720 $output_css .= '.adminify-top_bar nav.navbar .navbar-brand .navbar-item .wp-adminify-site-name, .adminify-top_bar nav.navbar .navbar-menu .wp-adminify-user-site-list button { color:' . esc_attr( $this->options['admin_bar_text_color'] ) . ' }';
721 $output_css .= '.wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-post > .ab-item { color:' . esc_attr( $this->options['admin_bar_text_color'] ) . ' ; }';
722 $output_css .= '.wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-post > .ab-item .ab-icon:before { color:' . esc_attr( $this->options['admin_bar_text_color'] ) . ' ; }';
723 $output_css .= '.wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-post > .ab-item .ab-label { color:' . esc_attr( $this->options['admin_bar_text_color'] ) . ' ; }';
724 }
725 // Icon Color
726 if ( !empty( $this->options['admin_bar_icon_color'] ) ) {
727 $output_css .= '.adminify-top_bar nav.navbar .navbar-menu .topbar-icon svg path { fill:' . esc_attr( $this->options['admin_bar_icon_color'] ) . ' }';
728 $output_css .= '.adminify-top_bar nav.navbar .navbar-end i, .adminify-top_bar nav.navbar .navbar-burger i { color:' . esc_attr( $this->options['admin_bar_icon_color'] ) . ' }';
729 }
730 $output_css .= '.wp-adminify .editor-document-tools__left button.editor-document-tools__inserter-toggle {
731 padding: 0 !important;
732 border: 2px solid var(--adminify-btn-bg) !important;
733 }';
734 $output_css .= ' </style>';
735 // echo Utils::wp_kses_custom($output_css);
736 echo $output_css;
737 }
738
739 // Admin Bar Body Class
740 public function admin_bar_body_class( $classes ) {
741 if ( is_admin() ) {
742 $classes .= ' wp-adminify-admin-bar';
743 $admin_bar_position = ( !empty( $this->options['admin_bar_position'] ) ? $this->options['admin_bar_position'] : 'top' );
744 if ( $admin_bar_position === 'top' ) {
745 $classes .= ' position-top';
746 } elseif ( $admin_bar_position === 'bottom' ) {
747 $classes .= ' position-bottom';
748 }
749 if ( !empty( $this->options['enable_admin_bar'] ) ) {
750 $classes .= ' topbar-disabled';
751 }
752 } else {
753 global $pagenow;
754 if ( !is_user_logged_in() && $pagenow != 'wp-login.php' ) {
755 return $classes;
756 }
757 $classes[] = 'wp-adminify-admin-bar';
758 $admin_bar_position = ( !empty( $this->options['admin_bar_position'] ) ? $this->options['admin_bar_position'] : 'top' );
759 if ( $admin_bar_position === 'top' ) {
760 $classes[] = 'admin-bar-position-top';
761 } elseif ( $admin_bar_position === 'bottom' ) {
762 $classes[] = 'admin-bar-position-bottom';
763 }
764 if ( !empty( $this->options['enable_admin_bar'] ) ) {
765 $classes[] = 'topbar-disabled';
766 }
767 }
768 return $classes;
769 }
770
771 public function get_post_types() {
772 if ( is_array( $this->post_types ) ) {
773 return $this->post_types;
774 } else {
775 $args = [
776 'public' => true,
777 ];
778 $output = 'objects';
779 $post_types = get_post_types( $args, $output );
780 $this->post_types = $post_types;
781 return $post_types;
782 }
783 }
784
785 public function jltwp_adminify_legacy_admin_bar_positon() {
786 if ( !empty( $this->options['admin_bar_position'] ) && $this->options['admin_bar_position'] == 'bottom' ) {
787 $jltwp_adminify_thirdparty_css = '';
788 $jltwp_adminify_thirdparty_css .= 'body.wp-adminify.position-bottom {
789 margin-top: -28px;
790 padding-bottom: 28px;
791 }
792
793 body.wp-adminify.position-bottom.admin-bar #wphead {
794 padding-top: 0;
795 }
796
797 body.wp-adminify.position-bottom.admin-bar #footer {
798 padding-bottom: 28px;
799 }
800
801 body.wp-adminify.position-bottom #wpadminbar {
802 top: auto !important;
803 bottom: 0;
804 }
805
806 body.wp-adminify.position-bottom #wpadminbar .quicklinks .ab-top-menu .menupop .ab-sub-wrapper {
807 bottom: 32px;
808 }
809
810 body.wp-adminify.position-bottom #wpadminbar .quicklinks .ab-top-menu .menupop .ab-sub-wrapper .ab-submenu .menupop .ab-sub-wrapper {
811 bottom: -9px;
812 }';
813 echo '<style>' . wp_strip_all_tags( $jltwp_adminify_thirdparty_css ) . '</style>';
814 }
815 }
816
817 public function jltwp_adminify_add_admin_bar() {
818 // For Testing Admin Bar on Setup Wizard
819 // add_action('admin_head', [$this, 'jltwp_adminify_render_admin_bar']);
820 add_action( 'in_admin_header', [$this, 'jltwp_adminify_render_admin_bar'], -999999999 );
821 // on frontend area
822 add_action( 'wp_head', [$this, 'jltwp_adminify_render_admin_bar'] );
823 }
824
825 public function jltwp_adminify_render_admin_bar() {
826 global $pagenow;
827 if ( !is_user_logged_in() && $pagenow != 'wp-login.php' ) {
828 return;
829 }
830 // Check Gutenberg Editor Page
831 // if (Utils::is_block_editor_page()) {
832 // return;
833 // }
834 // if (!is_admin_bar_showing()) {
835 // return false;
836 // }
837 // Remove Adminbar from Gutenberg Block Editor Page
838 // if (function_exists('is_gutenberg_page') && is_gutenberg_page()) {
839 // // The Gutenberg plugin is on.
840 // return;
841 // }
842 // if (function_exists('get_current_screen')) {
843 // $current_screen = get_current_screen();
844 // if (!empty($current_screen->is_block_editor)) {
845 // return;
846 // }
847 // }
848 global $wp_admin_bar;
849 if ( empty( $wp_admin_bar ) ) {
850 return false;
851 }
852 $admin_bar_mode = AdminSettings::get_instance()->get();
853 $admin_bar_mode = ( empty( $admin_bar_mode['admin_bar_mode'] ) ? 'light' : $admin_bar_mode['admin_bar_mode'] );
854 // Light/Dark Mode
855 $enable_dark_mode = $admin_bar_mode != 'light';
856 // Screen Option && Hide WP Links
857 $enable_screen_tab = Utils::get_user_preference( 'screen_options_tab' );
858 $enable_help_tab = Utils::get_user_preference( 'adminify_help_tab' );
859 // $enable_hide_wp_links = Utils::get_user_preference( 'hide_wp_links' );
860 // Admin Bar Position
861 if ( !empty( $this->options['admin_bar_position'] ) && $this->options['admin_bar_position'] === 'top' ) {
862 $admin_bar_position = 'top_bar';
863 } elseif ( !empty( $this->options['admin_bar_position'] ) && $this->options['admin_bar_position'] === 'bottom' ) {
864 $admin_bar_position = 'bottom_bar is-fixed-bottom';
865 } else {
866 $admin_bar_position = 'top_bar';
867 }
868 $current_user = wp_get_current_user();
869 ob_start();
870 // Temporarily removing Topbar
871 // <div class="wp-adminify-topbar-loader"></div>
872 // 17-7-23, removed opacity for Conflicting Opacity Issue
873 // <div class="wp-adminify adminify-top_bar" style="opacity: 0;">
874 ?>
875
876
877
878 <div class="wp-adminify adminify-top_bar">
879 <nav class="navbar adminify-top-navbar <?php
880 echo esc_attr( $admin_bar_position );
881 ?>">
882
883 <?php
884 $this->jltwp_adminify_logo();
885 ?>
886 <div class="adminify-admin-wrapper">
887 <div class="adminify-legacy-admin">
888 <?php
889 echo wp_admin_bar_render();
890 ?>
891 </div>
892
893 <div id="wp-adminify-top-adminbar" class="navbar-menu">
894
895 <div class="navbar-end">
896 <div class="field is-grouped">
897
898 <?php
899 if ( !empty( $this->options['admin_bar_dark_light_btn'] ) ) {
900 ?>
901 <div class="wp-admnify--mode--switcher pr-4">
902 <label class="admnify-switcher is-pulled-right">
903 <input type="checkbox" id="light-dark-switcher-btn" <?php
904 checked( $enable_dark_mode, 1 );
905 ?>>
906 <span class="slider round"></span>
907 </label>
908 </div>
909 <?php
910 }
911 ?>
912
913 <?php
914 if ( !empty( $this->options['admin_bar_comments'] ) ) {
915 ?>
916 <div class="wp-adminify--top--comment ml-4 mr-4">
917 <button class="comment-trigger is-clickable">
918 <div class="topbar-icon">
919 <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
920 <path d="M0.25 13.75V1.75C0.25 0.921573 0.921572 0.25 1.75 0.25H12.25C13.0784 0.25 13.75 0.921573 13.75 1.75V9.25C13.75 10.0784 13.0784 10.75 12.25 10.75H4.75C4.42535 10.7494 4.10936 10.8547 3.85 11.05L0.25 13.75ZM1.75 1.75V10.75L3.3505 9.55C3.60973 9.35448 3.9258 9.24913 4.2505 9.25H12.25V1.75H1.75Z" fill="#4E4B66" />
921 </svg>
922 </div>
923 <span class="comment-counter p-0 tag is-rounded">
924 <?php
925 $comments_count = wp_count_comments();
926 echo esc_html( $comments_count->moderated );
927 ?>
928 </span>
929 </button>
930 </div>
931
932 <?php
933 }
934 if ( !empty( $this->options['admin_bar_view_website'] ) ) {
935 ?>
936 <div class="wp-adminify--preview mr-4">
937 <a class="preview-trigger is-clickable" href="<?php
938 echo esc_url( get_home_url() );
939 ?>" <?php
940 if ( !empty( $this->options['admin_bar_view_website_window_type'] ) && $this->options['admin_bar_view_website_window_type'] == 'new_tab' ) {
941 ?> target="_blank" <?php
942 }
943 ?>>
944 <i class="dashicons dashicons-visibility"></i>
945 </a>
946 </div>
947 <?php
948 }
949 ?>
950
951 <div class="wp-adminify--user--account">
952 <button class="user-avatar is-clickable">
953 <div class="image is-45x45">
954 <?php
955 echo get_avatar(
956 $current_user->user_email,
957 45,
958 '',
959 '',
960 [
961 'class' => 'is-rounded',
962 ]
963 );
964 ?>
965 </div>
966 <span class="user-status tag p-0 is-rounded"></span>
967 </button>
968 </div>
969
970 </div>
971 </div>
972 </div>
973 </div>
974 </nav>
975
976 <?php
977 if ( !empty( $this->options['admin_bar_user_offcanvas_menu'] ) ) {
978 ?>
979 <div class="wp-adminify--user--wrapper">
980 <div class="user-wqrapper-inner">
981 <button class="user-wrapper-close is-clickable">
982 <img src="<?php
983 echo esc_url( WP_ADMINIFY_ASSETS );
984 ?>images/header/close.svg" alt="Close Icon">
985 </button>
986
987 <div class="user-wrapper-top media">
988 <figure class="media-left">
989 <p class="image is-85x85">
990 <?php
991 echo get_avatar(
992 $current_user->user_email,
993 85,
994 '',
995 '',
996 [
997 'class' => 'is-rounded',
998 ]
999 );
1000 ?>
1001 </p>
1002 </figure>
1003 <div class="media-content">
1004 <div class="content">
1005 <h3 class="name">
1006 <?php
1007 echo esc_html( $current_user->display_name );
1008 ?>
1009 </h3>
1010 <a href="<?php
1011 echo esc_url( admin_url( 'profile.php' ) );
1012 ?>" class="email">
1013 <?php
1014 echo wp_kses_post( is_email( $current_user->user_email ) );
1015 ?>
1016 </a>
1017 <br>
1018 <a href="<?php
1019 echo esc_url( wp_logout_url() );
1020 ?>" class="logout button">
1021 <?php
1022 echo esc_html__( 'Log Out', 'adminify' );
1023 ?>
1024 </a>
1025 </div>
1026 </div>
1027 </div>
1028
1029
1030 <div class="user-wrapper-content">
1031 <div class="panel-insider">
1032 <h4 class="title"><?php
1033 esc_html__( 'Overview', 'adminify' );
1034 ?></h4>
1035 <ul>
1036 <li>
1037 <a href="<?php
1038 echo esc_url( get_home_url() );
1039 ?>" target="_blank">
1040 <img class="user-panel-icon" src="<?php
1041 echo esc_url( WP_ADMINIFY_ASSETS );
1042 ?>images/header/panel/building.svg" alt="<?php
1043 echo esc_html__( 'View Website Icon', 'adminify' );
1044 ?>">
1045 <?php
1046 echo esc_html_e( 'View Website', 'adminify' );
1047 ?>
1048 </a>
1049 </li>
1050 <li>
1051 <a href="<?php
1052 echo esc_url( admin_url( 'profile.php' ) );
1053 ?>">
1054 <img class="user-panel-icon" src="<?php
1055 echo esc_url( WP_ADMINIFY_ASSETS );
1056 ?>images/header/panel/users.svg" alt="<?php
1057 echo esc_html__( 'Profile Icon', 'adminify' );
1058 ?>">
1059 <?php
1060 esc_html_e( 'View Profile', 'adminify' );
1061 ?>
1062 </a>
1063 </li>
1064 </ul>
1065 </div>
1066
1067 <?php
1068 $all_updates = Utils::get_all_updates();
1069 $total_updates = $all_updates['total'];
1070 $plugin_updates = $all_updates['plugin'];
1071 $theme_updates = $all_updates['theme'];
1072 $wp_updates = $all_updates['wordpress'];
1073 ?>
1074
1075
1076 <div class="panel-insider">
1077 <h4 class="title"><?php
1078 esc_html_e( 'Updates', 'adminify' );
1079 ?></h4>
1080 <?php
1081 if ( $total_updates < 1 ) {
1082 ?>
1083 <p class="adminify-meta">
1084 <?php
1085 esc_html_e( 'Everything is up to date', 'adminify' );
1086 ?>
1087 </p>
1088 <?php
1089 } else {
1090 ?>
1091 <ul>
1092
1093 <li>
1094 <a href="<?php
1095 echo esc_url( admin_url( 'update-core.php' ) );
1096 ?>">
1097 <span class="icon-reload"></span>
1098 <?php
1099 esc_html_e( 'All Updates', 'adminify' );
1100 ?>
1101 <span class="count tag is-rounded">
1102 <?php
1103 echo esc_html( $total_updates );
1104 ?>
1105 </span>
1106 </a>
1107 </li>
1108 <li>
1109 <a href="<?php
1110 echo esc_url( admin_url( 'update-core.php' ) );
1111 ?>">
1112 <span class="dashicons dashicons-wordpress"></span>
1113 <?php
1114 esc_html_e( ' WordPress Core', 'adminify' );
1115 ?>
1116 <span class="count tag is-rounded">
1117 <?php
1118 echo esc_html( $wp_updates );
1119 ?>
1120 </span>
1121 </a>
1122 </li>
1123 <li>
1124 <a href="<?php
1125 echo esc_url( admin_url( 'plugins.php' ) );
1126 ?>">
1127 <span class="icon-energy"></span>
1128 <?php
1129 esc_html_e( ' Plugins', 'adminify' );
1130 ?>
1131 <span class="count tag is-rounded"><?php
1132 echo esc_html( count( $plugin_updates ) );
1133 ?></span>
1134 </a>
1135 </li>
1136 <li>
1137 <a href="<?php
1138 echo esc_url( admin_url( 'themes.php' ) );
1139 ?>">
1140 <img class="user-panel-icon" src="<?php
1141 echo esc_url( WP_ADMINIFY_ASSETS );
1142 ?>images/header/panel/plugins.svg" />
1143 <?php
1144 esc_html_e( ' Themes', 'adminify' );
1145 ?>
1146 <span class="count tag is-rounded"><?php
1147 echo esc_html( count( $theme_updates ) );
1148 ?></span>
1149 </a>
1150 </li>
1151 </ul>
1152 <?php
1153 }
1154 ?>
1155 </div>
1156
1157 <div class="panel-insider">
1158 <h4 class="title"><?php
1159 esc_html_e( 'Preferences', 'adminify' );
1160 ?></h4>
1161 <ul>
1162 <li>
1163 <?php
1164 esc_html_e( 'Screen Tab Hide', 'adminify' );
1165 ?>
1166 <label class="admnify-switcher is-pulled-right">
1167 <input type="checkbox" id="screen-option-switcher-btn" <?php
1168 checked( $enable_screen_tab, 1 );
1169 ?>>
1170 <span class="slider round"></span>
1171 </label>
1172 </li>
1173 <li>
1174 <?php
1175 esc_html_e( 'Help Tab Hide ', 'adminify' );
1176 ?>
1177 <label class="admnify-switcher is-pulled-right">
1178 <input type="checkbox" id="help-option-switcher-btn" <?php
1179 checked( $enable_help_tab, 1 );
1180 ?>>
1181 <span class="slider round"></span>
1182 </label>
1183 </li>
1184 <?php
1185 $on = false;
1186 // temporary hide this menu
1187 if ( $on == true ) {
1188 ?>
1189 <li>
1190 <?php
1191 esc_html_e( 'Hide WP Links', 'adminify' );
1192 ?>
1193 <label class="admnify-switcher is-pulled-right">
1194 <input type="checkbox" id="hide-wp-links-switcher-btn" <?php
1195 checked( $enable_hide_wp_links, 1 );
1196 ?>>
1197 <span class="slider round"></span>
1198 </label>
1199 </li>
1200 <?php
1201 }
1202 ?>
1203 </ul>
1204 </div>
1205 </div>
1206
1207 <!-- <div class="user-notification-area pb-5">
1208 <h4>
1209 <?php
1210 // esc_html_e('All Notifications', 'adminify');
1211 ?>
1212 </h4>
1213 <ul class="m-0 p-0">
1214 <li>
1215 <a href="#">Dashboard: <span class="count has-text-centered is-pulled-right">2</span></a>
1216 </li>
1217 <li>
1218 <a href="#">Themes: <span class="count has-text-centered is-pulled-right">2</span></a>
1219 </li>
1220 <li>
1221 <a href="#">Plugins: <span class="count has-text-centered is-pulled-right">2</span></a>
1222 </li>
1223 <li>
1224 <a href="#">Settings: <span class="count has-text-centered is-pulled-right">2</span></a>
1225 </li>
1226 </ul>
1227 </div> -->
1228
1229 </div>
1230 </div>
1231 <?php
1232 }
1233 ?>
1234 </div>
1235
1236 <?php
1237 $output_wp_admin_bar = ob_get_clean();
1238 // echo Utils::wp_kses_custom($output_wp_admin_bar);
1239 echo $output_wp_admin_bar;
1240 }
1241
1242 public function jltwp_adminify_logo() {
1243 global $wp_admin_bar;
1244 $adminurl = get_admin_url();
1245 $homeurl = $adminurl;
1246 // Light Logo
1247 $admin_bar_mode = AdminSettings::get_instance()->get();
1248 $menu_layout = (array) $admin_bar_mode['menu_layout_settings'];
1249 // Menu Layouts
1250 $menu_layout = ( !empty( $admin_bar_mode['menu_layout_settings'] ) ? $admin_bar_mode['menu_layout_settings'] : '' );
1251 $menu_mode = ( !empty( $menu_layout['menu_mode'] ) ? $menu_layout['menu_mode'] : 'classic' );
1252 $menu_layout = ( !empty( $menu_layout['layout_type'] ) ? $menu_layout['layout_type'] : 'vertical' );
1253 $admin_bar_logo_type = ( !empty( $admin_bar_mode['admin_bar_logo_type'] ) ? $admin_bar_mode['admin_bar_logo_type'] : 'image_logo' );
1254 $light_mode = ( !empty( $admin_bar_mode['admin_bar_light_mode'] ) ? $admin_bar_mode['admin_bar_light_mode'] : '' );
1255 $light_logo = '';
1256 if ( $admin_bar_logo_type == 'image_logo' ) {
1257 if ( $menu_mode == 'icon_menu' ) {
1258 if ( isset( $light_mode['mini_admin_bar_light_logo']['url'] ) && $light_mode['mini_admin_bar_light_logo']['url'] ) {
1259 $light_logo = $light_mode['mini_admin_bar_light_logo']['url'];
1260 } else {
1261 $light_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/logo-text-light.svg';
1262 }
1263 } else {
1264 // Logo Image
1265 if ( !empty( $light_mode['admin_bar_light_logo']['url'] ) ) {
1266 $light_logo = $light_mode['admin_bar_light_logo']['url'];
1267 } else {
1268 $light_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/logo-text-light.svg';
1269 }
1270 }
1271 } elseif ( $admin_bar_logo_type == 'text_logo' ) {
1272 // Text Logo
1273 if ( $admin_bar_mode['admin_bar_mode'] == 'light' ) {
1274 $text_logo = $light_mode['admin_bar_light_logo_text'];
1275 }
1276 }
1277 // Logo Size
1278 $light_width = ( isset( $light_mode['light_logo_size']['width'] ) ? $light_mode['light_logo_size']['width'] : '150' );
1279 $light_height = ( isset( $light_mode['light_logo_size']['height'] ) ? $light_mode['light_logo_size']['height'] : '45' );
1280 // Dark Logo
1281 $dark_mode = ( !empty( $admin_bar_mode['admin_bar_dark_mode'] ) ? $admin_bar_mode['admin_bar_dark_mode'] : '' );
1282 $dark_logo = '';
1283 if ( $admin_bar_logo_type == 'image_logo' ) {
1284 if ( $menu_mode == 'icon_menu' ) {
1285 if ( isset( $dark_mode['mini_admin_bar_dark_logo']['url'] ) && $dark_mode['mini_admin_bar_dark_logo']['url'] ) {
1286 $dark_logo = $dark_mode['mini_admin_bar_dark_logo']['url'];
1287 } else {
1288 $dark_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/logo-text-dark.svg';
1289 }
1290 } else {
1291 // Dark Logo Image
1292 if ( isset( $dark_mode['admin_bar_dark_logo']['url'] ) && $dark_mode['admin_bar_dark_logo']['url'] ) {
1293 $dark_logo = $dark_mode['admin_bar_dark_logo']['url'];
1294 } else {
1295 $dark_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/logo-text-dark.svg';
1296 }
1297 }
1298 } elseif ( $admin_bar_logo_type == 'text_logo' ) {
1299 // Text Logo
1300 if ( $admin_bar_mode['admin_bar_mode'] == 'dark' ) {
1301 $text_logo = $dark_mode['admin_bar_dark_logo_text'];
1302 }
1303 }
1304 // Dark Logo Size
1305 $dark_width = ( isset( $dark_mode['dark_logo_size']['width'] ) ? $dark_mode['dark_logo_size']['width'] : '150' );
1306 $dark_height = ( isset( $dark_mode['dark_logo_size']['height'] ) ? $dark_mode['dark_logo_size']['height'] : '45' );
1307 ?>
1308
1309 <div class="navbar-brand">
1310 <a class="navbar-item p-0" href="<?php
1311 echo esc_url( $homeurl );
1312 ?>">
1313 <?php
1314 if ( $admin_bar_logo_type == 'image_logo' ) {
1315 ?>
1316 <img alt="<?php
1317 echo esc_attr( get_bloginfo( 'name' ) );
1318 ?>" class="logo-light" src="<?php
1319 echo esc_url( $light_logo );
1320 ?>" width="<?php
1321 echo esc_attr( $light_width );
1322 ?>" height="<?php
1323 echo esc_attr( $light_height );
1324 ?>">
1325 <img alt="<?php
1326 echo esc_attr( get_bloginfo( 'name' ) );
1327 ?>" class="logo-dark" src="<?php
1328 echo esc_url( $dark_logo );
1329 ?>" width="<?php
1330 echo esc_attr( $dark_width );
1331 ?>" height="<?php
1332 echo esc_attr( $dark_height );
1333 ?>">
1334 <?php
1335 } elseif ( $admin_bar_logo_type == 'text_logo' ) {
1336 ?>
1337 <span class="wp-adminify-site-name">
1338 <?php
1339 echo esc_html( $text_logo );
1340 ?>
1341 </span>
1342 <?php
1343 }
1344 ?>
1345 </a>
1346
1347
1348 <div class="navbar-burger" data-target="wp-adminify-top-adminbar">
1349 <i class="dashicons dashicons-menu-alt"></i>
1350 </div>
1351
1352 </div>
1353
1354 <?php
1355 }
1356
1357 /* Remove from the administration bar */
1358 public function jltma_adminify_remove_admin_bar_menus() {
1359 global $wp_admin_bar;
1360 $restricted_user = ( !empty( $this->options['admin_bar_new_button_user_roles'] ) ? $this->options['admin_bar_new_button_user_roles'] : '' );
1361 if ( $restricted_user ) {
1362 if ( Utils::restrict_for( $this->options['admin_bar_new_button_user_roles'] ) ) {
1363 $wp_admin_bar->remove_menu( 'new-content' );
1364 return;
1365 }
1366 }
1367 $wp_admin_bar->remove_menu( 'wp-logo' );
1368 $wp_admin_bar->remove_menu( 'site-name' );
1369 $wp_admin_bar->remove_menu( 'updates' );
1370 $wp_admin_bar->remove_menu( 'menu-toggle' );
1371 }
1372
1373 }
1374