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