.*?\\<\\/span><\\/span>/s', '', $item[0] );
}
}
}
}
return $options;
}
public function jltwp_adminify_admin_scripts()
{
global $pagenow ;
if ( !is_user_logged_in() && $pagenow != 'wp-login.php' ) {
return;
}
if ( is_admin_bar_showing() ) {
}
wp_enqueue_style( 'wp-adminify-admin-bar' );
wp_enqueue_script( 'wp-adminify-admin' );
wp_localize_script( 'wp-adminify-admin', 'WPAdminify', $this->adminify_create_admin_bar_js_object() );
$this->admin_topbar_loader_css();
// wp_enqueue_style('wp-adminify-admin-bar', WP_ADMINIFY_ASSETS . 'css/admin-bar.css', false, WP_ADMINIFY_VER);
// wp_enqueue_script('wp-adminify-admin', WP_ADMINIFY_ASSETS . 'js/wp-adminify.js', ['jquery'], WP_ADMINIFY_VER, true);
// wp_localize_script('wp-adminify-admin', 'WPAdminify', $this->adminify_create_admin_bar_js_object());
}
public function adminify_create_admin_bar_js_object()
{
return array(
'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(' . $topbar_wireframe_img . '); }';
echo '' ;
}
/**
* 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();
$key = Utils::clean_ajax_input( $_POST['key'] );
$value = Utils::clean_ajax_input( $_POST['value'] );
if ( $key == "" ) {
$message = __( "No Color Mode supplied to save", WP_ADMINIFY_TD );
echo Utils::ajax_error_message( $message ) ;
die;
}
// Light/Dark Mode
if ( $key === 'color_mode' ) {
$admin_bar_mode['admin_bar_mode'] = $value;
$admin_bar_mode['enable_schedule_dark_mode'] = false;
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 = array();
$current[$key] = $value;
}
$state = update_user_meta( $userid, '_wpadminify_preferences', $current );
if ( $state ) {
$returndata = array();
$returndata['success'] = true;
$returndata['message'] = __( 'Preferences saved', WP_ADMINIFY_TD );
echo json_encode( $returndata ) ;
} else {
$message = __( "Unable to save user preferences", WP_ADMINIFY_TD );
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 ) {
$term = $_POST['search'];
// Search Arguments
$args = array(
'numberposts' => -1,
's' => $term,
'post_status' => array(
'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);
// }
ob_start();
?>
s found', WP_ADMINIFY_TD ) ;
?>
options = (array) AdminSettings::get_instance()->get( 'admin_bar_settings' );
$admin_bar_mode = AdminSettings::get_instance()->get();
$admin_bar_mode = ( !empty($admin_bar_mode['admin_bar_mode']) ? $admin_bar_mode['admin_bar_mode'] : '' );
$output_css = '';
$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[] = " 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 = array(
'public' => true,
);
$output = 'objects';
$post_types = get_post_types( $args, $output );
$this->post_types = $post_types;
return $post_types;
}
}
public function jltwp_adminify_render_admin_bar()
{
global $pagenow ;
if ( !is_user_logged_in() && $pagenow != 'wp-login.php' ) {
return;
}
if ( !is_admin_bar_showing() ) {
return false;
}
global $wp_admin_bar ;
if ( empty($wp_admin_bar) ) {
return false;
}
$admin_bar_mode = AdminSettings::get_instance()->get();
$admin_bar_mode = ( !empty($admin_bar_mode['admin_bar_mode']) ? $admin_bar_mode['admin_bar_mode'] : '' );
// Light/Dark Mode
if ( $admin_bar_mode == 'light' ) {
$enable_dark_mode = 0;
} elseif ( $admin_bar_mode == 'dark' ) {
$enable_dark_mode = 1;
}
// 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']) === 'top' ) {
$admin_bar_position = 'top_bar';
} elseif ( !empty($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();
?>
get();
$menu_layout = (array) $admin_bar_mode['menu_layout_settings'];
// Menu Layouts
$menu_layout = ( !empty($admin_bar_mode['menu_layout_settings']) ? $admin_bar_mode['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_bar_logo_type = ( !empty($admin_bar_mode['admin_bar_logo_type']) ? $admin_bar_mode['admin_bar_logo_type'] : 'image_logo' );
$light_mode = ( !empty($admin_bar_mode['admin_bar_light_mode']) ? $admin_bar_mode['admin_bar_light_mode'] : '' );
if ( $admin_bar_logo_type == 'image_logo' ) {
// Logo Image
if ( !empty($light_mode['admin_bar_light_logo']['url']) ) {
$light_logo = $light_mode['admin_bar_light_logo']['url'];
} else {
if ( $menu_layout == 'vertical' && $menu_mode == 'icon_menu' ) {
$light_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/logo-text-light.svg';
} else {
$light_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/logo-text-light.svg';
}
}
} elseif ( $admin_bar_logo_type == 'text_logo' ) {
// Text Logo
$light_logo = $light_mode['admin_bar_light_logo_text'];
}
// Logo Size
$light_width = ( isset( $light_mode['light_logo_size']['width'] ) ? $light_mode['light_logo_size']['width'] : '150' );
$light_height = ( isset( $light_mode['light_logo_size']['height'] ) ? $light_mode['light_logo_size']['height'] : '45' );
// Dark Logo
$dark_mode = ( !empty($admin_bar_mode['admin_bar_dark_mode']) ? $admin_bar_mode['admin_bar_dark_mode'] : '' );
if ( $admin_bar_logo_type == 'image_logo' ) {
// Dark Logo Image
if ( isset( $dark_mode['admin_bar_dark_logo']['url'] ) && $dark_mode['admin_bar_dark_logo']['url'] ) {
$dark_logo = $dark_mode['admin_bar_dark_logo']['url'];
} else {
if ( $menu_layout == 'vertical' && $menu_mode === 'icon_menu' ) {
$dark_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/logo-text-dark.svg';
} else {
$dark_logo = WP_ADMINIFY_ASSETS_IMAGE . 'logos/logo-text-dark.svg';
}
}
} elseif ( $admin_bar_logo_type == 'text_logo' ) {
// Text Logo
$dark_logo = $dark_mode['admin_bar_dark_logo_text'];
}
// Dark Logo Size
$dark_width = ( isset( $dark_mode['dark_logo_size']['width'] ) ? $dark_mode['dark_logo_size']['width'] : '150' );
$dark_height = ( isset( $dark_mode['dark_logo_size']['height'] ) ? $dark_mode['dark_logo_size']['height'] : '45' );
?>
options['admin_bar_user_roles']) ? $this->options['admin_bar_user_roles'] : '' );
if ( $restricted_user ) {
if ( Utils::restrict_for( $this->options['admin_bar_user_roles'] ) ) {
$wp_admin_bar->remove_menu( 'new-content' );
return;
}
}
$wp_admin_bar->remove_menu( 'wp-logo' );
$wp_admin_bar->remove_menu( 'site-name' );
$wp_admin_bar->remove_menu( 'updates' );
$wp_admin_bar->remove_menu( 'menu-toggle' );
$wp_admin_bar->remove_menu( 'top-secondary' );
// WP Adminify Settings
$wp_admin_bar->remove_menu( 'wp-adminify-settings-4' );
// Notification Page
$wp_admin_bar->remove_menu( 'wp-adminify-settings-6' );
// Login Customizer
$wp_admin_bar->remove_menu( 'wp-adminify-settings-10' );
// Admin Pages
$wp_admin_bar->remove_menu( 'wp-adminify-settings-11' );
// Affiliation Page
$wp_admin_bar->remove_menu( 'wp-adminify-settings-12' );
// Account Page
$wp_admin_bar->remove_menu( 'wp-adminify-settings-13' );
// Contact Page
$wp_admin_bar->remove_menu( 'wp-adminify-settings-14' );
// Pricing Page
$wp_admin_bar->remove_menu( 'wp-adminify-settings-16' );
// Pricing Page
// Add/Modify Admin bar links
// Notification Bar
$wp_admin_bar->add_menu( array(
'id' => 'wp-adminify-settings-4',
'parent' => 'wp-adminify-settings',
'title' => __( 'Notification Bar', WP_ADMINIFY_TD ),
'href' => 'customize.php?autofocus%5Bpanel%5D=jltwp_notification_bar_panel',
) );
// Login Customizer
$wp_admin_bar->add_menu( array(
'id' => 'wp-adminify-settings-6',
'parent' => 'wp-adminify-settings',
'title' => __( 'Login Customizer', WP_ADMINIFY_TD ),
'href' => 'customize.php?autofocus[panel]=jltwp_adminify_panel',
) );
}
}