예제 #1
0
function wp_admin_bar_bookings_menu()
{
    global $wp_admin_bar;
    $current_user = wp_get_current_user();
    $curr_user_role = get_bk_option('booking_user_role_booking');
    $level = 10;
    if ($curr_user_role == 'administrator') {
        $level = 10;
    } else {
        if ($curr_user_role == 'editor') {
            $level = 7;
        } else {
            if ($curr_user_role == 'author') {
                $level = 2;
            } else {
                if ($curr_user_role == 'contributor') {
                    $level = 1;
                } else {
                    if ($curr_user_role == 'subscriber') {
                        $level = 0;
                    }
                }
            }
        }
    }
    $is_super_admin = apply_bk_filter('multiuser_is_user_can_be_here', false, 'only_super_admin');
    if ($current_user->user_level < $level && !$is_super_admin || !is_admin_bar_showing()) {
        return;
    }
    $update_count = getNumOfNewBookings();
    $title = __('Bookings', 'wpdev-booking');
    $update_title = $title;
    if ($update_count > 0) {
        $update_count_title = "&nbsp;<span id='ab-updates' class='booking-count bk-update-count' >" . number_format_i18n($update_count) . "</span>";
        //id='booking-count'
        $update_title .= $update_count_title;
    }
    $link_bookings = admin_url('admin.php') . "?page=" . WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME . "wpdev-booking";
    $link_settings = admin_url('admin.php') . "?page=" . WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME . "wpdev-booking-option";
    $wp_admin_bar->add_menu(array('id' => 'booking_options', 'title' => $update_title, 'href' => $link_bookings));
    $curr_user_role_settings = get_bk_option('booking_user_role_settings');
    $level = 10;
    if ($curr_user_role_settings == 'administrator') {
        $level = 10;
    } else {
        if ($curr_user_role_settings == 'editor') {
            $level = 7;
        } else {
            if ($curr_user_role_settings == 'author') {
                $level = 2;
            } else {
                if ($curr_user_role_settings == 'contributor') {
                    $level = 1;
                } else {
                    if ($curr_user_role_settings == 'subscriber') {
                        $level = 0;
                    }
                }
            }
        }
    }
    if ($current_user->user_level < $level && !$is_super_admin || !is_admin_bar_showing()) {
        return;
    }
    $wp_admin_bar->add_menu(array('parent' => 'booking_options', 'title' => __('Settings', 'wpdev-booking'), 'href' => $link_settings, 'id' => 'booking_settings'));
}
예제 #2
0
 function add_new_admin_menu()
 {
     $users_roles = array(get_bk_option('booking_user_role_booking'), get_bk_option('booking_user_role_addbooking'), get_bk_option('booking_user_role_settings'), get_bk_option('booking_user_role_resources'));
     for ($i = 0; $i < count($users_roles); $i++) {
         if ($users_roles[$i] == 'administrator') {
             $users_roles[$i] = 'activate_plugins';
         }
         if ($users_roles[$i] == 'editor') {
             $users_roles[$i] = 'publish_pages';
         }
         if ($users_roles[$i] == 'author') {
             $users_roles[$i] = 'publish_posts';
         }
         if ($users_roles[$i] == 'contributor') {
             $users_roles[$i] = 'edit_posts';
         }
         if ($users_roles[$i] == 'subscriber') {
             $users_roles[$i] = 'read';
         }
     }
     if ($this->is_field_in_table_exists('booking', 'is_new') == 0) {
         $update_count = 0;
     } else {
         $update_count = getNumOfNewBookings();
     }
     $title = __('Booking', 'wpdev-booking');
     $update_title = $title;
     if ($update_count > 0) {
         $update_count_title = "<span class='update-plugins count-{$update_count}' title='{$update_title}'><span class='update-count bk-update-count'>" . number_format_i18n($update_count) . "</span></span>";
         $update_title .= $update_count_title;
     }
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // M A I N     B O O K I N G
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $pagehook1 = add_menu_page(__('Booking calendar', 'wpdev-booking'), $update_title, $users_roles[0], WPDEV_BK_FILE . 'wpdev-booking', array(&$this, 'on_show_booking_page_main'), WPDEV_BK_PLUGIN_URL . '/img/calendar-16x16.png');
     add_action("admin_print_scripts-" . $pagehook1, array(&$this, 'on_add_admin_js_files'));
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // A D D     R E S E R V A T I O N
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $pagehook2 = add_submenu_page(WPDEV_BK_FILE . 'wpdev-booking', __('Add booking', 'wpdev-booking'), __('Add booking', 'wpdev-booking'), $users_roles[1], WPDEV_BK_FILE . 'wpdev-booking-reservation', array(&$this, 'on_show_booking_page_addbooking'));
     add_action("admin_print_scripts-" . $pagehook2, array(&$this, 'client_side_print_booking_head'));
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // A D D     R E S O U R C E S     Management
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $version = get_bk_version();
     //$is_can = apply_bk_filter('multiuser_is_user_can_be_here', true, 'not_low_level_user'); //Anxo customizarion
     if ($version != 'free') {
         //Anxo customizarion
         $pagehook4 = add_submenu_page(WPDEV_BK_FILE . 'wpdev-booking', __('Resources', 'wpdev-booking'), __('Resources', 'wpdev-booking'), $users_roles[3], WPDEV_BK_FILE . 'wpdev-booking-resources', array(&$this, 'on_show_booking_page_resources'));
         add_action("admin_print_scripts-" . $pagehook4, array(&$this, 'on_add_admin_js_files'));
     }
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // S E T T I N G S
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $pagehook3 = add_submenu_page(WPDEV_BK_FILE . 'wpdev-booking', __('Booking settings customization', 'wpdev-booking'), __('Settings', 'wpdev-booking'), $users_roles[2], WPDEV_BK_FILE . 'wpdev-booking-option', array(&$this, 'on_show_booking_page_settings'));
     add_action("admin_print_scripts-" . $pagehook3, array(&$this, 'on_add_admin_js_files'));
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     global $submenu, $menu;
     // Change Title of the Main menu inside of submenu
     if (isset($submenu[plugin_basename(WPDEV_BK_FILE) . 'wpdev-booking'])) {
         $submenu[plugin_basename(WPDEV_BK_FILE) . 'wpdev-booking'][0][0] = __('Bookings', 'wpdev-booking');
     }
 }
