* @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_Content_Widget_Collage' ) ) : /** * Class: Display Featured Slide Item for section * * @since Brimstone 1.01 * * @see Brimstone_Widget */ class Brimstone_Content_Widget_Collage extends Brimstone_Widget { /** * __construct * * @since Brimstone 1.01 * * @return void */ public function __construct() { $this->widget_id = 'brimstone-content-widget-collage'; $this->widget_description = esc_html__( 'Displays a collage on your widgetized page.', 'brimstone' ); $this->widget_name = esc_html__( 'Brimstone: Collage', 'brimstone' ); $this->settings = array( 'panels' => array( array( 'title' => esc_html__( 'Slider Settings', 'brimstone' ), 'fields' => array( 'slider_mode' => array( 'type' => 'select', 'std' => 'horizontal', 'label' => esc_html__( 'Transition Effect:', 'brimstone' ), 'options' => array( 'horizontal' => esc_html__( 'Slide', 'brimstone' ), 'fade' => esc_html__( 'Fade', 'brimstone' ), ), 'sanitize' => 'text', ), 'slider_pause' => array( 'type' => 'number', 'std' => 9, 'step' => 1, 'min' => 1, 'max' => 100, 'label' => esc_html__( 'Speed of the slideshow change in seconds:', 'brimstone' ), 'sanitize' => 'number', ), 'slider_auto' => array( 'type' => 'checkbox', 'std' => 1, 'label' => esc_html__( 'Auto start slider transitions?', 'brimstone' ), 'sanitize' => 'checkbox', ), 'slider_autohover' => array( 'type' => 'checkbox', 'std' => 1, 'label' => esc_html__( 'Pause slideshow when hovering?', 'brimstone' ), 'sanitize' => 'checkbox', ), 'slider_controls' => array( 'type' => 'checkbox', 'std' => 1, 'label' => esc_html__( 'Show slide control?', 'brimstone' ), 'sanitize' => 'checkbox', ), 'slider_pager' => array( 'type' => 'checkbox', 'std' => 1, 'label' => esc_html__( 'Show slide pagination?', 'brimstone' ), 'sanitize' => 'checkbox', ), 'slider_control_color' => array( 'type' => 'select', 'std' => 'light', 'label' => esc_html__( 'Slider Control Color', 'brimstone' ), 'options' => array( 'light' => esc_html__( 'Light', 'brimstone' ), 'dark' => esc_html__( 'Dark', 'brimstone' ), ), 'sanitize' => 'text', ), 'margin_bottom' => array( 'type' => 'number', 'std' => 40, 'step' => 1, 'min' => 0, 'label' => esc_html__( 'Bottom margin of widget:', 'brimstone' ), 'sanitize' => 'number', ), ), ), ), 'repeater' => array( 'title' => '', 'fields' => array( 'page' => array( 'type' => 'page', 'std' => '', 'label' => esc_html__( 'Select Page:', 'brimstone' ), 'description' => esc_html__( 'Create a new page with the the content and featured image you want to display for this collage item. If no featured image is set, then this collage item will display only the background color selected.', 'brimstone' ), 'sanitize' => 'text', ), 'background_color' => array( 'type' => 'colorpicker', 'std' => '#ffffff', 'label' => esc_html__( 'Background Color:', 'brimstone' ), 'sanitize' => 'color', ), 'background_size' => array( 'type' => 'select', 'std' => 'cover', 'label' => esc_html__( 'Background Size:', 'brimstone' ), 'options' => $this->options_background_size(), 'sanitize' => 'background_size', ), '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', ), 'text_background_color' => array( 'type' => 'colorpicker', 'std' => '', 'label' => esc_html__( 'Text Background Color:', 'brimstone' ), 'description' => esc_html__( 'Leave blank for no background color.', 'brimstone' ), 'sanitize' => 'color', ), 'text_background_opacity' => array( 'type' => 'number', 'std' => '80', 'step' => '1', 'min' => '0', 'max' => '100', 'label' => esc_html__( 'Text Background Color Opacity:', 'brimstone' ), 'sanitize' => 'absint', ), 'max_width' => array( 'type' => 'number', 'std' => '400', 'step' => '1', 'min' => '0', 'label' => esc_html__( 'Max Width of Content Box:', 'brimstone' ), 'description' => esc_html__( 'Leave blank to set max width to none.', 'brimstone' ), 'sanitize' => 'number_blank', ), 'button_text' => array( 'type' => 'text', 'std' => '', 'label' => esc_html__( 'Button Text:', 'brimstone' ), 'sanitize' => 'text', ), 'button_link' => array( 'type' => 'text', 'std' => '', 'label' => esc_html__( 'Button URL:', 'brimstone' ), 'sanitize' => 'url', ), 'button_style' => array( 'type' => 'select', 'std' => 'default', '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', ), ), 'default' => array( array( 'background_color' => '#cccccc', 'background_size' => 'cover', 'text_color' => '', 'text_background_color' => '#ffffff', 'text_background_opacity' => '70', 'max_width' => '300', 'button_link' => esc_url( home_url( '/' ) ), 'button_text' => _x( 'Slide 1', 'Theme starter content', 'brimstone' ), 'button_style' => 'default', ), array( 'background_color' => '#cccccc', 'background_size' => 'cover', 'text_color' => '', 'text_background_color' => '#ffffff', 'text_background_opacity' => '70', 'max_width' => '300', 'button_link' => esc_url( home_url( '/' ) ), 'button_text' => _x( 'Slide 2', 'Theme starter content', 'brimstone' ), ), array( 'background_color' => '#cccccc', 'background_size' => 'cover', 'text_color' => '', 'text_background_color' => '#ffffff', 'text_background_opacity' => '70', 'max_width' => '300', 'button_link' => esc_url( home_url( '/' ) ), 'button_text' => _x( 'Slide 3', 'Theme starter content', 'brimstone' ), ), array( 'background_color' => '#cccccc', 'background_size' => 'cover', 'text_color' => '', 'text_background_color' => '', 'text_background_opacity' => '70', 'max_width' => '350', 'button_link' => esc_url( home_url( '/' ) ), 'button_text' => '', ), array( 'background_color' => '#cccccc', 'background_size' => 'cover', 'text_color' => '', 'text_background_color' => '', 'text_background_opacity' => '70', 'max_width' => '', 'button_link' => esc_url( home_url( '/' ) ), 'button_text' => '', ), array( 'background_color' => '#cccccc', 'background_size' => 'fit-width', 'text_color' => '', 'text_background_color' => '', 'text_background_opacity' => '70', 'max_width' => '', 'button_link' => esc_url( home_url( '/' ) ), 'button_text' => '', ), array( 'background_color' => '#cccccc', 'background_size' => 'cover', 'text_color' => '', 'text_background_color' => '#ffffff', 'text_background_opacity' => '100', 'max_width' => '', 'button_link' => esc_url( home_url( '/' ) ), 'button_text' => '', ), ), ), ); parent::__construct(); } /** * Widget function. * * @since Brimstone 1.01 * * @param array $args * @param array $instance * @return void */ public function widget( $args, $instance ) { wp_enqueue_script( 'bx2slider' ); $o = $this->sanitize( $instance ); if ( ( ! isset( $o['repeater'] ) ) || ! is_array( $o['repeater'] ) ) { return; } $slider_size = max( count( $o['repeater'] ), 5 ); $repeater = $o['repeater']; $style = array(); if ( ! empty( $o['margin_bottom'] ) ) { $style[] = 'margin-bottom:' . $o['margin_bottom'] . 'px;'; } $class = array( 'collage' ); if ( ! empty( $o['slider_control_color'] ) ) { $class[] = 'slider-control-' . $o['slider_control_color']; } echo $args['before_widget']; /* WPCS: XSS OK. HTML output. */ ?>