Changeset 10029
- Timestamp:
- 07/07/2020 08:02:03 AM (6 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login
- Files:
-
- 5 edited
-
admin/ui.php (modified) (1 diff)
-
functions-registration.php (modified) (4 diffs)
-
functions-restapi.php (modified) (6 diffs)
-
js/registration.js (modified) (3 diffs)
-
pending-profile.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/admin/ui.php
r10010 r10029 55 55 56 56 if ( $email ) { 57 wporg_ send_confirmation_email( $email );57 wporg_login_send_confirmation_email( $email ); 58 58 } 59 59 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions-registration.php
r10028 r10029 92 92 } 93 93 94 wporg_ send_confirmation_email( $user_email );94 wporg_login_send_confirmation_email( $user_email ); 95 95 96 96 $url = home_url( sprintf( … … 107 107 * Send a "Welcome to WordPress.org" confirmation email. 108 108 */ 109 function wporg_ send_confirmation_email( $user_email) {109 function wporg_login_send_confirmation_email( $user ) { 110 110 global $wpdb; 111 111 112 $user = wporg_get_pending_user( $user _email);112 $user = wporg_get_pending_user( $user ); 113 113 114 114 if ( ! $user || $user['created'] ) { … … 117 117 118 118 $user_login = $user['user_login']; 119 $user_email = $user['user_email']; 119 120 120 121 $activation_key = wp_hash( $user_login . ':' . $user_email, 'activation' ); … … 150 151 function wporg_get_pending_user( $login_or_email ) { 151 152 global $wpdb; 153 154 // Is it a pending user object already? 155 if ( is_array( $login_or_email ) && isset( $login_or_email['pending_id'] ) ) { 156 return $login_or_email; 157 } 152 158 153 159 $pending_user = $wpdb->get_row( $wpdb->prepare( -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions-restapi.php
r9146 r10029 19 19 'callback' => 'wporg_login_rest_email_in_use' 20 20 ) ); 21 22 register_rest_route( 'wporg/v1', '/resend-confirmation-email/?', array( 23 'methods' => WP_REST_Server::EDITABLE, 24 'callback' => 'wporg_login_rest_resend_confirmation_email' 25 ) ); 21 26 } 22 27 add_action( 'rest_api_init', 'wporg_login_rest_routes' ); … … 31 36 return [ 32 37 'available' => false, 33 'error' => __( 'That username is already in use.', 'wporg' ) . '<br>' . __( 'Is it yours? <a href="/lostpassword">Reset your password</a>.', 'wporg' ), 38 'error' => __( 'That username is already in use.', 'wporg' ) . '<br>' . 39 __( 'Is it yours? <a href="/lostpassword">Reset your password</a>.', 'wporg' ), 34 40 'avatar' => get_avatar( $user, 64 ), 35 41 ]; … … 40 46 return [ 41 47 'available' => false, 42 'error' => __( 'That username is already in use.', 'wporg' ) . '<br>' . __( 'The registration is still pending, please check your email for the confirmation link.', 'wporg' ), 48 'error' => __( 'That username is already in use.', 'wporg' ) . '<br>' . 49 __( 'The registration is still pending, please check your email for the confirmation link.', 'wporg' ) . '<br>' . 50 '<a href="#" class="resend">' . __( 'Resend confirmation email.', 'wporg' ) . '</a>', 43 51 'avatar' => get_avatar( $pending->user_email, 64 ), 44 52 ]; … … 65 73 return [ 66 74 'available' => false, 67 'error' => __( 'That email address already has an account.', 'wporg' ) . '<br>' . __( 'Is it yours? <a href="/lostpassword">Reset your password</a>.', 'wporg' ), 75 'error' => __( 'That email address already has an account.', 'wporg' ) . '<br>' . 76 __( 'Is it yours? <a href="/lostpassword">Reset your password</a>.', 'wporg' ), 68 77 'avatar' => get_avatar( $user, 64 ), 69 78 ]; … … 74 83 return [ 75 84 'available' => false, 76 'error' => __( 'That email address already has an account.', 'wporg' ) . '<br>' . __( 'The registration is still pending, please check your email for the confirmation link.', 'wporg' ), 85 'error' => __( 'That email address already has an account.', 'wporg' ) . '<br>' . 86 __( 'The registration is still pending, please check your email for the confirmation link.', 'wporg' ) . '<br>' . 87 '<a href="#" class="resend">' . __( 'Resend confirmation email.', 'wporg' ) . '</a>', 77 88 'avatar' => get_avatar( $email, 64 ), 78 89 ]; … … 91 102 return [ 'available' => true ]; 92 103 } 104 105 /* 106 * Resend a confirmation email to create an account. 107 * 108 * This API intentionally doesn't report if it performs the action, always returning the success message. 109 */ 110 function wporg_login_rest_resend_confirmation_email( $request ) { 111 $account = $request['account']; 112 113 $success_message = sprintf( 114 __( 'Please check your email %s for a confirmation link to set your password.', 'wporg' ), 115 '<code>' . esc_html( $account ) . '</code>' 116 ); 117 118 $pending_user = wporg_get_pending_user( $request['account'] ); 119 if ( ! $pending_user || $pending_user['created'] ) { 120 return $success_message; 121 } 122 123 // Allow for w.org plugins to block the action. 124 if ( null !== ( $pre_register_error = apply_filters( 'wporg_login_pre_registration', null, $pending_user['user_login'], $pending_user['user_email'], $pending_user['meta']['user_mailinglist'] ) ) ) { 125 return $success_message; 126 } 127 128 // Only one email per.. 129 // - 1 minute for brand new accounts (<15min) 130 // - 5 minutes for new accounts (<1hr) 131 // - 3 hours there after 132 list( $requested_time, ) = explode( ':', $pending_user['user_activation_key'] ); 133 $time_limit = 3 * HOUR_IN_SECONDS; 134 135 if ( time() - strtotime( $pending_user['user_registered'] ) < HOUR_IN_SECONDS ) { 136 $time_limit = 5 * MINUTE_IN_SECONDS; 137 } 138 139 if ( time() - strtotime( $pending_user['user_registered'] ) < 15 * MINUTE_IN_SECONDS ) { 140 $time_limit = MINUTE_IN_SECONDS; 141 } 142 143 if ( ( time() - $requested_time ) < $time_limit ) { 144 return $success_message; 145 } 146 147 wporg_login_send_confirmation_email( $pending_user ); 148 149 return $success_message; 150 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/js/registration.js
r9224 r10029 20 20 21 21 $.get( rest_url, function( datas ) { 22 $this. parents( 'p' ).nextUntil( 'p', 'div.message.error' ).remove();22 $this.closest( 'p' ).nextUntil( 'p', 'div.message' ).remove(); 23 23 $this.removeClass( 'good' ); 24 24 25 25 if ( ! datas.available ) { 26 26 $this.addClass( 'error' ); 27 $this. parents( 'p' ).after(27 $this.closest( 'p' ).after( 28 28 '<div class="message error' + ( datas.avatar ? ' with-avatar' : '' ) + '"><p>' + 29 29 ( datas.avatar ? datas.avatar : '' ) + '<span>' + … … 31 31 '</span></p></div>' 32 32 ); 33 $this.closest( 'p' ).next('div.message.error').find( '.resend' ).data( 'account', $this.val() ); 33 34 } else { 34 35 $this.addClass( 'good' ); … … 36 37 } ); 37 38 } ); 39 40 $loginForm.on( 'click', '.resend', function( e ) { 41 var $this = $(this), 42 account = $this.data('account'); 43 44 e.preventDefault(); 45 46 $this.closest( 'div.message' ).next('div.message.info').remove(); 47 48 $.post( 49 wporg_registration.rest_url + '/resend-confirmation-email', 50 { 51 account: account, 52 }, 53 function( datas ) { 54 $this.closest( 'div.message' ).after( 55 '<div class="message info"><p><span>' + datas + '</span></p></div>' 56 ); 57 } 58 ); 59 60 }); 38 61 39 62 // If the form has data in it upon load, immediately trigger the validation. -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/pending-profile.php
r9835 r10029 50 50 get_header(); 51 51 ?> 52 <div class="message info"> 53 <p><?php 54 printf( 55 /* translators: %s Email address */ 56 __( 'Please check your email %s for a confirmation link to set your password.', 'wporg' ), 57 '<code>' . esc_html( $pending_user['user_email'] ) . '</code>' 58 ); 59 ?></p> 60 </div> 52 <form name="registerform" id="registerform" action="" method="post"> 61 53 62 <p class="intro"> 63 <?php _e( 'Complete your WordPress.org Profile information.', 'wporg' ); ?> 64 </p> 54 <div class="message info"> 55 <p><?php 56 printf( 57 /* translators: %s Email address */ 58 __( 'Please check your email %s for a confirmation link to set your password.', 'wporg' ) . '<br>' . 59 '<a href="#" class="resend" data-account="%s">' . __( 'Resend confirmation email.', 'wporg' ) . '</a>', 60 '<code>' . esc_html( $pending_user['user_email'] ) . '</code>', 61 esc_attr( $pending_user['user_email'] ) 62 ); 63 ?></p> 64 </div> 65 65 66 <form name="registerform" id="registerform" action="" method="post"> 66 <p class="intro"> 67 <?php _e( 'Complete your WordPress.org Profile information.', 'wporg' ); ?> 68 </p> 67 69 68 70 <p class="login-login">
Note: See TracChangeset
for help on using the changeset viewer.