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

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