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 / Classes / AdminBar.php

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

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