widget_cssclass = 'widget_bloglex_cat'; $this->widget_description = __("Displays call to action button and text with background", 'bloglex'); $this->widget_id = 'bloglex_cat'; $this->widget_name = __('Bloglex: CTA', 'bloglex'); $this->settings = $this->get_widget_settings(); parent::__construct(); } /** * Define widget settings. */ protected function get_widget_settings() { return array( 'title' => array( 'type' => 'text', 'label' => __('Widget Title', 'bloglex'), ), 'title_text' => array( 'type' => 'text', 'label' => __('CTA Title', 'bloglex'), ), 'font_size' => array( 'type' => 'select', 'label' => __('Heading font size', 'bloglex'), 'options' => array( 'entry-title-small' => __('Small', 'bloglex'), 'entry-title-medium' => __('Medium', 'bloglex'), 'entry-title-big' => __('Big', 'bloglex'), 'entry-title-large' => __('Large', 'bloglex'), ), 'std' => 'entry-title-large', ), 'font_style' => array( 'type' => 'select', 'label' => __('Heading font style', 'bloglex'), 'options' => array( 'entry-title-normal' => __('Normal', 'bloglex'), 'entry-title-italic' => __('Italic', 'bloglex'), ), 'std' => 'entry-title-normal', ), 'text_alignment' => array( 'type' => 'select', 'label' => __('Text Alignment', 'bloglex'), 'options' => array( 'align-text-center' => __('Center', 'bloglex'), 'align-text-left' => __('Left', 'bloglex'), 'align-text-right' => __('Right', 'bloglex'), ), 'std' => 'align-text-center', ), 'description' => array( 'type' => 'textarea', 'label' => __('CTA Description', 'bloglex'), 'rows' => 10, ), 'button_text_1' => array( 'type' => 'text', 'label' => __('Button Text - 1', 'bloglex'), ), 'button_link_1' => array( 'type' => 'url', 'label' => __('Link to url - 1', 'bloglex'), 'desc' => __('Enter a proper url with http: OR https:', 'bloglex'), ), 'link_target_1' => array( 'type' => 'checkbox', 'label' => __('Open Link in new Tab - 1', 'bloglex'), 'std' => true, ), 'button_text_2' => array( 'type' => 'text', 'label' => __('Button Text - 2', 'bloglex'), ), 'button_link_2' => array( 'type' => 'url', 'label' => __('Link to url - 2', 'bloglex'), 'desc' => __('Enter a proper url with http: OR https:', 'bloglex'), ), 'link_target_2' => array( 'type' => 'checkbox', 'label' => __('Open Link in new Tab - 2', 'bloglex'), 'std' => true, ), 'widget_settings' => array( 'type' => 'heading', 'label' => __('Widget Settings', 'bloglex'), ), 'display_layout' => array( 'type' => 'select', 'label' => __('Display Layout', 'bloglex'), 'options' => array( 'display-regular-layout' => __('Regular layout', 'bloglex'), 'display-fullwidth-layout' => __('Full Width Layout', 'bloglex'), ), 'std' => 'display-regular-layout', ), 'vertical_alignment' => array( 'type' => 'select', 'label' => __('Vertical Alignment', 'bloglex'), 'options' => array( 'vertical-align-top' => __('Top', 'bloglex'), 'vertical-align-middle' => __('Middle', 'bloglex'), 'vertical-align-bottom' => __('Bottom', 'bloglex'), ), 'std' => 'vertical-align-middle', ), 'text_color' => array( 'type' => 'color', 'label' => __('Text Color', 'bloglex'), 'std' => '#ffffff', ), 'bg_color' => array( 'type' => 'color', 'label' => __('Background Color', 'bloglex'), 'std' => '#000000', 'desc' => __('Will be overridden if used background image.', 'bloglex'), ), 'bg_image' => array( 'type' => 'image', 'label' => __('Background Image', 'bloglex'), ), 'enable_fixed_bg' => array( 'type' => 'checkbox', 'label' => __('Enable Fixed Background Image', 'bloglex'), 'std' => false, ), 'bg_overlay_color' => array( 'type' => 'color', 'label' => __('Overlay Color', 'bloglex'), 'std' => '#000000', ), 'overlay_opacity' => array( 'type' => 'number', 'step' => 10, 'min' => 0, 'max' => 100, 'std' => 50, 'label' => __('Overlay Opacity', 'bloglex'), ), 'height' => array( 'type' => 'number', 'step' => 1, 'min' => 150, 'max' => '', 'std' => 560, 'label' => __('Height (px)', 'bloglex'), 'desc' => __('Works when there is either a background color or image.', 'bloglex'), ), ); } /** * Output widget. * * @param array $args * @param array $instance * @see WP_Widget * */ public function widget($args, $instance) { ob_start(); $style = ''; $font_size = !empty($instance['font_size']) ? $instance['font_size'] : $this->settings['font_size']['std']; $font_style = !empty($instance['font_style']) ? $instance['font_style'] : $this->settings['font_style']['std']; $text_alignment = !empty($instance['text_alignment']) ? $instance['text_alignment'] : $this->settings['text_alignment']['std']; $vertical_alignment = !empty($instance['vertical_alignment']) ? $instance['vertical_alignment'] : $this->settings['vertical_alignment']['std']; $class = isset($instance['display_layout']) ? $instance['display_layout'] : $this->settings['display_layout']['std']; $image_enabled = false; $this->widget_start($args, $instance); $bg_color = isset($instance['bg_color']) ? $instance['bg_color'] : $this->settings['bg_color']['std']; $text_color = isset($instance['text_color']) ? $instance['text_color'] : $this->settings['text_color']['std']; $style = 'background-color:' . esc_attr($bg_color) . ';'; $style .= '--cta-text-color:' . esc_attr($text_color) . ';'; $height = isset($instance['height']) ? $instance['height'] : $this->settings['height']['std']; $style .= 'min-height:' . esc_attr($height) . 'px;'; if ((isset($instance['bg_image']) && 0 != $instance['bg_image'])) { $image_enabled = true; if ($instance['enable_fixed_bg']) { $class .= ' background-image-fixed'; } } if ($image_enabled) { $class .= ' widget-has-background entry-background-image'; } if ($vertical_alignment) { $class .= ' ' . $vertical_alignment; } do_action('bloglex_before_cta'); ?>
widget_end($args); echo ob_get_clean(); } }