Skip to content

Commit

Permalink
Merge pull request #18 from emreerkan/develop
Browse files Browse the repository at this point in the history
Added translator comments and updated POT file.
  • Loading branch information
mustafauysal committed Jan 21, 2023
2 parents 03c3f6f + 49b38a4 commit 126b02c
Show file tree
Hide file tree
Showing 3 changed files with 254 additions and 143 deletions.
5 changes: 5 additions & 0 deletions includes/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,10 @@ function handle_login_request() {
do_action( 'magic_login_handle_login_request' );

if ( is_user_logged_in() ) {
/* translators: 1: User login 2: Dashboard URL */
$error = sprintf( __( 'Invalid magic login token, but you are logged in as \'%1$s\'. <a href="%2$s">Go to the dashboard instead</a>?', 'magic-login' ), wp_get_current_user()->user_login, admin_url() );
} else {
/* translators: %s: Login URL */
$error = sprintf( __( 'Invalid magic login token. <a href="%s">Try signing in instead</a>?', 'magic-login' ), wp_login_url() );
}

Expand Down Expand Up @@ -529,14 +531,17 @@ function add_auto_login_link_to_message( $args, $user ) {

if ( $is_html ) {
$login_message = '<br>';
/* translators: %s: The magic login link */
$login_message .= sprintf( __( '<a href="%s" target="_blank" rel="noopener">Click here to login</a>.', 'magic-login' ), $link );
} else {
$login_message = PHP_EOL;
/* translators: %s: The magic login link */
$login_message .= sprintf( __( 'Auto Login: %s', 'magic-login' ), $link );
}

if ( $token_ttl > 0 ) {
$login_message .= $is_html ? '<br>' : PHP_EOL;
/* translators: 1: TTL value (number) 2: Unit (minute(s), hour(s), days(s)) */
$login_message .= sprintf( __( 'Login link will expire in %1$s %2$s.', 'magic-login' ), $token_ttl, $selected_interval_str );
}

Expand Down
73 changes: 42 additions & 31 deletions includes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function settings_page() {
<?php
echo wp_kses_post(
sprintf(
/* translators: 1: Login URL with Magic Login flavour */
__( 'Magic login form is accessible <a href="%1$s">%1$s</a>' ),
esc_url( site_url( 'wp-login.php?action=magic_login', 'login_post' ) )
)
Expand All @@ -152,6 +153,7 @@ function settings_page() {
<?php
echo wp_kses_post(
sprintf(
/* translators: 1: Magic Login shortcode 2: Documentation URL 3: 'Learn More' text */
__( 'In order to add a login form to any page, you can use shortcode <code>%1$s</code> or block. <a href="%2$s" target="_blank" rel="noopener">%3$s</a>' ),
'[magic_login_form]',
get_doc_url( 'add-login-form-to-a-page' ),
Expand Down Expand Up @@ -280,37 +282,45 @@ class="sui-form-control sui-field-has-suffix"

<div style=" <?php echo( ! $settings['enable_brute_force_protection'] ? 'display:none' : '' ); ?>" tabindex="0" id="brute-force-protection-controls" class="sui-toggle-content sui-border-frame">
<div class="sui-form-field">
<?php esc_html_e( 'Block the IP address for', 'magic-login' ); ?>
<input
id="brute_force_bantime"
name="brute_force_bantime"
min="1"
max="1440"
type="number"
class="sui-form-control sui-field-has-suffix"
value="<?php echo absint( $settings['brute_force_bantime'] ); ?>"
>
<?php esc_html_e( 'minutes when it fails to login ', 'magic-login' ); ?>
<input
id="brute_force_login_attempt"
name="brute_force_login_attempt"
min="1"
max="100"
type="number"
class="sui-form-control sui-field-has-suffix"
value="<?php echo absint( $settings['brute_force_login_attempt'] ); ?>"
>
<?php esc_html_e( 'times in', 'magic-login' ); ?>
<input
id="brute_force_login_time"
name="brute_force_login_time"
min="1"
max="600"
type="number"
class="sui-form-control sui-field-has-suffix"
value="<?php echo absint( $settings['brute_force_login_time'] ); ?>"
>
<?php esc_html_e( 'minutes.', 'magic-login' ); ?>
<?php
$brute_force_fields = array(
'brute_force_bantime' => array(
'min' => 1,
'max' => 1440,
),
'brute_force_login_attempt' => array(
'min' => 1,
'max' => 100,
),
'brute_force_login_time' => array(
'min' => 1,
'max' => 600,
),
);
foreach ( $brute_force_fields as $field => $args ) {
${$field . '_input'} = sprintf(
'<input
id="%1$s"
name="%1$s"
min="%2$d"
max="%3$d"
type="number"
class="sui-form-control sui-field-has-suffix"
value="%4$d"
>',
esc_attr( $field ),
absint( $args['min'] ),
absint( $args['max'] ),
absint( $settings[ $field ] )
);
}
/* translators: 1: Ban duration input 2: Trial count input 3: Interval input */
printf( _( 'Block the IP address for %1$s minutes when it fails to login %2$s times in %3$s minutes.', 'magic-login' ),
$brute_force_bantime_input,
$brute_force_login_attempt_input,
$brute_force_login_time_input
); // WPCS: XSS ok.
?>
</div>
</div>
</div>
Expand Down Expand Up @@ -662,6 +672,7 @@ class="sui-form-control"
<?php
echo wp_kses_post(
sprintf(
/* translators: %s: HandyPlugins URL */
__( 'Made with <i class="sui-icon-heart"></i> by <a href="%s" rel="noopener" target="_blank">HandyPlugins</a>', 'magic-login' ),
'https://handyplugins.co/'
)
Expand Down
Loading

0 comments on commit 126b02c

Please sign in to comment.