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

1,277 lines 58.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\Classes\DarkModeConflicts;
8 use WPAdminify\Inc\Admin\AdminSettingsModel;
9 // no direct access allowed
10 if ( !defined( 'ABSPATH' ) ) {
11 exit;
12 }
13 class AdminBar extends AdminSettingsModel {
14 public $options;
15
16 public $post_types;
17
18 public $adminify_ui;
19
20 public function __construct() {
21 $this->options = (array) AdminSettings::get_instance()->get();
22 $this->adminify_ui = $this->options['admin_ui'];
23 $global_ui_mode = ( empty( $this->options['light_dark_mode']['admin_ui_mode'] ) ? 'light' : $this->options['light_dark_mode']['admin_ui_mode'] );
24 $current_ui_mode = ( empty( get_user_meta( get_current_user_id(), 'color_mode', true ) ) ? $global_ui_mode : get_user_meta( get_current_user_id(), 'color_mode', true ) );
25 if ( $current_ui_mode === 'dark' || $current_ui_mode === 'system' ) {
26 new DarkModeConflicts();
27 }
28 // $admin_bar_user_roles = !empty($this->options['admin_bar_user_roles']) ? $this->options['admin_bar_user_roles'] : '';
29 // if (Utils::restricted_for($admin_bar_user_roles)) {
30 // return;
31 // }
32 // Disable the default admin bar
33 // add_filter('show_admin_bar', '__return_false');
34 // Add admin-bar support if not already activated
35 // add_theme_support('admin-bar', ['callback' => '__return_false']);
36 // 05-06-2024
37 // Check Adminify Setup Wizard Page
38 if ( !empty( $_GET['page'] ) && 'wp-adminify-setup-wizard' == $_GET['page'] ) {
39 return;
40 }
41 $this->initialize();
42 // if (!empty($this->adminify_ui) && !empty($this->options['admin_bar_search'] )) {
43 // add_action('wp_admin_bar_class', [$this, 'load_wp_admin_bar_class']);
44 // add_action('adminify/before/secondary_menu', [$this, 'before_secondary_menu']);
45 // }
46 if ( is_admin() ) {
47 // Switcher for Default UI
48 if ( empty( $this->adminify_ui ) ) {
49 if ( !empty( $this->options['admin_bar_dark_light_btn'] ) ) {
50 add_action( 'admin_bar_menu', [$this, 'jltwp_adminify_dark_mode_switcher_icon'] );
51 }
52 }
53 }
54 }
55
56 // Add Switcher Icon on Admin Bar Secondary
57 public function jltwp_adminify_dark_mode_switcher_icon( $wp_admin_bar ) {
58 $args = [
59 'parent' => 'top-secondary',
60 'id' => 'wp-adminify-admin-bar-switcher',
61 'title' => $this->jltwp_adminify_dark_mode_switcher_dom(),
62 'meta' => false,
63 ];
64 $wp_admin_bar->add_node( $args );
65 }
66
67 public function jltwp_adminify_dark_mode_switcher_dom() {
68 $global_color_mode = ( !empty( $this->options['light_dark_mode']['admin_ui_mode'] ) ? $this->options['light_dark_mode']['admin_ui_mode'] : 'light' );
69 $color_mode = ( empty( get_user_meta( get_current_user_id(), 'color_mode', true ) ) ? $global_color_mode : get_user_meta( get_current_user_id(), 'color_mode', true ) );
70 $color_var = ( !empty( $this->adminify_ui ) ? 'var(--adminify-menu-text-color)' : '#fff' );
71 $adminbar_switcher_icon = '<div id="wp-adminify-color-mode-wrapper">
72 <div class="mode-icon adminify-color-mode-' . esc_attr( $color_mode ) . '-active">
73 <svg viewBox="0 0 24 24" width="24" height="24" class="darkIcon" ><path fill="' . $color_var . '" d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg>
74 <svg viewBox="0 0 24 24" width="24" height="24" class="lightIcon"><path fill="' . $color_var . '" d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"></path></svg>
75 <svg width="16" height="16" viewBox="0 0 22 18" fill="none" xmlns="http://www.w3.org/2000/svg" class="systemIcon">
76 <path d="M20 13V4.2C20 3.0799 20 2.51984 19.782 2.09202C19.5903 1.71569 19.2843 1.40973 18.908 1.21799C18.4802 1 17.9201 1 16.8 1H5.2C4.07989 1 3.51984 1 3.09202 1.21799C2.71569 1.40973 2.40973 1.71569 2.21799 2.09202C2 2.51984 2 3.0799 2 4.2V13M3.66667 17H18.3333C18.9533 17 19.2633 17 19.5176 16.9319C20.2078 16.7469 20.7469 16.2078 20.9319 15.5176C21 15.2633 21 14.9533 21 14.3333C21 14.0233 21 13.8683 20.9659 13.7412C20.8735 13.3961 20.6039 13.1265 20.2588 13.0341C20.1317 13 19.9767 13 19.6667 13H2.33333C2.02334 13 1.86835 13 1.74118 13.0341C1.39609 13.1265 1.12654 13.3961 1.03407 13.7412C1 13.8683 1 14.0233 1 14.3333C1 14.9533 1 15.2633 1.06815 15.5176C1.25308 16.2078 1.79218 16.7469 2.48236 16.9319C2.73669 17 3.04669 17 3.66667 17Z" stroke="' . $color_var . '" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
77 </svg>
78 </div>
79 <div class="light-dark-dropdown">
80 <div class="light">
81 <svg viewBox="0 0 24 24" width="24" height="24" class="lightIcon"><path fill="' . $color_var . '" d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"></path></svg>
82 <span>Light</span>
83 </div>
84 <div class="dark">
85 <svg viewBox="0 0 24 24" width="24" height="24" class="darkIcon"><path fill="' . $color_var . '" d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg>
86 <span>Dark</span>
87 </div>
88 <div class="system">
89 <svg width="16" height="16" viewBox="0 0 22 18" fill="none" xmlns="http://www.w3.org/2000/svg" class="systemIcon">
90 <path d="M20 13V4.2C20 3.0799 20 2.51984 19.782 2.09202C19.5903 1.71569 19.2843 1.40973 18.908 1.21799C18.4802 1 17.9201 1 16.8 1H5.2C4.07989 1 3.51984 1 3.09202 1.21799C2.71569 1.40973 2.40973 1.71569 2.21799 2.09202C2 2.51984 2 3.0799 2 4.2V13M3.66667 17H18.3333C18.9533 17 19.2633 17 19.5176 16.9319C20.2078 16.7469 20.7469 16.2078 20.9319 15.5176C21 15.2633 21 14.9533 21 14.3333C21 14.0233 21 13.8683 20.9659 13.7412C20.8735 13.3961 20.6039 13.1265 20.2588 13.0341C20.1317 13 19.9767 13 19.6667 13H2.33333C2.02334 13 1.86835 13 1.74118 13.0341C1.39609 13.1265 1.12654 13.3961 1.03407 13.7412C1 13.8683 1 14.0233 1 14.3333C1 14.9533 1 15.2633 1.06815 15.5176C1.25308 16.2078 1.79218 16.7469 2.48236 16.9319C2.73669 17 3.04669 17 3.66667 17Z" stroke="' . $color_var . '" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
91 </svg>
92 <span>System</span>
93 </div>
94 </div>
95 </div>';
96 return $adminbar_switcher_icon;
97 }
98
99 public function initialize() {
100 $admin_bar_position = ( !empty( $this->options['admin_bar_position'] ) ? $this->options['admin_bar_position'] : 'top' );
101 if ( is_admin() ) {
102 if ( $admin_bar_position == 'top' || $admin_bar_position == 'bottom' ) {
103 if ( !empty( $this->adminify_ui ) ) {
104 //TODO: not need to adminify ui. alternative use iframe topbar
105 // add_action('admin_init', [$this, 'jltwp_adminify_add_admin_bar']);
106 // } else {
107 add_action( 'admin_head', [$this, 'jltwp_adminify_legacy_admin_bar_positon'] );
108 }
109 }
110 add_action( 'admin_enqueue_scripts', [$this, 'jltwp_adminify_admin_scripts'], 100 );
111 // Remove Unnecessary Menus from Admin bar
112 // add_action('wp_before_admin_bar_render', [$this, 'jltma_adminify_remove_admin_bar_menus'], 0);
113 // add_filter('admin_body_class', [$this, 'admin_bar_body_class']);
114 // add_action('admin_head', [$this, 'jltwp_adminify_admin_bar_css'], 999);
115 add_action( 'wp_ajax_adminify_all_search', [$this, 'adminify_all_search'] );
116 add_action( 'wp_ajax_wp_adminify_color_mode', [$this, 'wp_adminify_color_mode'] );
117 // Screen Option and Help Tab
118 add_action(
119 'admin_head',
120 [$this, 'jltwp_adminify_remove_screen_options'],
121 10,
122 3
123 );
124 add_action( 'admin_head', [$this, 'jltwp_adminify_remove_help_tab'] );
125 } else {
126 // Admin bar Frontend settings
127 $frontend_admin = ( !empty( $this->options['admin_bar_hide_frontend'] ) ? $this->options['admin_bar_hide_frontend'] : 'show' );
128 // if (jltwp_adminify()->can_use_premium_code__premium_only()) {
129 // if ($frontend_admin == 'show') {
130 // $frontend_admin_roles = (!empty($this->options['admin_bar_hide_frontend_user_roles'])) ? $this->options['admin_bar_hide_frontend_user_roles'] : [];
131 // if (Utils::restricted_for($frontend_admin_roles)) {
132 // $frontend_admin = 'hide';
133 // }
134 // }
135 // }
136 $this->jltwp_adminify_front_bar();
137 if ( $admin_bar_position == 'bottom' ) {
138 add_action( 'init', [$this, 'admin_bar_front_style_init'] );
139 }
140 if ( $frontend_admin == 'hide' ) {
141 add_filter( 'show_admin_bar', '__return_false' );
142 }
143 }
144 }
145
146 public function before_secondary_menu() {
147 ?>
148 <div class="wp-adminify-top-header--search--form">
149 <form class="top-header--search--form" action="$">
150 <span class="adminify-search-expand"><i class="icon-magnifier icons"></i></span>
151 <input id="top-header-search-input" class="top-header-search-input" type="search" placeholder="Search here">
152 </form>
153
154 <div id="top-header-search-results" class=" top-header-search-results" style="display: none;">
155 <div class="top-header-results-wrapper">
156 </div>
157 </div>
158 </div>
159 <?php
160 }
161
162 public function load_wp_admin_bar_class() {
163 return 'WPAdminify\\Inc\\Classes\\Adminify_Admin_Bar';
164 }
165
166 public function jltwp_adminify_front_bar() {
167 add_action( 'admin_init', [$this, 'jltwp_adminify_add_admin_bar'] );
168 add_filter( 'body_class', [$this, 'admin_bar_body_class'] );
169 }
170
171 public function admin_bar_front_style_init() {
172 add_filter( 'wp_enqueue_scripts', [$this, 'admin_bar_front_style'] );
173 }
174
175 // Frontend Admin bar style
176 public function admin_bar_front_style() {
177 $admin_bar_css = '';
178 $admin_bar_css .= '.admin-bar-position-bottom #wpadminbar{
179 top:auto;
180 bottom: 0;
181 }
182 .admin-bar-position-bottom #wpadminbar .menupop .ab-sub-wrapper{
183 bottom: 32px;
184 }
185 @media all and (max-width:600px){
186 body.logged-in.admin-bar-position-bottom {
187 position: relative;
188 }
189 }';
190 wp_add_inline_style( 'admin-bar', $admin_bar_css );
191 }
192
193 // Remove Screen Options
194 public function jltwp_adminify_remove_screen_options() {
195 $enable_screen_tab = Utils::get_user_preference( 'screen_options_tab' );
196 if ( $enable_screen_tab ) {
197 add_filter( 'screen_options_show_screen', '__return_false' );
198 }
199 }
200
201 // Contextual Help Tab Remove
202 public function jltwp_adminify_remove_help_tab() {
203 $enable_screen_tab = Utils::get_user_preference( 'adminify_help_tab' );
204 if ( $enable_screen_tab ) {
205 $screen = get_current_screen();
206 $screen->remove_help_tabs();
207 }
208 }
209
210 // Get All registered WP Admin Menus
211 public static function get_wp_admin_menus( $thismenu, $thissubmenu ) {
212 $options = [];
213 if ( !empty( $thismenu ) && is_array( $thismenu ) ) {
214 foreach ( $thismenu as $item ) {
215 if ( !empty( $item[0] ) ) {
216 // the preg_replace removes "Comments" & "Plugins" menu spans.
217 $options[$item[2]] = preg_replace( '/\\<span.*?>.*?\\<\\/span><\\/span>/s', '', $item[0] );
218 }
219 }
220 }
221 if ( !empty( $thissubmenu ) && is_array( $thissubmenu ) ) {
222 foreach ( $thissubmenu as $items ) {
223 foreach ( $items as $item ) {
224 if ( !empty( $item[0] ) ) {
225 $options[$item[1]] = preg_replace( '/\\<span.*?>.*?\\<\\/span><\\/span>/s', '', $item[0] );
226 }
227 }
228 }
229 }
230 return $options;
231 }
232
233 public function jltwp_adminify_admin_scripts() {
234 global $pagenow;
235 if ( $pagenow == 'wp-login.php' || $pagenow == 'wp-register.php' || $pagenow == 'customize.php' ) {
236 return;
237 }
238 // Commented on: 9-6-24
239 if ( !empty( $this->adminify_ui ) ) {
240 wp_enqueue_style( 'wp-adminify-admin-bar' );
241 $this->admin_topbar_loader_css();
242 }
243 wp_localize_script( 'wp-adminify-admin', 'WPAdminify', $this->adminify_create_admin_bar_js_object() );
244 }
245
246 public function adminify_create_admin_bar_js_object() {
247 return [
248 'ajax_url' => admin_url( 'admin-ajax.php' ),
249 'security_nonce' => wp_create_nonce( 'adminify-admin-bar-security-nonce' ),
250 'notice_nonce' => wp_create_nonce( 'adminify-notice-nonce' ),
251 ];
252 }
253
254 /**
255 * Preloader
256 *
257 * @return void
258 */
259 public function admin_topbar_loader_css() {
260 $output_css = '';
261 $topbar_wireframe_img = WP_ADMINIFY_ASSETS_IMAGE . 'topbar-wireframe.svg';
262 $output_css .= '.js .wp-adminify-topbar-loader{background: url(' . esc_url( $topbar_wireframe_img ) . '); }';
263 // Use wp_add_inline_style instead of echo to prevent "headers already sent" errors
264 wp_add_inline_style( 'wp-adminify-admin-bar', wp_strip_all_tags( $output_css ) );
265 $screen = get_current_screen();
266 // Get current screen details
267 if ( isset( $screen->base ) && $screen->base === 'post' ) {
268 $inline_script = "window.addEventListener('load', function() {\n\t\t\t\tconst isFullscreenMode = wp.data.select('core/edit-post').isFeatureActive('fullscreenMode');\n\t\t\t\tif (isFullscreenMode) {\n\t\t\t\t\tjQuery('.adminify-top_bar').css({\n\t\t\t\t\t\t'display': 'none !important'\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});";
269 wp_add_inline_script( 'wp-adminify-admin', $inline_script );
270 }
271 }
272
273 /**
274 * Save Color Mode by Ajax
275 *
276 * @return void
277 */
278 public function wp_adminify_color_mode() {
279 if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'adminify-admin-bar-security-nonce', 'security' ) > 0 ) {
280 // Color mode is per-user preference; require the caller to be
281 // a logged-in user with admin-bar access.
282 if ( !is_user_logged_in() || !current_user_can( 'read' ) ) {
283 wp_send_json_error( array(
284 'mess' => __( 'You are not allowed to perform this action.', 'adminify' ),
285 ), 403 );
286 }
287 $admin_bar_mode = AdminSettings::get_instance()->get();
288 if ( !empty( $_POST['key'] ) ) {
289 $key = sanitize_key( $_POST['key'] );
290 $value = Utils::clean_ajax_input( wp_unslash( $_POST['value'] ) );
291 if ( $key == '' ) {
292 $message = __( 'No Color Mode supplied to save', 'adminify' );
293 echo Utils::ajax_error_message( $message );
294 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- JSON-encoded string, not HTML.
295 die;
296 }
297 }
298 // Light/Dark Mode
299 if ( $key === 'color_mode' ) {
300 // For User preference
301 $userid = get_current_user_id();
302 $current = get_user_meta( $userid, $key, true );
303 if ( $current !== $value ) {
304 $state = update_user_meta( $userid, $key, $value );
305 }
306 die;
307 $admin_bar_mode['light_dark_mode']['admin_ui_mode'] = $value;
308 $this->options['schedule_dark_mode']['enable_schedule_dark_mode'] = false;
309 if ( $value == 'system' ) {
310 $admin_bar_mode['schedule_dark_mode']['enable_schedule_dark_mode'] = true;
311 $admin_bar_mode['schedule_dark_mode']['schedule_dark_mode_type'] = 'system';
312 }
313 update_option( '_wpadminify', $admin_bar_mode );
314 die;
315 }
316 // Screen Options, Help Tabs and WP Hide Links
317 if ( $key === 'screen_options_tab' || $key === 'hide_wp_links' || $key === 'adminify_help_tab' ) {
318 $userid = get_current_user_id();
319 $current = get_user_meta( $userid, '_wpadminify_preferences', true );
320 if ( is_array( $current ) ) {
321 $current[$key] = $value;
322 } else {
323 $current = [];
324 $current[$key] = $value;
325 }
326 $state = update_user_meta( $userid, '_wpadminify_preferences', $current );
327 if ( $state ) {
328 $returndata = [];
329 $returndata['success'] = true;
330 $returndata['message'] = __( 'Preferences saved', 'adminify' );
331 echo json_encode( $returndata );
332 } else {
333 $message = __( 'Unable to save user preferences', 'adminify' );
334 echo Utils::ajax_error_message( $message );
335 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- JSON-encoded string, not HTML.
336 die;
337 }
338 }
339 }
340 }
341
342 /**
343 * Search Everything
344 *
345 * @return void
346 */
347 public function adminify_all_search() {
348 if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'adminify-admin-bar-security-nonce', 'security' ) > 0 ) {
349 // Security check - only users who can edit posts should access admin search
350 if ( !current_user_can( 'edit_posts' ) ) {
351 wp_send_json_error( array(
352 'message' => __( 'You do not have permission to perform this action.', 'adminify' ),
353 ) );
354 }
355 $search_text = '';
356 if ( !empty( $_POST['search'] ) ) {
357 $search_text = sanitize_text_field( wp_unslash( $_POST['search'] ) );
358 }
359 // Error Handling For Minimum 3 Char
360 if ( strlen( $search_text ) < 3 ) {
361 wp_send_json_success( [
362 'message' => 'Please Enter Minimum 3 Characters',
363 ] );
364 }
365 // Search Arguments
366 $args = [
367 'numberposts' => -1,
368 's' => $search_text,
369 'post_status' => [
370 'publish',
371 'pending',
372 'draft',
373 'future',
374 'private',
375 'inherit'
376 ],
377 ];
378 // All Post Types
379 $post_types = $this->get_post_types();
380 foreach ( $post_types as $type ) {
381 $args['post_type'][] = $type->name;
382 }
383 // All Categories/Taxonomies
384 $all_taxonomies = get_taxonomies();
385 // Get Comments
386 $all_comments = get_comments();
387 // Get All Users
388 $all_users = get_users();
389 // All Users
390 // $blogusers = get_users();
391 // foreach ($blogusers as $type) {
392 // $name = $type->user_login;
393 // $id = $type->ID;
394 // $args['author__in'][] = $type->ID;
395 // }
396 // // All Menus
397 // $all_admin_menus = self::get_wp_admin_menus();
398 // All Plugins
399 if ( !function_exists( 'get_plugins' ) ) {
400 require_once ABSPATH . 'wp-admin/includes/plugin.php';
401 }
402 $all_plugins = get_plugins();
403 $foundposts = get_posts( $args );
404 // $count_items = '';
405 // if (count($foundposts) > 0) {
406 // $count_items .= count($foundposts);
407 // } elseif (count($all_plugins)) {
408 // $count_items .= count($all_plugins);
409 // }
410 $output_data = [
411 'foundposts' => $this->set_edit_url_foundposts( $foundposts ),
412 'all_taxonomies' => $this->filter_all_taxonomies( $all_taxonomies, $search_text ),
413 'all_comments' => $this->filter_all_comments( $all_comments, $search_text ),
414 'all_users' => $this->filter_all_users( $all_users, $search_text ),
415 'all_plugins' => $this->filter_all_plugins( $all_plugins, $search_text ),
416 ];
417 wp_send_json_success( [
418 'data' => json_encode( $output_data ),
419 ] );
420 return;
421 ob_start();
422 ?>
423
424 <p><span class="count"></span><?php
425 echo count( $foundposts ) . wp_kses_post( ' item<span>s</span> found' );
426 ?></p>
427
428 <table class="top-header-result-table" style="height:500px;">
429 <thead>
430 <tr class="has-text-left">
431 <th><?php
432 esc_html_e( 'Title', 'adminify' );
433 ?></th>
434 <th><?php
435 esc_html_e( 'Type', 'adminify' );
436 ?></th>
437 <th><?php
438 esc_html_e( 'User', 'adminify' );
439 ?></th>
440 <th><?php
441 esc_html_e( 'Date', 'adminify' );
442 ?></th>
443 </tr>
444 </thead>
445 <tbody>
446
447 <?php
448 foreach ( $foundposts as $item ) {
449 $author_id = $item->post_author;
450 $editurl = get_edit_post_link( $item );
451 $public = get_permalink( $item );
452 ?>
453 <tr>
454 <td><span class="table-title"><a href="<?php
455 echo esc_url( $editurl );
456 ?>"><?php
457 echo wp_kses_post( get_the_title( $item ) );
458 ?></a></span></td>
459 <td><span class="type"><?php
460 echo wp_kses_post( get_post_type( $item ) );
461 ?></span></td>
462 <td><span class="user"><?php
463 echo wp_kses_post( the_author_meta( 'user_login', $author_id ) );
464 ?></span></td>
465 <td><span class="date"><?php
466 echo wp_kses_post( get_the_date( get_option( 'date_format' ), $item ) );
467 ?></span></td>
468 </tr>
469 <?php
470 }
471 ?>
472
473 <?php
474 foreach ( $all_taxonomies as $tax_name ) {
475 $terms = get_terms( [
476 'taxonomy' => $tax_name,
477 'hide_empty' => 1,
478 ] );
479 foreach ( $terms as $cat ) {
480 if ( strpos( strtolower( $cat->name ), strtolower( $term ) ) === false ) {
481 continue;
482 }
483 // $user = get_userdata($cat->term_id);
484 ?>
485 <tr>
486 <td>
487 <span class="table-title">
488 <a href="<?php
489 echo esc_url( get_term_link( $cat->slug, $cat->taxonomy ) );
490 ?>">
491 <?php
492 echo esc_html( $cat->name );
493 ?>
494 </a>
495 </span>
496 </td>
497 <td>
498 <span class="type"><?php
499 echo esc_html( $cat->taxonomy );
500 ?></span>
501 </td>
502 <td>
503 <span class="user">
504 <?php
505 esc_html_e( 'N/A', 'adminify' );
506 ?>
507 </span>
508 </td>
509 <td>
510 <span class="date">
511 <?php
512 esc_html_e( 'N/A', 'adminify' );
513 ?>
514 </span>
515 </td>
516 <td>
517 </td>
518 </tr>
519 <?php
520 }
521 }
522 ?>
523
524
525 <!-- Get Comments -->
526 <?php
527 foreach ( $all_comments as $comment ) {
528 if ( strpos( strtolower( $comment->comment_content ), strtolower( $term ) ) === false ) {
529 continue;
530 }
531 ?>
532 <tr>
533 <td>
534 <span class="table-title">
535 <a href="<?php
536 echo esc_url_raw( admin_url( 'comment.php?action=editcomment&c=' . esc_attr( $comment->comment_ID ) ) );
537 ?>">
538 <?php
539 echo wp_kses_post( $comment->comment_content );
540 ?>
541 </a>
542 </span>
543 </td>
544 <td>
545 <span class="type">
546 <?php
547 echo wp_kses_post( ucwords( $comment->comment_type ) );
548 ?>
549 </span>
550 </td>
551 <td>
552 <span class="user">
553 <?php
554 echo wp_kses_post( the_author_meta( 'display_name', $comment->user_id ) );
555 ?>
556 </span>
557 </td>
558 <td>
559 <span class="date">
560 <?php
561 echo esc_html( get_the_date( get_option( 'date_format' ), $comment->comment_date ) );
562 ?>
563 </span>
564 </td>
565 </tr>
566 <?php
567 }
568 ?>
569
570
571
572 <!-- Get Users -->
573 <?php
574 foreach ( $all_users as $user ) {
575 if ( strpos( strtolower( $user->user_login ), strtolower( $term ) ) === false ) {
576 continue;
577 }
578 ?>
579 <tr>
580 <td>
581 <span class="table-title">
582 <a href="<?php
583 echo esc_url( admin_url( 'user-edit.php?user_id=' . $user->ID ) );
584 ?>">
585 <?php
586 echo esc_html( $user->display_name );
587 ?>
588 </a>
589 </span>
590 </td>
591 <td>
592 <span class="type">
593 <?php
594 echo wp_kses_post( ucwords( $comment->comment_type ) );
595 ?>
596 </span>
597 </td>
598 <td>
599 <span class="user">
600 <?php
601 echo wp_kses_post( the_author_meta( 'display_name', $comment->user_id ) );
602 ?>
603 </span>
604 </td>
605 <td>
606 <span class="date">
607 <?php
608 echo wp_kses_post( get_the_date( get_option( 'date_format' ), $user->user_registered ) );
609 ?>
610 </span>
611 </td>
612 </tr>
613 <?php
614 }
615 ?>
616
617
618
619 <!-- Get Plugins -->
620 <?php
621 foreach ( $all_plugins as $plugin ) {
622 if ( strpos( strtolower( $plugin['Name'] ), strtolower( $term ) ) === false ) {
623 continue;
624 }
625 ?>
626 <tr>
627 <td>
628 <span class="table-title">
629 <a href="<?php
630 echo esc_url( admin_url( 'plugins.php' ) );
631 ?>">
632 <?php
633 echo esc_html( $plugin['Name'] );
634 ?>
635 </a>
636 </span>
637 </td>
638 <td>
639 <span class="type">
640 <?php
641 esc_html_e( 'Plugin', 'adminify' );
642 ?>
643 </span>
644 </td>
645 <td>
646 <span class="user">
647 <?php
648 echo esc_html( $plugin['AuthorName'] );
649 ?>
650 </span>
651 </td>
652 <td>
653 <span class="date">
654 <?php
655 esc_html_e( 'N/A', 'adminify' );
656 ?>
657 </span>
658 </td>
659 </tr>
660 <?php
661 }
662 ?>
663
664
665 </tbody>
666 </table>
667
668
669 <?php
670 // $output_data = ob_get_clean();
671 // $output_data = [
672 // 'foundposts' => $foundposts,
673 // 'all_taxonomies' => $all_taxonomies,
674 // 'all_comments' => $all_comments,
675 // 'all_users' => $all_users,
676 // 'all_plugins' => $all_plugins,
677 // ];
678 // echo json_encode($output_data);
679 echo json_encode( $foundposts );
680 wp_send_json_success( [
681 'data' => $foundposts,
682 ] );
683 }
684 die;
685 }
686
687 /**
688 * Set URL to All Post
689 */
690 public function set_edit_url_foundposts( $foundposts ) {
691 $all_posts = [];
692 foreach ( $foundposts as $key => $post ) {
693 $edit_url = get_edit_post_link( $post );
694 $all_posts[$key]['title'] = get_the_title( $post->ID );
695 $all_posts[$key]['link'] = $edit_url;
696 }
697 return $all_posts;
698 }
699
700 /**
701 * Search Taxonomies
702 */
703 public function filter_all_taxonomies( $all_taxonomies, $search_text ) {
704 $find_taxonomies = [];
705 foreach ( $all_taxonomies as $tax_name ) {
706 $terms = get_terms( [
707 'taxonomy' => $tax_name,
708 'hide_empty' => 1,
709 ] );
710 foreach ( $terms as $key => $cat ) {
711 if ( strpos( strtolower( $cat->name ), strtolower( $search_text ) ) === false ) {
712 continue;
713 }
714 $find_taxonomies[$key]['name'] = $cat->name;
715 $find_taxonomies[$key]['link'] = get_edit_term_link( $cat );
716 }
717 }
718 return $find_taxonomies;
719 }
720
721 /**
722 * Search Comments
723 */
724 public function filter_all_comments( $all_comments, $search_text ) {
725 $find_comments = [];
726 foreach ( $all_comments as $key => $comment ) {
727 if ( strpos( strtolower( $comment->comment_content ), strtolower( $search_text ) ) === false ) {
728 continue;
729 }
730 $find_comments[$key]['content'] = $comment->comment_content;
731 $find_comments[$key]['link'] = admin_url( 'comment.php?action=editcomment&c=' . esc_attr( $comment->comment_ID ) );
732 }
733 return $find_comments;
734 }
735
736 /**
737 * Search Users
738 */
739 public function filter_all_users( $all_users, $search_text ) {
740 $find_users = [];
741 foreach ( $all_users as $key => $user ) {
742 if ( str_contains( strtolower( $user->data->user_login ), strtolower( $search_text ) ) || str_contains( strtolower( $user->data->display_name ), strtolower( $search_text ) ) ) {
743 $find_users[$key]['name'] = $user->data->user_login;
744 $find_users[$key]['display_name'] = $user->data->display_name;
745 $find_users[$key]['link'] = admin_url( 'user-edit.php?user_id=' . $user->ID );
746 }
747 }
748 return $find_users;
749 }
750
751 /**
752 * Search Plugins
753 */
754 public function filter_all_plugins( $all_plugins, $search_text ) {
755 $find_plugins = [];
756 foreach ( $all_plugins as $key => $plugin ) {
757 if ( strpos( strtolower( $plugin['Name'] ), strtolower( $search_text ) ) === false ) {
758 continue;
759 }
760 $find_plugins[] = [
761 'name' => $plugin['Name'],
762 'link' => admin_url( 'plugins.php' ),
763 ];
764 }
765 return $find_plugins;
766 }
767
768 public function jltwp_adminify_admin_bar_css() {
769 $current_screen = get_current_screen();
770 $admin_bar_mode = ( !empty( $admin_bar_mode['light_dark_mode']['admin_ui_mode'] ) ? $admin_bar_mode['light_dark_mode']['admin_ui_mode'] : '' );
771 $output_css = '';
772 $output_css .= '<style type="text/css">';
773 if ( !empty( $current_screen->is_block_editor ) ) {
774 $output_css .= '.wp-adminify.adminify-ui.block-editor-page:not(.wp-adminify.is-fullscreen-mode) .interface-interface-skeleton { top: 90px !important; left: 244px !important; border-top: 0 !important; border-left: 0 !important; }';
775 $output_css .= '.wp-adminify.block-editor-page.is-fullscreen-mode.block-editor-page .interface-interface-skeleton { top: 0 !important; left: 0 !important; border-top: 0 !important; border-left: 0 !important; }';
776 }
777 $admin_bar_container = ( !empty( $this->options['admin_bar_container'] ) ? $this->options['admin_bar_container'] : 'full_container' );
778 if ( $admin_bar_mode === 'light' ) {
779 $light_bg_type = ( !empty( $this->options['admin_bar_light_bg'] ) ? $this->options['admin_bar_light_bg'] : 'color' );
780 $light_bg_color = ( !empty( $this->options['admin_bar_light_bg_color'] ) ? $this->options['admin_bar_light_bg_color'] : '' );
781 // Full Container Colors
782 if ( $admin_bar_container == 'full_container' ) {
783 if ( $light_bg_type === 'color' ) {
784 $output_css .= '.wp-adminify.adminify-light-mode .adminify-top_bar nav.navbar, .wp-adminify .wp-adminify-horizontal-menu { background-color:' . esc_attr( $light_bg_color ) . ' ; }';
785 }
786 } elseif ( $admin_bar_container == 'admin_bar_only' ) {
787 // Admin Bar Colors
788 if ( $light_bg_type === 'color' ) {
789 if ( !empty( $this->options['admin_bar_light_bg_color'] ) ) {
790 $output_css .= '.wp-adminify.adminify-light-mode .adminify-top_bar nav.navbar { background-color:' . esc_attr( $light_bg_color ) . ' }';
791 }
792 }
793 }
794 if ( !empty( $admin_bar_colors['icon_color'] ) ) {
795 $output_css .= '.adminify-top_bar nav.navbar .navbar-menu .topbar-icon { fill: ' . esc_attr( $admin_bar_colors['icon_color'] ) . ' }';
796 }
797 } elseif ( $admin_bar_mode === 'dark' ) {
798 $dark_bg_type = ( isset( $this->options['admin_bar_dark_bg'] ) ? $this->options['admin_bar_dark_bg'] : 'color' );
799 if ( $admin_bar_container == 'full_container' ) {
800 if ( $dark_bg_type === 'color' ) {
801 $dark_bg_color = $this->options['admin_bar_dark_bg_color'];
802 $output_css .= '.wp-adminify.adminify-dark-mode .adminify-top_bar nav.navbar, .wp-adminify .wp-adminify-horizontal-menu{ background-color:' . esc_attr( $dark_bg_color ) . ' }';
803 } elseif ( $dark_bg_type === 'gradient' ) {
804 $dark_gradient_bg_color = $this->options['admin_bar_dark_bg_gradient']['background-color'];
805 $dark_gradient_color = $this->options['admin_bar_dark_bg_gradient']['background-gradient-color'];
806 $dark_gradient_color_dir = $this->options['admin_bar_dark_bg_gradient']['background-gradient-direction'];
807 $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 ) . '); }';
808 }
809 } elseif ( $admin_bar_container == 'admin_bar_only' ) {
810 if ( $dark_bg_type === 'color' ) {
811 $dark_bg_color = $this->options['admin_bar_dark_bg_color'];
812 $output_css .= '.wp-adminify.adminify-dark-mode .adminify-top_bar nav.navbar{ background-color:' . esc_attr( $dark_bg_color ) . ' }';
813 }
814 }
815 }
816 // "New" Button Colors
817 $new_btn_colors = ( !empty( $this->options['admin_bar_link_color'] ) ? $this->options['admin_bar_link_color'] : '' );
818 if ( !empty( $new_btn_colors['link_color'] ) ) {
819 $output_css .= '.wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-content > .ab-item .ab-label, .wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-content .ab-item .ab-icon:before { color:' . esc_attr( $new_btn_colors['link_color'] ) . ' !important; }';
820 }
821 if ( !empty( $new_btn_colors['hover_color'] ) ) {
822 $output_css .= '.wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-content > .ab-item:hover .ab-label, .wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-content .ab-item:hover .ab-icon:before{ color:' . esc_attr( $new_btn_colors['hover_color'] ) . ' !important; }';
823 }
824 if ( !empty( $new_btn_colors['bg_color'] ) ) {
825 $output_css .= '.wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-content > .ab-item, .wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-content:hover > .ab-item { background:' . esc_attr( $new_btn_colors['bg_color'] ) . ' !important;}';
826 }
827 // "New" Button Hover Colors
828 $new_btn_dropwon = ( !empty( $this->options['admin_bar_link_dropdown_color'] ) ? $this->options['admin_bar_link_dropdown_color'] : '' );
829 if ( !empty( $new_btn_dropwon['wrapper_bg'] ) ) {
830 $output_css .= '.wp-adminify #wpadminbar .ab-top-menu .ab-sub-wrapper, .wp-adminify #wpadminbar .ab-top-menu .ab-sub-wrapper .ab-submenu, .wp-adminify #wpadminbar .ab-top-menu .ab-sub-wrapper .ab-submenu .ab-item { background-color:' . esc_attr( $new_btn_dropwon['wrapper_bg'] ) . ' !important;}';
831 }
832 if ( !empty( $new_btn_dropwon['bg_color'] ) ) {
833 $output_css .= '.wp-adminify #wpadminbar .ab-top-menu .ab-sub-wrapper .ab-submenu .ab-item:hover { background-color:' . esc_attr( $new_btn_dropwon['bg_color'] ) . ' !important;}';
834 }
835 if ( !empty( $new_btn_dropwon['link_color'] ) ) {
836 $output_css .= '.wp-adminify #wpadminbar .ab-top-menu .ab-sub-wrapper .ab-submenu .ab-item { color:' . esc_attr( $new_btn_dropwon['link_color'] ) . ' !important }';
837 }
838 if ( !empty( $new_btn_dropwon['hover_color'] ) ) {
839 $output_css .= '.wp-adminify #wpadminbar .ab-top-menu .ab-sub-wrapper .ab-submenu .ab-item:hover { color:' . esc_attr( $new_btn_dropwon['hover_color'] ) . ' !important }';
840 }
841 // Text Color
842 if ( !empty( $this->options['admin_bar_text_color'] ) ) {
843 $output_css .= '.adminify-top_bar nav.navbar .navbar-brand .navbar-item .wp-adminify-site-name, .adminify-top_bar nav.navbar .navbar-menu .wp-adminify-user-site-list button { color:' . esc_attr( $this->options['admin_bar_text_color'] ) . ' }';
844 $output_css .= '.wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-post > .ab-item { color:' . esc_attr( $this->options['admin_bar_text_color'] ) . ' ; }';
845 $output_css .= '.wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-post > .ab-item .ab-icon:before { color:' . esc_attr( $this->options['admin_bar_text_color'] ) . ' ; }';
846 $output_css .= '.wp-adminify #wpadminbar #wp-admin-bar-root-default #wp-admin-bar-new-post > .ab-item .ab-label { color:' . esc_attr( $this->options['admin_bar_text_color'] ) . ' ; }';
847 }
848 // Icon Color
849 if ( !empty( $this->options['admin_bar_icon_color'] ) ) {
850 $output_css .= '.adminify-top_bar nav.navbar .navbar-menu .topbar-icon svg path { fill:' . esc_attr( $this->options['admin_bar_icon_color'] ) . ' }';
851 $output_css .= '.adminify-top_bar nav.navbar .navbar-end i, .adminify-top_bar nav.navbar .navbar-burger i { color:' . esc_attr( $this->options['admin_bar_icon_color'] ) . ' }';
852 }
853 $output_css .= '.wp-adminify .editor-document-tools__left button.editor-document-tools__inserter-toggle {
854 padding: 0 !important;
855 border: 2px solid var(--adminify-btn-bg) !important;
856 }';
857 $output_css .= ' </style>';
858 // echo Utils::wp_kses_custom($output_css);
859 echo $output_css;
860 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Inline CSS for <style> block; escaping would break the output.
861 }
862
863 // Admin Bar Body Class
864 public function admin_bar_body_class( $classes ) {
865 if ( is_admin() ) {
866 $classes .= ' wp-adminify-admin-bar';
867 $admin_bar_position = ( !empty( $this->options['admin_bar_position'] ) ? $this->options['admin_bar_position'] : 'top' );
868 if ( $admin_bar_position === 'top' ) {
869 $classes .= ' position-top';
870 } elseif ( $admin_bar_position === 'bottom' ) {
871 $classes .= ' position-bottom';
872 }
873 if ( !empty( $this->options['enable_admin_bar'] ) ) {
874 $classes .= ' topbar-disabled';
875 }
876 } else {
877 global $pagenow;
878 if ( !is_user_logged_in() && $pagenow != 'wp-login.php' ) {
879 return $classes;
880 }
881 $classes[] = 'wp-adminify-admin-bar';
882 $admin_bar_position = ( !empty( $this->options['admin_bar_position'] ) ? $this->options['admin_bar_position'] : 'top' );
883 if ( $admin_bar_position === 'top' ) {
884 $classes[] = 'admin-bar-position-top';
885 } elseif ( $admin_bar_position === 'bottom' ) {
886 $classes[] = 'admin-bar-position-bottom';
887 }
888 if ( !empty( $this->options['enable_admin_bar'] ) ) {
889 $classes[] = 'topbar-disabled';
890 }
891 }
892 return $classes;
893 }
894
895 public function get_post_types() {
896 if ( is_array( $this->post_types ) ) {
897 return $this->post_types;
898 } else {
899 $args = [
900 'public' => true,
901 ];
902 $output = 'objects';
903 $post_types = get_post_types( $args, $output );
904 $this->post_types = $post_types;
905 return $post_types;
906 }
907 }
908
909 public function jltwp_adminify_legacy_admin_bar_positon() {
910 if ( !empty( $this->options['admin_bar_position'] ) && $this->options['admin_bar_position'] == 'bottom' ) {
911 $jltwp_adminify_thirdparty_css = '';
912 $jltwp_adminify_thirdparty_css .= 'body.wp-adminify.position-bottom {
913 margin-top: -28px;
914 padding-bottom: 28px;
915 }
916
917 body.wp-adminify.position-bottom.admin-bar #wphead {
918 padding-top: 0;
919 }
920
921 body.wp-adminify.position-bottom.admin-bar #footer {
922 padding-bottom: 28px;
923 }
924
925 body.wp-adminify.position-bottom #wpadminbar {
926 top: auto !important;
927 bottom: 0;
928 }
929
930 body.wp-adminify.position-bottom #wpadminbar .quicklinks .ab-top-menu .menupop .ab-sub-wrapper {
931 bottom: 32px;
932 }
933
934 body.wp-adminify.position-bottom #wpadminbar .quicklinks .ab-top-menu .menupop .ab-sub-wrapper .ab-submenu .menupop .ab-sub-wrapper {
935 bottom: -9px;
936 }';
937 echo '<style>' . esc_html( wp_strip_all_tags( $jltwp_adminify_thirdparty_css ) ) . '</style>';
938 }
939 }
940
941 public function jltwp_adminify_add_admin_bar() {
942 // For Testing Admin Bar on Setup Wizard
943 // add_action('admin_head', [$this, 'jltwp_adminify_render_admin_bar']);
944 add_action( 'in_admin_header', [$this, 'jltwp_adminify_render_admin_bar'], -999999999 );
945 // on frontend area
946 add_action( 'wp_head', [$this, 'jltwp_adminify_render_admin_bar'] );
947 }
948
949 public function jltwp_adminify_render_admin_bar() {
950 global $pagenow;
951 if ( !is_user_logged_in() && $pagenow != 'wp-login.php' ) {
952 return;
953 }
954 // Check Gutenberg Editor Page
955 // if (Utils::is_block_editor_page()) {
956 // return;
957 // }
958 // if (!is_admin_bar_showing()) {
959 // return false;
960 // }
961 // Remove Adminbar from Gutenberg Block Editor Page
962 // if (function_exists('is_gutenberg_page') && is_gutenberg_page()) {
963 // // The Gutenberg plugin is on.
964 // return;
965 // }
966 // if (function_exists('get_current_screen')) {
967 // $current_screen = get_current_screen();
968 // if (!empty($current_screen->is_block_editor)) {
969 // return;
970 // }
971 // }
972 global $wp_admin_bar;
973 if ( empty( $wp_admin_bar ) ) {
974 return false;
975 }
976 $admin_bar_mode = ( empty( $admin_bar_mode['light_dark_mode']['admin_ui_mode'] ) ? 'light' : $admin_bar_mode['light_dark_mode']['admin_ui_mode'] );
977 // Light/Dark Mode
978 $enable_dark_mode = $admin_bar_mode != 'light';
979 // Screen Option && Hide WP Links
980 $enable_screen_tab = Utils::get_user_preference( 'screen_options_tab' );
981 $enable_help_tab = Utils::get_user_preference( 'adminify_help_tab' );
982 // $enable_hide_wp_links = Utils::get_user_preference( 'hide_wp_links' );
983 // Admin Bar Position
984 if ( !empty( $this->options['admin_bar_position'] ) && $this->options['admin_bar_position'] === 'top' ) {
985 $admin_bar_position = 'top_bar';
986 } elseif ( !empty( $this->options['admin_bar_position'] ) && $this->options['admin_bar_position'] === 'bottom' ) {
987 $admin_bar_position = 'bottom_bar is-fixed-bottom';
988 } else {
989 $admin_bar_position = 'top_bar';
990 }
991 $current_user = wp_get_current_user();
992 ob_start();
993 // Temporarily removing Topbar
994 // <div class="wp-adminify-topbar-loader"></div>
995 // 17-7-23, removed opacity for Conflicting Opacity Issue
996 // <div class="wp-adminify adminify-top_bar" style="opacity: 0;">
997 ?>
998
999
1000
1001 <div class="wp-adminify adminify-top_bar">
1002 <nav class="navbar adminify-top-navbar <?php
1003 echo esc_attr( $admin_bar_position );
1004 ?>">
1005
1006 <?php
1007 $this->jltwp_adminify_logo();
1008 ?>
1009 <div class="adminify-admin-wrapper">
1010 <div class="adminify-legacy-admin">
1011 <div class="adminify-hamburger navbar-burger" data-target="wp-adminify-top-adminbar">
1012 <svg width="11" height="8" viewBox="0 0 11 8" fill="none" xmlns="http://www.w3.org/2000/svg">
1013 <path d="M7 0H0V1H7V0Z" fill="#48455F" />
1014 <path d="M7 7H0V8H7V7Z" fill="#48455F" />
1015 <path d="M4.67 3.5H0V4.5H4.67V3.5Z" fill="#48455F" />
1016 <path d="M9.65 7.35L6.29 4L9.65 0.65L10.35 1.35L7.71 4L10.35 6.65L9.65 7.35Z" fill="#48455F" />
1017 </svg>
1018 </div>
1019 <?php
1020 wp_admin_bar_render();
1021 ?>
1022 </div>
1023
1024 <div id="wp-adminify-top-adminbar" class="navbar-menu">
1025
1026 <div class="navbar-end">
1027 <div class="field is-grouped">
1028
1029 <?php
1030 echo wp_kses_post( $this->jltwp_adminify_dark_mode_switcher_dom() );
1031 ?>
1032
1033 <?php
1034 if ( !empty( $this->options['admin_bar_notif'] ) ) {
1035 ?>
1036 <div class="wp-adminify--top--comment">
1037 <button class="comment-trigger is-clickable">
1038 <div class="topbar-icon">
1039 <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
1040 <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="var(--adminify-menu-text-color)" />
1041 </svg>
1042 </div>
1043 <span class="comment-counter">
1044 <?php
1045 $comments_count = wp_count_comments();
1046 echo esc_html( $comments_count->moderated );
1047 ?>
1048 </span>
1049 </button>
1050 </div>
1051
1052 <?php
1053 }
1054 ?>
1055
1056 <div class="wp-adminify--preview">
1057 <a class="preview-trigger is-clickable" href="<?php
1058 echo esc_url( get_home_url() );
1059 ?>" target="_blank">
1060 <i class="dashicons dashicons-visibility"></i>
1061 </a>
1062 </div>
1063
1064 <div class="wp-adminify--user--account">
1065 <button class="user-avatar is-clickable">
1066 <div class="image is-45x45">
1067 <?php
1068 echo get_avatar(
1069 $current_user->user_email,
1070 45,
1071 '',
1072 '',
1073 [
1074 'class' => 'is-rounded',
1075 ]
1076 );
1077 ?>
1078 </div>
1079 <span class="user-status tag p-0 is-rounded"></span>
1080 </button>
1081
1082 <?php
1083 if ( !empty( $this->adminify_ui ) ) {
1084 ?>
1085 <div class="wp-adminify--user--wrapper">
1086 <div class="wp-adminify-user-info">
1087 <h3 class="wp-adminify-user-name">
1088 <?php
1089 echo esc_html( $current_user->display_name );
1090 ?>
1091 </h3>
1092 <span><?php
1093 echo wp_kses_post( is_email( $current_user->user_email ) );
1094 ?></span>
1095
1096 <ul>
1097 <hr>
1098 <li>
1099 <a href="<?php
1100 echo esc_url( admin_url( 'profile.php' ) );
1101 ?>">
1102 <svg class="wp-adminify-profile-icon" width="16" height="18" viewBox="0 0 16 18" fill="none" xmlns="http://www.w3.org/2000/svg">
1103 <path d="M14.6654 16.5C14.6654 15.337 14.6654 14.7555 14.5218 14.2824C14.1987 13.217 13.365 12.3834 12.2996 12.0602C11.8265 11.9167 11.245 11.9167 10.082 11.9167H5.91537C4.7524 11.9167 4.17091 11.9167 3.69775 12.0602C2.63241 12.3834 1.79873 13.217 1.47556 14.2824C1.33203 14.7555 1.33203 15.337 1.33203 16.5M11.7487 5.25C11.7487 7.32107 10.0698 9 7.9987 9C5.92763 9 4.2487 7.32107 4.2487 5.25C4.2487 3.17893 5.92763 1.5 7.9987 1.5C10.0698 1.5 11.7487 3.17893 11.7487 5.25Z" stroke="var(--adminify-primary)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
1104 </svg>
1105 <span><?php
1106 esc_html_e( 'View Profile', 'adminify' );
1107 ?></span>
1108 </a>
1109 </li>
1110 <hr>
1111 <li>
1112 <a href="<?php
1113 echo esc_url( wp_logout_url( home_url() ) );
1114 ?>" class="wp-adminify-logout">
1115 <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
1116 <path fill-rule="evenodd" clip-rule="evenodd" d="M5.7587 4.31292e-07L7 9.08129e-07C7.55229 9.08129e-07 8 0.447716 8 1C8 1.55229 7.55229 2 7 2H5.8C4.94342 2 4.36113 2.00078 3.91104 2.03755C3.47262 2.07337 3.24842 2.1383 3.09202 2.21799C2.7157 2.40973 2.40974 2.7157 2.21799 3.09202C2.1383 3.24842 2.07337 3.47262 2.03755 3.91104C2.00078 4.36113 2 4.94342 2 5.8V14.2C2 15.0566 2.00078 15.6389 2.03755 16.089C2.07337 16.5274 2.1383 16.7516 2.21799 16.908C2.40973 17.2843 2.7157 17.5903 3.09202 17.782C3.24842 17.8617 3.47262 17.9266 3.91104 17.9624C4.36113 17.9992 4.94342 18 5.8 18H7C7.55229 18 8 18.4477 8 19C8 19.5523 7.55229 20 7 20H5.75868C4.95372 20 4.28937 20 3.74818 19.9558C3.18608 19.9099 2.66937 19.8113 2.18404 19.564C1.43139 19.1805 0.819468 18.5686 0.435975 17.816C0.188684 17.3306 0.0901197 16.8139 0.0441946 16.2518C-2.28137e-05 15.7106 -1.23241e-05 15.0463 4.31291e-07 14.2413V5.7587C-1.23241e-05 4.95373 -2.28137e-05 4.28937 0.0441947 3.74817C0.09012 3.18608 0.188685 2.66937 0.435976 2.18404C0.81947 1.43139 1.43139 0.819468 2.18404 0.435975C2.66938 0.188684 3.18608 0.0901197 3.74818 0.0441945C4.28937 -2.28137e-05 4.95373 -1.23241e-05 5.7587 4.31292e-07ZM13.2929 4.29289C13.6834 3.90237 14.3166 3.90237 14.7071 4.29289L19.7071 9.29289C20.0976 9.68342 20.0976 10.3166 19.7071 10.7071L14.7071 15.7071C14.3166 16.0976 13.6834 16.0976 13.2929 15.7071C12.9024 15.3166 12.9024 14.6834 13.2929 14.2929L16.5858 11H7C6.44772 11 6 10.5523 6 10C6 9.44772 6.44772 9 7 9H16.5858L13.2929 5.70711C12.9024 5.31658 12.9024 4.68342 13.2929 4.29289Z" fill="var(--adminify-primary)"></path>
1117 </svg>
1118 <span><?php
1119 echo esc_html__( 'Log Out', 'adminify' );
1120 ?></span>
1121 </a>
1122 </li>
1123 </ul>
1124 </div>
1125 </div>
1126 <?php
1127 }
1128 ?>
1129 </div>
1130 </div>
1131 </div>
1132 </div>
1133 </div>
1134 </nav>
1135 </div>
1136
1137 <?php
1138 $output_wp_admin_bar = ob_get_clean();
1139 // echo Utils::wp_kses_custom($output_wp_admin_bar);
1140 echo $output_wp_admin_bar;
1141 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Buffered admin bar markup (includes inline SVG/<style>); wp_kses_post would strip required tags.
1142 }
1143
1144 public function jltwp_adminify_logo() {
1145 global $wp_admin_bar;
1146 $adminurl = get_admin_url();
1147 $homeurl = $adminurl;
1148 // Light Logo
1149 // menu_layout_settings.layout_type / .menu_mode were read here
1150 // previously but the resulting locals were never used
1151 // downstream. Removed because layout_type === 'horizontal' is
1152 // a Pro-only feature whose handler now lives in
1153 // Pro/Classes/OutputCSS_Body_Pro.php.
1154 $admin_ui_logo_type = ( !empty( $this->options['light_dark_mode']['admin_ui_logo_type'] ) ? $this->options['light_dark_mode']['admin_ui_logo_type'] : 'image_logo' );
1155 $light_mode = ( !empty( $this->options['light_dark_mode']['admin_ui_light_mode'] ) ? $this->options['light_dark_mode']['admin_ui_light_mode'] : '' );
1156 $light_logo = '';
1157 $light_mini_logo = '';
1158 if ( $admin_ui_logo_type == 'image_logo' ) {
1159 if ( isset( $light_mode['mini_admin_ui_light_logo']['url'] ) && $light_mode['mini_admin_ui_light_logo']['url'] ) {
1160 $light_mini_logo = $light_mode['mini_admin_ui_light_logo']['url'];
1161 } else {
1162 $light_mini_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/mini-logo-light.svg';
1163 }
1164 // Logo Image
1165 if ( !empty( $light_mode['admin_ui_light_logo']['url'] ) ) {
1166 $light_logo = $light_mode['admin_ui_light_logo']['url'];
1167 } else {
1168 $light_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/logo-text-light.svg';
1169 }
1170 } elseif ( $admin_ui_logo_type == 'text_logo' ) {
1171 // Text Logo
1172 if ( $this->options['light_dark_mode']['admin_ui_mode'] == 'light' ) {
1173 $text_logo = $light_mode['admin_ui_light_logo_text'];
1174 }
1175 }
1176 // Logo Size
1177 $light_width = ( !empty( $light_mode['light_logo_size']['width'] ) ? $light_mode['light_logo_size']['width'] : '120' );
1178 $light_height = ( !empty( $light_mode['light_logo_size']['height'] ) ? $light_mode['light_logo_size']['height'] : '32' );
1179 // Dark Logo
1180 $dark_mode = ( !empty( $this->options['light_dark_mode']['admin_ui_dark_mode'] ) ? $this->options['light_dark_mode']['admin_ui_dark_mode'] : '' );
1181 $dark_logo = '';
1182 $dark_mini_logo = '';
1183 if ( $admin_ui_logo_type == 'image_logo' ) {
1184 if ( isset( $dark_mode['mini_admin_ui_dark_logo']['url'] ) && $dark_mode['mini_admin_ui_dark_logo']['url'] ) {
1185 $dark_mini_logo = $dark_mode['mini_admin_ui_dark_logo']['url'];
1186 } else {
1187 $dark_mini_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/mini-logo-dark.svg';
1188 }
1189 // Dark Logo Image
1190 if ( isset( $dark_mode['admin_ui_dark_logo']['url'] ) && $dark_mode['admin_ui_dark_logo']['url'] ) {
1191 $dark_logo = $dark_mode['admin_ui_dark_logo']['url'];
1192 } else {
1193 $dark_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/logo-text-dark.svg';
1194 }
1195 } elseif ( $admin_ui_logo_type == 'text_logo' ) {
1196 // Text Logo
1197 if ( $this->options['light_dark_mode']['admin_ui_mode'] == 'dark' ) {
1198 $text_logo = $dark_mode['admin_ui_dark_logo_text'];
1199 }
1200 }
1201 // Dark Logo Size
1202 $dark_width = ( !empty( $dark_mode['dark_logo_size']['width'] ) ? $dark_mode['dark_logo_size']['width'] : '120' );
1203 $dark_height = ( !empty( $dark_mode['dark_logo_size']['height'] ) ? $dark_mode['dark_logo_size']['height'] : '32' );
1204 ?>
1205
1206 <div class="navbar-brand">
1207 <a class="navbar-item p-0" href="<?php
1208 echo esc_url( $homeurl );
1209 ?>">
1210 <?php
1211 if ( $admin_ui_logo_type == 'image_logo' ) {
1212 ?>
1213 <!-- Light Logo -->
1214 <img alt="<?php
1215 echo esc_attr( get_bloginfo( 'name' ) );
1216 ?>" class="logo-light" src="<?php
1217 echo esc_url( $light_logo );
1218 ?>" width="<?php
1219 echo esc_attr( $light_width );
1220 ?>" height="<?php
1221 echo esc_attr( $light_height );
1222 ?>">
1223 <img alt="<?php
1224 echo esc_attr( get_bloginfo( 'name' ) );
1225 ?>" class="mini-logo-light" src="<?php
1226 echo esc_url( $light_mini_logo );
1227 ?>" width="36" height="36">
1228 <!-- Dark Logo -->
1229 <img alt="<?php
1230 echo esc_attr( get_bloginfo( 'name' ) );
1231 ?>" class="logo-dark" src="<?php
1232 echo esc_url( $dark_logo );
1233 ?>" width="<?php
1234 echo esc_attr( $dark_width );
1235 ?>" height="<?php
1236 echo esc_attr( $dark_height );
1237 ?>">
1238 <img alt="<?php
1239 echo esc_attr( get_bloginfo( 'name' ) );
1240 ?>" class="mini-logo-dark" src="<?php
1241 echo esc_url( $dark_mini_logo );
1242 ?>" width="36" height="36">
1243 <?php
1244 } elseif ( $admin_ui_logo_type == 'text_logo' ) {
1245 ?>
1246 <span class="wp-adminify-site-name">
1247 <?php
1248 echo esc_html( $text_logo );
1249 ?>
1250 </span>
1251 <?php
1252 }
1253 ?>
1254 </a>
1255
1256 <!-- <div class="navbar-burger" data-target="wp-adminify-top-adminbar">
1257 <img src="<?php
1258 // echo WP_ADMINIFY_ASSETS_IMAGE . 'icons/toggol.svg';
1259 ?>" alt="Toggol icon"/>
1260 </div> -->
1261
1262 </div>
1263
1264 <?php
1265 }
1266
1267 /* Remove from the administration bar */
1268 public function jltma_adminify_remove_admin_bar_menus() {
1269 global $wp_admin_bar;
1270 $wp_admin_bar->remove_menu( 'wp-logo' );
1271 $wp_admin_bar->remove_menu( 'site-name' );
1272 $wp_admin_bar->remove_menu( 'updates' );
1273 $wp_admin_bar->remove_menu( 'menu-toggle' );
1274 }
1275
1276 }
1277