* @copyright Copyright (c) 2018, Chris Baldelomar * @link https://webplantmedia.com/product/brimstone-wordpress-theme/ * @license http://www.gnu.org/licenses/gpl-2.0.html */ if ( ! class_exists( 'Brimstone_Widget_Image_Banner_Widget' ) ) : /** * Class: Display static content from an specific page. * * @since Brimstone 1.01 * * @see Brimstone_Widget */ class Brimstone_Widget_Image_Banner_Widget extends Brimstone_Widget { /** * __construct * * @since Brimstone 1.01 * * @return void */ public function __construct() { $this->widget_id = 'brimstone-image-banner'; $this->widget_cssclass = 'brimstone-image-banner'; $this->widget_description = esc_html__( 'Display an image banner in your footer or sidebar.', 'brimstone' ); $this->widget_name = esc_html__( 'Brimstone: Image Banner', 'brimstone' ); $this->settings = array( 'page' => array( 'type' => 'page', 'std' => '', 'label' => esc_html__( 'Select Page:', 'brimstone' ), 'description' => esc_html__( 'The post content and featured image will be grabbed from the selected post.', 'brimstone' ), 'sanitize' => 'text', ), 'image_width' => array( 'type' => 'number', 'std' => '', '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', ), 'image_style' => array( 'type' => 'select', 'std' => 'round', 'label' => esc_html__( 'Image Style:', 'brimstone' ), 'options' => array( 'none' => esc_html__( 'None', 'brimstone' ), 'round' => esc_html__( 'Round', 'brimstone' ), ), 'sanitize' => 'text', ), 'title_position' => array( 'type' => 'select', 'std' => 'below', 'label' => esc_html__( 'Title Position:', 'brimstone' ), 'options' => array( 'above' => esc_html__( 'Above', 'brimstone' ), 'middle' => esc_html__( 'Middle', 'brimstone' ), 'below' => esc_html__( 'Below', 'brimstone' ), ), 'sanitize' => 'text', ), 'link' => array( 'type' => 'text', 'std' => home_url( '/' ), 'label' => esc_html__( 'Link:', 'brimstone' ), 'sanitize' => 'url', ), ); 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'] ); } if ( $p ) { $size = 'large'; if ( $o['image_width'] >= 100 ) { $size = array( $o['image_width'], 9999 ); } $featured_image = get_the_post_thumbnail( $p->ID, $size ); } echo $args['before_widget']; /* WPCS: XSS OK. HTML output. */ $class = array(); $class[] = 'image-banner-wrapper'; $class[] = 'image-banner-title-position-' . $o['title_position']; $class[] = 'image-banner-style-' . $o['image_style']; ?>