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

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