| @@ -1,130 +1,137 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace passster; | |
| 4 | - | |
| 5 | -class PS_Dynamic_Styles { | |
| 6 | - /** | |
| 7 | - * Contains instance or null | |
| 8 | - * | |
| 9 | - * @var object|null | |
| 10 | - */ | |
| 11 | - private static $instance = null; | |
| 12 | - | |
| 13 | - /** | |
| 14 | - * Returns instance of PS_Dynamic_Styles. | |
| 15 | - * | |
| 16 | - * @return object | |
| 17 | - */ | |
| 18 | - public static function get_instance() { | |
| 19 | - if ( null === self::$instance ) { | |
| 20 | - self::$instance = new self(); | |
| 21 | - } | |
| 22 | - | |
| 23 | - return self::$instance; | |
| 24 | - } | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * Constructor. | |
| 28 | - * | |
| 29 | - * @return void | |
| 30 | - */ | |
| 31 | - public function __construct() { | |
| 32 | - add_action( 'wp_head', array( $this, 'dynamic_styles' ) ); | |
| 33 | - } | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * Add dynamic styles | |
| 37 | - * | |
| 38 | - * @return void | |
| 39 | - */ | |
| 40 | - public function dynamic_styles() { | |
| 41 | - $options = get_option( 'passster' ); | |
| 42 | - | |
| 43 | - if ( isset( $options['button_font_size'] ) ) { | |
| 44 | - $button_font_size = $options['button_font_size']; | |
| 45 | - } else { | |
| 46 | - $button_font_size = 12; | |
| 47 | - } | |
| 48 | - | |
| 49 | - if ( isset( $options['button_font_weight'] ) ) { | |
| 50 | - $button_font_weight = $options['button_font_weight']; | |
| 51 | - } else { | |
| 52 | - $button_font_weight = 400; | |
| 53 | - } | |
| 54 | - | |
| 55 | - // Set default padding/margin if missing. | |
| 56 | - $form_spacing = [ | |
| 57 | - 'margin' => [ | |
| 58 | - 'top' => $options['form_margin']['top'] ?? 0, | |
| 59 | - 'right' => $options['form_margin']['right'] ?? 0, | |
| 60 | - 'bottom' => $options['form_margin']['bottom'] ?? 0, | |
| 61 | - 'left' => $options['form_margin']['left'] ?? 0, | |
| 62 | - ], | |
| 63 | - 'padding' => [ | |
| 64 | - 'top' => $options['form_padding']['top'] ?? '10px', | |
| 65 | - 'right' => $options['form_padding']['right'] ?? '30px', | |
| 66 | - 'bottom' => $options['form_padding']['bottom'] ?? '30px', | |
| 67 | - 'left' => $options['form_padding']['left'] ?? '30px', | |
| 68 | - ], | |
| 69 | - ]; | |
| 70 | - | |
| 71 | - $button_spacing = [ | |
| 72 | - 'margin' => [ | |
| 73 | - 'top' => $options['button_margin']['top'] ?? 0, | |
| 74 | - 'right' => $options['button_margin']['right'] ?? 0, | |
| 75 | - 'bottom' => $options['button_margin']['bottom'] ?? 0, | |
| 76 | - 'left' => $options['button_margin']['left'] ?? 0, | |
| 77 | - ], | |
| 78 | - 'padding' => [ | |
| 79 | - 'top' => $options['button_padding']['top'] ?? '10px', | |
| 80 | - 'right' => $options['button_padding']['right'] ?? '10px', | |
| 81 | - 'bottom' => $options['button_padding']['bottom'] ?? '10px', | |
| 82 | - 'left' => $options['button_padding']['left'] ?? '10px', | |
| 83 | - ], | |
| 84 | - ]; | |
| 85 | - | |
| 86 | - ?> | |
| 87 | - <style> | |
| 88 | - .passster-form { | |
| 89 | - max-width: <?php echo esc_html($options['form_max_width']); ?> !important; | |
| 90 | - <?php if( isset($options['center_form']) && $options['center_form']) : ?> margin: 0 auto !important; | |
| 91 | - <?php endif; ?> | |
| 92 | - } | |
| 93 | - | |
| 94 | - .passster-form > form { | |
| 95 | - background: <?php echo esc_html($options['form_background_color']); ?>; | |
| 96 | - padding: <?php echo esc_html($form_spacing['padding']['top']); ?> <?php echo esc_html($form_spacing['padding']['right']); ?> <?php echo esc_html($form_spacing['padding']['bottom']); ?> <?php echo esc_html($form_spacing['padding']['left']); ?>; | |
| 97 | - margin: <?php echo esc_html($form_spacing['margin']['top']); ?> <?php echo esc_html($form_spacing['margin']['right']); ?> <?php echo esc_html($form_spacing['margin']['bottom']); ?> <?php echo esc_html($form_spacing['margin']['left']); ?>; | |
| 98 | - border-radius: <?php echo esc_html($options['form_border_radius']); ?>px; | |
| 99 | - } | |
| 100 | - | |
| 101 | - .passster-form .ps-form-headline { | |
| 102 | - font-size: <?php echo esc_html($options['headline_font_size']); ?>px; | |
| 103 | - font-weight: <?php echo esc_html($options['headline_font_weight']); ?>; | |
| 104 | - color: <?php echo esc_html($options['headline_font_color']); ?>; | |
| 105 | - } | |
| 106 | - | |
| 107 | - .passster-form p { | |
| 108 | - font-size: <?php echo esc_html($options['instruction_font_size']); ?>px; | |
| 109 | - font-weight: <?php echo esc_html($options['instruction_font_weight']); ?>; | |
| 110 | - color: <?php echo esc_html($options['instruction_font_color']); ?>; | |
| 111 | - } | |
| 112 | - | |
| 113 | - .passster-submit, .passster-submit-recaptcha { | |
| 114 | - background: <?php echo esc_html($options['button_background_color']); ?>; | |
| 115 | - padding: <?php echo esc_html($button_spacing['padding']['top']); ?> <?php echo esc_html($button_spacing['padding']['right']); ?> <?php echo esc_html($button_spacing['padding']['bottom']); ?> <?php echo esc_html($button_spacing['padding']['left']); ?>; | |
| 116 | - margin: <?php echo esc_html($button_spacing['margin']['top']); ?> <?php echo esc_html($button_spacing['margin']['right']); ?> <?php echo esc_html($button_spacing['margin']['bottom']); ?> <?php echo esc_html($button_spacing['margin']['left']); ?>; | |
| 117 | - border-radius: <?php echo esc_html($options['button_border_radius']); ?>px; | |
| 118 | - font-size: <?php echo esc_html($button_font_size); ?>px; | |
| 119 | - font-weight: <?php echo esc_html($button_font_weight); ?>; | |
| 120 | - color: <?php echo esc_html($options['button_font_color']); ?>; | |
| 121 | - } | |
| 122 | - | |
| 123 | - .passster-submit:hover, .passster-submit-recaptcha:hover { | |
| 124 | - background: <?php echo esc_html($options['button_background_color_hover']); ?>; | |
| 125 | - color: <?php echo esc_html($options['button_font_color_hover']); ?>; | |
| 126 | - } | |
| 127 | - </style> | |
| 128 | - <?php | |
| 129 | - } | |
| 130 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace passster; | |
| 4 | + | |
| 5 | +class PS_Dynamic_Styles { | |
| 6 | + /** | |
| 7 | + * Contains instance or null | |
| 8 | + * | |
| 9 | + * @var object|null | |
| 10 | + */ | |
| 11 | + private static $instance = null; | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * Returns instance of PS_Dynamic_Styles. | |
| 15 | + * | |
| 16 | + * @return object | |
| 17 | + */ | |
| 18 | + public static function get_instance() { | |
| 19 | + if ( null === self::$instance ) { | |
| 20 | + self::$instance = new self(); | |
| 21 | + } | |
| 22 | + | |
| 23 | + return self::$instance; | |
| 24 | + } | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * Constructor. | |
| 28 | + * | |
| 29 | + * @return void | |
| 30 | + */ | |
| 31 | + public function __construct() { | |
| 32 | + add_action( 'wp_head', array( $this, 'dynamic_styles' ) ); | |
| 33 | + } | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * Add dynamic styles | |
| 37 | + * | |
| 38 | + * @return void | |
| 39 | + */ | |
| 40 | + public function dynamic_styles() { | |
| 41 | + $options = get_option( 'passster' ); | |
| 42 | + | |
| 43 | + // Don't output styles if disabled (theme handles styling) | |
| 44 | + if ( ! empty( $options['disable_css'] ) ) { | |
| 45 | + return; | |
| 46 | + } | |
| 47 | + | |
| 48 | + if ( isset( $options['button_font_size'] ) ) { | |
| 49 | + $button_font_size = $options['button_font_size']; | |
| 50 | + } else { | |
| 51 | + $button_font_size = 12; | |
| 52 | + } | |
| 53 | + | |
| 54 | + if ( isset( $options['button_font_weight'] ) ) { | |
| 55 | + $button_font_weight = $options['button_font_weight']; | |
| 56 | + } else { | |
| 57 | + $button_font_weight = 400; | |
| 58 | + } | |
| 59 | + | |
| 60 | + // Set default padding/margin if missing. | |
| 61 | + $form_spacing = [ | |
| 62 | + 'margin' => [ | |
| 63 | + 'top' => $options['form_margin']['top'] ?? 0, | |
| 64 | + 'right' => $options['form_margin']['right'] ?? 0, | |
| 65 | + 'bottom' => $options['form_margin']['bottom'] ?? 0, | |
| 66 | + 'left' => $options['form_margin']['left'] ?? 0, | |
| 67 | + ], | |
| 68 | + 'padding' => [ | |
| 69 | + 'top' => $options['form_padding']['top'] ?? '10px', | |
| 70 | + 'right' => $options['form_padding']['right'] ?? '30px', | |
| 71 | + 'bottom' => $options['form_padding']['bottom'] ?? '30px', | |
| 72 | + 'left' => $options['form_padding']['left'] ?? '30px', | |
| 73 | + ], | |
| 74 | + ]; | |
| 75 | + | |
| 76 | + $button_spacing = [ | |
| 77 | + 'margin' => [ | |
| 78 | + 'top' => $options['button_margin']['top'] ?? 0, | |
| 79 | + 'right' => $options['button_margin']['right'] ?? 0, | |
| 80 | + 'bottom' => $options['button_margin']['bottom'] ?? 0, | |
| 81 | + 'left' => $options['button_margin']['left'] ?? 0, | |
| 82 | + ], | |
| 83 | + 'padding' => [ | |
| 84 | + 'top' => $options['button_padding']['top'] ?? '10px', | |
| 85 | + 'right' => $options['button_padding']['right'] ?? '10px', | |
| 86 | + 'bottom' => $options['button_padding']['bottom'] ?? '10px', | |
| 87 | + 'left' => $options['button_padding']['left'] ?? '10px', | |
| 88 | + ], | |
| 89 | + ]; | |
| 90 | + | |
| 91 | + ?> | |
| 92 | + <style> | |
| 93 | + .passster-form { | |
| 94 | + max-width: <?php echo esc_html($options['form_max_width']); ?>; | |
| 95 | + <?php if( isset($options['center_form']) && $options['center_form']) : ?> margin: 0 auto; | |
| 96 | + <?php endif; ?> | |
| 97 | + } | |
| 98 | + | |
| 99 | + .passster-form > form { | |
| 100 | + background: <?php echo esc_html($options['form_background_color']); ?>; | |
| 101 | + padding: <?php echo esc_html($form_spacing['padding']['top']); ?> <?php echo esc_html($form_spacing['padding']['right']); ?> <?php echo esc_html($form_spacing['padding']['bottom']); ?> <?php echo esc_html($form_spacing['padding']['left']); ?>; | |
| 102 | + margin: <?php echo esc_html($form_spacing['margin']['top']); ?> <?php echo esc_html($form_spacing['margin']['right']); ?> <?php echo esc_html($form_spacing['margin']['bottom']); ?> <?php echo esc_html($form_spacing['margin']['left']); ?>; | |
| 103 | + border-radius: <?php echo esc_html($options['form_border_radius']); ?>px; | |
| 104 | + } | |
| 105 | + | |
| 106 | + .passster-form .ps-form-headline { | |
| 107 | + font-size: <?php echo esc_html($options['headline_font_size']); ?>px; | |
| 108 | + font-weight: <?php echo esc_html($options['headline_font_weight']); ?>; | |
| 109 | + color: <?php echo esc_html($options['headline_font_color']); ?>; | |
| 110 | + } | |
| 111 | + | |
| 112 | + .passster-form .ps-form-instructions-wrap { | |
| 113 | + font-size: <?php echo esc_html($options['instruction_font_size']); ?>px; | |
| 114 | + font-weight: <?php echo esc_html($options['instruction_font_weight']); ?>; | |
| 115 | + color: <?php echo esc_html($options['instruction_font_color']); ?>; | |
| 116 | + } | |
| 117 | + | |
| 118 | + .passster-form button[type="submit"], .passster-form .passster-submit, | |
| 119 | + .passster-form .passster-submit-recaptcha, .passster-form .passster-submit-turnstile { | |
| 120 | + background: <?php echo esc_html($options['button_background_color']); ?>; | |
| 121 | + padding: <?php echo esc_html($button_spacing['padding']['top']); ?> <?php echo esc_html($button_spacing['padding']['right']); ?> <?php echo esc_html($button_spacing['padding']['bottom']); ?> <?php echo esc_html($button_spacing['padding']['left']); ?>; | |
| 122 | + margin: <?php echo esc_html($button_spacing['margin']['top']); ?> <?php echo esc_html($button_spacing['margin']['right']); ?> <?php echo esc_html($button_spacing['margin']['bottom']); ?> <?php echo esc_html($button_spacing['margin']['left']); ?>; | |
| 123 | + border-radius: <?php echo esc_html($options['button_border_radius']); ?>px; | |
| 124 | + font-size: <?php echo esc_html($button_font_size); ?>px; | |
| 125 | + font-weight: <?php echo esc_html($button_font_weight); ?>; | |
| 126 | + color: <?php echo esc_html($options['button_font_color']); ?>; | |
| 127 | + } | |
| 128 | + | |
| 129 | + .passster-form button[type="submit"]:hover, .passster-form .passster-submit:hover, | |
| 130 | + .passster-form .passster-submit-recaptcha:hover, .passster-form .passster-submit-turnstile:hover { | |
| 131 | + background: <?php echo esc_html($options['button_background_color_hover']); ?>; | |
| 132 | + color: <?php echo esc_html($options['button_font_color_hover']); ?>; | |
| 133 | + } | |
| 134 | + </style> | |
| 135 | + <?php | |
| 136 | + } | |
| 137 | +} | |