widget_cssclass = 'widget_blogmarks_call_to_action'; $this->widget_description = __( 'Adds Call to action section', 'blogmarks' ); $this->widget_id = 'blogmarks_call_to_action'; $this->widget_name = __( 'Blogmarks: Call To Action', 'blogmarks' ); $this->settings = array( 'title' => array( 'type' => 'text', 'label' => __( 'Widget Title', 'blogmarks' ), ), 'cta_settings' => array( 'type' => 'heading', 'label' => __( 'CTA Settings', 'blogmarks' ), ), 'title_text' => array( 'type' => 'text', 'label' => __( 'CTA Title', 'blogmarks' ), ), 'desc' => array( 'type' => 'textarea', 'label' => __( 'CTA Description', 'blogmarks' ), 'rows' => 10, ), 'btn_text' => array( 'type' => 'text', 'label' => __( 'Button Text', 'blogmarks' ), ), 'btn_link' => array( 'type' => 'url', 'label' => __( 'Link to url', 'blogmarks' ), 'desc' => __( 'Enter a proper url with http: OR https:', 'blogmarks' ), ), 'btn_style' => array( 'type' => 'select', 'label' => __( 'Button Style', 'blogmarks' ), 'options' => blogmarks_get_read_more_styles(), 'std' => 'style_1', ), 'btn_icon' => array( 'type' => 'select', 'label' => __( 'Button Icon', 'blogmarks' ), 'options' => blogmarks_get_read_more_icons_list(), 'std' => '', ), 'link_target' => array( 'type' => 'checkbox', 'label' => __( 'Open Link in new Tab', 'blogmarks' ), 'std' => true, ), 'widget_settings' => array( 'type' => 'heading', 'label' => __( 'Widget Settings', 'blogmarks' ), ), 'style' => array( 'type' => 'select', 'label' => __( 'Display Style', 'blogmarks' ), 'options' => array( 'style_1' => __( 'Items Aligned Center + Small Width Description', 'blogmarks' ), 'style_2' => __( 'Full Width + Items Aligned Center ', 'blogmarks' ), 'style_3' => __( 'Items Aligned Left', 'blogmarks' ), 'style_4' => __( 'Items Aligned Right', 'blogmarks' ), 'style_5' => __( 'Normal', 'blogmarks' ), ), 'std' => 'style_1', ), 'enable_bg_color' => array( 'type' => 'checkbox', 'label' => __( 'Enable Background Color', 'blogmarks' ), 'std' => false, ), 'bg_color' => array( 'type' => 'color', 'label' => __( 'Background Color', 'blogmarks' ), 'std' => '#000000', 'desc' => __( 'Will be overridden if used background image.', 'blogmarks' ), ), 'bg_image' => array( 'type' => 'image', 'label' => __( 'Background Image', 'blogmarks' ), ), 'enable_fixed_bg' => array( 'type' => 'checkbox', 'label' => __( 'Enable Fixed Background Image', 'blogmarks' ), 'std' => true, ), 'bg_overlay_color' => array( 'type' => 'color', 'label' => __( 'Overlay Color', 'blogmarks' ), 'std' => '#000000', ), 'overlay_opacity' => array( 'type' => 'number', 'step' => 10, 'min' => 0, 'max' => 100, 'std' => 50, 'label' => __( 'Overlay Opacity', 'blogmarks' ), ), 'height' => array( 'type' => 'number', 'step' => 1, 'min' => 150, 'max' => '', 'std' => 500, 'label' => __( 'Height (px)', 'blogmarks' ), 'desc' => __( 'Works when there is either a background color or image.', 'blogmarks' ), ), ); 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 ( $enable_bg_color ) { $bg_color = isset( $instance['bg_color'] ) ? $instance['bg_color'] : $this->settings['bg_color']['std']; $style = 'background-color:' . esc_attr( $bg_color ) . ';'; } if ( ( isset( $instance['bg_image'] ) && 0 != $instance['bg_image'] ) ) { $image_enabled = true; if ( $instance['enable_fixed_bg'] ) { $class .= ' blogmarks-bg-image blogmarks-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 .= ' widget-has-background'; } do_action( 'blogmarks_before_cta' ); ?>

settings['btn_style']['std']; $btn_icon = isset( $instance['btn_icon'] ) ? $instance['btn_icon'] : $this->settings['btn_icon']['std']; ?>
widget_end( $args ); echo ob_get_clean(); } public function enqueue_assets() { if ( is_active_widget( false, false, $this->id_base ) ) { $file_prefix = is_rtl() ? '-rtl' : ''; $css_file = get_template_directory() . '/include/widgets/assets/call-to-action' . $file_prefix . '.css'; if ( file_exists( $css_file ) ) { $styles = wp_strip_all_tags( file_get_contents( $css_file ) ); wp_add_inline_style( 'blogmarks-style', $styles ); } } } }