widget_cssclass = 'widget_blogbyte_mailchimp_form'; $this->widget_description = __( 'Displays MailChimp form if you have any', 'blogbyte' ); $this->widget_id = 'blogbyte_mailchimp_form'; $this->widget_name = __( 'Blogbyte: MailChimp Form', 'blogbyte' ); $this->settings = array( 'title' => array( 'type' => 'text', 'label' => __( 'Widget Title', 'blogbyte' ), ), 'mailchimp_settings_heading' => array( 'type' => 'heading', 'label' => __( 'Mailchimp Settings', 'blogbyte' ), ), 'mailchimp_title' => array( 'type' => 'text', 'label' => __( 'Mailchimp Title', 'blogbyte' ), ), 'desc' => array( 'type' => 'textarea', 'label' => __( 'Description', 'blogbyte' ), 'rows' => 10, ), 'form_shortcode' => array( 'type' => 'text', 'label' => __( 'MailChimp Form Shortcode', 'blogbyte' ), ), 'widget_settings_heading' => array( 'type' => 'heading', 'label' => __( 'Widget Settings', 'blogbyte' ), ), 'style' => array( 'type' => 'select', 'label' => __( 'Style', 'blogbyte' ), 'desc' => __( 'For Inline Style, make sure to wrap each element ( like name, email, submit, etc. ) you want to display as inline, inside a "<p></p>" tag.', 'blogbyte' ), 'options' => array( 'style_1' => __( 'Default Style', 'blogbyte' ), 'style_2' => __( 'Form Items Inline', 'blogbyte' ), 'style_3' => __( 'Content Inline + Form Items Inline', 'blogbyte' ), ), 'std' => 'style_1', ), 'center_aligned_form' => array( 'type' => 'checkbox', 'label' => __( 'Center Aligned Form', 'blogbyte' ), 'std' => false, ), 'wide_submit_btn' => array( 'type' => 'checkbox', 'label' => __( 'Wide Submit Button', 'blogbyte' ), 'std' => false, ), 'inverted_block_color' => array( 'type' => 'checkbox', 'label' => __( 'Inverted Color', 'blogbyte' ), 'desc' => __( 'Can be used if you have dark background color or image background and want lighter color on the text.', 'blogbyte' ), 'std' => false, ), 'height' => array( 'type' => 'number', 'step' => 1, 'min' => 150, 'max' => '', 'std' => 350, 'label' => __( 'Height (px)', 'blogbyte' ), 'desc' => __( 'Works when there is either a background color or image.', 'blogbyte' ), ), 'bg_color_settings' => array( 'type' => 'heading', 'label' => __( 'Background Color', 'blogbyte' ), ), 'enable_bg_color' => array( 'type' => 'checkbox', 'label' => __( 'Enable Background Color', 'blogbyte' ), 'std' => false, ), 'bg_color' => array( 'type' => 'color', 'label' => __( 'Background Color', 'blogbyte' ), 'std' => '#f5f7f8', 'desc' => __( 'Will be overridden if used background image.', 'blogbyte' ), ), 'bg_image_settings' => array( 'type' => 'heading', 'label' => __( 'Background Image', 'blogbyte' ), ), 'bg_image' => array( 'type' => 'image', 'label' => __( 'Background Image', 'blogbyte' ), 'desc' => __( 'Will override the background color if you set an image.', 'blogbyte' ), ), 'enable_fixed_bg' => array( 'type' => 'checkbox', 'label' => __( 'Enable Fixed Background Image', 'blogbyte' ), 'std' => true, ), 'bg_overlay_color' => array( 'type' => 'color', 'label' => __( 'Overlay Color', 'blogbyte' ), 'std' => '#000000', ), 'overlay_opacity' => array( 'type' => 'number', 'step' => 10, 'min' => 0, 'max' => 100, 'std' => 50, 'label' => __( 'Overlay Opacity', 'blogbyte' ), ), ); parent::__construct(); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_assets' ) ); } /** * Output widget. * * @see WP_Widget * * @param array $args * @param array $instance */ public function widget( $args, $instance ) { if ( ! empty( $instance['form_shortcode'] ) ) { ob_start(); $style = ''; $display_style = isset( $instance['style'] ) ? $instance['style'] : $this->settings['style']['std']; $class = $display_style; if ( 'style_2' == $display_style || 'style_3' == $display_style ) { $class .= ' blogbyte-inline-mailchimp-form'; } $image_enabled = false; $this->widget_start( $args, $instance ); if ( $instance['center_aligned_form'] ) { $class .= ' blogbyte-mailchimp-centered'; } if ( $instance['wide_submit_btn'] ) { $class .= ' blogbyte-mailchimp-wide-btn'; } if ( ( $instance['bg_image'] && 0 != $instance['bg_image'] ) ) { $image_enabled = true; if ( $instance['enable_fixed_bg'] ) { $class .= ' blogbyte-bg-image blogbyte-bg-attachment-fixed'; } } if ( $instance['enable_bg_color'] || $image_enabled ) { $height = isset( $instance['height'] ) ? $instance['height'] : $this->settings['height']['std']; $style .= 'min-height:' . esc_attr( $height ) . 'px;'; $class .= ' blogbyte-cover-block'; } // Inverted Color. $inverted_block_color = isset( $instance['inverted_block_color'] ) ? $instance['inverted_block_color'] : $this->settings['inverted_block_color']['std']; if ( $inverted_block_color ) { $class .= ' saga-block-inverted-color'; } do_action( 'blogbyte_before_mailchimp' ); $widget_inline_styles = ''; $widget_id = isset( $args['widget_id'] ) ? $args['widget_id'] : ''; if ( $widget_id ) { if ( $instance['enable_bg_color'] ) { $bg_color = isset( $instance['bg_color'] ) ? $instance['bg_color'] : $this->settings['bg_color']['std']; if ( $bg_color ) { $widget_inline_styles .= " #{$widget_id} .blogbyte-mailchimp-widget { background-color:{$bg_color} !important; } "; } } if ( $widget_inline_styles ) { echo ''; } } ?>

widget_end( $args ); echo ob_get_clean(); } } public function enqueue_assets() { blogbyte_widget_css( $this->id_base, 'mailchimp-form' ); } }