add_panel( self::PANEL, array( 'priority' => 9990, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __( 'PPWP Partial Protection Form', 'password-protect-page' ), ) ); $this->append_form_section( $wp_customize ); $this->append_err_msg_section( $wp_customize ); $this->append_button_section( $wp_customize ); } /** * Append form section. * * @param WP_Customize $wp_customize WP Customize class. */ public function append_form_section( $wp_customize ) { $wp_customize->add_section( self::FORM_SECTION, array( 'title' => __( 'Password Form', 'password-protect-page' ), 'panel' => self::PANEL, 'priority' => 10, ) ); $wp_customize->add_setting( 'ppwp_pcp_form_background_title' ); $wp_customize->add_control( new PPW_Title_Group_Control( $wp_customize, 'ppwp_pcp_form_background_title', array( 'label' => __( 'Background', 'password-protect-page' ), 'section' => self::FORM_SECTION, 'settings' => 'ppwp_pcp_form_background_title', 'type' => 'control_title', 'priority' => 0, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_form_background_color' ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ppwp_pcp_form_background_color_control', array( 'label' => __( 'Form Background Color', 'password-protect-page' ), 'section' => self::FORM_SECTION, 'settings' => 'ppwp_pcp_form_background_color', 'priority' => 10, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_form_padding' ); $wp_customize->add_control( 'ppwp_pcp_form_padding_control', array( 'label' => __( 'Padding', 'password-protect-page' ), 'description' => __( 'Padding in px', 'password-protect-page' ), 'section' => self::FORM_SECTION, 'settings' => 'ppwp_pcp_form_padding', 'type' => 'number', 'priority' => 20, ) ); /* form background border radius */ $wp_customize->add_setting( 'ppwp_pcp_form_border_radius', array( 'default' => PPW_Constants::DEFAULT_FORM_BORDER_RADIUS, ) ); $wp_customize->add_control( 'ppwp_pcp_form_border_radius_control', array( 'label' => __( 'Border Radius', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'description' => 'Border Radius in px', 'settings' => 'ppwp_pcp_form_border_radius', 'type' => 'number', 'priority' => 40, ) ); $wp_customize->add_setting( 'ppwp_pcp_form_headline_title' ); $wp_customize->add_control( new PPW_Title_Group_Control( $wp_customize, 'ppwp_pcp_form_headline_title', array( 'label' => __( 'Headline', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'settings' => 'ppwp_pcp_form_headline_title', 'type' => 'control_title', 'priority' => 50, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_form_headline', array( 'default' => PPW_Constants::DEFAULT_SHORTCODE_HEADLINE, ) ); $wp_customize->add_control( new PPW_Text_Editor_Custom_Control( $wp_customize, 'ppwp_pcp_form_headline', array( 'label' => __( 'Headline', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'settings' => 'ppwp_pcp_form_headline', 'type' => 'textarea', 'priority' => 60, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_form_headline_font_size', array( 'default' => PPW_Constants::DEFAULT_HEADLINE_FONT_SIZE, ) ); $wp_customize->add_control( 'ppwp_pcp_form_headline_font_size_control', array( 'label' => __( 'Font Size', 'password-protect-page' ), 'description' => __( 'Font size in px', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'settings' => 'ppwp_pcp_form_headline_font_size', 'type' => 'number', 'priority' => 70, ) ); $wp_customize->add_setting( 'ppwp_pcp_form_headline_font_weight', array( 'default' => PPW_Constants::DEFAULT_HEADLINE_FONT_WEIGHT, ) ); $wp_customize->add_control( 'ppwp_pcp_form_headline_font_weight_control', array( 'label' => __( 'Font Weight', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'settings' => 'ppwp_pcp_form_headline_font_weight', 'type' => 'number', 'priority' => 80, ) ); $wp_customize->add_setting( 'ppwp_pcp_form_headline_color', array( 'default' => PPW_Constants::DEFAULT_HEADLINE_FONT_COLOR, ) ); $wp_customize->add_control( new \WP_Customize_Color_Control( $wp_customize, 'ppwp_pcp_form_headline_color_control', array( 'label' => __( 'Text Color', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'settings' => 'ppwp_pcp_form_headline_color', 'priority' => 90, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_form_description_title' ); $wp_customize->add_control( new PPW_Title_Group_Control( $wp_customize, 'ppwp_pcp_form_description_title', array( 'label' => __( 'Description Above Form', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'settings' => 'ppwp_pcp_form_description_title', 'type' => 'control_title', 'priority' => 100, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_form_description', array( 'default' => PPW_Constants::DEFAULT_SHORTCODE_DESCRIPTION, ) ); $wp_customize->add_control( new PPW_Text_Editor_Custom_Control( $wp_customize, 'ppwp_pcp_form_description', array( 'label' => __( 'Description', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'settings' => 'ppwp_pcp_form_description', 'type' => 'textarea', 'priority' => 110, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_form_description_font_size', array( 'default' => PPW_Constants::DEFAULT_TEXT_FONT_SIZE, ) ); $wp_customize->add_control( 'ppwp_pcp_form_description_font_size_control', array( 'label' => __( 'Font Size', 'password-protect-page' ), 'description' => __( 'Font size in px', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'settings' => 'ppwp_pcp_form_description_font_size', 'type' => 'number', 'priority' => 120, ) ); $wp_customize->add_setting( 'ppwp_pcp_form_description_font_weight', array( 'default' => PPW_Constants::DEFAULT_TEXT_FONT_WEIGHT, ) ); $wp_customize->add_control( 'ppwp_pcp_form_description_font_weight_control', array( 'label' => __( 'Font Weight', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'settings' => 'ppwp_pcp_form_description_font_weight', 'type' => 'number', 'priority' => 130, ) ); $wp_customize->add_setting( 'ppwp_pcp_form_description_color', array( 'default' => PPW_Constants::DEFAULT_TEXT_FONT_COLOR, ) ); $wp_customize->add_control( new \WP_Customize_Color_Control( $wp_customize, 'ppwp_pcp_form_description_color_control', array( 'label' => __( 'Text Color', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'settings' => 'ppwp_pcp_form_description_color', 'priority' => 140, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_form_desc_title' ); $wp_customize->add_control( new PPW_Title_Group_Control( $wp_customize, 'ppwp_pcp_form_desc_title', array( 'label' => __( 'Description Below Form', 'password-protect-page' ), 'section' => 'ppwp_pcp_form', 'settings' => 'ppwp_pcp_form_desc_title', 'type' => 'control_title', 'priority' => 145, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_description_below_form', array( 'default' => PPW_Constants::DEFAULT_SHORTCODE_DESC_BELOW_PWD_FORM, ) ); $wp_customize->add_control( new PPW_Text_Editor_Custom_Control( $wp_customize, 'ppwp_pcp_description_below_form', array( 'label' => __( 'Description', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'settings' => 'ppwp_pcp_description_below_form', 'type' => 'textarea', 'priority' => 146, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_form_description_below_form_font_size', array( 'default' => PPW_Constants::DEFAULT_TEXT_FONT_SIZE, ) ); $wp_customize->add_control( 'ppwp_pcp_form_description_below_form_font_size_control', array( 'label' => __( 'Font Size', 'password-protect-page' ), 'description' => __( 'Font size in px', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'settings' => 'ppwp_pcp_form_description_below_form_font_size', 'type' => 'number', 'priority' => 147, ) ); $wp_customize->add_setting( 'ppwp_pcp_form_description_below_form_font_weight', array( 'default' => PPW_Constants::DEFAULT_TEXT_FONT_WEIGHT, ) ); $wp_customize->add_control( 'ppwp_pcp_form_description_below_form_font_weight_control', array( 'label' => __( 'Font Weight', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'settings' => 'ppwp_pcp_form_description_below_form_font_weight', 'type' => 'number', 'priority' => 148, ) ); $wp_customize->add_setting( 'ppwp_pcp_form_description_below_form_color', array( 'default' => PPW_Constants::DEFAULT_TEXT_FONT_COLOR, ) ); $wp_customize->add_control( new \WP_Customize_Color_Control( $wp_customize, 'ppwp_pcp_form_description_below_form_color_control', array( 'label' => __( 'Text Color', 'password-protect-page' ), 'section' => self::GENERAL_SECTION, 'settings' => 'ppwp_pcp_form_description_below_form_color', 'priority' => 149, ) ) ); // $wp_customize->add_setting( 'ppwp_pcp_desc_above_btn' ); // $wp_customize->add_control( // new PPW_Title_Group_Control( // $wp_customize, // 'ppwp_pcp_desc_above_btn', // array( // 'label' => __( 'Description Above Button', 'password-protect-page' ), // 'section' => 'ppwp_pcp_form', // 'settings' => 'ppwp_pcp_desc_above_btn', // 'type' => 'control_title', // 'priority' => 150, // ) // ) // ); // $wp_customize->add_setting( 'ppwp_pcp_description_above_btn', array( // 'default' => PPW_Constants::DEFAULT_SHORTCODE_DESC_ABOVE_PWD_BTN, // ) ); // $wp_customize->add_control( // new PPW_Text_Editor_Custom_Control( // $wp_customize, // 'ppwp_pcp_description_above_btn', // array( // 'label' => __( 'Description', 'password-protect-page' ), // 'section' => self::GENERAL_SECTION, // 'settings' => 'ppwp_pcp_description_above_btn', // 'type' => 'textarea', // 'priority' => 152, // ) // ) // ); // $wp_customize->add_setting( 'ppwp_pcp_form_description_above_btn_font_size', array( // 'default' => PPW_Constants::DEFAULT_TEXT_FONT_SIZE, // ) ); // $wp_customize->add_control( 'ppwp_pcp_form_description_above_btn_font_size_control', array( // 'label' => __( 'Font Size', 'password-protect-page' ), // 'description' => __( 'Font size in px', 'password-protect-page' ), // 'section' => self::GENERAL_SECTION, // 'settings' => 'ppwp_pcp_form_description_above_btn_font_size', // 'type' => 'number', // 'priority' => 153, // ) ); // $wp_customize->add_setting( 'ppwp_pcp_form_description_above_btn_font_weight', array( // 'default' => PPW_Constants::DEFAULT_TEXT_FONT_WEIGHT, // ) ); // $wp_customize->add_control( 'ppwp_pcp_form_description_above_btn_font_weight_control', array( // 'label' => __( 'Font Weight', 'password-protect-page' ), // 'section' => self::GENERAL_SECTION, // 'settings' => 'ppwp_pcp_form_description_above_btn_font_weight', // 'type' => 'number', // 'priority' => 154, // ) ); // $wp_customize->add_setting( 'ppwp_pcp_form_description_above_btn_color', array( // 'default' => PPW_Constants::DEFAULT_TEXT_FONT_COLOR, // ) ); // $wp_customize->add_control( // new \WP_Customize_Color_Control( // $wp_customize, // 'ppwp_pcp_form_description_above_btn_color_control', array( // 'label' => __( 'Text Color', 'password-protect-page' ), // 'section' => self::GENERAL_SECTION, // 'settings' => 'ppwp_pcp_form_description_above_btn_color', // 'priority' => 155, // ) ) // ); $wp_customize->add_setting( 'ppwp_pcp_form_label_title' ); $wp_customize->add_control( new PPW_Title_Group_Control( $wp_customize, 'ppwp_pcp_form_label_title', array( 'label' => __( 'Password Field', 'password-protect-page' ), 'section' => 'ppwp_pcp_form', 'settings' => 'ppwp_pcp_form_label_title', 'type' => 'control_title', 'priority' => 159, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_form_label', array( 'default' => PPW_Constants::DEFAULT_SHORTCODE_LABEL, ) ); $wp_customize->add_control( 'ppwp_pcp_form_label_control', array( 'label' => __( 'Password Label', 'password-protect-page' ), 'section' => 'ppwp_pcp_form', 'settings' => 'ppwp_pcp_form_label', 'type' => 'text', 'priority' => 160, ) ); $wp_customize->add_setting( 'ppwp_pcp_form_label_font_size', array( 'default' => PPW_Constants::DEFAULT_TEXT_FONT_SIZE, ) ); $wp_customize->add_control( 'ppwp_pcp_form_label_font_size_control', array( 'label' => __( 'Font Size', 'password-protect-page' ), 'description' => __( 'Font size in px', 'password-protect-page' ), 'section' => 'ppwp_pcp_form', 'settings' => 'ppwp_pcp_form_label_font_size', 'type' => 'number', 'priority' => 170, ) ); $wp_customize->add_setting( 'ppwp_pcp_form_label_font_weight', array( 'default' => PPW_Constants::DEFAULT_TEXT_FONT_WEIGHT, ) ); $wp_customize->add_control( 'ppwp_pcp_form_label_font_weight_control', array( 'label' => __( 'Font Weight', 'password-protect-page' ), 'section' => 'ppwp_pcp_form', 'settings' => 'ppwp_pcp_form_label_font_weight', 'type' => 'number', 'priority' => 180, ) ); $wp_customize->add_setting( 'ppwp_pcp_form_label_color', array( 'default' => PPW_Constants::DEFAULT_TEXT_FONT_COLOR, ) ); $wp_customize->add_control( new \WP_Customize_Color_Control( $wp_customize, 'ppwp_pcp_form_label_color_control', array( 'label' => __( 'Text Color', 'password-protect-page' ), 'section' => 'ppwp_pcp_form', 'settings' => 'ppwp_pcp_form_label_color', 'priority' => 190, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_form_placeholder', array( 'default' => PPW_Constants::DEFAULT_PLACEHOLDER, ) ); $wp_customize->add_control( 'ppwp_pcp_form_placeholder_control', array( 'label' => __( 'Placeholder', 'password-protect-page' ), 'section' => 'ppwp_pcp_form', 'settings' => 'ppwp_pcp_form_placeholder', 'type' => 'text', 'priority' => 200, ) ); $wp_customize->add_setting( 'ppwp_pcp_form_show_password_title' ); $wp_customize->add_control( new PPW_Title_Group_Control( $wp_customize, 'ppwp_pcp_form_show_password_title', array( 'label' => __( 'Show Password', 'password-protect-page' ), 'section' => 'ppwp_pcp_form', 'settings' => 'ppwp_pcp_form_show_password_title', 'type' => 'control_title', 'priority' => 210, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_form_is_show_password', array( 'default' => PPW_Constants::DEFAULT_SHORTCODE_SHOW_PASSWORD, ) ); $wp_customize->add_control( new PPW_Toggle_Control( $wp_customize, 'ppwp_pcp_form_is_show_password_control', array( 'label' => __( 'Show Password Reveal Button', 'password-protect-page' ), 'section' => 'ppwp_pcp_form', 'type' => 'toggle', 'settings' => 'ppwp_pcp_form_is_show_password', 'priority' => 220, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_form_show_password_text', array( 'default' => PPW_Constants::DEFAULT_SHORTCODE_SHOW_PASSWORD_TEXT, ) ); $wp_customize->add_control( 'ppwp_pcp_form_show_password_text_control', array( 'label' => __( 'Button Text', 'password-protect-page' ), 'section' => 'ppwp_pcp_form', 'settings' => 'ppwp_pcp_form_show_password_text', 'type' => 'text', 'priority' => 230, ) ); } /** * Append error message section. * * @param WP_Customize $wp_customize WP Customize class. */ public function append_err_msg_section( $wp_customize ) { /* form error message section */ $wp_customize->add_section( self::ERR_MSG_SECTION, array( 'title' => __( 'Error Message', 'password-protect-page' ), 'panel' => self::PANEL, 'priority' => 20, ) ); $wp_customize->add_setting( 'ppwp_pcp_err_msg_text', array( 'default' => PPW_Constants::DEFAULT_SHORTCODE_ERROR_MSG, ) ); $wp_customize->add_control( new PPW_Text_Editor_Custom_Control( $wp_customize, 'ppwp_pcp_err_msg_text', array( 'label' => __( 'Wrong Password Message', 'password-protect-page' ), 'section' => self::ERR_MSG_SECTION, 'settings' => 'ppwp_pcp_err_msg_text', 'type' => 'textarea', 'priority' => 10, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_err_msg_text_font_size', array( 'default' => PPW_Constants::DEFAULT_ERROR_TEXT_FONT_SIZE, ) ); $wp_customize->add_control( 'ppwp_pcp_err_msg_text_font_size_control', array( 'label' => __( 'Font Size', 'password-protect-page' ), 'description' => __( 'Font size in px', 'password-protect-page' ), 'section' => self::ERR_MSG_SECTION, 'settings' => 'ppwp_pcp_err_msg_text_font_size', 'type' => 'number', 'priority' => 20, ) ); $wp_customize->add_setting( 'ppwp_pcp_err_msg_text_font_weight', array( 'default' => PPW_Constants::DEFAULT_ERROR_TEXT_FONT_WEIGHT, ) ); $wp_customize->add_control( 'ppwp_pcp_err_msg_text_font_weight_control', array( 'label' => __( 'Font Weight', 'password-protect-page' ), 'section' => self::ERR_MSG_SECTION, 'settings' => 'ppwp_pcp_err_msg_text_font_weight', 'type' => 'number', 'priority' => 25, ) ); $wp_customize->add_setting( 'ppwp_pcp_err_msg_text_color', array( 'default' => PPW_Constants::DEFAULT_ERROR_TEXT_FONT_COLOR, ) ); $wp_customize->add_control( new \WP_Customize_Color_Control( $wp_customize, 'ppwp_pcp_err_msg_text_color_control', array( 'label' => __( 'Text Color', 'password-protect-page' ), 'section' => self::ERR_MSG_SECTION, 'settings' => 'ppwp_pcp_err_msg_text_color', 'priority' => 30, ) ) ); $wp_customize->add_setting( 'ppwp_pcp_err_msg_background_color', array( 'default' => '#ffffff', ) ); $wp_customize->add_control( new \WP_Customize_Color_Control( $wp_customize, 'ppwp_pcp_err_msg_background_color_control', array( 'label' => __( 'Background Color', 'password-protect-page' ), 'section' => self::ERR_MSG_SECTION, 'settings' => 'ppwp_pcp_err_msg_background_color', 'priority' => 35, ) ) ); } /** * Append button section. * * @param WP_Customize $wp_customize WP Customize class. */ public function append_button_section( $wp_customize ) { $wp_customize->add_section( self::BUTTON_SECTION, array( 'title' => __( 'Button', 'password-protect-page' ), 'panel' => self::PANEL, 'priority' => 300, ) ); $wp_customize->add_setting( 'ppwp_pcp_button_text', array( 'default' => PPW_Constants::DEFAULT_SHORTCODE_BUTTON, ) ); $wp_customize->add_control( 'ppwp_pcp_button_text_control', array( 'label' => __( 'Button Label', 'password-protect-page' ), 'section' => 'ppwp_pcp_button', 'settings' => 'ppwp_pcp_button_text', 'type' => 'text', ) ); $wp_customize->add_setting( 'ppwp_pcp_button_loading_text', array( 'default' => __( PPW_Constants::DEFAULT_SHORTCODE_LOADING, 'password-protect-page' ), ) ); $wp_customize->add_control( 'ppwp_pcp_button_loading_text_control', array( 'label' => __( 'Button Loading Label', 'password-protect-page' ), 'section' => 'ppwp_pcp_button', 'settings' => 'ppwp_pcp_button_loading_text', 'type' => 'text', ) ); $wp_customize->add_setting( 'ppwp_pcp_button_text_color', array( 'default' => PPW_Constants::DEFAULT_BUTTON_TEXT_FONT_COLOR, ) ); $wp_customize->add_control( new \WP_Customize_Color_Control( $wp_customize, 'ppwp_pcp_button_text_color_control', array( 'label' => __( 'Text Color', 'password-protect-page' ), 'section' => 'ppwp_pcp_button', 'settings' => 'ppwp_pcp_button_text_color', ) ) ); $wp_customize->add_setting( 'ppwp_pcp_button_text_hover_color', array( 'default' => PPW_Constants::DEFAULT_BUTTON_TEXT_HOVER_COLOR, ) ); $wp_customize->add_control( new \WP_Customize_Color_Control( $wp_customize, 'ppwp_pcp_button_text_hover_color_control', array( 'label' => __( 'Text Color (Hover)', 'password-protect-page' ), 'section' => 'ppwp_pcp_button', 'settings' => 'ppwp_pcp_button_text_hover_color', ) ) ); $wp_customize->add_setting( 'ppwp_pcp_button_background_color', array( 'default' => PPW_Constants::DEFAULT_BUTTON_BACKGROUND_COLOR, ) ); $wp_customize->add_control( new \WP_Customize_Color_Control( $wp_customize, 'ppwp_pcp_button_background_color_control', array( 'label' => __( 'Background Color', 'password-protect-page' ), 'section' => 'ppwp_pcp_button', 'settings' => 'ppwp_pcp_button_background_color', ) ) ); $wp_customize->add_setting( 'ppwp_pcp_button_background_hover_color', array( 'default' => PPW_Constants::DEFAULT_BUTTON_BACKGROUND_HOVER_COLOR, ) ); $wp_customize->add_control( new \WP_Customize_Color_Control( $wp_customize, 'ppwp_pcp_button_background_hover_color_control', array( 'label' => __( 'Background Color (Hover)', 'password-protect-page' ), 'section' => 'ppwp_pcp_button', 'settings' => 'ppwp_pcp_button_background_hover_color', ) ) ); } /** * Add dynamic styles * * @return void */ public function dynamic_styles() { $ppw_custom_css = " "; // compress $ppw_custom_css. $ppw_custom_css = preg_replace( "/\s{2,}/", " ", str_replace( "\n", "", str_replace( ', ', ",", $ppw_custom_css ) ) ); echo $ppw_custom_css; } /* * Optimize css. */ public function optimize_css( $sw_custom_css ) { return preg_replace( "/\s{2,}/", " ", str_replace( "\n", "", str_replace( ', ', ",", $sw_custom_css ) ) ); } } }