| @@ -1,36 +1,34 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace passster; |
| 4 | 4 | |
| 5 | -class PS_Form | |
| 6 | -{ | |
| 5 | +class PS_Form { | |
| 7 | 6 | /** |
| 8 | 7 | * Contains instance or null |
| 9 | 8 | * |
| 10 | 9 | * @var object|null |
| 11 | 10 | */ |
| 12 | - private static $instance = null ; | |
| 11 | + private static $instance = null; | |
| 12 | + | |
| 13 | 13 | /** |
| 14 | 14 | * Returns instance of PS_Form. |
| 15 | 15 | * |
| 16 | 16 | * @return object |
| 17 | 17 | */ |
| 18 | - public static function get_instance() | |
| 19 | - { | |
| 18 | + public static function get_instance() { | |
| 20 | 19 | if ( null === self::$instance ) { |
| 21 | 20 | self::$instance = new self(); |
| 22 | 21 | } |
| 23 | 22 | return self::$instance; |
| 24 | 23 | } |
| 25 | - | |
| 24 | + | |
| 26 | 25 | /** |
| 27 | 26 | * Get password form markup and replace placeholders |
| 28 | 27 | * |
| 29 | 28 | * @return string |
| 30 | 29 | */ |
| 31 | - public static function get_password_form() : string | |
| 32 | - { | |
| 30 | + public static function get_password_form() : string { | |
| 33 | 31 | $options = get_option( 'passster' ); |
| 34 | 32 | ob_start(); |
| 35 | 33 | include apply_filters( 'passster_password_form', PASSSTER_PATH . '/inc/templates/password-form.php' ); |
| 36 | 34 | $password_form = ob_get_contents(); |
| @@ -38,16 +36,15 @@ | ||
| 38 | 36 | $password_form_placeholders = array( |
| 39 | 37 | '[PASSSTER_AUTH]' => 'passster_password', |
| 40 | 38 | '[PS_AJAX_LOADER]' => PASSSTER_URL . '/assets/public/ps-loader.svg', |
| 41 | 39 | ); |
| 42 | - $show_password = $options['show_password']; | |
| 43 | - | |
| 40 | + $show_password = $options['show_password'] ?? false; | |
| 41 | + $show_password_label = $options['show_password_label'] ?? __( 'Show Password', 'content-protector' ); | |
| 44 | 42 | if ( $show_password ) { |
| 45 | - $password_form_placeholders['[PASSSTER_SHOW_PASSWORD]'] = '<label for="passster-password-hint"><input name="passster-password-hint" id="passster-password-hint" type="checkbox" onclick="showPassword()"/> ' . esc_html__( 'Show Password', 'content-protector' ) . '</label>'; | |
| 43 | + $password_form_placeholders['[PASSSTER_SHOW_PASSWORD]'] = '<label for="passster-password-hint"><input name="passster-password-hint" id="passster-password-hint" type="checkbox" onclick="showPassword()"/> ' . esc_html( $show_password_label ) . '</label>'; | |
| 46 | 44 | } else { |
| 47 | 45 | $password_form_placeholders['[PASSSTER_SHOW_PASSWORD]'] = ''; |
| 48 | 46 | } |
| 49 | - | |
| 50 | 47 | foreach ( $password_form_placeholders as $placeholder => $string ) { |
| 51 | 48 | $password_form = str_replace( $placeholder, $string, $password_form ); |
| 52 | 49 | } |
| 53 | 50 | return $password_form; |
| @@ -52,5 +49,5 @@ | ||
| 52 | 49 | } |
| 53 | 50 | return $password_form; |
| 54 | 51 | } |
| 55 | 52 | |
| 56 | -} | |
| 53 | +} | |