widget_cssclass = 'blog_tale widget_mailchimp_form'; $this->widget_description = __("Displays MailChimp form if you have any", 'blog-tale'); $this->widget_id = 'blog_tale_mailchimp_form'; $this->widget_name = __('BT: MailChimp Form', 'blog-tale'); $this->settings = array( 'title' => array( 'type' => 'text', 'label' => __('Title', 'blog-tale'), ), 'desc' => array( 'type' => 'textarea', 'label' => __('Description', 'blog-tale'), 'rows' => 10, ), 'form_shortcode' => array( 'type' => 'text', 'label' => __('MailChimp Form Shortcode', 'blog-tale'), ), 'msg' => array( 'type' => 'message', 'label' => sprintf( __( 'You can edit your sign-up form in the MailChimp for WordPress form settings.', 'blog-tale' ), admin_url( 'admin.php?page=mailchimp-for-wp-forms' )), 'separator' => true, ), 'bg_image' => array( 'type' => 'image', 'label' => __( 'Background Image', 'blog-tale' ), 'desc' => __( 'Don\'t upload any image if you do not want to show the background image.', 'blog-tale' ), ), 'bg_img_padding' => array( 'type' => 'number', 'step' => 1, 'min' => 0, 'max' => 200, 'std' => 60, 'label' => __('Background Image padding', 'blog-tale'), ), 'enable_bg_overlay' => array( 'type' => 'checkbox', 'label' => __('Enable Image Overlay', 'blog-tale'), 'std' => true, ), ); parent::__construct(); } /** * Output widget. * * @see WP_Widget * * @param array $args * @param array $instance */ public function widget($args, $instance) { if (!empty($instance['form_shortcode'])) { ob_start(); $img_div = $class = $bg_img_padding = ''; $this->widget_start($args, $instance); /*Background Image*/ if($instance['bg_image'] && 0 != $instance['bg_image']){ $image_url = wp_get_attachment_url($instance['bg_image']); if($image_url){ $bg_img_padding = 'padding:'.absint($instance['bg_img_padding']).'px 0px'; $class = 'be-bg-image'; if ($instance['enable_bg_overlay'] == 1) { $class .= ' bg-overlay'; } $img_div = ''; } } do_action( 'blog_tale_before_mailchimp'); ?>
widget_end($args); echo ob_get_clean(); } } }