: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ( ! class_exists( 'PPW_Customizer_Sitewide' ) ) {
// TODO: need to force PPW_Pro_Customizer_Service extend this class to remove the code duplication.
class PPW_Customizer_Sitewide {
* Instance of PPW_Pro_Shortcode class.
* @var PPW_Customizer_Sitewide
protected static $instance = null;
public function register_sitewide_form() {
add_action( 'customize_register', array( $this, 'customize_register' ), 15 );
public static function register_themes() {
add_action( 'customize_register', array( $self, 'customize_register_themes' ), 25 );
add_action( 'ppw_custom_style_form_entire_site', array( $self, 'load_css_to_pro' ), 15 );
public function register_sitewide_style() {
add_action( PPW_Constants::HOOK_CUSTOM_STYLE_FORM_ENTIRE_SITE, array( $this, 'dynamic_styles' ) );
public function customize_register_themes( $wp_customize ) {
if ( ! class_exists( 'PPW_Presets_Control' ) ) {
include PPW_DIR_PATH . 'includes/customizers/class-ppw-presets.php';
$wp_customize->add_section( 'ppw_customize_presets', array(
'title' => __( 'Themes', PPW_Constants::DOMAIN ),
'panel' => 'ppwp_sitewide',
$wp_customize->add_setting( 'ppw_customize_presets_settings', array(
'capability' => 'edit_theme_options',
$wp_customize->add_control(
new PPW_Presets_Control( $wp_customize, 'ppw_customize_presets_settings',
'section' => 'ppw_customize_presets',
// 'label' => __( 'Themes', 'loginpress' ),
'choices' => $this->get_templates(),
* Get instance of PPW_Customizer
* @return PPW_Customizer_Sitewide
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();
* Register customizer fields
* @param object $wp_customize customizer object.
public function customize_register( $wp_customize ) {
if ( ! class_exists( 'PPW_Toggle_Control' ) ) {
include PPW_DIR_PATH . 'includes/customizers/class-ppw-title-group-control.php';
if ( ! class_exists( 'PPW_Title_Group_Control' ) ) {
include PPW_DIR_PATH . 'includes/customizers/class-ppw-toggle-control.php';
/* register toggle control */
$wp_customize->register_control_type( 'PPW_Toggle_Control' );
$wp_customize->register_control_type( 'PPW_Title_Group_Control' );
$wp_customize->add_panel( 'ppwp_sitewide',
'capability' => 'edit_theme_options',
'title' => __( 'PPWP Sitewide Login Form', PPW_Constants::DOMAIN ),
$wp_customize->add_section( 'ppwp_pro_form_logo', array(
'title' => __( 'Logo', PPW_Constants::DOMAIN ),
'panel' => 'ppwp_sitewide',
// Add an option to disable the logo.
$wp_customize->add_setting( 'ppwp_pro_logo_disable' );
$wp_customize->add_control(
'ppwp_pro_logo_disable_control', array(
'label' => __( 'Disable Logo', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_logo',
'settings' => 'ppwp_pro_logo_disable',
$wp_customize->add_setting( 'ppwp_pro_logo_customize', array(
'default' => __( PPW_DIR_URL . 'includes/views/entire-site/assets/ppwp-logo.png', PPW_Constants::DOMAIN ),
$wp_customize->add_control(
new \WP_Customize_Image_Control(
'ppwp_pro_logo_customize_control', array(
'label' => __( 'Logo Image', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_logo',
'settings' => 'ppwp_pro_logo_customize',
$wp_customize->add_setting( 'ppwp_pro_logo_customize_width' );
$wp_customize->add_control( 'ppwp_pro_logo_customize_width_control', array(
'label' => __( 'Logo Width', PPW_Constants::DOMAIN ),
'description' => __( 'Width in px', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_logo',
'settings' => 'ppwp_pro_logo_customize_width',
$wp_customize->add_setting( 'ppwp_pro_logo_customize_height' );
$wp_customize->add_control( 'ppwp_pro_logo_customize_height_control', array(
'label' => __( 'Logo Height', PPW_Constants::DOMAIN ),
'description' => __( 'Height in px', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_logo',
'settings' => 'ppwp_pro_logo_customize_height',
$wp_customize->add_setting( 'ppwp_pro_logo_customize_border_radius' );
$wp_customize->add_control( 'ppwp_pro_logo_customize_border_radius_control', array(
'label' => __( 'Logo Radius', PPW_Constants::DOMAIN ),
'description' => __( 'Border Radius in %', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_logo',
'settings' => 'ppwp_pro_logo_customize_border_radius',
/* password form section */
$wp_customize->add_section( 'ppwp_pro_form_instructions', array(
'title' => __( 'Password Form', PPW_Constants::DOMAIN ),
'panel' => 'ppwp_sitewide',
$wp_customize->add_setting( 'ppwp_pro_form_section_group' );
$wp_customize->add_control(
new PPW_Title_Group_Control(
'ppwp_pro_form_section_group', array(
'label' => __( 'Password Form', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_instructions',
'settings' => 'ppwp_pro_form_section_group',
'type' => 'control_title',
/* form countdown section */
apply_filters('ppwp_customizer_custom_fields', $wp_customize, $wp_customize);
/* enable form transparency */
$wp_customize->add_setting( 'ppwp_pro_form_enable_transparency' );
$wp_customize->add_control(
'ppwp_pro_form_enable_transparency_control', array(
'label' => __( 'Enable Form Transparency', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_instructions',
'settings' => 'ppwp_pro_form_enable_transparency',
/* password form background color */
$wp_customize->add_setting( 'ppwp_pro_form_instructions_background_color', array(
$wp_customize->add_control(
new \WP_Customize_Color_Control(
'ppwp_pro_form_instructions_background_color_control', array(
'label' => __( 'Form Background Color', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_instructions',
'settings' => 'ppwp_pro_form_instructions_background_color',
/* password form width */
$wp_customize->add_setting( 'ppwp_pro_form_instructions_width' );
$wp_customize->add_control( 'ppwp_pro_form_instructions_width_control', array(
'label' => __( 'Form Width', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_instructions',
'settings' => 'ppwp_pro_form_instructions_width',
'description' => 'Width in px',
/* password form border radius */
$wp_customize->add_setting( 'ppwp_pro_form_instructions_border_radius' );
$wp_customize->add_control( 'ppwp_pro_form_instructions_border_radius_control', array(
'label' => __( 'Form Border Radius', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_instructions',
'settings' => 'ppwp_pro_form_instructions_border_radius',
'description' => 'Border Radius in px',
/* password label group */
$wp_customize->add_setting( 'ppwp_pro_password_label_group' );
$wp_customize->add_control(
new PPW_Title_Group_Control(
'ppwp_pro_password_label_group', array(
'label' => __( 'Password Field', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_instructions',
'settings' => 'ppwp_pro_password_label_group',
'type' => 'control_title',
/* password label font size */
$wp_customize->add_setting( 'ppwp_pro_form_instructions_password_label_font_size' );
$wp_customize->add_control( 'ppwp_pro_form_instructions_password_label_font_size_control', array(
'label' => __( 'Font Size', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_instructions',
'settings' => 'ppwp_pro_form_instructions_password_label_font_size',
'description' => __( 'Font size in px', PPW_Constants::DOMAIN ),
/* password label color */
$wp_customize->add_setting( 'ppwp_pro_form_instructions_password_label_color' );
$wp_customize->add_control(
new \WP_Customize_Color_Control(
'ppwp_pro_form_instructions_password_label_color_control', array(
'label' => __( 'Label Color', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_instructions',
'settings' => 'ppwp_pro_form_instructions_password_label_color',
$wp_customize->add_setting( 'ppwp_pro_form_instructions_placeholder' );
$wp_customize->add_control( 'ppwp_pro_form_instructions_placeholder_control', array(
'label' => __( 'Placeholder', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_instructions',
'settings' => 'ppwp_pro_form_instructions_placeholder',
/* form button section */
$wp_customize->add_section( 'ppwp_pro_form_button', array(
'title' => __( 'Button', PPW_Constants::DOMAIN ),
'panel' => 'ppwp_sitewide',
$wp_customize->add_setting( 'ppwp_pro_form_button_label', array(
'default' => __( 'Enter', PPW_Constants::DOMAIN ),
$wp_customize->add_control( 'ppwp_pro_form_button_label_control', array(
'label' => __( 'Button Label', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_button',
'settings' => 'ppwp_pro_form_button_label',
$wp_customize->add_setting( 'ppwp_pro_form_button_text_color' );
$wp_customize->add_control(
new \WP_Customize_Color_Control(
'ppwp_pro_form_button_text_color_control', array(
'label' => __( 'Text Color', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_button',
'settings' => 'ppwp_pro_form_button_text_color',
/* button background color */
$wp_customize->add_setting( 'ppwp_pro_form_button_background_color' );
$wp_customize->add_control(
new \WP_Customize_Color_Control(
'ppwp_pro_form_button_background_color_control', array(
'label' => __( 'Background Color', PPW_Constants::DOMAIN ),
'section' => 'ppwp_pro_form_button',
'settings' => 'ppwp_pro_form_button_background_color',
* TODO: move this styles into css file.
public function dynamic_styles() {
$sw_custom_css = $this->get_preset_css();
$sw_custom_css = $sw_custom_css . '
width: ' . esc_attr( get_theme_mod( 'ppwp_pro_form_instructions_width' ) ) . 'px!important;
font-size: ' . esc_attr( get_theme_mod( 'ppwp_pro_form_instructions_password_label_font_size' ) ) . 'px!important;
color: ' . esc_attr( get_theme_mod( 'ppwp_pro_form_instructions_password_label_color' ) ) . '!important;
background-color: ' . esc_attr( get_theme_mod( 'ppwp_pro_form_instructions_background_color' ) ) . '!important;
border-radius: ' . esc_attr( get_theme_mod( 'ppwp_pro_form_instructions_border_radius' ) ) . 'px!important;
.pda-form-login a.ppw-swp-logo {
background-image: none, url(' . esc_url( get_theme_mod( 'ppwp_pro_logo_customize', PPW_DIR_URL . 'includes/views/entire-site/assets/ppwp-logo.png' ) ) . ')!important;
width: ' . esc_attr( get_theme_mod( 'ppwp_pro_logo_customize_width', '' ) ) . 'px!important;
height: ' . esc_attr( get_theme_mod( 'ppwp_pro_logo_customize_height', '' ) ) . 'px!important;
border-radius: ' . esc_attr( get_theme_mod( 'ppwp_pro_logo_customize_border_radius', '' ) ) . '%!important;
.pda-form-login .button-login {
color: ' . esc_attr( get_theme_mod( 'ppwp_pro_form_button_text_color' ) ) . '!important;
background-color: ' . esc_attr( get_theme_mod( 'ppwp_pro_form_button_background_color' ) ) . '!important;
border-color: ' . esc_attr( get_theme_mod( 'ppwp_pro_form_button_background_color' ) ) . '!important;
// remove space in $sw_custom_css.
$sw_custom_css = $this->optimize_css( $sw_custom_css );
echo $sw_custom_css; // phpcs:ignore -- we already escase inside the css
public function optimize_css( $sw_custom_css ) {
return preg_replace( "/\s{2,}/", " ", str_replace( "\n", "", str_replace( ', ', ",", $sw_custom_css ) ) );
public function get_templates() {
$free_templates = array();
__( 'Default', PPW_Constants::DOMAIN ),
__( 'Event', PPW_Constants::DOMAIN ),
__( 'Business', PPW_Constants::DOMAIN ),
__( 'Wedding', PPW_Constants::DOMAIN ),
foreach ( $themes_name as $index => $theme_name ) {
$free_templates["default{$index}"] = array(
'thumbnail' => PPW_DIR_URL . 'includes/customizers/assets/images/thumbnail/sw-default' . $index . '.png',
'id' => "default{$index}",
'css_file' => PPW_DIR_PATH . 'includes/customizers/assets/css/sw-default' . $index . '.php',
return apply_filters( 'ppw_customizer_sitewide_templates', $free_templates );
public function get_preset_css() {
$default_preset = 'default0';
$preset = esc_attr( get_theme_mod( 'ppw_customize_presets_settings', $default_preset ) );
if ( $preset !== $default_preset ) {
$templates = $this->get_templates();
if ( isset( $templates[ $preset ], $templates[ $preset ]['css_file'] ) ) {
include_once( $templates[ $preset ]['css_file'] );
@media screen and (max-width: 768px) {
$sw_custom_css = ob_get_clean();
public function load_css_to_pro() {
echo $this->optimize_css( $this->get_preset_css() ); // phpcs:ignores -- we don't need to escape css, already escape $preset above