From 265de524843b74b6130c03794f0c8ab99929d00c Mon Sep 17 00:00:00 2001 From: Stephen Schrauger Date: Tue, 8 Mar 2016 13:08:15 -0500 Subject: [PATCH 01/12] adds preference to hide disabled users --- init.php | 196 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 190 insertions(+), 6 deletions(-) diff --git a/init.php b/init.php index cafae69..b06f538 100644 --- a/init.php +++ b/init.php @@ -3,9 +3,9 @@ * Plugin Name: Disable Users * Plugin URI: http://wordpress.org/extend/disable-users * Description: This plugin provides the ability to disable specific user accounts. - * Version: 1.0.5 - * Author: Jared Atchison - * Author URI: http://jaredatchison.com + * Version: 1.2.0 + * Author: Jared Atchison, Stephen Schrauger + * Author URI: http://jaredatchison.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,8 +17,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * @author Jared Atchison - * @version 1.0.5 + * @author Jared Atchison, Stephen Schrauger + * @version 1.2.0 * @package JA_DisableUsers * @copyright Copyright (c) 2015, Jared Atchison * @link http://jaredatchison.com @@ -47,6 +47,18 @@ function __construct() { // Filters add_filter( 'login_message', array( $this, 'user_login_message' ) ); add_filter( 'manage_users_columns', array( $this, 'manage_users_columns' ) ); + + // Plugin Settings + // Register the 'settings' page + add_action( 'admin_menu', array( $this, 'add_plugin_page' ) ); + add_action( 'admin_init', array( $this, 'admin_init' ) ); + + // Add a link from the plugin page to this plugin's settings page + add_filter( 'plugin_row_meta', array( $this, 'plugin_action_links' ), 10, 2 ); + + // Modify the All Users query to hide disabled users by default (if preference set) + add_filter('pre_user_query', array($this, 'user_query_exceptions' ) ); + } /** @@ -167,7 +179,14 @@ public function user_login_message( $message ) { */ public function manage_users_columns( $defaults ) { - $defaults['ja_user_disabled'] = __( 'Disabled', 'ja_disable_users' ); + + if (esc_attr( get_option( 'ja-disable-users-setting-hide-disabled' ))) { + $title = __("Click to show disabled accounts."); + } else { + $title = __("Click to hide disabled accounts."); + } + $toggle_link = '*'; + $defaults['ja_user_disabled'] = __( 'Disabled' . $toggle_link, 'ja_disable_users' ); return $defaults; } @@ -197,5 +216,170 @@ public function manage_users_column_content( $empty, $column_name, $user_ID ) { public function manage_users_css() { echo ''; } + + /** + * Tells WordPress about a new page and what function to call to create it + * + * @since 1.1.0 + */ + public function add_plugin_page() { + // This page will be under "Settings" menu. add_options_page is merely a WP wrapper for add_submenu_page specifying the 'options-general' menu as parent + add_options_page( + "Disable Users Settings", // page title + "Disable Users Settings", // menu title + "manage_options", // user capability required to edit these settings + "ja-disable-users-settings", // new page slug + array( + $this, + 'create_settings_page' + ) // since we are putting settings on our own page, we also have to define how to print out the settings + ); + } + + /** + * Adds a link to this plugin's setting page directly on the WordPress plugin list page + * + * @param $links + * @param $file + * + * @return array + */ + public function plugin_action_links( $links, $file ) { + if ( strpos( __FILE__, $file ) !== false ) { + $links = array_merge( + $links, + array( + 'settings' => '' . __( 'Settings', 'ja-disable-users-settings') . '' + ) + ); + } + + return $links; + } + + /** + * Tells WordPress how to output the page + * + * @since 1.2.0 + */ + public function create_settings_page() { + ?> +
+ +

Disable Users - Settings

