'https://aio.divipeople.com', 'author' => 'DiviPeople', 'author_uri' => 'https://divipeople.com', ); public function init() { $this->name = esc_html__( ' AiO - Contact Form 7', 'daio' ); $this->icon_path = plugin_dir_path( __FILE__ ) . 'cf7.svg'; $this->main_css_element = '%%order_class%%.daio_cf7_styler'; $this->settings_modal_toggles = array( 'general' => array( 'toggles' => array( 'general' => esc_html__( 'General', 'daio' ), ), ), 'advanced' => array( 'toggles' => array( 'form_field' => esc_html__( 'Form Fields', 'daio' ), 'labels' => esc_html__( 'Labels', 'daio' ), 'radio_checkbox' => esc_html__( 'Radio & Checkbox', 'daio' ), 'submit_button' => esc_html__( 'Submit Button', 'daio' ), 'suc_err_msg' => esc_html__( 'Success / Error Message', 'daio' ), ), ), ); $this->custom_css_fields = array( 'cf7_fields' => array( 'label' => esc_html__( 'Form Fields', 'daio' ), 'selector' => '%%order_class%% .daio-cf7-styler input', ), 'cf7_labels' => array( 'label' => esc_html__( 'Form Labels', 'daio' ), 'selector' => '%%order_class%% .daio-cf7-styler label', ), ); } /** * Contact form 7 */ public static function select_wpcf7() { if ( function_exists( 'wpcf7' ) ) { $options = array(); $args = array( 'post_type' => 'wpcf7_contact_form', 'posts_per_page' => -1 ); $contact_forms = get_posts( $args ); if ( ! empty( $contact_forms ) && ! is_wp_error( $contact_forms ) ) { $i = 0; foreach ( $contact_forms as $post ) { if ( $i == 0 ) { (int)$options[0] = esc_html__( 'Select a Contact form', 'daio' ); } (int)$options[ $post->ID ] = $post->post_title; $i++; } } } else { $options = array(); } return $options; } /** * Get Fields */ public function get_fields() { return array( 'cf7' => array( 'label' => esc_html__( 'Select Form', 'daio' ), 'type' => 'select', 'option_category' => 'layout', 'options' => self::select_wpcf7(), 'description' => esc_html__( 'Choose a contact form to display.', 'daio' ), 'computed_affects' => array( '__cf7form', ), 'toggle_slug' => 'general', ), 'form_background_color' => array( 'label' => esc_html__( 'Form Field Background Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'default' => '#f5f5f5', 'toggle_slug' => 'form_field', 'tab_slug' => 'advanced', ), 'form_field_active_color' => array( 'label' => esc_html__( 'Form Field Active Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'form_field', ), 'cf7_cr_size' => array( 'label' => esc_html__( 'Size', 'daio' ), 'type' => 'range', 'option_category' => 'layout', 'tab_slug' => 'advanced', 'toggle_slug' => 'radio_checkbox', 'default_unit' => 'px', 'default' => '20', 'range_settings' => array( 'min' => '1', 'max' => '50', 'step' => '1', ), ), 'cf7_cr_background_color' => array( 'label' => esc_html__( 'Background Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'radio_checkbox', ), 'cf7_cr_selected_color' => array( 'label' => esc_html__( 'Selected Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'default' => '#222222', 'tab_slug' => 'advanced', 'toggle_slug' => 'radio_checkbox', ), 'cf7_cr_border_color' => array( 'label' => esc_html__( 'Border Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'default' => '#222222', 'toggle_slug' => 'radio_checkbox', 'tab_slug' => 'advanced', ), 'cf7_cr_border_size' => array( 'label' => esc_html__( 'Border Size', 'daio' ), 'type' => 'range', 'option_category' => 'layout', 'tab_slug' => 'advanced', 'toggle_slug' => 'radio_checkbox', 'default_unit' => 'px', 'default' => '1', 'range_settings' => array( 'min' => '1', 'max' => '5', 'step' => '1', ), ), 'cf7_cr_label_color' => array( 'label' => esc_html__( 'Label Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'radio_checkbox', ), // Success or Error Message 'cf7_message_color' => array( 'label' => esc_html__( 'Message Text Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'suc_err_msg', ), 'cf7_message_bg_color' => array( 'label' => esc_html__( 'Message Background Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'suc_err_msg', ), 'cf7_border_highlight_color' => array( 'label' => esc_html__( 'Border Highlight Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'suc_err_msg', ), // Success 'cf7_success_message_color' => array( 'label' => esc_html__( 'Success Message Text Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'suc_err_msg', ), 'cf7_success_message_bg_color' => array( 'label' => esc_html__( 'Success Message Background Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'suc_err_msg', ), 'cf7_success_border_color' => array( 'label' => esc_html__( 'Success Border Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'suc_err_msg', ), // Error 'cf7_error_message_color' => array( 'label' => esc_html__( 'Error Message Text Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'suc_err_msg', ), 'cf7_error_message_bg_color' => array( 'label' => esc_html__( 'Error Message Background Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'suc_err_msg', ), 'cf7_error_border_color' => array( 'label' => esc_html__( 'Error Border Color', 'daio' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'suc_err_msg', ), 'cf7_message_padding' => array( 'label' => esc_html__( 'Message Padding', 'daio' ), 'type' => 'range', 'option_category' => 'layout', 'tab_slug' => 'advanced', 'toggle_slug' => 'suc_err_msg', 'default_unit' => 'px', 'default' => '0', 'range_settings' => array( 'min' => '1', 'max' => '50', 'step' => '1', ), ), 'cf7_message_margin_top' => array( 'label' => esc_html__( 'Message Margin Top', 'daio' ), 'type' => 'range', 'option_category' => 'layout', 'tab_slug' => 'advanced', 'toggle_slug' => 'suc_err_msg', 'default_unit' => 'px', 'default' => '0', 'range_settings' => array( 'min' => '1', 'max' => '50', 'step' => '1', ), ), /** * Computed */ '__cf7form' => array( 'type' => 'computed', 'computed_callback' => array( 'Daio_CfStyler', 'get_cf7_shortcode_html' ), 'computed_depends_on' => array( 'cf7', ), ), ); } /** * Config Advanced Fields */ public function get_advanced_fields_config() { $advanced_fields = array(); /** * Fonts ( Labels, Placeholer) */ $advanced_fields['fonts'] = false; $advanced_fields['text'] = false; $advanced_fields['text_shadow'] = false; $advanced_fields['fonts']['form_field_font'] = array( 'label' => esc_html__( 'Field', 'daio'), 'css' => array( 'main' => implode( ', ', array( "{$this->main_css_element} .daio-cf7 .wpcf7 input:not([type=submit])", "{$this->main_css_element} .daio-cf7 .wpcf7 input::placeholder", "{$this->main_css_element} .daio-cf7 .wpcf7 select", "{$this->main_css_element} .daio-cf7 .wpcf7 textarea", "{$this->main_css_element} .daio-cf7 .wpcf7 textarea::placeholder", ) ), 'important' => array( 'font', 'size', 'letter-spacing', 'line-height', 'text-align', 'all_caps', ), ), 'toggle_slug' => 'form_field', ); $advanced_fields['fonts']['labels'] = array( 'label' => esc_html__( 'Label', 'daio'), 'css' => array( 'main' => "{$this->main_css_element} .daio-cf7 .wpcf7 label", 'important' => 'all' ), 'toggle_slug' => 'labels', ); $advanced_fields['button']['submit_button'] = array( 'label' => esc_html__( 'Submit Button', 'daio' ), 'css' => array( 'main' => implode( ', ', array( "{$this->main_css_element} .daio-cf7 .wpcf7 input[type=submit]", ) ), ), 'no_rel_attr' => true, 'box_shadow' => array( 'css' => array( 'main' => implode( ', ', array( "{$this->main_css_element} .daio-cf7 .wpcf7 input[type=submit]", ) ), 'important' => true, ), ), ); $advanced_fields['borders']['default'] = array(); $advanced_fields['borders']['field'] = array( 'label_prefix' => esc_html__( 'Field', 'daio' ), 'toggle_slug' => 'form_field', 'css' => array( 'main' => array( 'border_radii' => sprintf(' %1$s .daio-cf7-styler .wpcf7 input:not([type=submit]), %1$s .daio-cf7-styler .wpcf7 input[type=email], %1$s .daio-cf7-styler .wpcf7 input[type=text], %1$s .daio-cf7-styler .wpcf7 input[type=url], %1$s .daio-cf7-styler .wpcf7 input[type=tel, %1$s .daio-cf7-styler .wpcf7 input[type=date], %1$s .daio-cf7-styler .wpcf7 select, %1$s .daio-cf7-styler .wpcf7 textarea', $this->main_css_element ), 'border_styles' => sprintf(' %1$s .daio-cf7-styler .wpcf7 input:not([type=submit]), %1$s .daio-cf7-styler .wpcf7 input[type=email], %1$s .daio-cf7-styler .wpcf7 input[type=text], %1$s .daio-cf7-styler .wpcf7 input[type=url], %1$s .daio-cf7-styler .wpcf7 input[type=tel, %1$s .daio-cf7-styler .wpcf7 input[type=date], %1$s .daio-cf7-styler .wpcf7 select, %1$s .daio-cf7-styler .wpcf7 textarea ', $this->main_css_element ), ), 'important' => 'all', ), ); return $advanced_fields; } /** * Get Contact form 7 Shortcode with id */ function get_cf7_shortcode( $args = array() ) { $cf7_id = $this->props['cf7']; $cf7_shortcode = ''; if( 0 == $cf7_id ) { $cf7_shortcode = 'Please select a Contact Form 7.'; } else { $cf7_shortcode = do_shortcode( sprintf( '[contact-form-7 id="%1$s" ]', $cf7_id ) ); } return $cf7_shortcode; } /** * Contact form 7 shortcode convert to html for using in VB */ static function get_cf7_shortcode_html( $args = array() ) { $cf7_shortcode = new self(); $cf7_shortcode->props = $args; $output = $cf7_shortcode->get_cf7_shortcode( array() ); return sprintf( '