PluginProbe
Passster – Password Protect Pages and Content / 3.5.5.9
Passster – Password Protect Pages and Content v3.5.5.9
4.3.15 4.3.14 4.3.12 4.3.13 4.3.11 4.3.10 4.3.9 4.3.8 4.3.7 4.3.6 4.3.5 trunk 3.5.4 3.5.5.2 3.5.5.8 3.5.5.9 4.0 4.1.4 4.2.10 4.2.11 4.2.12 4.2.13 4.2.14 4.2.15 4.2.16 All 47 releases
content-protector / src / class-ps-form.php

class-ps-form.php in Passster – Password Protect Pages and Content 3.5.5.9, at src/class-ps-form.php

56 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace passster;
4
5 class PS_Form
6 {
7 /**
8 * Contains instance or null
9 *
10 * @var object|null
11 */
12 private static $instance = null ;
13 /**
14 * Returns instance of PS_Form.
15 *
16 * @return object
17 */
18 public static function get_instance()
19 {
20 if ( null === self::$instance ) {
21 self::$instance = new self();
22 }
23 return self::$instance;
24 }
25
26 /**
27 * Get password form markup and replace placeholders
28 *
29 * @return string
30 */
31 public static function get_password_form() : string
32 {
33 ob_start();
34 include apply_filters( 'passster_password_form', PASSSTER_PATH . '/src/templates/password-form.php' );
35 $password_form = ob_get_contents();
36 ob_end_clean();
37 $password_form_placeholders = array(
38 '[PASSSTER_AUTH]' => 'passster_password',
39 '[PASSSTER_CURRENT_URL]' => \get_the_permalink(),
40 '[PS_AJAX_LOADER]' => PASSSTER_URL . '/assets/public/ps-loader.svg',
41 );
42 $show_password = get_theme_mod( 'passster_form_instructions_password_typing', false );
43
44 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>';
46 } else {
47 $password_form_placeholders['[PASSSTER_SHOW_PASSWORD]'] = '';
48 }
49
50 foreach ( $password_form_placeholders as $placeholder => $string ) {
51 $password_form = str_replace( $placeholder, $string, $password_form );
52 }
53 return $password_form;
54 }
55
56 }