Changeset 2944363
- Timestamp:
- 07/27/2023 07:59:43 PM (3 years ago)
- Location:
- disable-user-login
- Files:
-
- 4 added
- 6 edited
- 1 copied
-
tags/1.3.4 (copied) (copied from disable-user-login/trunk)
-
tags/1.3.4/assets/js (added)
-
tags/1.3.4/assets/js/admin.js (added)
-
tags/1.3.4/disable-user-login.php (modified) (1 diff)
-
tags/1.3.4/includes/class-ss-disable-user-login-plugin.php (modified) (6 diffs)
-
tags/1.3.4/readme.txt (modified) (2 diffs)
-
trunk/assets/js (added)
-
trunk/assets/js/admin.js (added)
-
trunk/disable-user-login.php (modified) (1 diff)
-
trunk/includes/class-ss-disable-user-login-plugin.php (modified) (6 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
disable-user-login/tags/1.3.4/disable-user-login.php
r2823022 r2944363 4 4 * Plugin URI: http://wordpress.org/plugins/disable-user-login 5 5 * Description: Provides the ability to disable user accounts and prevent them from logging in. 6 * Version: 1.3. 36 * Version: 1.3.4 7 7 * 8 8 * Author: Saint Systems -
disable-user-login/tags/1.3.4/includes/class-ss-disable-user-login-plugin.php
r2823022 r2944363 16 16 * @var string 17 17 */ 18 private static $version = '1.3. 3';18 private static $version = '1.3.4'; 19 19 20 20 /** … … 60 60 61 61 self::$instance = new SS_Disable_User_Login_Plugin(); 62 self::$instance->define_constants(); 62 63 self::$instance->load_plugin_textdomain(); 63 64 self::$instance->add_hooks(); … … 80 81 81 82 /** 83 * Define Plugin Constants. 84 */ 85 private function define_constants() { 86 87 // Plugin version. 88 $this->define( 'SS_DISABLE_USER_LOGIN_VERSION', self::version() ); 89 90 // Plugin Folder Path. 91 $this->define( 'SS_DISABLE_USER_LOGIN_DIR', plugin_dir_path( SS_DISABLE_USER_LOGIN_FILE ) ); 92 93 // Plugin Folder URL. 94 $this->define( 'SS_DISABLE_USER_LOGIN_URL', plugin_dir_url( SS_DISABLE_USER_LOGIN_FILE ) ); 95 96 } //function define_constants 97 98 /** 99 * Define constant if not already set. 100 * 101 * @param string $name Constant name. 102 * @param string|bool $value Constant value. 103 * @return void 104 */ 105 private function define( $name, $value ) { 106 if ( ! defined( $name ) ) { 107 define( $name, $value ); 108 } 109 } //function define 110 111 /** 82 112 * Setup the plugin action hooks and filters 83 113 */ 84 114 private function add_hooks() { 85 115 86 // Actions 87 add_action( 'edit_user_profile', array( $this, 'add_disabled_field' ) ); 88 add_action( 'personal_options_update', array( $this, 'save_disabled_field' ) ); 89 add_action( 'edit_user_profile_update', array( $this, 'save_disabled_field' ) ); 90 add_filter( 'manage_users_custom_column', array( $this, 'manage_users_column_content' ), 10, 3 ); 91 add_action( 'admin_footer-users.php', array( $this, 'manage_users_css' ) ); 92 add_action( 'admin_notices', array( $this, 'bulk_disable_user_notices' ) ); 116 if ( is_admin() ) { 117 // Actions 118 add_action( 'edit_user_profile', array( $this, 'add_disabled_field' ) ); 119 add_action( 'personal_options_update', array( $this, 'save_disabled_field' ) ); 120 add_action( 'edit_user_profile_update', array( $this, 'save_disabled_field' ) ); 121 add_filter( 'manage_users_custom_column', array( $this, 'manage_users_column_content' ), 10, 3 ); 122 add_action( 'admin_footer-users.php', array( $this, 'manage_users_css' ) ); 123 add_action( 'admin_notices', array( $this, 'bulk_disable_user_notices' ) ); 124 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 125 add_action( 'wp_ajax_ssdul_enable_disable_user', array( $this, 'enable_disable_user' ) ); 126 } 93 127 94 128 // Disabled hook … … 101 135 add_filter( 'bulk_actions-users', array( $this, 'bulk_action_disable_users' ) ); 102 136 add_filter( 'handle_bulk_actions-users', array( $this, 'handle_bulk_disable_users' ), 10, 3 ); 137 add_filter( 'user_row_actions', array( $this, 'add_quick_links' ), 10, 2 ); 103 138 104 139 } //end function add_hooks 140 141 /** 142 * Adds a quick 'enable/disable' link to the user row actions based on the current user status. 143 * 144 * @param [type] $actions 145 * @param [type] $user_object 146 * @return void 147 */ 148 function add_quick_links( $actions, $user_object ) { 149 150 if ( $user_object->ID !== get_current_user_id() ) { 151 $action = 'disable'; 152 $label = __( 'Disable', 'disable-user-login' ); 153 154 if ( $this->is_user_disabled( $user_object->ID ) ) { 155 $action = 'enable'; 156 $label = __( 'Enable', 'disable-user-login' ); 157 } 158 $actions[ 'disable_user_login' ] = "<a class='dul-quick-links' href='#' data-dul-action='$action' data-dul-user-id='$user_object->ID'>" . $label . '</a>'; 159 } 160 return $actions; 161 } 105 162 106 163 /** … … 235 292 236 293 /** 294 * Enable/Disable users from user row actions quick links. 295 */ 296 public function enable_disable_user() { 297 298 check_ajax_referer( 'ssdul_quick_links', 'nonce' ); 299 300 if ( empty( $_POST['data'] ) ) return; 301 302 $data = $_POST['data']; 303 304 $user_id = $data['user_id']; 305 306 $action = $data['action']; 307 308 if ( ! $this->can_disable( $user_id ) ) { 309 $response = array( 310 'error' => sprintf( esc_html__( 'User %s cannot disable user $s.', 'disable-user-login' ), get_current_user_id(), $user_id ) 311 ); 312 wp_send_json( $response); 313 return; 314 } 315 316 $disabled = $action == 'disable' ? 1 : 0; 317 318 // Store disabled status before update 319 $originally_disabled = $this->is_user_disabled( $user_id ); 320 321 // Update the user's disabled status 322 update_user_meta( $user_id, self::$user_meta_key, $disabled ); 323 324 $this->maybe_trigger_enabled_disabled_actions( $user_id, $originally_disabled, $disabled ); 325 326 $response = array( 327 'status_code' => 200, 328 'message' => sprintf( esc_html__( 'Success: user %s %s', 'disable-user-login' ), $user_id, ($disabled ? 'disabled' : 'enabled' ) ), 329 ); 330 wp_send_json( $response, '200' ); 331 } 332 333 /** 237 334 * After login check to see if user account is disabled 238 335 * … … 455 552 } //end function force_logout 456 553 554 /** 555 * Enqueue plugin settings scripts. 556 * 557 * @since 1.3.4 558 * 559 * @access public 560 * @return array $scripts 561 */ 562 public function enqueue_scripts() { 563 564 // Plugin scripts 565 wp_register_script( 'disable-user-login-admin', SS_DISABLE_USER_LOGIN_URL . 'assets/js/admin.js', array( 'jquery' ), time() ) ;//self::version() ); 566 567 $nonces = array( 568 'quick_links' => wp_create_nonce( 'ssdul_quick_links' ), 569 ); 570 571 $ssdul = array( 572 //'messages' => $translations, 573 'nonces' => $nonces, 574 ); 575 576 wp_localize_script( 'disable-user-login-admin', 'SSDUL', $ssdul ); 577 578 // Scripts. 579 wp_enqueue_script( 'disable-user-login-admin' ); 580 581 } //end function scripts 582 457 583 } //end class SS_Disable_User_Login_Plugin -
disable-user-login/tags/1.3.4/readme.txt
r2823022 r2944363 6 6 Tested up to: 6.1.1 7 7 Requires PHP: 5.6 8 Stable tag: 1.3. 38 Stable tag: 1.3.4 9 9 License: GPLv3 10 10 … … 49 49 == Changelog == 50 50 51 = 1.3.4 = 52 * Add user enable/disable quick links. 53 51 54 = 1.3.3 = 52 55 * Bump WP tested version. -
disable-user-login/trunk/disable-user-login.php
r2823022 r2944363 4 4 * Plugin URI: http://wordpress.org/plugins/disable-user-login 5 5 * Description: Provides the ability to disable user accounts and prevent them from logging in. 6 * Version: 1.3. 36 * Version: 1.3.4 7 7 * 8 8 * Author: Saint Systems -
disable-user-login/trunk/includes/class-ss-disable-user-login-plugin.php
r2823022 r2944363 16 16 * @var string 17 17 */ 18 private static $version = '1.3. 3';18 private static $version = '1.3.4'; 19 19 20 20 /** … … 60 60 61 61 self::$instance = new SS_Disable_User_Login_Plugin(); 62 self::$instance->define_constants(); 62 63 self::$instance->load_plugin_textdomain(); 63 64 self::$instance->add_hooks(); … … 80 81 81 82 /** 83 * Define Plugin Constants. 84 */ 85 private function define_constants() { 86 87 // Plugin version. 88 $this->define( 'SS_DISABLE_USER_LOGIN_VERSION', self::version() ); 89 90 // Plugin Folder Path. 91 $this->define( 'SS_DISABLE_USER_LOGIN_DIR', plugin_dir_path( SS_DISABLE_USER_LOGIN_FILE ) ); 92 93 // Plugin Folder URL. 94 $this->define( 'SS_DISABLE_USER_LOGIN_URL', plugin_dir_url( SS_DISABLE_USER_LOGIN_FILE ) ); 95 96 } //function define_constants 97 98 /** 99 * Define constant if not already set. 100 * 101 * @param string $name Constant name. 102 * @param string|bool $value Constant value. 103 * @return void 104 */ 105 private function define( $name, $value ) { 106 if ( ! defined( $name ) ) { 107 define( $name, $value ); 108 } 109 } //function define 110 111 /** 82 112 * Setup the plugin action hooks and filters 83 113 */ 84 114 private function add_hooks() { 85 115 86 // Actions 87 add_action( 'edit_user_profile', array( $this, 'add_disabled_field' ) ); 88 add_action( 'personal_options_update', array( $this, 'save_disabled_field' ) ); 89 add_action( 'edit_user_profile_update', array( $this, 'save_disabled_field' ) ); 90 add_filter( 'manage_users_custom_column', array( $this, 'manage_users_column_content' ), 10, 3 ); 91 add_action( 'admin_footer-users.php', array( $this, 'manage_users_css' ) ); 92 add_action( 'admin_notices', array( $this, 'bulk_disable_user_notices' ) ); 116 if ( is_admin() ) { 117 // Actions 118 add_action( 'edit_user_profile', array( $this, 'add_disabled_field' ) ); 119 add_action( 'personal_options_update', array( $this, 'save_disabled_field' ) ); 120 add_action( 'edit_user_profile_update', array( $this, 'save_disabled_field' ) ); 121 add_filter( 'manage_users_custom_column', array( $this, 'manage_users_column_content' ), 10, 3 ); 122 add_action( 'admin_footer-users.php', array( $this, 'manage_users_css' ) ); 123 add_action( 'admin_notices', array( $this, 'bulk_disable_user_notices' ) ); 124 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 125 add_action( 'wp_ajax_ssdul_enable_disable_user', array( $this, 'enable_disable_user' ) ); 126 } 93 127 94 128 // Disabled hook … … 101 135 add_filter( 'bulk_actions-users', array( $this, 'bulk_action_disable_users' ) ); 102 136 add_filter( 'handle_bulk_actions-users', array( $this, 'handle_bulk_disable_users' ), 10, 3 ); 137 add_filter( 'user_row_actions', array( $this, 'add_quick_links' ), 10, 2 ); 103 138 104 139 } //end function add_hooks 140 141 /** 142 * Adds a quick 'enable/disable' link to the user row actions based on the current user status. 143 * 144 * @param [type] $actions 145 * @param [type] $user_object 146 * @return void 147 */ 148 function add_quick_links( $actions, $user_object ) { 149 150 if ( $user_object->ID !== get_current_user_id() ) { 151 $action = 'disable'; 152 $label = __( 'Disable', 'disable-user-login' ); 153 154 if ( $this->is_user_disabled( $user_object->ID ) ) { 155 $action = 'enable'; 156 $label = __( 'Enable', 'disable-user-login' ); 157 } 158 $actions[ 'disable_user_login' ] = "<a class='dul-quick-links' href='#' data-dul-action='$action' data-dul-user-id='$user_object->ID'>" . $label . '</a>'; 159 } 160 return $actions; 161 } 105 162 106 163 /** … … 235 292 236 293 /** 294 * Enable/Disable users from user row actions quick links. 295 */ 296 public function enable_disable_user() { 297 298 check_ajax_referer( 'ssdul_quick_links', 'nonce' ); 299 300 if ( empty( $_POST['data'] ) ) return; 301 302 $data = $_POST['data']; 303 304 $user_id = $data['user_id']; 305 306 $action = $data['action']; 307 308 if ( ! $this->can_disable( $user_id ) ) { 309 $response = array( 310 'error' => sprintf( esc_html__( 'User %s cannot disable user $s.', 'disable-user-login' ), get_current_user_id(), $user_id ) 311 ); 312 wp_send_json( $response); 313 return; 314 } 315 316 $disabled = $action == 'disable' ? 1 : 0; 317 318 // Store disabled status before update 319 $originally_disabled = $this->is_user_disabled( $user_id ); 320 321 // Update the user's disabled status 322 update_user_meta( $user_id, self::$user_meta_key, $disabled ); 323 324 $this->maybe_trigger_enabled_disabled_actions( $user_id, $originally_disabled, $disabled ); 325 326 $response = array( 327 'status_code' => 200, 328 'message' => sprintf( esc_html__( 'Success: user %s %s', 'disable-user-login' ), $user_id, ($disabled ? 'disabled' : 'enabled' ) ), 329 ); 330 wp_send_json( $response, '200' ); 331 } 332 333 /** 237 334 * After login check to see if user account is disabled 238 335 * … … 455 552 } //end function force_logout 456 553 554 /** 555 * Enqueue plugin settings scripts. 556 * 557 * @since 1.3.4 558 * 559 * @access public 560 * @return array $scripts 561 */ 562 public function enqueue_scripts() { 563 564 // Plugin scripts 565 wp_register_script( 'disable-user-login-admin', SS_DISABLE_USER_LOGIN_URL . 'assets/js/admin.js', array( 'jquery' ), time() ) ;//self::version() ); 566 567 $nonces = array( 568 'quick_links' => wp_create_nonce( 'ssdul_quick_links' ), 569 ); 570 571 $ssdul = array( 572 //'messages' => $translations, 573 'nonces' => $nonces, 574 ); 575 576 wp_localize_script( 'disable-user-login-admin', 'SSDUL', $ssdul ); 577 578 // Scripts. 579 wp_enqueue_script( 'disable-user-login-admin' ); 580 581 } //end function scripts 582 457 583 } //end class SS_Disable_User_Login_Plugin -
disable-user-login/trunk/readme.txt
r2823022 r2944363 6 6 Tested up to: 6.1.1 7 7 Requires PHP: 5.6 8 Stable tag: 1.3. 38 Stable tag: 1.3.4 9 9 License: GPLv3 10 10 … … 49 49 == Changelog == 50 50 51 = 1.3.4 = 52 * Add user enable/disable quick links. 53 51 54 = 1.3.3 = 52 55 * Bump WP tested version.
Note: See TracChangeset
for help on using the changeset viewer.