widget_cssclass = 'widget_blogbyte_call_to_action'; $this->widget_description = __( 'Adds Call to action section', 'blogbyte' ); $this->widget_id = 'blogbyte_call_to_action'; $this->widget_name = __( 'Blogbyte: Call To Action', 'blogbyte' ); $this->settings = array( 'title' => array( 'type' => 'text', 'label' => __( 'Widget Title', 'blogbyte' ), ), 'cta_settings' => array( 'type' => 'heading', 'label' => __( 'CTA Settings', 'blogbyte' ), ), 'title_text' => array( 'type' => 'text', 'label' => __( 'CTA Title', 'blogbyte' ), ), 'desc' => array( 'type' => 'textarea', 'label' => __( 'CTA Description', 'blogbyte' ), 'rows' => 10, ), 'btn_text' => array( 'type' => 'text', 'label' => __( 'Button Text', 'blogbyte' ), ), 'btn_link' => array( 'type' => 'url', 'label' => __( 'Link to url', 'blogbyte' ), 'desc' => __( 'Enter a proper url with http: OR https:', 'blogbyte' ), ), 'btn_style' => array( 'type' => 'select', 'label' => __( 'Button Style', 'blogbyte' ), 'options' => blogbyte_get_read_more_styles(), 'std' => 'style_1', ), 'btn_icon' => array( 'type' => 'select', 'label' => __( 'Button Icon', 'blogbyte' ), 'options' => blogbyte_get_read_more_icons_list(), 'std' => '', ), 'link_target' => array( 'type' => 'checkbox', 'label' => __( 'Open Link in new Tab', 'blogbyte' ), 'std' => true, ), 'widget_settings' => array( 'type' => 'heading', 'label' => __( 'Widget Settings', 'blogbyte' ), ), 'style' => array( 'type' => 'select', 'label' => __( 'Display Style', 'blogbyte' ), 'options' => array( 'style_1' => __( 'Items Aligned Center + Small Width Description', 'blogbyte' ), 'style_2' => __( 'Items Aligned Center + Full Width Description', 'blogbyte' ), 'style_3' => __( 'Items Aligned Left', 'blogbyte' ), 'style_4' => __( 'Items Aligned Right', 'blogbyte' ), 'style_5' => __( 'Normal', 'blogbyte' ), ), 'std' => 'style_1', ), 'justify_content' => array( 'type' => 'checkbox', 'label' => __( 'Justify Content', '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' => true, ), '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 ) { ob_start(); $style = ''; $class = isset( $instance['style'] ) ? $instance['style'] : $this->settings['style']['std']; $enable_bg_color = isset( $instance['enable_bg_color'] ) ? $instance['enable_bg_color'] : $this->settings['enable_bg_color']['std']; $image_enabled = false; $this->widget_start( $args, $instance ); if ( ( isset( $instance['bg_image'] ) && 0 != $instance['bg_image'] ) ) { $image_enabled = true; if ( $instance['enable_fixed_bg'] ) { $class .= ' blogbyte-bg-image blogbyte-bg-attachment-fixed'; } } if ( $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'; } $justify_content = isset( $instance['justify_content'] ) ? $instance['justify_content'] : ''; if ( $justify_content ) { $class .= ' justified-cta'; } // 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_cta' ); $widget_inline_styles = ''; $widget_id = isset( $args['widget_id'] ) ? $args['widget_id'] : ''; if ( $widget_id ) { if ( $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-cta-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, 'call-to-action' ); } }