예제 #3
0
 function add_new_admin_menu()
 {
     $users_roles = array(get_bk_option('booking_user_role_booking'), get_bk_option('booking_user_role_addbooking'), get_bk_option('booking_user_role_settings'), get_bk_option('booking_user_role_resources'));
     for ($i = 0; $i < count($users_roles); $i++) {
         if (empty($users_roles[$i])) {
             $users_roles[$i] = 'editor';
         }
         //Fix: 2015-03-02 Need to have this fix for WordPress MU installations.
         if ($users_roles[$i] == 'administrator') {
             $users_roles[$i] = 'manage_options';
         }
         //Fix: 2015-03-02 Need to have this fix for WordPress MU installations.
         if ($users_roles[$i] == 'editor') {
             $users_roles[$i] = 'publish_pages';
         }
         if ($users_roles[$i] == 'author') {
             $users_roles[$i] = 'publish_posts';
         }
         if ($users_roles[$i] == 'contributor') {
             $users_roles[$i] = 'edit_posts';
         }
         if ($users_roles[$i] == 'subscriber') {
             $users_roles[$i] = 'read';
         }
     }
     if (wpbc_is_field_in_table_exists('booking', 'is_new') == 0) {
         $update_count = 0;
     } else {
         $update_count = getNumOfNewBookings();
     }
     $title = __('Booking', 'wpdev-booking');
     $update_title = $title;
     if ($update_count > 0) {
         $update_count_title = "<span class='update-plugins count-{$update_count}' title='{$update_title}'><span class='update-count bk-update-count'>" . number_format_i18n($update_count) . "</span></span>";
         $update_title .= $update_count_title;
     }
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // M A I N     B O O K I N G
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $pagehook1 = add_menu_page(__('Booking calendar', 'wpdev-booking'), $update_title, $users_roles[0], WPDEV_BK_FILE . 'wpdev-booking', array(&$this, 'on_show_booking_page_main'), WPDEV_BK_PLUGIN_URL . '/img/bc-16x16.png');
     add_action("admin_print_scripts-" . $pagehook1, array(&$this, 'load_admin_scripts_on_page'));
     add_action("admin_print_styles-" . $pagehook1, array(&$this, 'load_css_skip_client_css'));
     //Fix. 5.3 We need to load at client side and admin  side styles for having correct  calendar skins at  datepick elemtns. This hook for loading the styles at  the header of page
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // A D D     R E S E R V A T I O N
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $pagehook2 = add_submenu_page(WPDEV_BK_FILE . 'wpdev-booking', __('Add booking', 'wpdev-booking'), __('Add booking', 'wpdev-booking'), $users_roles[1], WPDEV_BK_FILE . 'wpdev-booking-reservation', array(&$this, 'on_show_booking_page_addbooking'));
     add_action("admin_print_scripts-" . $pagehook2, array(&$this, 'load_admin_client_scripts_on_page'));
     add_action("admin_print_styles-" . $pagehook2, array(&$this, 'load_admin_client_styles_on_page'));
     // This hook for loading the styles at  the header of page
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // A D D     R E S O U R C E S     Management
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $version = get_bk_version();
     //$is_can = apply_bk_filter('multiuser_is_user_can_be_here', true, 'not_low_level_user'); //Anxo customizarion
     if ($version != 'free') {
         //Anxo customizarion
         $pagehook4 = add_submenu_page(WPDEV_BK_FILE . 'wpdev-booking', __('Resources', 'wpdev-booking'), __('Resources', 'wpdev-booking'), $users_roles[3], WPDEV_BK_FILE . 'wpdev-booking-resources', array(&$this, 'on_show_booking_page_resources'));
         add_action("admin_print_scripts-" . $pagehook4, array(&$this, 'load_admin_scripts_on_page'));
         add_action("admin_print_styles-" . $pagehook4, array(&$this, 'load_admin_styles_on_page'));
         // This hook for loading the styles at  the header of page
     }
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // S E T T I N G S
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     $pagehook3 = add_submenu_page(WPDEV_BK_FILE . 'wpdev-booking', __('Booking Calendar Settings', 'wpdev-booking'), __('Settings', 'wpdev-booking'), $users_roles[2], WPDEV_BK_FILE . 'wpdev-booking-option', array(&$this, 'on_show_booking_page_settings'));
     add_action("admin_print_scripts-" . $pagehook3, array(&$this, 'load_admin_scripts_on_page'));
     add_action("admin_print_styles-" . $pagehook3, array(&$this, 'load_admin_styles_on_page'));
     // This hook for loading the styles at  the header of page
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     global $submenu, $menu;
     // Change Title of the Main menu inside of submenu
     if (isset($submenu[plugin_basename(WPDEV_BK_FILE) . 'wpdev-booking'])) {
         $submenu[plugin_basename(WPDEV_BK_FILE) . 'wpdev-booking'][0][0] = __('Bookings', 'wpdev-booking');
     }
 }