widget_cssclass = 'widget_blogbend_cat'; $this->widget_description = __("Displays call to action button and text with background", 'blogbend'); $this->widget_id = 'blogbend_cat'; $this->widget_name = __('BlogBend: CTA', 'blogbend'); $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', 'blogbend'), ), 'title_text' => array( 'type' => 'text', 'label' => __('CTA Title', 'blogbend'), ), 'font_size' => array( 'type' => 'select', 'label' => __('Heading font size', 'blogbend'), 'options' => array( 'entry-title-small' => __('Small', 'blogbend'), 'entry-title-medium' => __('Medium', 'blogbend'), 'entry-title-big' => __('Big', 'blogbend'), 'entry-title-large' => __('Large', 'blogbend'), ), 'std' => 'entry-title-large', ), 'font_style' => array( 'type' => 'select', 'label' => __('Heading font style', 'blogbend'), 'options' => array( 'entry-title-normal' => __('Normal', 'blogbend'), 'entry-title-italic' => __('Italic', 'blogbend'), ), 'std' => 'entry-title-normal', ), 'description' => array( 'type' => 'textarea', 'label' => __('CTA Description', 'blogbend'), 'rows' => 10, ), 'button_text_1' => array( 'type' => 'text', 'label' => __('Button Text - 1', 'blogbend'), ), 'button_link_1' => array( 'type' => 'url', 'label' => __('Link to url - 1', 'blogbend'), 'desc' => __('Enter a proper url with http: OR https:', 'blogbend'), ), 'link_target_1' => array( 'type' => 'checkbox', 'label' => __('Open Link in new Tab - 1', 'blogbend'), 'std' => true, ), 'button_text_2' => array( 'type' => 'text', 'label' => __('Button Text - 2', 'blogbend'), ), 'button_link_2' => array( 'type' => 'url', 'label' => __('Link to url - 2', 'blogbend'), 'desc' => __('Enter a proper url with http: OR https:', 'blogbend'), ), 'link_target_2' => array( 'type' => 'checkbox', 'label' => __('Open Link in new Tab - 2', 'blogbend'), 'std' => true, ), 'widget_settings' => array( 'type' => 'heading', 'label' => __('Widget Settings', 'blogbend'), ), 'display_layout' => array( 'type' => 'select', 'label' => __('Display Layout', 'blogbend'), 'options' => array( 'display-regular-layout' => __('Regular layout', 'blogbend'), 'display-fullwidth-layout' => __('Full Width Layout', 'blogbend'), ), 'std' => 'display-regular-layout', ), 'text_alignment' => array( 'type' => 'select', 'label' => __('Text Alignment', 'blogbend'), 'options' => array( 'align-flex-start' => __('Left', 'blogbend'), 'align-flex-center' => __('Center', 'blogbend'), 'align-flex-end' => __('Right', 'blogbend'), ), 'std' => 'align-flex-start', ), 'vertical_alignment' => array( 'type' => 'select', 'label' => __('Vertical Alignment', 'blogbend'), 'options' => array( 'justify-content-center' => __('Middle', 'blogbend'), 'justify-content-left' => __('Top', 'blogbend'), 'justify-content-right' => __('Bottom', 'blogbend'), ), 'std' => 'justify-content-right', ), 'text_color' => array( 'type' => 'color', 'label' => __('Text Color', 'blogbend'), 'std' => '#ffffff', ), 'bg_color' => array( 'type' => 'color', 'label' => __('Background Color', 'blogbend'), 'std' => '#000000', 'desc' => __('Will be overridden if used background image.', 'blogbend'), ), 'bg_image' => array( 'type' => 'image', 'label' => __('Background Image', 'blogbend'), ), 'bg_overlay_color' => array( 'type' => 'color', 'label' => __('Overlay Color', 'blogbend'), 'std' => '#000000', ), 'overlay_opacity' => array( 'type' => 'number', 'step' => 10, 'min' => 0, 'max' => 100, 'std' => 50, 'label' => __('Overlay Opacity', 'blogbend'), ), 'height' => array( 'type' => 'number', 'step' => 1, 'min' => 150, 'max' => '', 'std' => 680, 'label' => __('Height (px)', 'blogbend'), 'desc' => __('Works when there is either a background color or image.', 'blogbend'), ), ); } /** * Output widget. * * @param array $args * @param array $instance */ public function widget($args, $instance) { ob_start(); $style = ''; // Default settings fallback $font_size = $instance['font_size'] ?? $this->settings['font_size']['std']; $font_style = $instance['font_style'] ?? $this->settings['font_style']['std']; $text_alignment = $instance['text_alignment'] ?? $this->settings['text_alignment']['std']; $vertical_alignment = $instance['vertical_alignment'] ?? $this->settings['vertical_alignment']['std']; $class = $instance['display_layout'] ?? $this->settings['display_layout']['std']; echo $args['before_widget']; $bg_color = $instance['bg_color'] ?? $this->settings['bg_color']['std']; $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 = $instance['height'] ?? $this->settings['height']['std']; $style .= 'height:' . esc_attr($height) . 'px;'; $image_enabled = !empty($instance['bg_image']); do_action('blogbend_before_cta'); ?>