* @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: Jetpack Testimonials * * @since Brimstone 1.01 * * @see Brimstone_Widget */ class Brimstone_Content_Widget_Jetpack_Testimonials extends Brimstone_Widget { /** * __construct * * @since Brimstone 1.01 * * @return void */ public function __construct() { $this->widget_id = 'brimstone-content-widget-jetpack-testimonials'; $this->widget_description = esc_html__( 'Displays Jetpack testimonials on your widgetized page.', 'brimstone' ); $this->widget_name = esc_html__( 'Brimstone: Jetpack Testimonials', 'brimstone' ); $this->settings = array( 'title' => array( 'type' => 'text', 'std' => esc_html__( 'THOUSANDS OF HAPPY CUSTOMERS AND COUNTING', 'brimstone' ), 'label' => esc_html__( 'Title:', 'brimstone' ), 'sanitize' => 'text', ), 'display_signature' => array( 'type' => 'checkbox', 'std' => 1, 'label' => esc_html__( 'Display Signature:', 'brimstone' ), 'sanitize' => 'checkbox', ), 'signature_icon' => array( 'type' => 'select', 'std' => 'heart', 'label' => esc_html__( 'Icon to display before signature:', 'brimstone' ), 'options' => array( 'short-dash' => esc_html__( 'Short Dash', 'brimstone' ), 'medium-dash' => esc_html__( 'Medium Dash', 'brimstone' ), 'long-dash' => esc_html__( 'Long Dash', 'brimstone' ), 'heart' => esc_html__( 'Heart', 'brimstone' ), '' => esc_html__( 'None', 'brimstone' ), ), 'sanitize' => 'text', ), 'columns' => array( 'type' => 'select', 'std' => '2', 'label' => esc_html__( 'Columns:', 'brimstone' ), 'options' => array( '1' => esc_html__( '1', 'brimstone' ), '2' => esc_html__( '2', 'brimstone' ), ), 'sanitize' => 'text', ), 'showposts' => array( 'type' => 'number', 'std' => 0, 'step' => 1, 'min' => 0, 'label' => esc_html__( 'Number of testimonials to display:', 'brimstone' ), 'description' => esc_html__( 'Set to zero to display all.', 'brimstone' ), 'sanitize' => 'number', ), 'order' => array( 'type' => 'select', 'std' => 'asc', 'label' => esc_html__( 'Order:', 'brimstone' ), 'options' => array( 'asc' => esc_html__( 'ASC', 'brimstone' ), 'desc' => esc_html__( 'DESC', 'brimstone' ), ), 'sanitize' => 'text', ), 'orderby' => array( 'type' => 'select', 'std' => 'date', 'label' => esc_html__( 'Order By:', 'brimstone' ), 'options' => array( 'date' => esc_html__( 'Date', 'brimstone' ), 'title' => esc_html__( 'Title', 'brimstone' ), 'author' => esc_html__( 'Author', 'brimstone' ), 'rand' => esc_html__( 'Random', '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', ), 'height' => array( 'type' => 'number', 'std' => 370, 'step' => 1, 'min' => 0, 'max' => 1000, 'label' => esc_html__( 'Height of testimonials:', 'brimstone' ), 'sanitize' => 'number', ), 'padding_top' => array( 'type' => 'number', 'std' => 40, 'step' => 1, 'min' => 0, 'max' => 300, 'label' => esc_html__( 'Top padding of widget:', 'brimstone' ), 'sanitize' => 'number', ), 'padding_bottom' => array( 'type' => 'number', 'std' => 40, 'step' => 1, 'min' => 0, 'max' => 300, 'label' => esc_html__( 'Bottom padding of widget:', 'brimstone' ), 'sanitize' => 'number', ), 'margin_bottom' => array( 'type' => 'number', 'std' => 80, 'step' => 1, 'min' => 0, 'max' => 300, 'label' => esc_html__( 'Bottom margin of widget:', 'brimstone' ), 'sanitize' => 'number', ), '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', ), ), ), ), ); parent::__construct(); } /** * Widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ public function widget( $args, $instance ) { wp_enqueue_script( 'bx2slider' ); $o = $this->sanitize( $instance ); $style = array(); $testimonial_style = array(); $classes[] = 'content-jetpack-testimonial'; if ( ! empty( $o['margin_bottom'] ) ) { $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 ( ! empty( $o['style'] ) ) { $classes[] = 'box-style-' . $o['style']; } if ( ! empty( $o['height'] ) ) { $testimonial_style[] = 'height:' . $o['height'] . 'px;'; } $options['showposts'] = $this->settings['showposts']['std']; $options['order'] = $this->settings['order']['std']; $options['orderby'] = $this->settings['orderby']['std']; $options['post_type'] = 'jetpack-testimonial'; /* Force this post type. */ $query = new WP_Query( $options ); $testimonial_index_number = 1; $column = 0; $testimonials = array(); $notice = ''; ?> have_posts() ) : ?> have_posts() ) { $query->the_post(); $post_id = get_the_ID(); $temp = '
'; $temp .= '
'; // Featured image. $class = ' no-testimonial-image'; $image = $this->get_testimonial_thumbnail_link( $post_id ); if ( $image ) { $temp .= $image; $class = ' has-testimonial-image'; } $temp .= '
'; $temp .= '
' . get_the_excerpt() . '
'; if ( $o['display_signature'] ) { switch ( $o['signature_icon'] ) { case 'short-dash': $icon = '– '; break; case 'medium-dash': $icon = '— '; break; case 'long-dash': $icon = '― '; break; case 'heart': $icon = ''; break; default: $icon = ''; break; } $temp .= '
'; $temp .= $icon . '' . get_the_title() . ''; $temp .= '
'; } $temp .= '
'; $temp .= '
'; if ( get_edit_post_link( $post_id ) ) { $temp .= ''; } $temp .= '
'; $testimonials[ $column ][] = $temp; $mod = $testimonial_index_number % $o['columns']; if ( 0 === $mod ) { $column++; } $testimonial_index_number++; } /* end of while loop. */ ?>
$testimonial ) : ?>

' . get_the_post_thumbnail( $post_id, 'thumbnail' ) . ''; } } /** * Registers the widget with the WordPress Widget API. * * @since Brimstone 1.01 * * @return void */ public static function register() { register_widget( __CLASS__ ); } } add_action( 'widgets_init', array( 'Brimstone_Content_Widget_Jetpack_Testimonials', 'register' ) );