Commit 3f7782a1 authored by Rodrigo's avatar Rodrigo
Browse files

Add menu item to users without admin rights

Change the dashboard rights restriction
Update plugin version
parent 615c4ae5
......@@ -13,7 +13,7 @@ if ( ! defined( 'WPINC' ) ) {
die;
}
define( 'GEN_REGISTRATION_TRACKER_VERSION', '1.0.0' );
define( 'GEN_REGISTRATION_TRACKER_VERSION', '1.0.1' );
/**
* The core plugin class that is used to define internationalization,
......
......@@ -95,7 +95,8 @@ class Gen_Registration_Tracker {
// Register style sheet.
add_action( 'admin_enqueue_scripts', array( $this, 'register_styles' ) );
// Adding the function that creates a submenu to the admin menu.
add_action( 'admin_menu', array( $this, 'create_submenu' ) );
add_action( 'admin_menu', array( $this, 'create_dashboard_menu_link' ) );
}
/**
* Include CSS file for the plugin.
......@@ -105,16 +106,28 @@ class Gen_Registration_Tracker {
wp_enqueue_style( $this->plugin_name );
}
/** Function that creates a submenu to the admin menu*/
public function create_submenu() {
add_submenu_page(
'caldera-forms',
'GEN Registration Tracker',
'<span class="caldera-forms-menu-dashicon"><span class="dashicons dashicons-analytics"></span>GEN Registration Tracker',
'manage_options',
$this->plugin_name,
array( $this, 'create_admin_page' )
);
/** Function that creates a submenu to the admin menuif the user is admin, otherwise creates a new menu item*/
public function create_dashboard_menu_link() {
if ( current_user_can( 'manage_options' ) ) {
add_submenu_page(
'caldera-forms',
'GEN Registration Tracker',
'<span class="caldera-forms-menu-dashicon"><span class="dashicons dashicons-analytics"></span>GEN Registration Tracker',
'edit_pages',
$this->plugin_name,
array( $this, 'create_admin_page' )
);
} elseif ( current_user_can( 'read_private_posts' ) ) {
add_menu_page(
'GEN Registration Tracker',
'GEN Registration Tracker',
'read_private_posts',
$this->plugin_name,
array( $this, 'create_admin_page' ),
'dashicons-analytics',
);
}
}
/**
......@@ -142,7 +155,7 @@ class Gen_Registration_Tracker {
* @since 1.0.0
*/
public function create_admin_page() {
if ( ! current_user_can( 'manage_options' ) ) {
if ( ! current_user_can( 'read_private_posts' ) ) {
wp_die( esc_html__( 'You do not have sufficient permissions to access this page.' ) );
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment