* @copyright Copyright (c) 2018, Chris Baldelomar * @link https://webplantmedia.com/product/brimstone-wordpress-theme/ * @license http://www.gnu.org/licenses/gpl-2.0.html */ /** * Class: Callout widget * * @since Brimstone 1.01 * * @see Brimstone_Widget */ class Brimstone_Content_Widget_Callout extends Brimstone_Widget { /** * __construct * * @since Brimstone 1.01 * * @return void */ public function __construct() { $this->widget_id = 'brimstone-content-widget-callout'; $this->widget_description = esc_html__( 'Displays a callout on your widgetized page.', 'brimstone' ); $this->widget_name = esc_html__( 'Brimstone: Callout', 'brimstone' ); $this->settings = array( 'page' => array( 'type' => 'page', 'std' => '', 'label' => esc_html__( 'Select Page:', 'brimstone' ), 'description' => sprintf( '%1$s %2$s', esc_html__( 'Create a new page', 'brimstone' ), esc_html__( 'with the the content and featured image you want to display for this callout item. If no featured image is set, then the text will display in full width.', 'brimstone' ) ), 'sanitize' => 'text', ), 'image_width' => array( 'type' => 'number', 'std' => '410', 'step' => 1, 'min' => 100, 'max' => 1600, 'label' => esc_html__( 'Image Width (in pixels)', 'brimstone' ), 'description' => esc_html__( 'Set custom size for featured image. Leave blank to use large image display.', 'brimstone' ), 'sanitize' => 'number_blank', ), 'text_align' => array( 'type' => 'select', 'std' => 'left', 'label' => esc_html__( 'Text Position:', 'brimstone' ), 'options' => array( 'left' => esc_html__( 'Left', 'brimstone' ), 'right' => esc_html__( 'Right', 'brimstone' ), ), 'sanitize' => 'text', ), 'vertical_align' => array( 'type' => 'select', 'std' => 'middle', 'label' => esc_html__( 'Vertical Alignment:', 'brimstone' ), 'options' => array( 'top' => esc_html__( 'Top', 'brimstone' ), 'middle' => esc_html__( 'Middle', 'brimstone' ), 'bottom' => esc_html__( 'Bottom', 'brimstone' ), ), 'sanitize' => 'text', ), 'background_color' => array( 'type' => 'colorpicker', 'std' => '#ffffff', 'label' => esc_html__( 'Background Color:', 'brimstone' ), 'sanitize' => 'color', ), 'text_color' => array( 'type' => 'colorpicker', 'std' => '', 'label' => esc_html__( 'Text Color:', 'brimstone' ), 'description' => esc_html__( 'Leave blank to use default theme color.', 'brimstone' ), 'sanitize' => 'color', ), 'button_text' => array( 'type' => 'text', 'std' => 'BUTTON', 'label' => esc_html__( 'Button Text:', 'brimstone' ), 'sanitize' => 'text', ), 'button_link' => array( 'type' => 'text', 'std' => esc_url( home_url( '/' ) ), 'label' => esc_html__( 'Button URL:', 'brimstone' ), 'sanitize' => 'url', ), 'button_style' => array( 'type' => 'select', 'std' => 'button-2', 'label' => esc_html__( 'Button Style:', 'brimstone' ), 'options' => array( 'default' => esc_html__( 'Default Button', 'brimstone' ), 'button-1' => esc_html__( 'Image Button 1', 'brimstone' ), 'button-2' => esc_html__( 'Image Button 2', 'brimstone' ), ), 'sanitize' => 'text', ), 'style' => array( 'type' => 'select', 'std' => 'plain', 'label' => esc_html__( 'Box Style:', 'brimstone' ), 'options' => array( 'plain' => esc_html__( 'Plain', 'brimstone' ), 'border' => esc_html__( 'Border', 'brimstone' ), ), 'sanitize' => 'text', ), 'padding_top' => array( 'type' => 'number', 'std' => 70, 'step' => 1, 'min' => 0, 'label' => esc_html__( 'Top padding of widget:', 'brimstone' ), 'sanitize' => 'number', ), 'padding_bottom' => array( 'type' => 'number', 'std' => 70, 'step' => 1, 'min' => 0, 'label' => esc_html__( 'Bottom padding of widget:', 'brimstone' ), 'sanitize' => 'number', ), 'margin_bottom' => array( 'type' => 'number', 'std' => 40, 'step' => 1, 'min' => 0, 'label' => esc_html__( 'Bottom margin of widget:', 'brimstone' ), 'sanitize' => 'number', ), ); parent::__construct(); } /** * Widget function. * * @since Brimstone 1.01 * * @param array $args * @param array $instance * @return void */ public function widget( $args, $instance ) { $o = $this->sanitize( $instance ); $p = null; $featured_image = null; if ( ! empty( $o['page'] ) ) { $p = get_post( $o['page'] ); } $content = $this->callout_content( $o, $p ); $style = array(); $wrap_style = array(); if ( ! empty( $o['background_color'] ) ) { $style[] = 'background-color:' . $o['background_color'] . ';'; } if ( ! empty( $o['margin_bottom'] ) ) { if ( 'border' === $o['style'] ) { $wrap_style[] = 'margin-bottom:' . $o['margin_bottom'] . 'px;'; } else { $style[] = 'margin-bottom:' . $o['margin_bottom'] . 'px;'; } } if ( ! empty( $o['padding_top'] ) ) { $style[] = 'padding-top:' . $o['padding_top'] . 'px;'; } if ( ! empty( $o['padding_bottom'] ) ) { $style[] = 'padding-bottom:' . $o['padding_bottom'] . 'px;'; } if ( $p ) { $size = 'large'; if ( $o['image_width'] >= 100 ) { $size = array( $o['image_width'], 9999 ); } $featured_image = get_the_post_thumbnail( $p->ID, $size ); } $args['before_widget'] = str_replace( 'class="content-widget', 'class="content-widget full-width-bar', $args['before_widget'] ); ?>