+ +
+ +
+
+ add_setting('ja-disable-users-setting-hide-disabled', __("Hide disabled users by default on All Users")); // adds a checkbox that lets users view All Users minus any disabled users + } + + /** + * Adds a setting + * + * @param $setting_name + * @param $label + */ + public function add_setting( $setting_id, $label ) { + // add setting, and register it + add_settings_field( + $setting_id, // Unique ID used to identify the field + $label, // The label to the left of the option. + array($this, 'settings_input_checkbox'), // The function responsible for rendering checkboxes + 'ja-disable-users-settings', // The page on which this option will be displayed + 'ja-disable-users-settings-section', // The name of the section to which this field belongs + array( // The array of arguments to pass to the callback. These 3 are referenced in setting_input_checkbox. + 'id' => $setting_id, + 'label' => $label, + 'value' => esc_attr( get_option( $setting_id )) + ) + ); + register_setting( + 'ja-disable-users-settings-group', + $setting_id + //array( $this, 'sanitize' ) // sanitize function + ); + + } + + /* + ** + * Creates the HTML code that is printed for each setting input + * + * @param $args + */ + public function settings_input_checkbox( $args ) { + // Note the ID and the name attribute of the element should match that of the ID in the call to add_settings_field. + // Because we only call register_setting once, all the options are stored in an array in the database. So we + // have to name our inputs with the name of an array. ex . + // WordPress will automatically serialize the inputs that are in this array form and store it under + // the option_group_name field. Then get_option will automatically unserialize and grab the value already set and pass it in via the $args as the 'value' parameter. + if ($args[ 'value' ]) { + $checked = 'checked="checked"'; + } else { + $checked = ''; + } + + $html = ''; + + // create a hidden variable with the same name and no value. if the box is unchecked, the hidden value will be POSTed. + // If the value is checked, only the checkbox will be sent. + // This way, we don't have to uncheck everything server-side and then re-check the POSTed values. + // This is particularly useful to prevent preferences from being deleted if a post type is removed from a theme's code. + // If we just unchecked everything, old post types would lose their preferences; if they are later reactivated, the preference + // would be gone. This way, the preference persists. + $html .= ''; + $html .= ''; + + // Here, we will take the first argument of the array and add it to a label next to the input + $html .= ''; + echo $html; + } + + public function user_query_exceptions($query_obj){ + // if preference is set to hide disabled users by default, then alter the All Users query to prevent disabled users from showing up + global $wpdb; + $str_hide_query = " AND ID NOT IN (SELECT user_id from $wpdb->usermeta WHERE meta_key = 'ja_disable_user' AND meta_value = '1')"; + + if (esc_attr( get_option( 'ja-disable-users-setting-hide-disabled' ))) { + // preference set to hide disabled users by default. now check if they are manually showing them. + if ( empty( $_REQUEST[ 'toggle_disabled' ] ) ) { + // 'show_disabled' not specified, so exclude disabled users + // search for ja_disable_user=true. if ID is listed, they are disabled. + $query_obj->query_where .= $str_hide_query; + } + } else { + // preference set to show disabled users by default. now check if they are manually hiding them. + if ( !empty( $_REQUEST[ 'toggle_disabled' ] ) ) { + // 'hide_disabled' specified, so exclude disabled users + // search for ja_disable_user=true. if ID is listed, they are disabled. + $query_obj->query_where .= $str_hide_query; + } + } + return $query_obj; + + } } new ja_disable_users(); \ No newline at end of file From cce6a8766d92b6b8088bfcb829f730aec67850f0 Mon Sep 17 00:00:00 2001 From: Stephen Schrauger Date: Tue, 8 Mar 2016 13:28:16 -0500 Subject: [PATCH 02/12] adds submenu to show ONLY disabled users --- init.php | 62 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/init.php b/init.php index b06f538..9a09b2b 100644 --- a/init.php +++ b/init.php @@ -3,7 +3,7 @@ * Plugin Name: Disable Users * Plugin URI: http://wordpress.org/extend/disable-users * Description: This plugin provides the ability to disable specific user accounts. - * Version: 1.2.0 + * Version: 1.2.1 * Author: Jared Atchison, Stephen Schrauger * Author URI: http://jaredatchison.com * @@ -18,7 +18,7 @@ * GNU General Public License for more details. * * @author Jared Atchison, Stephen Schrauger - * @version 1.2.0 + * @version 1.2.1 * @package JA_DisableUsers * @copyright Copyright (c) 2015, Jared Atchison * @link http://jaredatchison.com @@ -218,9 +218,9 @@ public function manage_users_css() { } /** - * Tells WordPress about a new page and what function to call to create it + * Tells WordPress about a new settings page and what function to call to create it * - * @since 1.1.0 + * @since 1.2.0 */ public function add_plugin_page() { // This page will be under "Settings" menu. add_options_page is merely a WP wrapper for add_submenu_page specifying the 'options-general' menu as parent @@ -234,11 +234,18 @@ public function add_plugin_page() { 'create_settings_page' ) // since we are putting settings on our own page, we also have to define how to print out the settings ); + + global $submenu; + $permalink = admin_url( 'users.php' ).'?only_disabled=1'; + $submenu['users.php'][] = array( 'Disabled Users', 'ja-disable-user-onlydisabled', $permalink ); + } /** * Adds a link to this plugin's setting page directly on the WordPress plugin list page * + * @since 1.2.0 + * * @param $links * @param $file * @@ -279,13 +286,11 @@ public function create_settings_page() { usermeta WHERE meta_key = 'ja_disable_user' AND meta_value = '1')"; + $str_hide_disabled_query = " AND ID NOT IN (SELECT user_id from $wpdb->usermeta WHERE meta_key = 'ja_disable_user' AND meta_value = '1')"; + $str_only_disabled_query = " AND ID IN (SELECT user_id from $wpdb->usermeta WHERE meta_key = 'ja_disable_user' AND meta_value = '1')"; + + + if ( !empty( $_REQUEST[ 'only_disabled' ] ) ) { + $query_obj->query_where .= $str_only_disabled_query; + return $query_obj; // force return here. we don't want the user to select 'only disabled' and 'hide disabled', because they would get an empty list. + } if (esc_attr( get_option( 'ja-disable-users-setting-hide-disabled' ))) { // preference set to hide disabled users by default. now check if they are manually showing them. if ( empty( $_REQUEST[ 'toggle_disabled' ] ) ) { // 'show_disabled' not specified, so exclude disabled users // search for ja_disable_user=true. if ID is listed, they are disabled. - $query_obj->query_where .= $str_hide_query; + $query_obj->query_where .= $str_hide_disabled_query; } } else { // preference set to show disabled users by default. now check if they are manually hiding them. if ( !empty( $_REQUEST[ 'toggle_disabled' ] ) ) { // 'hide_disabled' specified, so exclude disabled users // search for ja_disable_user=true. if ID is listed, they are disabled. - $query_obj->query_where .= $str_hide_query; + $query_obj->query_where .= $str_hide_disabled_query; } } - return $query_obj; + if ( !empty( $_REQUEST[ 'only_disabled' ] ) ) { + $query_obj->query_where .= $str_only_disabled_query; + } + + return $query_obj; } } From 367de7f11624d1efdf232acc4c1deb6134f82cd1 Mon Sep 17 00:00:00 2001 From: Stephen Schrauger Date: Tue, 8 Mar 2016 13:35:11 -0500 Subject: [PATCH 03/12] new functionality, changelog Describes new functionality with settings page and hiding users from All Users. Updates changelog with version updates. --- readme.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 0954a4e..b806d7e 100644 --- a/readme.txt +++ b/readme.txt @@ -20,6 +20,8 @@ This can be useful in a few situations. * You are working on a site for a client who has an account, but do not want him to login and/or make changes during development. * You have a client who has an unpaid invoice. +Disabled users can also be hidden from the All Users listing, either by default (via the plugin settings page) or manually (by clicking on the link in the Disabled column). A new menu item is added as well, letting you view only disabled users. + **[This plugin is on GitHub!](https://github.com/jaredatch/Disable-Users/)** Pull requests are welcome. If possible please report issues through Github. == Installation == @@ -40,6 +42,13 @@ Yes, there is a filter in place for that, `ja_disable_users_notice`. == Changelog == += 1.2.1 (03/08/2016) = +* Added menu item to show only disabled users + += 1.2.0 (03/08/2016) = +* Added plugin setting page +** Preference to hide disabled users by default when viewing All Users + = 1.0.5 (11/11/2015) = * Added pl_PL transnation - Props Dominik Kocuj @@ -57,4 +66,4 @@ Yes, there is a filter in place for that, `ja_disable_users_notice`. * Fixed notice that would show if WP_DEBUG was on. Props @vegasgeek. = 1.0.0 = -* Initial launch \ No newline at end of file +* Initial launch From 969bdf31c7967fb5037d1da6afb3ac2ce2303d08 Mon Sep 17 00:00:00 2001 From: Stephen Schrauger Date: Tue, 8 Mar 2016 13:35:49 -0500 Subject: [PATCH 04/12] adds 'schrauger' (me) as a contributor --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index b806d7e..dcb73a0 100644 --- a/readme.txt +++ b/readme.txt @@ -1,5 +1,5 @@ === Disable Users === -Contributors: jaredatch +Contributors: jaredatch, schrauger Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AD8KTWTTDX9JL Tags: users, login, disable Requires at least: 4.0.0 From 98a7102f5510e402f72c5381064f2d509601d42a Mon Sep 17 00:00:00 2001 From: Stephen Schrauger Date: Wed, 27 Apr 2016 11:49:22 -0400 Subject: [PATCH 05/12] fixes network admin plugin page --- init.php | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 8 deletions(-) diff --git a/init.php b/init.php index 9a09b2b..78ff3fa 100644 --- a/init.php +++ b/init.php @@ -50,8 +50,13 @@ function __construct() { // Plugin Settings // Register the 'settings' page + if (is_multisite()) { + add_action( 'network_admin_menu', array( $this, 'add_network_plugin_page' ) ); + add_action('network_admin_edit_ja_disable_users_save', array($this, 'save_network_settings_page'), 10, 0); + add_site_option( 'ja-disable-users-setting-hide-disabled', '0' ); + } add_action( 'admin_menu', array( $this, 'add_plugin_page' ) ); - add_action( 'admin_init', array( $this, 'admin_init' ) ); + add_action( 'admin_init', array( $this, 'admin_settings' ) ); // Add a link from the plugin page to this plugin's settings page add_filter( 'plugin_row_meta', array( $this, 'plugin_action_links' ), 10, 2 ); @@ -180,7 +185,7 @@ public function user_login_message( $message ) { public function manage_users_columns( $defaults ) { - if (esc_attr( get_option( 'ja-disable-users-setting-hide-disabled' ))) { + if (esc_attr( $this->get_option( 'ja-disable-users-setting-hide-disabled' ))) { $title = __("Click to show disabled accounts."); } else { $title = __("Click to hide disabled accounts."); @@ -235,9 +240,42 @@ public function add_plugin_page() { ) // since we are putting settings on our own page, we also have to define how to print out the settings ); + if (is_multisite() && is_network_admin()) { + $permalink = network_admin_url( 'users.php' ) . '?only_disabled=1'; + } else { + $permalink = admin_url( 'users.php' ) . '?only_disabled=1'; + } global $submenu; - $permalink = admin_url( 'users.php' ).'?only_disabled=1'; - $submenu['users.php'][] = array( 'Disabled Users', 'ja-disable-user-onlydisabled', $permalink ); + $submenu['users.php'][] = array( 'Disabled Users', 'ja-disable-user-onlydisabled', $permalink ); + + } + + /** + * Tells WordPress about a new settings page and what function to call to create it + * + * @since 1.2.0 + */ + public function add_network_plugin_page() { + // This page will be under "Settings" menu. add_options_page is merely a WP wrapper for add_submenu_page specifying the 'options-general' menu as parent + add_submenu_page( + "settings.php", + "Disable Users Settings", // page title + "Disable Users Settings", // menu title + "manage_options", // user capability required to edit these settings + "ja-disable-users-settings", // new page slug + array( + $this, + 'create_settings_page' + ) // since we are putting settings on our own page, we also have to define how to print out the settings + ); + + if (is_multisite() && is_network_admin()) { + $permalink = network_admin_url( 'users.php' ) . '?only_disabled=1'; + } else { + $permalink = admin_url( 'users.php' ) . '?only_disabled=1'; + } + global $submenu; + $submenu['users.php'][] = array( 'Disabled Users', 'ja-disable-user-onlydisabled', $permalink ); } @@ -270,12 +308,19 @@ public function plugin_action_links( $links, $file ) { * @since 1.2.0 */ public function create_settings_page() { + if (is_multisite() && is_network_admin()){ + // network admin page doesn't have the luxury of register_setting api, + // so a custom hook must be created and called to save the setting. + $action = "edit.php?action=ja_disable_users_save"; + } else { + $action = "options.php"; + } ?>

