Skip to content

Commit

Permalink
Bring the RDA repo in-line with 1.1.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
DrewAPicture committed Mar 26, 2015
1 parent b3102c3 commit 8b5b545
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 95 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

* Contributors: DrewAPicture
* Tags: dashboard, access, users, administration
* Requires at least: 3.1
* Tested up to: 4.0
* Stable tag: 1.1.1
* Requires at least: 3.1.0
* Tested up to: 4.1.1
* Stable tag: 1.1.3

This WordPress plugin limits user access to the dashboard based on whether users have a chosen capability or role. Disallowed users are redirected to a chosen URL.

#### Features:

* Limit Dashboard access to Administrators only, Admins + Editors, Admins + Editors + Authors, or limit by specific capability.
* Limit Dashboard access to admins only, admins + editors, admins + editors + authors, or limit by specific capability.
* Choose your own redirect URL
* Optionally allow user profile access
* Optionally display a message on the login screen
Expand Down Expand Up @@ -95,14 +95,14 @@ add_filter( 'rda_frontend_toolbar_nodes', 'hide_some_toolbar_menu' );

## Changelog

#### 1.2
#### 1.1.3

Enhancements:
* Full multisite support, including the ability to choose Multisite-specific capabilities.
* More complete filter documentation
* New filter: `rda_capabilities_list` for filtering the capabilities drop-down list
* New filter: `rda_login_message` for filtering the login message
* New filter: `rda_menu_pages_to_remove` for filter the list of menu pages to remove
* Fixed a compatibility issue with bbPress and the media grid view.

#### 1.1.2

* Bump tested-up-to to 4.1.0
* Miscellaneous readme changes.

#### 1.1.1

