| 1 |
<?php |
| 2 |
|
| 3 |
namespace passster; |
| 4 |
|
| 5 |
class PS_Customizer { |
| 6 |
|
| 7 |
/** |
| 8 |
* Constructor for PS_Customizer |
| 9 |
*/ |
| 10 |
public function __construct() { |
| 11 |
add_action( 'customize_register', array( $this, 'customize_register' ) ); |
| 12 |
add_action( 'wp_head', array( $this, 'dynamic_styles' ) ); |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Get instance of PS_Customizer |
| 17 |
* |
| 18 |
* @return void |
| 19 |
*/ |
| 20 |
public static function get_instance() { |
| 21 |
new PS_Customizer(); |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Register customizer fields |
| 26 |
* |
| 27 |
* @param object $wp_customize customizer object. |
| 28 |
* @return void |
| 29 |
*/ |
| 30 |
public function customize_register( $wp_customize ) { |
| 31 |
|
| 32 |
$wp_customize->add_panel( 'passster', array( |
| 33 |
'priority' => 999, |
| 34 |
'capability' => 'edit_theme_options', |
| 35 |
'theme_supports' => '', |
| 36 |
'title' => __( 'Passster', 'content-protector' ), |
| 37 |
) ); |
| 38 |
|
| 39 |
/* general section */ |
| 40 |
$wp_customize->add_section( 'passster_form_general', array( |
| 41 |
'title' => __( 'General', 'content-protector' ), |
| 42 |
'panel' => 'passster', |
| 43 |
) ); |
| 44 |
|
| 45 |
/* background color - form container */ |
| 46 |
$wp_customize->add_setting( 'passster_form_general_background_color', array( |
| 47 |
'default' => '#F9F9F9', |
| 48 |
) ); |
| 49 |
|
| 50 |
$wp_customize->add_control( |
| 51 |
new \WP_Customize_Color_Control( |
| 52 |
$wp_customize, |
| 53 |
'passster_form_general_background_color_control', array( |
| 54 |
'label' => __( 'Background Color', 'content-protector' ), |
| 55 |
'description' => __( 'Change the background color of the form', 'content-protector' ), |
| 56 |
'section' => 'passster_form_general', |
| 57 |
'settings' => 'passster_form_general_background_color', |
| 58 |
) ) |
| 59 |
); |
| 60 |
|
| 61 |
// padding - form container |
| 62 |
$wp_customize->add_setting( 'passster_form_general_padding', array( |
| 63 |
'default' => '10', |
| 64 |
) ); |
| 65 |
|
| 66 |
$wp_customize->add_control( 'passster_form_general_padding_control', array( |
| 67 |
'label' => __( 'Padding', 'content-protector' ), |
| 68 |
'description' => __( 'Padding in PX', 'content-protector' ), |
| 69 |
'section' => 'passster_form_general', |
| 70 |
'settings' => 'passster_form_general_padding', |
| 71 |
'type' => 'text', |
| 72 |
) ); |
| 73 |
|
| 74 |
// margin - form container |
| 75 |
$wp_customize->add_setting( 'passster_form_general_margin', array( |
| 76 |
'default' => '0', |
| 77 |
) ); |
| 78 |
|
| 79 |
$wp_customize->add_control( 'passster_form_general_margin_control', array( |
| 80 |
'label' => __( 'Margin', 'content-protector' ), |
| 81 |
'description' => __( 'Margin in PX', 'content-protector' ), |
| 82 |
'section' => 'passster_form_general', |
| 83 |
'settings' => 'passster_form_general_margin', |
| 84 |
'type' => 'text', |
| 85 |
) ); |
| 86 |
|
| 87 |
/* form instructions section */ |
| 88 |
$wp_customize->add_section( 'passster_form_instructions', array( |
| 89 |
'title' => __( 'Form Instructions', 'content-protector' ), |
| 90 |
'panel' => 'passster', |
| 91 |
) ); |
| 92 |
|
| 93 |
/* instructions headline */ |
| 94 |
$wp_customize->add_setting( 'passster_form_instructions_headline', array( |
| 95 |
'default' => __( 'Protected Area', 'content-protector' ), |
| 96 |
) ); |
| 97 |
$wp_customize->add_control( 'passster_form_instructions_headline_control', array( |
| 98 |
'label' => __( 'Headline', 'content-protector' ), |
| 99 |
'section' => 'passster_form_instructions', |
| 100 |
'settings' => 'passster_form_instructions_headline', |
| 101 |
'type' => 'text', |
| 102 |
) ); |
| 103 |
|
| 104 |
/* headline font size */ |
| 105 |
$wp_customize->add_setting( 'passster_form_instructions_headline_font_size', array( |
| 106 |
'default' => '20', |
| 107 |
) ); |
| 108 |
$wp_customize->add_control( 'passster_form_instructions_headline_font_size_control', array( |
| 109 |
'label' => __( 'Headline Font Size', 'content-protector' ), |
| 110 |
'description' => __( 'Font size in PX', 'content-protector' ), |
| 111 |
'section' => 'passster_form_instructions', |
| 112 |
'settings' => 'passster_form_instructions_headline_font_size', |
| 113 |
'type' => 'number', |
| 114 |
) ); |
| 115 |
|
| 116 |
/* headline font weight */ |
| 117 |
$wp_customize->add_setting( 'passster_form_instructions_headline_font_weight', array( |
| 118 |
'default' => '700', |
| 119 |
) ); |
| 120 |
$wp_customize->add_control( 'passster_form_instructions_headline_font_weight_control', array( |
| 121 |
'label' => __( 'Headline Font Weight', 'content-protector' ), |
| 122 |
'section' => 'passster_form_instructions', |
| 123 |
'settings' => 'passster_form_instructions_headline_font_weight', |
| 124 |
'type' => 'number', |
| 125 |
) ); |
| 126 |
|
| 127 |
/* headline color */ |
| 128 |
$wp_customize->add_setting( 'passster_form_instructions_headline_color', array( |
| 129 |
'default' => '#4998b3', |
| 130 |
) ); |
| 131 |
|
| 132 |
$wp_customize->add_control( |
| 133 |
new \WP_Customize_Color_Control( |
| 134 |
$wp_customize, |
| 135 |
'passster_form_instructions_headline_color_control', array( |
| 136 |
'label' => __( 'Headline Color', 'content-protector' ), |
| 137 |
'section' => 'passster_form_instructions', |
| 138 |
'settings' => 'passster_form_instructions_headline_color', |
| 139 |
) ) |
| 140 |
); |
| 141 |
|
| 142 |
/* placeholder text */ |
| 143 |
$wp_customize->add_setting( 'passster_form_instructions_placeholder', array( |
| 144 |
'default' => __( 'Enter your password..', 'content-protector' ), |
| 145 |
) ); |
| 146 |
$wp_customize->add_control( 'passster_form_instructions_placeholder_control', array( |
| 147 |
'label' => __( 'Placholder Text', 'content-protector' ), |
| 148 |
'section' => 'passster_form_instructions', |
| 149 |
'settings' => 'passster_form_instructions_placeholder', |
| 150 |
'type' => 'text', |
| 151 |
) ); |
| 152 |
|
| 153 |
/* instructions text */ |
| 154 |
$wp_customize->add_setting( 'passster_form_instructions_text', array( |
| 155 |
'default' => __( 'This content is password-protected. Please verify with a password to unlock the content.', 'content-protector' ), |
| 156 |
) ); |
| 157 |
$wp_customize->add_control( 'passster_form_instructions_text_control', array( |
| 158 |
'label' => __( 'Instructions Text', 'content-protector' ), |
| 159 |
'section' => 'passster_form_instructions', |
| 160 |
'settings' => 'passster_form_instructions_text', |
| 161 |
'type' => 'textarea', |
| 162 |
) ); |
| 163 |
|
| 164 |
/* error text */ |
| 165 |
$wp_customize->add_setting( 'passster_form_error_text', array( |
| 166 |
'default' => __( 'Sorry, there was an error.', 'content-protector' ), |
| 167 |
) ); |
| 168 |
$wp_customize->add_control( 'passster_form_error_text_control', array( |
| 169 |
'label' => __( 'Error Text', 'content-protector' ), |
| 170 |
'section' => 'passster_form_instructions', |
| 171 |
'settings' => 'passster_form_error_text', |
| 172 |
'type' => 'textarea', |
| 173 |
) ); |
| 174 |
|
| 175 |
|
| 176 |
/* instructions font size */ |
| 177 |
$wp_customize->add_setting( 'passster_form_instructions_text_font_size', array( |
| 178 |
'default' => '14', |
| 179 |
) ); |
| 180 |
$wp_customize->add_control( 'passster_form_instructions_text_font_size_control', array( |
| 181 |
'label' => __( 'Font Size', 'content-protector' ), |
| 182 |
'description' => __( 'Font size in PX', 'content-protector' ), |
| 183 |
'section' => 'passster_form_instructions', |
| 184 |
'settings' => 'passster_form_instructions_text_font_size', |
| 185 |
'type' => 'number', |
| 186 |
) ); |
| 187 |
|
| 188 |
/* instructions font weight */ |
| 189 |
$wp_customize->add_setting( 'passster_form_instructions_text_font_weight', array( |
| 190 |
'default' => '400', |
| 191 |
) ); |
| 192 |
$wp_customize->add_control( 'passster_form_instructions_text_font_weight_control', array( |
| 193 |
'label' => __( 'Font Weight', 'content-protector' ), |
| 194 |
'section' => 'passster_form_instructions', |
| 195 |
'settings' => 'passster_form_instructions_text_font_weight', |
| 196 |
'type' => 'number', |
| 197 |
) ); |
| 198 |
|
| 199 |
/* text color - form instructions */ |
| 200 |
$wp_customize->add_setting( 'passster_form_instructions_text_color', array( |
| 201 |
'default' => '#000000', |
| 202 |
) ); |
| 203 |
|
| 204 |
$wp_customize->add_control( |
| 205 |
new \WP_Customize_Color_Control( |
| 206 |
$wp_customize, |
| 207 |
'passster_form_instructions_text_color_control', array( |
| 208 |
'label' => __( 'Text Color', 'content-protector' ), |
| 209 |
'section' => 'passster_form_instructions', |
| 210 |
'settings' => 'passster_form_instructions_text_color', |
| 211 |
) ) |
| 212 |
); |
| 213 |
|
| 214 |
/* password typing - form instructions */ |
| 215 |
|
| 216 |
$wp_customize->add_setting( 'passster_form_instructions_password_typing', array( |
| 217 |
'default' => 0, |
| 218 |
) ); |
| 219 |
|
| 220 |
$wp_customize->add_control( 'passster_form_instructions_password_typing_control', array( |
| 221 |
'label' => __( 'Add Checkbox to show password', 'content-protector' ), |
| 222 |
'section' => 'passster_form_instructions', |
| 223 |
'settings' => 'passster_form_instructions_password_typing', |
| 224 |
'type' => 'checkbox', |
| 225 |
)); |
| 226 |
|
| 227 |
/* form button */ |
| 228 |
$wp_customize->add_section( 'passster_form_button', array( |
| 229 |
'title' => __( 'Button', 'content-protector' ), |
| 230 |
'panel' => 'passster', |
| 231 |
) ); |
| 232 |
|
| 233 |
/* button label */ |
| 234 |
$wp_customize->add_setting( 'passster_form_button_label', array( |
| 235 |
'default' => __( 'Submit', 'content-protector' ), |
| 236 |
) ); |
| 237 |
$wp_customize->add_control( 'passster_form_button_label_control', array( |
| 238 |
'label' => __( 'Button Label', 'content-protector' ), |
| 239 |
'section' => 'passster_form_button', |
| 240 |
'settings' => 'passster_form_button_label', |
| 241 |
'type' => 'text', |
| 242 |
) ); |
| 243 |
|
| 244 |
/* button text color */ |
| 245 |
$wp_customize->add_setting( 'passster_form_button_text_color', array( |
| 246 |
'default' => '#FFFFFF', |
| 247 |
) ); |
| 248 |
|
| 249 |
$wp_customize->add_control( |
| 250 |
new \WP_Customize_Color_Control( |
| 251 |
$wp_customize, |
| 252 |
'passster_form_button_text_color_control', array( |
| 253 |
'label' => __( 'Text Color', 'content-protector' ), |
| 254 |
'section' => 'passster_form_button', |
| 255 |
'settings' => 'passster_form_button_text_color', |
| 256 |
) ) |
| 257 |
); |
| 258 |
|
| 259 |
/* button text hover color */ |
| 260 |
$wp_customize->add_setting( 'passster_form_button_text_hover_color', array( |
| 261 |
'default' => '#FFFFFF', |
| 262 |
) ); |
| 263 |
|
| 264 |
$wp_customize->add_control( |
| 265 |
new \WP_Customize_Color_Control( |
| 266 |
$wp_customize, |
| 267 |
'passster_form_button_text_hover_color_control', array( |
| 268 |
'label' => __( 'Text Color (Hover)', 'content-protector' ), |
| 269 |
'section' => 'passster_form_button', |
| 270 |
'settings' => 'passster_form_button_text_hover_color', |
| 271 |
) ) |
| 272 |
); |
| 273 |
|
| 274 |
/* button background color */ |
| 275 |
$wp_customize->add_setting( 'passster_form_button_background_color', array( |
| 276 |
'default' => '#4998b3', |
| 277 |
) ); |
| 278 |
|
| 279 |
$wp_customize->add_control( |
| 280 |
new \WP_Customize_Color_Control( |
| 281 |
$wp_customize, |
| 282 |
'passster_form_button_background_color_control', array( |
| 283 |
'label' => __( 'Background Color', 'content-protector' ), |
| 284 |
'section' => 'passster_form_button', |
| 285 |
'settings' => 'passster_form_button_background_color', |
| 286 |
) ) |
| 287 |
); |
| 288 |
|
| 289 |
/* button background hover color */ |
| 290 |
$wp_customize->add_setting( 'passster_form_button_background_hover_color', array( |
| 291 |
'default' => '#aa1100', |
| 292 |
) ); |
| 293 |
|
| 294 |
$wp_customize->add_control( |
| 295 |
new \WP_Customize_Color_Control( |
| 296 |
$wp_customize, |
| 297 |
'passster_form_button_background_hover_color_control', array( |
| 298 |
'label' => __( 'Background Color (Hover)', 'content-protector' ), |
| 299 |
'section' => 'passster_form_button', |
| 300 |
'settings' => 'passster_form_button_background_hover_color', |
| 301 |
) ) |
| 302 |
); |
| 303 |
|
| 304 |
} |
| 305 |
/** |
| 306 |
* Add dynamic styles |
| 307 |
* |
| 308 |
* @return void |
| 309 |
*/ |
| 310 |
public function dynamic_styles() { |
| 311 |
?> |
| 312 |
<style> |
| 313 |
.passster-form { |
| 314 |
background: <?php echo get_theme_mod( 'passster_form_general_background_color', '#F9F9F9' ); ?>; |
| 315 |
padding: <?php echo get_theme_mod( 'passster_form_general_padding', '10' ); ?>px; |
| 316 |
margin: <?php echo get_theme_mod( 'passster_form_general_margin', '0' ); ?>px; |
| 317 |
} |
| 318 |
.passster-form h4 { |
| 319 |
font-size: <?php echo get_theme_mod( 'passster_form_instructions_headline_font_size', '20' ); ?>px; |
| 320 |
font-weight: <?php echo get_theme_mod( 'passster_form_instructions_headline_font_weight', '700' ); ?>; |
| 321 |
color: <?php echo get_theme_mod( 'passster_form_instructions_headline_color', '#4998b3' ); ?>; |
| 322 |
} |
| 323 |
.passster-form p { |
| 324 |
font-size: <?php echo get_theme_mod( 'passster_form_instructions_text_font_size', '14' ); ?>px; |
| 325 |
font-weight: <?php echo get_theme_mod( 'passster_form_instructions_text_font_weight', '400' ); ?>; |
| 326 |
color: <?php echo get_theme_mod( 'passster_form_instructions_text_color', '#000000' ); ?>; |
| 327 |
} |
| 328 |
.passster-submit, .passster-submit-recaptcha, .passster-submit-captcha { |
| 329 |
color: <?php echo get_theme_mod( 'passster_form_button_text_color', '#FFFFFF' ); ?> !important; |
| 330 |
background: <?php echo get_theme_mod( 'passster_form_button_background_color', '#4998b3' ); ?> !important; |
| 331 |
} |
| 332 |
.passster-submit:hover, .passster-submit-recaptcha:hover, .passster-submit-captcha:hover { |
| 333 |
color: <?php echo get_theme_mod( 'passster_form_button_text_hover_color', '#FFFFFF' ); ?> !important; |
| 334 |
background: <?php echo get_theme_mod( 'passster_form_button_background_hover_color', '#aa1100' ); ?> !important; |
| 335 |
} |
| 336 |
</style> |
| 337 |
<?php |
| 338 |
} |
| 339 |
|
| 340 |
} |
| 341 |
|
| 342 |
|