From: Steve Sutton Date: Thu, 27 Oct 2016 14:35:41 +0000 (-0400) Subject: Setup new capability for bridge conditions. X-Git-Tag: v1.0.1^2~2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=100d3297913cb008158a027acae17d327632476a;p=WP-Plugins%2Fglm-member-db-conditions.git Setup new capability for bridge conditions. Limit a subscriber with this capability to only see Conditions in the glmAssociate menu. --- diff --git a/css/subscriberAdmin.css b/css/subscriberAdmin.css new file mode 100644 index 0000000..fb912d5 --- /dev/null +++ b/css/subscriberAdmin.css @@ -0,0 +1,6 @@ +#toplevel_page_glm-members-admin-menu-members li.wp-first-item + li, +#toplevel_page_glm-members-admin-menu-members li.wp-first-item + li + li +{ + display: none; +} + diff --git a/setup/adminMenus.php b/setup/adminMenus.php index d0594e4..20084eb 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -13,26 +13,6 @@ * @link http://dev.gaslightmedia.com/ */ -/********************************************************************** - * NOTE: THIS IS A CONDITIONS FILE - DO NOT USE UNMODIFIED - * - * Please change all references to conditions, Conditions, or CONDITIONS to a name - * appropriate for your new Add-On. - * - * This file is used to add main menus or sub-menus to the admin - * area. If this add-on does not create additional menus, this file - * should be omitted. - * - * If adding a main menu, use "add_menu_page()" WordPress function - * instead and note any differences. - * - * The menu slug should be constructed as - * "glm-members-admin-{page}-{action}" - * The default action for a page is usually "index". - * - * Remove this message before using this file in production! - **********************************************************************/ - /* * Added menus or sub-menus examples * @@ -92,3 +72,9 @@ add_submenu_page( function() {$this->controller('conditions');} ); +$user = wp_get_current_user(); +if ( in_array( 'subscriber', (array) $user->roles ) ) { + if ( current_user_can( 'glm_members_edit_conditions' ) ) { + wp_enqueue_style('glmConditionsSubscriberAdminStyle', GLM_MEMBERS_CONDITIONS_PLUGIN_URL . 'css/subscriberAdmin.css' ); + } +} diff --git a/setup/permissions.php b/setup/permissions.php index 461451a..cdf68b8 100644 --- a/setup/permissions.php +++ b/setup/permissions.php @@ -13,20 +13,6 @@ * @link http://dev.gaslightmedia.com/ */ - -/********************************************************************** - * NOTE: THIS IS A CONDITIONS FILE - DO NOT USE UNMODIFIED - * - * Please change all references to conditions, Conditions, or CONDITIONS to a name - * appropriate for your new Add-On. - * - * This file is used to add permission checks that can be used throught - * the main plugin and add-ons. If no such permissions are needed by - * this add-on, this file should be omitted. - * - * Remove this message before using this file in production! - **********************************************************************/ - /* * Below are permission checks for various specific things in this add-on and * elsewhere in the Member DB main plugin and add-ons. diff --git a/setup/rolesAndCapabilities.php b/setup/rolesAndCapabilities.php index 5285546..5ec28ac 100644 --- a/setup/rolesAndCapabilities.php +++ b/setup/rolesAndCapabilities.php @@ -13,19 +13,14 @@ * @link http://dev.gaslightmedia.com/ */ -/********************************************************************** - * NOTE: THIS IS A CONDITIONS FILE - DO NOT USE UNMODIFIED - * - * Please change all references to conditions, Conditions, or CONDITIONS to a name - * appropriate for your new Add-On. - * - * This file is used to add roles and capability. If none are required, - * this file should be omitted. - * - * Remove this message before using this file in production! - **********************************************************************/ - /** * NOTE: This file is only included in the activate.php process. * It is not regularly used during operation. */ + +$roles = get_editable_roles(); +foreach ($GLOBALS['wp_roles']->role_objects as $key => $role) { + if (isset($roles[$key]) && $role->has_cap('edit_posts')) { + $role->add_cap('glm_members_edit_conditions'); + } +}