Temporary Login Without Password - Version 1.5.8

Version Description

Download this release

Release Info

Developer storeapps
Plugin Icon 128x128 Temporary Login Without Password
Version 1.5.8
Comparing to
See all releases

Code changes from version 1.5.7 to 1.5.8

admin/class-wp-temporary-login-without-password-admin.php CHANGED
@@ -8,10 +8,10 @@
8
  * @since 1.0
9
  * @package Temporary Login Without Password
10
  */
11
-
12
  class Wp_Temporary_Login_Without_Password_Admin {
13
-
14
  /**
 
 
15
  * @var string $plugin_name
16
  *
17
  * @since 1.0
@@ -19,6 +19,8 @@ class Wp_Temporary_Login_Without_Password_Admin {
19
  private $plugin_name;
20
 
21
  /**
 
 
22
  * @var string $version
23
  *
24
  * @since 1.0
@@ -26,6 +28,7 @@ class Wp_Temporary_Login_Without_Password_Admin {
26
  private $version;
27
 
28
  /**
 
29
  *
30
  * @param string $plugin_name
31
  * @param string $version
@@ -77,23 +80,28 @@ class Wp_Temporary_Login_Without_Password_Admin {
77
  public function admin_menu() {
78
  $current_user_id = get_current_user_id();
79
  if ( ! Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login( $current_user_id ) ) {
80
- 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(
81
- __class__,
82
- 'admin_settings',
83
- ) );
 
 
84
  }
85
  }
86
 
87
  /**
88
  * Manage admin settings
89
  *
 
 
90
  * @since 1.0
91
  */
92
  public static function admin_settings() {
 
93
  $active_tab = ! empty( $_GET['tab'] ) ? $_GET['tab'] : 'home';
94
- $_template_file = WTLWP_PLUGIN_DIR . '/templates/admin_settings.php';
95
  $wtlwp_generated_url = ! empty( $_REQUEST['wtlwp_generated_url'] ) ? $_REQUEST['wtlwp_generated_url'] : '';
96
- $user_email = ! empty( $_REQUEST['user_email'] ) ? $_REQUEST['user_email'] : '';
97
  $tlwp_settings = maybe_unserialize( get_option( 'tlwp_settings', array() ) );
98
  $action = ! empty( $_GET['action'] ) ? $_GET['action'] : '';
99
  $user_id = ! empty( $_GET['user_id'] ) ? $_GET['user_id'] : '';
@@ -104,7 +112,7 @@ class Wp_Temporary_Login_Without_Password_Admin {
104
  }
105
 
106
  if ( ! empty( $wtlwp_generated_url ) ) {
107
- $mailto_link = Wp_Temporary_Login_Without_Password_Common::generate_mailto_link($user_email, $wtlwp_generated_url);
108
  }
109
 
110
  $default_role = ( ! empty( $tlwp_settings ) && isset( $tlwp_settings['default_role'] ) ) ? $tlwp_settings['default_role'] : 'administrator';
@@ -116,11 +124,12 @@ class Wp_Temporary_Login_Without_Password_Admin {
116
  /**
117
  * Create a Temporary user
118
  *
 
 
119
  * @since 1.0
120
  */
121
  public function create_user() {
122
 
123
-
124
  if ( empty( $_POST['wtlwp_data'] ) || empty( $_POST['wtlwp-nonce'] ) || ( ! empty( $_POST['wtlwp_action'] ) && 'update' === $_POST['wtlwp_action'] ) ) {
125
  return;
126
  }
@@ -128,52 +137,41 @@ class Wp_Temporary_Login_Without_Password_Admin {
128
  $data = $_POST['wtlwp_data'];
129
  $email = $data['user_email'];
130
  $error = true;
131
- $result = array();
 
 
132
 
133
  $redirect_link = '';
134
  if ( false == Wp_Temporary_Login_Without_Password_Common::can_manage_wtlwp() ) {
135
- $result = array(
136
- 'status' => 'error',
137
- 'message' => 'unathorised_access',
138
- );
139
  } elseif ( ! wp_verify_nonce( $_POST['wtlwp-nonce'], 'wtlwp_generate_login_url' ) ) {
140
- $result = array(
141
- 'status' => 'error',
142
- 'message' => 'nonce_failed',
143
- );
144
  } elseif ( empty( $data['user_email'] ) ) {
145
- $result = array(
146
- 'status' => 'error',
147
- 'message' => 'empty_email',
148
- );
149
  } elseif ( ! is_email( $email ) ) {
150
- $result = array(
151
- 'status' => 'error',
152
- 'message' => 'not_valid_email',
153
- );
154
  } elseif ( ! empty( $data['user_email'] ) && email_exists( $data['user_email'] ) ) {
155
- $result = array(
156
- 'status' => 'error',
157
- 'message' => 'email_is_in_use',
158
- );
159
  } else {
160
  $error = false;
161
  }
162
 
163
  if ( ! $error ) {
164
  $user = Wp_Temporary_Login_Without_Password_Common::create_new_user( $data );
165
- if ( ! empty( $user['error'] ) ) {
166
  $result = array(
167
  'status' => 'error',
168
  'message' => 'user_creation_failed',
169
  );
170
  } else {
171
- $result = array(
172
  'status' => 'success',
173
  'message' => 'user_created',
174
  );
 
 
175
  $redirect_link = Wp_Temporary_Login_Without_Password_Common::get_redirect_link( $result );
176
- $redirect_link = add_query_arg( 'wtlwp_generated_url', Wp_Temporary_Login_Without_Password_Common::get_login_url( $user ), $redirect_link );
177
  $redirect_link = add_query_arg( 'user_email', $email, $redirect_link );
178
  }
179
  }
@@ -182,13 +180,15 @@ class Wp_Temporary_Login_Without_Password_Admin {
182
  $redirect_link = Wp_Temporary_Login_Without_Password_Common::get_redirect_link( $result );
183
  }
184
 
185
- wp_redirect( $redirect_link, 302 );
186
  exit();
187
  }
188
 
189
  /**
190
  * Manage settings
191
  *
 
 
192
  * @since 1.4.6
193
  */
194
  public function update_tlwp_settings() {
@@ -249,7 +249,7 @@ class Wp_Temporary_Login_Without_Password_Admin {
249
  'disable',
250
  'enable',
251
  'delete',
252
- 'update'
253
  );
254
 
255
  if ( ! in_array( $action, $valid_actions ) ) {
@@ -336,8 +336,7 @@ class Wp_Temporary_Login_Without_Password_Admin {
336
  'message' => 'default_error_message',
337
  );
338
  }
339
-
340
- } else if ( 'update' === $action ) {
341
 
342
  $data = ! empty( $_POST['wtlwp_data'] ) ? $_POST['wtlwp_data'] : array();
343
 
@@ -356,8 +355,6 @@ class Wp_Temporary_Login_Without_Password_Admin {
356
  'message' => 'default_error_message',
357
  );
358
  }
359
-
360
-
361
  } else {
362
  $result = array(
363
  'status' => 'error',
@@ -378,48 +375,41 @@ class Wp_Temporary_Login_Without_Password_Admin {
378
  */
379
  public function display_admin_notices() {
380
 
381
- if ( empty( $_REQUEST['page'] ) || ( empty( $_REQUEST['page'] ) && 'wp-temporary-login-without-password' !== $_REQUEST['page'] ) || ! isset( $_REQUEST['wtlwp_message'] ) || ( ! isset( $_REQUEST['wtlwp_error'] ) && ! isset( $_REQUEST['wtlwp_success'] ) ) ) {
382
  return;
383
  }
384
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385
  $class = $message = '';
386
- $error = ! empty( $_REQUEST['wtlwp_error'] ) ? true : false;
387
- $success = ! empty( $_REQUEST['wtlwp_success'] ) ? true : false;
388
  if ( $error ) {
389
  $message_type = ! empty( $_REQUEST['wtlwp_message'] ) ? $_REQUEST['wtlwp_message'] : 'default_error_message';
390
-
391
- $messages = array(
392
- 'user_creation_failed' => __( 'User creation failed', 'temporary-login-without-password' ),
393
- 'unathorised_access' => __( 'You do not have permission to create a temporary login', 'temporary-login-without-password' ),
394
- 'email_is_in_use' => __( 'Email is already in use', 'temporary-login-without-password' ),
395
- 'empty_email' => __( 'Please enter valid email address. Email field should not be empty', 'temporary-login-without-password' ),
396
- 'not_valid_email' => __( 'Please enter valid email address', 'temporary-login-without-password' ),
397
- 'is_not_temporary_login' => __( 'User you are trying to delete is not temporary', 'temporary-login-without-password' ),
398
- 'nonce_failed' => __( 'Nonce failed', 'temporary-login-without-password' ),
399
- 'invalid_action' => __( 'Invalid action', 'temporary-login-without-password' ),
400
- 'default_error_message' => __( 'Unknown error occured', 'temporary-login-without-password' )
401
- );
402
-
403
- $message = $messages[ $message_type ];
404
-
405
- $class = 'error';
406
  } elseif ( $success ) {
407
  $message_type = ! empty( $_REQUEST['wtlwp_message'] ) ? $_REQUEST['wtlwp_message'] : 'default_success_message';
408
-
409
- $messages = array(
410
- 'user_created' => __( 'Login created successfully!', 'temporary-login-without-password' ),
411
- 'user_updated' => __( 'Login updated successfully!', 'temporary-login-without-password' ),
412
- 'user_deleted' => __( 'Login deleted successfully!', 'temporary-login-without-password' ),
413
- 'login_disabled' => __( 'Login disabled successfully!', 'temporary-login-without-password' ),
414
- 'login_enabled' => __( 'Login enabled successfully!', 'temporary-login-without-password' ),
415
- 'settings_updated' => __( 'Settings have been updated successfully', 'temporary-login-without-password' ),
416
- 'default_success_message' => __( 'Success!', 'temporary-login-without-password' )
417
- );
418
-
419
- $message = $messages[ $message_type ];
420
-
421
- $class = 'updated';
422
- }// End if().
423
 
424
  $class .= ' notice notice-succe is-dismissible';
425
 
@@ -436,8 +426,15 @@ class Wp_Temporary_Login_Without_Password_Admin {
436
  }
437
 
438
  /**
439
- *
440
  * Disable welcome notification for temporary user.
 
 
 
 
 
 
 
 
441
  */
442
  public function disable_welcome_notification( $blog_id, $user_id, $password, $title, $meta ) {
443
 
@@ -466,9 +463,10 @@ class Wp_Temporary_Login_Without_Password_Admin {
466
 
467
  if ( isset( $current_screen->id ) && 'users_page_wp-temporary-login-without-password' === $current_screen->id ) {
468
 
469
- $can_ask_for_review = self::can_ask_for_review();
 
470
 
471
- // Change the footer text
472
  if ( $can_ask_for_review ) {
473
  $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' ) . '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>' );
474
  } else {
@@ -501,29 +499,6 @@ class Wp_Temporary_Login_Without_Password_Admin {
501
  wp_die();
502
  }
503
 
504
- /**
505
- * Can we ask user for review?
506
- *
507
- * @since 1.4.5
508
- */
509
- public static function can_ask_for_review() {
510
-
511
- $current_user_id = get_current_user_id();
512
-
513
- $tlwp_nobug = get_user_meta( $current_user_id, 'tlwp_no_bug', true );
514
- $tlwp_rated = get_user_meta( $current_user_id, 'tlwp_admin_footer_text_rated', true );
515
- $tlwp_rated_header = get_user_meta( $current_user_id, 'tlwp_admin_header_text_rated', true );
516
-
517
- $temporary_logins = Wp_Temporary_Login_Without_Password_Common::get_temporary_logins();
518
- $total_logins = count( $temporary_logins );
519
-
520
- if ( $tlwp_nobug || $tlwp_rated || $tlwp_rated_header || ( $total_logins < 1 ) ) {
521
- return false;
522
- }
523
-
524
- return true;
525
- }
526
-
527
  /**
528
  * Prepare a HTML for the review
529
  *
@@ -535,8 +510,8 @@ class Wp_Temporary_Login_Without_Password_Admin {
535
 
536
  $nobug = '';
537
 
538
- if ( isset( $_GET['tlwpnobug'] ) ) {
539
- $nobug = absint( esc_attr( wp_unslash( $_GET['tlwpnobug'] ) ) );
540
  }
541
 
542
  if ( 1 === $nobug ) {
@@ -544,17 +519,18 @@ class Wp_Temporary_Login_Without_Password_Admin {
544
  update_user_meta( $current_user_id, 'tlwp_no_bug_time', time() );
545
  }
546
 
547
- $can_ask_for_review = self::can_ask_for_review();
 
548
 
549
  if ( $can_ask_for_review ) {
550
 
551
  $reviewurl = 'https://wordpress.org/support/plugin/temporary-login-without-password/reviews/';
552
 
553
- $nobugurl = add_query_arg( 'tlwpnobug', 1, menu_page_url( 'wp-temporary-login-without-password', false ) );
554
 
555
  echo '<div class="notice notice-warning">';
556
 
557
- echo sprintf( __( '<p>You have been using <b>Temporary Login Without Password</b> plugin, do you like it? If so, please leave us a review with your feedback! <a href="%s" class="tlwp-rating-link-header" target="_blank" data-rated="' . esc_attr__( 'Thank You :) ', 'temporary-login-without-password' ) . '">Leave A Review</a> <a href="%s">No, Thanks</a></p>' ), $reviewurl, $nobugurl );
558
 
559
  echo '</div>';
560
  }
@@ -564,10 +540,10 @@ class Wp_Temporary_Login_Without_Password_Admin {
564
  *
565
  * Disable plugin deactivation link for the temporary user
566
  *
567
- * @param $actions
568
- * @param $plugin_file
569
- * @param $plugin_data
570
- * @param $context
571
  *
572
  * @since 1.4.5
573
  *
@@ -587,7 +563,7 @@ class Wp_Temporary_Login_Without_Password_Admin {
587
  /**
588
  * Add settings link
589
  *
590
- * @param $links
591
  *
592
  * @since 1.5.7
593
  *
@@ -618,16 +594,17 @@ class Wp_Temporary_Login_Without_Password_Admin {
618
 
619
  if ( $is_valid_temporary_user ) {
620
  // Add the main site admin menu item.
621
- $wp_admin_bar->add_menu( array(
622
- 'id' => 'temporay-access-notice',
623
- 'href' => admin_url(),
624
- 'parent' => 'top-secondary',
625
- 'title' => __( 'Temporary Access', 'temporary-login-without-password' ),
626
- 'meta' => array( 'class' => 'temporay-access-mode-active' ),
627
- ) );
 
 
628
  }
629
 
630
-
631
  return true;
632
 
633
  }
8
  * @since 1.0
9
  * @package Temporary Login Without Password
10
  */
 
11
  class Wp_Temporary_Login_Without_Password_Admin {
 
12
  /**
13
+ * Plugin Name
14
+ *
15
  * @var string $plugin_name
16
  *
17
  * @since 1.0
19
  private $plugin_name;
20
 
21
  /**
22
+ * Plugin Version
23
+ *
24
  * @var string $version
25
  *
26
  * @since 1.0
28
  private $version;
29
 
30
  /**
31
+ * Initialize Admin Class
32
  *
33
  * @param string $plugin_name
34
  * @param string $version
80
  public function admin_menu() {
81
  $current_user_id = get_current_user_id();
82
  if ( ! Wp_Temporary_Login_Without_Password_Common::is_valid_temporary_login( $current_user_id ) ) {
83
+ add_users_page(
84
+ __( '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(
85
+ __class__,
86
+ 'admin_settings',
87
+ )
88
+ );
89
  }
90
  }
91
 
92
  /**
93
  * Manage admin settings
94
  *
95
+ * @return void
96
+ *
97
  * @since 1.0
98
  */
99
  public static function admin_settings() {
100
+
101
  $active_tab = ! empty( $_GET['tab'] ) ? $_GET['tab'] : 'home';
102
+ $_template_file = WTLWP_PLUGIN_DIR . '/templates/admin-settings.php';
103
  $wtlwp_generated_url = ! empty( $_REQUEST['wtlwp_generated_url'] ) ? $_REQUEST['wtlwp_generated_url'] : '';
104
+ $user_email = ! empty( $_REQUEST['user_email'] ) ? sanitize_email( $_REQUEST['user_email'] ) : '';
105
  $tlwp_settings = maybe_unserialize( get_option( 'tlwp_settings', array() ) );
106
  $action = ! empty( $_GET['action'] ) ? $_GET['action'] : '';
107
  $user_id = ! empty( $_GET['user_id'] ) ? $_GET['user_id'] : '';
112
  }
113
 
114
  if ( ! empty( $wtlwp_generated_url ) ) {
115
+ $mailto_link = Wp_Temporary_Login_Without_Password_Common::generate_mailto_link( $user_email, $wtlwp_generated_url );
116
  }
117
 
118
  $default_role = ( ! empty( $tlwp_settings ) && isset( $tlwp_settings['default_role'] ) ) ? $tlwp_settings['default_role'] : 'administrator';
124
  /**
125
  * Create a Temporary user
126
  *
127
+ * @return void
128
+ *
129
  * @since 1.0
130
  */
131
  public function create_user() {
132
 
 
133
  if ( empty( $_POST['wtlwp_data'] ) || empty( $_POST['wtlwp-nonce'] ) || ( ! empty( $_POST['wtlwp_action'] ) && 'update' === $_POST['wtlwp_action'] ) ) {
134
  return;
135
  }
137
  $data = $_POST['wtlwp_data'];
138
  $email = $data['user_email'];
139
  $error = true;
140
+ $result = array(
141
+ 'status' => 'error',
142
+ );
143
 
144
  $redirect_link = '';
145
  if ( false == Wp_Temporary_Login_Without_Password_Common::can_manage_wtlwp() ) {
146
+ $result['message'] = 'unathorised_access';
 
 
 
147
  } elseif ( ! wp_verify_nonce( $_POST['wtlwp-nonce'], 'wtlwp_generate_login_url' ) ) {
148
+ $result['message'] = 'nonce_failed';
 
 
 
149
  } elseif ( empty( $data['user_email'] ) ) {
150
+ $result['message'] = 'empty_email';
 
 
 
151
  } elseif ( ! is_email( $email ) ) {
152
+ $result['message'] = 'not_valid_email';
 
 
 
153
  } elseif ( ! empty( $data['user_email'] ) && email_exists( $data['user_email'] ) ) {
154
+ $result['message'] = 'email_is_in_use';
 
 
 
155
  } else {
156
  $error = false;
157
  }
158
 
159
  if ( ! $error ) {
160
  $user = Wp_Temporary_Login_Without_Password_Common::create_new_user( $data );
161
+ if ( isset( $user['error'] ) && $user['error'] === true ) {
162
  $result = array(
163
  'status' => 'error',
164
  'message' => 'user_creation_failed',
165
  );
166
  } else {
167
+ $result = array(
168
  'status' => 'success',
169
  'message' => 'user_created',
170
  );
171
+
172
+ $user_id = isset( $user['user_id'] ) ? $user['user_id'] : 0;
173
  $redirect_link = Wp_Temporary_Login_Without_Password_Common::get_redirect_link( $result );
174
+ $redirect_link = add_query_arg( 'wtlwp_generated_url', Wp_Temporary_Login_Without_Password_Common::get_login_url( $user_id ), $redirect_link );
175
  $redirect_link = add_query_arg( 'user_email', $email, $redirect_link );
176
  }
177
  }
180
  $redirect_link = Wp_Temporary_Login_Without_Password_Common::get_redirect_link( $result );
181
  }
182
 
183
+ wp_safe_redirect( $redirect_link, 302 );
184
  exit();
185
  }
186
 
187
  /**
188
  * Manage settings
189
  *
190
+ * @return Void
191
+ *
192
  * @since 1.4.6
193
  */
194
  public function update_tlwp_settings() {
249
  'disable',
250
  'enable',
251
  'delete',
252
+ 'update',
253
  );
254
 
255
  if ( ! in_array( $action, $valid_actions ) ) {
336
  'message' => 'default_error_message',
337
  );
338
  }
339
+ } elseif ( 'update' === $action ) {
 
340
 
341
  $data = ! empty( $_POST['wtlwp_data'] ) ? $_POST['wtlwp_data'] : array();
342
 
355
  'message' => 'default_error_message',
356
  );
357
  }
 
 
358
  } else {
359
  $result = array(
360
  'status' => 'error',
375
  */
376
  public function display_admin_notices() {
377
 
378
+ if ( empty( $_REQUEST['page'] ) || ( empty( $_REQUEST['page'] ) && 'wp-temporary-login-without-password' !== $_REQUEST['page'] ) || ! isset( $_REQUEST['wtlwp_message'] ) || ( ! isset( $_REQUEST['wtlwp_error'] ) && ! isset( $_REQUEST['wtlwp_success'] ) ) ) { // Input var okay.
379
  return;
380
  }
381
 
382
+ $messages = array(
383
+ 'user_creation_failed' => __( 'User creation failed', 'temporary-login-without-password' ),
384
+ 'unathorised_access' => __( 'You do not have permission to create a temporary login', 'temporary-login-without-password' ),
385
+ 'email_is_in_use' => __( 'Email is already in use', 'temporary-login-without-password' ),
386
+ 'empty_email' => __( 'Please enter valid email address. Email field should not be empty', 'temporary-login-without-password' ),
387
+ 'not_valid_email' => __( 'Please enter valid email address', 'temporary-login-without-password' ),
388
+ 'is_not_temporary_login' => __( 'User you are trying to delete is not temporary', 'temporary-login-without-password' ),
389
+ 'nonce_failed' => __( 'Nonce failed', 'temporary-login-without-password' ),
390
+ 'invalid_action' => __( 'Invalid action', 'temporary-login-without-password' ),
391
+ 'default_error_message' => __( 'Unknown error occured', 'temporary-login-without-password' ),
392
+ 'user_created' => __( 'Login created successfully!', 'temporary-login-without-password' ),
393
+ 'user_updated' => __( 'Login updated successfully!', 'temporary-login-without-password' ),
394
+ 'user_deleted' => __( 'Login deleted successfully!', 'temporary-login-without-password' ),
395
+ 'login_disabled' => __( 'Login disabled successfully!', 'temporary-login-without-password' ),
396
+ 'login_enabled' => __( 'Login enabled successfully!', 'temporary-login-without-password' ),
397
+ 'settings_updated' => __( 'Settings have been updated successfully', 'temporary-login-without-password' ),
398
+ 'default_success_message' => __( 'Success!', 'temporary-login-without-password' ),
399
+ );
400
+
401
  $class = $message = '';
402
+ $error = ! empty( $_REQUEST['wtlwp_error'] ) ? true : false; // Input var okay.
403
+ $success = ! empty( $_REQUEST['wtlwp_success'] ) ? true : false; // Input var okay.
404
  if ( $error ) {
405
  $message_type = ! empty( $_REQUEST['wtlwp_message'] ) ? $_REQUEST['wtlwp_message'] : 'default_error_message';
406
+ $message = $messages[ $message_type ];
407
+ $class = 'error';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
  } elseif ( $success ) {
409
  $message_type = ! empty( $_REQUEST['wtlwp_message'] ) ? $_REQUEST['wtlwp_message'] : 'default_success_message';
410
+ $message = $messages[ $message_type ];
411
+ $class = 'updated';
412
+ }
 
 
 
 
 
 
 
 
 
 
 
 
413
 
414
  $class .= ' notice notice-succe is-dismissible';
415
 
426
  }
427
 
428
  /**
 
429
  * Disable welcome notification for temporary user.
430
+ *
431
+ * @param int $blog_id
432
+ * @param int $user_id
433
+ * @param string $password
434
+ * @param string $title
435
+ * @param string $meta
436
+ *
437
+ * @return bool
438
  */
439
  public function disable_welcome_notification( $blog_id, $user_id, $password, $title, $meta ) {
440
 
463
 
464
  if ( isset( $current_screen->id ) && 'users_page_wp-temporary-login-without-password' === $current_screen->id ) {
465
 
466
+ $current_user_id = get_current_user_id();
467
+ $can_ask_for_review = Wp_Temporary_Login_Without_Password_Common::can_ask_for_review( $current_user_id );
468
 
469
+ // Change the footer text.
470
  if ( $can_ask_for_review ) {
471
  $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' ) . '">&#9733;&#9733;&#9733;&#9733;&#9733;</a>' );
472
  } else {
499
  wp_die();
500
  }
501
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
502
  /**
503
  * Prepare a HTML for the review
504
  *
510
 
511
  $nobug = '';
512
 
513
+ if ( isset( $_GET['tlwp_nobug'] ) ) { // Input var okay.
514
+ $nobug = absint( esc_attr( wp_unslash( $_GET['tlwp_nobug'] ) ) );
515
  }
516
 
517
  if ( 1 === $nobug ) {
519
  update_user_meta( $current_user_id, 'tlwp_no_bug_time', time() );
520
  }
521
 
522
+ $current_user_id = get_current_user_id();
523
+ $can_ask_for_review = Wp_Temporary_Login_Without_Password_Common::can_ask_for_review( $current_user_id );
524
 
525
  if ( $can_ask_for_review ) {
526
 
527
  $reviewurl = 'https://wordpress.org/support/plugin/temporary-login-without-password/reviews/';
528
 
529
+ $nobugurl = add_query_arg( 'tlwp_nobug', 1, menu_page_url( 'wp-temporary-login-without-password', false ) );
530
 
531
  echo '<div class="notice notice-warning">';
532
 
533
+ echo sprintf( __( '<p>You have been using <b>Temporary Login Without Password</b> plugin, do you like it? If so, please leave us a review with your feedback! <a href="%s" class="tlwp-rating-link-header" target="_blank" data-rated="' . esc_attr__( 'Thank You :) ', 'temporary-login-without-password' ) . '">Leave A Review</a> <a href="%s">No, Thanks</a></p>' ), esc_url( $reviewurl ), esc_url( $nobugurl ) );
534
 
535
  echo '</div>';
536
  }
540
  *
541
  * Disable plugin deactivation link for the temporary user
542
  *
543
+ * @param array $actions
544
+ * @param string $plugin_file
545
+ * @param array $plugin_data
546
+ * @param string $context
547
  *
548
  * @since 1.4.5
549
  *
563
  /**
564
  * Add settings link
565
  *
566
+ * @param array $links
567
  *
568
  * @since 1.5.7
569
  *
594
 
595
  if ( $is_valid_temporary_user ) {
596
  // Add the main site admin menu item.
597
+ $wp_admin_bar->add_menu(
598
+ array(
599
+ 'id' => 'temporay-access-notice',
600
+ 'href' => admin_url(),
601
+ 'parent' => 'top-secondary',
602
+ 'title' => __( 'Temporary Access', 'temporary-login-without-password' ),
603
+ 'meta' => array( 'class' => 'temporay-access-mode-active' ),
604
+ )
605
+ );
606
  }
607
 
 
608
  return true;
609
 
610
  }
admin/css/wp-temporary-login-without-password-admin.css CHANGED
@@ -1,108 +1,108 @@
1
  .wtlwp-form {
2
- background-color: white;
3
- border: 1px solid;
4
- padding: 10px;
5
  }
6
 
7
  .new-wtlwp-form {
8
- display: none;
9
  }
10
 
11
  .wtlwp-form-input {
12
- width: 300px !important;
13
  }
14
 
15
  .widefat .wtlwp-status {
16
- width: 40px;
17
  }
18
 
19
  .wtlwp-status-active {
20
- color: #008000 !important;
21
  }
22
 
23
  .wtlwp-status-expired {
24
- color: #FF0000 !important;
25
  }
26
 
27
  .wtlwp-status:after {
28
- border-radius: 32px;
29
- color: #fff;
30
- display: block;
31
- font-size: 11px;
32
- font-weight: bold;
33
- height: 16px;
34
- line-height: 17px;
35
- margin-left: 8px;
36
- text-align: center;
37
- width: 16px;
38
  }
39
 
40
  .wtlwp-status-active:after {
41
- background: #008000 none repeat scroll 0 0;
42
- content: "";
43
  }
44
 
45
  .wtlwp-status-expired:after {
46
- background: #FF0000 none repeat scroll 0 0;
47
- content: "";
48
  }
49
 
50
  .cancel-new-login-form, .cancel-update-login-form {
51
- cursor: pointer;
52
  }
53
 
54
  .wtlwp-wide-input {
55
- width: 60%;
56
  }
57
 
58
  .generated-wtlwp-login-link {
59
- border: 1px solid;
60
- padding: 10px 10px 10px 10px;
61
  }
62
 
63
  .wtlwp-form-row {
64
- padding-left: 20px !important;
65
  }
66
 
67
  .wtlwp-form-submit-button {
68
- width: 115px;
69
  }
70
 
71
  .wtlwp-user-login {
72
- font-size: 12px;
73
  }
74
 
75
  .wtlwp-copy-to-clipboard, .wtlwp-click-to-copy-btn {
76
- cursor: pointer;
77
  }
78
 
79
  .wtlwp-copy-to-clipboard:hover {
80
- color: #0073aa;
81
  }
82
 
83
  .copied-text-message {
84
- padding: 0 20px 20px 20px;
85
  }
86
 
87
  .wtlp-role-radio, .wtlp-role-checkbox {
88
- text-align: center;
89
- padding-top: 10px;
90
  }
91
 
92
  .tlwp-role-name {
93
- padding-top: 10px;
94
  }
95
 
96
  .visible-roles-dropdown {
97
- min-height: 100px !important;
98
- width: 200px;
99
  }
100
 
101
  .default-role-dropdown {
102
- width: 200px;
103
  }
104
 
105
  #wpadminbar .temporay-access-mode-active > .ab-item {
106
- color: #fff;
107
- background-color: #ffba00;
108
- }
1
  .wtlwp-form {
2
+ background-color: white;
3
+ border: 1px solid;
4
+ padding: 10px;
5
  }
6
 
7
  .new-wtlwp-form {
8
+ display: none;
9
  }
10
 
11
  .wtlwp-form-input {
12
+ width: 300px !important;
13
  }
14
 
15
  .widefat .wtlwp-status {
16
+ width: 40px;
17
  }
18
 
19
  .wtlwp-status-active {
20
+ color: #008000 !important;
21
  }
22
 
23
  .wtlwp-status-expired {
24
+ color: #FF0000 !important;
25
  }
26
 
27
  .wtlwp-status:after {
28
+ border-radius: 32px;
29
+ color: #fff;
30
+ display: block;
31
+ font-size: 11px;
32
+ font-weight: bold;
33
+ height: 16px;
34
+ line-height: 17px;
35
+ margin-left: 8px;
36
+ text-align: center;
37
+ width: 16px;
38
  }
39
 
40
  .wtlwp-status-active:after {
41
+ background: #008000 none repeat scroll 0 0;
42
+ content: "";
43
  }
44
 
45
  .wtlwp-status-expired:after {
46
+ background: #FF0000 none repeat scroll 0 0;
47
+ content: "";
48
  }
49
 
50
  .cancel-new-login-form, .cancel-update-login-form {
51
+ cursor: pointer;
52
  }
53
 
54
  .wtlwp-wide-input {
55
+ width: 60%;
56
  }
57
 
58
  .generated-wtlwp-login-link {
59
+ border: 1px solid;
60
+ padding: 10px 10px 10px 10px;
61
  }
62
 
63
  .wtlwp-form-row {
64
+ padding-left: 20px !important;
65
  }
66
 
67
  .wtlwp-form-submit-button {
68
+ width: 115px;
69
  }
70
 
71
  .wtlwp-user-login {
72
+ font-size: 12px;
73
  }
74
 
75
  .wtlwp-copy-to-clipboard, .wtlwp-click-to-copy-btn {
76
+ cursor: pointer;
77
  }
78
 
79
  .wtlwp-copy-to-clipboard:hover {
80
+ color: #0073aa;
81
  }
82
 
83
  .copied-text-message {
84
+ padding: 0 20px 20px 20px;
85
  }
86
 
87
  .wtlp-role-radio, .wtlp-role-checkbox {
88
+ text-align: center;
89
+ padding-top: 10px;
90
  }
91
 
92
  .tlwp-role-name {
93
+ padding-top: 10px;
94
  }
95
 
96
  .visible-roles-dropdown {
97
+ min-height: 100px !important;
98
+ width: 200px;
99
  }
100
 
101
  .default-role-dropdown {
102
+ width: 200px;
103
  }
104
 
105
  #wpadminbar .temporay-access-mode-active > .ab-item {
106
+ color: #fff;
107
+ background-color: #ffba00;
108
+ }
admin/js/clipboard.js CHANGED
@@ -4,746 +4,791 @@
4
  *
5
  * Licensed MIT © Zeno Rocha
6
  */
7
- (function(f){if (typeof exports === "object"&&typeof module !== "undefined") {module.exports = f()} else if (typeof define === "function"&&define.amd) {define( [],f )} else {var g;if (typeof window !== "undefined") {g = window} else if (typeof global !== "undefined") {g = global} else if (typeof self !== "undefined") {g = self} else {g = this}g.Clipboard = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if ( ! n[o]) {if ( ! t[o]) {var a = typeof require == "function"&&require;if ( ! u&&a) { return a( o, ! 0 );
8
- }if (i) { return i( o, ! 0 );
9
- }var f = new Error( "Cannot find module '" + o + "'" );throw f.code = "MODULE_NOT_FOUND",f}var l = n[o] = {exports:{}};t[o][0].call( l.exports,function(e){var n = t[o][1][e];return s( n?n:e )},l,l.exports,e,t,n,r )}return n[o].exports}var i = typeof require == "function"&&require;for (var o = 0;o < r.length;o++) { s( r[o] );
10
- }return s})({1:[function(require,module,exports){
11
- var matches = require( 'matches-selector' )
12
-
13
- module.exports = function (element, selector, checkYoSelf) {
14
- var parent = checkYoSelf ? element : element.parentNode
15
-
16
- while (parent && parent !== document) {
17
- if (matches( parent, selector )) { return parent;
18
- }
19
- parent = parent.parentNode
20
- }
21
- }
22
-
23
- },{"matches-selector":5}],2:[function(require,module,exports){
24
- var closest = require( 'closest' );
25
-
26
- /**
27
- * Delegates event to a selector.
28
- *
29
- * @param {Element} element
30
- * @param {String} selector
31
- * @param {String} type
32
- * @param {Function} callback
33
- * @param {Boolean} useCapture
34
- * @return {Object}
35
- */
36
- function delegate(element, selector, type, callback, useCapture) {
37
- var listenerFn = listener.apply( this, arguments );
38
-
39
- element.addEventListener( type, listenerFn, useCapture );
40
-
41
- return {
42
- destroy: function() {
43
- element.removeEventListener( type, listenerFn, useCapture );
44
- }
45
- }
46
- }
47
-
48
- /**
49
- * Finds closest match and invokes callback.
50
- *
51
- * @param {Element} element
52
- * @param {String} selector
53
- * @param {String} type
54
- * @param {Function} callback
55
- * @return {Function}
56
- */
57
- function listener(element, selector, type, callback) {
58
- return function(e) {
59
- e.delegateTarget = closest( e.target, selector, true );
60
-
61
- if (e.delegateTarget) {
62
- callback.call( element, e );
63
- }
64
- }
65
- }
66
-
67
- module.exports = delegate;
68
-
69
- },{"closest":1}],3:[function(require,module,exports){
70
- /**
71
- * Check if argument is a HTML element.
72
- *
73
- * @param {Object} value
74
- * @return {Boolean}
75
- */
76
- exports.node = function(value) {
77
- return value !== undefined
78
- && value instanceof HTMLElement
79
- && value.nodeType === 1;
80
- };
81
-
82
- /**
83
- * Check if argument is a list of HTML elements.
84
- *
85
- * @param {Object} value
86
- * @return {Boolean}
87
- */
88
- exports.nodeList = function(value) {
89
- var type = Object.prototype.toString.call( value );
90
-
91
- return value !== undefined
92
- && (type === '[object NodeList]' || type === '[object HTMLCollection]')
93
- && ('length' in value)
94
- && (value.length === 0 || exports.node( value[0] ));
95
- };
96
-
97
- /**
98
- * Check if argument is a string.
99
- *
100
- * @param {Object} value
101
- * @return {Boolean}
102
- */
103
- exports.string = function(value) {
104
- return typeof value === 'string'
105
- || value instanceof String;
106
- };
107
-
108
- /**
109
- * Check if argument is a function.
110
- *
111
- * @param {Object} value
112
- * @return {Boolean}
113
- */
114
- exports.fn = function(value) {
115
- var type = Object.prototype.toString.call( value );
116
-
117
- return type === '[object Function]';
118
- };
119
-
120
- },{}],4:[function(require,module,exports){
121
- var is = require( './is' );
122
- var delegate = require( 'delegate' );
123
-
124
- /**
125
- * Validates all params and calls the right
126
- * listener function based on its target type.
127
- *
128
- * @param {String|HTMLElement|HTMLCollection|NodeList} target
129
- * @param {String} type
130
- * @param {Function} callback
131
- * @return {Object}
132
- */
133
- function listen(target, type, callback) {
134
- if ( ! target && ! type && ! callback) {
135
- throw new Error( 'Missing required arguments' );
136
- }
137
-
138
- if ( ! is.string( type )) {
139
- throw new TypeError( 'Second argument must be a String' );
140
- }
141
-
142
- if ( ! is.fn( callback )) {
143
- throw new TypeError( 'Third argument must be a Function' );
144
- }
145
-
146
- if (is.node( target )) {
147
- return listenNode( target, type, callback );
148
- } else if (is.nodeList( target )) {
149
- return listenNodeList( target, type, callback );
150
- } else if (is.string( target )) {
151
- return listenSelector( target, type, callback );
152
- } else {
153
- throw new TypeError( 'First argument must be a String, HTMLElement, HTMLCollection, or NodeList' );
154
- }
155
- }
156
-
157
- /**
158
- * Adds an event listener to a HTML element
159
- * and returns a remove listener function.
160
- *
161
- * @param {HTMLElement} node
162
- * @param {String} type
163
- * @param {Function} callback
164
- * @return {Object}
165
- */
166
- function listenNode(node, type, callback) {
167
- node.addEventListener( type, callback );
168
-
169
- return {
170
- destroy: function() {
171
- node.removeEventListener( type, callback );
172
- }
173
- }
174
- }
175
-
176
- /**
177
- * Add an event listener to a list of HTML elements
178
- * and returns a remove listener function.
179
- *
180
- * @param {NodeList|HTMLCollection} nodeList
181
- * @param {String} type
182
- * @param {Function} callback
183
- * @return {Object}
184
- */
185
- function listenNodeList(nodeList, type, callback) {
186
- Array.prototype.forEach.call(nodeList, function(node) {
187
- node.addEventListener( type, callback );
188
- });
189
-
190
- return {
191
- destroy: function() {
192
- Array.prototype.forEach.call(nodeList, function(node) {
193
- node.removeEventListener( type, callback );
194
- });
195
- }
196
- }
197
- }
198
-
199
- /**
200
- * Add an event listener to a selector
201
- * and returns a remove listener function.
202
- *
203
- * @param {String} selector
204
- * @param {String} type
205
- * @param {Function} callback
206
- * @return {Object}
207
- */
208
- function listenSelector(selector, type, callback) {
209
- return delegate( document.body, selector, type, callback );
210
- }
211
-
212
- module.exports = listen;
213
-
214
- },{"./is":3,"delegate":2}],5:[function(require,module,exports){
215
-
216
- /**
217
- * Element prototype.
218
- */
219
-
220
- var proto = Element.prototype;
221
-
222
- /**
223
- * Vendor function.
224
- */
225
-
226
- var vendor = proto.matchesSelector
227
- || proto.webkitMatchesSelector
228
- || proto.mozMatchesSelector
229
- || proto.msMatchesSelector
230
- || proto.oMatchesSelector;
231
-
232
- /**
233
- * Expose `match()`.
234
- */
235
-
236
- module.exports = match;
237
-
238
- /**
239
- * Match `el` to `selector`.
240
- *
241
- * @param {Element} el
242
- * @param {String} selector
243
- * @return {Boolean}
244
- * @api public
245
- */
246
-
247
- function match(el, selector) {
248
- if (vendor) { return vendor.call( el, selector );
249
- }
250
- var nodes = el.parentNode.querySelectorAll( selector );
251
- for (var i = 0; i < nodes.length; ++i) {
252
- if (nodes[i] == el) { return true;
253
- }
254
- }
255
- return false;
256
- }
257
- },{}],6:[function(require,module,exports){
258
- function select(element) {
259
- var selectedText;
260
-
261
- if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
262
- element.focus();
263
- element.setSelectionRange( 0, element.value.length );
264
-
265
- selectedText = element.value;
266
- } else {
267
- if (element.hasAttribute( 'contenteditable' )) {
268
- element.focus();
269
- }
270
-
271
- var selection = window.getSelection();
272
- var range = document.createRange();
273
-
274
- range.selectNodeContents( element );
275
- selection.removeAllRanges();
276
- selection.addRange( range );
277
-
278
- selectedText = selection.toString();
279
- }
280
-
281
- return selectedText;
282
- }
283
-
284
- module.exports = select;
285
-
286
- },{}],7:[function(require,module,exports){
287
- function E () {
288
- // Keep this empty so it's easier to inherit from
289
- // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
290
- }
291
-
292
- E.prototype = {
293
- on: function (name, callback, ctx) {
294
- var e = this.e || (this.e = {});
295
-
296
- (e[name] || (e[name] = [])).push({
297
- fn: callback,
298
- ctx: ctx
299
- });
300
-
301
- return this;
302
- },
303
-
304
- once: function (name, callback, ctx) {
305
- var self = this;
306
- function listener () {
307
- self.off( name, listener );
308
- callback.apply( ctx, arguments );
309
- };
310
-
311
- listener._ = callback
312
- return this.on( name, listener, ctx );
313
- },
314
-
315
- emit: function (name) {
316
- var data = [].slice.call( arguments, 1 );
317
- var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
318
- var i = 0;
319
- var len = evtArr.length;
320
-
321
- for (i; i < len; i++) {
322
- evtArr[i].fn.apply( evtArr[i].ctx, data );
323
- }
324
-
325
- return this;
326
- },
327
-
328
- off: function (name, callback) {
329
- var e = this.e || (this.e = {});
330
- var evts = e[name];
331
- var liveEvents = [];
332
-
333
- if (evts && callback) {
334
- for (var i = 0, len = evts.length; i < len; i++) {
335
- if (evts[i].fn !== callback && evts[i].fn._ !== callback) {
336
- liveEvents.push( evts[i] );
337
- }
338
- }
339
- }
340
-
341
- // Remove event from queue to prevent memory leak
342
- // Suggested by https://github.com/lazd
343
- // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
344
- (liveEvents.length)
345
- ? e[name] = liveEvents
346
- : delete e[name];
347
-
348
- return this;
349
- }
350
- };
351
-
352
- module.exports = E;
353
-
354
- },{}],8:[function(require,module,exports){
355
- (function (global, factory) {
356
- if (typeof define === "function" && define.amd) {
357
- define( ['module', 'select'], factory );
358
- } else if (typeof exports !== "undefined") {
359
- factory( module, require( 'select' ) );
360
- } else {
361
- var mod = {
362
- exports: {}
363
- };
364
- factory( mod, global.select );
365
- global.clipboardAction = mod.exports;
366
- }
367
- })(this, function (module, _select) {
368
- 'use strict';
369
-
370
- var _select2 = _interopRequireDefault( _select );
371
-
372
- function _interopRequireDefault(obj) {
373
- return obj && obj.__esModule ? obj : {
374
- default: obj
375
- };
376
- }
377
-
378
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
379
- return typeof obj;
380
- } : function (obj) {
381
- return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
382
- };
383
-
384
- function _classCallCheck(instance, Constructor) {
385
- if ( ! (instance instanceof Constructor)) {
386
- throw new TypeError( "Cannot call a class as a function" );
387
- }
388
- }
389
-
390
- var _createClass = function () {
391
- function defineProperties(target, props) {
392
- for (var i = 0; i < props.length; i++) {
393
- var descriptor = props[i];
394
- descriptor.enumerable = descriptor.enumerable || false;
395
- descriptor.configurable = true;
396
- if ("value" in descriptor) { descriptor.writable = true;
397
- }
398
- Object.defineProperty( target, descriptor.key, descriptor );
399
- }
400
- }
401
-
402
- return function (Constructor, protoProps, staticProps) {
403
- if (protoProps) { defineProperties( Constructor.prototype, protoProps );
404
- }
405
- if (staticProps) { defineProperties( Constructor, staticProps );
406
- }
407
- return Constructor;
408
- };
409
- }();
410
-
411
- var ClipboardAction = function () {
412
- /**
413
- * @param {Object} options
414
- */
415
-
416
- function ClipboardAction(options) {
417
- _classCallCheck( this, ClipboardAction );
418
-
419
- this.resolveOptions( options );
420
- this.initSelection();
421
- }
422
-
423
- /**
424
- * Defines base properties passed from constructor.
425
- *
426
- * @param {Object} options
427
- */
428
-
429
- ClipboardAction.prototype.resolveOptions = function resolveOptions() {
430
- var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
431
-
432
- this.action = options.action;
433
- this.emitter = options.emitter;
434
- this.target = options.target;
435
- this.text = options.text;
436
- this.trigger = options.trigger;
437
-
438
- this.selectedText = '';
439
- };
440
-
441
- ClipboardAction.prototype.initSelection = function initSelection() {
442
- if (this.text) {
443
- this.selectFake();
444
- } else if (this.target) {
445
- this.selectTarget();
446
- }
447
- };
448
-
449
- ClipboardAction.prototype.selectFake = function selectFake() {
450
- var _this = this;
451
-
452
- var isRTL = document.documentElement.getAttribute( 'dir' ) == 'rtl';
453
-
454
- this.removeFake();
455
-
456
- this.fakeHandlerCallback = function () {
457
- return _this.removeFake();
458
- };
459
- this.fakeHandler = document.body.addEventListener( 'click', this.fakeHandlerCallback ) || true;
460
-
461
- this.fakeElem = document.createElement( 'textarea' );
462
- // Prevent zooming on iOS
463
- this.fakeElem.style.fontSize = '12pt';
464
- // Reset box model
465
- this.fakeElem.style.border = '0';
466
- this.fakeElem.style.padding = '0';
467
- this.fakeElem.style.margin = '0';
468
- // Move element out of screen horizontally
469
- this.fakeElem.style.position = 'absolute';
470
- this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
471
- // Move element to the same position vertically
472
- this.fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px';
473
- this.fakeElem.setAttribute( 'readonly', '' );
474
- this.fakeElem.value = this.text;
475
-
476
- document.body.appendChild( this.fakeElem );
477
-
478
- this.selectedText = (0, _select2.default)(this.fakeElem);
479
- this.copyText();
480
- };
481
-
482
- ClipboardAction.prototype.removeFake = function removeFake() {
483
- if (this.fakeHandler) {
484
- document.body.removeEventListener( 'click', this.fakeHandlerCallback );
485
- this.fakeHandler = null;
486
- this.fakeHandlerCallback = null;
487
- }
488
-
489
- if (this.fakeElem) {
490
- document.body.removeChild( this.fakeElem );
491
- this.fakeElem = null;
492
- }
493
- };
494
-
495
- ClipboardAction.prototype.selectTarget = function selectTarget() {
496
- this.selectedText = (0, _select2.default)(this.target);
497
- this.copyText();
498
- };
499
-
500
- ClipboardAction.prototype.copyText = function copyText() {
501
- var succeeded = undefined;
502
-
503
- try {
504
- succeeded = document.execCommand( this.action );
505
- } catch (err) {
506
- succeeded = false;
507
- }
508
-
509
- this.handleResult( succeeded );
510
- };
511
-
512
- ClipboardAction.prototype.handleResult = function handleResult(succeeded) {
513
- if (succeeded) {
514
- this.emitter.emit('success', {
515
- action: this.action,
516
- text: this.selectedText,
517
- trigger: this.trigger,
518
- clearSelection: this.clearSelection.bind( this )
519
- });
520
- } else {
521
- this.emitter.emit('error', {
522
- action: this.action,
523
- trigger: this.trigger,
524
- clearSelection: this.clearSelection.bind( this )
525
- });
526
- }
527
- };
528
-
529
- ClipboardAction.prototype.clearSelection = function clearSelection() {
530
- if (this.target) {
531
- this.target.blur();
532
- }
533
-
534
- window.getSelection().removeAllRanges();
535
- };
536
-
537
- ClipboardAction.prototype.destroy = function destroy() {
538
- this.removeFake();
539
- };
540
-
541
- _createClass(ClipboardAction, [{
542
- key: 'action',
543
- set: function set() {
544
- var action = arguments.length <= 0 || arguments[0] === undefined ? 'copy' : arguments[0];
545
-
546
- this._action = action;
547
-
548
- if (this._action !== 'copy' && this._action !== 'cut') {
549
- throw new Error( 'Invalid "action" value, use either "copy" or "cut"' );
550
- }
551
- },
552
- get: function get() {
553
- return this._action;
554
- }
555
- }, {
556
- key: 'target',
557
- set: function set(target) {
558
- if (target !== undefined) {
559
- if (target && (typeof target === 'undefined' ? 'undefined' : _typeof( target )) === 'object' && target.nodeType === 1) {
560
- if (this.action === 'copy' && target.hasAttribute( 'disabled' )) {
561
- throw new Error( 'Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute' );
562
- }
563
-
564
- if (this.action === 'cut' && (target.hasAttribute( 'readonly' ) || target.hasAttribute( 'disabled' ))) {
565
- throw new Error( 'Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes' );
566
- }
567
-
568
- this._target = target;
569
- } else {
570
- throw new Error( 'Invalid "target" value, use a valid Element' );
571
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
572
  }
573
- },
574
- get: function get() {
575
- return this._target;
576
- }
577
- }]);
578
-
579
- return ClipboardAction;
580
- }();
581
-
582
- module.exports = ClipboardAction;
583
- });
584
-
585
- },{"select":6}],9:[function(require,module,exports){
586
- (function (global, factory) {
587
- if (typeof define === "function" && define.amd) {
588
- define( ['module', './clipboard-action', 'tiny-emitter', 'good-listener'], factory );
589
- } else if (typeof exports !== "undefined") {
590
- factory( module, require( './clipboard-action' ), require( 'tiny-emitter' ), require( 'good-listener' ) );
591
- } else {
592
- var mod = {
593
- exports: {}
594
- };
595
- factory( mod, global.clipboardAction, global.tinyEmitter, global.goodListener );
596
- global.clipboard = mod.exports;
597
- }
598
- })(this, function (module, _clipboardAction, _tinyEmitter, _goodListener) {
599
- 'use strict';
600
-
601
- var _clipboardAction2 = _interopRequireDefault( _clipboardAction );
602
-
603
- var _tinyEmitter2 = _interopRequireDefault( _tinyEmitter );
604
-
605
- var _goodListener2 = _interopRequireDefault( _goodListener );
606
-
607
- function _interopRequireDefault(obj) {
608
- return obj && obj.__esModule ? obj : {
609
- default: obj
610
- };
611
- }
612
-
613
- function _classCallCheck(instance, Constructor) {
614
- if ( ! (instance instanceof Constructor)) {
615
- throw new TypeError( "Cannot call a class as a function" );
616
- }
617
- }
618
-
619
- function _possibleConstructorReturn(self, call) {
620
- if ( ! self) {
621
- throw new ReferenceError( "this hasn't been initialised - super() hasn't been called" );
622
- }
623
-
624
- return call && (typeof call === "object" || typeof call === "function") ? call : self;
625
- }
626
-
627
- function _inherits(subClass, superClass) {
628
- if (typeof superClass !== "function" && superClass !== null) {
629
- throw new TypeError( "Super expression must either be null or a function, not " + typeof superClass );
630
- }
631
-
632
- subClass.prototype = Object.create(superClass && superClass.prototype, {
633
- constructor: {
634
- value: subClass,
635
- enumerable: false,
636
- writable: true,
637
- configurable: true
638
- }
639
- });
640
- if (superClass) { Object.setPrototypeOf ? Object.setPrototypeOf( subClass, superClass ) : subClass.__proto__ = superClass;
641
- }
642
- }
643
-
644
- var Clipboard = function (_Emitter) {
645
- _inherits( Clipboard, _Emitter );
646
-
647
- /**
648
- * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
649
- * @param {Object} options
650
- */
651
-
652
- function Clipboard(trigger, options) {
653
- _classCallCheck( this, Clipboard );
654
-
655
- var _this = _possibleConstructorReturn( this, _Emitter.call( this ) );
656
-
657
- _this.resolveOptions( options );
658
- _this.listenClick( trigger );
659
- return _this;
660
- }
661
-
662
- /**
663
- * Defines if attributes would be resolved using internal setter functions
664
- * or custom functions that were passed in the constructor.
665
- *
666
- * @param {Object} options
667
- */
668
-
669
- Clipboard.prototype.resolveOptions = function resolveOptions() {
670
- var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
671
-
672
- this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
673
- this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
674
- this.text = typeof options.text === 'function' ? options.text : this.defaultText;
675
- };
676
-
677
- Clipboard.prototype.listenClick = function listenClick(trigger) {
678
- var _this2 = this;
679
-
680
- this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
681
- return _this2.onClick( e );
682
- });
683
- };
684
-
685
- Clipboard.prototype.onClick = function onClick(e) {
686
- var trigger = e.delegateTarget || e.currentTarget;
687
-
688
- if (this.clipboardAction) {
689
- this.clipboardAction = null;
690
- }
691
-
692
- this.clipboardAction = new _clipboardAction2.default({
693
- action: this.action( trigger ),
694
- target: this.target( trigger ),
695
- text: this.text( trigger ),
696
- trigger: trigger,
697
- emitter: this
698
- });
699
- };
700
-
701
- Clipboard.prototype.defaultAction = function defaultAction(trigger) {
702
- return getAttributeValue( 'action', trigger );
703
- };
704
-
705
- Clipboard.prototype.defaultTarget = function defaultTarget(trigger) {
706
- var selector = getAttributeValue( 'target', trigger );
707
-
708
- if (selector) {
709
- return document.querySelector( selector );
710
- }
711
- };
712
-
713
- Clipboard.prototype.defaultText = function defaultText(trigger) {
714
- return getAttributeValue( 'text', trigger );
715
- };
716
-
717
- Clipboard.prototype.destroy = function destroy() {
718
- this.listener.destroy();
719
-
720
- if (this.clipboardAction) {
721
- this.clipboardAction.destroy();
722
- this.clipboardAction = null;
723
- }
724
- };
725
-
726
- return Clipboard;
727
- }(_tinyEmitter2.default);
728
-
729
- /**
730
- * Helper function to retrieve attribute value.
731
- *
732
- * @param {String} suffix
733
- * @param {Element} element
734
- */
735
- function getAttributeValue(suffix, element) {
736
- var attribute = 'data-clipboard-' + suffix;
737
-
738
- if ( ! element.hasAttribute( attribute )) {
739
- return;
740
- }
741
-
742
- return element.getAttribute( attribute );
743
- }
744
-
745
- module.exports = Clipboard;
746
- });
747
-
748
- },{"./clipboard-action":8,"good-listener":4,"tiny-emitter":7}]},{},[9])(9)
749
- });
4
  *
5
  * Licensed MIT © Zeno Rocha
6
  */
7
+ (function(f){if (typeof exports === "object" && typeof module !== "undefined") {
8
+ module.exports = f()} else if (typeof define === "function" && define.amd) {
9
+ define( [],f )} else {
10
+ var g;if (typeof window !== "undefined") {
11
+ g = window} else if (typeof global !== "undefined") {
12
+ g = global} else if (typeof self !== "undefined") {
13
+ g = self} else {
14
+ g = this}g.Clipboard = f()}})(
15
+ function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if ( ! n[o]) {
16
+ if ( ! t[o]) {
17
+ var a = typeof require == "function" && require;if ( ! u && a) {
18
+ return a( o, ! 0 );
19
+ }if (i) {
20
+ return i( o, ! 0 );
21
+ }var f = new Error( "Cannot find module '" + o + "'" );throw f.code = "MODULE_NOT_FOUND",f}var l = n[o] = {exports:{}};t[o][0].call( l.exports,function(e){var n = t[o][1][e];return s( n ? n : e )},l,l.exports,e,t,n,r )}return n[o].exports}var i = typeof require == "function" && require;for (var o = 0;o < r.length;o++) {
22
+ s( r[o] );
23
+ }return s})(
24
+ {1:[function(require,module,exports){
25
+ var matches = require( 'matches-selector' )
26
+
27
+ module.exports = function (element, selector, checkYoSelf) {
28
+ var parent = checkYoSelf ? element : element.parentNode
29
+
30
+ while (parent && parent !== document) {
31
+ if (matches( parent, selector )) {
32
+ return parent;
33
+ }
34
+ parent = parent.parentNode
35
+ }
36
+ }
37
+
38
+ },{"matches-selector":5}],2:[function(require,module,exports){
39
+ var closest = require( 'closest' );
40
+
41
+ /**
42
+ * Delegates event to a selector.
43
+ *
44
+ * @param {Element} element
45
+ * @param {String} selector
46
+ * @param {String} type
47
+ * @param {Function} callback
48
+ * @param {Boolean} useCapture
49
+ * @return {Object}
50
+ */
51
+ function delegate(element, selector, type, callback, useCapture) {
52
+ var listenerFn = listener.apply( this, arguments );
53
+
54
+ element.addEventListener( type, listenerFn, useCapture );
55
+
56
+ return {
57
+ destroy: function() {
58
+ element.removeEventListener( type, listenerFn, useCapture );
59
+ }
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Finds closest match and invokes callback.
65
+ *
66
+ * @param {Element} element
67
+ * @param {String} selector
68
+ * @param {String} type
69
+ * @param {Function} callback
70
+ * @return {Function}
71
+ */
72
+ function listener(element, selector, type, callback) {
73
+ return function(e) {
74
+ e.delegateTarget = closest( e.target, selector, true );
75
+
76
+ if (e.delegateTarget) {
77
+ callback.call( element, e );
78
+ }
79
+ }
80
+ }
81
+
82
+ module.exports = delegate;
83
+
84
+ },{"closest":1}],3:[function(require,module,exports){
85
+ /**
86
+ * Check if argument is a HTML element.
87
+ *
88
+ * @param {Object} value
89
+ * @return {Boolean}
90
+ */
91
+ exports.node = function(value) {
92
+ return value !== undefined
93
+ && value instanceof HTMLElement
94
+ && value.nodeType === 1;
95
+ };
96
+
97
+ /**
98
+ * Check if argument is a list of HTML elements.
99
+ *
100
+ * @param {Object} value
101
+ * @return {Boolean}
102
+ */
103
+ exports.nodeList = function(value) {
104
+ var type = Object.prototype.toString.call( value );
105
+
106
+ return value !== undefined
107
+ && (type === '[object NodeList]' || type === '[object HTMLCollection]')
108
+ && ('length' in value)
109
+ && (value.length === 0 || exports.node( value[0] ));
110
+ };
111
+
112
+ /**
113
+ * Check if argument is a string.
114
+ *
115
+ * @param {Object} value
116
+ * @return {Boolean}
117
+ */
118
+ exports.string = function(value) {
119
+ return typeof value === 'string'
120
+ || value instanceof String;
121
+ };
122
+
123
+ /**
124
+ * Check if argument is a function.
125
+ *
126
+ * @param {Object} value
127
+ * @return {Boolean}
128
+ */
129
+ exports.fn = function(value) {
130
+ var type = Object.prototype.toString.call( value );
131
+
132
+ return type === '[object Function]';
133
+ };
134
+
135
+ },{}],4:[function(require,module,exports){
136
+ var is = require( './is' );
137
+ var delegate = require( 'delegate' );
138
+
139
+ /**
140
+ * Validates all params and calls the right
141
+ * listener function based on its target type.
142
+ *
143
+ * @param {String|HTMLElement|HTMLCollection|NodeList} target
144
+ * @param {String} type
145
+ * @param {Function} callback
146
+ * @return {Object}
147
+ */
148
+ function listen(target, type, callback) {
149
+ if ( ! target && ! type && ! callback) {
150
+ throw new Error( 'Missing required arguments' );
151
+ }
152
+
153
+ if ( ! is.string( type )) {
154
+ throw new TypeError( 'Second argument must be a String' );
155
+ }
156
+
157
+ if ( ! is.fn( callback )) {
158
+ throw new TypeError( 'Third argument must be a Function' );
159
+ }
160
+
161
+ if (is.node( target )) {
162
+ return listenNode( target, type, callback );
163
+ } else if (is.nodeList( target )) {
164
+ return listenNodeList( target, type, callback );
165
+ } else if (is.string( target )) {
166
+ return listenSelector( target, type, callback );
167
+ } else {
168
+ throw new TypeError( 'First argument must be a String, HTMLElement, HTMLCollection, or NodeList' );
169
+ }
170
+ }
171
+
172
+ /**
173
+ * Adds an event listener to a HTML element
174
+ * and returns a remove listener function.
175
+ *
176
+ * @param {HTMLElement} node
177
+ * @param {String} type
178
+ * @param {Function} callback
179
+ * @return {Object}
180
+ */
181
+ function listenNode(node, type, callback) {
182
+ node.addEventListener( type, callback );
183
+
184
+ return {
185
+ destroy: function() {
186
+ node.removeEventListener( type, callback );
187
+ }
188
+ }
189
+ }
190
+
191
+ /**
192
+ * Add an event listener to a list of HTML elements
193
+ * and returns a remove listener function.
194
+ *
195
+ * @param {NodeList|HTMLCollection} nodeList
196
+ * @param {String} type
197
+ * @param {Function} callback
198
+ * @return {Object}
199
+ */
200
+ function listenNodeList(nodeList, type, callback) {
201
+ Array.prototype.forEach.call(
202
+ nodeList, function(node) {
203
+ node.addEventListener( type, callback );
204
+ }
205
+ );
206
+
207
+ return {
208
+ destroy: function() {
209
+ Array.prototype.forEach.call(
210
+ nodeList, function(node) {
211
+ node.removeEventListener( type, callback );
212
+ }
213
+ );
214
+ }
215
+ }
216
+ }
217
+
218
+ /**
219
+ * Add an event listener to a selector
220
+ * and returns a remove listener function.
221
+ *
222
+ * @param {String} selector
223
+ * @param {String} type
224
+ * @param {Function} callback
225
+ * @return {Object}
226
+ */
227
+ function listenSelector(selector, type, callback) {
228
+ return delegate( document.body, selector, type, callback );
229
+ }
230
+
231
+ module.exports = listen;
232
+
233
+ },{"./is":3,"delegate":2}],5:[function(require,module,exports){
234
+
235
+ /**
236
+ * Element prototype.
237
+ */
238
+
239
+ var proto = Element.prototype;
240
+
241
+ /**
242
+ * Vendor function.
243
+ */
244
+
245
+ var vendor = proto.matchesSelector
246
+ || proto.webkitMatchesSelector
247
+ || proto.mozMatchesSelector
248
+ || proto.msMatchesSelector
249
+ || proto.oMatchesSelector;
250
+
251
+ /**
252
+ * Expose `match()`.
253
+ */
254
+
255
+ module.exports = match;
256
+
257
+ /**
258
+ * Match `el` to `selector`.
259
+ *
260
+ * @param {Element} el
261
+ * @param {String} selector
262
+ * @return {Boolean}
263
+ * @api public
264
+ */
265
+
266
+ function match(el, selector) {
267
+ if (vendor) {
268
+ return vendor.call( el, selector );
269
+ }
270
+ var nodes = el.parentNode.querySelectorAll( selector );
271
+ for (var i = 0; i < nodes.length; ++i) {
272
+ if (nodes[i] == el) {
273
+ return true;
274
+ }
275
+ }
276
+ return false;
277
+ }
278
+ },{}],6:[function(require,module,exports){
279
+ function select(element) {
280
+ var selectedText;
281
+
282
+ if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
283
+ element.focus();
284
+ element.setSelectionRange( 0, element.value.length );
285
+
286
+ selectedText = element.value;
287
+ } else {
288
+ if (element.hasAttribute( 'contenteditable' )) {
289
+ element.focus();
290
+ }
291
+
292
+ var selection = window.getSelection();
293
+ var range = document.createRange();
294
+
295
+ range.selectNodeContents( element );
296
+ selection.removeAllRanges();
297
+ selection.addRange( range );
298
+
299
+ selectedText = selection.toString();
300
+ }
301
+
302
+ return selectedText;
303
+ }
304
+
305
+ module.exports = select;
306
+
307
+ },{}],7:[function(require,module,exports){
308
+ function E () {
309
+ // Keep this empty so it's easier to inherit from
310
+ // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
311
+ }
312
+
313
+ E.prototype = {
314
+ on: function (name, callback, ctx) {
315
+ var e = this.e || (this.e = {});
316
+
317
+ (e[name] || (e[name] = [])).push(
318
+ {
319
+ fn: callback,
320
+ ctx: ctx
321
+ }
322
+ );
323
+
324
+ return this;
325
+ },
326
+
327
+ once: function (name, callback, ctx) {
328
+ var self = this;
329
+ function listener () {
330
+ self.off( name, listener );
331
+ callback.apply( ctx, arguments );
332
+ };
333
+
334
+ listener._ = callback
335
+ return this.on( name, listener, ctx );
336
+ },
337
+
338
+ emit: function (name) {
339
+ var data = [].slice.call( arguments, 1 );
340
+ var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
341
+ var i = 0;
342
+ var len = evtArr.length;
343
+
344
+ for (i; i < len; i++) {
345
+ evtArr[i].fn.apply( evtArr[i].ctx, data );
346
+ }
347
+
348
+ return this;
349
+ },
350
+
351
+ off: function (name, callback) {
352
+ var e = this.e || (this.e = {});
353
+ var evts = e[name];
354
+ var liveEvents = [];
355
+
356
+ if (evts && callback) {
357
+ for (var i = 0, len = evts.length; i < len; i++) {
358
+ if (evts[i].fn !== callback && evts[i].fn._ !== callback) {
359
+ liveEvents.push( evts[i] );
360
+ }
361
+ }
362
+ }
363
+
364
+ // Remove event from queue to prevent memory leak
365
+ // Suggested by https://github.com/lazd
366
+ // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
367
+ (liveEvents.length)
368
+ ? e[name] = liveEvents
369
+ : delete e[name];
370
+
371
+ return this;
372
+ }
373
+ };
374
+
375
+ module.exports = E;
376
+
377
+ },{}],8:[function(require,module,exports){
378
+ (function (global, factory) {
379
+ if (typeof define === "function" && define.amd) {
380
+ define( ['module', 'select'], factory );
381
+ } else if (typeof exports !== "undefined") {
382
+ factory( module, require( 'select' ) );
383
+ } else {
384
+ var mod = {
385
+ exports: {}
386
+ };
387
+ factory( mod, global.select );
388
+ global.clipboardAction = mod.exports;
389
+ }
390
+ })(
391
+ this, function (module, _select) {
392
+ 'use strict';
393
+
394
+ var _select2 = _interopRequireDefault( _select );
395
+
396
+ function _interopRequireDefault(obj) {
397
+ return obj && obj.__esModule ? obj : {
398
+ default: obj
399
+ };
400
+ }
401
+
402
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
403
+ return typeof obj;
404
+ } : function (obj) {
405
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
406
+ };
407
+
408
+ function _classCallCheck(instance, Constructor) {
409
+ if ( ! (instance instanceof Constructor)) {
410
+ throw new TypeError( "Cannot call a class as a function" );
411
+ }
412
+ }
413
+
414
+ var _createClass = function () {
415
+ function defineProperties(target, props) {
416
+ for (var i = 0; i < props.length; i++) {
417
+ var descriptor = props[i];
418
+ descriptor.enumerable = descriptor.enumerable || false;
419
+ descriptor.configurable = true;
420
+ if ("value" in descriptor) {
421
+ descriptor.writable = true;
422
+ }
423
+ Object.defineProperty( target, descriptor.key, descriptor );
424
+ }
425
+ }
426
+
427
+ return function (Constructor, protoProps, staticProps) {
428
+ if (protoProps) {
429
+ defineProperties( Constructor.prototype, protoProps );
430
+ }
431
+ if (staticProps) {
432
+ defineProperties( Constructor, staticProps );
433
+ }
434
+ return Constructor;
435
+ };
436
+ }();
437
+
438
+ var ClipboardAction = function () {
439
+ /**
440
+ * @param {Object} options
441
+ */
442
+
443
+ function ClipboardAction(options) {
444
+ _classCallCheck( this, ClipboardAction );
445
+
446
+ this.resolveOptions( options );
447
+ this.initSelection();
448
+ }
449
+
450
+ /**
451
+ * Defines base properties passed from constructor.
452
+ *
453
+ * @param {Object} options
454
+ */
455
+
456
+ ClipboardAction.prototype.resolveOptions = function resolveOptions() {
457
+ var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
458
+
459
+ this.action = options.action;
460
+ this.emitter = options.emitter;
461
+ this.target = options.target;
462
+ this.text = options.text;
463
+ this.trigger = options.trigger;
464
+
465
+ this.selectedText = '';
466
+ };
467
+
468
+ ClipboardAction.prototype.initSelection = function initSelection() {
469
+ if (this.text) {
470
+ this.selectFake();
471
+ } else if (this.target) {
472
+ this.selectTarget();
473
+ }
474
+ };
475
+
476
+ ClipboardAction.prototype.selectFake = function selectFake() {
477
+ var _this = this;
478
+
479
+ var isRTL = document.documentElement.getAttribute( 'dir' ) == 'rtl';
480
+
481
+ this.removeFake();
482
+
483
+ this.fakeHandlerCallback = function () {
484
+ return _this.removeFake();
485
+ };
486
+ this.fakeHandler = document.body.addEventListener( 'click', this.fakeHandlerCallback ) || true;
487
+
488
+ this.fakeElem = document.createElement( 'textarea' );
489
+ // Prevent zooming on iOS
490
+ this.fakeElem.style.fontSize = '12pt';
491
+ // Reset box model
492
+ this.fakeElem.style.border = '0';
493
+ this.fakeElem.style.padding = '0';
494
+ this.fakeElem.style.margin = '0';
495
+ // Move element out of screen horizontally
496
+ this.fakeElem.style.position = 'absolute';
497
+ this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
498
+ // Move element to the same position vertically
499
+ this.fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px';
500
+ this.fakeElem.setAttribute( 'readonly', '' );
501
+ this.fakeElem.value = this.text;
502
+
503
+ document.body.appendChild( this.fakeElem );
504
+
505
+ this.selectedText = (0, _select2.default)( this.fakeElem );
506
+ this.copyText();
507
+ };
508
+
509
+ ClipboardAction.prototype.removeFake = function removeFake() {
510
+ if (this.fakeHandler) {
511
+ document.body.removeEventListener( 'click', this.fakeHandlerCallback );
512
+ this.fakeHandler = null;
513
+ this.fakeHandlerCallback = null;
514
+ }
515
+
516
+ if (this.fakeElem) {
517
+ document.body.removeChild( this.fakeElem );
518
+ this.fakeElem = null;
519
+ }
520
+ };
521
+
522
+ ClipboardAction.prototype.selectTarget = function selectTarget() {
523
+ this.selectedText = (0, _select2.default)( this.target );
524
+ this.copyText();
525
+ };
526
+
527
+ ClipboardAction.prototype.copyText = function copyText() {
528
+ var succeeded = undefined;
529
+
530
+ try {
531
+ succeeded = document.execCommand( this.action );
532
+ } catch (err) {
533
+ succeeded = false;
534
+ }
535
+
536
+ this.handleResult( succeeded );
537
+ };
538
+
539
+ ClipboardAction.prototype.handleResult = function handleResult(succeeded) {
540
+ if (succeeded) {
541
+ this.emitter.emit(
542
+ 'success', {
543
+ action: this.action,
544
+ text: this.selectedText,
545
+ trigger: this.trigger,
546
+ clearSelection: this.clearSelection.bind( this )
547
+ }
548
+ );
549
+ } else {
550
+ this.emitter.emit(
551
+ 'error', {
552
+ action: this.action,
553
+ trigger: this.trigger,
554
+ clearSelection: this.clearSelection.bind( this )
555
+ }
556
+ );
557
+ }
558
+ };
559
+
560
+ ClipboardAction.prototype.clearSelection = function clearSelection() {
561
+ if (this.target) {
562
+ this.target.blur();
563
+ }
564
+
565
+ window.getSelection().removeAllRanges();
566
+ };
567
+
568
+ ClipboardAction.prototype.destroy = function destroy() {
569
+ this.removeFake();
570
+ };
571
+
572
+ _createClass(
573
+ ClipboardAction, [{
574
+ key: 'action',
575
+ set: function set() {
576
+ var action = arguments.length <= 0 || arguments[0] === undefined ? 'copy' : arguments[0];
577
+
578
+ this._action = action;
579
+
580
+ if (this._action !== 'copy' && this._action !== 'cut') {
581
+ throw new Error( 'Invalid "action" value, use either "copy" or "cut"' );
582
+ }
583
+ },
584
+ get: function get() {
585
+ return this._action;
586
+ }
587
+ }, {
588
+ key: 'target',
589
+ set: function set(target) {
590
+ if (target !== undefined) {
591
+ if (target && (typeof target === 'undefined' ? 'undefined' : _typeof( target )) === 'object' && target.nodeType === 1) {
592
+ if (this.action === 'copy' && target.hasAttribute( 'disabled' )) {
593
+ throw new Error( 'Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute' );
594
+ }
595
+
596
+ if (this.action === 'cut' && (target.hasAttribute( 'readonly' ) || target.hasAttribute( 'disabled' ))) {
597
+ throw new Error( 'Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes' );
598
+ }
599
+
600
+ this._target = target;
601
+ } else {
602
+ throw new Error( 'Invalid "target" value, use a valid Element' );
603
+ }
604
+ }
605
+ },
606
+ get: function get() {
607
+ return this._target;
608
+ }
609
+ }]
610
+ );
611
+
612
+ return ClipboardAction;
613
+ }();
614
+
615
+ module.exports = ClipboardAction;
616
+ }
617
+ );
618
+
619
+ },{"select":6}],9:[function(require,module,exports){
620
+ (function (global, factory) {
621
+ if (typeof define === "function" && define.amd) {
622
+ define( ['module', './clipboard-action', 'tiny-emitter', 'good-listener'], factory );
623
+ } else if (typeof exports !== "undefined") {
624
+ factory( module, require( './clipboard-action' ), require( 'tiny-emitter' ), require( 'good-listener' ) );
625
+ } else {
626
+ var mod = {
627
+ exports: {}
628
+ };
629
+ factory( mod, global.clipboardAction, global.tinyEmitter, global.goodListener );
630
+ global.clipboard = mod.exports;
631
+ }
632
+ })(
633
+ this, function (module, _clipboardAction, _tinyEmitter, _goodListener) {
634
+ 'use strict';
635
+
636
+ var _clipboardAction2 = _interopRequireDefault( _clipboardAction );
637
+
638
+ var _tinyEmitter2 = _interopRequireDefault( _tinyEmitter );
639
+
640
+ var _goodListener2 = _interopRequireDefault( _goodListener );
641
+
642
+ function _interopRequireDefault(obj) {
643
+ return obj && obj.__esModule ? obj : {
644
+ default: obj
645
+ };
646
+ }
647
+
648
+ function _classCallCheck(instance, Constructor) {
649
+ if ( ! (instance instanceof Constructor)) {
650
+ throw new TypeError( "Cannot call a class as a function" );
651
+ }
652
+ }
653
+
654
+ function _possibleConstructorReturn(self, call) {
655
+ if ( ! self) {
656
+ throw new ReferenceError( "this hasn't been initialised - super() hasn't been called" );
657
+ }
658
+
659
+ return call && (typeof call === "object" || typeof call === "function") ? call : self;
660
+ }
661
+
662
+ function _inherits(subClass, superClass) {
663
+ if (typeof superClass !== "function" && superClass !== null) {
664
+ throw new TypeError( "Super expression must either be null or a function, not " + typeof superClass );
665
+ }
666
+
667
+ subClass.prototype = Object.create(
668
+ superClass && superClass.prototype, {
669
+ constructor: {
670
+ value: subClass,
671
+ enumerable: false,
672
+ writable: true,
673
+ configurable: true
674
+ }
675
+ }
676
+ );
677
+ if (superClass) {
678
+ Object.setPrototypeOf ? Object.setPrototypeOf( subClass, superClass ) : subClass.__proto__ = superClass;
679
+ }
680
+ }
681
+
682
+ var Clipboard = function (_Emitter) {
683
+ _inherits( Clipboard, _Emitter );
684
+
685
+ /**
686
+ * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
687
+ * @param {Object} options
688
+ */
689
+
690
+ function Clipboard(trigger, options) {
691
+ _classCallCheck( this, Clipboard );
692
+
693
+ var _this = _possibleConstructorReturn( this, _Emitter.call( this ) );
694
+
695
+ _this.resolveOptions( options );
696
+ _this.listenClick( trigger );
697
+ return _this;
698
+ }
699
+
700
+ /**
701
+ * Defines if attributes would be resolved using internal setter functions
702
+ * or custom functions that were passed in the constructor.
703
+ *
704
+ * @param {Object} options
705
+ */
706
+
707
+ Clipboard.prototype.resolveOptions = function resolveOptions() {
708
+ var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
709
+
710
+ this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
711
+ this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
712
+ this.text = typeof options.text === 'function' ? options.text : this.defaultText;
713
+ };
714
+
715
+ Clipboard.prototype.listenClick = function listenClick(trigger) {
716
+ var _this2 = this;
717
+
718
+ this.listener = (0, _goodListener2.default)(
719
+ trigger, 'click', function (e) {
720
+ return _this2.onClick( e );
721
+ }
722
+ );
723
+ };
724
+
725
+ Clipboard.prototype.onClick = function onClick(e) {
726
+ var trigger = e.delegateTarget || e.currentTarget;
727
+
728
+ if (this.clipboardAction) {
729
+ this.clipboardAction = null;
730
+ }
731
+
732
+ this.clipboardAction = new _clipboardAction2.default(
733
+ {
734
+ action: this.action( trigger ),
735
+ target: this.target( trigger ),
736
+ text: this.text( trigger ),
737
+ trigger: trigger,
738
+ emitter: this
739
+ }
740
+ );
741
+ };
742
+
743
+ Clipboard.prototype.defaultAction = function defaultAction(trigger) {
744
+ return getAttributeValue( 'action', trigger );
745
+ };
746
+
747
+ Clipboard.prototype.defaultTarget = function defaultTarget(trigger) {
748
+ var selector = getAttributeValue( 'target', trigger );
749
+
750
+ if (selector) {
751
+ return document.querySelector( selector );
752
+ }
753
+ };
754
+
755
+ Clipboard.prototype.defaultText = function defaultText(trigger) {
756
+ return getAttributeValue( 'text', trigger );
757
+ };
758
+
759
+ Clipboard.prototype.destroy = function destroy() {
760
+ this.listener.destroy();
761
+
762
+ if (this.clipboardAction) {
763
+ this.clipboardAction.destroy();
764
+ this.clipboardAction = null;
765
+ }
766
+ };
767
+
768
+ return Clipboard;
769
+ }(_tinyEmitter2.default);
770
+
771
+ /**
772
+ * Helper function to retrieve attribute value.
773
+ *
774
+ * @param {String} suffix
775
+ * @param {Element} element
776
+ */
777
+ function getAttributeValue(suffix, element) {
778
+ var attribute = 'data-clipboard-' + suffix;
779
+
780
+ if ( ! element.hasAttribute( attribute )) {
781
+ return;
782
+ }
783
+
784
+ return element.getAttribute( attribute );
785
+ }
786
+
787
+ module.exports = Clipboard;
788
+ }
789
+ );
790
+
791
+ },{"./clipboard-action":8,"good-listener":4,"tiny-emitter":7}]},{},[9]
792
+ )( 9 )
793
  }
794
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/js/wp-temporary-login-without-password-admin.js CHANGED
@@ -1,89 +1,117 @@
 
 
 
 
 
 
1
  (function ($) {
2
- 'use strict';
3
-
4
- jQuery(document).ready(function () {
5
-
6
- jQuery('#add-new-wtlwp-form-button').click(function () {
7
- jQuery('#new-wtlwp-form').show();
8
- jQuery('#update-wtlwp-form').hide();
9
- });
10
-
11
- jQuery('#cancel-new-login-form').click(function () {
12
- jQuery('#new-wtlwp-form').hide();
13
- jQuery('#update-wtlwp-form').show();
14
- });
15
-
16
- jQuery('#cancel-update-login-form').click(function () {
17
- jQuery('#update-wtlwp-form').hide();
18
- });
19
-
20
- if (jQuery('.wtlwp-click-to-copy-btn').get(0)) {
21
-
22
- var clipboard = new Clipboard('.wtlwp-click-to-copy-btn');
23
-
24
- clipboard.on('success', function (e) {
25
- var elem = e.trigger;
26
- var className = elem.getAttribute('class');
27
- jQuery('#copied-text-message-' + className).text('Copied').fadeIn();
28
- jQuery('#copied-text-message-' + className).fadeOut('slow');
29
- });
30
- }
31
-
32
- if (jQuery('.wtlwp-copy-to-clipboard').get(0)) {
33
- var clipboard_link = new Clipboard('.wtlwp-copy-to-clipboard');
34
-
35
- clipboard_link.on('success', function (e) {
36
- var elem = e.trigger;
37
- var id = elem.getAttribute('id');
38
- jQuery('#copied-' + id).text('Copied').fadeIn();
39
- jQuery('#copied-' + id).fadeOut('slow');
40
- });
41
- }
42
-
43
- jQuery('#new-user-expiry-time').change(function () {
44
- var value = jQuery(this).val();
45
- showDatePicker(value, 'new');
46
- });
47
-
48
- jQuery('#update-user-expiry-time').change(function () {
49
- var value = jQuery(this).val();
50
- showDatePicker(value, 'update');
51
- });
52
-
53
- jQuery('a.tlwp-rating-link').click(function () {
54
- jQuery.post(data.admin_ajax_url, {action: 'tlwp_rated'});
55
- jQuery(this).parent().text(jQuery(this).data('rated'));
56
- });
57
-
58
- jQuery('a.tlwp-rating-link-header').click(function () {
59
- jQuery.post(data.admin_ajax_url, {action: 'tlwp_reivew_header'});
60
- jQuery(this).parent().text(jQuery(this).data('rated'));
61
- });
62
-
63
- function showDatePicker(value, datePickerClass) {
64
-
65
- var customDatePickerClass = '';
66
- var customDatePickerID = '';
67
- if( 'new' === datePickerClass ) {
68
- customDatePickerClass = '.new-custom-date-picker';
69
- customDatePickerID = '#new-custom-date-picker';
70
- } else {
71
- customDatePickerClass = '.update-custom-date-picker';
72
- customDatePickerID = '#update-custom-date-picker';
73
- }
74
-
75
- if (value === 'custom_date') {
76
- var tomorrowDate = new Date(new Date().getTime() + 24 * 60 * 60 * 1000);
77
- jQuery(customDatePickerClass).datepicker({
78
- dateFormat: 'yy-mm-dd',
79
- minDate: tomorrowDate
80
- });
81
- jQuery(customDatePickerID).show();
82
- } else {
83
- jQuery(customDatePickerID).hide();
84
- }
85
- }
86
-
87
- });
88
-
89
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Admin Settings Js.
3
+ *
4
+ * @package Temporary Login Without Password
5
+ */
6
+
7
  (function ($) {
8
+ 'use strict';
9
+
10
+ jQuery( document ).ready(
11
+ function () {
12
+
13
+ jQuery( '#add-new-wtlwp-form-button' ).click(
14
+ function () {
15
+ jQuery( '#new-wtlwp-form' ).show();
16
+ jQuery( '#update-wtlwp-form' ).hide();
17
+ }
18
+ );
19
+
20
+ jQuery( '#cancel-new-login-form' ).click(
21
+ function () {
22
+ jQuery( '#new-wtlwp-form' ).hide();
23
+ jQuery( '#update-wtlwp-form' ).show();
24
+ }
25
+ );
26
+
27
+ jQuery( '#cancel-update-login-form' ).click(
28
+ function () {
29
+ jQuery( '#update-wtlwp-form' ).hide();
30
+ }
31
+ );
32
+
33
+ if (jQuery( '.wtlwp-click-to-copy-btn' ).get( 0 )) {
34
+
35
+ var clipboard = new Clipboard( '.wtlwp-click-to-copy-btn' );
36
+
37
+ clipboard.on(
38
+ 'success', function (e) {
39
+ var elem = e.trigger;
40
+ var className = elem.getAttribute( 'class' );
41
+ jQuery( '#copied-text-message-' + className ).text( 'Copied' ).fadeIn();
42
+ jQuery( '#copied-text-message-' + className ).fadeOut( 'slow' );
43
+ }
44
+ );
45
+ }
46
+
47
+ if (jQuery( '.wtlwp-copy-to-clipboard' ).get( 0 )) {
48
+ var clipboard_link = new Clipboard( '.wtlwp-copy-to-clipboard' );
49
+
50
+ clipboard_link.on(
51
+ 'success', function (e) {
52
+ var elem = e.trigger;
53
+ var id = elem.getAttribute( 'id' );
54
+ jQuery( '#copied-' + id ).text( 'Copied' ).fadeIn();
55
+ jQuery( '#copied-' + id ).fadeOut( 'slow' );
56
+ }
57
+ );
58
+ }
59
+
60
+ jQuery( '#new-user-expiry-time' ).change(
61
+ function () {
62
+ var value = jQuery( this ).val();
63
+ showDatePicker( value, 'new' );
64
+ }
65
+ );
66
+
67
+ jQuery( '#update-user-expiry-time' ).change(
68
+ function () {
69
+ var value = jQuery( this ).val();
70
+ showDatePicker( value, 'update' );
71
+ }
72
+ );
73
+
74
+ jQuery( 'a.tlwp-rating-link' ).click(
75
+ function () {
76
+ jQuery.post( data.admin_ajax_url, {action: 'tlwp_rated'} );
77
+ jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );
78
+ }
79
+ );
80
+
81
+ jQuery( 'a.tlwp-rating-link-header' ).click(
82
+ function () {
83
+ jQuery.post( data.admin_ajax_url, {action: 'tlwp_reivew_header'} );
84
+ jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );
85
+ }
86
+ );
87
+
88
+ function showDatePicker(value, datePickerClass) {
89
+
90
+ var customDatePickerClass = '';
91
+ var customDatePickerID = '';
92
+ if ( 'new' === datePickerClass ) {
93
+ customDatePickerClass = '.new-custom-date-picker';
94
+ customDatePickerID = '#new-custom-date-picker';
95
+ } else {
96
+ customDatePickerClass = '.update-custom-date-picker';
97
+ customDatePickerID = '#update-custom-date-picker';
98
+ }
99
+
100
+ if (value === 'custom_date') {
101
+ var tomorrowDate = new Date( new Date().getTime() + 24 * 60 * 60 * 1000 );
102
+ jQuery( customDatePickerClass ).datepicker(
103
+ {
104
+ dateFormat: 'yy-mm-dd',
105
+ minDate: tomorrowDate
106
+ }
107
+ );
108
+ jQuery( customDatePickerID ).show();
109
+ } else {
110
+ jQuery( customDatePickerID ).hide();
111
+ }
112
+ }
113
+
114
+ }
115
+ );
116
+
117
+ })( jQuery );
includes/class-wp-temporary-login-without-password-activator.php CHANGED
@@ -1,7 +1,22 @@
1
  <?php
2
-
 
 
 
 
 
 
 
 
 
 
3
  class Wp_Temporary_Login_Without_Password_Activator {
4
 
 
 
 
 
 
5
  public static function activate() {
6
  /**
7
  * Process
1
  <?php
2
+ /**
3
+ * Activator Class
4
+ *
5
+ * @package Temporary Login Without Password
6
+ */
7
+
8
+ /**
9
+ * Class Wp_Temporary_Login_Without_Password_Activator
10
+ *
11
+ * @package Temporary Login Without Password
12
+ */
13
  class Wp_Temporary_Login_Without_Password_Activator {
14
 
15
+ /**
16
+ * Activate Plugin.
17
+ *
18
+ * @since 1.0.0
19
+ */
20
  public static function activate() {
21
  /**
22
  * Process
includes/class-wp-temporary-login-without-password-common.php CHANGED
@@ -49,6 +49,10 @@ class Wp_Temporary_Login_Without_Password_Common {
49
  return 0;
50
  }
51
 
 
 
 
 
52
  $expiry_option = ! empty( $data['expiry'] ) ? $data['expiry'] : 'day';
53
  $date = ! empty( $data['custom_date'] ) ? $data['custom_date'] : '';
54
 
@@ -72,25 +76,28 @@ class Wp_Temporary_Login_Without_Password_Common {
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
- );
80
- }
81
 
82
- if ( is_multisite() && ! empty( $data['super_admin'] ) && 'on' === $data['super_admin'] ) {
83
- grant_super_admin( $user_id );
84
- }
85
 
86
- update_user_meta( $user_id, '_wtlwp_user', true );
87
- update_user_meta( $user_id, '_wtlwp_created', Wp_Temporary_Login_Without_Password_Common::get_current_gmt_timestamp() );
88
- update_user_meta( $user_id, '_wtlwp_expire', Wp_Temporary_Login_Without_Password_Common::get_user_expire_time( $expiry_option, $date ) );
89
- update_user_meta( $user_id, '_wtlwp_token', Wp_Temporary_Login_Without_Password_Common::generate_wtlwp_token( $user_id ) );
90
 
91
- update_user_meta( $user_id, 'show_welcome_panel', 0 );
 
 
 
92
 
93
- return $user_id;
 
 
 
 
 
 
 
94
 
95
  }
96
 
@@ -828,11 +835,49 @@ class Wp_Temporary_Login_Without_Password_Common {
828
  */
829
  public static function generate_mailto_link( $email, $temporary_login_link ) {
830
 
831
- $mailto_subject = __( 'Temporary Login Link', 'temporary-login-without-password' );
832
- $mailto_body = nl2br( __( "Hello, \n\n Click on following link to login into the system. \n\n {$temporary_login_link} \n\n", 'temporary-login-without-password' ) );
 
 
 
833
 
834
  $mailto_link = __( sprintf( "mailto:%s?subject=%s&body=%s", $email, $mailto_subject, $mailto_body ), 'temporary-login-without-password' );
835
 
836
  return $mailto_link;
837
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
838
  }
49
  return 0;
50
  }
51
 
52
+ $result = array(
53
+ 'error' => true
54
+ );
55
+
56
  $expiry_option = ! empty( $data['expiry'] ) ? $data['expiry'] : 'day';
57
  $date = ! empty( $data['custom_date'] ) ? $data['custom_date'] : '';
58
 
76
  if ( is_wp_error( $user_id ) ) {
77
  $code = $user_id->get_error_code();
78
 
79
+ $result['errcode'] = $code;
80
+ $result['message'] = $user_id->get_error_message( $code );
 
 
 
 
81
 
82
+ } else {
 
 
83
 
84
+ if ( is_multisite() && ! empty( $data['super_admin'] ) && 'on' === $data['super_admin'] ) {
85
+ grant_super_admin( $user_id );
86
+ }
 
87
 
88
+ update_user_meta( $user_id, '_wtlwp_user', true );
89
+ update_user_meta( $user_id, '_wtlwp_created', Wp_Temporary_Login_Without_Password_Common::get_current_gmt_timestamp() );
90
+ update_user_meta( $user_id, '_wtlwp_expire', Wp_Temporary_Login_Without_Password_Common::get_user_expire_time( $expiry_option, $date ) );
91
+ update_user_meta( $user_id, '_wtlwp_token', Wp_Temporary_Login_Without_Password_Common::generate_wtlwp_token( $user_id ) );
92
 
93
+ update_user_meta( $user_id, 'show_welcome_panel', 0 );
94
+
95
+ $result['error'] = false;
96
+ $result['user_id'] = $user_id;
97
+
98
+ }
99
+
100
+ return $result;
101
 
102
  }
103
 
835
  */
836
  public static function generate_mailto_link( $email, $temporary_login_link ) {
837
 
838
+ $double_line_break = '%0D%0A%0D%0A'; // as per RFC2368
839
+ $mailto_greeting = __( 'Hello,', 'temporary-login-without-password' );
840
+ $mailto_instruction = __( 'Click the following link to log into the system:', 'temporary-login-without-password' );
841
+ $mailto_subject = __( 'Temporary Login Link', 'temporary-login-without-password' );
842
+ $mailto_body = $mailto_greeting . $double_line_break . $mailto_instruction . $double_line_break . $temporary_login_link . $double_line_break;
843
 
844
  $mailto_link = __( sprintf( "mailto:%s?subject=%s&body=%s", $email, $mailto_subject, $mailto_body ), 'temporary-login-without-password' );
845
 
846
  return $mailto_link;
847
  }
848
+
849
+ /**
850
+ * Can we ask user for review?
851
+ *
852
+ * @param int $current_user_id
853
+ *
854
+ * @since 1.4.5
855
+ *
856
+ * @return bool
857
+ */
858
+ public static function can_ask_for_review( $current_user_id ) {
859
+
860
+ $tlwp_nobug = get_user_meta( $current_user_id, 'tlwp_no_bug', true );
861
+ $no_bug_days_before = 1;
862
+ $tlwp_nobug_no_time = get_user_meta( $current_user_id, 'tlwp_no_bug_time', true );
863
+
864
+ if ( ! empty( $tlwp_nobug_no_time ) && 0 !== $tlwp_nobug_no_time ) {
865
+ $no_bug_time_diff = time() - $tlwp_nobug_no_time;
866
+ $no_bug_days_before = floor( $no_bug_time_diff / 86400 ); // 86400 seconds == 1 day
867
+ }
868
+
869
+ $tlwp_rated = get_user_meta( $current_user_id, 'tlwp_admin_footer_text_rated', true );
870
+ $tlwp_rated_header = get_user_meta( $current_user_id, 'tlwp_admin_header_text_rated', true );
871
+ $temporary_logins = self::get_temporary_logins();
872
+ $total_logins = count( $temporary_logins );
873
+
874
+ // Is user fall in love with our plugin in 60 days after they said no for the review?
875
+ // But, make sure we are asking user only after 60 days.
876
+ // We are good people. Respect the user decision.
877
+ if ( ( $tlwp_nobug && $no_bug_days_before < 60 ) || $tlwp_rated || $tlwp_rated_header || ( $total_logins < 1 ) ) {
878
+ return false;
879
+ }
880
+
881
+ return true;
882
+ }
883
  }
includes/class-wp-temporary-login-without-password-deactivator.php CHANGED
@@ -1,7 +1,22 @@
1
  <?php
 
 
 
 
 
2
 
 
 
 
 
 
3
  class Wp_Temporary_Login_Without_Password_Deactivator {
4
 
 
 
 
 
 
5
  public static function deactivate() {
6
 
7
  /**
@@ -19,9 +34,9 @@ class Wp_Temporary_Login_Without_Password_Deactivator {
19
  if ( $user instanceof WP_User ) {
20
  $temporary_logins_data[ $user->ID ] = $user->roles[0];
21
  wp_update_user( array(
22
- 'ID' => $user->ID,
23
  'role' => '',
24
- ) ); // Downgrade role to none. So, user won't be able to login
25
  }
26
  }
27
  }
1
  <?php
2
+ /**
3
+ * Deactivator Class
4
+ *
5
+ * @package Temporary Login Without Password
6
+ */
7
 
8
+ /**
9
+ * Class Wp_Temporary_Login_Without_Password_Deactivator
10
+ *
11
+ * @package Temporary Login Without Password
12
+ */
13
  class Wp_Temporary_Login_Without_Password_Deactivator {
14
 
15
+ /**
16
+ * Deactivate Plugin.
17
+ *
18
+ * @since 1.0.0
19
+ */
20
  public static function deactivate() {
21
 
22
  /**
34
  if ( $user instanceof WP_User ) {
35
  $temporary_logins_data[ $user->ID ] = $user->roles[0];
36
  wp_update_user( array(
37
+ 'ID' => $user->ID,
38
  'role' => '',
39
+ ) ); // Downgrade role to none. So, user won't be able to login.
40
  }
41
  }
42
  }
includes/class-wp-temporary-login-without-password-i18n.php CHANGED
@@ -1,10 +1,22 @@
1
  <?php
 
 
 
 
 
2
 
3
  /**
4
  * Define the internationalization functionality
 
 
5
  */
6
- class Wp_Temporary_Login_Without_Password_i18n {
7
 
 
 
 
 
 
8
  public function load_plugin_textdomain() {
9
 
10
  load_plugin_textdomain(
1
  <?php
2
+ /**
3
+ * Localiztion
4
+ *
5
+ * @package Temporary Login Without Password
6
+ */
7
 
8
  /**
9
  * Define the internationalization functionality
10
+ *
11
+ * Class Wp_Temporary_Login_Without_Password_I18n
12
  */
13
+ class Wp_Temporary_Login_Without_Password_I18n {
14
 
15
+ /**
16
+ * Load plugin text domain
17
+ *
18
+ * @since 1.0.0
19
+ */
20
  public function load_plugin_textdomain() {
21
 
22
  load_plugin_textdomain(
includes/class-wp-temporary-login-without-password-layout.php CHANGED
@@ -1,9 +1,19 @@
1
  <?php
2
-
 
 
 
 
 
 
 
 
 
 
3
  class Wp_Temporary_Login_Without_Password_Layout {
4
 
5
  /**
6
- * Create footer headings
7
  *
8
  * @since 1.0
9
  *
@@ -23,7 +33,7 @@ class Wp_Temporary_Login_Without_Password_Layout {
23
  }
24
 
25
  /**
26
- * Prepare empty user row
27
  *
28
  * @since 1.0
29
  *
@@ -43,7 +53,9 @@ class Wp_Temporary_Login_Without_Password_Layout {
43
  }
44
 
45
  /**
46
- * @param WP_User|int $user
 
 
47
  *
48
  * @since 1.0
49
  *
@@ -55,8 +67,8 @@ class Wp_Temporary_Login_Without_Password_Layout {
55
  $user = get_user_by( 'id', $user );
56
  }
57
 
58
- $expire = get_user_meta( $user->ID, '_wtlwp_expire', true );
59
- $last_login_time = get_user_meta( $user->ID, '_wtlwp_last_login', true );
60
 
61
  $last_login_str = __( 'Not yet logged in', 'temporary-login-without-password' );
62
  if ( ! empty( $last_login_time ) ) {
@@ -117,8 +129,10 @@ class Wp_Temporary_Login_Without_Password_Layout {
117
  }
118
 
119
  /**
120
- * @param WP_User $user
121
- * @param string $wtlwp_status
 
 
122
  *
123
  * @since 1.0
124
  *
@@ -131,7 +145,13 @@ class Wp_Temporary_Login_Without_Password_Layout {
131
  $email = $user->user_email;
132
 
133
  $delete_login_url = Wp_Temporary_Login_Without_Password_Common::get_manage_login_url( $user_id, 'delete' );
134
- $update_login_url = add_query_arg( array( 'page' => 'wp-temporary-login-without-password', 'user_id' => $user_id, 'action' => 'update' ), admin_url( 'users.php' ) );
 
 
 
 
 
 
135
  $disable_login_url = Wp_Temporary_Login_Without_Password_Common::get_manage_login_url( $user_id, 'disable' );
136
  $enable_login_url = Wp_Temporary_Login_Without_Password_Common::get_manage_login_url( $user_id, 'enable' );
137
  $temporary_login_link = Wp_Temporary_Login_Without_Password_Common::get_login_url( $user_id );
@@ -148,14 +168,14 @@ class Wp_Temporary_Login_Without_Password_Layout {
148
  $action_row .= "<span class='delete'><a title='" . __( 'Delete', 'temporary-login-without-password' ) . "' href='{$delete_login_url}'><span class='dashicons dashicons-no'></span></a></span>";
149
  $action_row .= "<span class='edit'><a title='" . __( 'Edit', 'temporary-login-without-password' ) . "' href='{$update_login_url}'><span class='dashicons dashicons-edit'></span></a></span>";
150
 
151
- // Shows these link only if temporary login active
152
  if ( $is_active ) {
153
  $action_row .= "<span class='email'><a title='" . __( 'Email login link', 'temporary-login-without-password' ) . "' href='{$mail_to_link}'><span class='dashicons dashicons-email'></span></a></span>";
154
  $action_row .= "<span class='copy'><span id='text-{$user_id}' class='dashicons dashicons-admin-links wtlwp-copy-to-clipboard' title='" . __( 'Copy login link', 'temporary-login-without-password' ) . "' data-clipboard-text='{$temporary_login_link}'></span></span>";
155
  $action_row .= "<span id='copied-text-{$user_id}' class='copied-text-message'></span>";
156
  }
157
 
158
- $action_row .= "</div>";
159
 
160
  return $action_row;
161
  }
1
  <?php
2
+ /**
3
+ * Plugin Layout Class
4
+ *
5
+ * @package Temporary Login Without Password
6
+ */
7
+
8
+ /**
9
+ * Manage Plugin Layout.
10
+ *
11
+ * Class Wp_Temporary_Login_Without_Password_Layout
12
+ */
13
  class Wp_Temporary_Login_Without_Password_Layout {
14
 
15
  /**
16
+ * Create footer headings.
17
  *
18
  * @since 1.0
19
  *
33
  }
34
 
35
  /**
36
+ * Prepare empty user row.
37
  *
38
  * @since 1.0
39
  *
53
  }
54
 
55
  /**
56
+ * Prepare single user row
57
+ *
58
+ * @param WP_User|int $user WP_User object.
59
  *
60
  * @since 1.0
61
  *
67
  $user = get_user_by( 'id', $user );
68
  }
69
 
70
+ $expire = get_user_meta( $user->ID, '_wtlwp_expire', true ); // phpcs:ignore
71
+ $last_login_time = get_user_meta( $user->ID, '_wtlwp_last_login', true ); // phpcs:ignore
72
 
73
  $last_login_str = __( 'Not yet logged in', 'temporary-login-without-password' );
74
  if ( ! empty( $last_login_time ) ) {
129
  }
130
 
131
  /**
132
+ * Prepare user actions row.
133
+ *
134
+ * @param WP_User $user WP_User object.
135
+ * @param string $wtlwp_status Current wtlwp_status.
136
  *
137
  * @since 1.0
138
  *
145
  $email = $user->user_email;
146
 
147
  $delete_login_url = Wp_Temporary_Login_Without_Password_Common::get_manage_login_url( $user_id, 'delete' );
148
+ $update_login_url = add_query_arg(
149
+ array(
150
+ 'page' => 'wp-temporary-login-without-password',
151
+ 'user_id' => $user_id,
152
+ 'action' => 'update',
153
+ ), admin_url( 'users.php' )
154
+ );
155
  $disable_login_url = Wp_Temporary_Login_Without_Password_Common::get_manage_login_url( $user_id, 'disable' );
156
  $enable_login_url = Wp_Temporary_Login_Without_Password_Common::get_manage_login_url( $user_id, 'enable' );
157
  $temporary_login_link = Wp_Temporary_Login_Without_Password_Common::get_login_url( $user_id );
168
  $action_row .= "<span class='delete'><a title='" . __( 'Delete', 'temporary-login-without-password' ) . "' href='{$delete_login_url}'><span class='dashicons dashicons-no'></span></a></span>";
169
  $action_row .= "<span class='edit'><a title='" . __( 'Edit', 'temporary-login-without-password' ) . "' href='{$update_login_url}'><span class='dashicons dashicons-edit'></span></a></span>";
170
 
171
+ // Shows these link only if temporary login active.
172
  if ( $is_active ) {
173
  $action_row .= "<span class='email'><a title='" . __( 'Email login link', 'temporary-login-without-password' ) . "' href='{$mail_to_link}'><span class='dashicons dashicons-email'></span></a></span>";
174
  $action_row .= "<span class='copy'><span id='text-{$user_id}' class='dashicons dashicons-admin-links wtlwp-copy-to-clipboard' title='" . __( 'Copy login link', 'temporary-login-without-password' ) . "' data-clipboard-text='{$temporary_login_link}'></span></span>";
175
  $action_row .= "<span id='copied-text-{$user_id}' class='copied-text-message'></span>";
176
  }
177
 
178
+ $action_row .= '</div>';
179
 
180
  return $action_row;
181
  }
includes/class-wp-temporary-login-without-password-loader.php CHANGED
@@ -1,11 +1,33 @@
1
  <?php
2
-
3
  /**
4
  * Register all actions and filters for the plugin
 
 
 
 
 
 
 
 
5
  */
6
  class Wp_Temporary_Login_Without_Password_Loader {
7
 
 
 
 
 
 
 
 
8
  protected $actions;
 
 
 
 
 
 
 
 
9
  protected $filters;
10
 
11
  /**
@@ -19,11 +41,13 @@ class Wp_Temporary_Login_Without_Password_Loader {
19
  }
20
 
21
  /**
22
- * @param $hook
23
- * @param $component
24
- * @param $callback
25
- * @param int $priority
26
- * @param int $accepted_args
 
 
27
  *
28
  * @since 1.0
29
  */
@@ -32,11 +56,13 @@ class Wp_Temporary_Login_Without_Password_Loader {
32
  }
33
 
34
  /**
35
- * @param $hook
36
- * @param $component
37
- * @param $callback
38
- * @param int $priority
39
- * @param int $accepted_args
 
 
40
  *
41
  * @since 1.0
42
  */
@@ -45,12 +71,14 @@ class Wp_Temporary_Login_Without_Password_Loader {
45
  }
46
 
47
  /**
48
- * @param $hooks
49
- * @param $hook
50
- * @param $component
51
- * @param $callback
52
- * @param $priority
53
- * @param $accepted_args
 
 
54
  *
55
  * @since 1.0
56
  *
@@ -70,23 +98,28 @@ class Wp_Temporary_Login_Without_Password_Loader {
70
  }
71
 
72
  /**
 
73
  *
74
  * @since 1.0
75
  */
76
  public function run() {
77
 
78
  foreach ( $this->filters as $hook ) {
79
- add_filter( $hook['hook'], array(
80
- $hook['component'],
81
- $hook['callback'],
82
- ), $hook['priority'], $hook['accepted_args'] );
 
 
83
  }
84
 
85
  foreach ( $this->actions as $hook ) {
86
- add_action( $hook['hook'], array(
87
- $hook['component'],
88
- $hook['callback'],
89
- ), $hook['priority'], $hook['accepted_args'] );
 
 
90
  }
91
  }
92
 
1
  <?php
 
2
  /**
3
  * Register all actions and filters for the plugin
4
+ *
5
+ * @package Temporary Login Without Password
6
+ */
7
+
8
+ /**
9
+ * Class Wp_Temporary_Login_Without_Password_Loader
10
+ *
11
+ * @package Temporary Login Without Password
12
  */
13
  class Wp_Temporary_Login_Without_Password_Loader {
14
 
15
+ /**
16
+ * All Actions to be added
17
+ *
18
+ * @var array $actions add actions.
19
+ *
20
+ * @since 1.0.0
21
+ */
22
  protected $actions;
23
+
24
+ /**
25
+ * All filteres to be added
26
+ *
27
+ * @var array $filters Define filteres.
28
+ *
29
+ * @since 1.0.0
30
+ */
31
  protected $filters;
32
 
33
  /**
41
  }
42
 
43
  /**
44
+ * Add action into $this->actions array
45
+ *
46
+ * @param string $hook Hook to be added.
47
+ * @param string $component component.
48
+ * @param string $callback class name.
49
+ * @param int $priority priority.
50
+ * @param int $accepted_args No of arguments.
51
  *
52
  * @since 1.0
53
  */
56
  }
57
 
58
  /**
59
+ * Add filters into $this->filteres array
60
+ *
61
+ * @param sting $hook Hook to be added.
62
+ * @param string $component component.
63
+ * @param string $callback class name.
64
+ * @param int $priority priority.
65
+ * @param int $accepted_args No of arguments.
66
  *
67
  * @since 1.0
68
  */
71
  }
72
 
73
  /**
74
+ * Collect Hooks
75
+ *
76
+ * @param array $hooks Hooks Array.
77
+ * @param string $hook hook.
78
+ * @param string $component component.
79
+ * @param string $callback class name.
80
+ * @param int $priority Priority.
81
+ * @param int $accepted_args No of arguments.
82
  *
83
  * @since 1.0
84
  *
98
  }
99
 
100
  /**
101
+ * Add Filters.
102
  *
103
  * @since 1.0
104
  */
105
  public function run() {
106
 
107
  foreach ( $this->filters as $hook ) {
108
+ add_filter(
109
+ $hook['hook'], array(
110
+ $hook['component'],
111
+ $hook['callback'],
112
+ ), $hook['priority'], $hook['accepted_args']
113
+ );
114
  }
115
 
116
  foreach ( $this->actions as $hook ) {
117
+ add_action(
118
+ $hook['hook'], array(
119
+ $hook['component'],
120
+ $hook['callback'],
121
+ ), $hook['priority'], $hook['accepted_args']
122
+ );
123
  }
124
  }
125
 
includes/class-wp-temporary-login-without-password.php CHANGED
@@ -1,11 +1,41 @@
1
  <?php
2
-
 
 
 
 
 
 
 
 
 
 
3
  class Wp_Temporary_Login_Without_Password {
4
 
 
 
 
 
 
5
  protected $loader;
 
 
 
 
 
 
6
  protected $plugin_name;
 
 
 
 
 
 
7
  protected $version;
8
 
 
 
 
9
  public function __construct() {
10
 
11
  $this->plugin_name = 'temporary-login-without-password';
@@ -17,6 +47,11 @@ class Wp_Temporary_Login_Without_Password {
17
  $this->define_public_hooks();
18
  }
19
 
 
 
 
 
 
20
  private function load_dependencies() {
21
 
22
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wp-temporary-login-without-password-loader.php';
@@ -30,13 +65,23 @@ class Wp_Temporary_Login_Without_Password {
30
  $this->loader = new Wp_Temporary_Login_Without_Password_Loader();
31
  }
32
 
 
 
 
 
 
33
  private function set_locale() {
34
 
35
- $plugin_i18n = new Wp_Temporary_Login_Without_Password_i18n();
36
 
37
  $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
38
  }
39
 
 
 
 
 
 
40
  private function define_admin_hooks() {
41
 
42
  $plugin_admin = new Wp_Temporary_Login_Without_Password_Admin( $this->get_plugin_name(), $this->get_version() );
@@ -61,6 +106,11 @@ class Wp_Temporary_Login_Without_Password {
61
  $this->loader->add_filter( 'plugin_action_links_' . WTLWP_PLUGIN_BASE_NAME, $plugin_admin, 'plugin_add_settings_link', 10, 4 );
62
  }
63
 
 
 
 
 
 
64
  private function define_public_hooks() {
65
 
66
  $plugin_public = new Wp_Temporary_Login_Without_Password_Public( $this->get_plugin_name(), $this->get_version() );
@@ -70,18 +120,41 @@ class Wp_Temporary_Login_Without_Password {
70
  $this->loader->add_filter( 'allow_password_reset', $plugin_public, 'disable_password_reset', 10, 2 );
71
  }
72
 
 
 
 
 
 
73
  public function run() {
74
  $this->loader->run();
75
  }
76
 
 
 
 
 
 
 
77
  public function get_plugin_name() {
78
  return $this->plugin_name;
79
  }
80
 
 
 
 
 
 
 
81
  public function get_loader() {
82
  return $this->loader;
83
  }
84
 
 
 
 
 
 
 
85
  public function get_version() {
86
  return $this->version;
87
  }
1
  <?php
2
+ /**
3
+ * Main class file
4
+ *
5
+ * @package Temporary Login Without Password
6
+ */
7
+
8
+ /**
9
+ * Class Wp_Temporary_Login_Without_Password
10
+ *
11
+ * @package Temporary Login Without Password
12
+ */
13
  class Wp_Temporary_Login_Without_Password {
14
 
15
+ /**
16
+ * Loader.
17
+ *
18
+ * @var string $loader Loader.
19
+ */
20
  protected $loader;
21
+
22
+ /**
23
+ * Plugin Name.
24
+ *
25
+ * @var string $plugin_name Plugin Name.
26
+ */
27
  protected $plugin_name;
28
+
29
+ /**
30
+ * Plugin Version
31
+ *
32
+ * @var string $version Plugin Version.
33
+ */
34
  protected $version;
35
 
36
+ /**
37
+ * Wp_Temporary_Login_Without_Password constructor.
38
+ */
39
  public function __construct() {
40
 
41
  $this->plugin_name = 'temporary-login-without-password';
47
  $this->define_public_hooks();
48
  }
49
 
50
+ /**
51
+ * Load dependencies.
52
+ *
53
+ * @since 1.0.0
54
+ */
55
  private function load_dependencies() {
56
 
57
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wp-temporary-login-without-password-loader.php';
65
  $this->loader = new Wp_Temporary_Login_Without_Password_Loader();
66
  }
67
 
68
+ /**
69
+ * Set Localization.
70
+ *
71
+ * @since 1.0.0
72
+ */
73
  private function set_locale() {
74
 
75
+ $plugin_i18n = new Wp_Temporary_Login_Without_Password_I18n();
76
 
77
  $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
78
  }
79
 
80
+ /**
81
+ * Define Admin Hooks.
82
+ *
83
+ * @since 1.0.0
84
+ */
85
  private function define_admin_hooks() {
86
 
87
  $plugin_admin = new Wp_Temporary_Login_Without_Password_Admin( $this->get_plugin_name(), $this->get_version() );
106
  $this->loader->add_filter( 'plugin_action_links_' . WTLWP_PLUGIN_BASE_NAME, $plugin_admin, 'plugin_add_settings_link', 10, 4 );
107
  }
108
 
109
+ /**
110
+ * Defind Admin hooks.
111
+ *
112
+ * @since 1.0.0
113
+ */
114
  private function define_public_hooks() {
115
 
116
  $plugin_public = new Wp_Temporary_Login_Without_Password_Public( $this->get_plugin_name(), $this->get_version() );
120
  $this->loader->add_filter( 'allow_password_reset', $plugin_public, 'disable_password_reset', 10, 2 );
121
  }
122
 
123
+ /**
124
+ * Start Loading.
125
+ *
126
+ * @since 1.0.0
127
+ */
128
  public function run() {
129
  $this->loader->run();
130
  }
131
 
132
+ /**
133
+ * Get Plugin Name.
134
+ *
135
+ * @since 1.0.0
136
+ * @return string
137
+ */
138
  public function get_plugin_name() {
139
  return $this->plugin_name;
140
  }
141
 
142
+ /**
143
+ * Get Loader Class.
144
+ *
145
+ * @since 1.0.0
146
+ * @return string
147
+ */
148
  public function get_loader() {
149
  return $this->loader;
150
  }
151
 
152
+ /**
153
+ * Get Plugin Version
154
+ *
155
+ * @since 1.0.0
156
+ * @return string
157
+ */
158
  public function get_version() {
159
  return $this->version;
160
  }
includes/index.php CHANGED
@@ -1 +1,6 @@
1
- <?php // Silence is golden
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Silence is golden
4
+ *
5
+ * @package Temporary Login Without Password
6
+ */
index.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /**
3
- * Silence is golden.
4
  *
5
- * @since 1.0
6
  */
1
  <?php
2
  /**
3
+ * Silence is golden
4
  *
5
+ * @package Temporary Login Without Password
6
  */
languages/temporary-login-without-password.pot CHANGED
@@ -3,7 +3,7 @@ msgid ""
3
  msgstr ""
4
  "Project-Id-Version: PACKAGE VERSION\n"
5
  "Report-Msgid-Bugs-To: \n"
6
- "POT-Creation-Date: 2018-04-09 07:31+0000\n"
7
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
8
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
9
  "Language-Team: \n"
@@ -14,133 +14,141 @@ msgstr ""
14
  "Content-Transfer-Encoding: 8bit\n"
15
  "X-Generator: Loco https://localise.biz/"
16
 
17
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:80
18
  #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/templates/admin_settings.php:13
19
  msgid "Temporary Logins"
20
  msgstr ""
21
 
22
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:392
23
  msgid "User creation failed"
24
  msgstr ""
25
 
26
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:393
27
  msgid "You do not have permission to create a temporary login"
28
  msgstr ""
29
 
30
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:394
31
  msgid "Email is already in use"
32
  msgstr ""
33
 
34
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:395
35
  msgid "Please enter valid email address. Email field should not be empty"
36
  msgstr ""
37
 
38
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:396
39
  msgid "Please enter valid email address"
40
  msgstr ""
41
 
42
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:397
43
  msgid "User you are trying to delete is not temporary"
44
  msgstr ""
45
 
46
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:398
47
  msgid "Nonce failed"
48
  msgstr ""
49
 
50
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:399
51
  msgid "Invalid action"
52
  msgstr ""
53
 
54
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:400
55
  msgid "Unknown error occured"
56
  msgstr ""
57
 
58
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:410
59
  msgid "Login created successfully!"
60
  msgstr ""
61
 
62
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:411
63
  msgid "Login updated successfully!"
64
  msgstr ""
65
 
66
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:412
67
  msgid "Login deleted successfully!"
68
  msgstr ""
69
 
70
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:413
71
  msgid "Login disabled successfully!"
72
  msgstr ""
73
 
74
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:414
75
  msgid "Login enabled successfully!"
76
  msgstr ""
77
 
78
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:415
79
  msgid "Settings have been updated successfully"
80
  msgstr ""
81
 
82
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:416
83
  msgid "Success!"
84
  msgstr ""
85
 
86
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:473
87
  #, php-format
88
  msgid ""
89
  "If you like <strong>Temporary Login Without Password</strong> plugin, please "
90
  "leave us a %s rating. A huge thanks in advance!"
91
  msgstr ""
92
 
93
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:473
94
  msgid "Thank You :) "
95
  msgstr ""
96
 
97
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:475
98
  #, php-format
99
  msgid "Thank you for using %s."
100
  msgstr ""
101
 
102
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:625
103
  msgid "Temporary Access"
104
  msgstr ""
105
 
106
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:158
107
  msgid "One Hour"
108
  msgstr ""
109
 
110
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:159
111
  msgid "Three Hours"
112
  msgstr ""
113
 
114
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:160
115
  msgid "One Day"
116
  msgstr ""
117
 
118
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:161
119
  msgid "Three Days"
120
  msgstr ""
121
 
122
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:162
123
  msgid "One Week"
124
  msgstr ""
125
 
126
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:163
127
  msgid "One Month"
128
  msgstr ""
129
 
130
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:164
131
  msgid "Custom Date"
132
  msgstr ""
133
 
134
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:173
135
  msgid "No Option Found"
136
  msgstr ""
137
 
138
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:634
139
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:669
140
  msgid "Expired"
141
  msgstr ""
142
 
143
- #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:829
 
 
 
 
 
 
 
 
144
  msgid "Temporary Login Link"
145
  msgstr ""
146
 
3
  msgstr ""
4
  "Project-Id-Version: PACKAGE VERSION\n"
5
  "Report-Msgid-Bugs-To: \n"
6
+ "POT-Creation-Date: 2018-04-23 06:52+0000\n"
7
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
8
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
9
  "Language-Team: \n"
14
  "Content-Transfer-Encoding: 8bit\n"
15
  "X-Generator: Loco https://localise.biz/"
16
 
17
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:85
18
  #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/templates/admin_settings.php:13
19
  msgid "Temporary Logins"
20
  msgstr ""
21
 
22
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:383
23
  msgid "User creation failed"
24
  msgstr ""
25
 
26
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:384
27
  msgid "You do not have permission to create a temporary login"
28
  msgstr ""
29
 
30
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:385
31
  msgid "Email is already in use"
32
  msgstr ""
33
 
34
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:386
35
  msgid "Please enter valid email address. Email field should not be empty"
36
  msgstr ""
37
 
38
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:387
39
  msgid "Please enter valid email address"
40
  msgstr ""
41
 
42
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:388
43
  msgid "User you are trying to delete is not temporary"
44
  msgstr ""
45
 
46
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:389
47
  msgid "Nonce failed"
48
  msgstr ""
49
 
50
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:390
51
  msgid "Invalid action"
52
  msgstr ""
53
 
54
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:391
55
  msgid "Unknown error occured"
56
  msgstr ""
57
 
58
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:392
59
  msgid "Login created successfully!"
60
  msgstr ""
61
 
62
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:393
63
  msgid "Login updated successfully!"
64
  msgstr ""
65
 
66
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:394
67
  msgid "Login deleted successfully!"
68
  msgstr ""
69
 
70
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:395
71
  msgid "Login disabled successfully!"
72
  msgstr ""
73
 
74
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:396
75
  msgid "Login enabled successfully!"
76
  msgstr ""
77
 
78
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:397
79
  msgid "Settings have been updated successfully"
80
  msgstr ""
81
 
82
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:398
83
  msgid "Success!"
84
  msgstr ""
85
 
86
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:463
87
  #, php-format
88
  msgid ""
89
  "If you like <strong>Temporary Login Without Password</strong> plugin, please "
90
  "leave us a %s rating. A huge thanks in advance!"
91
  msgstr ""
92
 
93
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:463
94
  msgid "Thank You :) "
95
  msgstr ""
96
 
97
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:465
98
  #, php-format
99
  msgid "Thank you for using %s."
100
  msgstr ""
101
 
102
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/admin/class-wp-temporary-login-without-password-admin.php:626
103
  msgid "Temporary Access"
104
  msgstr ""
105
 
106
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:165
107
  msgid "One Hour"
108
  msgstr ""
109
 
110
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:166
111
  msgid "Three Hours"
112
  msgstr ""
113
 
114
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:167
115
  msgid "One Day"
116
  msgstr ""
117
 
118
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:168
119
  msgid "Three Days"
120
  msgstr ""
121
 
122
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:169
123
  msgid "One Week"
124
  msgstr ""
125
 
126
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:170
127
  msgid "One Month"
128
  msgstr ""
129
 
130
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:171
131
  msgid "Custom Date"
132
  msgstr ""
133
 
134
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:180
135
  msgid "No Option Found"
136
  msgstr ""
137
 
138
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:641
139
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:678
140
  msgid "Expired"
141
  msgstr ""
142
 
143
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:839
144
+ msgid "Hello,"
145
+ msgstr ""
146
+
147
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:840
148
+ msgid "Click the following link to log into the system:"
149
+ msgstr ""
150
+
151
+ #: ../../../../../repositories/GitLab/store-apps/temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php:841
152
  msgid "Temporary Login Link"
153
  msgstr ""
154
 
public/class-wp-temporary-login-without-password-public.php CHANGED
@@ -1,15 +1,49 @@
1
  <?php
2
-
 
 
 
 
 
 
 
 
 
 
3
  class Wp_Temporary_Login_Without_Password_Public {
4
 
 
 
 
 
 
5
  private $plugin_name;
 
 
 
 
 
 
6
  private $version;
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(
@@ -24,11 +58,20 @@ class Wp_Temporary_Login_Without_Password_Public {
24
  return $error_messages;
25
  }
26
 
 
 
 
 
 
 
 
 
 
27
  public function init_wtlwp() {
28
 
29
- if ( ! is_user_logged_in() && ! empty( $_GET['wtlwp_token'] ) ) {
30
 
31
- $wtlwp_token = sanitize_key($_GET['wtlwp_token']);
32
  $users = Wp_Temporary_Login_Without_Password_Common::get_valid_user_based_on_wtlwp_token( $wtlwp_token );
33
 
34
  if ( empty( $users ) ) {
@@ -38,12 +81,12 @@ class Wp_Temporary_Login_Without_Password_Public {
38
 
39
  $user_id = $user->ID;
40
  $user_login = $user->login;
41
- update_user_meta( $user_id, '_wtlwp_last_login', Wp_Temporary_Login_Without_Password_Common::get_current_gmt_timestamp() );
42
  wp_set_current_user( $user_id, $user_login );
43
  wp_set_auth_cookie( $user_id );
44
 
45
  $redirect_to = admin_url();
46
- $redirect_to_url = apply_filters( 'login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user );
47
 
48
  do_action( 'wp_login', $user_login, $user );
49
 
@@ -52,7 +95,7 @@ class Wp_Temporary_Login_Without_Password_Public {
52
  $redirect_to = $redirect_to_url;
53
  }
54
 
55
- wp_safe_redirect( $redirect_to ); // Redirect to given url after successfull login
56
  }
57
  exit();
58
  }
@@ -67,10 +110,10 @@ class Wp_Temporary_Login_Without_Password_Public {
67
  } else {
68
  global $pagenow;
69
  $bloked_pages = Wp_Temporary_Login_Without_Password_Common::get_blocked_pages();
70
- $page = ! empty( $_GET['page'] ) ? $_GET['page'] : '';
71
 
72
- if ( ! empty( $page ) && in_array( $page, $bloked_pages ) || ( ! empty( $pagenow ) && ( in_array( $pagenow, $bloked_pages ) ) ) || ( ! empty( $pagenow ) && ( 'users.php' === $pagenow && isset( $_GET['action'] ) && ( 'deleteuser' === $_GET['action'] || 'delete' === $_GET['action'] ) ) ) ) {
73
- wp_die( __( "You don't have permission to access this page", 'temporary-login-without-password' ) );
74
  }
75
  }
76
  }
@@ -80,12 +123,12 @@ class Wp_Temporary_Login_Without_Password_Public {
80
  /**
81
  * Hooked to wp_authenticate_user filter to disable login for temporary user using username/email and password
82
  *
83
- * @param WP_User $user
84
- * @param string $password
85
  *
86
  * @return \WP_Error
87
  */
88
- function disable_temporary_user_login( $user, $password ) {
89
 
90
  if ( $user instanceof WP_User ) {
91
  $check_expiry = false;
@@ -103,12 +146,12 @@ class Wp_Temporary_Login_Without_Password_Public {
103
  /**
104
  * Hooked to allow_password_reset filter to disable reset password for temporary user
105
  *
106
- * @param boolean $allow
107
- * @param int $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;
1
  <?php
2
+ /**
3
+ * Public face of Temporary Login Without Password
4
+ *
5
+ * @package Temporary Login Without Password
6
+ */
7
+
8
+ /**
9
+ * Class Wp_Temporary_Login_Without_Password_Public
10
+ *
11
+ * @package Temporary Login Without Password
12
+ */
13
  class Wp_Temporary_Login_Without_Password_Public {
14
 
15
+ /**
16
+ * Plugin Name
17
+ *
18
+ * @var string $plugin_name
19
+ */
20
  private $plugin_name;
21
+
22
+ /**
23
+ * Plugin Version
24
+ *
25
+ * @var string $version
26
+ */
27
  private $version;
28
 
29
+ /**
30
+ * Wp_Temporary_Login_Without_Password_Public constructor.
31
+ *
32
+ * @param string $plugin_name Plugin Name.
33
+ * @param srting $version Plugin Version.
34
+ */
35
  public function __construct( $plugin_name, $version ) {
36
  $this->plugin_name = $plugin_name;
37
  $this->version = $version;
38
  }
39
 
40
+ /**
41
+ * Get Error Message
42
+ *
43
+ * @param string $error_code Error Code.
44
+ *
45
+ * @return array|mixed|string
46
+ */
47
  public static function get_error_messages( $error_code ) {
48
 
49
  $error_messages = array(
58
  return $error_messages;
59
  }
60
 
61
+ /**
62
+ * Initialize tlwp
63
+ *
64
+ * Hooked to init filter to initilize tlwp
65
+ *
66
+ * @since 1.0.0
67
+ *
68
+ * @return void
69
+ */
70
  public function init_wtlwp() {
71
 
72
+ if ( ! is_user_logged_in() && ! empty( $_GET['wtlwp_token'] ) ) { // phpcs:ignore
73
 
74
+ $wtlwp_token = sanitize_key( $_GET['wtlwp_token'] ); // Input var okay.
75
  $users = Wp_Temporary_Login_Without_Password_Common::get_valid_user_based_on_wtlwp_token( $wtlwp_token );
76
 
77
  if ( empty( $users ) ) {
81
 
82
  $user_id = $user->ID;
83
  $user_login = $user->login;
84
+ update_user_meta( $user_id, '_wtlwp_last_login', Wp_Temporary_Login_Without_Password_Common::get_current_gmt_timestamp() ); // phpcs:ignore
85
  wp_set_current_user( $user_id, $user_login );
86
  wp_set_auth_cookie( $user_id );
87
 
88
  $redirect_to = admin_url();
89
+ $redirect_to_url = apply_filters( 'login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user ); // phpcs:ignore
90
 
91
  do_action( 'wp_login', $user_login, $user );
92
 
95
  $redirect_to = $redirect_to_url;
96
  }
97
 
98
+ wp_safe_redirect( $redirect_to ); // Redirect to given url after successfull login.
99
  }
100
  exit();
101
  }
110
  } else {
111
  global $pagenow;
112
  $bloked_pages = Wp_Temporary_Login_Without_Password_Common::get_blocked_pages();
113
+ $page = ! empty( $_GET['page'] ) ? $_GET['page'] : ''; //phpcs:ignore
114
 
115
+ if ( ! empty( $page ) && in_array( $page, $bloked_pages) || ( ! empty( $pagenow ) && ( in_array( $pagenow, $bloked_pages ) ) ) || ( ! empty( $pagenow ) && ( 'users.php' === $pagenow && isset( $_GET['action'] ) && ( 'deleteuser' === $_GET['action'] || 'delete' === $_GET['action'] ) ) ) ) { //phpcs:ignore
116
+ wp_die( esc_attr__( "You don't have permission to access this page", 'temporary-login-without-password' ) );
117
  }
118
  }
119
  }
123
  /**
124
  * Hooked to wp_authenticate_user filter to disable login for temporary user using username/email and password
125
  *
126
+ * @param WP_User $user WP_User object.
127
+ * @param string $password password of a user.
128
  *
129
  * @return \WP_Error
130
  */
131
+ public function disable_temporary_user_login( $user, $password ) {
132
 
133
  if ( $user instanceof WP_User ) {
134
  $check_expiry = false;
146
  /**
147
  * Hooked to allow_password_reset filter to disable reset password for temporary user
148
  *
149
+ * @param boolean $allow allow to reset password.
150
+ * @param int $user_id user_id of a user.
151
  *
152
  * @return boolean
153
  */
154
+ public function disable_password_reset( $allow, $user_id ) {
155
 
156
  if ( is_int( $user_id ) ) {
157
  $check_expiry = false;
public/index.php CHANGED
@@ -1 +1,6 @@
1
- <?php // Silence is golden
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Silence is golden
4
+ *
5
+ * @package Temporary Login Without Password
6
+ */
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, developer account, customer access, temporary login, passwordless login, 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, user, WordPress Admin, wp-admin, developer login
5
  Requires at least: 3.0.1
6
  Tested up to: 4.9.5
7
- Stable tag: 1.5.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -44,87 +44,91 @@ If you like Temporary Login Without Password, please leave a five star review on
44
 
45
  == Changelog ==
46
 
47
- **1.5.7 [04-11-2018]**
 
 
 
 
48
 
49
  * Update: Added settings link on Plugins page
50
  * Update: URL parameters sanitized as keys (Thanks to [@danielgm](https://wordpress.org/support/users/danielgm/))
51
  * Update: Paste temporary login link directly into email
52
  * Fix: Lock and delete icon not clickable (Thanks to [@danielgm](https://wordpress.org/support/users/danielgm/))
53
 
54
- **1.5.6 [03-14-2018]**
55
 
56
  * Fix: Datepicker doesn't show up when edit temporary login and select "custom date" value from expiry time dropdown
57
 
58
- **1.5.5 [03-05-2018]**
59
 
60
  * Update: Set default expiry time as a "Week" for new temporary login instead of an "Hour".
61
  * Fix: PHP Warning: in_array() expects parameter 2 to be array, string given in temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php
62
  * Fix: Existing temporary user's role is not available into roles dropdown while edit.
63
 
64
- **1.5.4 [02-20-2018]**
65
 
66
  * Fix: Invalid argument supplied for foreach() PHP Warning in class-wp-temporary-login-without-password-deactivator.php
67
 
68
- **1.5.3 [02-06-2018]**
69
 
70
  * Update: Now, admin can change the role and expiry of temporary login
71
 
72
- **1.5.2 [01-29-2018]**
73
 
74
  * Update: Now, admin can select roles from which they want to create a Tempoary Login.
75
  * Fix: Temporary User with 'administrator' role shows as a 'Super Admin' for WordPress single site installation.
76
 
77
- **1.5.1 [01-19-2018]**
78
 
79
  * Fix: Parse error: syntax error, unexpected ‘[‘ (PHP < 5.4)
80
 
81
- **1.5 [01-08-2018]**
82
 
83
  * Update: Now, Temporary Login can be created for WordPress Multisite. Super Admin can create a temporary super admin for multisite
84
  * Update: Restrict Temporary user to delete other users.
85
 
86
- **1.4.6 [11-18-2017]**
87
 
88
  * Update: Now, admin can set the default role for temporary user from settings panel
89
 
90
- **1.4.5 [11-13-2017]**
91
 
92
  * Update: Restrict temporary user to deactivate/delete Temporary Login Without Password plugin
93
 
94
- **1.4.4 [10-23-2017]**
95
 
96
  * Fix: Trying to load scripts from unauthorized sources error.
97
 
98
- **1.4.3 [08-04-2017]**
99
 
100
  * Fix: Localization issue
101
 
102
- **1.4.2 [06-28-2017]**
103
 
104
  * Fix: Uncaught Error: Call to undefined function wc_enqueue_js().
105
 
106
- **1.4.1 [06-23-2017]**
107
 
108
  * Update: Now, create a temporary login with custom expiry date.
109
 
110
- **1.4 [09-07-2016]**
111
 
112
  * Added: Support for "Theme My Login" plugin. Now, temporary user will be redirected to page which is defined in Theme My Login plugin.
113
 
114
- **1.3 [09-01-2016]**
115
 
116
  * Fix: Temporary user is able to login with email address. Now onwards, temporary user is not able to login using username/email and password
117
  * Fix: Temporary user was able to reset password. Now onwards, they won't be able to reset password.
118
  * Update: Now, role of temporary user is downgrade to "none" on deactivation of plugin and change to default on re activation of plugin
119
 
120
- **1.2 [09-01-2016]**
121
 
122
  * Fix: Temporary user is able to login with username and password.
123
 
124
- **1.1 [08-05-2016]**
125
 
126
  * Fix: Temporary user redirected to login page instead of admin dashboard after successful login.
127
 
128
- **1.0 [08-04-2016]**
129
 
130
  * Initial Release
4
  Tags: admin login, developer account, customer access, temporary login, passwordless login, 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, user, WordPress Admin, wp-admin, developer login
5
  Requires at least: 3.0.1
6
  Tested up to: 4.9.5
7
+ Stable tag: 1.5.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
44
 
45
  == Changelog ==
46
 
47
+ **1.5.8 [2018-04-25]**
48
+
49
+ * Fix: Format temporary login link email for Apple Mail. (Thanks to [@danielgm](https://wordpress.org/support/users/danielgm/))
50
+
51
+ **1.5.7 [2018-04-11]**
52
 
53
  * Update: Added settings link on Plugins page
54
  * Update: URL parameters sanitized as keys (Thanks to [@danielgm](https://wordpress.org/support/users/danielgm/))
55
  * Update: Paste temporary login link directly into email
56
  * Fix: Lock and delete icon not clickable (Thanks to [@danielgm](https://wordpress.org/support/users/danielgm/))
57
 
58
+ **1.5.6 [2018-03-14]**
59
 
60
  * Fix: Datepicker doesn't show up when edit temporary login and select "custom date" value from expiry time dropdown
61
 
62
+ **1.5.5 [2018-03-05]**
63
 
64
  * Update: Set default expiry time as a "Week" for new temporary login instead of an "Hour".
65
  * Fix: PHP Warning: in_array() expects parameter 2 to be array, string given in temporary-login-without-password/includes/class-wp-temporary-login-without-password-common.php
66
  * Fix: Existing temporary user's role is not available into roles dropdown while edit.
67
 
68
+ **1.5.4 [2018-02-20]**
69
 
70
  * Fix: Invalid argument supplied for foreach() PHP Warning in class-wp-temporary-login-without-password-deactivator.php
71
 
72
+ **1.5.3 [2018-02-06]**
73
 
74
  * Update: Now, admin can change the role and expiry of temporary login
75
 
76
+ **1.5.2 [2018-01-29]**
77
 
78
  * Update: Now, admin can select roles from which they want to create a Tempoary Login.
79
  * Fix: Temporary User with 'administrator' role shows as a 'Super Admin' for WordPress single site installation.
80
 
81
+ **1.5.1 [2018-01-19]**
82
 
83
  * Fix: Parse error: syntax error, unexpected ‘[‘ (PHP < 5.4)
84
 
85
+ **1.5 [2018-01-08]**
86
 
87
  * Update: Now, Temporary Login can be created for WordPress Multisite. Super Admin can create a temporary super admin for multisite
88
  * Update: Restrict Temporary user to delete other users.
89
 
90
+ **1.4.6 [2017-11-18]**
91
 
92
  * Update: Now, admin can set the default role for temporary user from settings panel
93
 
94
+ **1.4.5 [2017-11-13]**
95
 
96
  * Update: Restrict temporary user to deactivate/delete Temporary Login Without Password plugin
97
 
98
+ **1.4.4 [2017-10-23]**
99
 
100
  * Fix: Trying to load scripts from unauthorized sources error.
101
 
102
+ **1.4.3 [2017-08-04]**
103
 
104
  * Fix: Localization issue
105
 
106
+ **1.4.2 [2017-06-28]**
107
 
108
  * Fix: Uncaught Error: Call to undefined function wc_enqueue_js().
109
 
110
+ **1.4.1 [2017-06-23]**
111
 
112
  * Update: Now, create a temporary login with custom expiry date.
113
 
114
+ **1.4 [2016-09-07]**
115
 
116
  * Added: Support for "Theme My Login" plugin. Now, temporary user will be redirected to page which is defined in Theme My Login plugin.
117
 
118
+ **1.3 [2016-09-01]**
119
 
120
  * Fix: Temporary user is able to login with email address. Now onwards, temporary user is not able to login using username/email and password
121
  * Fix: Temporary user was able to reset password. Now onwards, they won't be able to reset password.
122
  * Update: Now, role of temporary user is downgrade to "none" on deactivation of plugin and change to default on re activation of plugin
123
 
124
+ **1.2 [2016-09-01]**
125
 
126
  * Fix: Temporary user is able to login with username and password.
127
 
128
+ **1.1 [2016-08-05]**
129
 
130
  * Fix: Temporary user redirected to login page instead of admin dashboard after successful login.
131
 
132
+ **1.0 [2016-08-04]**
133
 
134
  * Initial Release
screenshots/screenshot-1.png DELETED
Binary file
screenshots/screenshot-2.png DELETED
Binary file
screenshots/screenshot-3.png DELETED
Binary file
templates/admin-settings.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Settings Template
4
+ *
5
+ * @package Temporary Login Without Password
6
+ */
7
+
8
+ ?>
9
+ <h2 class="nav-tab-wrapper">
10
+ <a href="<?php echo esc_url( admin_url( 'users.php?page=wp-temporary-login-without-password&tab=home' ) ); ?>" class="nav-tab <?php echo 'home' === $active_tab ? 'nav-tab-active' : ''; ?>"><?php echo esc_html__( 'Temporary Logins', 'temporary-login-without-password' ); ?></a>
11
+ <a href="<?php echo esc_url( admin_url( 'users.php?page=wp-temporary-login-without-password&tab=settings' ) ); ?>" class="nav-tab <?php echo 'settings' === $active_tab ? 'nav-tab-active' : ''; ?>"><?php echo esc_html__( 'Settings', 'temporary-login-without-password' ); ?></a>
12
+ </h2>
13
+
14
+ <?php if ( 'home' === $active_tab ) { ?>
15
+ <div class="wrap wtlwp-settings-wrap" id="temporary-logins">
16
+ <h2>
17
+ <?php echo esc_html__( 'Temporary Logins', 'temporary-login-without-password' ); ?>
18
+ <span class="page-title-action" id="add-new-wtlwp-form-button"><?php esc_html_e( 'Create New', 'temporary-login-without-password' ); ?></span>
19
+ </h2>
20
+ <div class="wtlwp-settings">
21
+ <!-- Add New Form Start -->
22
+
23
+ <div class="wrap new-wtlwp-form" id="new-wtlwp-form">
24
+ <?php include WTLWP_PLUGIN_DIR . '/templates/new-login.php'; ?>
25
+ </div>
26
+
27
+ <?php if ( $do_update ) { ?>
28
+
29
+ <div class="wrap update-wtlwp-form" id="update-wtlwp-form">
30
+ <?php include WTLWP_PLUGIN_DIR . '/templates/update-login.php'; ?>
31
+ </div>
32
+
33
+ <?php } ?>
34
+
35
+ <?php $wtlwp_generated_url = esc_url( $wtlwp_generated_url );
36
+ if ( ! empty( $wtlwp_generated_url ) ) { ?>
37
+
38
+ <div class="wrap generated-wtlwp-login-link" id="generated-wtlwp-login-link">
39
+ <p>
40
+ <?php esc_attr_e( "Here's a temporary login link", 'temporary-login-without-password' ); ?>
41
+ </p>
42
+ <input id="wtlwp-click-to-copy-btn" type="text" class="wtlwp-wide-input" value="<?php echo esc_url( $wtlwp_generated_url ); ?>">
43
+ <button class="wtlwp-click-to-copy-btn" data-clipboard-action="copy" data-clipboard-target="#wtlwp-click-to-copy-btn"><?php echo esc_html__( 'Click To Copy', 'temporary-login-without-password' ); ?></button>
44
+ <span id="copied-text-message-wtlwp-click-to-copy-btn"></span>
45
+ <p>
46
+ <?php
47
+ esc_attr_e( 'User can directly login to WordPress admin panel without username and password by opening this link.', 'temporary-login-without-password' );
48
+ if ( ! empty( $user_email ) ) {
49
+ /* translators: %s: mailto link */
50
+ echo __( sprintf( '<a href="%s">Email</a> temporary login link to user', $mailto_link ), 'temporary-login-without-password' ); //phpcs:ignore
51
+ }
52
+ ?>
53
+ </p>
54
+
55
+ </div>
56
+ <?php } ?>
57
+ <!-- Add New Form End -->
58
+
59
+ <!-- List All Generated Logins Start -->
60
+ <div class="wrap list-wtlwp-logins" id="list-wtlwp-logins">
61
+ <?php load_template( WTLWP_PLUGIN_DIR . '/templates/list-temporary-logins.php' ); ?>
62
+ </div>
63
+ <!-- List All Generated Logins End -->
64
+ </div>
65
+ </div>
66
+ <?php } elseif ( 'settings' === $active_tab ) { ?>
67
+
68
+ <div class="wrap list-wtlwp-logins" id="wtlwp-logins-settings">
69
+ <?php include WTLWP_PLUGIN_DIR . '/templates/temporary-logins-settings.php'; ?>
70
+ </div>
71
+
72
+ <?php } ?>
templates/admin_settings.php DELETED
@@ -1,67 +0,0 @@
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 ( 'home' === $active_tab ) { ?>
11
- <div class="wrap wtlwp-settings-wrap" id="temporary-logins">
12
- <h2>
13
- <?php echo __( 'Temporary Logins', 'temporary-login-without-password' ); ?>
14
- <span class="page-title-action" id="add-new-wtlwp-form-button"><?php _e( 'Create New', 'temporary-login-without-password' ); ?></span>
15
- </h2>
16
- <div class="wtlwp-settings">
17
- <!-- Add New Form Start -->
18
-
19
- <div class="wrap new-wtlwp-form" id="new-wtlwp-form">
20
- <?php include WTLWP_PLUGIN_DIR . '/templates/new_login.php'; ?>
21
- </div>
22
-
23
- <?php if ( $do_update ) { ?>
24
-
25
- <div class="wrap update-wtlwp-form" id="update-wtlwp-form">
26
- <?php include WTLWP_PLUGIN_DIR . '/templates/update_login.php'; ?>
27
- </div>
28
-
29
- <?php } ?>
30
-
31
- <?php if ( ! empty( $wtlwp_generated_url ) ) { ?>
32
-
33
- <div class="wrap generated-wtlwp-login-link" id="generated-wtlwp-login-link">
34
- <p>
35
- <?php _e( "Here's a temporary login link", 'temporary-login-without-password' ); ?>
36
- </p>
37
- <input id="wtlwp-click-to-copy-btn" type="text" class="wtlwp-wide-input" value="<?php echo $wtlwp_generated_url; ?>">
38
- <button class="wtlwp-click-to-copy-btn" data-clipboard-action="copy" data-clipboard-target="#wtlwp-click-to-copy-btn"><?php echo __( 'Click To Copy', 'temporary-login-without-password' ); ?></button>
39
- <span id="copied-text-message-wtlwp-click-to-copy-btn"></span>
40
- <p>
41
- <?php
42
- _e( 'User can directly login to wordpress admin panel without username and password by opening this link.', 'temporary-login-without-password' );
43
- if ( ! empty( $user_email ) ) {
44
- echo __( sprintf( " <a href='{$mailto_link}'>Email</a> temporary login link to user."), 'temporary-login-without-password' );
45
- }
46
- ?>
47
- </p>
48
-
49
- </div>
50
- <?php } ?>
51
- <!-- Add New Form End -->
52
-
53
- <!-- List All Generated Logins Start -->
54
- <div class="wrap list-wtlwp-logins" id="list-wtlwp-logins">
55
- <?php load_template( WTLWP_PLUGIN_DIR . '/templates/list_temporary_logins.php' ); ?>
56
- </div>
57
- <!-- List All Generated Logins End -->
58
- </div>
59
- </div>
60
- <?php } elseif ( 'settings' === $active_tab ) { ?>
61
-
62
- <div class="wrap list-wtlwp-logins" id="wtlwp-logins-settings">
63
- <?php include WTLWP_PLUGIN_DIR . '/templates/temporary_logins_settings.php' ?>
64
- </div>
65
-
66
- <?php }// End if().
67
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
templates/{list_temporary_logins.php → list-temporary-logins.php} RENAMED
@@ -1,5 +1,13 @@
 
 
 
 
 
 
 
 
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
 
1
+ <?php
2
+ /**
3
+ * List Temporary Logins
4
+ *
5
+ * @package Temporary Login Without Password
6
+ */
7
+
8
+ ?>
9
  <table class="wp-list-table widefat fixed striped users">
10
+ <thead>
11
  <?php echo Wp_Temporary_Login_Without_Password_Layout::prepare_header_footer_row(); ?>
12
  </thead>
13
 
templates/{new_login.php → new-login.php} RENAMED
@@ -1,9 +1,17 @@
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">
6
- <label for="user_email"><?php echo __( 'Email*', 'temporary-login-without-password' ); ?> </label>
7
  </th>
8
  <td>
9
  <input name="wtlwp_data[user_email]" type="text" id="user_email" value="" aria-required="true" maxlength="60" class="wtlwp-form-input"/>
@@ -12,7 +20,7 @@
12
 
13
  <tr class="form-field form-required">
14
  <th scope="row" class="wtlwp-form-row">
15
- <label for="user_first_name"><?php echo __( 'First Name', 'temporary-login-without-password' ); ?> </label>
16
  </th>
17
  <td>
18
  <input name="wtlwp_data[user_first_name]" type="text" id="user_first_name" value="" aria-required="true" maxlength="60" class="wtlwp-form-input"/>
@@ -21,7 +29,7 @@
21
 
22
  <tr class="form-field form-required">
23
  <th scope="row" class="wtlwp-form-row">
24
- <label for="user_last_name"><?php echo __( 'Last Name', 'temporary-login-without-password' ); ?> </label>
25
  </th>
26
  <td>
27
  <input name="wtlwp_data[user_last_name]" type="text" id="user_last_name" value="" aria-required="true" maxlength="60" class="wtlwp-form-input"/>
@@ -31,17 +39,16 @@
31
  <?php if ( is_network_admin() ) { ?>
32
  <tr class="form-field form-required">
33
  <th scope="row" class="wtlwp-form-row">
34
- <label for="user_super_admin"><?php echo __( 'Super Admin', 'temporary-login-without-password' ); ?> </label>
35
  </th>
36
  <td>
37
- <input type="checkbox" id="user_super_admin"
38
- name="wtlwp_data[super_admin]"><?php echo __( 'Grant this user super admin privileges for the Network.', 'temporary-login-without-password' ); ?>
39
  </td>
40
  </tr>
41
  <?php } else { ?>
42
  <tr class="form-field">
43
  <th scope="row" class="wtlwp-form-row">
44
- <label for="adduser-role"><?php echo __( 'Role', 'temporary-login-without-password' ); ?></label>
45
  </th>
46
  <td>
47
  <select name="wtlwp_data[role]" id="user-role">
@@ -53,13 +60,13 @@
53
 
54
  <tr class="form-field">
55
  <th scope="row" class="wtlwp-form-row">
56
- <label for="adduser-role"><?php echo __( 'Expiry', 'temporary-login-without-password' ); ?></label>
57
  </th>
58
  <td>
59
  <span id="expiry-date-selection">
60
  <select name="wtlwp_data[expiry]" id="new-user-expiry-time">
61
- <?php Wp_Temporary_Login_Without_Password_Common::get_expiry_duration_html('week'); ?>
62
- </select>
63
  </span>
64
 
65
  <span style="display:none;" id="new-custom-date-picker">
@@ -73,8 +80,8 @@
73
  <th scope="row" class="wtlwp-form-row"><label for="adduser-role"></label></th>
74
  <td>
75
  <p class="submit">
76
- <input type="submit" class="button button-primary wtlwp-form-submit-button" value="<?php _e( 'Submit', 'temporary-login-without-password' ); ?>" class="button button-primary" id="generatetemporarylogin" name="generate_temporary_login"> <?php _e( 'or', 'temporary-login-without-password' ); ?>
77
- <span class="cancel-new-login-form" id="cancel-new-login-form"><?php _e( 'Cancel', 'temporary-login-without-password' ); ?></span>
78
  </p>
79
  </td>
80
  </tr>
1
+ <?php
2
+ /**
3
+ * Create New Temporary Login template
4
+ *
5
+ * @package Temporary Login Without Password
6
+ */
7
+
8
+ ?>
9
+ <h2> <?php echo esc_html__( 'Create a new Temporary Login', 'temporary-login-without-password' ); ?></h2>
10
  <form method="post">
11
  <table class="form-table wtlwp-form">
12
  <tr class="form-field form-required">
13
  <th scope="row" class="wtlwp-form-row">
14
+ <label for="user_email"><?php echo esc_html__( 'Email*', 'temporary-login-without-password' ); ?> </label>
15
  </th>
16
  <td>
17
  <input name="wtlwp_data[user_email]" type="text" id="user_email" value="" aria-required="true" maxlength="60" class="wtlwp-form-input"/>
20
 
21
  <tr class="form-field form-required">
22
  <th scope="row" class="wtlwp-form-row">
23
+ <label for="user_first_name"><?php echo esc_html__( 'First Name', 'temporary-login-without-password' ); ?> </label>
24
  </th>
25
  <td>
26
  <input name="wtlwp_data[user_first_name]" type="text" id="user_first_name" value="" aria-required="true" maxlength="60" class="wtlwp-form-input"/>
29
 
30
  <tr class="form-field form-required">
31
  <th scope="row" class="wtlwp-form-row">
32
+ <label for="user_last_name"><?php echo esc_html__( 'Last Name', 'temporary-login-without-password' ); ?> </label>
33
  </th>
34
  <td>
35
  <input name="wtlwp_data[user_last_name]" type="text" id="user_last_name" value="" aria-required="true" maxlength="60" class="wtlwp-form-input"/>
39
  <?php if ( is_network_admin() ) { ?>
40
  <tr class="form-field form-required">
41
  <th scope="row" class="wtlwp-form-row">
42
+ <label for="user_super_admin"><?php echo esc_html__( 'Super Admin', 'temporary-login-without-password' ); ?> </label>
43
  </th>
44
  <td>
45
+ <input type="checkbox" id="user_super_admin" name="wtlwp_data[super_admin]"><?php echo esc_html__( 'Grant this user super admin privileges for the Network.', 'temporary-login-without-password' ); ?>
 
46
  </td>
47
  </tr>
48
  <?php } else { ?>
49
  <tr class="form-field">
50
  <th scope="row" class="wtlwp-form-row">
51
+ <label for="adduser-role"><?php echo esc_html__( 'Role', 'temporary-login-without-password' ); ?></label>
52
  </th>
53
  <td>
54
  <select name="wtlwp_data[role]" id="user-role">
60
 
61
  <tr class="form-field">
62
  <th scope="row" class="wtlwp-form-row">
63
+ <label for="adduser-role"><?php echo esc_html__( 'Expiry', 'temporary-login-without-password' ); ?></label>
64
  </th>
65
  <td>
66
  <span id="expiry-date-selection">
67
  <select name="wtlwp_data[expiry]" id="new-user-expiry-time">
68
+ <?php Wp_Temporary_Login_Without_Password_Common::get_expiry_duration_html( 'week' ); ?>
69
+ </select>
70
  </span>
71
 
72
  <span style="display:none;" id="new-custom-date-picker">
80
  <th scope="row" class="wtlwp-form-row"><label for="adduser-role"></label></th>
81
  <td>
82
  <p class="submit">
83
+ <input type="submit" class="button button-primary wtlwp-form-submit-button" value="<?php esc_html_e( 'Submit', 'temporary-login-without-password' ); ?>" class="button button-primary" id="generatetemporarylogin" name="generate_temporary_login"> <?php esc_html_e( 'or', 'temporary-login-without-password' ); ?>
84
+ <span class="cancel-new-login-form" id="cancel-new-login-form"><?php esc_html_e( 'Cancel', 'temporary-login-without-password' ); ?></span>
85
  </p>
86
  </td>
87
  </tr>
templates/{temporary_logins_settings.php → temporary-logins-settings.php} RENAMED
@@ -1,10 +1,18 @@
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="visible_roles"><?php echo __( 'Visible Roles', 'temporary-login-without-password' ); ?></label>
7
- <p class="description"><?php echo __( 'select roles from which you want to create a temporary login', 'temporary-login-without-password' ); ?></p>
8
 
9
  </th>
10
  <td>
@@ -15,7 +23,7 @@
15
  </tr>
16
  <tr class="form-field">
17
  <th scope="row" class="wtlwp-form-row">
18
- <label for="adduser-role"><?php echo __( 'Default Role', 'temporary-login-without-password' ); ?></label>
19
  </th>
20
  <td>
21
  <select name="tlwp_settings_data[default_role]" id="default-role" class="default-role-dropdown">
@@ -25,10 +33,10 @@
25
  </tr>
26
 
27
  <tr class="form-field">
28
- <th scope="row" class="wtlwp-form-row"><label for="temporary-login-settings"></label></th>
29
  <td>
30
  <p class="submit">
31
- <input type="submit" class="button button-primary wtlwp-form-submit-button" value="<?php _e( 'Submit', 'temporary-login-without-password' ); ?>" class="button button-primary" id="generatetemporarylogin" name="generate_temporary_login">
32
  </p>
33
  </td>
34
  </tr>
1
+ <?php
2
+ /**
3
+ * Temporary Login settings template
4
+ *
5
+ * @package Temporary Login Without Password
6
+ */
7
+
8
+ ?>
9
+ <h2> <?php echo esc_html__( 'Temporary Login Settings', 'temporary-login-without-password' ); ?></h2>
10
  <form method="post">
11
  <table class="form-table wtlwp-form">
12
  <tr class="form-field">
13
  <th scope="row" class="wtlwp-form-row">
14
+ <label for="visible_roles"><?php echo esc_html__( 'Visible Roles', 'temporary-login-without-password' ); ?></label>
15
+ <p class="description"><?php echo esc_html__( 'select roles from which you want to create a temporary login', 'temporary-login-without-password' ); ?></p>
16
 
17
  </th>
18
  <td>
23
  </tr>
24
  <tr class="form-field">
25
  <th scope="row" class="wtlwp-form-row">
26
+ <label for="adduser-role"><?php echo esc_html__( 'Default Role', 'temporary-login-without-password' ); ?></label>
27
  </th>
28
  <td>
29
  <select name="tlwp_settings_data[default_role]" id="default-role" class="default-role-dropdown">
33
  </tr>
34
 
35
  <tr class="form-field">
36
+ <th scope="row" class="wtlwp-form-row"><label for="temporary-login-settings"></label></th>
37
  <td>
38
  <p class="submit">
39
+ <input type="submit" class="button button-primary wtlwp-form-submit-button" value="<?php esc_html_e( 'Submit', 'temporary-login-without-password' ); ?>" class="button button-primary" id="generatetemporarylogin" name="generate_temporary_login">
40
  </p>
41
  </td>
42
  </tr>
templates/update-login.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Update Login template
4
+ *
5
+ * @package Temporary Login Without Password
6
+ */
7
+
8
+ ?>
9
+ <h2> <?php echo esc_html__( 'Update Temporary Login', 'temporary-login-without-password' ); ?></h2>
10
+ <form method="post">
11
+ <table class="form-table wtlwp-form">
12
+ <tr class="form-field form-required">
13
+ <th scope="row" class="wtlwp-form-row">
14
+ <label for="user_email"><?php echo esc_html__( 'Email', 'temporary-login-without-password' ); ?> </label>
15
+ </th>
16
+ <td>
17
+ <label for="user_email"><?php echo esc_attr( $temporary_user_data['email'] ); ?></label>
18
+ </td>
19
+ </tr>
20
+
21
+ <tr class="form-field form-required">
22
+ <th scope="row" class="wtlwp-form-row">
23
+ <label for="user_first_name"><?php echo esc_html__( 'First Name', 'temporary-login-without-password' ); ?> </label>
24
+ </th>
25
+ <td>
26
+ <input name="wtlwp_data[user_first_name]" type="text" id="user_first_name" value="<?php echo esc_attr( $temporary_user_data['first_name'] ); ?>" aria-required="true" maxlength="60" class="wtlwp-form-input"/>
27
+ </td>
28
+ </tr>
29
+
30
+ <tr class="form-field form-required">
31
+ <th scope="row" class="wtlwp-form-row">
32
+ <label for="user_last_name"><?php echo esc_html__( 'Last Name', 'temporary-login-without-password' ); ?> </label>
33
+ </th>
34
+ <td>
35
+ <input name="wtlwp_data[user_last_name]" type="text" id="user_last_name" value="<?php echo esc_attr( $temporary_user_data['last_name'] ); ?>" aria-required="true" maxlength="60" class="wtlwp-form-input"/>
36
+ </td>
37
+ </tr>
38
+
39
+ <?php if ( is_network_admin() ) { ?>
40
+ <tr class="form-field form-required">
41
+ <th scope="row" class="wtlwp-form-row">
42
+ <label for="user_super_admin"><?php echo esc_html__( 'Super Admin', 'temporary-login-without-password' ); ?> </label>
43
+ </th>
44
+ <td>
45
+ <input type="checkbox" id="user_super_admin" name="wtlwp_data[super_admin]">
46
+ <?php echo esc_html__( 'Grant this user super admin privileges for the Network.', 'temporary-login-without-password' ); ?>
47
+ </td>
48
+ </tr>
49
+ <?php } else { ?>
50
+ <tr class="form-field">
51
+ <th scope="row" class="wtlwp-form-row">
52
+ <label for="adduser-role"><?php echo esc_html__( 'Role', 'temporary-login-without-password' ); ?></label>
53
+ </th>
54
+ <td>
55
+ <select name="wtlwp_data[role]" id="user-role">
56
+ <?php
57
+ $role = $temporary_user_data['role'];
58
+ Wp_Temporary_Login_Without_Password_Common::tlwp_dropdown_roles( $visible_roles, $role );
59
+ ?>
60
+ </select>
61
+ </td>
62
+ </tr>
63
+ <?php } ?>
64
+
65
+ <tr class="form-field">
66
+ <th scope="row" class="wtlwp-form-row">
67
+ <label for="adduser-role"><?php echo esc_html__( 'Extend Expiry', 'temporary-login-without-password' ); ?></label>
68
+ </th>
69
+ <td>
70
+ <span id="expiry-date-selection">
71
+ <select name="wtlwp_data[expiry]" id="update-user-expiry-time">
72
+ <?php Wp_Temporary_Login_Without_Password_Common::get_expiry_duration_html( 'week' ); ?>
73
+ </select>
74
+ </span>
75
+
76
+ <span style="display:none;" id="update-custom-date-picker">
77
+ <input type="date" id="datepicker" name="wtlwp_data[custom_date]" value="" class="update-custom-date-picker"/>
78
+ </span>
79
+
80
+ </td>
81
+ </tr>
82
+
83
+ <tr class="form-field">
84
+ <th scope="row" class="wtlwp-form-row"><label for="adduser-role"></label></th>
85
+ <td>
86
+ <p class="submit">
87
+ <input type="submit" class="button button-primary wtlwp-form-submit-button" value="<?php esc_html_e( 'Submit', 'temporary-login-without-password' ); ?>" class="button button-primary" id="generatetemporarylogin" name="generate_temporary_login"> <?php esc_html_e( 'or', 'temporary-login-without-password' ); ?>
88
+ <span class="cancel-update-login-form" id="cancel-update-login-form"><?php esc_html_e( 'Cancel', 'temporary-login-without-password' ); ?></span>
89
+ </p>
90
+ </td>
91
+ </tr>
92
+ <input type="hidden" name="wtlwp_action" value="update"/>
93
+ <input type="hidden" name="wtlwp_data[user_id]" value="<?php echo esc_attr( $user_id ); ?>"/>
94
+ <?php wp_nonce_field( 'manage-temporary-login_' . $user_id, 'manage-temporary-login', true, true ); ?>
95
+ </table>
96
+ </form>
templates/update_login.php DELETED
@@ -1,88 +0,0 @@
1
- <h2> <?php echo __( 'Update 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">
6
- <label for="user_email"><?php echo __( 'Email', 'temporary-login-without-password' ); ?> </label>
7
- </th>
8
- <td>
9
- <label for="user_email"><?php echo $temporary_user_data['email']; ?></label>
10
- </td>
11
- </tr>
12
-
13
- <tr class="form-field form-required">
14
- <th scope="row" class="wtlwp-form-row">
15
- <label for="user_first_name"><?php echo __( 'First Name', 'temporary-login-without-password' ); ?> </label>
16
- </th>
17
- <td>
18
- <input name="wtlwp_data[user_first_name]" type="text" id="user_first_name" value="<?php echo $temporary_user_data['first_name']; ?>" aria-required="true" maxlength="60" class="wtlwp-form-input"/>
19
- </td>
20
- </tr>
21
-
22
- <tr class="form-field form-required">
23
- <th scope="row" class="wtlwp-form-row">
24
- <label for="user_last_name"><?php echo __( 'Last Name', 'temporary-login-without-password' ); ?> </label>
25
- </th>
26
- <td>
27
- <input name="wtlwp_data[user_last_name]" type="text" id="user_last_name" value="<?php echo $temporary_user_data['last_name']; ?>" aria-required="true" maxlength="60" class="wtlwp-form-input"/>
28
- </td>
29
- </tr>
30
-
31
- <?php if ( is_network_admin() ) { ?>
32
- <tr class="form-field form-required">
33
- <th scope="row" class="wtlwp-form-row">
34
- <label for="user_super_admin"><?php echo __( 'Super Admin', 'temporary-login-without-password' ); ?> </label>
35
- </th>
36
- <td>
37
- <input type="checkbox" id="user_super_admin" name="wtlwp_data[super_admin]">
38
- <?php echo __( 'Grant this user super admin privileges for the Network.', 'temporary-login-without-password' ); ?>
39
- </td>
40
- </tr>
41
- <?php } else { ?>
42
- <tr class="form-field">
43
- <th scope="row" class="wtlwp-form-row">
44
- <label for="adduser-role"><?php echo __( 'Role', 'temporary-login-without-password' ); ?></label>
45
- </th>
46
- <td>
47
- <select name="wtlwp_data[role]" id="user-role">
48
- <?php
49
- $role = $temporary_user_data['role'];
50
- Wp_Temporary_Login_Without_Password_Common::tlwp_dropdown_roles( $visible_roles, $role );
51
- ?>
52
- </select>
53
- </td>
54
- </tr>
55
- <?php } ?>
56
-
57
- <tr class="form-field">
58
- <th scope="row" class="wtlwp-form-row">
59
- <label for="adduser-role"><?php echo __( 'Extend Expiry', 'temporary-login-without-password' ); ?></label>
60
- </th>
61
- <td>
62
- <span id="expiry-date-selection">
63
- <select name="wtlwp_data[expiry]" id="update-user-expiry-time">
64
- <?php Wp_Temporary_Login_Without_Password_Common::get_expiry_duration_html('week'); ?>
65
- </select>
66
- </span>
67
-
68
- <span style="display:none;" id="update-custom-date-picker">
69
- <input type="date" id="datepicker" name="wtlwp_data[custom_date]" value="" class="update-custom-date-picker"/>
70
- </span>
71
-
72
- </td>
73
- </tr>
74
-
75
- <tr class="form-field">
76
- <th scope="row" class="wtlwp-form-row"><label for="adduser-role"></label></th>
77
- <td>
78
- <p class="submit">
79
- <input type="submit" class="button button-primary wtlwp-form-submit-button" value="<?php _e( 'Submit', 'temporary-login-without-password' ); ?>" class="button button-primary" id="generatetemporarylogin" name="generate_temporary_login"> <?php _e( 'or', 'temporary-login-without-password' ); ?>
80
- <span class="cancel-update-login-form" id="cancel-update-login-form"><?php _e( 'Cancel', 'temporary-login-without-password' ); ?></span>
81
- </p>
82
- </td>
83
- </tr>
84
- <input type="hidden" name="wtlwp_action" value="update" />
85
- <input type="hidden" name="wtlwp_data[user_id]" value="<?php echo $user_id; ?>" />
86
- <?php wp_nonce_field( 'manage-temporary-login_' . $user_id, 'manage-temporary-login', true, true ); ?>
87
- </table>
88
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
temporary-login-without-password.php CHANGED
@@ -3,7 +3,7 @@
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.7
7
  * Author: StoreApps
8
  * Author URI: http://storeapps.org
9
  * Requires at least: 3.0.1
@@ -13,6 +13,8 @@
13
  * Text Domain: temporary-login-without-password
14
  * Domain Path: /languages
15
  * Copyright (c) 2016, 2017 StoreApps, All right reserved
 
 
16
  */
17
 
18
  // If this file is called directly, abort.
@@ -24,8 +26,8 @@ if ( ! defined( 'WPINC' ) ) {
24
  * Define constants
25
  */
26
  define( 'WTLWP_PLUGIN_DIR', dirname( __FILE__ ) );
27
- define( 'WTLWP_PLUGIN_VERSION', '1.5.7');
28
- define( 'WTLWP_PLUGIN_BASE_NAME', plugin_basename(__FILE__));
29
 
30
  /**
31
  * Deactivate Temporary Login Without Password
@@ -51,7 +53,7 @@ register_deactivation_hook( __FILE__, 'wp_deactivate_temporary_login_without_pas
51
  register_activation_hook( __FILE__, 'wp_activate_temporary_login_without_password' );
52
 
53
 
54
- // Include main class file
55
  require plugin_dir_path( __FILE__ ) . 'includes/class-wp-temporary-login-without-password.php';
56
 
57
  /**
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.8
7
  * Author: StoreApps
8
  * Author URI: http://storeapps.org
9
  * Requires at least: 3.0.1
13
  * Text Domain: temporary-login-without-password
14
  * Domain Path: /languages
15
  * Copyright (c) 2016, 2017 StoreApps, All right reserved
16
+ *
17
+ * @package Temporary Login Without Password
18
  */
19
 
20
  // If this file is called directly, abort.
26
  * Define constants
27
  */
28
  define( 'WTLWP_PLUGIN_DIR', dirname( __FILE__ ) );
29
+ define( 'WTLWP_PLUGIN_VERSION', '1.5.8' );
30
+ define( 'WTLWP_PLUGIN_BASE_NAME', plugin_basename( __FILE__ ) );
31
 
32
  /**
33
  * Deactivate Temporary Login Without Password
53
  register_activation_hook( __FILE__, 'wp_activate_temporary_login_without_password' );
54
 
55
 
56
+ // Include main class file.
57
  require plugin_dir_path( __FILE__ ) . 'includes/class-wp-temporary-login-without-password.php';
58
 
59
  /**