Version Description
[01-19-2018] =
- Fixed: Parse error: syntax error, unexpected [ (PHP < 5.4)
Download this release
Release Info
Developer | storeapps |
Plugin | Temporary Login Without Password |
Version | 1.5.1 |
Comparing to | |
See all releases |
Code changes from version 1.5 to 1.5.1
- admin/class-wp-temporary-login-without-password-admin.php +129 -62
- admin/css/wp-temporary-login-without-password-admin.css +33 -32
- admin/index.php +7 -1
- admin/js/clipboard.js +1 -1
- admin/js/clipboard.min.js +1 -1
- admin/js/wp-temporary-login-without-password-admin.js +51 -51
- includes/class-wp-temporary-login-without-password-activator.php +1 -1
- includes/class-wp-temporary-login-without-password-common.php +143 -67
- includes/class-wp-temporary-login-without-password-deactivator.php +2 -2
- includes/class-wp-temporary-login-without-password-layout.php +10 -10
- includes/class-wp-temporary-login-without-password-loader.php +12 -6
- includes/class-wp-temporary-login-without-password.php +1 -1
- index.php +6 -1
- public/class-wp-temporary-login-without-password-public.php +13 -11
- readme.txt +5 -1
- templates/admin_settings.php +40 -34
- templates/list_temporary_logins.php +16 -16
- templates/new_login.php +67 -44
- templates/temporary_logins_settings.php +21 -14
- temporary-login-without-password.php +17 -2
- uninstall.php +2 -1
admin/class-wp-temporary-login-without-password-admin.php
CHANGED
@@ -1,22 +1,50 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
class Wp_Temporary_Login_Without_Password_Admin {
|
4 |
|
|
|
5 |
private $plugin_name;
|
|
|
|
|
6 |
private $version;
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
public function __construct( $plugin_name, $version ) {
|
9 |
|
10 |
$this->plugin_name = $plugin_name;
|
11 |
-
$this->version
|
12 |
}
|
13 |
|
|
|
|
|
|
|
|
|
|
|
14 |
public function enqueue_styles() {
|
15 |
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wp-temporary-login-without-password-admin.css', array(), $this->version, 'all' );
|
16 |
|
17 |
wp_enqueue_style( 'jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
|
18 |
}
|
19 |
|
|
|
|
|
|
|
|
|
|
|
20 |
public function enqueue_scripts() {
|
21 |
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wp-temporary-login-without-password-admin.js', array( 'jquery' ), $this->version, false );
|
22 |
wp_enqueue_script( 'clipboardjs', plugin_dir_url( __FILE__ ) . 'js/clipboard.min.js', array( 'jquery' ), $this->version, false );
|
@@ -32,79 +60,96 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
32 |
wp_localize_script( $this->plugin_name, 'data', $data );
|
33 |
}
|
34 |
|
|
|
|
|
|
|
|
|
|
|
35 |
public function admin_menu() {
|
36 |
$current_user_id = get_current_user_id();
|
37 |
if ( ! Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login( $current_user_id ) ) {
|
38 |
-
add_users_page( __( 'Temporary Logins', 'temporary-login-without-password' ), __( 'Temporary Logins', 'temporary-login-without-password' ), apply_filters( 'tempadmin_user_cap', 'manage_options' ), 'wp-temporary-login-without-password', array(
|
|
|
|
|
|
|
39 |
}
|
40 |
}
|
41 |
|
|
|
|
|
|
|
|
|
|
|
42 |
public static function admin_settings() {
|
43 |
-
|
44 |
-
$
|
45 |
-
$_template_file = WTLWP_PLUGIN_DIR . '/templates/admin_settings.php';
|
46 |
$wtlwp_generated_url = ! empty( $_REQUEST['wtlwp_generated_url'] ) ? $_REQUEST['wtlwp_generated_url'] : '';
|
47 |
-
$user_email
|
48 |
-
$tlwp_settings
|
49 |
|
50 |
-
$default_role = ( ! empty( $tlwp_settings ) && isset( $tlwp_settings['default_role'] )) ? $tlwp_settings['default_role'] : 'administrator';
|
51 |
|
52 |
include $_template_file;
|
53 |
}
|
54 |
|
|
|
|
|
|
|
|
|
|
|
55 |
public function create_user() {
|
56 |
|
57 |
if ( empty( $_POST['wtlwp_data'] ) || empty( $_POST['wtlwp-nonce'] ) ) {
|
58 |
return;
|
59 |
}
|
60 |
|
61 |
-
$data
|
62 |
$email = $data['user_email'];
|
63 |
$error = false;
|
64 |
|
65 |
$redirect_link = '';
|
66 |
if ( false == Wp_Temporary_Login_Without_Password_Common::can_manage_wtlwp() ) {
|
67 |
$result = array(
|
68 |
-
'status'
|
69 |
'message' => 'unathorised_access',
|
70 |
);
|
71 |
-
$error
|
72 |
} elseif ( ! wp_verify_nonce( $_POST['wtlwp-nonce'], 'wtlwp_generate_login_url' ) ) {
|
73 |
$result = array(
|
74 |
-
'status'
|
75 |
'message' => 'nonce_failed',
|
76 |
);
|
77 |
-
$error
|
78 |
} elseif ( empty( $data['user_email'] ) ) {
|
79 |
$result = array(
|
80 |
-
'status'
|
81 |
'message' => 'empty_email',
|
82 |
);
|
83 |
-
$error
|
84 |
} elseif ( ! is_email( $email ) ) {
|
85 |
$result = array(
|
86 |
-
'status'
|
87 |
'message' => 'not_valid_email',
|
88 |
);
|
89 |
-
$error
|
90 |
} elseif ( ! empty( $data['user_email'] ) && email_exists( $data['user_email'] ) ) {
|
91 |
$result = array(
|
92 |
-
'status'
|
93 |
'message' => 'email_is_in_use',
|
94 |
);
|
95 |
-
$error
|
96 |
}
|
97 |
|
98 |
if ( ! $error ) {
|
99 |
$user = Wp_Temporary_Login_Without_Password_Common::create_new_user( $data );
|
100 |
if ( ! empty( $user['error'] ) ) {
|
101 |
$result = array(
|
102 |
-
'status'
|
103 |
'message' => 'user_creation_failed',
|
104 |
);
|
105 |
} else {
|
106 |
-
$result
|
107 |
-
'status'
|
108 |
'message' => 'user_created',
|
109 |
);
|
110 |
$redirect_link = Wp_Temporary_Login_Without_Password_Common::get_redirect_link( $result );
|
@@ -121,6 +166,11 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
121 |
exit();
|
122 |
}
|
123 |
|
|
|
|
|
|
|
|
|
|
|
124 |
public function update_tlwp_settings() {
|
125 |
|
126 |
if ( empty( $_POST['tlwp_settings_data'] ) || empty( $_POST['wtlwp-nonce'] ) ) {
|
@@ -131,18 +181,18 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
131 |
|
132 |
$default_role = isset( $data['role'] ) ? $data['role'] : 'administrator';
|
133 |
|
134 |
-
$tlwp_settings =
|
135 |
-
'default_role' => $default_role
|
136 |
-
|
137 |
|
138 |
$update = update_option( 'tlwp_settings', maybe_serialize( $tlwp_settings ), true );
|
139 |
|
140 |
$result = array();
|
141 |
if ( $update ) {
|
142 |
$result = array(
|
143 |
-
'status'
|
144 |
'message' => 'settings_updated',
|
145 |
-
'tab'
|
146 |
);
|
147 |
}
|
148 |
|
@@ -154,28 +204,33 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
154 |
exit();
|
155 |
}
|
156 |
|
|
|
|
|
|
|
|
|
|
|
157 |
public static function delete_user() {
|
158 |
|
159 |
-
if ( (false === Wp_Temporary_Login_Without_Password_Common::can_manage_wtlwp()) || empty( $_REQUEST['wtlwp_action'] ) || ($_REQUEST['wtlwp_action'] != 'delete') || empty( $_REQUEST['user_id'] ) || (absint( $_REQUEST['user_id'] ) == 0) ) {
|
160 |
return;
|
161 |
}
|
162 |
|
163 |
-
$user_id
|
164 |
-
$nonce
|
165 |
$redirect_url = '';
|
166 |
-
$error
|
167 |
if ( ! wp_verify_nonce( $nonce, 'manage-temporary-login_' . $user_id ) ) {
|
168 |
$result = array(
|
169 |
-
'status'
|
170 |
'message' => 'nonce_failed',
|
171 |
);
|
172 |
-
$error
|
173 |
} elseif ( ! Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login( $user_id, false ) ) {
|
174 |
$result = array(
|
175 |
-
'status'
|
176 |
'message' => 'is_not_temporary_login',
|
177 |
);
|
178 |
-
$error
|
179 |
}
|
180 |
|
181 |
if ( ! $error ) {
|
@@ -194,12 +249,12 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
194 |
|
195 |
if ( ! is_wp_error( $delete_user ) ) {
|
196 |
$result = array(
|
197 |
-
'status'
|
198 |
'message' => 'user_deleted',
|
199 |
);
|
200 |
} else {
|
201 |
$result = array(
|
202 |
-
'status'
|
203 |
'message' => 'default_error_message',
|
204 |
);
|
205 |
}
|
@@ -210,31 +265,36 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
210 |
exit();
|
211 |
}
|
212 |
|
|
|
|
|
|
|
|
|
|
|
213 |
public static function manage_temporary_login() {
|
214 |
|
215 |
-
if ( (false === Wp_Temporary_Login_Without_Password_Common::can_manage_wtlwp()) || empty( $_REQUEST['wtlwp_action'] ) || ($_REQUEST['wtlwp_action'] != 'disable' && $_REQUEST['wtlwp_action'] != 'enable') || empty( $_REQUEST['user_id'] ) || (absint( $_REQUEST['user_id'] ) == 0) ) {
|
216 |
return;
|
217 |
}
|
218 |
|
219 |
-
$error
|
220 |
$user_id = absint( $_REQUEST['user_id'] );
|
221 |
-
$action
|
222 |
-
$nonce
|
223 |
|
224 |
$is_valid_temporary_user = Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login( $user_id, false );
|
225 |
|
226 |
if ( ! $is_valid_temporary_user ) {
|
227 |
$result = array(
|
228 |
-
'status'
|
229 |
'message' => 'is_not_temporary_login',
|
230 |
);
|
231 |
-
$error
|
232 |
} elseif ( ! wp_verify_nonce( $nonce, 'manage-temporary-login_' . $user_id ) ) {
|
233 |
$result = array(
|
234 |
-
'status'
|
235 |
'message' => 'nonce_failed',
|
236 |
);
|
237 |
-
$error
|
238 |
}
|
239 |
|
240 |
if ( ! $error ) {
|
@@ -242,37 +302,37 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
242 |
$disable_login = Wp_Temporary_Login_Without_Password_Common::manage_login( absint( $user_id ), 'disable' );
|
243 |
if ( $disable_login ) {
|
244 |
$result = array(
|
245 |
-
'status'
|
246 |
'message' => 'login_disabled',
|
247 |
);
|
248 |
} else {
|
249 |
$result = array(
|
250 |
-
'status'
|
251 |
'message' => 'default_error_message',
|
252 |
);
|
253 |
-
$error
|
254 |
}
|
255 |
} elseif ( $action == 'enable' ) {
|
256 |
$enable_login = Wp_Temporary_Login_Without_Password_Common::manage_login( absint( $user_id ), 'enable' );
|
257 |
|
258 |
if ( $enable_login ) {
|
259 |
$result = array(
|
260 |
-
'status'
|
261 |
'message' => 'login_enabled',
|
262 |
);
|
263 |
} else {
|
264 |
$result = array(
|
265 |
-
'status'
|
266 |
'message' => 'default_error_message',
|
267 |
);
|
268 |
-
$error
|
269 |
}
|
270 |
} else {
|
271 |
$result = array(
|
272 |
-
'status'
|
273 |
'message' => 'invalid_action',
|
274 |
);
|
275 |
-
$error
|
276 |
}// End if().
|
277 |
}// End if().
|
278 |
|
@@ -281,14 +341,19 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
281 |
exit();
|
282 |
}
|
283 |
|
|
|
|
|
|
|
|
|
|
|
284 |
public function display_admin_notices() {
|
285 |
|
286 |
-
if ( empty( $_REQUEST['page'] ) || (empty( $_REQUEST['page'] ) && $_REQUEST['page'] !== 'wp-temporary-login-without-password') || ! isset( $_REQUEST['wtlwp_message'] ) || ( ! isset( $_REQUEST['wtlwp_error'] ) && ! isset( $_REQUEST['wtlwp_success'] )) ) {
|
287 |
return;
|
288 |
}
|
289 |
|
290 |
-
$class
|
291 |
-
$error
|
292 |
$success = ! empty( $_REQUEST['wtlwp_success'] ) ? true : false;
|
293 |
if ( $error ) {
|
294 |
$message_type = ! empty( $_REQUEST['wtlwp_message'] ) ? $_REQUEST['wtlwp_message'] : 'default_error_message';
|
@@ -397,7 +462,9 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
397 |
* Change the admin footer text on temporary login admin pages.
|
398 |
*
|
399 |
* @since 1.4.3
|
|
|
400 |
* @param string $footer_text
|
|
|
401 |
* @return string
|
402 |
*/
|
403 |
public function admin_footer_text( $footer_text ) {
|
@@ -408,7 +475,7 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
408 |
|
409 |
$can_ask_for_review = self::can_ask_for_review();
|
410 |
|
411 |
-
|
412 |
if ( $can_ask_for_review ) {
|
413 |
$footer_text = sprintf( __( 'If you like <strong>Temporary Login Without Password</strong> plugin, please leave us a %s rating. A huge thanks in advance!', 'temporary-login-without-password' ), '<a href="https://wordpress.org/support/plugin/temporary-login-without-password/reviews" target="_blank" class="tlwp-rating-link" data-rated="' . esc_attr__( 'Thank You :) ', 'temporary-login-without-password' ) . '">★★★★★</a>' );
|
414 |
} else {
|
@@ -442,14 +509,14 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
442 |
*/
|
443 |
public static function can_ask_for_review() {
|
444 |
|
445 |
-
$tlwp_nobug
|
446 |
-
$tlwp_rated
|
447 |
$tlwp_rated_header = get_option( 'tlwp_admin_header_text_rated', false );
|
448 |
|
449 |
$temporary_logins = Wp_Temporary_Login_Without_Password_Common::get_temporary_logins();
|
450 |
-
$total_logins
|
451 |
|
452 |
-
if ( $tlwp_nobug || $tlwp_rated || $tlwp_rated_header || ($total_logins < 3) ) {
|
453 |
return false;
|
454 |
}
|
455 |
|
@@ -502,7 +569,7 @@ class Wp_Temporary_Login_Without_Password_Admin {
|
|
502 |
public function disable_plugin_deactivation( $actions, $plugin_file, $plugin_data, $context ) {
|
503 |
|
504 |
$current_user_id = get_current_user_id();
|
505 |
-
if ( Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login( $current_user_id ) && ($plugin_file === 'temporary-login-without-password/temporary-login-without-password.php') ) {
|
506 |
unset( $actions['deactivate'] );
|
507 |
echo "<script> jQuery(document).ready(function() { jQuery('table.plugins tbody#the-list tr[data-slug=temporary-login-without-password] th.check-column input').attr('disabled', true); }); </script>";
|
508 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Main Temporary Login Without Password Admin Class
|
5 |
+
*
|
6 |
+
* Manage settings, Temporary Logins
|
7 |
+
*
|
8 |
+
* @since 1.0
|
9 |
+
* @package Temporary Login Without Password
|
10 |
+
*/
|
11 |
class Wp_Temporary_Login_Without_Password_Admin {
|
12 |
|
13 |
+
/* @var $plugin_name Wp_Temporary_Login_Without_Password_Admin */
|
14 |
private $plugin_name;
|
15 |
+
|
16 |
+
/* @var $version Wp_Temporary_Login_Without_Password_Admin */
|
17 |
private $version;
|
18 |
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
* @param string $plugin_name
|
22 |
+
* @param string $version
|
23 |
+
*
|
24 |
+
* @since 1.0
|
25 |
+
*/
|
26 |
public function __construct( $plugin_name, $version ) {
|
27 |
|
28 |
$this->plugin_name = $plugin_name;
|
29 |
+
$this->version = $version;
|
30 |
}
|
31 |
|
32 |
+
/**
|
33 |
+
* Enqueue CSS
|
34 |
+
*
|
35 |
+
* @since 1.0
|
36 |
+
*/
|
37 |
public function enqueue_styles() {
|
38 |
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wp-temporary-login-without-password-admin.css', array(), $this->version, 'all' );
|
39 |
|
40 |
wp_enqueue_style( 'jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
|
41 |
}
|
42 |
|
43 |
+
/**
|
44 |
+
* Enqueue JS
|
45 |
+
*
|
46 |
+
* @since 1.0
|
47 |
+
*/
|
48 |
public function enqueue_scripts() {
|
49 |
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wp-temporary-login-without-password-admin.js', array( 'jquery' ), $this->version, false );
|
50 |
wp_enqueue_script( 'clipboardjs', plugin_dir_url( __FILE__ ) . 'js/clipboard.min.js', array( 'jquery' ), $this->version, false );
|
60 |
wp_localize_script( $this->plugin_name, 'data', $data );
|
61 |
}
|
62 |
|
63 |
+
/**
|
64 |
+
* Add admin menu for 'Temporary Logins' inside users section
|
65 |
+
*
|
66 |
+
* @since 1.0
|
67 |
+
*/
|
68 |
public function admin_menu() {
|
69 |
$current_user_id = get_current_user_id();
|
70 |
if ( ! Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login( $current_user_id ) ) {
|
71 |
+
add_users_page( __( 'Temporary Logins', 'temporary-login-without-password' ), __( 'Temporary Logins', 'temporary-login-without-password' ), apply_filters( 'tempadmin_user_cap', 'manage_options' ), 'wp-temporary-login-without-password', array(
|
72 |
+
__class__,
|
73 |
+
'admin_settings'
|
74 |
+
) );
|
75 |
}
|
76 |
}
|
77 |
|
78 |
+
/**
|
79 |
+
* Manage admin settings
|
80 |
+
*
|
81 |
+
* @since 1.0
|
82 |
+
*/
|
83 |
public static function admin_settings() {
|
84 |
+
$active_tab = ! empty( $_GET['tab'] ) ? $_GET['tab'] : 'home';
|
85 |
+
$_template_file = WTLWP_PLUGIN_DIR . '/templates/admin_settings.php';
|
|
|
86 |
$wtlwp_generated_url = ! empty( $_REQUEST['wtlwp_generated_url'] ) ? $_REQUEST['wtlwp_generated_url'] : '';
|
87 |
+
$user_email = ! empty( $_REQUEST['user_email'] ) ? $_REQUEST['user_email'] : '';
|
88 |
+
$tlwp_settings = maybe_unserialize( get_option( 'tlwp_settings', array() ) );
|
89 |
|
90 |
+
$default_role = ( ! empty( $tlwp_settings ) && isset( $tlwp_settings['default_role'] ) ) ? $tlwp_settings['default_role'] : 'administrator';
|
91 |
|
92 |
include $_template_file;
|
93 |
}
|
94 |
|
95 |
+
/**
|
96 |
+
* Create a Temporary user
|
97 |
+
*
|
98 |
+
* @since 1.0
|
99 |
+
*/
|
100 |
public function create_user() {
|
101 |
|
102 |
if ( empty( $_POST['wtlwp_data'] ) || empty( $_POST['wtlwp-nonce'] ) ) {
|
103 |
return;
|
104 |
}
|
105 |
|
106 |
+
$data = $_POST['wtlwp_data'];
|
107 |
$email = $data['user_email'];
|
108 |
$error = false;
|
109 |
|
110 |
$redirect_link = '';
|
111 |
if ( false == Wp_Temporary_Login_Without_Password_Common::can_manage_wtlwp() ) {
|
112 |
$result = array(
|
113 |
+
'status' => 'error',
|
114 |
'message' => 'unathorised_access',
|
115 |
);
|
116 |
+
$error = true;
|
117 |
} elseif ( ! wp_verify_nonce( $_POST['wtlwp-nonce'], 'wtlwp_generate_login_url' ) ) {
|
118 |
$result = array(
|
119 |
+
'status' => 'error',
|
120 |
'message' => 'nonce_failed',
|
121 |
);
|
122 |
+
$error = true;
|
123 |
} elseif ( empty( $data['user_email'] ) ) {
|
124 |
$result = array(
|
125 |
+
'status' => 'error',
|
126 |
'message' => 'empty_email',
|
127 |
);
|
128 |
+
$error = true;
|
129 |
} elseif ( ! is_email( $email ) ) {
|
130 |
$result = array(
|
131 |
+
'status' => 'error',
|
132 |
'message' => 'not_valid_email',
|
133 |
);
|
134 |
+
$error = true;
|
135 |
} elseif ( ! empty( $data['user_email'] ) && email_exists( $data['user_email'] ) ) {
|
136 |
$result = array(
|
137 |
+
'status' => 'error',
|
138 |
'message' => 'email_is_in_use',
|
139 |
);
|
140 |
+
$error = true;
|
141 |
}
|
142 |
|
143 |
if ( ! $error ) {
|
144 |
$user = Wp_Temporary_Login_Without_Password_Common::create_new_user( $data );
|
145 |
if ( ! empty( $user['error'] ) ) {
|
146 |
$result = array(
|
147 |
+
'status' => 'error',
|
148 |
'message' => 'user_creation_failed',
|
149 |
);
|
150 |
} else {
|
151 |
+
$result = array(
|
152 |
+
'status' => 'success',
|
153 |
'message' => 'user_created',
|
154 |
);
|
155 |
$redirect_link = Wp_Temporary_Login_Without_Password_Common::get_redirect_link( $result );
|
166 |
exit();
|
167 |
}
|
168 |
|
169 |
+
/**
|
170 |
+
* Manage settings
|
171 |
+
*
|
172 |
+
* @since 1.4.6
|
173 |
+
*/
|
174 |
public function update_tlwp_settings() {
|
175 |
|
176 |
if ( empty( $_POST['tlwp_settings_data'] ) || empty( $_POST['wtlwp-nonce'] ) ) {
|
181 |
|
182 |
$default_role = isset( $data['role'] ) ? $data['role'] : 'administrator';
|
183 |
|
184 |
+
$tlwp_settings = array(
|
185 |
+
'default_role' => $default_role
|
186 |
+
);
|
187 |
|
188 |
$update = update_option( 'tlwp_settings', maybe_serialize( $tlwp_settings ), true );
|
189 |
|
190 |
$result = array();
|
191 |
if ( $update ) {
|
192 |
$result = array(
|
193 |
+
'status' => 'success',
|
194 |
'message' => 'settings_updated',
|
195 |
+
'tab' => 'settings',
|
196 |
);
|
197 |
}
|
198 |
|
204 |
exit();
|
205 |
}
|
206 |
|
207 |
+
/**
|
208 |
+
* Delete temporary user.
|
209 |
+
*
|
210 |
+
* @since 1.0
|
211 |
+
*/
|
212 |
public static function delete_user() {
|
213 |
|
214 |
+
if ( ( false === Wp_Temporary_Login_Without_Password_Common::can_manage_wtlwp() ) || empty( $_REQUEST['wtlwp_action'] ) || ( $_REQUEST['wtlwp_action'] != 'delete' ) || empty( $_REQUEST['user_id'] ) || ( absint( $_REQUEST['user_id'] ) == 0 ) ) {
|
215 |
return;
|
216 |
}
|
217 |
|
218 |
+
$user_id = absint( $_REQUEST['user_id'] );
|
219 |
+
$nonce = $_REQUEST['manage-temporary-login'];
|
220 |
$redirect_url = '';
|
221 |
+
$error = false;
|
222 |
if ( ! wp_verify_nonce( $nonce, 'manage-temporary-login_' . $user_id ) ) {
|
223 |
$result = array(
|
224 |
+
'status' => 'error',
|
225 |
'message' => 'nonce_failed',
|
226 |
);
|
227 |
+
$error = true;
|
228 |
} elseif ( ! Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login( $user_id, false ) ) {
|
229 |
$result = array(
|
230 |
+
'status' => 'error',
|
231 |
'message' => 'is_not_temporary_login',
|
232 |
);
|
233 |
+
$error = true;
|
234 |
}
|
235 |
|
236 |
if ( ! $error ) {
|
249 |
|
250 |
if ( ! is_wp_error( $delete_user ) ) {
|
251 |
$result = array(
|
252 |
+
'status' => 'success',
|
253 |
'message' => 'user_deleted',
|
254 |
);
|
255 |
} else {
|
256 |
$result = array(
|
257 |
+
'status' => 'error',
|
258 |
'message' => 'default_error_message',
|
259 |
);
|
260 |
}
|
265 |
exit();
|
266 |
}
|
267 |
|
268 |
+
/**
|
269 |
+
* Manage temporary logins
|
270 |
+
*
|
271 |
+
* @since 1.0
|
272 |
+
*/
|
273 |
public static function manage_temporary_login() {
|
274 |
|
275 |
+
if ( ( false === Wp_Temporary_Login_Without_Password_Common::can_manage_wtlwp() ) || empty( $_REQUEST['wtlwp_action'] ) || ( $_REQUEST['wtlwp_action'] != 'disable' && $_REQUEST['wtlwp_action'] != 'enable' ) || empty( $_REQUEST['user_id'] ) || ( absint( $_REQUEST['user_id'] ) == 0 ) ) {
|
276 |
return;
|
277 |
}
|
278 |
|
279 |
+
$error = false;
|
280 |
$user_id = absint( $_REQUEST['user_id'] );
|
281 |
+
$action = $_REQUEST['wtlwp_action'];
|
282 |
+
$nonce = $_REQUEST['manage-temporary-login'];
|
283 |
|
284 |
$is_valid_temporary_user = Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login( $user_id, false );
|
285 |
|
286 |
if ( ! $is_valid_temporary_user ) {
|
287 |
$result = array(
|
288 |
+
'status' => 'error',
|
289 |
'message' => 'is_not_temporary_login',
|
290 |
);
|
291 |
+
$error = true;
|
292 |
} elseif ( ! wp_verify_nonce( $nonce, 'manage-temporary-login_' . $user_id ) ) {
|
293 |
$result = array(
|
294 |
+
'status' => 'error',
|
295 |
'message' => 'nonce_failed',
|
296 |
);
|
297 |
+
$error = true;
|
298 |
}
|
299 |
|
300 |
if ( ! $error ) {
|
302 |
$disable_login = Wp_Temporary_Login_Without_Password_Common::manage_login( absint( $user_id ), 'disable' );
|
303 |
if ( $disable_login ) {
|
304 |
$result = array(
|
305 |
+
'status' => 'success',
|
306 |
'message' => 'login_disabled',
|
307 |
);
|
308 |
} else {
|
309 |
$result = array(
|
310 |
+
'status' => 'error',
|
311 |
'message' => 'default_error_message',
|
312 |
);
|
313 |
+
$error = true;
|
314 |
}
|
315 |
} elseif ( $action == 'enable' ) {
|
316 |
$enable_login = Wp_Temporary_Login_Without_Password_Common::manage_login( absint( $user_id ), 'enable' );
|
317 |
|
318 |
if ( $enable_login ) {
|
319 |
$result = array(
|
320 |
+
'status' => 'success',
|
321 |
'message' => 'login_enabled',
|
322 |
);
|
323 |
} else {
|
324 |
$result = array(
|
325 |
+
'status' => 'error',
|
326 |
'message' => 'default_error_message',
|
327 |
);
|
328 |
+
$error = true;
|
329 |
}
|
330 |
} else {
|
331 |
$result = array(
|
332 |
+
'status' => 'error',
|
333 |
'message' => 'invalid_action',
|
334 |
);
|
335 |
+
$error = true;
|
336 |
}// End if().
|
337 |
}// End if().
|
338 |
|
341 |
exit();
|
342 |
}
|
343 |
|
344 |
+
/**
|
345 |
+
* Display Success/ Error message
|
346 |
+
*
|
347 |
+
* @since 1.0
|
348 |
+
*/
|
349 |
public function display_admin_notices() {
|
350 |
|
351 |
+
if ( empty( $_REQUEST['page'] ) || ( empty( $_REQUEST['page'] ) && $_REQUEST['page'] !== 'wp-temporary-login-without-password' ) || ! isset( $_REQUEST['wtlwp_message'] ) || ( ! isset( $_REQUEST['wtlwp_error'] ) && ! isset( $_REQUEST['wtlwp_success'] ) ) ) {
|
352 |
return;
|
353 |
}
|
354 |
|
355 |
+
$class = $message = '';
|
356 |
+
$error = ! empty( $_REQUEST['wtlwp_error'] ) ? true : false;
|
357 |
$success = ! empty( $_REQUEST['wtlwp_success'] ) ? true : false;
|
358 |
if ( $error ) {
|
359 |
$message_type = ! empty( $_REQUEST['wtlwp_message'] ) ? $_REQUEST['wtlwp_message'] : 'default_error_message';
|
462 |
* Change the admin footer text on temporary login admin pages.
|
463 |
*
|
464 |
* @since 1.4.3
|
465 |
+
*
|
466 |
* @param string $footer_text
|
467 |
+
*
|
468 |
* @return string
|
469 |
*/
|
470 |
public function admin_footer_text( $footer_text ) {
|
475 |
|
476 |
$can_ask_for_review = self::can_ask_for_review();
|
477 |
|
478 |
+
// Change the footer text
|
479 |
if ( $can_ask_for_review ) {
|
480 |
$footer_text = sprintf( __( 'If you like <strong>Temporary Login Without Password</strong> plugin, please leave us a %s rating. A huge thanks in advance!', 'temporary-login-without-password' ), '<a href="https://wordpress.org/support/plugin/temporary-login-without-password/reviews" target="_blank" class="tlwp-rating-link" data-rated="' . esc_attr__( 'Thank You :) ', 'temporary-login-without-password' ) . '">★★★★★</a>' );
|
481 |
} else {
|
509 |
*/
|
510 |
public static function can_ask_for_review() {
|
511 |
|
512 |
+
$tlwp_nobug = get_option( 'tlwp_no_bug', false );
|
513 |
+
$tlwp_rated = get_option( 'tlwp_admin_footer_text_rated', false );
|
514 |
$tlwp_rated_header = get_option( 'tlwp_admin_header_text_rated', false );
|
515 |
|
516 |
$temporary_logins = Wp_Temporary_Login_Without_Password_Common::get_temporary_logins();
|
517 |
+
$total_logins = count( $temporary_logins );
|
518 |
|
519 |
+
if ( $tlwp_nobug || $tlwp_rated || $tlwp_rated_header || ( $total_logins < 3 ) ) {
|
520 |
return false;
|
521 |
}
|
522 |
|
569 |
public function disable_plugin_deactivation( $actions, $plugin_file, $plugin_data, $context ) {
|
570 |
|
571 |
$current_user_id = get_current_user_id();
|
572 |
+
if ( Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login( $current_user_id ) && ( $plugin_file === 'temporary-login-without-password/temporary-login-without-password.php' ) ) {
|
573 |
unset( $actions['deactivate'] );
|
574 |
echo "<script> jQuery(document).ready(function() { jQuery('table.plugins tbody#the-list tr[data-slug=temporary-login-without-password] th.check-column input').attr('disabled', true); }); </script>";
|
575 |
}
|
admin/css/wp-temporary-login-without-password-admin.css
CHANGED
@@ -1,81 +1,82 @@
|
|
1 |
.new-wtlwp-form {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
}
|
7 |
|
8 |
.wtlwp-form-input {
|
9 |
-
|
10 |
}
|
|
|
11 |
.widefat .wtlwp-status {
|
12 |
-
|
13 |
}
|
14 |
|
15 |
.wtlwp-status-active {
|
16 |
-
|
17 |
}
|
18 |
|
19 |
.wtlwp-status-expired {
|
20 |
-
|
21 |
}
|
22 |
|
23 |
.wtlwp-status:after {
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
}
|
35 |
|
36 |
.wtlwp-status-active:after {
|
37 |
-
|
38 |
-
|
39 |
}
|
40 |
|
41 |
.wtlwp-status-expired:after {
|
42 |
-
|
43 |
-
|
44 |
}
|
45 |
|
46 |
.cancel-new-login-form {
|
47 |
-
|
48 |
}
|
49 |
|
50 |
.wtlwp-wide-input {
|
51 |
-
|
52 |
}
|
53 |
|
54 |
.generated-wtlwp-login-link {
|
55 |
-
|
56 |
-
|
57 |
}
|
58 |
|
59 |
.wtlwp-form-row {
|
60 |
-
|
61 |
}
|
62 |
|
63 |
.wtlwp-form-submit-button {
|
64 |
-
|
65 |
}
|
66 |
|
67 |
.wtlwp-user-login {
|
68 |
-
|
69 |
}
|
70 |
|
71 |
.wtlwp-copy-to-clipboard, .wtlwp-click-to-copy-btn {
|
72 |
-
|
73 |
}
|
74 |
|
75 |
.wtlwp-copy-to-clipboard:hover {
|
76 |
-
|
77 |
}
|
78 |
|
79 |
.copied-text-message {
|
80 |
-
|
81 |
}
|
1 |
.new-wtlwp-form {
|
2 |
+
border: 1px solid;
|
3 |
+
padding: 10px;
|
4 |
+
background-color: white;
|
5 |
+
display: none;
|
6 |
}
|
7 |
|
8 |
.wtlwp-form-input {
|
9 |
+
width: 300px !important;
|
10 |
}
|
11 |
+
|
12 |
.widefat .wtlwp-status {
|
13 |
+
width: 40px;
|
14 |
}
|
15 |
|
16 |
.wtlwp-status-active {
|
17 |
+
color: #008000 !important;
|
18 |
}
|
19 |
|
20 |
.wtlwp-status-expired {
|
21 |
+
color: #FF0000 !important;
|
22 |
}
|
23 |
|
24 |
.wtlwp-status:after {
|
25 |
+
border-radius: 32px;
|
26 |
+
color: #fff;
|
27 |
+
display: block;
|
28 |
+
font-size: 11px;
|
29 |
+
font-weight: bold;
|
30 |
+
height: 16px;
|
31 |
+
line-height: 17px;
|
32 |
+
margin-left: 8px;
|
33 |
+
text-align: center;
|
34 |
+
width: 16px;
|
35 |
}
|
36 |
|
37 |
.wtlwp-status-active:after {
|
38 |
+
background: #008000 none repeat scroll 0 0;
|
39 |
+
content: "";
|
40 |
}
|
41 |
|
42 |
.wtlwp-status-expired:after {
|
43 |
+
background: #FF0000 none repeat scroll 0 0;
|
44 |
+
content: "";
|
45 |
}
|
46 |
|
47 |
.cancel-new-login-form {
|
48 |
+
cursor: pointer;
|
49 |
}
|
50 |
|
51 |
.wtlwp-wide-input {
|
52 |
+
width: 60%;
|
53 |
}
|
54 |
|
55 |
.generated-wtlwp-login-link {
|
56 |
+
border: 1px solid;
|
57 |
+
padding: 10px 10px 10px 10px;
|
58 |
}
|
59 |
|
60 |
.wtlwp-form-row {
|
61 |
+
padding-left: 20px !important;
|
62 |
}
|
63 |
|
64 |
.wtlwp-form-submit-button {
|
65 |
+
width: 115px;
|
66 |
}
|
67 |
|
68 |
.wtlwp-user-login {
|
69 |
+
font-size: 12px;
|
70 |
}
|
71 |
|
72 |
.wtlwp-copy-to-clipboard, .wtlwp-click-to-copy-btn {
|
73 |
+
cursor: pointer;
|
74 |
}
|
75 |
|
76 |
.wtlwp-copy-to-clipboard:hover {
|
77 |
+
color: #0073aa;
|
78 |
}
|
79 |
|
80 |
.copied-text-message {
|
81 |
+
padding: 20px;
|
82 |
}
|
admin/index.php
CHANGED
@@ -1 +1,7 @@
|
|
1 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silence is golden.
|
4 |
+
*
|
5 |
+
* @package Temporary Login Without Password
|
6 |
+
* @since 1.0
|
7 |
+
*/
|
admin/js/clipboard.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
|
2 |
* clipboard.js v1.5.12
|
3 |
* https://zenorocha.github.io/clipboard.js
|
4 |
*
|
1 |
+
/**
|
2 |
* clipboard.js v1.5.12
|
3 |
* https://zenorocha.github.io/clipboard.js
|
4 |
*
|
admin/js/clipboard.min.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
|
2 |
* clipboard.js v1.5.12
|
3 |
* https://zenorocha.github.io/clipboard.js
|
4 |
*
|
1 |
+
/**
|
2 |
* clipboard.js v1.5.12
|
3 |
* https://zenorocha.github.io/clipboard.js
|
4 |
*
|
admin/js/wp-temporary-login-without-password-admin.js
CHANGED
@@ -1,65 +1,65 @@
|
|
1 |
-
(
|
2 |
-
|
3 |
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
|
17 |
-
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
-
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
|
64 |
-
|
65 |
-
}
|
1 |
+
(function ($) {
|
2 |
+
'use strict';
|
3 |
|
4 |
+
jQuery(document).ready(function () {
|
5 |
|
6 |
+
// jQuery('#new-wtlwp-form').hide();
|
7 |
+
jQuery('#add-new-wtlwp-form-button').click(function () {
|
8 |
+
jQuery('#new-wtlwp-form').show();
|
9 |
+
});
|
10 |
|
11 |
+
jQuery('#cancel-new-login-form').click(function () {
|
12 |
+
jQuery('#new-wtlwp-form').hide();
|
13 |
+
});
|
14 |
|
15 |
+
if (jQuery('.wtlwp-click-to-copy-btn').get(0)) {
|
16 |
|
17 |
+
var clipboard = new Clipboard('.wtlwp-click-to-copy-btn');
|
18 |
|
19 |
+
clipboard.on('success', function (e) {
|
20 |
+
var elem = e.trigger;
|
21 |
+
var className = elem.getAttribute('class');
|
22 |
+
jQuery('#copied-text-message-' + className).text('Copied').fadeIn();
|
23 |
+
jQuery('#copied-text-message-' + className).fadeOut('slow');
|
24 |
+
});
|
25 |
+
}
|
26 |
|
27 |
+
if (jQuery('.wtlwp-copy-to-clipboard').get(0)) {
|
28 |
+
var clipboard_link = new Clipboard('.wtlwp-copy-to-clipboard');
|
29 |
|
30 |
+
clipboard_link.on('success', function (e) {
|
31 |
+
var elem = e.trigger;
|
32 |
+
var id = elem.getAttribute('id');
|
33 |
+
jQuery('#copied-' + id).text('Copied').fadeIn();
|
34 |
+
jQuery('#copied-' + id).fadeOut('slow');
|
35 |
+
});
|
36 |
+
}
|
37 |
|
38 |
+
jQuery('#user-expiry-time').change(function () {
|
39 |
|
40 |
+
var value = jQuery(this).val();
|
41 |
+
if (value === 'custom_date') {
|
42 |
+
var tomorrowDate = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);
|
43 |
+
jQuery('.example-datepicker').datepicker({
|
44 |
+
dateFormat: 'yy-mm-dd',
|
45 |
+
minDate: tomorrowDate
|
46 |
+
});
|
47 |
+
jQuery('#custom-date-picker').show();
|
48 |
+
} else {
|
49 |
+
jQuery('#custom-date-picker').hide();
|
50 |
+
}
|
51 |
|
52 |
+
});
|
53 |
|
54 |
+
jQuery('a.tlwp-rating-link').click(function () {
|
55 |
+
jQuery.post(data.admin_ajax_url, {action: 'tlwp_rated'});
|
56 |
+
jQuery(this).parent().text(jQuery(this).data('rated'));
|
57 |
+
});
|
58 |
|
59 |
+
jQuery('a.tlwp-rating-link-header').click(function () {
|
60 |
+
jQuery.post(data.admin_ajax_url, {action: 'tlwp_reivew_header'});
|
61 |
+
jQuery(this).parent().text(jQuery(this).data('rated'));
|
62 |
+
});
|
63 |
|
64 |
+
});
|
65 |
+
})(jQuery);
|
includes/class-wp-temporary-login-without-password-activator.php
CHANGED
@@ -9,7 +9,7 @@ class Wp_Temporary_Login_Without_Password_Activator {
|
|
9 |
if ( count( $temporary_logins_data ) > 0 ) {
|
10 |
foreach ( $temporary_logins_data as $user_id => $user_role ) {
|
11 |
wp_update_user( array(
|
12 |
-
'ID'
|
13 |
'role' => $user_role,
|
14 |
) );
|
15 |
}
|
9 |
if ( count( $temporary_logins_data ) > 0 ) {
|
10 |
foreach ( $temporary_logins_data as $user_id => $user_role ) {
|
11 |
wp_update_user( array(
|
12 |
+
'ID' => $user_id,
|
13 |
'role' => $user_role,
|
14 |
) );
|
15 |
}
|
includes/class-wp-temporary-login-without-password-common.php
CHANGED
@@ -1,12 +1,22 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
3 |
class Wp_Temporary_Login_Without_Password_Common {
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
public static function create_username( $data ) {
|
6 |
|
7 |
$first_name = isset( $data['user_first_name'] ) ? $data['user_first_name'] : '';
|
8 |
-
$last_name
|
9 |
-
$email
|
10 |
|
11 |
$name = '';
|
12 |
if ( ! empty( $first_name ) || ! empty( $last_name ) ) {
|
@@ -14,18 +24,25 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
14 |
} else {
|
15 |
if ( ! empty( $email ) ) {
|
16 |
$explode = explode( '@', $email );
|
17 |
-
$name
|
18 |
}
|
19 |
}
|
20 |
|
21 |
if ( username_exists( $name ) ) {
|
22 |
-
$name = $name . substr( uniqid( '', true ), -6 );
|
23 |
}
|
24 |
|
25 |
return sanitize_user( $name, true );
|
26 |
|
27 |
}
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
public static function create_new_user( $data ) {
|
30 |
|
31 |
if ( false === Wp_Temporary_Login_Without_Password_Common::can_manage_wtlwp() ) {
|
@@ -33,29 +50,30 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
33 |
}
|
34 |
|
35 |
$expiry_option = ! empty( $data['expiry'] ) ? $data['expiry'] : 'day';
|
36 |
-
$date
|
37 |
|
38 |
-
$password
|
39 |
-
$username
|
40 |
$first_name = isset( $data['user_first_name'] ) ? sanitize_text_field( $data['user_first_name'] ) : '';
|
41 |
-
$last_name
|
42 |
-
$email
|
43 |
-
$role
|
44 |
-
$user_args
|
45 |
'first_name' => $first_name,
|
46 |
-
'last_name'
|
47 |
'user_login' => $username,
|
48 |
-
'user_pass'
|
49 |
'user_email' => sanitize_email( $email, true ),
|
50 |
-
'role'
|
51 |
);
|
52 |
|
53 |
$user_id = wp_insert_user( $user_args );
|
54 |
|
55 |
if ( is_wp_error( $user_id ) ) {
|
56 |
$code = $user_id->get_error_code();
|
|
|
57 |
return array(
|
58 |
-
'error'
|
59 |
'errcode' => $code,
|
60 |
'message' => $user_id->get_error_message( $code ),
|
61 |
);
|
@@ -76,21 +94,22 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
76 |
|
77 |
}
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
85 |
public static function get_expiry_options( $key = '' ) {
|
86 |
|
87 |
$expiry_duration = array(
|
88 |
-
'3_days'
|
89 |
-
'day'
|
90 |
-
'3_hours'
|
91 |
-
'hour'
|
92 |
-
'week'
|
93 |
-
'month'
|
94 |
'custom_date' => __( 'Custom Date', 'temporary-login-without-password' ),
|
95 |
);
|
96 |
|
@@ -135,36 +154,36 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
135 |
switch ( $expiry_option ) {
|
136 |
case '3_days' :
|
137 |
$timestamp = DAY_IN_SECONDS * 3;
|
138 |
-
|
139 |
|
140 |
case 'day':
|
141 |
$timestamp = DAY_IN_SECONDS;
|
142 |
-
|
143 |
|
144 |
case '3_hours':
|
145 |
$timestamp = HOUR_IN_SECONDS * 3;
|
146 |
-
|
147 |
|
148 |
case 'hour':
|
149 |
$timestamp = HOUR_IN_SECONDS;
|
150 |
-
|
151 |
|
152 |
case 'week':
|
153 |
$timestamp = WEEK_IN_SECONDS;
|
154 |
-
|
155 |
|
156 |
case 'month':
|
157 |
$timestamp = MONTH_IN_SECONDS;
|
158 |
-
|
159 |
|
160 |
case 'custom_date':
|
161 |
-
$timestamp
|
162 |
$current_timestamp = 0;
|
163 |
-
|
164 |
|
165 |
default:
|
166 |
$timestamp = DAY_IN_SECONDS;
|
167 |
-
|
168 |
}
|
169 |
|
170 |
return $current_timestamp + floatval( $timestamp );
|
@@ -179,13 +198,13 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
179 |
public static function get_temporary_logins( $role = '' ) {
|
180 |
|
181 |
$args = array(
|
182 |
-
'fields'
|
183 |
-
'meta_key'
|
184 |
-
'order'
|
185 |
-
'orderby'
|
186 |
'meta_query' => array(
|
187 |
0 => array(
|
188 |
-
'key'
|
189 |
'value' => 1,
|
190 |
),
|
191 |
),
|
@@ -197,7 +216,7 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
197 |
|
198 |
$users = new WP_User_Query( $args );
|
199 |
|
200 |
-
if ( ! ($users->results) ) {
|
201 |
return false;
|
202 |
}
|
203 |
|
@@ -263,6 +282,13 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
263 |
|
264 |
}
|
265 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
public static function can_manage_wtlwp( $user_id = 0 ) {
|
267 |
|
268 |
if ( empty( $user_id ) ) {
|
@@ -273,6 +299,7 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
273 |
return false;
|
274 |
}
|
275 |
|
|
|
276 |
$check = get_user_meta( $user_id, '_wtlwp_user', true );
|
277 |
|
278 |
return ! empty( $check ) ? false : true;
|
@@ -297,6 +324,7 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
297 |
|
298 |
public static function generate_wtlwp_token( $user_id ) {
|
299 |
$str = $user_id . time() . uniqid( '', true );
|
|
|
300 |
return md5( $str );
|
301 |
|
302 |
}
|
@@ -308,14 +336,14 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
308 |
}
|
309 |
|
310 |
$args = array(
|
311 |
-
'fields'
|
312 |
-
'meta_key'
|
313 |
-
'order'
|
314 |
-
'orderby'
|
315 |
'meta_query' => array(
|
316 |
0 => array(
|
317 |
-
'key'
|
318 |
-
'value'
|
319 |
'compare' => '=',
|
320 |
),
|
321 |
),
|
@@ -339,6 +367,14 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
339 |
|
340 |
}
|
341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
public static function is_valid_temporary_login( $user_id = 0, $check_expiry = true ) {
|
343 |
|
344 |
if ( empty( $user_id ) ) {
|
@@ -348,13 +384,21 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
348 |
$check = get_user_meta( $user_id, '_wtlwp_user', true );
|
349 |
|
350 |
if ( ! empty( $check ) && $check_expiry ) {
|
351 |
-
$check = ! (self::is_login_expired( $user_id ));
|
352 |
}
|
353 |
|
354 |
return ! empty( $check ) ? true : false;
|
355 |
|
356 |
}
|
357 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
public static function get_manage_login_url( $user_id, $action = '' ) {
|
359 |
|
360 |
if ( empty( $user_id ) || empty( $action ) ) {
|
@@ -362,34 +406,34 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
362 |
}
|
363 |
|
364 |
$base_url = menu_page_url( 'wp-temporary-login-without-password', false );
|
365 |
-
$args
|
366 |
|
367 |
switch ( $action ) {
|
368 |
case 'disable';
|
369 |
$args = array(
|
370 |
'wtlwp_action' => 'disable',
|
371 |
-
'user_id'
|
372 |
);
|
373 |
-
|
374 |
case 'enable';
|
375 |
$args = array(
|
376 |
'wtlwp_action' => 'enable',
|
377 |
-
'user_id'
|
378 |
);
|
379 |
-
|
380 |
case 'delete';
|
381 |
$args = array(
|
382 |
'wtlwp_action' => 'delete',
|
383 |
-
'user_id'
|
384 |
);
|
385 |
-
|
386 |
default:
|
387 |
-
|
388 |
}
|
389 |
|
390 |
$manage_login_url = '';
|
391 |
if ( ! empty( $args ) ) {
|
392 |
-
$base_url
|
393 |
$manage_login_url = wp_nonce_url( $base_url, 'manage-temporary-login_' . $user_id, 'manage-temporary-login' );
|
394 |
}
|
395 |
|
@@ -397,6 +441,13 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
397 |
|
398 |
}
|
399 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
400 |
public static function get_login_url( $user_id ) {
|
401 |
|
402 |
if ( empty( $user_id ) ) {
|
@@ -419,6 +470,14 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
419 |
|
420 |
}
|
421 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
public static function manage_login( $user_id = 0, $action = '' ) {
|
423 |
|
424 |
if ( empty( $user_id ) || empty( $action ) ) {
|
@@ -445,6 +504,14 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
445 |
|
446 |
}
|
447 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
448 |
public static function time_elapsed_string( $time, $ago = false ) {
|
449 |
|
450 |
if ( $ago ) {
|
@@ -461,16 +528,16 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
461 |
// 365 * 24 * 60 * 60 => 'year',
|
462 |
// 30 * 24 * 60 * 60 => 'month',
|
463 |
24 * 60 * 60 => 'day',
|
464 |
-
60 * 60
|
465 |
-
60
|
466 |
-
1
|
467 |
);
|
468 |
|
469 |
$a_plural = array(
|
470 |
-
'year'
|
471 |
-
'month'
|
472 |
-
'day'
|
473 |
-
'hour'
|
474 |
'minute' => 'minutes',
|
475 |
'second' => 'seconds',
|
476 |
);
|
@@ -482,22 +549,31 @@ class Wp_Temporary_Login_Without_Password_Common {
|
|
482 |
$r = round( $d );
|
483 |
|
484 |
if ( $ago ) {
|
485 |
-
return __( sprintf( '%d %s ago', $r, ($r > 1 ? $a_plural[ $str ] : $str ) ), 'temporary-login-without-password' );
|
486 |
} else {
|
487 |
-
return __( sprintf( '%d %s remaining', $r, ($r > 1 ? $a_plural[ $str ] : $str ) ), 'temporary-login-without-password' );
|
488 |
}
|
489 |
}
|
490 |
}
|
491 |
|
492 |
}
|
493 |
|
|
|
|
|
|
|
|
|
|
|
494 |
public static function get_blocked_pages() {
|
495 |
$blocked_pages = array( 'wp-temporary-login-without-password', 'user-new.php', 'user-edit.php', 'profile.php' );
|
496 |
$blocked_pages = apply_filters( 'wtlwp_restricted_pages_for_temporary_users', $blocked_pages );
|
|
|
497 |
return $blocked_pages;
|
498 |
|
499 |
}
|
500 |
|
|
|
|
|
|
|
501 |
public static function delete_temporary_logins() {
|
502 |
|
503 |
$temporary_logins = Wp_Temporary_Login_Without_Password_Common::get_temporary_logins();
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Class Wp_Temporary_Login_Without_Password_Common
|
5 |
+
*/
|
6 |
class Wp_Temporary_Login_Without_Password_Common {
|
7 |
|
8 |
+
/**
|
9 |
+
* Create a ranadom username for the temporary user
|
10 |
+
*
|
11 |
+
* @param array $data
|
12 |
+
*
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
public static function create_username( $data ) {
|
16 |
|
17 |
$first_name = isset( $data['user_first_name'] ) ? $data['user_first_name'] : '';
|
18 |
+
$last_name = isset( $data['user_last_name'] ) ? $data['user_last_name'] : '';
|
19 |
+
$email = isset( $data['user_email'] ) ? $data['user_email'] : '';
|
20 |
|
21 |
$name = '';
|
22 |
if ( ! empty( $first_name ) || ! empty( $last_name ) ) {
|
24 |
} else {
|
25 |
if ( ! empty( $email ) ) {
|
26 |
$explode = explode( '@', $email );
|
27 |
+
$name = str_replace( array( '.', '+' ), '', $explode[0] );
|
28 |
}
|
29 |
}
|
30 |
|
31 |
if ( username_exists( $name ) ) {
|
32 |
+
$name = $name . substr( uniqid( '', true ), - 6 );
|
33 |
}
|
34 |
|
35 |
return sanitize_user( $name, true );
|
36 |
|
37 |
}
|
38 |
|
39 |
+
/**
|
40 |
+
* Create a new user
|
41 |
+
*
|
42 |
+
* @param array $data
|
43 |
+
*
|
44 |
+
* @return array|int|WP_Error
|
45 |
+
*/
|
46 |
public static function create_new_user( $data ) {
|
47 |
|
48 |
if ( false === Wp_Temporary_Login_Without_Password_Common::can_manage_wtlwp() ) {
|
50 |
}
|
51 |
|
52 |
$expiry_option = ! empty( $data['expiry'] ) ? $data['expiry'] : 'day';
|
53 |
+
$date = ! empty( $data['custom_date'] ) ? $data['custom_date'] : '';
|
54 |
|
55 |
+
$password = Wp_Temporary_Login_Without_Password_Common::generate_password();
|
56 |
+
$username = Wp_Temporary_Login_Without_Password_Common::create_username( $data );
|
57 |
$first_name = isset( $data['user_first_name'] ) ? sanitize_text_field( $data['user_first_name'] ) : '';
|
58 |
+
$last_name = isset( $data['user_last_name'] ) ? sanitize_text_field( $data['user_last_name'] ) : '';
|
59 |
+
$email = isset( $data['user_email'] ) ? sanitize_email( $data['user_email'] ) : '';
|
60 |
+
$role = ! empty( $data['role'] ) ? $data['role'] : 'subscriber';
|
61 |
+
$user_args = array(
|
62 |
'first_name' => $first_name,
|
63 |
+
'last_name' => $last_name,
|
64 |
'user_login' => $username,
|
65 |
+
'user_pass' => $password,
|
66 |
'user_email' => sanitize_email( $email, true ),
|
67 |
+
'role' => $role,
|
68 |
);
|
69 |
|
70 |
$user_id = wp_insert_user( $user_args );
|
71 |
|
72 |
if ( is_wp_error( $user_id ) ) {
|
73 |
$code = $user_id->get_error_code();
|
74 |
+
|
75 |
return array(
|
76 |
+
'error' => true,
|
77 |
'errcode' => $code,
|
78 |
'message' => $user_id->get_error_message( $code ),
|
79 |
);
|
94 |
|
95 |
}
|
96 |
|
97 |
+
/**
|
98 |
+
* get the expiry duration
|
99 |
+
*
|
100 |
+
* @param type $key
|
101 |
+
*
|
102 |
+
* @return boolean|array
|
103 |
+
*/
|
104 |
public static function get_expiry_options( $key = '' ) {
|
105 |
|
106 |
$expiry_duration = array(
|
107 |
+
'3_days' => __( 'Three Days', 'temporary-login-without-password' ),
|
108 |
+
'day' => __( 'One Day', 'temporary-login-without-password' ),
|
109 |
+
'3_hours' => __( 'Three Hours', 'temporary-login-without-password' ),
|
110 |
+
'hour' => __( 'One Hour', 'temporary-login-without-password' ),
|
111 |
+
'week' => __( 'One Week', 'temporary-login-without-password' ),
|
112 |
+
'month' => __( 'One Month', 'temporary-login-without-password' ),
|
113 |
'custom_date' => __( 'Custom Date', 'temporary-login-without-password' ),
|
114 |
);
|
115 |
|
154 |
switch ( $expiry_option ) {
|
155 |
case '3_days' :
|
156 |
$timestamp = DAY_IN_SECONDS * 3;
|
157 |
+
break;
|
158 |
|
159 |
case 'day':
|
160 |
$timestamp = DAY_IN_SECONDS;
|
161 |
+
break;
|
162 |
|
163 |
case '3_hours':
|
164 |
$timestamp = HOUR_IN_SECONDS * 3;
|
165 |
+
break;
|
166 |
|
167 |
case 'hour':
|
168 |
$timestamp = HOUR_IN_SECONDS;
|
169 |
+
break;
|
170 |
|
171 |
case 'week':
|
172 |
$timestamp = WEEK_IN_SECONDS;
|
173 |
+
break;
|
174 |
|
175 |
case 'month':
|
176 |
$timestamp = MONTH_IN_SECONDS;
|
177 |
+
break;
|
178 |
|
179 |
case 'custom_date':
|
180 |
+
$timestamp = strtotime( $date );
|
181 |
$current_timestamp = 0;
|
182 |
+
break;
|
183 |
|
184 |
default:
|
185 |
$timestamp = DAY_IN_SECONDS;
|
186 |
+
break;
|
187 |
}
|
188 |
|
189 |
return $current_timestamp + floatval( $timestamp );
|
198 |
public static function get_temporary_logins( $role = '' ) {
|
199 |
|
200 |
$args = array(
|
201 |
+
'fields' => 'all',
|
202 |
+
'meta_key' => '_wtlwp_expire',
|
203 |
+
'order' => 'DESC',
|
204 |
+
'orderby' => 'meta_value',
|
205 |
'meta_query' => array(
|
206 |
0 => array(
|
207 |
+
'key' => '_wtlwp_user',
|
208 |
'value' => 1,
|
209 |
),
|
210 |
),
|
216 |
|
217 |
$users = new WP_User_Query( $args );
|
218 |
|
219 |
+
if ( ! ( $users->results ) ) {
|
220 |
return false;
|
221 |
}
|
222 |
|
282 |
|
283 |
}
|
284 |
|
285 |
+
/**
|
286 |
+
* Can user have permission to manage temporary logins?
|
287 |
+
*
|
288 |
+
* @param int $user_id
|
289 |
+
*
|
290 |
+
* @return bool
|
291 |
+
*/
|
292 |
public static function can_manage_wtlwp( $user_id = 0 ) {
|
293 |
|
294 |
if ( empty( $user_id ) ) {
|
299 |
return false;
|
300 |
}
|
301 |
|
302 |
+
// Don't give manage temporary users permission to temporary user
|
303 |
$check = get_user_meta( $user_id, '_wtlwp_user', true );
|
304 |
|
305 |
return ! empty( $check ) ? false : true;
|
324 |
|
325 |
public static function generate_wtlwp_token( $user_id ) {
|
326 |
$str = $user_id . time() . uniqid( '', true );
|
327 |
+
|
328 |
return md5( $str );
|
329 |
|
330 |
}
|
336 |
}
|
337 |
|
338 |
$args = array(
|
339 |
+
'fields' => $fields,
|
340 |
+
'meta_key' => '_wtlwp_expire',
|
341 |
+
'order' => 'DESC',
|
342 |
+
'orderby' => 'meta_value',
|
343 |
'meta_query' => array(
|
344 |
0 => array(
|
345 |
+
'key' => '_wtlwp_token',
|
346 |
+
'value' => sanitize_text_field( $token ),
|
347 |
'compare' => '=',
|
348 |
),
|
349 |
),
|
367 |
|
368 |
}
|
369 |
|
370 |
+
/**
|
371 |
+
* Checks whether user is valid temporary user
|
372 |
+
*
|
373 |
+
* @param int $user_id
|
374 |
+
* @param bool $check_expiry
|
375 |
+
*
|
376 |
+
* @return bool
|
377 |
+
*/
|
378 |
public static function is_valid_temporary_login( $user_id = 0, $check_expiry = true ) {
|
379 |
|
380 |
if ( empty( $user_id ) ) {
|
384 |
$check = get_user_meta( $user_id, '_wtlwp_user', true );
|
385 |
|
386 |
if ( ! empty( $check ) && $check_expiry ) {
|
387 |
+
$check = ! ( self::is_login_expired( $user_id ) );
|
388 |
}
|
389 |
|
390 |
return ! empty( $check ) ? true : false;
|
391 |
|
392 |
}
|
393 |
|
394 |
+
/**
|
395 |
+
* Get temporary login manage url
|
396 |
+
*
|
397 |
+
* @param $user_id
|
398 |
+
* @param string $action
|
399 |
+
*
|
400 |
+
* @return string|void
|
401 |
+
*/
|
402 |
public static function get_manage_login_url( $user_id, $action = '' ) {
|
403 |
|
404 |
if ( empty( $user_id ) || empty( $action ) ) {
|
406 |
}
|
407 |
|
408 |
$base_url = menu_page_url( 'wp-temporary-login-without-password', false );
|
409 |
+
$args = array();
|
410 |
|
411 |
switch ( $action ) {
|
412 |
case 'disable';
|
413 |
$args = array(
|
414 |
'wtlwp_action' => 'disable',
|
415 |
+
'user_id' => $user_id,
|
416 |
);
|
417 |
+
break;
|
418 |
case 'enable';
|
419 |
$args = array(
|
420 |
'wtlwp_action' => 'enable',
|
421 |
+
'user_id' => $user_id,
|
422 |
);
|
423 |
+
break;
|
424 |
case 'delete';
|
425 |
$args = array(
|
426 |
'wtlwp_action' => 'delete',
|
427 |
+
'user_id' => $user_id,
|
428 |
);
|
429 |
+
break;
|
430 |
default:
|
431 |
+
break;
|
432 |
}
|
433 |
|
434 |
$manage_login_url = '';
|
435 |
if ( ! empty( $args ) ) {
|
436 |
+
$base_url = add_query_arg( $args, trailingslashit( $base_url ) );
|
437 |
$manage_login_url = wp_nonce_url( $base_url, 'manage-temporary-login_' . $user_id, 'manage-temporary-login' );
|
438 |
}
|
439 |
|
441 |
|
442 |
}
|
443 |
|
444 |
+
/**
|
445 |
+
* Get temporary login url
|
446 |
+
*
|
447 |
+
* @param $user_id
|
448 |
+
*
|
449 |
+
* @return string|void
|
450 |
+
*/
|
451 |
public static function get_login_url( $user_id ) {
|
452 |
|
453 |
if ( empty( $user_id ) ) {
|
470 |
|
471 |
}
|
472 |
|
473 |
+
/**
|
474 |
+
* Manage temporary logins
|
475 |
+
*
|
476 |
+
* @param int $user_id
|
477 |
+
* @param string $action
|
478 |
+
*
|
479 |
+
* @return bool|void
|
480 |
+
*/
|
481 |
public static function manage_login( $user_id = 0, $action = '' ) {
|
482 |
|
483 |
if ( empty( $user_id ) || empty( $action ) ) {
|
504 |
|
505 |
}
|
506 |
|
507 |
+
/**
|
508 |
+
* Get the redable time elapsed string
|
509 |
+
*
|
510 |
+
* @param int $time
|
511 |
+
* @param bool $ago
|
512 |
+
*
|
513 |
+
* @return string|void
|
514 |
+
*/
|
515 |
public static function time_elapsed_string( $time, $ago = false ) {
|
516 |
|
517 |
if ( $ago ) {
|
528 |
// 365 * 24 * 60 * 60 => 'year',
|
529 |
// 30 * 24 * 60 * 60 => 'month',
|
530 |
24 * 60 * 60 => 'day',
|
531 |
+
60 * 60 => 'hour',
|
532 |
+
60 => 'minute',
|
533 |
+
1 => 'second',
|
534 |
);
|
535 |
|
536 |
$a_plural = array(
|
537 |
+
'year' => 'years',
|
538 |
+
'month' => 'months',
|
539 |
+
'day' => 'days',
|
540 |
+
'hour' => 'hours',
|
541 |
'minute' => 'minutes',
|
542 |
'second' => 'seconds',
|
543 |
);
|
549 |
$r = round( $d );
|
550 |
|
551 |
if ( $ago ) {
|
552 |
+
return __( sprintf( '%d %s ago', $r, ( $r > 1 ? $a_plural[ $str ] : $str ) ), 'temporary-login-without-password' );
|
553 |
} else {
|
554 |
+
return __( sprintf( '%d %s remaining', $r, ( $r > 1 ? $a_plural[ $str ] : $str ) ), 'temporary-login-without-password' );
|
555 |
}
|
556 |
}
|
557 |
}
|
558 |
|
559 |
}
|
560 |
|
561 |
+
/**
|
562 |
+
* Get all pages which needs to be blocked for temporary users
|
563 |
+
*
|
564 |
+
* @return array|mixed|void
|
565 |
+
*/
|
566 |
public static function get_blocked_pages() {
|
567 |
$blocked_pages = array( 'wp-temporary-login-without-password', 'user-new.php', 'user-edit.php', 'profile.php' );
|
568 |
$blocked_pages = apply_filters( 'wtlwp_restricted_pages_for_temporary_users', $blocked_pages );
|
569 |
+
|
570 |
return $blocked_pages;
|
571 |
|
572 |
}
|
573 |
|
574 |
+
/**
|
575 |
+
* Delete all temporary logins
|
576 |
+
*/
|
577 |
public static function delete_temporary_logins() {
|
578 |
|
579 |
$temporary_logins = Wp_Temporary_Login_Without_Password_Common::get_temporary_logins();
|
includes/class-wp-temporary-login-without-password-deactivator.php
CHANGED
@@ -11,8 +11,8 @@ class Wp_Temporary_Login_Without_Password_Deactivator {
|
|
11 |
foreach ( $temporary_logins as $user ) {
|
12 |
if ( $user instanceof WP_User ) {
|
13 |
$temporary_logins_data[ $user->ID ] = $user->roles[0];
|
14 |
-
$user
|
15 |
-
'ID'
|
16 |
'role' => '',
|
17 |
) ); // Downgrade role to none. So, user won't be able to login
|
18 |
}
|
11 |
foreach ( $temporary_logins as $user ) {
|
12 |
if ( $user instanceof WP_User ) {
|
13 |
$temporary_logins_data[ $user->ID ] = $user->roles[0];
|
14 |
+
$user = wp_update_user( array(
|
15 |
+
'ID' => $user->ID,
|
16 |
'role' => '',
|
17 |
) ); // Downgrade role to none. So, user won't be able to login
|
18 |
}
|
includes/class-wp-temporary-login-without-password-layout.php
CHANGED
@@ -34,9 +34,9 @@ class Wp_Temporary_Login_Without_Password_Layout {
|
|
34 |
$user = get_user_by( 'id', $user );
|
35 |
}
|
36 |
|
37 |
-
$create
|
38 |
-
$expire
|
39 |
-
$token
|
40 |
$last_login_time = get_user_meta( $user->ID, '_wtlwp_last_login', true );
|
41 |
|
42 |
$last_login_str = __( 'Not yet logged in', 'temporary-login-without-password' );
|
@@ -53,8 +53,8 @@ class Wp_Temporary_Login_Without_Password_Layout {
|
|
53 |
$user_role = __( 'Super Admin', 'temporary-login-without-password' );
|
54 |
} else {
|
55 |
$capabilities = $user->{$wpdb->prefix . 'capabilities'};
|
56 |
-
$wp_roles
|
57 |
-
$user_role
|
58 |
foreach ( $wp_roles->role_names as $role => $name ) {
|
59 |
if ( array_key_exists( $role, $capabilities ) ) {
|
60 |
$user_role = $name;
|
@@ -63,17 +63,17 @@ class Wp_Temporary_Login_Without_Password_Layout {
|
|
63 |
}
|
64 |
|
65 |
$user_details = '<div><span>';
|
66 |
-
if ( (esc_attr( $user->first_name )) ) {
|
67 |
$user_details .= '<span>' . esc_attr( $user->first_name ) . '</span>';
|
68 |
}
|
69 |
|
70 |
-
if ( (esc_attr( $user->last_name )) ) {
|
71 |
$user_details .= '<span> ' . esc_attr( $user->last_name ) . '</span>';
|
72 |
}
|
73 |
|
74 |
$user_details .= " (<span class='wtlwp-user-login'>" . esc_attr( $user->user_login ) . ')</span><br />';
|
75 |
|
76 |
-
if ( (esc_attr( $user->user_email )) ) {
|
77 |
$user_details .= '<span><b>' . esc_attr( $user->user_email ) . '</b></span> <br />';
|
78 |
}
|
79 |
|
@@ -103,9 +103,9 @@ class Wp_Temporary_Login_Without_Password_Layout {
|
|
103 |
|
104 |
$user_id = $user->ID;
|
105 |
|
106 |
-
$delete_login_url
|
107 |
$disable_login_url = Wp_Temporary_Login_Without_Password_Common::get_manage_login_url( $user_id, 'disable' );
|
108 |
-
$enable_login_url
|
109 |
|
110 |
if ( strtolower( $wtlwp_status ) == 'expired' ) {
|
111 |
$action_row .= '<span class="enable"><a title="' . __( 'Reactivate for one day', 'temporary-login-without-password' ) . '" href="' . $enable_login_url . '"><span class="dashicons dashicons-lock"></a></span></span>';
|
34 |
$user = get_user_by( 'id', $user );
|
35 |
}
|
36 |
|
37 |
+
$create = get_user_meta( $user->ID, '_wtlwp_created', true );
|
38 |
+
$expire = get_user_meta( $user->ID, '_wtlwp_expire', true );
|
39 |
+
$token = get_user_meta( $user->ID, '_wtlwp_token', true );
|
40 |
$last_login_time = get_user_meta( $user->ID, '_wtlwp_last_login', true );
|
41 |
|
42 |
$last_login_str = __( 'Not yet logged in', 'temporary-login-without-password' );
|
53 |
$user_role = __( 'Super Admin', 'temporary-login-without-password' );
|
54 |
} else {
|
55 |
$capabilities = $user->{$wpdb->prefix . 'capabilities'};
|
56 |
+
$wp_roles = new WP_Roles();
|
57 |
+
$user_role = '';
|
58 |
foreach ( $wp_roles->role_names as $role => $name ) {
|
59 |
if ( array_key_exists( $role, $capabilities ) ) {
|
60 |
$user_role = $name;
|
63 |
}
|
64 |
|
65 |
$user_details = '<div><span>';
|
66 |
+
if ( ( esc_attr( $user->first_name ) ) ) {
|
67 |
$user_details .= '<span>' . esc_attr( $user->first_name ) . '</span>';
|
68 |
}
|
69 |
|
70 |
+
if ( ( esc_attr( $user->last_name ) ) ) {
|
71 |
$user_details .= '<span> ' . esc_attr( $user->last_name ) . '</span>';
|
72 |
}
|
73 |
|
74 |
$user_details .= " (<span class='wtlwp-user-login'>" . esc_attr( $user->user_login ) . ')</span><br />';
|
75 |
|
76 |
+
if ( ( esc_attr( $user->user_email ) ) ) {
|
77 |
$user_details .= '<span><b>' . esc_attr( $user->user_email ) . '</b></span> <br />';
|
78 |
}
|
79 |
|
103 |
|
104 |
$user_id = $user->ID;
|
105 |
|
106 |
+
$delete_login_url = Wp_Temporary_Login_Without_Password_Common::get_manage_login_url( $user_id, 'delete' );
|
107 |
$disable_login_url = Wp_Temporary_Login_Without_Password_Common::get_manage_login_url( $user_id, 'disable' );
|
108 |
+
$enable_login_url = Wp_Temporary_Login_Without_Password_Common::get_manage_login_url( $user_id, 'enable' );
|
109 |
|
110 |
if ( strtolower( $wtlwp_status ) == 'expired' ) {
|
111 |
$action_row .= '<span class="enable"><a title="' . __( 'Reactivate for one day', 'temporary-login-without-password' ) . '" href="' . $enable_login_url . '"><span class="dashicons dashicons-lock"></a></span></span>';
|
includes/class-wp-temporary-login-without-password-loader.php
CHANGED
@@ -24,10 +24,10 @@ class Wp_Temporary_Login_Without_Password_Loader {
|
|
24 |
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
25 |
|
26 |
$hooks[] = array(
|
27 |
-
'hook'
|
28 |
-
'component'
|
29 |
-
'callback'
|
30 |
-
'priority'
|
31 |
'accepted_args' => $accepted_args,
|
32 |
);
|
33 |
|
@@ -37,11 +37,17 @@ class Wp_Temporary_Login_Without_Password_Loader {
|
|
37 |
public function run() {
|
38 |
|
39 |
foreach ( $this->filters as $hook ) {
|
40 |
-
add_filter( $hook['hook'], array(
|
|
|
|
|
|
|
41 |
}
|
42 |
|
43 |
foreach ( $this->actions as $hook ) {
|
44 |
-
add_action( $hook['hook'], array(
|
|
|
|
|
|
|
45 |
}
|
46 |
}
|
47 |
|
24 |
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
25 |
|
26 |
$hooks[] = array(
|
27 |
+
'hook' => $hook,
|
28 |
+
'component' => $component,
|
29 |
+
'callback' => $callback,
|
30 |
+
'priority' => $priority,
|
31 |
'accepted_args' => $accepted_args,
|
32 |
);
|
33 |
|
37 |
public function run() {
|
38 |
|
39 |
foreach ( $this->filters as $hook ) {
|
40 |
+
add_filter( $hook['hook'], array(
|
41 |
+
$hook['component'],
|
42 |
+
$hook['callback']
|
43 |
+
), $hook['priority'], $hook['accepted_args'] );
|
44 |
}
|
45 |
|
46 |
foreach ( $this->actions as $hook ) {
|
47 |
+
add_action( $hook['hook'], array(
|
48 |
+
$hook['component'],
|
49 |
+
$hook['callback']
|
50 |
+
), $hook['priority'], $hook['accepted_args'] );
|
51 |
}
|
52 |
}
|
53 |
|
includes/class-wp-temporary-login-without-password.php
CHANGED
@@ -9,7 +9,7 @@ class Wp_Temporary_Login_Without_Password {
|
|
9 |
public function __construct() {
|
10 |
|
11 |
$this->plugin_name = 'temporary-login-without-password';
|
12 |
-
$this->version
|
13 |
|
14 |
$this->load_dependencies();
|
15 |
$this->set_locale();
|
9 |
public function __construct() {
|
10 |
|
11 |
$this->plugin_name = 'temporary-login-without-password';
|
12 |
+
$this->version = '1.5.1';
|
13 |
|
14 |
$this->load_dependencies();
|
15 |
$this->set_locale();
|
index.php
CHANGED
@@ -1 +1,6 @@
|
|
1 |
-
<?php
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Silence is golden.
|
4 |
+
*
|
5 |
+
* @since 1.0
|
6 |
+
*/
|
public/class-wp-temporary-login-without-password-public.php
CHANGED
@@ -7,18 +7,18 @@ class Wp_Temporary_Login_Without_Password_Public {
|
|
7 |
|
8 |
public function __construct( $plugin_name, $version ) {
|
9 |
$this->plugin_name = $plugin_name;
|
10 |
-
$this->version
|
11 |
}
|
12 |
|
13 |
public static function get_error_messages( $error_code ) {
|
14 |
|
15 |
$error_messages = array(
|
16 |
-
'token'
|
17 |
'unauth' => __( 'Authentication failed', 'temporary-login-without-password' ),
|
18 |
);
|
19 |
|
20 |
if ( ! empty( $error_code ) ) {
|
21 |
-
return (isset( $error_messages[ $error_code ] ) ? $error_messages[ $error_code ] : '');
|
22 |
}
|
23 |
|
24 |
return $error_messages;
|
@@ -31,20 +31,20 @@ class Wp_Temporary_Login_Without_Password_Public {
|
|
31 |
$error_messages = array();
|
32 |
|
33 |
$wtlwp_token = $_GET['wtlwp_token'];
|
34 |
-
$users
|
35 |
|
36 |
if ( empty( $users ) ) {
|
37 |
wp_safe_redirect( home_url() );
|
38 |
} else {
|
39 |
$user = $users[0];
|
40 |
|
41 |
-
$user_id
|
42 |
$user_login = $user->login;
|
43 |
update_user_meta( $user_id, '_wtlwp_last_login', Wp_Temporary_Login_Without_Password_Common::get_current_gmt_timestamp() );
|
44 |
wp_set_current_user( $user_id, $user_login );
|
45 |
wp_set_auth_cookie( $user_id );
|
46 |
|
47 |
-
$redirect_to
|
48 |
$redirect_to_url = apply_filters( 'login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user );
|
49 |
|
50 |
do_action( 'wp_login', $user_login, $user );
|
@@ -69,9 +69,9 @@ class Wp_Temporary_Login_Without_Password_Public {
|
|
69 |
} else {
|
70 |
global $pagenow;
|
71 |
$bloked_pages = Wp_Temporary_Login_Without_Password_Common::get_blocked_pages();
|
72 |
-
$page
|
73 |
|
74 |
-
if ( ! empty( $page ) && in_array( $page, $bloked_pages ) || ( ! empty( $pagenow ) && (in_array( $pagenow, $bloked_pages ) ) ) || ( ! empty( $pagenow ) && ($pagenow === 'users.php' && isset($_GET['action']) && ( $_GET['action'] === 'deleteuser' || $_GET['action'] === 'delete' ) )) ) {
|
75 |
wp_die( __( "You don't have permission to access this page", 'temporary-login-without-password' ) );
|
76 |
}
|
77 |
}
|
@@ -84,12 +84,13 @@ class Wp_Temporary_Login_Without_Password_Public {
|
|
84 |
*
|
85 |
* @param type $user
|
86 |
* @param type $password
|
|
|
87 |
* @return \WP_Error
|
88 |
*/
|
89 |
function disable_temporary_user_login( $user, $password ) {
|
90 |
|
91 |
if ( $user instanceof WP_User ) {
|
92 |
-
$check_expiry
|
93 |
$is_valid_temporary_login = Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login( $user->ID, $check_expiry );
|
94 |
if ( $is_valid_temporary_login ) {
|
95 |
$user = new WP_Error( 'denied', __( "ERROR: User can't find." ) );
|
@@ -103,13 +104,14 @@ class Wp_Temporary_Login_Without_Password_Public {
|
|
103 |
* Hooked to allow_password_reset filter to disable reset password for temporary user
|
104 |
*
|
105 |
* @param boolean $allow
|
106 |
-
* @param type
|
|
|
107 |
* @return boolean
|
108 |
*/
|
109 |
function disable_password_reset( $allow, $user_id ) {
|
110 |
|
111 |
if ( is_int( $user_id ) ) {
|
112 |
-
$check_expiry
|
113 |
$is_valid_temporary_login = Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login( $user_id, $check_expiry );
|
114 |
if ( $is_valid_temporary_login ) {
|
115 |
$allow = false;
|
7 |
|
8 |
public function __construct( $plugin_name, $version ) {
|
9 |
$this->plugin_name = $plugin_name;
|
10 |
+
$this->version = $version;
|
11 |
}
|
12 |
|
13 |
public static function get_error_messages( $error_code ) {
|
14 |
|
15 |
$error_messages = array(
|
16 |
+
'token' => __( 'Token empty', 'temporary-login-without-password' ),
|
17 |
'unauth' => __( 'Authentication failed', 'temporary-login-without-password' ),
|
18 |
);
|
19 |
|
20 |
if ( ! empty( $error_code ) ) {
|
21 |
+
return ( isset( $error_messages[ $error_code ] ) ? $error_messages[ $error_code ] : '' );
|
22 |
}
|
23 |
|
24 |
return $error_messages;
|
31 |
$error_messages = array();
|
32 |
|
33 |
$wtlwp_token = $_GET['wtlwp_token'];
|
34 |
+
$users = Wp_Temporary_Login_Without_Password_Common::get_valid_user_based_on_wtlwp_token( $wtlwp_token );
|
35 |
|
36 |
if ( empty( $users ) ) {
|
37 |
wp_safe_redirect( home_url() );
|
38 |
} else {
|
39 |
$user = $users[0];
|
40 |
|
41 |
+
$user_id = $user->ID;
|
42 |
$user_login = $user->login;
|
43 |
update_user_meta( $user_id, '_wtlwp_last_login', Wp_Temporary_Login_Without_Password_Common::get_current_gmt_timestamp() );
|
44 |
wp_set_current_user( $user_id, $user_login );
|
45 |
wp_set_auth_cookie( $user_id );
|
46 |
|
47 |
+
$redirect_to = admin_url();
|
48 |
$redirect_to_url = apply_filters( 'login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user );
|
49 |
|
50 |
do_action( 'wp_login', $user_login, $user );
|
69 |
} else {
|
70 |
global $pagenow;
|
71 |
$bloked_pages = Wp_Temporary_Login_Without_Password_Common::get_blocked_pages();
|
72 |
+
$page = ! empty( $_GET['page'] ) ? $_GET['page'] : '';
|
73 |
|
74 |
+
if ( ! empty( $page ) && in_array( $page, $bloked_pages ) || ( ! empty( $pagenow ) && ( in_array( $pagenow, $bloked_pages ) ) ) || ( ! empty( $pagenow ) && ( $pagenow === 'users.php' && isset( $_GET['action'] ) && ( $_GET['action'] === 'deleteuser' || $_GET['action'] === 'delete' ) ) ) ) {
|
75 |
wp_die( __( "You don't have permission to access this page", 'temporary-login-without-password' ) );
|
76 |
}
|
77 |
}
|
84 |
*
|
85 |
* @param type $user
|
86 |
* @param type $password
|
87 |
+
*
|
88 |
* @return \WP_Error
|
89 |
*/
|
90 |
function disable_temporary_user_login( $user, $password ) {
|
91 |
|
92 |
if ( $user instanceof WP_User ) {
|
93 |
+
$check_expiry = false;
|
94 |
$is_valid_temporary_login = Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login( $user->ID, $check_expiry );
|
95 |
if ( $is_valid_temporary_login ) {
|
96 |
$user = new WP_Error( 'denied', __( "ERROR: User can't find." ) );
|
104 |
* Hooked to allow_password_reset filter to disable reset password for temporary user
|
105 |
*
|
106 |
* @param boolean $allow
|
107 |
+
* @param type $user_id
|
108 |
+
*
|
109 |
* @return boolean
|
110 |
*/
|
111 |
function disable_password_reset( $allow, $user_id ) {
|
112 |
|
113 |
if ( is_int( $user_id ) ) {
|
114 |
+
$check_expiry = false;
|
115 |
$is_valid_temporary_login = Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login( $user_id, $check_expiry );
|
116 |
if ( $is_valid_temporary_login ) {
|
117 |
$allow = false;
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: admin login, custom login, customer access, customer login, secure login, access, admin, log in, login, login security, protection, user login, user login, wordpress admin login, wordpress login, wp-admin, wp-login, expiration, login, Login Without Password, temporary login, user, WordPress Admin, wp-admin, developer account, developer login, developer account, passwordless login, password less login
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 4.9.1
|
7 |
-
Stable tag: 1.5
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -40,6 +40,10 @@ If you like Temporary Login Without Password, please leave a five star review on
|
|
40 |
|
41 |
== Changelog ==
|
42 |
|
|
|
|
|
|
|
|
|
43 |
= 1.5 [01-08-2018] =
|
44 |
|
45 |
- Added: Now, Temporary Login can be created for WordPress Multisite. Super Admin can create a temporary super admin for multisite
|
4 |
Tags: admin login, custom login, customer access, customer login, secure login, access, admin, log in, login, login security, protection, user login, user login, wordpress admin login, wordpress login, wp-admin, wp-login, expiration, login, Login Without Password, temporary login, user, WordPress Admin, wp-admin, developer account, developer login, developer account, passwordless login, password less login
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 4.9.1
|
7 |
+
Stable tag: 1.5.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
40 |
|
41 |
== Changelog ==
|
42 |
|
43 |
+
= 1.5.1 [01-19-2018] =
|
44 |
+
|
45 |
+
- Fixed: Parse error: syntax error, unexpected ‘[‘ (PHP < 5.4)
|
46 |
+
|
47 |
= 1.5 [01-08-2018] =
|
48 |
|
49 |
- Added: Now, Temporary Login can be created for WordPress Multisite. Super Admin can create a temporary super admin for multisite
|
templates/admin_settings.php
CHANGED
@@ -1,50 +1,56 @@
|
|
1 |
<?php ?>
|
2 |
<h2 class="nav-tab-wrapper">
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
</h2>
|
6 |
|
7 |
|
8 |
<?php if ( $active_tab == 'home' ) { ?>
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
14 |
<?php include WTLWP_PLUGIN_DIR . '/templates/new_login.php'; ?>
|
15 |
-
|
16 |
|
17 |
<?php if ( ! empty( $wtlwp_generated_url ) ) { ?>
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
25 |
_e( 'User can directly login to wordpress admin panel without username and password by opening this link.', 'temporary-login-without-password' );
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
?>
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
<?php } elseif ( $active_tab == 'settings' ) { ?>
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
|
49 |
<?php }// End if().
|
50 |
-
|
1 |
<?php ?>
|
2 |
<h2 class="nav-tab-wrapper">
|
3 |
+
<a href="<?php echo admin_url( 'users.php?page=wp-temporary-login-without-password&tab=home' ); ?>"
|
4 |
+
class="nav-tab <?php echo $active_tab == 'home' ? 'nav-tab-active' : ''; ?>">Temporary Logins</a>
|
5 |
+
<a href="<?php echo admin_url( 'users.php?page=wp-temporary-login-without-password&tab=settings' ); ?>"
|
6 |
+
class="nav-tab <?php echo $active_tab == 'settings' ? 'nav-tab-active' : ''; ?>">Settings</a>
|
7 |
</h2>
|
8 |
|
9 |
|
10 |
<?php if ( $active_tab == 'home' ) { ?>
|
11 |
+
<div class="wrap wtlwp-settings-wrap" id="temporary-logins">
|
12 |
+
<h2> <?php echo __( 'Temporary Logins', 'temporary-login-without-password' ); ?> <span class="page-title-action"
|
13 |
+
id="add-new-wtlwp-form-button"><?php _e( 'Create New', 'temporary-login-without-password' ); ?></span>
|
14 |
+
</h2>
|
15 |
+
<div class="wtlwp-settings">
|
16 |
+
<!-- Add New Form Start -->
|
17 |
+
<div class="wrap new-wtlwp-form" id="new-wtlwp-form">
|
18 |
<?php include WTLWP_PLUGIN_DIR . '/templates/new_login.php'; ?>
|
19 |
+
</div>
|
20 |
|
21 |
<?php if ( ! empty( $wtlwp_generated_url ) ) { ?>
|
22 |
|
23 |
+
<div class="wrap generated-wtlwp-login-link" id="generated-wtlwp-login-link">
|
24 |
+
<p><?php _e( "Here's a temporary login link", 'temporary-login-without-password' ); ?></p>
|
25 |
+
<input id="wtlwp-click-to-copy-btn" type="text" class="wtlwp-wide-input"
|
26 |
+
value="<?php echo $wtlwp_generated_url; ?>">
|
27 |
+
<button class="wtlwp-click-to-copy-btn" data-clipboard-action="copy"
|
28 |
+
data-clipboard-target="#wtlwp-click-to-copy-btn"><?php echo __( 'Click To Copy', 'temporary-login-without-password' ); ?></button>
|
29 |
+
<span id="copied-text-message-wtlwp-click-to-copy-btn"></span>
|
30 |
+
<p><?php
|
31 |
_e( 'User can directly login to wordpress admin panel without username and password by opening this link.', 'temporary-login-without-password' );
|
32 |
+
if ( ! empty( $user_email ) ) {
|
33 |
+
echo __( sprintf( " <a href='mailto:%s'>Email</a> copied login link to user.", $user_email ), 'temporary-login-without-password' );
|
34 |
+
}
|
35 |
?>
|
36 |
+
</p>
|
37 |
+
|
38 |
+
</div>
|
39 |
+
<?php } ?>
|
40 |
+
<!-- Add New Form End -->
|
41 |
+
|
42 |
+
<!-- List All Generated Logins Start -->
|
43 |
+
<div class="wrap list-wtlwp-logins" id="list-wtlwp-logins">
|
44 |
+
<?php load_template( WTLWP_PLUGIN_DIR . '/templates/list_temporary_logins.php' ); ?>
|
45 |
+
</div>
|
46 |
+
<!-- List All Generated Logins End -->
|
47 |
+
</div>
|
48 |
+
</div>
|
49 |
<?php } elseif ( $active_tab == 'settings' ) { ?>
|
50 |
|
51 |
+
<div class="wrap list-wtlwp-logins" id="wtlwp-logins-settings">
|
52 |
+
<?php include WTLWP_PLUGIN_DIR . '/templates/temporary_logins_settings.php' ?>
|
53 |
+
</div>
|
54 |
|
55 |
<?php }// End if().
|
56 |
+
?>
|
templates/list_temporary_logins.php
CHANGED
@@ -1,26 +1,26 @@
|
|
1 |
<table class="wp-list-table widefat fixed striped users">
|
2 |
<thead>
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
|
10 |
-
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
}
|
15 |
-
} else {
|
16 |
-
echo Wp_Temporary_Login_Without_Password_Layout::prepare_empty_user_row();
|
17 |
}
|
|
|
|
|
|
|
18 |
|
19 |
-
|
20 |
|
21 |
-
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
</table>
|
1 |
<table class="wp-list-table widefat fixed striped users">
|
2 |
<thead>
|
3 |
+
<?php echo Wp_Temporary_Login_Without_Password_Layout::prepare_header_footer_row(); ?>
|
4 |
+
</thead>
|
5 |
|
6 |
+
<tbody>
|
7 |
+
<?php
|
8 |
+
$users = Wp_Temporary_Login_Without_Password_Common::get_temporary_logins();
|
9 |
|
10 |
+
if ( is_array( $users ) && count( $users ) > 0 ) {
|
11 |
|
12 |
+
foreach ( $users as $user ) {
|
13 |
+
echo Wp_Temporary_Login_Without_Password_Layout::prepare_single_user_row( $user );
|
|
|
|
|
|
|
14 |
}
|
15 |
+
} else {
|
16 |
+
echo Wp_Temporary_Login_Without_Password_Layout::prepare_empty_user_row();
|
17 |
+
}
|
18 |
|
19 |
+
?>
|
20 |
|
21 |
+
</tbody>
|
22 |
|
23 |
+
<tfoot>
|
24 |
+
<?php echo Wp_Temporary_Login_Without_Password_Layout::prepare_header_footer_row(); ?>
|
25 |
+
</tfoot>
|
26 |
</table>
|
templates/new_login.php
CHANGED
@@ -1,57 +1,80 @@
|
|
1 |
<h2> <?php echo __( 'Create a new Temporary Login', 'temporary-login-without-password' ); ?></h2>
|
2 |
<form method="post">
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
37 |
<span id="expiry-date-selection">
|
38 |
<select name="wtlwp_data[expiry]" id="user-expiry-time">
|
39 |
<?php Wp_Temporary_Login_Without_Password_Common::get_expiry_duration_html(); ?>
|
40 |
</select>
|
41 |
</span>
|
42 |
-
|
43 |
-
|
44 |
-
<input type="date" id="datepicker" name="wtlwp_data[custom_date]" value=""
|
|
|
45 |
</span>
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
<?php wp_nonce_field( 'wtlwp_generate_login_url', 'wtlwp-nonce', true, true ); ?>
|
56 |
-
|
57 |
</form>
|
1 |
<h2> <?php echo __( 'Create a new Temporary Login', 'temporary-login-without-password' ); ?></h2>
|
2 |
<form method="post">
|
3 |
+
<table class="form-table wtlwp-form">
|
4 |
+
<tr class="form-field form-required">
|
5 |
+
<th scope="row" class="wtlwp-form-row"><label
|
6 |
+
for="user_email"><?php echo __( 'Email*', 'temporary-login-without-password' ); ?> </label></th>
|
7 |
+
<td><input name="wtlwp_data[user_email]" type="text" id="user_email" value="" aria-required="true"
|
8 |
+
autocapitalize="none" autocorrect="off" maxlength="60" class="wtlwp-form-input"/></td>
|
9 |
+
</tr>
|
10 |
|
11 |
+
<tr class="form-field form-required">
|
12 |
+
<th scope="row" class="wtlwp-form-row"><label
|
13 |
+
for="user_first_name"><?php echo __( 'First Name', 'temporary-login-without-password' ); ?> </label>
|
14 |
+
</th>
|
15 |
+
<td><input name="wtlwp_data[user_first_name]" type="text" id="user_first_name" value="" aria-required="true"
|
16 |
+
autocapitalize="none" autocorrect="off" maxlength="60" class="wtlwp-form-input"/></td>
|
17 |
+
</tr>
|
18 |
|
19 |
+
<tr class="form-field form-required">
|
20 |
+
<th scope="row" class="wtlwp-form-row"><label
|
21 |
+
for="user_last_name"><?php echo __( 'Last Name', 'temporary-login-without-password' ); ?> </label>
|
22 |
+
</th>
|
23 |
+
<td><input name="wtlwp_data[user_last_name]" type="text" id="user_last_name" value="" aria-required="true"
|
24 |
+
autocapitalize="none" autocorrect="off" maxlength="60" class="wtlwp-form-input"/></td>
|
25 |
+
</tr>
|
26 |
+
|
27 |
+
<?php if ( is_network_admin() ) { ?>
|
28 |
+
<tr class="form-field form-required">
|
29 |
+
<th scope="row" class="wtlwp-form-row"><label
|
30 |
+
for="user_super_admin"><?php echo __( 'Super Admin', 'temporary-login-without-password' ); ?> </label>
|
31 |
+
</th>
|
32 |
+
<td><input type="checkbox" id="user_super_admin" name="wtlwp_data[super_admin]"> Grant this user super
|
33 |
+
admin privileges for the Network.
|
34 |
+
</td>
|
35 |
+
</tr>
|
36 |
+
<?php } else { ?>
|
37 |
+
<tr class="form-field">
|
38 |
+
<th scope="row" class="wtlwp-form-row"><label
|
39 |
+
for="adduser-role"><?php echo __( 'Role', 'temporary-login-without-password' ); ?></label>
|
40 |
+
</th>
|
41 |
+
<td><select name="wtlwp_data[role]" id="user-role">
|
42 |
+
<?php wp_dropdown_roles( $default_role ); ?>
|
43 |
+
</select>
|
44 |
+
</td>
|
45 |
+
</tr>
|
46 |
+
<?php } ?>
|
47 |
|
48 |
+
<tr class="form-field">
|
49 |
+
<th scope="row" class="wtlwp-form-row"><label
|
50 |
+
for="adduser-role"><?php echo __( 'Expiry', 'temporary-login-without-password' ); ?></label>
|
51 |
+
</th>
|
52 |
+
<td>
|
53 |
<span id="expiry-date-selection">
|
54 |
<select name="wtlwp_data[expiry]" id="user-expiry-time">
|
55 |
<?php Wp_Temporary_Login_Without_Password_Common::get_expiry_duration_html(); ?>
|
56 |
</select>
|
57 |
</span>
|
58 |
+
|
59 |
+
<span style="display:none;" id="custom-date-picker">
|
60 |
+
<input type="date" id="datepicker" name="wtlwp_data[custom_date]" value=""
|
61 |
+
class="example-datepicker"/>
|
62 |
</span>
|
63 |
+
|
64 |
+
</td>
|
65 |
+
</tr>
|
66 |
+
|
67 |
+
<tr class="form-field">
|
68 |
+
<th scope="row" class="wtlwp-form-row"><label for="adduser-role"></label></th>
|
69 |
+
<td><p class="submit"><input type="submit" class="button button-primary wtlwp-form-submit-button"
|
70 |
+
value="<?php _e( 'Submit', 'temporary-login-without-password' ); ?>"
|
71 |
+
class="button button-primary" id="generatetemporarylogin"
|
72 |
+
name="generate_temporary_login"> <?php _e( 'or', 'temporary-login-without-password' ); ?>
|
73 |
+
<span class="cancel-new-login-form"
|
74 |
+
id="cancel-new-login-form"><?php _e( 'Cancel', 'temporary-login-without-password' ); ?></span>
|
75 |
+
</p>
|
76 |
+
</td>
|
77 |
+
</tr>
|
78 |
<?php wp_nonce_field( 'wtlwp_generate_login_url', 'wtlwp-nonce', true, true ); ?>
|
79 |
+
</table>
|
80 |
</form>
|
templates/temporary_logins_settings.php
CHANGED
@@ -1,19 +1,26 @@
|
|
1 |
<h2> <?php echo __( 'Temporary Login Settings', 'temporary-login-without-password' ); ?></h2>
|
2 |
<form method="post">
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
7 |
<?php wp_dropdown_roles( $default_role ); ?>
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
<?php wp_nonce_field( 'wtlwp_generate_login_url', 'wtlwp-nonce', true, true ); ?>
|
18 |
-
|
19 |
</form>
|
1 |
<h2> <?php echo __( 'Temporary Login Settings', 'temporary-login-without-password' ); ?></h2>
|
2 |
<form method="post">
|
3 |
+
<table class="form-table wtlwp-form">
|
4 |
+
<tr class="form-field">
|
5 |
+
<th scope="row" class="wtlwp-form-row">
|
6 |
+
<label for="adduser-role"><?php echo __( 'Default Role', 'temporary-login-without-password' ); ?></label>
|
7 |
+
</th>
|
8 |
+
<td>
|
9 |
+
<select name="tlwp_settings_data[role]" id="user-role">
|
10 |
<?php wp_dropdown_roles( $default_role ); ?>
|
11 |
+
</select>
|
12 |
+
</td>
|
13 |
+
</tr>
|
14 |
+
|
15 |
+
<tr class="form-field">
|
16 |
+
<th scope="row" class="wtlwp-form-row"><label for="adduser-role"></label></th>
|
17 |
+
<td>
|
18 |
+
<p class="submit"><input type="submit" class="button button-primary wtlwp-form-submit-button"
|
19 |
+
value="<?php _e( 'Submit', 'temporary-login-without-password' ); ?>"
|
20 |
+
class="button button-primary" id="generatetemporarylogin"
|
21 |
+
name="generate_temporary_login"></p>
|
22 |
+
</td>
|
23 |
+
</tr>
|
24 |
<?php wp_nonce_field( 'wtlwp_generate_login_url', 'wtlwp-nonce', true, true ); ?>
|
25 |
+
</table>
|
26 |
</form>
|
temporary-login-without-password.php
CHANGED
@@ -1,10 +1,9 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
* Plugin Name: Temporary Login Without Password
|
5 |
* Plugin URI: http://www.storeapps.org/create-secure-login-without-password-for-wordpress/
|
6 |
* Description: Create a temporary login link with any role using which one can access to your sytem without username and password for limited period of time.
|
7 |
-
* Version: 1.5
|
8 |
* Author: StoreApps
|
9 |
* Author URI: http://storeapps.org
|
10 |
* Requires at least: 3.3
|
@@ -15,16 +14,27 @@
|
|
15 |
* Domain Path: /languages
|
16 |
* Copyright (c) 2016, 2017 StoreApps, All right reserved
|
17 |
*/
|
|
|
18 |
// If this file is called directly, abort.
|
19 |
if ( ! defined( 'WPINC' ) ) {
|
20 |
die;
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
|
|
23 |
function wp_deactivate_temporary_login_without_password() {
|
24 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-temporary-login-without-password-deactivator.php';
|
25 |
Wp_Temporary_Login_Without_Password_Deactivator::deactivate();
|
26 |
}
|
27 |
|
|
|
|
|
|
|
|
|
|
|
28 |
function wp_activate_temporary_login_without_password() {
|
29 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-temporary-login-without-password-activator.php';
|
30 |
Wp_Temporary_Login_Without_Password_Activator::activate();
|
@@ -37,6 +47,11 @@ register_activation_hook( __FILE__, 'wp_activate_temporary_login_without_passwor
|
|
37 |
// Include main class file
|
38 |
require plugin_dir_path( __FILE__ ) . 'includes/class-wp-temporary-login-without-password.php';
|
39 |
|
|
|
|
|
|
|
|
|
|
|
40 |
function run_wp_temporary_login_without_password() {
|
41 |
$plugin = new Wp_Temporary_Login_Without_Password();
|
42 |
$plugin->define_constant( 'WTLWP_PLUGIN_DIR', dirname( __FILE__ ) );
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Plugin Name: Temporary Login Without Password
|
4 |
* Plugin URI: http://www.storeapps.org/create-secure-login-without-password-for-wordpress/
|
5 |
* Description: Create a temporary login link with any role using which one can access to your sytem without username and password for limited period of time.
|
6 |
+
* Version: 1.5.1
|
7 |
* Author: StoreApps
|
8 |
* Author URI: http://storeapps.org
|
9 |
* Requires at least: 3.3
|
14 |
* Domain Path: /languages
|
15 |
* Copyright (c) 2016, 2017 StoreApps, All right reserved
|
16 |
*/
|
17 |
+
|
18 |
// If this file is called directly, abort.
|
19 |
if ( ! defined( 'WPINC' ) ) {
|
20 |
die;
|
21 |
}
|
22 |
|
23 |
+
/**
|
24 |
+
* Deactivate Temporary Login Without Password
|
25 |
+
*
|
26 |
+
* @since 1.0
|
27 |
+
*/
|
28 |
function wp_deactivate_temporary_login_without_password() {
|
29 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-temporary-login-without-password-deactivator.php';
|
30 |
Wp_Temporary_Login_Without_Password_Deactivator::deactivate();
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
+
* Activate Temporary Login Without Password
|
35 |
+
*
|
36 |
+
* @since 1.0
|
37 |
+
*/
|
38 |
function wp_activate_temporary_login_without_password() {
|
39 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-wp-temporary-login-without-password-activator.php';
|
40 |
Wp_Temporary_Login_Without_Password_Activator::activate();
|
47 |
// Include main class file
|
48 |
require plugin_dir_path( __FILE__ ) . 'includes/class-wp-temporary-login-without-password.php';
|
49 |
|
50 |
+
/**
|
51 |
+
* Initialize
|
52 |
+
*
|
53 |
+
* @since 1.0
|
54 |
+
*/
|
55 |
function run_wp_temporary_login_without_password() {
|
56 |
$plugin = new Wp_Temporary_Login_Without_Password();
|
57 |
$plugin->define_constant( 'WTLWP_PLUGIN_DIR', dirname( __FILE__ ) );
|
uninstall.php
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
* Fired when the plugin is uninstalled.
|
|
|
|
|
5 |
*/
|
6 |
|
7 |
// If uninstall not called from WordPress, then exit.
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Fired when the plugin is uninstalled.
|
4 |
+
*
|
5 |
+
* @package Temporary Login Without Password
|
6 |
*/
|
7 |
|
8 |
// If uninstall not called from WordPress, then exit.
|