Expand Down
18 changes: 0 additions & 18 deletions inc/class.rda-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,6 @@ private function _output_caps_dropdown() {
// Alphabetize for nicer display.
ksort( $capabilities );

/**
* Filter the capabilities list prior to outputting the drop-down.
*
* @since 1.2
*
* @param array $capabilities List of capabilities.
*/
$capabilities = apply_filters( 'rda_capabilities_list', $capabilities );

if ( ! empty( $capabilities ) ) {
// Start <select> element.
print( '<select name="rda_access_cap">' );
Expand Down Expand Up @@ -458,15 +449,6 @@ public function login_message_cb() {
* @access public
*/
public function output_login_message( $message ) {
/**
* Filter the login message prior to output.
*
* @since 1.2
*
* @param string $login_message Login message. Will be passed through {@see esc_html()} on output.
*/
$this->settings['login_message'] = apply_filters( 'rda_login_message', $this->settings['login_message'] );

if ( ! empty( $this->settings['login_message'] ) ) {
$message .= '<p class="message">' . esc_html( $this->settings['login_message'] ) . '</p>';
}
Expand Down
41 changes: 5 additions & 36 deletions inc/class.rda-remove-access.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class RDA_Remove_Access {
* RDA Remove Access Init
*
* @since 1.0
* @since 1.1.3 Moved `is_user_allowed()` to the {@see 'init'} hook.
*
* @param string $capability Capability passed from RDA_Options instance.
* @param array $settings Settings array passed from RDA_Options instance.
Expand All @@ -43,7 +44,7 @@ function __construct( $capability, $settings ) {

$this->settings = $settings;

add_action( 'plugins_loaded', array( $this, 'is_user_allowed' ) );
add_action( 'init', array( $this, 'is_user_allowed' ) );
}

/**
Expand Down Expand Up @@ -86,7 +87,7 @@ public function hide_menus() {
/** @global array $menu */
global $menu;

$menu_pages = array();
$menu_ids = array();

// Gather menu IDs (minus profile.php).
foreach ( $menu as $index => $values ) {
Expand All @@ -95,26 +96,10 @@ public function hide_menus() {
continue;
}

$menu_pages[] = $values[2];
// Remove menu pages.
remove_menu_page( $values[2] );
}
}

/**
* Filter the list of menu pages to remove.
*
* Does not include profile.php
*
* @since 1.2
*
* @param array $menu_pages List of menu pages to remove.
*/
$menu_pages = apply_filters( 'rda_menu_pages_to_remove', $menu_pages );

// Remove menu pages.
foreach ( $menu_pages as $menu_page ) {
remove_menu_page( $menu_page );
}

}

/**
Expand Down Expand Up @@ -145,25 +130,9 @@ function hide_toolbar_items( $wp_admin_bar ) {
$edit_profile = ! $this->settings['enable_profile'] ? 'edit-profile' : '';
if ( is_admin() ) {
$ids = array( 'about', 'comments', 'new-content', $edit_profile );

/**
* Filter the list of Toolbar menus to remove in the admin.
*
* @since 1.0
*
* @param array $nodes List of Toolbar "nodes", or menus, to remove in the admin.
*/
$nodes = apply_filters( 'rda_toolbar_nodes', $ids );
} else {
$ids = array( 'about', 'dashboard', 'comments', 'new-content', 'edit', $edit_profile );

/**
* Filter the list of Toolbar menus to remove in the front-end.
*
* @since 1.0
*
* @param array $nodes List of Toolbar "nodes", or menus, to remove in the front-end.
*/
$nodes = apply_filters( 'rda_frontend_toolbar_nodes', $ids );
}
foreach ( $nodes as $id ) {
Expand Down
62 changes: 33 additions & 29 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
Contributors: DrewAPicture
Donate link: http://www.werdswords.com
Tags: dashboard, access, users, administration
Requires at least: 3.1
Tested up to: 4.0
Stable tag: 1.1.1
Requires at least: 3.1.0
Tested up to: 4.1.1
Stable tag: 1.1.3

Allows you to disable Dashboard access for users of a specific role or capability. Disallowed users are redirected to a chosen URL.

== Description ==

* Limit Dashboard access to Administrators only, Admins + Editors, Admins + Editors + Authors, or limit by specific capability.
* Limit Dashboard access to admins only, admins + editors, admins + editors + authors, or limit by specific capability.
* Choose your own redirect URL
* Optionally allow user profile access
* Optionally display a message on the login screen
Expand All @@ -31,60 +31,65 @@ This plugin is in active development <a href="https://github.com/DrewAPicture/re

Users lacking the chosen capability or role(s) will be redirected to the URL set in Settings > Dashboard Access.

= Why haven't you added an option to disable the WordPress Toolbar?
= Why haven't you added an option to disable the WordPress Toolbar? =

The Toolbar contains certain important links (even for disallowed users) such as for accessing to the profile editor and/or logging out. Plus, there are many plugins out there for disabling the Toolbar if you really want to.

= Can I disable the redirection/profile-editing controls without disabling the plugin?
= Can I disable the redirection/profile-editing controls without disabling the plugin? =

No. Disable the plugin if you don't wish to leverage the functionality.

== Other Notes ==

<strong>Capabilities</strong>
<strong>Capabilities:</strong>

* You can limit Dashboard access to Admins only, Editors or above, Authors or above, or by selecting a capability. More information on WordPress' default roles and capabilities can be found here: http://codex.wordpress.org/Roles_and_Capabilities

<strong>User Profile Access</strong>
<strong>User Profile Access:</strong>

* You can optionally allow all users the ability to edit their profiles in the Dashboard. Users lacking the chosen capability won't be able to access any other sections of the Dashboard.

<strong>Login Message</strong>
<strong>Login Message:</strong>

* Supply a message to display on the login screen. Leaving this blank disables the message.

<strong>Hiding other plugins/themes' Toolbar menus</strong>
<strong>Hiding other plugins/themes' Toolbar menus:</strong>

* Remove Dashboard Access removes some built-in WordPress Toolbar menus by default, but can be extended to hide menus from other plugins or themes via two filters: `rda_toolbar_nodes` (viewing from the admin), and `rda_frontend_toolbar_nodes` (viewing from the front-end).

How to find the menu (node) id:
<strong>How to find the menu (node) id:</strong>

* In the HTML page source, look for the `<li>` container for the menu node you're targeting. It should take the form of `<li id="wp-admin-bar-SOMETHING">`
* In `<li id="wp-admin-bar-SOMETHING">`, you want the "SOMETHING" part.

How to filter the disallowed Toolbar nodes on the front-end:
<strong>How to filter the disallowed Toolbar nodes on the front-end:</strong>

`
/**
* Filter hidden Toolbar menus on the front-end.
*
* @param array $ids Toolbar menu IDs.
* @return array (maybe) filtered front-end Toolbar menu IDs.
*/
function hide_some_toolbar_menu( $ids ) {
function wpdocs_hide_some_toolbar_menu( $ids ) {
$ids[] = 'SOMETHING';
return $ids;
}
add_filter( 'rda_frontend_toolbar_nodes', 'hide_some_toolbar_menu' );
add_filter( 'rda_frontend_toolbar_nodes', 'wpdocs_hide_some_toolbar_menu' );
`

<strong>Common plugin Toolbar menus and their ids:</strong>
| <a href="http://wordpress.org/extend/plugins/jetpack/">Jetpack by WordPress.com</a> (notifications): 'notes
| <a href="http://wordpress.org/extend/plugins/wordpress-seo/">WordPress SEO by Yoast</a>: 'wpseo-menu'
| <a href="http://wordpress.org/extend/plugins/w3-total-cache/">W3 Total Cache</a>: 'w3tc'

* <a href="http://wordpress.org/extend/plugins/jetpack/">Jetpack by WordPress.com</a> (notifications) – 'notes'
* <a href="http://wordpress.org/extend/plugins/wordpress-seo/">WordPress SEO by Yoast</a> – 'wpseo-menu'
* <a href="http://wordpress.org/extend/plugins/w3-total-cache/">W3 Total Cache</a> – 'w3tc'

<strong>Debug Mode</strong>

To view debugging information on the Settings > Reading screen, visit yoursite.com/options-general.php?page=dashboard-access&rda_debug=1
To view debugging information on the Settings > Reading screen, visit:
`
example.com/options-general.php?page=dashboard-access&rda_debug=1
`

== Screenshots ==

Expand All @@ -94,25 +99,24 @@ To view debugging information on the Settings > Reading screen, visit yoursite.c

== Changelog ==

= 1.2 =
= 1.1.3 =

* Fixed a compatibility issue with bbPress and the media grid view.

<strong>Enhancements:</strong>
= 1.1.2 =

* Full multisite support, including the ability to choose Multisite-specific capabilities.
* More complete filter documentation
* New filter: `rda_capabilities_list` for filtering the capabilities drop-down list
* New filter: `rda_login_message` for filtering the login message
* New filter: `rda_menu_pages_to_remove` for filter the list of menu pages to remove
* Bump tested-up-to to 4.1.0
* Miscellaneous readme changes.

= 1.1.1 =

<strong>Bug Fix:</strong>
Bug Fix:

* Move options back to Settings > Dashboard Access screen to resolve conflict with page_on_front UI.

= 1.1 =

<strong>Enhancements:</strong>
Enhancements:

* Instantiate as a static instance for better modularity
* Move Dashboard Access Controls settings to Settings > Dashboard Access
Expand All @@ -121,7 +125,7 @@ To view debugging information on the Settings > Reading screen, visit yoursite.c
* New Filter: `rda_default_caps_for_role` - Filter default roles for Admins, Editors, and Authors
* New Debug Mode

<strong>Bug Fixes:</strong>
Bug Fixes:

* Remove unnecessarily stringent URL mask on the redirect URL option

Expand Down Expand Up @@ -167,4 +171,4 @@ To view debugging information on the Settings > Reading screen, visit yoursite.c

= 0.1 =

* Initial submission
* Initial submission
2 changes: 1 addition & 1 deletion remove-dashboard-access.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Remove Dashboard Access
* Plugin URI: http://www.werdswords.com
* Description: Removes Dashboard access for certain users based on capability.
* Version: 1.1.1
* Version: 1.1.3
* Author: Drew Jaynes (DrewAPicture)
* Author URI: http://www.drewapicture.com
* License: GPLv2
Expand Down

0 comments on commit 8b5b545

Please sign in to comment.