Skip to content
Permalink
Browse files

Lots of filters for strings

  • Loading branch information
Nomafin committed Oct 2, 2019
1 parent 4cf9805 commit 35176082f9a5ee22fd134f6ebc50755955b5f690
Showing with 58 additions and 14 deletions.
  1. +58 −14 models/user-activate.php
@@ -23,17 +23,21 @@ class UserActivate extends \DustPress\Model {
* @return $state (string) State of the view.
*/
public function State() {
$valid_error_codes = [ 'already_active', 'blog_taken' ];

// Get the key from cookie if set
$activate_cookie = 'wp-activate-' . COOKIEHASH;

$key = '';

if ( isset( $_COOKIE[ $activate_cookie ] ) ) {
$key = $_COOKIE[ $activate_cookie ];
}

if ( empty( $key ) ) {
if ( ! $key ) {
// activation key required
$state = "no-key";
$this->print['title'] = __( 'Activation Key Required' );
$this->print['title'] = apply_filters( 'dustpress/activate/key_required', __( 'Activation Key Required' ) );
$this->print['wp-activate-link'] = network_site_url( 'wp-activate.php' );
}
else {
@@ -43,25 +47,48 @@ public function State() {
$signup = $result->get_error_data();

$this->signup = $signup;
$this->print['title'] = __( 'Your account is now active!' );
$this->print['title'] = apply_filters( 'dustpress/activate/account_active', __( 'Your account is now active!' ) );

if ( $signup->domain . $signup->path == '' ) {
// account active and email sent
$state = "account-active-mail";
$this->print['message'] = sprintf( /* translators: 1: login URL, 2: username, 3: user email, 4: lost password URL */
__( 'Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.' ), network_site_url( 'wp-login.php', 'login' ), $signup->user_login, $signup->user_email, wp_lostpassword_url() );
$this->print['message'] = apply_filters(
'dustpress/activate/user_activated',
sprintf( /* translators: 1: login URL, 2: username, 3: user email, 4: lost password URL */
__( 'Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.' ),
network_site_url( 'wp-login.php', 'login' ),
$signup->user_login,
$signup->user_email,
wp_lostpassword_url()
),
$signup->user_login,
$signup->user_email
);
}
else {
// site active and email sent
$state = "site-active-mail";
/* translators: 1: site URL, 2: site domain, 3: username, 4: user email, 5: lost password URL */
$this->print['message'] = sprintf( /* translators: 1: site URL, 2: site domain, 3: username, 4: user email, 5: lost password URL */
__( 'Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of &#8220;%3$s&#8221;. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.' ), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, wp_lostpassword_url() );
$this->print['message'] = apply_filters(
'dustpress/activate/site_activated',
sprintf( /* translators: 1: site URL, 2: site domain, 3: username, 4: user email, 5: lost password URL */
__( 'Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of &#8220;%3$s&#8221;. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.' ),
'http://' . $signup->domain,
$signup->domain,
$signup->user_login,
$signup->user_email,
wp_lostpassword_url()
),
$signup->domain,
$signup->user_login,
$signup->user_email
);
}
}
elseif ( $result === null || is_wp_error( $result ) ) {
$state = "error";

$this->print['title'] = __( 'An error occurred during the activation' );
$this->print['title'] = apply_filters( 'dustpress/activate/error_occurred', __( 'An error occurred during the activation' ) );
$this->print['error'] = $result->get_error_message();
}
else {
@@ -70,7 +97,7 @@ public function State() {
$url = isset( $result['blog_id'] ) ? get_home_url( (int) $result['blog_id'] ) : '';
$user = get_userdata( (int) $result['user_id'] );

$this->print['title'] = __( 'Your account is now active!' );
$this->print['title'] = apply_filters( 'dustpress/activate/account_active', __( 'Your account is now active!' ) );
$this->print['username'] = $user->user_login;
$this->print['useremail'] = $user->user_email;
$this->print['password'] = $result['password'];
@@ -79,14 +106,31 @@ public function State() {
switch_to_blog( (int) $result['blog_id'] );
$login_url = wp_login_url();
restore_current_blog();
//log in link to blog
/* translators: 1: site URL, 2: login URL */
$this->print['message'] = sprintf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ), $url, esc_url( $login_url ) );
// log in link to blog
$this->print['message'] = apply_filters(
'dustpress/activate/account_activated',
sprintf( /* translators: 1: site URL, 2: login URL */
__( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ),
$url,
esc_url( $login_url )
),
$url,
$login_url,
$user,
$result['blog_id']
);
}
else {
//log in link to main site
/* translators: 1: login URL, 2: network home URL */
$this->print['message'] = sprintf( __( 'Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ), network_site_url( 'wp-login.php', 'login' ), network_home_url() );
$this->print['message'] = apply_filters(
'dustpress/activate/account_activated',
sprintf( /* translators: 1: login URL, 2: network home URL */
__( 'Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ),
network_site_url( 'wp-login.php', 'login' ),
network_home_url()
),
$user
);
}
}
}

0 comments on commit 3517608

Please sign in to comment.
You can’t perform that action at this time.