_accept_btn_state1', 'value' => 'hover', 'operator' => '==', ), ), 'wfocu_transport' => array( array( 'type' => 'css', 'hover' => true, 'prop' => array( 'background-color' ), 'elem' => '.wfocu-sidebar-cart .wfocu-mc-button', ), ), ), 'yes_btn_hover_color_text' => array( 'label' => __( 'Text Color', 'woofunnels-upstroke-one-click-upsell' ), 'type' => 'color', 'default' => $get_defaults['offer_yes_btn_txt_cl_h'], 'priority' => 100, 'active_callback' => array( array( 'setting' => 'wfocu_offer_confirmation_offer_confirmation_ct_accept_btn_state1', 'value' => 'hover', 'operator' => '==', ), ), 'transport' => 'postMessage', 'wfocu_transport' => array( array( 'type' => 'css', 'hover' => true, 'prop' => array( 'color' ), 'elem' => '.wfocu-sidebar-cart .wfocu-mc-button', ), ), ), 'yes_btn_hover_shadow_color' => array( 'label' => __( 'Shadow Color', 'woofunnels-upstroke-one-click-upsell' ), 'type' => 'color', 'default' => $get_defaults['offer_yes_btn_sh_cl_h'], 'priority' => 110, 'transport' => 'postMessage', 'active_callback' => array( array( 'setting' => 'wfocu_offer_confirmation_offer_confirmation_ct_accept_btn_state1', 'value' => 'hover', 'operator' => '==', ), ), 'wfocu_transport' => array( array( 'hover' => true, 'type' => 'css', 'prop' => array( 'box-shadow', '-moz-box-shadow', '-webkit-box-shadow', '-ms-box-shadow', '-o-box-shadow' ), 'prefix' => '0px 4px 0px ', 'elem' => '.wfocu-sidebar-cart .wfocu-mc-button', ), ), ), /**** YES BUTTON COLOR SETTINGS ENDS */ /**** NO BUTTON COLOR SETTINGS STARTS */ 'ct_colors3' => array( 'type' => 'custom', 'default' => '
' . esc_html__( 'Decline Offer Colors', 'woofunnels-upstroke-one-click-upsell' ) . '
', 'priority' => 120, ), 'ct_accept_btn_state2' => array( 'type' => 'radio-buttonset', 'label' => '', 'default' => 'normal', 'choices' => array( 'normal' => __( 'Normal', 'woofunnels-upstroke-one-click-upsell' ), 'hover' => __( 'Hover', 'woofunnels-upstroke-one-click-upsell' ), ), 'transport' => 'postMessage', 'priority' => 130, ), 'no_btn_color' => array( 'label' => __( 'Text Color', 'woofunnels-upstroke-one-click-upsell' ), 'type' => 'color', 'default' => $get_defaults['offer_no_btn_txt_cl'], 'priority' => 140, 'transport' => 'postMessage', 'active_callback' => array( array( 'setting' => 'wfocu_offer_confirmation_offer_confirmation_ct_accept_btn_state2', 'value' => 'normal', 'operator' => '==', ), ), 'wfocu_transport' => array( array( 'type' => 'css', 'prop' => array( 'color' ), 'elem' => '.wfocu-sidebar-cart .wfocu-mc-footer-btm-text a', 'internal' => true, ), ), ), 'no_btn_color_hover' => array( 'label' => __( 'Text Color', 'woofunnels-upstroke-one-click-upsell' ), 'type' => 'color', 'default' => $get_defaults['offer_no_btn_txt_cl_h'], 'priority' => 150, 'transport' => 'postMessage', 'active_callback' => array( array( 'setting' => 'wfocu_offer_confirmation_offer_confirmation_ct_accept_btn_state2', 'value' => 'hover', 'operator' => '==', ), ), 'wfocu_transport' => array( array( 'hover' => true, 'type' => 'css', 'prop' => array( 'color' ), 'elem' => '.wfocu-sidebar-cart .wfocu-mc-footer-btm-text a', ), ), ), /**** NO BUTTON COLOR SETTINGS ENDS */ 'ct_cart_opener' => array( 'type' => 'custom', 'default' => '
' . esc_html__( 'Offer Confirmation Opener', 'woofunnels-upstroke-one-click-upsell' ) . '
', 'priority' => 160, ), 'ct_cart_opener_desc' => array( 'type' => 'custom', 'default' => '', 'description' => esc_attr__( 'This element will only display after user closes Offer Confirmation.', 'woofunnels-upstroke-one-click-upsell' ), 'priority' => 170, ), 'cart_opener_text' => array( 'type' => 'text', 'label' => __( 'Text', 'woofunnels-upstroke-one-click-upsell' ), 'default' => $get_defaults['cart_opener_text'], 'transport' => 'postMessage', 'wfocu_transport' => array( array( 'type' => 'html', 'elem' => '.wfocu-confirm-order-btn .wfocu-opener-btn-bg', ), ), 'priority' => 180, ), 'cart_opener_color' => array( 'type' => 'color', 'label' => __( 'Background Color', 'woofunnels-upstroke-one-click-upsell' ), 'default' => $get_defaults['cart_opener_background_color'], 'transport' => 'postMessage', 'wfocu_transport' => array( array( 'type' => 'css', 'prop' => array( 'background-color' ), 'elem' => '.wfocu-confirm-order-btn .wfocu-opener-btn-bg', ), array( 'type' => 'css', 'prop' => array( 'border-right-color' ), 'elem' => '.wfocu-confirm-order-btn .wfocu-left-arrow', ), ), 'priority' => 190, ), 'cart_opener_text_color' => array( 'type' => 'color', 'label' => __( 'Text Color', 'woofunnels-upstroke-one-click-upsell' ), 'default' => $get_defaults['cart_opener_text_color'], 'transport' => 'postMessage', 'wfocu_transport' => array( array( 'type' => 'css', 'prop' => array( 'color' ), 'elem' => '.wfocu-confirm-order-btn', ), ), 'priority' => 200, ), ), ), ), ); $customizer_data[] = $offer_confirmation_panel; return $customizer_data; } /** * @return null */ public function get_template_instance() { return $this->template_ins; } public function maybe_update_customize_save() { if ( 0 !== $this->offer_id ) { update_post_meta( $this->offer_id, '_wfocu_edit_last', time() ); } } public function mark_changsets_as_dismissed( $post_id, $post ) { if ( ! $post instanceof WP_Post ) { return; } if ( 'customize_changeset' === $post->post_type ) { update_post_meta( $post_id, '_customize_restore_dismissed', true ); } } public function dequeue_unnecessary_customizer_scripts() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended,FunnelBuilder.CodeAnalysis.FunnelBuilderSpecific.MissingCapabilityCheck -- Customizer preview parameter detection if ( isset( $_REQUEST['wfocu_customize'] ) && $_REQUEST['wfocu_customize'] === 'loaded' && isset( $_REQUEST['offer_id'] ) && $_REQUEST['offer_id'] > 0 ) { /** * wp-titan framework add these color pickers, that breaks our customizer page */ wp_deregister_script( 'wp-color-picker-alpha' ); wp_dequeue_script( 'wp-color-picker-alpha' ); } } public function customizer_product_check() { if ( WFOCU_Core()->template_loader->is_valid_state_for_data_setup() ) { $variation_field = true; $offer_data = WFOCU_Core()->template_loader->product_data; // product_data is null when the offer's configured products were deleted permanently; // fall back to an empty set so we hit the "no products" branch below instead of fataling. $temp_product = ( is_object( $offer_data ) && isset( $offer_data->products ) && is_object( $offer_data->products ) ) ? get_object_vars( $offer_data->products ) : array(); if ( is_array( $temp_product ) && count( $temp_product ) > 0 ) { /** Checking for variation single product */ if ( is_array( $temp_product ) && count( $temp_product ) > 1 ) { $variation_field = false; } else { /** Only 1 product */ foreach ( $offer_data->products as $hash_key => $product ) { if ( isset( $product->id ) && $product->id > 0 ) { $product_obj = wc_get_product( $product->id ); if ( ! empty( WFOCU_Core()->template_loader->current_template ) ) { WFOCU_Core()->template_loader->current_template->products_data[ $hash_key ] = array( 'id' => $product->id, 'obj' => $product_obj, ); } /** Checking if product variation and single product */ $product_type = $product_obj->get_type(); if ( ! in_array( $product_type, WFOCU_Common::get_variable_league_product_types(), true ) ) { $variation_field = false; } } } } } elseif ( WFOCU_Core()->template_loader->is_customizer_preview() ) { wp_die( esc_attr__( 'Your offer must have at least one product to show preview.', 'woofunnels-upstroke-one-click-upsell' ) ); } if ( ! empty( WFOCU_Core()->template_loader->current_template ) ) { WFOCU_Core()->template_loader->current_template->variation_field = $variation_field; } } } public function setup_offer_for_wfocukirki() { if ( true === WFOCU_Core()->template_loader->is_customizer_preview() ) { add_action( 'customize_preview_init', array( WFOCU_Core()->template_loader, 'maybe_add_customize_preview_init' ) ); /** wp customizer scripts and styles */ add_action( 'wfocu_header_print_in_head', array( WFOCU_Core()->template_loader, 'load_customizer_styles' ) ); add_action( 'wfocu_footer_before_print_scripts', array( WFOCU_Core()->template_loader, 'load_customizer_footer_before_scripts' ) ); } WFOCU_Core()->template_loader->customizer_key_prefix = WFOCU_SLUG . '_c_' . WFOCU_Core()->template_loader->offer_id; /** Set customizer key prefix in common */ WFOCU_Common::$customizer_key_prefix = WFOCU_Core()->template_loader->customizer_key_prefix; /** wfocukirki */ if ( class_exists( 'WFOCUKirki' ) ) { WFOCUKirki::add_config( WFOCU_SLUG, array( 'option_type' => 'option', 'option_name' => WFOCU_Core()->template_loader->customizer_key_prefix, ) ); } } public function wfocu_wfocukirki_configuration( $path ) { if ( WFOCU_Core()->template_loader->is_valid_state_for_data_setup() ) { return array( 'url_path' => WFOCU_PLUGIN_URL . '/admin/includes/wfocukirki/', ); } return $path; } public function wfocu_wfocukirki_fields() { $temp_ins = WFOCU_Core()->template_loader->get_template_ins(); /** if ! customizer */ if ( ! WFOCU_Core()->template_loader->is_customizer_preview() ) { return; } if ( $temp_ins instanceof WFOCU_Customizer_Common && is_array( $temp_ins->customizer_data ) && count( $temp_ins->customizer_data ) > 0 ) { foreach ( $temp_ins->customizer_data as $panel_single ) { /** Panel */ foreach ( $panel_single as $panel_key => $panel_arr ) { /** Section */ if ( is_array( $panel_arr['sections'] ) && count( $panel_arr['sections'] ) > 0 ) { foreach ( $panel_arr['sections'] as $section_key => $section_arr ) { $section_key_final = $panel_key . '_' . $section_key; /** Fields */ if ( is_array( $section_arr['fields'] ) && count( $section_arr['fields'] ) > 0 ) { foreach ( $section_arr['fields'] as $field_key => $field_data ) { $field_key_final = $section_key_final . '_' . $field_key; $field_data = array_merge( $field_data, array( 'settings' => $field_key_final, 'section' => $section_key_final, ) ); /** unset wfocu_partial key if present as not required for wfocukirki */ if ( isset( $field_data['wfocu_partial'] ) ) { unset( $field_data['wfocu_partial'] ); } WFOCUKirki::add_field( WFOCU_SLUG, $field_data ); /** Setting fields: type and element class for live preview */ if ( isset( $field_data['wfocu_transport'] ) && is_array( $field_data['wfocu_transport'] ) ) { $field_key_final = WFOCU_Core()->template_loader->customizer_key_prefix . '[' . $field_key_final . ']'; $temp_ins->fields[ $field_key_final ] = $field_data['wfocu_transport']; } } } } } } } } } public function maybe_add_customizer_multiple_templates( $customizer_templates ) { if ( defined( 'WFOCU_MP_VERSION' ) && version_compare( WFOCU_MP_VERSION, '1.1.0', '<=' ) ) { return array_merge( $customizer_templates, array( 'mp-grid', 'mp-list' ) ); } return $customizer_templates; } } if ( class_exists( 'WFOCU_Core' ) ) { WFOCU_Core::register( 'customizer', 'WFOCU_Customizer' ); } }