: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ( ! class_exists( 'PPW_Customizer_PCP' ) ) {
class PPW_Customizer_PCP {
* Instance of PPW_Pro_Shortcode class.
* @var PPW_Customizer_PCP
protected static $instance = null;
const PANEL = 'ppwp_pcp';
const GENERAL_SECTION = 'ppwp_pcp_form';
const FORM_SECTION = 'ppwp_pcp_form';
const ERR_MSG_SECTION = 'ppwp_pcp_err_msg';
const BUTTON_SECTION = 'ppwp_pcp_button';
* Get instance of PPW_Customizer
* @return PPW_Customizer_PCP
public static function get_instance() {
if ( is_null( self::$instance ) ) {
// Use static instead of self due to the inheritance later.
// For example: ChildSC extends this class, when we call get_instance
// it will return the object of child class. On the other hand, self function
// will return the object of base class.
self::$instance = new static();
public function register() {
add_action( 'customize_register', array( $this, 'customize_register' ), 15 );
add_action( 'wp_head', array( $this, 'dynamic_styles' ) );
add_filter( 'ppw_pcp_attributes', array( $this, 'load_customizer_attributes' ) );
add_filter( 'ppw_validated_pcp_password', array( $this, 'load_customizer_err_msg' ), 10, 3 );
* Load customizer attributes.
* @param array $attrs Attributes
public function load_customizer_attributes( $attrs ) {
$attrs['headline'] = get_theme_mod( 'ppwp_pcp_form_headline', PPW_Constants::DEFAULT_SHORTCODE_HEADLINE );
$attrs['description'] = get_theme_mod( 'ppwp_pcp_form_description', PPW_Constants::DEFAULT_SHORTCODE_DESCRIPTION );
$attrs['label'] = get_theme_mod( 'ppwp_pcp_form_label', PPW_Constants::DEFAULT_SHORTCODE_LABEL );
$attrs['placeholder'] = get_theme_mod( 'ppwp_pcp_form_placeholder', '' );
$attrs['error_msg'] = get_theme_mod( 'ppwp_pcp_err_msg_text', PPW_Constants::DEFAULT_SHORTCODE_ERROR_MSG );
$attrs['button'] = get_theme_mod( 'ppwp_pcp_button_text', PPW_Constants::DEFAULT_SHORTCODE_BUTTON );
$attrs['loading'] = get_theme_mod( 'ppwp_pcp_button_loading_text', PPW_Constants::DEFAULT_SHORTCODE_LOADING );
$attrs['show_password'] = get_theme_mod( 'ppwp_pcp_form_is_show_password', PPW_Constants::DEFAULT_SHORTCODE_SHOW_PASSWORD );
$attrs['show_password_text'] = get_theme_mod( 'ppwp_pcp_form_show_password_text', PPW_Constants::DEFAULT_SHORTCODE_SHOW_PASSWORD_TEXT );
// $attrs['desc_above_btn'] = get_theme_mod( 'ppwp_pcp_description_above_btn', PPW_Constants::DEFAULT_SHORTCODE_DESC_ABOVE_PWD_BTN );
$attrs['desc_below_form'] = get_theme_mod( 'ppwp_pcp_description_below_form', PPW_Constants::DEFAULT_SHORTCODE_DESC_BELOW_PWD_FORM );
* Load customizer error message.
* @param array $attrs Attributes.
* @param string $password Password.
* @param array $parsed_attrs Parsed attributes.
public function load_customizer_err_msg( $attrs, $password, $parsed_attrs ) {
if ( isset( $parsed_attrs['error_msg'] ) ) {
if ( isset( $attrs['is_valid_password'] ) && ! $attrs['is_valid_password'] ) {
$attrs['message'] = get_theme_mod( 'ppwp_pcp_err_msg_text', PPW_Constants::DEFAULT_SHORTCODE_ERROR_MSG );
* @param WP_Customize $wp_customize WP Customize class.
public function customize_register( $wp_customize ) {
if ( ! class_exists( 'PPW_Title_Group_Control' ) ) {
include PPW_DIR_PATH . 'includes/customizers/class-ppw-title-group-control.php';
if ( ! class_exists( 'PPW_Toggle_Control' ) ) {
include PPW_DIR_PATH . 'includes/customizers/class-ppw-toggle-control.php';
if ( ! class_exists( 'PPW_Text_Editor_Custom_Control' ) ) {
include PPW_DIR_PATH . 'includes/customizers/class-ppw-text-editor-control.php';
$wp_customize->add_panel(
'capability' => 'edit_theme_options',
'title' => __( 'PPWP Partial Protection Form', PPW_Constants::DOMAIN ),
$this->append_form_section( $wp_customize );
$this->append_err_msg_section( $wp_customize );
$this->append_button_section( $wp_customize );
* @param WP_Customize $wp_customize WP Customize class.
public function append_form_section( $wp_customize ) {
$wp_customize->add_section(
'title' => __( 'Password Form', PPW_Constants::DOMAIN ),
$wp_customize->add_setting( 'ppwp_pcp_form_background_title' );
$wp_customize->add_control(
new PPW_Title_Group_Control(
'ppwp_pcp_form_background_title', array(
'label' => __( 'Background', PPW_Constants::DOMAIN ),
'section' => self::FORM_SECTION,
'settings' => 'ppwp_pcp_form_background_title',
'type' => 'control_title',
$wp_customize->add_setting( 'ppwp_pcp_form_background_color' );
$wp_customize->add_control(
new WP_Customize_Color_Control(
'ppwp_pcp_form_background_color_control',
'label' => __( 'Form Background Color', PPW_Constants::DOMAIN ),
'section' => self::FORM_SECTION,
'settings' => 'ppwp_pcp_form_background_color',
$wp_customize->add_setting( 'ppwp_pcp_form_padding' );
$wp_customize->add_control(
'ppwp_pcp_form_padding_control',
'label' => __( 'Padding', PPW_Constants::DOMAIN ),
'description' => __( 'Padding in px', PPW_Constants::DOMAIN ),
'section' => self::FORM_SECTION,
'settings' => 'ppwp_pcp_form_padding',
/* 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', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'description' => 'Border Radius in px',
'settings' => 'ppwp_pcp_form_border_radius',
$wp_customize->add_setting( 'ppwp_pcp_form_headline_title' );
$wp_customize->add_control(
new PPW_Title_Group_Control(
'ppwp_pcp_form_headline_title', array(
'label' => __( 'Headline', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'settings' => 'ppwp_pcp_form_headline_title',
'type' => 'control_title',
$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(
'ppwp_pcp_form_headline',
'label' => __( 'Headline', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'settings' => 'ppwp_pcp_form_headline',
$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', PPW_Constants::DOMAIN ),
'description' => __( 'Font size in px', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'settings' => 'ppwp_pcp_form_headline_font_size',
$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', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'settings' => 'ppwp_pcp_form_headline_font_weight',
$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(
'ppwp_pcp_form_headline_color_control', array(
'label' => __( 'Text Color', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'settings' => 'ppwp_pcp_form_headline_color',
$wp_customize->add_setting( 'ppwp_pcp_form_description_title' );
$wp_customize->add_control(
new PPW_Title_Group_Control(
'ppwp_pcp_form_description_title', array(
'label' => __( 'Description Above Form', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'settings' => 'ppwp_pcp_form_description_title',
'type' => 'control_title',
$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(
'ppwp_pcp_form_description',
'label' => __( 'Description', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'settings' => 'ppwp_pcp_form_description',
$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', PPW_Constants::DOMAIN ),
'description' => __( 'Font size in px', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'settings' => 'ppwp_pcp_form_description_font_size',
$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', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'settings' => 'ppwp_pcp_form_description_font_weight',
$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(
'ppwp_pcp_form_description_color_control', array(
'label' => __( 'Text Color', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'settings' => 'ppwp_pcp_form_description_color',
$wp_customize->add_setting( 'ppwp_pcp_form_desc_title' );
$wp_customize->add_control(
new PPW_Title_Group_Control(
'ppwp_pcp_form_desc_title',
'label' => __( 'Description Below Form', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pcp_form',
'settings' => 'ppwp_pcp_form_desc_title',
'type' => 'control_title',
$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(
'ppwp_pcp_description_below_form', array(
'label' => __( 'Description', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'settings' => 'ppwp_pcp_description_below_form',
$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', PPW_Constants::DOMAIN ),
'description' => __( 'Font size in px', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'settings' => 'ppwp_pcp_form_description_below_form_font_size',
$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', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'settings' => 'ppwp_pcp_form_description_below_form_font_weight',
$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(
'ppwp_pcp_form_description_below_form_color_control', array(
'label' => __( 'Text Color', PPW_Constants::DOMAIN ),
'section' => self::GENERAL_SECTION,
'settings' => 'ppwp_pcp_form_description_below_form_color',
// $wp_customize->add_setting( 'ppwp_pcp_desc_above_btn' );
// $wp_customize->add_control(
// new PPW_Title_Group_Control(
// 'ppwp_pcp_desc_above_btn',
// 'label' => __( 'Description Above Button', PPW_Constants::DOMAIN ),
// 'section' => 'ppwp_pcp_form',
// 'settings' => 'ppwp_pcp_desc_above_btn',
// 'type' => 'control_title',
// $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(
// 'ppwp_pcp_description_above_btn',
// 'label' => __( 'Description', PPW_Constants::DOMAIN ),
// 'section' => self::GENERAL_SECTION,
// 'settings' => 'ppwp_pcp_description_above_btn',
// $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', PPW_Constants::DOMAIN ),
// 'description' => __( 'Font size in px', PPW_Constants::DOMAIN ),
// 'section' => self::GENERAL_SECTION,
// 'settings' => 'ppwp_pcp_form_description_above_btn_font_size',
// $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', PPW_Constants::DOMAIN ),
// 'section' => self::GENERAL_SECTION,
// 'settings' => 'ppwp_pcp_form_description_above_btn_font_weight',
// $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(
// 'ppwp_pcp_form_description_above_btn_color_control', array(
// 'label' => __( 'Text Color', PPW_Constants::DOMAIN ),
// 'section' => self::GENERAL_SECTION,
// 'settings' => 'ppwp_pcp_form_description_above_btn_color',
$wp_customize->add_setting( 'ppwp_pcp_form_label_title' );
$wp_customize->add_control(
new PPW_Title_Group_Control(
'ppwp_pcp_form_label_title',
'label' => __( 'Password Field', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pcp_form',
'settings' => 'ppwp_pcp_form_label_title',
'type' => 'control_title',
$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', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pcp_form',
'settings' => 'ppwp_pcp_form_label',
$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', PPW_Constants::DOMAIN ),
'description' => __( 'Font size in px', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pcp_form',
'settings' => 'ppwp_pcp_form_label_font_size',
$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', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pcp_form',
'settings' => 'ppwp_pcp_form_label_font_weight',