options = (array) AdminSettings::get_instance()->get(); $this->adminify_ui = $this->options['admin_ui']; $global_ui_mode = ( empty( $this->options['light_dark_mode']['admin_ui_mode'] ) ? 'light' : $this->options['light_dark_mode']['admin_ui_mode'] ); $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 ) ); if ( $current_ui_mode === 'dark' ) { new DarkModeConflicts(); } // $admin_bar_user_roles = !empty($this->options['admin_bar_user_roles']) ? $this->options['admin_bar_user_roles'] : ''; // if (Utils::restricted_for($admin_bar_user_roles)) { // return; // } // Disable the default admin bar // add_filter('show_admin_bar', '__return_false'); // Add admin-bar support if not already activated // add_theme_support('admin-bar', ['callback' => '__return_false']); // 05-06-2024 // Check Adminify Setup Wizard Page if ( !empty( $_GET['page'] ) && 'wp-adminify-setup-wizard' == $_GET['page'] ) { return; } $this->initialize(); // if (!empty($this->adminify_ui) && !empty($this->options['admin_bar_search'] )) { // add_action('wp_admin_bar_class', [$this, 'load_wp_admin_bar_class']); // add_action('adminify/before/secondary_menu', [$this, 'before_secondary_menu']); // } if ( is_admin() ) { // Switcher for Default UI if ( empty( $this->adminify_ui ) ) { if ( !empty( $this->options['admin_bar_dark_light_btn'] ) ) { add_action( 'admin_bar_menu', [$this, 'jltwp_adminify_dark_mode_switcher_icon'] ); } } } } // Add Switcher Icon on Admin Bar Secondary public function jltwp_adminify_dark_mode_switcher_icon( $wp_admin_bar ) { $args = [ 'parent' => 'top-secondary', 'id' => 'wp-adminify-admin-bar-switcher', 'title' => $this->jltwp_adminify_dark_mode_switcher_dom(), 'meta' => false, ]; $wp_admin_bar->add_node( $args ); } public function jltwp_adminify_dark_mode_switcher_dom() { $global_color_mode = ( !empty( $this->options['light_dark_mode']['admin_ui_mode'] ) ? $this->options['light_dark_mode']['admin_ui_mode'] : 'light' ); $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 ) ); $color_var = ( !empty( $this->adminify_ui ) ? 'var(--adminify-menu-text-color)' : '#fff' ); $adminbar_switcher_icon = '
Light
Dark
System
'; return $adminbar_switcher_icon; } public function initialize() { $admin_bar_position = ( !empty( $this->options['admin_bar_position'] ) ? $this->options['admin_bar_position'] : 'top' ); if ( is_admin() ) { if ( $admin_bar_position == 'top' || $admin_bar_position == 'bottom' ) { if ( !empty( $this->adminify_ui ) ) { //TODO: not need to adminify ui. alternative use iframe topbar // add_action('admin_init', [$this, 'jltwp_adminify_add_admin_bar']); // } else { add_action( 'admin_head', [$this, 'jltwp_adminify_legacy_admin_bar_positon'] ); } } add_action( 'admin_enqueue_scripts', [$this, 'jltwp_adminify_admin_scripts'], 100 ); // Remove Unnecessary Menus from Admin bar // add_action('wp_before_admin_bar_render', [$this, 'jltma_adminify_remove_admin_bar_menus'], 0); // add_filter('admin_body_class', [$this, 'admin_bar_body_class']); // add_action('admin_head', [$this, 'jltwp_adminify_admin_bar_css'], 999); add_action( 'wp_ajax_adminify_all_search', [$this, 'adminify_all_search'] ); add_action( 'wp_ajax_wp_adminify_color_mode', [$this, 'wp_adminify_color_mode'] ); // Screen Option and Help Tab add_action( 'admin_head', [$this, 'jltwp_adminify_remove_screen_options'], 10, 3 ); add_action( 'admin_head', [$this, 'jltwp_adminify_remove_help_tab'] ); } else { // Admin bar Frontend settings $frontend_admin = ( !empty( $this->options['admin_bar_hide_frontend'] ) ? $this->options['admin_bar_hide_frontend'] : 'show' ); // if (jltwp_adminify()->can_use_premium_code__premium_only()) { // if ($frontend_admin == 'show') { // $frontend_admin_roles = (!empty($this->options['admin_bar_hide_frontend_user_roles'])) ? $this->options['admin_bar_hide_frontend_user_roles'] : []; // if (Utils::restricted_for($frontend_admin_roles)) { // $frontend_admin = 'hide'; // } // } // } $this->jltwp_adminify_front_bar(); if ( $admin_bar_position == 'bottom' ) { add_action( 'init', [$this, 'admin_bar_front_style_init'] ); } if ( $frontend_admin == 'hide' ) { add_filter( 'show_admin_bar', '__return_false' ); } } } public function before_secondary_menu() { ?>
remove_help_tabs(); } } // Get All registered WP Admin Menus public static function get_wp_admin_menus( $thismenu, $thissubmenu ) { $options = []; if ( !empty( $thismenu ) && is_array( $thismenu ) ) { foreach ( $thismenu as $item ) { if ( !empty( $item[0] ) ) { // the preg_replace removes "Comments" & "Plugins" menu spans. $options[$item[2]] = preg_replace( '/\\.*?\\<\\/span><\\/span>/s', '', $item[0] ); } } } if ( !empty( $thissubmenu ) && is_array( $thissubmenu ) ) { foreach ( $thissubmenu as $items ) { foreach ( $items as $item ) { if ( !empty( $item[0] ) ) { $options[$item[1]] = preg_replace( '/\\.*?\\<\\/span><\\/span>/s', '', $item[0] ); } } } } return $options; } public function jltwp_adminify_admin_scripts() { global $pagenow; if ( $pagenow == 'wp-login.php' || $pagenow == 'wp-register.php' || $pagenow == 'customize.php' ) { return; } // Commented on: 9-6-24 if ( !empty( $this->adminify_ui ) ) { wp_enqueue_style( 'wp-adminify-admin-bar' ); $this->admin_topbar_loader_css(); } wp_localize_script( 'wp-adminify-admin', 'WPAdminify', $this->adminify_create_admin_bar_js_object() ); } public function adminify_create_admin_bar_js_object() { return [ 'ajax_url' => admin_url( 'admin-ajax.php' ), 'security_nonce' => wp_create_nonce( 'adminify-admin-bar-security-nonce' ), 'notice_nonce' => wp_create_nonce( 'adminify-notice-nonce' ), ]; } /** * Preloader * * @return void */ public function admin_topbar_loader_css() { $output_css = ''; $topbar_wireframe_img = WP_ADMINIFY_ASSETS_IMAGE . 'topbar-wireframe.svg'; $output_css .= '.js .wp-adminify-topbar-loader{background: url(' . esc_url( $topbar_wireframe_img ) . '); }'; // Use wp_add_inline_style instead of echo to prevent "headers already sent" errors wp_add_inline_style( 'wp-adminify-admin-bar', wp_strip_all_tags( $output_css ) ); $screen = get_current_screen(); // Get current screen details if ( isset( $screen->base ) && $screen->base === 'post' ) { $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});"; wp_add_inline_script( 'wp-adminify-admin', $inline_script ); } } /** * Save Color Mode by Ajax * * @return void */ public function wp_adminify_color_mode() { if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'adminify-admin-bar-security-nonce', 'security' ) > 0 ) { $admin_bar_mode = AdminSettings::get_instance()->get(); if ( !empty( $_POST['key'] ) ) { $key = sanitize_key( $_POST['key'] ); $value = Utils::clean_ajax_input( wp_unslash( $_POST['value'] ) ); if ( $key == '' ) { $message = __( 'No Color Mode supplied to save', 'adminify' ); echo Utils::ajax_error_message( $message ); die; } } // Light/Dark Mode if ( $key === 'color_mode' ) { // For User preference $userid = get_current_user_id(); $current = get_user_meta( $userid, $key, true ); if ( $current !== $value ) { $state = update_user_meta( $userid, $key, $value ); } die; $admin_bar_mode['light_dark_mode']['admin_ui_mode'] = $value; $this->options['schedule_dark_mode']['enable_schedule_dark_mode'] = false; if ( $value == 'system' ) { $admin_bar_mode['schedule_dark_mode']['enable_schedule_dark_mode'] = true; $admin_bar_mode['schedule_dark_mode']['schedule_dark_mode_type'] = 'system'; } update_option( '_wpadminify', $admin_bar_mode ); die; } // Screen Options, Help Tabs and WP Hide Links if ( $key === 'screen_options_tab' || $key === 'hide_wp_links' || $key === 'adminify_help_tab' ) { $userid = get_current_user_id(); $current = get_user_meta( $userid, '_wpadminify_preferences', true ); if ( is_array( $current ) ) { $current[$key] = $value; } else { $current = []; $current[$key] = $value; } $state = update_user_meta( $userid, '_wpadminify_preferences', $current ); if ( $state ) { $returndata = []; $returndata['success'] = true; $returndata['message'] = __( 'Preferences saved', 'adminify' ); echo json_encode( $returndata ); } else { $message = __( 'Unable to save user preferences', 'adminify' ); echo Utils::ajax_error_message( $message ); die; } } } } /** * Search Everything * * @return void */ public function adminify_all_search() { if ( defined( 'DOING_AJAX' ) && DOING_AJAX && check_ajax_referer( 'adminify-admin-bar-security-nonce', 'security' ) > 0 ) { // Security check - only users who can edit posts should access admin search if ( !current_user_can( 'edit_posts' ) ) { wp_send_json_error( array( 'message' => __( 'You do not have permission to perform this action.', 'adminify' ), ) ); } $search_text = ''; if ( !empty( $_POST['search'] ) ) { $search_text = sanitize_text_field( wp_unslash( $_POST['search'] ) ); } // Error Handling For Minimum 3 Char if ( strlen( $search_text ) < 3 ) { wp_send_json_success( [ 'message' => 'Please Enter Minimum 3 Characters', ] ); } // Search Arguments $args = [ 'numberposts' => -1, 's' => $search_text, 'post_status' => [ 'publish', 'pending', 'draft', 'future', 'private', 'inherit' ], ]; // All Post Types $post_types = $this->get_post_types(); foreach ( $post_types as $type ) { $args['post_type'][] = $type->name; } // All Categories/Taxonomies $all_taxonomies = get_taxonomies(); // Get Comments $all_comments = get_comments(); // Get All Users $all_users = get_users(); // All Users // $blogusers = get_users(); // foreach ($blogusers as $type) { // $name = $type->user_login; // $id = $type->ID; // $args['author__in'][] = $type->ID; // } // // All Menus // $all_admin_menus = self::get_wp_admin_menus(); // All Plugins if ( !function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $all_plugins = get_plugins(); $foundposts = get_posts( $args ); // $count_items = ''; // if (count($foundposts) > 0) { // $count_items .= count($foundposts); // } elseif (count($all_plugins)) { // $count_items .= count($all_plugins); // } $output_data = [ 'foundposts' => $this->set_edit_url_foundposts( $foundposts ), 'all_taxonomies' => $this->filter_all_taxonomies( $all_taxonomies, $search_text ), 'all_comments' => $this->filter_all_comments( $all_comments, $search_text ), 'all_users' => $this->filter_all_users( $all_users, $search_text ), 'all_plugins' => $this->filter_all_plugins( $all_plugins, $search_text ), ]; wp_send_json_success( [ 'data' => json_encode( $output_data ), ] ); return; ob_start(); ?>

