Plugin Directory

Changeset 2869876


Ignore:
Timestamp:
02/23/2023 09:46:57 AM (3 years ago)
Author:
wprj
Message:

v1.1

Location:
emlg-tfa/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • emlg-tfa/trunk/emlg-tfa.php

    r2735764 r2869876  
    55 * Plugin Name:  EMLG TFA
    66 * Description:  Two-Factor Authentication via out of band email
    7  * Version:      1.0.1
    8  * Author:       wprj, Lalaina Rajaonah
    9  * Author URI:   https://codecanyon.net/user/wprj
     7 * Version:      1.1
     8 * Author:       wprj
     9 * Author URI:   https://www.upwork.com/freelancers/~01f7aae88a686d0580
    1010 * Text Domain:  emlg-tfa
    1111 * Domain Path:  /languages
     
    1414 */
    1515
    16 const EMLG_VERSION = '1.0.1';
     16const EMLG_VERSION = '1.1';
    1717define( 'EMLG_BASE', plugin_basename( __FILE__ ) );
    1818define( 'EMLG_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
  • emlg-tfa/trunk/includes/class-emlg-ajax.php

    r2735692 r2869876  
    168168                   "\t" . '<p style="font-size:1.6em;">%SITE_TITLE%</p>' . "\n" .
    169169                   "\t" . '<hr/>' . "\n" .
    170                    "\t" . '<p>Checking for email capability of WordPress</p>' . "\n" .
     170                   "\t" . '<p>Checking for email capability of WordPress at %SITE_URL%</p>' . "\n" .
    171171                   "\t" . '<p style="font-size: 1.1em;">Enter the following code on the EMLG TFA dashboard page:</p>' . "\n" .
    172172                   "\t" . '<p style="font-size: 1.6em;font-weight: 700">%CODE%</p>' . "\n" .
    173173                   '</div>';
    174174
    175         $content             = str_replace( [ '%SITE_TITLE%', '%CODE%' ], [ get_bloginfo(), $code ], $content );
     175        $content             = str_replace( [ '%SITE_TITLE%', '%CODE%', '%SITE_URL%' ], [ get_bloginfo(), $code, site_url() ], $content );
    176176        $email               = new Emlg_Email( $content );
    177177        $email->sender_email = $options['email_details']['sender_email'];
  • emlg-tfa/trunk/includes/class-emlg-login.php

    r2735692 r2869876  
    2626     */
    2727    const OPTION_NAME = 'emlg_options';
    28 
    29     /**
    30      * Default option value
    31      *
    32      * @var array
    33      */
    34     private static $default_options = [
    35         'mail_cap_status' => '',
    36         'templates'       => [
    37             'login_mail' => '<div style=\'font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;color:#fff;background-color:#2271b1;padding:10px;\'>' . "\n" .
    38                             "\t" . '<p style="font-size:1.6em;">%SITE_TITLE%</p>' . "\n" .
    39                             "\t" . '<hr/>' . "\n" .
    40                             "\t" . '<p>A login attempt to "%SITE_TITLE%" with your account "%USER%" has been performed.</p>' . "\n" .
    41                             "\t" . '<p style="font-size: 1.1em;">This is your login code:</p>' . "\n" .
    42                             "\t" . '<p style="font-size: 1.6em;font-weight: 700">%CODE%</p>' . "\n" .
    43                             "\t" . '<hr/>' . "\n" .
    44                             "\t" . '<p>If you did not perform this action, your password is likely compromised.</p>' . "\n" .
    45                             '</div>',
    46         ],
    47         'email_details'   => [
    48             'sender_name'  => 'Email login',
    49             'sender_email' => 'noreply@sandbox.local',
    50             'subject'      => 'Login verification',
    51         ],
    52         'enabled'         => '',
    53     ];
    5428
    5529    /**
     
    11791
    11892    /**
     93     * Get plugin's default options
     94     *
     95     * @return array
     96     */
     97    private static function get_default_options() {
     98        return [
     99            'mail_cap_status' => '',
     100            'templates'       => [
     101                'login_mail' => '<div style=\'font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;color:#fff;background-color:#2271b1;padding:10px;\'>' . "\n" .
     102                                "\t" . '<p style="font-size:1.6em;">%SITE_TITLE%</p>' . "\n" .
     103                                "\t" . '<hr/>' . "\n" .
     104                                "\t" . '<p>A login attempt to %SITE_URL% with your account "%USER%" has been performed.</p>' . "\n" .
     105                                "\t" . '<p style="font-size: 1.1em;">This is your login code:</p>' . "\n" .
     106                                "\t" . '<p style="font-size: 1.6em;font-weight: 700">%CODE%</p>' . "\n" .
     107                                "\t" . '<hr/>' . "\n" .
     108                                "\t" . '<p>If you did not perform this action, your password is likely compromised.</p>' . "\n" .
     109                                '</div>',
     110            ],
     111            'email_details'   => [
     112                'sender_name'  => 'Email login',
     113                'sender_email' => 'noreply@example.com',
     114                'subject'      => 'Login verification',
     115            ],
     116            'enabled'         => '',
     117        ];
     118    }
     119
     120    /**
    119121     * Return plugin option
    120122     *
     
    124126        $options = get_option( self::OPTION_NAME, [] );
    125127
    126         return $options + self::$default_options;
     128        return wp_parse_args( $options, self::get_default_options() );
    127129    }
    128130
     
    138140        $options = Emlg_Login::get_option();
    139141
    140         if ( is_string( $field_or_options ) && $value !== null && isset( self::$default_options[ $field_or_options ] ) ) {
     142        if ( is_string( $field_or_options ) && $value !== null && isset( self::get_default_options()[ $field_or_options ] ) ) {
    141143            // Updating a single field.
    142144            $options[ $field_or_options ] = $value;
     
    241243
    242244        // Replace all placeholder in the email message.
    243         $email = new Emlg_Email( str_ireplace( [ '%CODE%', '%USER%', '%SITE_TITLE%' ], [ $code, $credentials['user_login'], get_bloginfo() ], self::get_option()['templates']['login_mail'] ) );
     245        $email = new Emlg_Email( str_ireplace( [ '%CODE%', '%USER%', '%SITE_TITLE%', '%SITE_URL%' ], [ $code, $credentials['user_login'], get_bloginfo(), site_url() ], self::get_option()['templates']['login_mail'] ) );
    244246
    245247        $email->to           = $user->user_email;
     
    292294            self::$instance = new self();
    293295        }
     296
    294297        return self::$instance;
    295298    }
  • emlg-tfa/trunk/languages/emlg-tfa.pot

    r2735692 r2869876  
    44"Project-Id-Version: EMLG TFA\n"
    55"Report-Msgid-Bugs-To: \n"
    6 "POT-Creation-Date: 2022-05-30 14:02+0000\n"
     6"POT-Creation-Date: 2023-02-23 09:30+0000\n"
    77"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    88"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    2424msgstr ""
    2525
    26 #: views/admin-page.php:78
     26#: views/admin-page.php:79
    2727msgid ""
    2828"An attempt to send an email has failed during an user login. Please verify "
     
    3030msgstr ""
    3131
    32 #: views/admin-page.php:60
     32#: views/admin-page.php:61
    3333msgid "An email with a confirmation code has been sent to"
    3434msgstr ""
     
    3838msgstr ""
    3939
    40 #: views/admin-page.php:93
     40#: views/admin-page.php:94
    4141msgid "Check now"
    4242msgstr ""
     
    4646msgstr ""
    4747
    48 #: views/admin-page.php:64
     48#: views/admin-page.php:65
    4949msgid "Confirm code"
    5050msgstr ""
    5151
    52 #: views/admin-page.php:110
     52#: views/admin-page.php:111
    5353msgid "Disabled"
    5454msgstr ""
    5555
    56 #: views/admin-page.php:21 views/admin-page.php:144
     56#: views/admin-page.php:21 views/admin-page.php:145
    5757msgid "Edit"
    5858msgstr ""
    5959
    60 #: views/admin-page.php:107
     60#: views/admin-page.php:108
    6161msgid "Email 2FA"
    6262msgstr ""
    6363
    64 #: views/admin-page.php:122
     64#: views/admin-page.php:123
    6565msgid "Email sender name"
    6666msgstr ""
    6767
    68 #: views/admin-page.php:133
     68#: views/admin-page.php:134
    6969msgid "Email subject"
    7070msgstr ""
    7171
    72 #: views/admin-page.php:115
     72#. Name of the plugin
     73#: includes/class-emlg-dashboard.php:65 includes/class-emlg-dashboard.php:66
     74#: views/admin-page.php:7
     75msgid "EMLG TFA"
     76msgstr ""
     77
     78#: views/admin-page.php:116
    7379msgid "Enable Two-Factor Authentication via Email"
    7480msgstr ""
    7581
    76 #: views/admin-page.php:111
     82#: views/admin-page.php:112
    7783msgid "enabled"
    7884msgstr ""
     
    8692msgstr ""
    8793
    88 #: views/admin-page.php:136
     94#: views/admin-page.php:137
    8995msgid "Login email subject"
    9096msgstr ""
    9197
    92 #: views/admin-page.php:140 views/admin-page.php:146
     98#: views/admin-page.php:141 views/admin-page.php:147
    9399msgid "Login email template"
    94100msgstr ""
    95101
    96 #. 1: place holder for site title, 2: placeholder for login code, 3: placeholder for user login
     102#. 1: place holder for site title, 2:login code, 3:user login, 4:site url
    97103#: views/admin-page.php:31
    98104#, php-format
    99 msgid "Placeholders: %1$s: site title, %2$s: verification code, %3$s: username"
     105msgid ""
     106"Placeholders: %1$s: site title, %2$s: verification code, %3$s: username, "
     107"%4$s: site url"
    100108msgstr ""
    101109
     
    104112msgstr ""
    105113
    106 #: views/admin-page.php:72
     114#: views/admin-page.php:73
    107115msgid "Resend email"
    108116msgstr ""
    109117
    110 #: views/admin-page.php:149
     118#: views/admin-page.php:150
    111119msgid "Save settings"
    112120msgstr ""
    113121
    114 #: views/admin-page.php:82
     122#: views/admin-page.php:83
    115123msgid "Send a test email"
    116124msgstr ""
    117125
    118 #: views/admin-page.php:126 views/admin-page.php:129
     126#: views/admin-page.php:127 views/admin-page.php:130
    119127msgid "Sender email address"
    120128msgstr ""
    121129
    122 #: views/admin-page.php:119
     130#: views/admin-page.php:120
    123131msgid "Sender name"
    124132msgstr ""
     
    128136msgstr ""
    129137
    130 #: views/admin-page.php:71 views/submit-code.php:37
     138#: views/admin-page.php:72 views/submit-code.php:37
    131139msgid "Submit code"
    132140msgstr ""
    133141
    134 #: includes/class-emlg-ajax.php:60
     142#: includes/class-emlg-ajax.php:59
    135143msgid "The code is incorrect or has expired."
    136144msgstr ""
    137145
    138 #: includes/class-emlg-login.php:89 includes/class-emlg-login.php:108
     146#: includes/class-emlg-login.php:63 includes/class-emlg-login.php:82
    139147msgid "The code is invalid or has expired"
    140148msgstr ""
    141149
    142 #: views/admin-page.php:88 views/admin-page.php:99
     150#: views/admin-page.php:89 views/admin-page.php:100
    143151msgid ""
    144152"Two-factor authentication via email can't work unless WordPress can actually "
     
    146154msgstr ""
    147155
    148 #: views/admin-page.php:74
     156#: views/admin-page.php:75
    149157msgid ""
    150158"Two-factor authentication via email can't work unless WordPress can actually "
     
    156164msgstr ""
    157165
    158 #: views/admin-page.php:90
     166#: views/admin-page.php:91
    159167msgid "unknown"
    160168msgstr ""
    161169
    162 #: includes/class-emlg-ajax.php:193 includes/class-emlg-email.php:86
     170#: includes/class-emlg-ajax.php:192 includes/class-emlg-email.php:97
    163171msgid "WordPress could not send the email"
    164172msgstr ""
    165173
    166 #: views/admin-page.php:54
     174#: views/admin-page.php:55
    167175msgid "WordPress email capability"
    168176msgstr ""
  • emlg-tfa/trunk/readme.txt

    r2735764 r2869876  
    11=== EMLG TFA ===
    2 Contributors: wprj, kamiwdp6
     2Contributors: wprj
    33Tags: 2FA ,email two-factor authentication, 2-factor authentication, login, email login, email authentication, two factor, 2 factor
    4 Requires at least: 5.9.3
    5 Tested up to: 6.0
    6 Requires PHP: 5.6.20
    7 Stable tag: 1.0.1
     4Requires at least: 6.0
     5Tested up to: 6.1.1
     6Requires PHP: 7.4
     7Stable tag: 1.1
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
     
    5656== Changelog ==
    5757
     58= 1.1
     59
     60Feature: add site url to the possible placeholders in email body
     61Updated `.pot` file
     62
    5863= 1.0.1 =
    5964
  • emlg-tfa/trunk/views/admin-page.php

    r2735692 r2869876  
    33 * Dashboard page templates.
    44 */
    5  ?>
     5?>
    66<div class="wrap">
    77    <h2><?php esc_html_e( 'EMLG TFA', 'emlg-tfa' ); ?></h2>
     
    2828                                    <?php
    2929                                    printf(
    30                                         /* translators: 1: place holder for site title, 2: placeholder for login code, 3: placeholder for user login */
    31                                         esc_html__( 'Placeholders: %1$s: site title, %2$s: verification code, %3$s: username', 'emlg-tfa' ),
     30                                    // translators: 1: place holder for site title, 2:login code, 3:user login, 4:site url
     31                                        esc_html__( 'Placeholders: %1$s: site title, %2$s: verification code, %3$s: username, %4$s: site url', 'emlg-tfa' ),
    3232                                        '<code>%SITE_TITLE%</code>',
    3333                                        '<code>%CODE%</code>',
    34                                         '<code>%USER%</code>'
     34                                        '<code>%USER%</code>',
     35                                        '<code>%SITE_URL%</code>'
    3536                                    );
    3637                                    ?>
     
    132133        <label>
    133134            <span class="label"><?php esc_html_e( 'Email subject', 'emlg-tfa' ); ?></span>
    134             <input type="text" class="widefat" name="email_details[subject]" value="{{data.options.email_details.subject}}" />
     135            <input type="text" class="widefat" name="email_details[subject]" value="{{data.options.email_details.subject}}"/>
    135136        </label>
    136137        <p class="description"><?php esc_html_e( 'Login email subject', 'emlg-tfa' ); ?></p>
Note: See TracChangeset for help on using the changeset viewer.