Remove Dashboard Access - Version 1.1.4

Version Description

on April 18, 2022 =

Remove Dashboard Access is now being maintained by TrustedLogin! Remove Dashboard Access aligns with what we do at TrustedLogin: simply making WordPress more secure. Email any questions to support@trustedlogin.com.

  • Fixed: Deprecated function screen_icon() warning
  • Fixed: Issue when front-end editing of profiles when the $pagenow global is not defined (#24)
  • Fixed: Potential Invalid argument supplied for foreach() PHP warning (#22)
Download this release

Release Info

Developer trustedlogin
Plugin Icon 128x128 Remove Dashboard Access
Version 1.1.4
Comparing to
See all releases

Code changes from version 1.1.3 to 1.1.4

inc/class.rda-options.php CHANGED
@@ -52,7 +52,7 @@ class RDA_Options {
52
  'access_cap' => get_option( 'rda_access_cap', 'manage_options' ),
53
  'enable_profile' => get_option( 'rda_enable_profile', 1 ),
54
  'redirect_url' => get_option( 'rda_redirect_url', home_url() ),
55
- 'login_message' => get_option( 'rda_login_message', __( 'This site is in maintenance mode.', 'remove_dashboard_access' ) ),
56
  );
57
 
58
  // Settings.
@@ -138,8 +138,8 @@ class RDA_Options {
138
  */
139
  function options_page() {
140
  add_options_page(
141
- __( 'Dashboard Access Settings', 'remove_dashboard_access' ),
142
- __( 'Dashboard Access', 'remove_dashboard_access' ),
143
  'manage_options',
144
  'dashboard-access',
145
  array( $this, 'options_page_cb' )
@@ -156,8 +156,7 @@ class RDA_Options {
156
  function options_page_cb() {
157
  ?>
158
  <div class="wrap">
159
- <?php screen_icon(); ?>
160
- <h2><?php _e( 'Dashboard Access Settings', 'remove_dashboard_access' ); ?></h2>
161
  <form action="options.php" method="POST" id="rda-options-form">
162
  <?php
163
  settings_fields( 'dashboard-access' );
@@ -179,12 +178,12 @@ class RDA_Options {
179
  */
180
  public function settings() {
181
  // Dashboard Access Controls section.
182
- add_settings_section( 'rda_options', __( 'Dashboard Access Controls', 'remove_dashbord_access' ), array( $this, 'settings_section' ), 'dashboard-access' );
183
 
184
  // Settings.
185
  $sets = array(
186
  'rda_access_switch' => array(
187
- 'label' => __( 'Dashboard User Access:', 'remove_dashboard_access' ),
188
  'callback' => 'access_switch_cb',
189
  ),
190
  'rda_access_cap' => array(
@@ -192,15 +191,15 @@ class RDA_Options {
192
  'callback' => 'access_cap_dropdown',
193
  ),
194
  'rda_redirect_url' => array(
195
- 'label' => __( 'Redirect URL:', 'remove_dashboard_access' ),
196
  'callback' => 'url_redirect_cb',
197
  ),
198
  'rda_enable_profile' => array(
199
- 'label' => __( 'User Profile Access:', 'remove_dashboard_access' ),
200
  'callback' => 'profile_enable_cb',
201
  ),
202
  'rda_login_message' => array(
203
- 'label' => __( 'Login Message', 'remove_dashboard_access' ),
204
  'callback' => 'login_message_cb',
205
  ),
206
  );
@@ -215,7 +214,7 @@ class RDA_Options {
215
 
216
  // Debug info "setting".
217
  if ( ! empty( $_GET['rda_debug'] ) ) {
218
- add_settings_field( 'rda_debug_mode', __( 'Debug Info', 'remove_dashboard_access' ), array( $this, '_debug_mode' ), 'dashboard-access', 'rda_options' );
219
  }
220
 
221
  }
@@ -227,7 +226,7 @@ class RDA_Options {
227
  * @access public
228
  */
229
  public function settings_section() {
230
- _e( 'Dashboard access can be restricted to users of certain roles only or users with a specific capability.', 'remove_dashboard_access' );
231
  }
232
 
233
  /**
@@ -243,13 +242,13 @@ class RDA_Options {
243
  ?>
244
  <p><label>
245
  <input name="rda_access_switch" type="radio" value="capability" class="tag" <?php checked( 'capability', esc_attr( $switch ) ); ?> />
246
- <?php _e( '<strong>Advanced</strong>: Limit by capability:', 'remove_dashboard_access' ); ?>
247
  </label><?php $this->_output_caps_dropdown(); ?></p>
248
  <p>
249
- <?php printf( __( 'You can find out more about specific %s in the Codex.', 'remove_dashboard_access' ),
250
  sprintf( '<a href="%1$s" target="_new">%2$s</a>',
251
  esc_url( 'http://codex.wordpress.org/Roles_and_Capabilities' ),
252
- esc_html( __( 'Roles &amp; Capabilities', 'remove_dashboard_access' ) )
253
  )
254
  ); ?>
255
  </p>
@@ -282,7 +281,7 @@ class RDA_Options {
282
  public function plugin_toggle_cb() {
283
  printf( '<input name="rda_toggle_plugin_off" type="checkbox" value="1" class="code" %1$s/>%2$s',
284
  checked( esc_attr( $this->settings['toggle_plugin_off'] ), true, false ),
285
- __( ' Disable access controls and redirection', 'remove_dashboard_access' )
286
  );
287
  }
288
 
@@ -325,15 +324,15 @@ class RDA_Options {
325
  ?>
326
  <p><label>
327
  <input name="rda_access_switch" type="radio" value="<?php echo esc_attr( $defaults['admin'] ); ?>" class="tag" <?php checked( $defaults['admin'], esc_attr( $switch ) ); ?> />
328
- <?php _e( 'Administrators only', 'remove_dashboard_access' ); ?>
329
  </label></p>
330
  <p><label>
331
  <input name="rda_access_switch" type="radio" value="<?php echo esc_attr( $defaults['editor'] ); ?>" class="tag" <?php checked( $defaults['editor'], esc_attr( $switch ) ); ?> />
332
- <?php _e( 'Editors and Administrators', 'remove_dashboard_access' ); ?>
333
  </label></p>
334
  <p><label>
335
  <input name="rda_access_switch" type="radio" value="<?php echo esc_attr( $defaults['author'] ); ?>" class="tag" <?php checked( $defaults['author'], esc_attr( $switch ) ); ?> />
336
- <?php _e( 'Authors, Editors, and Administrators', 'remove_dashboard_access' ); ?>
337
  </label></p>
338
 
339
  <?php
@@ -383,7 +382,7 @@ class RDA_Options {
383
  print( '<select name="rda_access_cap">' );
384
 
385
  // Default first option.
386
- printf( '<option selected="selected" value="manage_options">%s</option>', __( '--- Select a Capability ---', 'removed_dashboard_access' ) );
387
 
388
  // Build capabilities dropdown.
389
  foreach ( $capabilities as $capability => $value ) {
@@ -407,7 +406,7 @@ class RDA_Options {
407
  printf( '<input name="rda_enable_profile" type="checkbox" value="1" class="code" %1$s/>%2$s',
408
  checked( esc_attr( $this->settings['enable_profile'] ), true, false ),
409
  /* Translators: The leading space is intentional to space the text away from the checkbox */
410
- __( ' Allow all users to edit their profiles in the dashboard.', 'remove_dashboard_access' )
411
  );
412
  }
413
 
@@ -424,7 +423,7 @@ class RDA_Options {
424
  public function url_redirect_cb() {
425
  ?>
426
  <p><label>
427
- <?php _e( 'Redirect disallowed users to:', 'remove_dashboard_access' ); ?>
428
  <input name="rda_redirect_url" class="regular-text" type="text" value="<?php echo esc_attr( $this->settings['redirect_url'] ); ?>" placeholder="<?php printf( esc_attr__( 'Default: %s', 'remove_dashboard_access' ), home_url() ); ?>" />
429
  </label></p>
430
  <?php
@@ -593,11 +592,11 @@ class RDA_Options {
593
  <table class="rda_debug">
594
  <tbody>
595
  <tr>
596
- <th><?php _e( 'Setting', 'remove_dashboard_access' ); ?></th>
597
- <th><?php _e( 'Value', 'remove_dashboard_access' ); ?></th>
598
  </tr>
599
  <?php foreach ( $this->settings as $key => $value ) :
600
- $value = empty( $value ) ? __( 'empty', 'remove_dashboard_access' ) : $value;
601
  ?>
602
  <tr>
603
  <td><?php echo esc_html( $key ); ?></td>
52
  'access_cap' => get_option( 'rda_access_cap', 'manage_options' ),
53
  'enable_profile' => get_option( 'rda_enable_profile', 1 ),
54
  'redirect_url' => get_option( 'rda_redirect_url', home_url() ),
55
+ 'login_message' => get_option( 'rda_login_message', esc_html__( 'This site is in maintenance mode.', 'remove_dashboard_access' ) ),
56
  );
57
 
58
  // Settings.
138
  */
139
  function options_page() {
140
  add_options_page(
141
+ esc_html__( 'Dashboard Access Settings', 'remove_dashboard_access' ),
142
+ esc_html__( 'Dashboard Access', 'remove_dashboard_access' ),
143
  'manage_options',
144
  'dashboard-access',
145
  array( $this, 'options_page_cb' )
156
  function options_page_cb() {
157
  ?>
158
  <div class="wrap">
159
+ <h2><?php esc_html_e( 'Dashboard Access Settings', 'remove_dashboard_access' ); ?></h2>
 
160
  <form action="options.php" method="POST" id="rda-options-form">
161
  <?php
162
  settings_fields( 'dashboard-access' );
178
  */
179
  public function settings() {
180
  // Dashboard Access Controls section.
181
+ add_settings_section( 'rda_options', esc_html__( 'Dashboard Access Controls', 'remove_dashbord_access' ), array( $this, 'settings_section' ), 'dashboard-access' );
182
 
183
  // Settings.
184
  $sets = array(
185
  'rda_access_switch' => array(
186
+ 'label' => esc_html__( 'Dashboard User Access:', 'remove_dashboard_access' ),
187
  'callback' => 'access_switch_cb',
188
  ),
189
  'rda_access_cap' => array(
191
  'callback' => 'access_cap_dropdown',
192
  ),
193
  'rda_redirect_url' => array(
194
+ 'label' => esc_html__( 'Redirect URL:', 'remove_dashboard_access' ),
195
  'callback' => 'url_redirect_cb',
196
  ),
197
  'rda_enable_profile' => array(
198
+ 'label' => esc_html__( 'User Profile Access:', 'remove_dashboard_access' ),
199
  'callback' => 'profile_enable_cb',
200
  ),
201
  'rda_login_message' => array(
202
+ 'label' => esc_html__( 'Login Message', 'remove_dashboard_access' ),
203
  'callback' => 'login_message_cb',
204
  ),
205
  );
214
 
215
  // Debug info "setting".
216
  if ( ! empty( $_GET['rda_debug'] ) ) {
217
+ add_settings_field( 'rda_debug_mode', esc_html__( 'Debug Info', 'remove_dashboard_access' ), array( $this, '_debug_mode' ), 'dashboard-access', 'rda_options' );
218
  }
219
 
220
  }
226
  * @access public
227
  */
228
  public function settings_section() {
229
+ esc_html_e( 'Dashboard access can be restricted to users of certain roles only or users with a specific capability.', 'remove_dashboard_access' );
230
  }
231
 
232
  /**
242
  ?>
243
  <p><label>
244
  <input name="rda_access_switch" type="radio" value="capability" class="tag" <?php checked( 'capability', esc_attr( $switch ) ); ?> />
245
+ <?php echo wp_kses( __( '<strong>Advanced</strong>: Limit by capability:', 'remove_dashboard_access' ), array( 'strong' => array() ) ); ?>
246
  </label><?php $this->_output_caps_dropdown(); ?></p>
247
  <p>
248
+ <?php printf( esc_html__( 'You can find out more about specific %s in the Codex.', 'remove_dashboard_access' ),
249
  sprintf( '<a href="%1$s" target="_new">%2$s</a>',
250
  esc_url( 'http://codex.wordpress.org/Roles_and_Capabilities' ),
251
+ esc_html__( 'Roles &amp; Capabilities', 'remove_dashboard_access' )
252
  )
253
  ); ?>
254
  </p>
281
  public function plugin_toggle_cb() {
282
  printf( '<input name="rda_toggle_plugin_off" type="checkbox" value="1" class="code" %1$s/>%2$s',
283
  checked( esc_attr( $this->settings['toggle_plugin_off'] ), true, false ),
284
+ esc_html__( ' Disable access controls and redirection', 'remove_dashboard_access' )
285
  );
286
  }
287
 
324
  ?>
325
  <p><label>
326
  <input name="rda_access_switch" type="radio" value="<?php echo esc_attr( $defaults['admin'] ); ?>" class="tag" <?php checked( $defaults['admin'], esc_attr( $switch ) ); ?> />
327
+ <?php esc_html_e( 'Administrators only', 'remove_dashboard_access' ); ?>
328
  </label></p>
329
  <p><label>
330
  <input name="rda_access_switch" type="radio" value="<?php echo esc_attr( $defaults['editor'] ); ?>" class="tag" <?php checked( $defaults['editor'], esc_attr( $switch ) ); ?> />
331
+ <?php esc_html_e( 'Editors and Administrators', 'remove_dashboard_access' ); ?>
332
  </label></p>
333
  <p><label>
334
  <input name="rda_access_switch" type="radio" value="<?php echo esc_attr( $defaults['author'] ); ?>" class="tag" <?php checked( $defaults['author'], esc_attr( $switch ) ); ?> />
335
+ <?php esc_html_e( 'Authors, Editors, and Administrators', 'remove_dashboard_access' ); ?>
336
  </label></p>
337
 
338
  <?php
382
  print( '<select name="rda_access_cap">' );
383
 
384
  // Default first option.
385
+ printf( '<option selected="selected" value="manage_options">%s</option>', esc_html__( '--- Select a Capability ---', 'removed_dashboard_access' ) );
386
 
387
  // Build capabilities dropdown.
388
  foreach ( $capabilities as $capability => $value ) {
406
  printf( '<input name="rda_enable_profile" type="checkbox" value="1" class="code" %1$s/>%2$s',
407
  checked( esc_attr( $this->settings['enable_profile'] ), true, false ),
408
  /* Translators: The leading space is intentional to space the text away from the checkbox */
409
+ esc_html__( ' Allow all users to edit their profiles in the dashboard.', 'remove_dashboard_access' )
410
  );
411
  }
412
 
423
  public function url_redirect_cb() {
424
  ?>
425
  <p><label>
426
+ <?php esc_html_e( 'Redirect disallowed users to:', 'remove_dashboard_access' ); ?>
427
  <input name="rda_redirect_url" class="regular-text" type="text" value="<?php echo esc_attr( $this->settings['redirect_url'] ); ?>" placeholder="<?php printf( esc_attr__( 'Default: %s', 'remove_dashboard_access' ), home_url() ); ?>" />
428
  </label></p>
429
  <?php
592
  <table class="rda_debug">
593
  <tbody>
594
  <tr>
595
+ <th><?php esc_html_e( 'Setting', 'remove_dashboard_access' ); ?></th>
596
+ <th><?php esc_html_e( 'Value', 'remove_dashboard_access' ); ?></th>
597
  </tr>
598
  <?php foreach ( $this->settings as $key => $value ) :
599
+ $value = empty( $value ) ? esc_html__( 'empty', 'remove_dashboard_access' ) : $value;
600
  ?>
601
  <tr>
602
  <td><?php echo esc_html( $key ); ?></td>
inc/class.rda-remove-access.php CHANGED
@@ -87,7 +87,9 @@ class RDA_Remove_Access {
87
  /** @global array $menu */
88
  global $menu;
89
 
90
- $menu_ids = array();
 
 
91
 
92
  // Gather menu IDs (minus profile.php).
93
  foreach ( $menu as $index => $values ) {
@@ -113,7 +115,7 @@ class RDA_Remove_Access {
113
  /** @global string $pagenow */
114
  global $pagenow;
115
 
116
- if ( 'profile.php' != $pagenow || ! $this->settings['enable_profile'] ) {
117
  wp_redirect( $this->settings['redirect_url'] );
118
  exit;
119
  }
87
  /** @global array $menu */
88
  global $menu;
89
 
90
+ if ( ! $menu || ! is_array( $menu ) ) {
91
+ return;
92
+ }
93
 
94
  // Gather menu IDs (minus profile.php).
95
  foreach ( $menu as $index => $values ) {
115
  /** @global string $pagenow */
116
  global $pagenow;
117
 
118
+ if ( ( $pagenow && 'profile.php' !== $pagenow ) || ( defined( 'IS_PROFILE_PAGE' ) && ! IS_PROFILE_PAGE ) || ! $this->settings['enable_profile'] ) {
119
  wp_redirect( $this->settings['redirect_url'] );
120
  exit;
121
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: DrewAPicture
3
  Donate link: http://www.werdswords.com
4
  Tags: dashboard, access, users, administration
5
  Requires at least: 3.1.0
6
- Tested up to: 4.8.2
7
- Stable tag: 1.1.3
8
 
9
  Allows you to disable Dashboard access for users of a specific role or capability. Disallowed users are redirected to a chosen URL.
10
 
@@ -99,6 +99,14 @@ example.com/options-general.php?page=dashboard-access&rda_debug=1
99
 
100
  == Changelog ==
101
 
 
 
 
 
 
 
 
 
102
  = 1.1.3 =
103
 
104
  * Fixed a compatibility issue with bbPress and the media grid view.
3
  Donate link: http://www.werdswords.com
4
  Tags: dashboard, access, users, administration
5
  Requires at least: 3.1.0
6
+ Tested up to: 4.1.1
7
+ Stable tag: 1.1.4
8
 
9
  Allows you to disable Dashboard access for users of a specific role or capability. Disallowed users are redirected to a chosen URL.
10
 
99
 
100
  == Changelog ==
101
 
102
+ = 1.1.4 on April 18, 2022 =
103
+
104
+ Remove Dashboard Access is now being maintained by [TrustedLogin](https://www.trustedlogin.com/2022/02/21/remove-dashboard-access/)! Remove Dashboard Access aligns with what we do at TrustedLogin: simply making WordPress more secure. Email any questions to [support@trustedlogin.com](mailto:support@trustedlogin.com).
105
+
106
+ * Fixed: Deprecated function `screen_icon()` warning
107
+ * Fixed: Issue when front-end editing of profiles when the `$pagenow` global is not defined ([#24](https://github.com/trustedlogin/Remove-Dashboard-Access/issues/24))
108
+ * Fixed: Potential `Invalid argument supplied for foreach()` PHP warning ([#22](https://github.com/trustedlogin/Remove-Dashboard-Access/pull/22))
109
+
110
  = 1.1.3 =
111
 
112
  * Fixed a compatibility issue with bbPress and the media grid view.
remove-dashboard-access.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /**
3
  * Plugin Name: Remove Dashboard Access
4
- * Plugin URI: http://www.werdswords.com
5
  * Description: Removes Dashboard access for certain users based on capability.
6
- * Version: 1.1.3
7
- * Author: Drew Jaynes (DrewAPicture)
8
- * Author URI: http://www.drewapicture.com
9
  * License: GPLv2
10
  */
11
 
1
  <?php
2
  /**
3
  * Plugin Name: Remove Dashboard Access
4
+ * Plugin URI: https://www.trustedlogin.com/remove-dashboard-access/
5
  * Description: Removes Dashboard access for certain users based on capability.
6
+ * Version: 1.1.4
7
+ * Author: TrustedLogin
8
+ * Author URI: https://www.trustedlogin.com
9
  * License: GPLv2
10
  */
11