function on_woocommerce_waitlist_loaded()
{
    $canView_settings = false;
    if (is_user_logged_in()) {
        global $current_user, $wpdb;
        $allowed_settings_role = array("administrator");
        $wew_enable_shop_manager_settings = get_option('wew-enable-shop-manager-settings') && get_option('wew-enable-shop-manager-settings') == "on" ? true : false;
        if ($wew_enable_shop_manager_settings) {
            $allowed_settings_role[] = "shop_manager";
        }
        $user = get_userdata($current_user->ID);
        $capabilities = $user->{$wpdb->prefix . 'capabilities'};
        if (!isset($wp_roles)) {
            $wp_roles = new WP_Roles();
        }
        foreach ($wp_roles->role_names as $role => $name) {
            if (array_key_exists($role, $capabilities)) {
                if (!$canView_settings && in_array($role, $allowed_settings_role)) {
                    $canView_settings = true;
                }
            }
        }
    }
    if ($canView_settings) {
        require_once plugin_dir_path(__FILE__) . 'admin/class-woocommerce-waitlist.php';
        Woocommerce_Waitlist_Admin::get_instance();
    }
}
 /**
  * Return an instance of this class.
  *
  * @since     1.0.0
  *
  * @return    object    A single instance of this class.
  */
 public static function get_instance()
 {
     // If the single instance hasn't been set, set it now.
     if (null == self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Esempio n. 3
0
    $plugin_slug = 'woocommerce-waitlist';
    $tabs = array('woowaitlist_settings' => __('WooWaitlist Settings', $plugin_slug), 'email_settings' => __('Email Settings', $plugin_slug), 'woowaitlist_data' => __('WooWaitlist Data', $plugin_slug));
    echo '<div id="icon-themes" class="icon32"><br></div>';
    echo '<h2 class="nav-tab-wrapper">';
    foreach ($tabs as $tab => $name) {
        $class = $tab == $current ? ' nav-tab-active' : '';
        if ($tab == "woowaitlist_settings") {
            $tab_str = "";
        } else {
            $tab_str = "&tab={$tab}";
        }
        echo "<a class='nav-tab{$class}' href='?page=" . $plugin_slug . $tab_str . "'>{$name}</a>";
    }
    echo '</h2>';
}
$a = Woocommerce_Waitlist_Admin::get_instance();
$message = $a->get_plugin_msg();
$errorMessage = $message['error'];
$message = $message['message'];
$updated_html = "";
if ($message) {
    $updated_classes = array('updated');
    if ($errorMessage) {
        $updated_classes[] = 'error';
    }
    $updated_html .= "<div class='" . implode(" ", $updated_classes) . "'>";
    $updated_html .= $message;
    $updated_html .= "</div>";
}
?>