Disable Users - Settings

-
+ 'ja-disable-users-settings', 'updated' => 'true'), network_admin_url('settings.php'))); + exit(); + } + /**toggle_disabled * Adds settings to settings page for this plugin. * @since 1.2.0 */ - public function admin_init() { + public function admin_settings() { add_settings_section( 'ja-disable-users-settings-section', // unique name of section 'Disable Users - Settings', // start of section text shown to user @@ -319,7 +376,7 @@ public function add_setting( $setting_id, $label ) { array( // The array of arguments to pass to the callback. These 3 are referenced in setting_input_checkbox. 'id' => $setting_id, 'label' => $label, - 'value' => esc_attr( get_option( $setting_id )) + 'value' => esc_attr( $this->get_option( $setting_id )) ) ); register_setting( @@ -387,7 +444,7 @@ public function user_query_exceptions($query_obj){ return $query_obj; // force return here. we don't want the user to select 'only disabled' and 'hide disabled', because they would get an empty list. } - if (esc_attr( get_option( 'ja-disable-users-setting-hide-disabled' ))) { + if (esc_attr( $this->get_option( 'ja-disable-users-setting-hide-disabled' ))) { // preference set to hide disabled users by default. now check if they are manually showing them. if ( empty( $_REQUEST[ 'toggle_disabled' ] ) ) { // 'show_disabled' not specified, so exclude disabled users @@ -409,5 +466,17 @@ public function user_query_exceptions($query_obj){ return $query_obj; } + + /** + * If site is multisite, and page is network admin page, return site option. Otherwise, just regular option. + * @param $setting_id + */ + public function get_option($setting_id){ + if (is_multisite() && is_network_admin()){ + return get_site_option($setting_id); + } else { + return get_option($setting_id); + } + } } new ja_disable_users(); \ No newline at end of file From fb185baea4e6a6b7a21c5b2acee58f765ac94f9c Mon Sep 17 00:00:00 2001 From: Stephen Schrauger Date: Wed, 27 Apr 2016 11:55:07 -0400 Subject: [PATCH 06/12] fixes network settings link on plugin page --- init.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/init.php b/init.php index 78ff3fa..a52e21c 100644 --- a/init.php +++ b/init.php @@ -290,11 +290,16 @@ public function add_network_plugin_page() { * @return array */ public function plugin_action_links( $links, $file ) { + if (is_multisite() && is_network_admin()){ + $base_page = network_admin_url("settings.php?page=ja-disable-users-settings"); + } else { + $base_page = admin_url('options-general.php?page=ja-disable-users-settings'); + } if ( strpos( __FILE__, $file ) !== false ) { $links = array_merge( $links, array( - 'settings' => '' . __( 'Settings', 'ja-disable-users-settings') . '' + 'settings' => '' . __( 'Settings', 'ja-disable-users-settings') . '' ) ); } @@ -331,6 +336,9 @@ public function create_settings_page() { 'ja-disable-users-settings', 'updated' => 'true'), network_admin_url('settings.php'))); exit(); } From dfb48f41e468c4cd604d485074c860fa554b48fa Mon Sep 17 00:00:00 2001 From: Stephen Schrauger Date: Wed, 27 Apr 2016 12:23:31 -0400 Subject: [PATCH 07/12] moves add_site_option to wrapper --- init.php | 58 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/init.php b/init.php index a52e21c..d4bb241 100644 --- a/init.php +++ b/init.php @@ -42,18 +42,19 @@ function __construct() { add_action( 'edit_user_profile_update', array( $this, 'user_profile_field_save' ) ); add_action( 'wp_login', array( $this, 'user_login' ), 10, 2 ); add_action( 'manage_users_custom_column', array( $this, 'manage_users_column_content' ), 10, 3 ); + add_action( 'wpmu_users_custom_column', array( $this, 'manage_users_column_content' ), 10, 3 ); add_action( 'admin_footer-users.php', array( $this, 'manage_users_css' ) ); // Filters add_filter( 'login_message', array( $this, 'user_login_message' ) ); add_filter( 'manage_users_columns', array( $this, 'manage_users_columns' ) ); + add_filter( 'wpmu_users_columns', array( $this, 'manage_users_columns' ) ); // Plugin Settings // Register the 'settings' page if (is_multisite()) { add_action( 'network_admin_menu', array( $this, 'add_network_plugin_page' ) ); add_action('network_admin_edit_ja_disable_users_save', array($this, 'save_network_settings_page'), 10, 0); - add_site_option( 'ja-disable-users-setting-hide-disabled', '0' ); } add_action( 'admin_menu', array( $this, 'add_plugin_page' ) ); add_action( 'admin_init', array( $this, 'admin_settings' ) ); @@ -184,13 +185,18 @@ public function user_login_message( $message ) { */ public function manage_users_columns( $defaults ) { - - if (esc_attr( $this->get_option( 'ja-disable-users-setting-hide-disabled' ))) { + if (esc_attr( $this->get_option( 'ja-disable-users-setting-hide-disabled' )) xor (!empty($_REQUEST['toggle_disabled']))) { $title = __("Click to show disabled accounts."); } else { $title = __("Click to hide disabled accounts."); } - $toggle_link = '*'; + if (!empty($_REQUEST['toggle_disabled'])){ + // user has overridden. make the link point to default + $toggle_link = '*'; + } else { + // user has not overridden. make the link point to override + $toggle_link = '*'; + } $defaults['ja_user_disabled'] = __( 'Disabled' . $toggle_link, 'ja_disable_users' ); return $defaults; } @@ -338,20 +344,42 @@ public function create_settings_page() { /** * Network admin pages don't have some settings APIs available, so saving must be done manually. + * @since 1.2.1 */ public function save_network_settings_page(){ if ($_REQUEST['ja-disable-users-setting-hide-disabled']) { // user has set the checkbox. Hide disabled users by default. - update_site_option('ja-disable-users-setting-hide-disabled', "1"); + $this->update_site_option('ja-disable-users-setting-hide-disabled', "1"); } else { // user has unset the checkbox. Show disabled users by default. - update_site_option('ja-disable-users-setting-hide-disabled', "0"); + $this->update_site_option('ja-disable-users-setting-hide-disabled', "0"); } // after saving, redirect to same page (otherwise, it would auto redirect to the network dashboard) wp_redirect(add_query_arg(array('page' => 'ja-disable-users-settings', 'updated' => 'true'), network_admin_url('settings.php'))); exit(); } + /** + * WP update_site_option apparently doesn't work if the option isn't already added (unlike update_option, which auto-adds if not exists). + * So this is a wrapper to add the option if it doesn't exist already. + * @since 1.2.1 + * @param $setting_id + * @param $value + */ + public function update_site_option($setting_id, $value){ + $exists = get_site_option($setting_id, -1); + // get_site_option will return false if the option doesn't exist. + // However, it will also return false if it exists and the option's value is false! + // So we define a default of -1 if the option doesn't exist. As long as the return is + // anything other than -1, the option exists and we must update it. Otherwise, + // we must add it. + if ($exists !== -1){ + update_site_option( $setting_id, $value ); + } else { + add_site_option( $setting_id, $value ); + } + } + /**toggle_disabled * Adds settings to settings page for this plugin. * @since 1.2.0 @@ -453,20 +481,10 @@ public function user_query_exceptions($query_obj){ return $query_obj; // force return here. we don't want the user to select 'only disabled' and 'hide disabled', because they would get an empty list. } - if (esc_attr( $this->get_option( 'ja-disable-users-setting-hide-disabled' ))) { - // preference set to hide disabled users by default. now check if they are manually showing them. - if ( empty( $_REQUEST[ 'toggle_disabled' ] ) ) { - // 'show_disabled' not specified, so exclude disabled users - // search for ja_disable_user=true. if ID is listed, they are disabled. - $query_obj->query_where .= $str_hide_disabled_query; - } - } else { - // preference set to show disabled users by default. now check if they are manually hiding them. - if ( !empty( $_REQUEST[ 'toggle_disabled' ] ) ) { - // 'hide_disabled' specified, so exclude disabled users - // search for ja_disable_user=true. if ID is listed, they are disabled. - $query_obj->query_where .= $str_hide_disabled_query; - } + if ((esc_attr( $this->get_option( 'ja-disable-users-setting-hide-disabled' ))) xor (!empty( $_REQUEST[ 'toggle_disabled' ] ))) { + // preference set to hide disabled users by default, or is unset but override is active + + $query_obj->query_where .= $str_hide_disabled_query; } if ( !empty( $_REQUEST[ 'only_disabled' ] ) ) { $query_obj->query_where .= $str_only_disabled_query; From e1b225a3c6af86b799f44803537987757eba0942 Mon Sep 17 00:00:00 2001 From: Stephen Schrauger Date: Wed, 27 Apr 2016 12:32:24 -0400 Subject: [PATCH 08/12] changes version down to 1.1.2; adds version notes --- init.php | 8 ++++---- readme.txt | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/init.php b/init.php index d4bb241..1357b19 100644 --- a/init.php +++ b/init.php @@ -3,7 +3,7 @@ * Plugin Name: Disable Users * Plugin URI: http://wordpress.org/extend/disable-users * Description: This plugin provides the ability to disable specific user accounts. - * Version: 1.2.1 + * Version: 1.1.1 * Author: Jared Atchison, Stephen Schrauger * Author URI: http://jaredatchison.com * @@ -18,7 +18,7 @@ * GNU General Public License for more details. * * @author Jared Atchison, Stephen Schrauger - * @version 1.2.1 + * @version 1.1.1 * @package JA_DisableUsers * @copyright Copyright (c) 2015, Jared Atchison * @link http://jaredatchison.com @@ -344,7 +344,7 @@ public function create_settings_page() { /** * Network admin pages don't have some settings APIs available, so saving must be done manually. - * @since 1.2.1 + * @since 1.1.2 */ public function save_network_settings_page(){ if ($_REQUEST['ja-disable-users-setting-hide-disabled']) { @@ -362,7 +362,7 @@ public function save_network_settings_page(){ /** * WP update_site_option apparently doesn't work if the option isn't already added (unlike update_option, which auto-adds if not exists). * So this is a wrapper to add the option if it doesn't exist already. - * @since 1.2.1 + * @since 1.1.2 * @param $setting_id * @param $value */ diff --git a/readme.txt b/readme.txt index dcb73a0..6b4507e 100644 --- a/readme.txt +++ b/readme.txt @@ -42,10 +42,13 @@ Yes, there is a filter in place for that, `ja_disable_users_notice`. == Changelog == -= 1.2.1 (03/08/2016) = += 1.1.2 (04/27/2016) = +* Fixed network admin pages for multisite installations + += 1.1.1 (03/08/2016) = * Added menu item to show only disabled users -= 1.2.0 (03/08/2016) = += 1.1.0 (03/08/2016) = * Added plugin setting page ** Preference to hide disabled users by default when viewing All Users From 7c6fb8b2b575d0be65ed2bee102f15a9e79c0759 Mon Sep 17 00:00:00 2001 From: Stephen Schrauger Date: Wed, 27 Apr 2016 12:33:09 -0400 Subject: [PATCH 09/12] version info --- init.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.php b/init.php index 1357b19..baa6d79 100644 --- a/init.php +++ b/init.php @@ -3,7 +3,7 @@ * Plugin Name: Disable Users * Plugin URI: http://wordpress.org/extend/disable-users * Description: This plugin provides the ability to disable specific user accounts. - * Version: 1.1.1 + * Version: 1.1.2 * Author: Jared Atchison, Stephen Schrauger * Author URI: http://jaredatchison.com * @@ -18,7 +18,7 @@ * GNU General Public License for more details. * * @author Jared Atchison, Stephen Schrauger - * @version 1.1.1 + * @version 1.1.2 * @package JA_DisableUsers * @copyright Copyright (c) 2015, Jared Atchison * @link http://jaredatchison.com From 3028972796ace0dde9559e49f38828632a8ab06f Mon Sep 17 00:00:00 2001 From: Stephen Schrauger Date: Thu, 28 Apr 2016 10:59:38 -0400 Subject: [PATCH 10/12] renamed readme to '.md' --- readme.txt => readme.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename readme.txt => readme.md (100%) diff --git a/readme.txt b/readme.md similarity index 100% rename from readme.txt rename to readme.md From 10ddf53ef148f04ae62eb180e50d09f18fb097e0 Mon Sep 17 00:00:00 2001 From: Stephen Schrauger Date: Thu, 28 Apr 2016 11:02:50 -0400 Subject: [PATCH 11/12] Updates headers to markdown --- readme.md | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/readme.md b/readme.md index 6b4507e..38d4fde 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,5 @@ -=== Disable Users === +# Disable Users # + Contributors: jaredatch, schrauger Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AD8KTWTTDX9JL Tags: users, login, disable @@ -9,7 +10,7 @@ License: GPLv2 Provides the ability to disable specific user accounts. -== Description == +## Description ## This plugin gives you the ability to disable specific user accounts via a profile setting. @@ -24,49 +25,49 @@ Disabled users can also be hidden from the All Users listing, either by default **[This plugin is on GitHub!](https://github.com/jaredatch/Disable-Users/)** Pull requests are welcome. If possible please report issues through Github. -== Installation == +## Installation ## 1. Upload `disable-users` to your `/wp-content/plugins/` directory. -1. Edit any user and then look for the "Disable User Account" checkbox. +2. Edit any user and then look for the "Disable User Account" checkbox. -== Frequently Asked Questions == +## Frequently Asked Questions ## -= Can I change the message a disabled user sees? = +### Can I change the message a disabled user sees? ### Yes, there is a filter in place for that, `ja_disable_users_notice`. -== Screenshots == +## Screenshots## 1. User profile setting available to administrators. 2. Message when a disabled user tries to login. -== Changelog == +## Changelog ## -= 1.1.2 (04/27/2016) = +#### 1.1.2 (04/27/2016) #### * Fixed network admin pages for multisite installations -= 1.1.1 (03/08/2016) = +#### 1.1.1 (03/08/2016) #### * Added menu item to show only disabled users -= 1.1.0 (03/08/2016) = +#### 1.1.0 (03/08/2016) #### * Added plugin setting page ** Preference to hide disabled users by default when viewing All Users -= 1.0.5 (11/11/2015) = +#### 1.0.5 (11/11/2015) #### * Added pl_PL transnation - Props Dominik Kocuj -= 1.0.4 (6/21/2015) = +#### 1.0.4 (6/21/2015) #### * Bug fix for Disabled column to manage user screen -= 1.0.3 (6/15/2015) = +#### 1.0.3 (6/15/2015) #### * Added Disabled column to manage user screen. Props @basteln3rk [(flexponsive)](https://www.flexponsive.net). * Cleaned up code slightly and updated README information -= 1.0.2 = +#### 1.0.2 #### * Removed accidental PHP short form -= 1.0.1 = +#### 1.0.1 #### * Fixed notice that would show if WP_DEBUG was on. Props @vegasgeek. -= 1.0.0 = +#### 1.0.0 #### * Initial launch From d7486b5c9cf761ef215a7ec90f8cb4e3d3bcc25d Mon Sep 17 00:00:00 2001 From: Stephen Schrauger Date: Thu, 28 Apr 2016 11:05:03 -0400 Subject: [PATCH 12/12] adds spaces to cause line break --- readme.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index 38d4fde..ea03d99 100644 --- a/readme.md +++ b/readme.md @@ -1,12 +1,12 @@ # Disable Users # -Contributors: jaredatch, schrauger -Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AD8KTWTTDX9JL -Tags: users, login, disable -Requires at least: 4.0.0 -Tested up to: 4.3 -Stable tag: trunk -License: GPLv2 +Contributors: jaredatch, schrauger +Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AD8KTWTTDX9JL +Tags: users, login, disable +Requires at least: 4.0.0 +Tested up to: 4.3 +Stable tag: trunk +License: GPLv2 Provides the ability to disable specific user accounts.