s found' ); ?>

post_author; $editurl = get_edit_post_link( $item ); $public = get_permalink( $item ); ?> $tax_name, 'hide_empty' => 1, ] ); foreach ( $terms as $cat ) { if ( strpos( strtolower( $cat->name ), strtolower( $term ) ) === false ) { continue; } // $user = get_userdata($cat->term_id); ?> comment_content ), strtolower( $term ) ) === false ) { continue; } ?> user_login ), strtolower( $term ) ) === false ) { continue; } ?>
name ); ?> taxonomy ); ?>
comment_content ); ?> comment_type ) ); ?> user_id ) ); ?> comment_date ) ); ?>
display_name ); ?> comment_type ) ); ?> user_id ) ); ?> user_registered ) ); ?>
$foundposts, // 'all_taxonomies' => $all_taxonomies, // 'all_comments' => $all_comments, // 'all_users' => $all_users, // 'all_plugins' => $all_plugins, // ]; // echo json_encode($output_data); echo json_encode( $foundposts ); wp_send_json_success( [ 'data' => $foundposts, ] ); } die; } /** * Set URL to All Post */ public function set_edit_url_foundposts( $foundposts ) { $all_posts = []; foreach ( $foundposts as $key => $post ) { $edit_url = get_edit_post_link( $post ); $all_posts[$key]['title'] = get_the_title( $post->ID ); $all_posts[$key]['link'] = $edit_url; } return $all_posts; } /** * Search Taxonomies */ public function filter_all_taxonomies( $all_taxonomies, $search_text ) { $find_taxonomies = []; foreach ( $all_taxonomies as $tax_name ) { $terms = get_terms( [ 'taxonomy' => $tax_name, 'hide_empty' => 1, ] ); foreach ( $terms as $key => $cat ) { if ( strpos( strtolower( $cat->name ), strtolower( $search_text ) ) === false ) { continue; } $find_taxonomies[$key]['name'] = $cat->name; $find_taxonomies[$key]['link'] = get_edit_term_link( $cat ); } } return $find_taxonomies; } /** * Search Comments */ public function filter_all_comments( $all_comments, $search_text ) { $find_comments = []; foreach ( $all_comments as $key => $comment ) { if ( strpos( strtolower( $comment->comment_content ), strtolower( $search_text ) ) === false ) { continue; } $find_comments[$key]['content'] = $comment->comment_content; $find_comments[$key]['link'] = admin_url( 'comment.php?action=editcomment&c=' . esc_attr( $comment->comment_ID ) ); } return $find_comments; } /** * Search Users */ public function filter_all_users( $all_users, $search_text ) { $find_users = []; foreach ( $all_users as $key => $user ) { if ( str_contains( strtolower( $user->data->user_login ), strtolower( $search_text ) ) || str_contains( strtolower( $user->data->display_name ), strtolower( $search_text ) ) ) { $find_users[$key]['name'] = $user->data->user_login; $find_users[$key]['display_name'] = $user->data->display_name; $find_users[$key]['link'] = admin_url( 'user-edit.php?user_id=' . $user->ID ); } } return $find_users; } /** * Search Plugins */ public function filter_all_plugins( $all_plugins, $search_text ) { $find_plugins = []; foreach ( $all_plugins as $key => $plugin ) { if ( strpos( strtolower( $plugin['Name'] ), strtolower( $search_text ) ) === false ) { continue; } $find_plugins[] = [ 'name' => $plugin['Name'], 'link' => admin_url( 'plugins.php' ), ]; } return $find_plugins; } public function jltwp_adminify_admin_bar_css() { $current_screen = get_current_screen(); $admin_bar_mode = ( !empty( $admin_bar_mode['light_dark_mode']['admin_ui_mode'] ) ? $admin_bar_mode['light_dark_mode']['admin_ui_mode'] : '' ); $output_css = ''; $output_css .= ''; // echo Utils::wp_kses_custom($output_css); echo $output_css; } // Admin Bar Body Class public function admin_bar_body_class( $classes ) { if ( is_admin() ) { $classes .= ' wp-adminify-admin-bar'; $admin_bar_position = ( !empty( $this->options['admin_bar_position'] ) ? $this->options['admin_bar_position'] : 'top' ); if ( $admin_bar_position === 'top' ) { $classes .= ' position-top'; } elseif ( $admin_bar_position === 'bottom' ) { $classes .= ' position-bottom'; } if ( !empty( $this->options['enable_admin_bar'] ) ) { $classes .= ' topbar-disabled'; } } else { global $pagenow; if ( !is_user_logged_in() && $pagenow != 'wp-login.php' ) { return $classes; } $classes[] = 'wp-adminify-admin-bar'; $admin_bar_position = ( !empty( $this->options['admin_bar_position'] ) ? $this->options['admin_bar_position'] : 'top' ); if ( $admin_bar_position === 'top' ) { $classes[] = 'admin-bar-position-top'; } elseif ( $admin_bar_position === 'bottom' ) { $classes[] = 'admin-bar-position-bottom'; } if ( !empty( $this->options['enable_admin_bar'] ) ) { $classes[] = 'topbar-disabled'; } } return $classes; } public function get_post_types() { if ( is_array( $this->post_types ) ) { return $this->post_types; } else { $args = [ 'public' => true, ]; $output = 'objects'; $post_types = get_post_types( $args, $output ); $this->post_types = $post_types; return $post_types; } } public function jltwp_adminify_legacy_admin_bar_positon() { if ( !empty( $this->options['admin_bar_position'] ) && $this->options['admin_bar_position'] == 'bottom' ) { $jltwp_adminify_thirdparty_css = ''; $jltwp_adminify_thirdparty_css .= 'body.wp-adminify.position-bottom { margin-top: -28px; padding-bottom: 28px; } body.wp-adminify.position-bottom.admin-bar #wphead { padding-top: 0; } body.wp-adminify.position-bottom.admin-bar #footer { padding-bottom: 28px; } body.wp-adminify.position-bottom #wpadminbar { top: auto !important; bottom: 0; } body.wp-adminify.position-bottom #wpadminbar .quicklinks .ab-top-menu .menupop .ab-sub-wrapper { bottom: 32px; } body.wp-adminify.position-bottom #wpadminbar .quicklinks .ab-top-menu .menupop .ab-sub-wrapper .ab-submenu .menupop .ab-sub-wrapper { bottom: -9px; }'; echo ''; } } public function jltwp_adminify_add_admin_bar() { // For Testing Admin Bar on Setup Wizard // add_action('admin_head', [$this, 'jltwp_adminify_render_admin_bar']); add_action( 'in_admin_header', [$this, 'jltwp_adminify_render_admin_bar'], -999999999 ); // on frontend area add_action( 'wp_head', [$this, 'jltwp_adminify_render_admin_bar'] ); } public function jltwp_adminify_render_admin_bar() { global $pagenow; if ( !is_user_logged_in() && $pagenow != 'wp-login.php' ) { return; } // Check Gutenberg Editor Page // if (Utils::is_block_editor_page()) { // return; // } // if (!is_admin_bar_showing()) { // return false; // } // Remove Adminbar from Gutenberg Block Editor Page // if (function_exists('is_gutenberg_page') && is_gutenberg_page()) { // // The Gutenberg plugin is on. // return; // } // if (function_exists('get_current_screen')) { // $current_screen = get_current_screen(); // if (!empty($current_screen->is_block_editor)) { // return; // } // } global $wp_admin_bar; if ( empty( $wp_admin_bar ) ) { return false; } $admin_bar_mode = ( empty( $admin_bar_mode['light_dark_mode']['admin_ui_mode'] ) ? 'light' : $admin_bar_mode['light_dark_mode']['admin_ui_mode'] ); // Light/Dark Mode $enable_dark_mode = $admin_bar_mode != 'light'; // Screen Option && Hide WP Links $enable_screen_tab = Utils::get_user_preference( 'screen_options_tab' ); $enable_help_tab = Utils::get_user_preference( 'adminify_help_tab' ); // $enable_hide_wp_links = Utils::get_user_preference( 'hide_wp_links' ); // Admin Bar Position if ( !empty( $this->options['admin_bar_position'] ) && $this->options['admin_bar_position'] === 'top' ) { $admin_bar_position = 'top_bar'; } elseif ( !empty( $this->options['admin_bar_position'] ) && $this->options['admin_bar_position'] === 'bottom' ) { $admin_bar_position = 'bottom_bar is-fixed-bottom'; } else { $admin_bar_position = 'top_bar'; } $current_user = wp_get_current_user(); ob_start(); // Temporarily removing Topbar //
// 17-7-23, removed opacity for Conflicting Opacity Issue //
?>
options['menu_layout_settings']; // Menu Layouts $menu_layout = ( !empty( $this->options['menu_layout_settings'] ) ? $this->options['menu_layout_settings'] : '' ); $menu_mode = ( !empty( $menu_layout['menu_mode'] ) ? $menu_layout['menu_mode'] : 'classic' ); $menu_layout = ( !empty( $menu_layout['layout_type'] ) ? $menu_layout['layout_type'] : 'vertical' ); $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' ); $light_mode = ( !empty( $this->options['light_dark_mode']['admin_ui_light_mode'] ) ? $this->options['light_dark_mode']['admin_ui_light_mode'] : '' ); $light_logo = ''; $light_mini_logo = ''; if ( $admin_ui_logo_type == 'image_logo' ) { if ( isset( $light_mode['mini_admin_ui_light_logo']['url'] ) && $light_mode['mini_admin_ui_light_logo']['url'] ) { $light_mini_logo = $light_mode['mini_admin_ui_light_logo']['url']; } else { $light_mini_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/mini-logo-light.svg'; } // Logo Image if ( !empty( $light_mode['admin_ui_light_logo']['url'] ) ) { $light_logo = $light_mode['admin_ui_light_logo']['url']; } else { $light_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/logo-text-light.svg'; } } elseif ( $admin_ui_logo_type == 'text_logo' ) { // Text Logo if ( $this->options['light_dark_mode']['admin_ui_mode'] == 'light' ) { $text_logo = $light_mode['admin_ui_light_logo_text']; } } // Logo Size $light_width = ( !empty( $light_mode['light_logo_size']['width'] ) ? $light_mode['light_logo_size']['width'] : '120' ); $light_height = ( !empty( $light_mode['light_logo_size']['height'] ) ? $light_mode['light_logo_size']['height'] : '32' ); // Dark Logo $dark_mode = ( !empty( $this->options['light_dark_mode']['admin_ui_dark_mode'] ) ? $this->options['light_dark_mode']['admin_ui_dark_mode'] : '' ); $dark_logo = ''; $dark_mini_logo = ''; if ( $admin_ui_logo_type == 'image_logo' ) { if ( isset( $dark_mode['mini_admin_ui_dark_logo']['url'] ) && $dark_mode['mini_admin_ui_dark_logo']['url'] ) { $dark_mini_logo = $dark_mode['mini_admin_ui_dark_logo']['url']; } else { $dark_mini_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/mini-logo-dark.svg'; } // Dark Logo Image if ( isset( $dark_mode['admin_ui_dark_logo']['url'] ) && $dark_mode['admin_ui_dark_logo']['url'] ) { $dark_logo = $dark_mode['admin_ui_dark_logo']['url']; } else { $dark_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/logo-text-dark.svg'; } } elseif ( $admin_ui_logo_type == 'text_logo' ) { // Text Logo if ( $this->options['light_dark_mode']['admin_ui_mode'] == 'dark' ) { $text_logo = $dark_mode['admin_ui_dark_logo_text']; } } // Dark Logo Size $dark_width = ( !empty( $dark_mode['dark_logo_size']['width'] ) ? $dark_mode['dark_logo_size']['width'] : '120' ); $dark_height = ( !empty( $dark_mode['dark_logo_size']['height'] ) ? $dark_mode['dark_logo_size']['height'] : '32' ); ?> remove_menu( 'wp-logo' ); $wp_admin_bar->remove_menu( 'site-name' ); $wp_admin_bar->remove_menu( 'updates' ); $wp_admin_bar->remove_menu( 'menu-toggle' ); } }