Changeset 3089036
- Timestamp:
- 05/19/2024 04:58:53 PM (20 months ago)
- Location:
- create-temporary-login
- Files:
-
- 24 added
- 5 edited
-
assets/screenshot-1.png (added)
-
assets/screenshot-2.png (added)
-
assets/screenshot-3.png (added)
-
assets/screenshot-4.png (added)
-
assets/screenshot-5.png (added)
-
assets/screenshot-6.png (added)
-
tags/1.0.2 (added)
-
tags/1.0.2/admin (added)
-
tags/1.0.2/admin/css (added)
-
tags/1.0.2/admin/css/admin.css (added)
-
tags/1.0.2/admin/js (added)
-
tags/1.0.2/admin/js/admin.js (added)
-
tags/1.0.2/create-temporary-login.php (added)
-
tags/1.0.2/includes (added)
-
tags/1.0.2/includes/class-admin.php (added)
-
tags/1.0.2/includes/class-create-temporary-login.php (added)
-
tags/1.0.2/includes/class-option.php (added)
-
tags/1.0.2/index.php (added)
-
tags/1.0.2/languages (added)
-
tags/1.0.2/languages/create-temporary-login.pot (added)
-
tags/1.0.2/readme.txt (added)
-
tags/1.0.2/uninstall.php (added)
-
trunk/create-temporary-login.php (modified) (2 diffs)
-
trunk/includes/class-admin.php (modified) (5 diffs)
-
trunk/includes/class-create-temporary-login.php (modified) (1 diff)
-
trunk/includes/class-option.php (modified) (4 diffs)
-
trunk/languages (added)
-
trunk/languages/create-temporary-login.pot (added)
-
trunk/readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
create-temporary-login/trunk/create-temporary-login.php
r3083509 r3089036 1 1 <?php 2 2 /* 3 Plugin Name: WP Bifröst- Create Passwordless Temporary Login Links3 Plugin Name: Bifröst WP - Create Passwordless Temporary Login Links 4 4 Plugin URI: https://wordpress.org/plugins/create-temporary-login 5 5 Description: Create passwordless temporary login links to easily give access to your site's dashboard. 6 Version: 1.0. 16 Version: 1.0.2 7 7 Author: Hakik Zaman 8 8 Author URI: https://profiles.wordpress.org/users/hakik … … 21 21 */ 22 22 if ( ! defined( 'CTLAZ_TEMP_LOGIN_VERSION' ) ) { 23 define( 'CTLAZ_TEMP_LOGIN_VERSION', '1.0. 1' );23 define( 'CTLAZ_TEMP_LOGIN_VERSION', '1.0.2' ); 24 24 } 25 25 -
create-temporary-login/trunk/includes/class-admin.php
r3083509 r3089036 43 43 // Disallow direct login access for Temp Users 44 44 add_filter( 'wp_authenticate_user', array( $this, 'disallow_temporary_user_login' ) ); 45 // Set redirect before the plugin render the plugin settings page 46 add_action( 'admin_init', array( $this,'set_header_redirect' ) ); 45 47 } 46 48 … … 71 73 } 72 74 73 /** 74 * Create Temporary Login Interface 75 */ 76 public function create_temporary_login(){ 75 76 /** 77 * Sets the header redirect. 78 */ 79 public function set_header_redirect(){ 77 80 // If found a user_id as a get delete the user 78 81 if ( isset($_GET['ctl_delete_link_nonce']) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['ctl_delete_link_nonce'] ) ), 'ctl_delete_link') ){ … … 90 93 } 91 94 } 92 93 echo "<h1>".esc_html__( 'Create Temporary Login Settings', 'create-temporary-login' )."</h1>"; 95 } 96 97 /** 98 * Create Temporary Login Interface 99 */ 100 public function create_temporary_login(){ 101 102 echo "<h1>".esc_html__( 'Bifröst WP - Settings (Create Passwordless Temporary Login Links)', 'create-temporary-login' )."</h1>"; 94 103 $other_attributes = array( 'tabindex' => '1' ); 95 104 submit_button( __( 'Generate a link', 'create-temporary-login' ), 'secondary ctl_generate_link', '', true, $other_attributes ); … … 136 145 esc_html__( 'Copied', 'create-temporary-login' ), 137 146 // Human readable time to show how many days are remaining 138 ctlaz_create_temporary_login()->get_option()-> human_readable_duration( $user->ID ),147 ctlaz_create_temporary_login()->get_option()->get_human_readable_link_duration( $user->ID ), 139 148 // Text of the Extend Button 140 149 esc_html__( 'Extend 3 days', 'create-temporary-login' ), … … 182 191 183 192 echo absint( $user_id ); 184 wp_die();193 wp_die(); 185 194 186 195 } -
create-temporary-login/trunk/includes/class-create-temporary-login.php
r3083509 r3089036 49 49 $this->get_option(); 50 50 $this->get_admin(); 51 $this->set_hooks(); 51 52 } 53 54 /** 55 * Sets the hooks. 56 */ 57 public function set_hooks(){ 58 add_action( 'plugins_loaded', array( $this, 'load_textdomain' ), 10 ); 59 } 60 61 /** 62 * Loads a textdomain. 63 */ 64 public function load_textdomain() { 65 load_plugin_textdomain( 'create-temporary-login', false, basename( dirname( CTLAZ_TEMP_LOGIN_FILE ) )."/languages" ); 66 } 52 67 53 68 /** -
create-temporary-login/trunk/includes/class-option.php
r3083509 r3089036 22 22 public function __construct(){ 23 23 // Firing Hooks 24 // $this->hooks();24 $this->set_hooks(); 25 25 } 26 26 27 /** 28 * Sets the hooks. 29 */ 30 public function set_hooks(){ 31 add_action( 'admin_init', array( $this, 'set_temporary_logged_in_user_permission' ), 10 ); 32 } 33 34 /** 35 * Determines whether the specified user id is temporary user. 36 * 37 * @param int $user_ID The user id 38 * 39 * @return bool True if the specified user id is temporary user, False otherwise. 40 */ 27 41 public function is_temporary_user( $user_ID ) : bool { 28 42 return (bool) get_user_meta( $user_ID, 'ctl_user', true ); 29 43 } 30 44 45 /** 46 * Gets the maximum expired time. 47 * 48 * @return int The maximum expired time. 49 */ 31 50 public function get_max_expired_time(): int { 32 51 return current_time( 'timestamp' ) + WEEK_IN_SECONDS; 33 52 } 34 53 54 /** 55 * Determines whether the specified user id is user expired. 56 * 57 * @param int $user_ID The user id 58 * 59 * @return bool True if the specified user id is user expired, False otherwise. 60 */ 35 61 public function is_user_expired( $user_ID ): bool { 36 62 $expiration = $this->get_expiration( $user_ID ); … … 43 69 } 44 70 71 /** 72 * Gets the expiration. 73 * 74 * @param int $user_ID The user id 75 * 76 * @return int | bool Meta ID if the key didn’t exist, true on successful update, false on failure or if the value passed to the function is the same as the one that is already in the database. 77 */ 45 78 public function get_expiration( $user_ID ) { 46 79 return get_user_meta( $user_ID, 'ctl_expiration', true ); 47 80 } 48 81 49 public function human_readable_duration( $user_ID ){ 82 83 84 /** 85 * Gets the human readable link duration. 86 * 87 * @param int $user_ID The user id 88 * 89 * @return mixed The human readable link duration. 90 */ 91 public function get_human_readable_link_duration( $user_ID ){ 50 92 if( $this->is_user_expired( $user_ID ) ){ 51 93 return esc_html__( 'Expired', 'create-temporary-login' ); … … 53 95 return sprintf( 54 96 /* translators: %s: How many days remaining */ 55 esc_html__( 'Will be expired after: %s', ' plugin-slug' ),97 esc_html__( 'Will be expired after: %s', 'create-temporary-login' ), 56 98 wp_kses_post( human_time_diff( $this->get_expiration( $user_ID ), current_time('U') ) ) 57 99 ); 58 100 } 59 101 102 /** 103 * Extends the expiration. 104 * 105 * @param <int> $user_ID The user id 106 * 107 * @return int | bool Meta ID if the key didn’t exist, true on successful update, false on failure or if the value passed to the function is the same as the one that is already in the database. 108 */ 60 109 public function extend_expiration( $user_ID ) { 61 110 $expiration = $this->get_expiration( $user_ID ); … … 76 125 } 77 126 127 128 /** 129 * Sets the temporary logged in user permission. 130 */ 131 public function set_temporary_logged_in_user_permission(){ 132 133 if( $this->is_temporary_user( get_current_user_id() ) ){ 134 135 // Remove a capability from a specific user. 136 $user = new WP_User( get_current_user_id() ); 137 /** 138 * @note `list_users` to revoke entire access of the user menus 139 * 140 * To print the available capabilities for this current user- `print_r($user->get_role_caps());` 141 */ 142 $user->add_cap( 'delete_users', false ); 143 /** 144 * @note for future use 145 * Remove the User menu for temporary users 146 * remove_menu_page( 'users.php' ); 147 */ 148 } 149 150 151 152 } 153 78 154 } -
create-temporary-login/trunk/readme.txt
r3084138 r3089036 1 === WP Bifröst- Create Passwordless Temporary Login Links ===1 === Bifröst WP - Create Passwordless Temporary Login Links === 2 2 Contributors: Hakik 3 3 Tags: temporary login, passwordless login, temporary access, login … … 5 5 Requires at least: 6.2 6 6 Tested up to: 6.5 7 Stable tag: 1.0. 17 Stable tag: 1.0.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 18 18 19 19 [youtube https://www.youtube.com/watch?v=jMTwoAtKlUk] 20 21 20 22 21 How often do you need to allow someone access to your WordPress site? There are many cases when you need to allow people access to your site, including support engineers. … … 45 44 == Changelog == 46 45 46 = 1.0.2 = 47 * Add: Disallow the temporary user to delete an user of the site. 48 * Add: POT file added. 49 * Fix: Text domain for a method. 50 * Fix: Headers already sent warning after deleting a link. 51 47 52 = 1.0.1 = 48 53 * Fix: Plugin file header, sanitize for wp_nonce, prefix related issue, internationalization issues.
Note: See TracChangeset
for help on using the changeset viewer.