diff --git a/changelog.txt b/changelog.txt index 2b1a2f6..c056999 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ ### Higgs Assistant Changelog +## 1.0.1 - August 30, 2023 +* Fix Testimonials widget +* Fix escaping and conditional checks +* Other minor improvements + ## 1.0.0 - June 16, 2020 * Initial release diff --git a/higgs-assistant.php b/higgs-assistant.php index acb29ca..2eb1cea 100644 --- a/higgs-assistant.php +++ b/higgs-assistant.php @@ -5,7 +5,7 @@ * Description: A plugin to assist Higgs theme in adding widgets. * Author: Codestag * Author URI: https://codestag.com - * Version: 1.0 + * Version: 1.0.1 * Text Domain: higgs-assistant * License: GPL2+ * License URI: https://www.gnu.org/licenses/gpl-2.0.txt @@ -52,7 +52,7 @@ public static function register() { * @since 1.0 */ public function define_constants() { - $this->define( 'HA_VERSION', '1.0' ); + $this->define( 'HA_VERSION', '1.0.1' ); $this->define( 'HA_DEBUG', true ); $this->define( 'HA_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); $this->define( 'HA_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); diff --git a/includes/widgets/portfolio.php b/includes/widgets/portfolio.php index 5b0b99f..5dff7e3 100644 --- a/includes/widgets/portfolio.php +++ b/includes/widgets/portfolio.php @@ -1,92 +1,100 @@ widget_id = 'higgs_portfolio'; - $this->widget_cssclass = 'section-portfolio'; - $this->widget_description = __( 'Display recent portfolio post in grid style.', 'higgs-assistant' ); - $this->widget_name = __( 'Section: Portfolio', 'higgs-assistant' ); - $this->settings = array( - 'title' => array( - 'type' => 'text', - 'std' => '', - 'label' => __( 'Title:', 'higgs-assistant' ), - ), - 'orderby' => array( - 'type' => 'select', - 'std' => 'post_date', - 'label' => __( 'Sort by:', 'higgs-assistant' ), - 'options' => array( - 'post_date' => __( 'Date', 'higgs-assistant' ), - 'title' => __( 'Title', 'higgs-assistant' ), - 'rand' => __( 'Random', 'higgs-assistant' ), + /** + * Displays recent portfolio posts. + * + * @since 1.0.0. + * @package Higgs + */ + class Higgs_Portfolio extends Stag_Widget { + public function __construct() { + $this->widget_id = 'higgs_portfolio'; + $this->widget_cssclass = 'section-portfolio'; + $this->widget_description = __( 'Display recent portfolio post in grid style.', 'higgs-assistant' ); + $this->widget_name = __( 'Section: Portfolio', 'higgs-assistant' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => '', + 'label' => __( 'Title:', 'higgs-assistant' ), ), - ), - 'number' => array( - 'type' => 'number', - 'std' => '6', - 'label' => __( 'Count:', 'higgs-assistant' ), - 'step' => '1', - 'min' => '1', - 'max' => '20', - ), - 'more_text' => array( - 'type' => 'text', - 'std' => __( 'View all Posts', 'higgs-assistant' ), - 'label' => __( 'More Posts text:', 'higgs-assistant' ), - ), - ); - - parent::__construct(); - } + 'orderby' => array( + 'type' => 'select', + 'std' => 'post_date', + 'label' => __( 'Sort by:', 'higgs-assistant' ), + 'options' => array( + 'post_date' => __( 'Date', 'higgs-assistant' ), + 'title' => __( 'Title', 'higgs-assistant' ), + 'rand' => __( 'Random', 'higgs-assistant' ), + ), + ), + 'number' => array( + 'type' => 'number', + 'std' => '6', + 'label' => __( 'Count:', 'higgs-assistant' ), + 'step' => '1', + 'min' => '1', + 'max' => '20', + ), + 'more_text' => array( + 'type' => 'text', + 'std' => __( 'View all Posts', 'higgs-assistant' ), + 'label' => __( 'More Posts text:', 'higgs-assistant' ), + ), + ); + + parent::__construct(); + } - function widget( $args, $instance ) { - if ( $this->get_cached_widget( $args ) ) - return; + function widget( $args, $instance ) { + if ( $this->get_cached_widget( $args ) ) { + return; + } - ob_start(); + ob_start(); - extract( $args ); + extract( $args ); - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); - $orderby = $instance['orderby']; - $number = absint( $instance['number'] ); - $more_text = strip_tags( $instance['more_text'] ); + $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); + $orderby = $instance['orderby']; + $number = absint( $instance['number'] ); + $more_text = wp_strip_all_tags( $instance['more_text'] ); - echo $before_widget; + echo $before_widget; - $link = get_post_type_archive_link( 'jetpack-portfolio' ); + $link = get_post_type_archive_link( 'jetpack-portfolio' ); - if ( $title ) : - echo $before_title; - echo $title; - if ( '' != $link ) : ?> + if ( $title ) : + echo $before_title; + echo $title; + if ( '' !== $link ) : ?> - 'jetpack-portfolio', - 'post_status' => 'publish', - 'orderby' => $orderby, - 'posts_per_page' => $number, - 'no_found_rows' => true, - 'ignore_sticky_posts' => true, - 'meta_query' => array( array( 'key' => '_thumbnail_id' ) ), - ) ) ); - - if ( $p->have_posts() ) : ?> + 'jetpack-portfolio', + 'post_status' => 'publish', + 'orderby' => $orderby, + 'posts_per_page' => $number, + 'no_found_rows' => true, + 'ignore_sticky_posts' => true, + 'meta_query' => array( array( 'key' => '_thumbnail_id' ) ), + ) + ) + ); + + if ( $p->have_posts() ) : + ?>
@@ -99,33 +107,38 @@ function widget( $args, $instance ) {
- have_posts() ) : $p->the_post(); - get_template_part( 'partials/content', 'portfolio-archive' ); - endwhile; ?> + have_posts() ) : + $p->the_post(); + get_template_part( 'partials/content', 'portfolio-archive' ); + endwhile; + ?>
- + ?> - cache_widget( $args, $content ); - } + $this->cache_widget( $args, $content ); + } - public static function register() { - register_widget( __CLASS__ ); + public static function register() { + register_widget( __CLASS__ ); + } } -} endif; add_action( 'widgets_init', array( 'Higgs_Portfolio', 'register' ) ); diff --git a/includes/widgets/recent-posts.php b/includes/widgets/recent-posts.php index ec41b2e..3f555e0 100644 --- a/includes/widgets/recent-posts.php +++ b/includes/widgets/recent-posts.php @@ -1,106 +1,120 @@ widget_id = 'higgs_recent_posts'; - $this->widget_cssclass = 'section-recent-posts'; - $this->widget_description = __( 'Displays recent posts from Blog.', 'higgs-assistant' ); - $this->widget_name = __( 'Section: Recent Posts', 'higgs-assistant' ); - $this->settings = array( - 'title' => array( - 'type' => 'text', - 'std' => 'Latest Posts', - 'label' => __( 'Title:', 'higgs-assistant' ), - ), - 'count' => array( - 'type' => 'number', - 'std' => '3', - 'label' => __( 'Number of posts to show:', 'higgs-assistant' ), - ), - 'post_date' => array( - 'type' => 'checkbox', - 'std' => 'on', - 'label' => __( 'Display Post Date?', 'higgs-assistant' ), - ), - 'category' => array( - 'type' => 'category', - 'std' => '0', - 'label' => __( 'Post Category:', 'higgs-assistant' ), - ), - 'more_text' => array( - 'type' => 'text', - 'std' => __( 'View all Posts', 'higgs-assistant' ), - 'label' => __( 'More Posts text:', 'higgs-assistant' ), - ), - ); - - parent::__construct(); - } - /** - * Widget function. + * Displays latest blog posts. * - * @see WP_Widget - * @access public - * @param array $args - * @param array $instance - * @return void + * @since 1.0.0. + * @package Higgs */ - function widget( $args, $instance ) { - if ( $this->get_cached_widget( $args ) ) - return; - - ob_start(); - - extract( $args ); - - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); - $count = $instance['count']; - $show_date = $instance['post_date']; - $category = $instance['category']; - $more_text = strip_tags( $instance['more_text'] ); - - $posts = wp_get_recent_posts( array( 'post_type' => 'post', 'numberposts' => $count, 'post_status' => 'publish', 'category' => $category ), OBJECT ); - $posts_page = get_option( 'page_for_posts' ); - - if ( 0 == $posts_page ) { - $posts_page = home_url(); - } else { - $posts_page = get_permalink( $posts_page ); + class Higgs_Recent_Posts extends Stag_Widget { + public function __construct() { + $this->widget_id = 'higgs_recent_posts'; + $this->widget_cssclass = 'section-recent-posts'; + $this->widget_description = __( 'Displays recent posts from Blog.', 'higgs-assistant' ); + $this->widget_name = __( 'Section: Recent Posts', 'higgs-assistant' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => 'Latest Posts', + 'label' => __( 'Title:', 'higgs-assistant' ), + ), + 'count' => array( + 'type' => 'number', + 'std' => '3', + 'label' => __( 'Number of posts to show:', 'higgs-assistant' ), + ), + 'post_date' => array( + 'type' => 'checkbox', + 'std' => 'on', + 'label' => __( 'Display Post Date?', 'higgs-assistant' ), + ), + 'category' => array( + 'type' => 'category', + 'std' => '0', + 'label' => __( 'Post Category:', 'higgs-assistant' ), + ), + 'more_text' => array( + 'type' => 'text', + 'std' => __( 'View all Posts', 'higgs-assistant' ), + 'label' => __( 'More Posts text:', 'higgs-assistant' ), + ), + ); + + parent::__construct(); } - global $post; - - echo $before_widget; - ?> + /** + * Widget function. + * + * @see WP_Widget + * @access public + * @param array $args + * @param array $instance + * @return void + */ + function widget( $args, $instance ) { + if ( $this->get_cached_widget( $args ) ) { + return; + } + + ob_start(); + + extract( $args ); + + $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); + $count = $instance['count']; + $show_date = $instance['post_date']; + $category = $instance['category']; + $more_text = wp_strip_all_tags( $instance['more_text'] ); + + $posts = wp_get_recent_posts( + array( + 'post_type' => 'post', + 'numberposts' => $count, + 'post_status' => 'publish', + 'category' => $category, + ), + OBJECT + ); + $posts_page = get_option( 'page_for_posts' ); + + if ( 0 === $posts_page ) { + $posts_page = home_url(); + } else { + $posts_page = get_permalink( $posts_page ); + } + + global $post; + + echo $before_widget; + ?> - cache_widget( $args, $content ); - } + $this->cache_widget( $args, $content ); + } - /** - * Registers the widget with the WordPress Widget API. - * - * @return void. - */ - public static function register() { - register_widget( __CLASS__ ); + /** + * Registers the widget with the WordPress Widget API. + * + * @return void. + */ + public static function register() { + register_widget( __CLASS__ ); + } } -} endif; add_action( 'widgets_init', array( 'Higgs_Recent_Posts', 'register' ) ); diff --git a/includes/widgets/service-option.php b/includes/widgets/service-option.php index b95b044..c07f1bf 100644 --- a/includes/widgets/service-option.php +++ b/includes/widgets/service-option.php @@ -1,88 +1,93 @@ widget_id = 'higgs_service_option'; - $this->widget_cssclass = 'service-option'; - $this->widget_description = __( 'Create a service option for services section.', 'higgs-assistant' ); - $this->widget_name = __( 'Service Box', 'higgs-assistant' ); - $this->settings = array( - 'title' => array( - 'type' => 'text', - 'std' => '', - 'label' => __( 'Title:', 'higgs-assistant' ), - ), - 'icon' => array( - 'type' => 'text', - 'std' => '', - 'label' => __( 'Custom Icon URL:', 'higgs-assistant' ), - ), - 'description' => array( - 'type' => 'textarea', - 'std' => '', - 'rows' => '4', - 'label' => __( 'Description:', 'higgs-assistant' ), - ), - 'description_help' => array( - 'type' => 'description', - 'std' => __( 'Accepts shortcodes/HTML.', 'higgs-assistant' ), - ), - ); - - parent::__construct(); - } - - function widget( $args, $instance ) { - if ( $this->get_cached_widget( $args ) ) - return; - - ob_start(); - - extract( $args ); - - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); - $icon = esc_url( $instance['icon'] ); - $description = stripslashes( $instance['description'] ); - - echo $before_widget; ?> + /** + * Adds a services option, to be ultimately added to services section widget. + * + * @since Higgs 1.0.0. + * + * @package Higgs + */ + class Higgs_Service_Option extends Stag_Widget { + public function __construct() { + $this->widget_id = 'higgs_service_option'; + $this->widget_cssclass = 'service-option'; + $this->widget_description = __( 'Create a service option for services section.', 'higgs-assistant' ); + $this->widget_name = __( 'Service Box', 'higgs-assistant' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => '', + 'label' => __( 'Title:', 'higgs-assistant' ), + ), + 'icon' => array( + 'type' => 'text', + 'std' => '', + 'label' => __( 'Custom Icon URL:', 'higgs-assistant' ), + ), + 'description' => array( + 'type' => 'textarea', + 'std' => '', + 'rows' => '4', + 'label' => __( 'Description:', 'higgs-assistant' ), + ), + 'description_help' => array( + 'type' => 'description', + 'std' => __( 'Accepts shortcodes/HTML.', 'higgs-assistant' ), + ), + ); + + parent::__construct(); + } + + function widget( $args, $instance ) { + if ( $this->get_cached_widget( $args ) ) { + return; + } + + ob_start(); + + extract( $args ); + + $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); + $icon = esc_url( $instance['icon'] ); + $description = stripslashes( $instance['description'] ); + + echo $before_widget; ?>
- +
<?php echo esc_attr( $title ); ?>
- + - +
- +
- cache_widget( $args, $content ); - } + $this->cache_widget( $args, $content ); + } - public static function register() { - register_widget( __CLASS__ ); + public static function register() { + register_widget( __CLASS__ ); + } } -} endif; add_action( 'widgets_init', array( 'Higgs_Service_Option', 'register' ) ); diff --git a/includes/widgets/service-section.php b/includes/widgets/service-section.php index 1f3347b..95b45cb 100644 --- a/includes/widgets/service-section.php +++ b/includes/widgets/service-section.php @@ -1,82 +1,84 @@ widget_id = 'higgs_service_section'; - $this->widget_cssclass = 'service-section'; - $this->widget_description = __( 'Output the service section (based on the “Services widget area”).', 'higgs-assistant' ); - $this->widget_name = __( 'Section: Services', 'higgs-assistant' ); - $this->settings = array( - 'title' => array( - 'type' => 'text', - 'std' => __( 'Our Services', 'higgs-assistant' ), - 'label' => __( 'Title:', 'higgs-assistant' ), - ), - 'link_text' => array( - 'type' => 'text', - 'std' => '', - 'label' => __( 'Custom Link Text (Optional):', 'higgs-assistant' ), - ), - 'link' => array( - 'type' => 'text', - 'std' => '', - 'label' => __( 'Custom Link URL (Optional):', 'higgs-assistant' ), - ), - ); + /** + * Shows service section, populated by 'Services widget area'. + * + * @since Higgs 1.0.0. + * + * @package Higgs + */ + class Higgs_Service_Section extends Stag_Widget { + public function __construct() { + $this->widget_id = 'higgs_service_section'; + $this->widget_cssclass = 'service-section'; + $this->widget_description = __( 'Output the service section (based on the “Services widget area”).', 'higgs-assistant' ); + $this->widget_name = __( 'Section: Services', 'higgs-assistant' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => __( 'Our Services', 'higgs-assistant' ), + 'label' => __( 'Title:', 'higgs-assistant' ), + ), + 'link_text' => array( + 'type' => 'text', + 'std' => '', + 'label' => __( 'Custom Link Text (Optional):', 'higgs-assistant' ), + ), + 'link' => array( + 'type' => 'text', + 'std' => '', + 'label' => __( 'Custom Link URL (Optional):', 'higgs-assistant' ), + ), + ); - parent::__construct(); - } + parent::__construct(); + } - function widget( $args, $instance ) { - if ( $this->get_cached_widget( $args ) ) - return; + function widget( $args, $instance ) { + if ( $this->get_cached_widget( $args ) ) { + return; + } - ob_start(); + ob_start(); - extract( $args ); + extract( $args ); - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); - $link = esc_url( $instance['link'] ); - $link_text = $instance['link_text']; + $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); + $link = esc_url( $instance['link'] ); + $link_text = $instance['link_text']; - echo $before_widget; + echo $before_widget; - if ( $title ) : - echo $before_title; - echo $title; - if ( '' != $link ) : ?> + if ( $title ) : + echo $before_title; + echo $title; + if ( '' !== $link ) : ?> - cache_widget( $args, $content ); - } + $this->cache_widget( $args, $content ); + } - public static function register() { - register_widget( __CLASS__ ); + public static function register() { + register_widget( __CLASS__ ); + } } -} endif; add_action( 'widgets_init', array( 'Higgs_Service_Section', 'register' ) ); diff --git a/includes/widgets/stag-widget.php b/includes/widgets/stag-widget.php index e652454..edcc52e 100644 --- a/includes/widgets/stag-widget.php +++ b/includes/widgets/stag-widget.php @@ -38,11 +38,12 @@ public function __construct() { function get_cached_widget( $args ) { $cache = wp_cache_get( $this->widget_id, 'widget' ); - if ( ! is_array( $cache ) ) + if ( ! is_array( $cache ) ) { $cache = array(); + } - if ( isset( $cache[ $args[ 'widget_id' ] ] ) ) { - echo $cache[ $args[ 'widget_id' ] ]; + if ( isset( $cache[ $args['widget_id'] ] ) ) { + echo $cache[ $args['widget_id'] ]; return true; } @@ -55,7 +56,7 @@ function get_cached_widget( $args ) { * @return void */ public function cache_widget( $args, $content ) { - $cache[ $args[ 'widget_id' ] ] = $content; + $cache[ $args['widget_id'] ] = $content; wp_cache_set( $this->widget_id, $cache, 'widget' ); } @@ -81,23 +82,25 @@ public function flush_widget_cache() { function update( $new_instance, $old_instance ) { $instance = $old_instance; - if ( ! $this->settings ) + if ( ! $this->settings ) { return $instance; + } foreach ( $this->settings as $key => $setting ) { - switch ( $setting[ 'type' ] ) { - case 'textarea' : - if ( current_user_can( 'unfiltered_html' ) ) - $instance[ $key ] = $new_instance[ $key ]; - else - $instance[ $key ] = wp_kses_data( $new_instance[ $key ] ); - break; - case 'number' : - $instance[ $key ] = absint( $new_instance[ $key ] ); - break; - default : - $instance[ $key ] = sanitize_text_field( $new_instance[ $key ] ); - break; + switch ( $setting['type'] ) { + case 'textarea': + if ( current_user_can( 'unfiltered_html' ) ) { + $instance[ $key ] = isset( $new_instance[ $key ] ) ? $new_instance[ $key ] : ''; + } else { + $instance[ $key ] = isset( $new_instance[ $key ] ) ? wp_kses_data( $new_instance[ $key ] ) : ''; + } + break; + case 'number': + $instance[ $key ] = isset( $new_instance[ $key ] ) ? absint( $new_instance[ $key ] ) : ''; + break; + default: + $instance[ $key ] = isset( $new_instance[ $key ] ) ? sanitize_text_field( $new_instance[ $key ] ) : ''; + break; } } @@ -116,58 +119,59 @@ function update( $new_instance, $old_instance ) { */ function form( $instance ) { - if ( ! $this->settings ) + if ( ! $this->settings ) { return; + } foreach ( $this->settings as $key => $setting ) { - $value = isset( $instance[ $key ] ) ? $instance[ $key ] : $setting[ 'std' ]; + $value = isset( $instance[ $key ] ) ? $instance[ $key ] : $setting['std']; - switch ( $setting[ 'type' ] ) { - case 'description' : + switch ( $setting['type'] ) { + case 'description': ?>

- +

- +

- +

0 ); - if ( isset( $setting['taxonomy'] ) ) $args['taxonomy'] = $setting['taxonomy']; + if ( isset( $setting['taxonomy'] ) ) { + $args['taxonomy'] = $setting['taxonomy']; + } $categories = get_categories( $args ); ?>

- +

- - + +

- - + +

- +

widget_id = 'higgs_static_content'; - $this->widget_cssclass = 'static-content'; - $this->widget_description = __( 'Displays content from a specific page.', 'higgs-assistant' ); - $this->widget_name = __( 'Section: Static Content', 'higgs-assistant' ); - $this->settings = array( - 'title' => array( - 'type' => 'text', - 'std' => '', - 'label' => __( 'Title:', 'higgs-assistant' ), - ), - 'page' => array( - 'type' => 'page', - 'std' => '', - 'label' => __( 'Select Page:', 'higgs-assistant' ), - ), - ); - - parent::__construct(); - } - - /** - * Widget function. + * Display static content from an specific page. * - * @see WP_Widget - * @access public - * @param array $args - * @param array $instance - * @return void + * @since Higgs 1.0.0. + * + * @package Higgs */ - function widget( $args, $instance ) { - if ( $this->get_cached_widget( $args ) ) - return; - - ob_start(); - - extract( $args ); - - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); - $page = $instance[ 'page' ]; - $post = new WP_Query( array( 'page_id' => $page ) ); - - echo $before_widget; - - // Allow site-wide customization of the 'Read more' link text - $read_more = apply_filters( 'higgs_read_more_text', __( 'Read more', 'higgs-assistant' ) ); - ?> + class Higgs_Widget_Static_Content extends Stag_Widget { + /** + * Constructor + */ + public function __construct() { + $this->widget_id = 'higgs_static_content'; + $this->widget_cssclass = 'static-content'; + $this->widget_description = __( 'Displays content from a specific page.', 'higgs-assistant' ); + $this->widget_name = __( 'Section: Static Content', 'higgs-assistant' ); + $this->settings = array( + 'title' => array( + 'type' => 'text', + 'std' => '', + 'label' => __( 'Title:', 'higgs-assistant' ), + ), + 'page' => array( + 'type' => 'page', + 'std' => '', + 'label' => __( 'Select Page:', 'higgs-assistant' ), + ), + ); + + parent::__construct(); + } + + /** + * Widget function. + * + * @see WP_Widget + * @access public + * @param array $args + * @param array $instance + * @return void + */ + function widget( $args, $instance ) { + if ( $this->get_cached_widget( $args ) ) { + return; + } + + ob_start(); + + extract( $args ); + + $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); + $page = $instance['page']; + $post = new WP_Query( array( 'page_id' => $page ) ); + + echo $before_widget; + + // Allow site-wide customization of the 'Read more' link text + $read_more = apply_filters( 'higgs_read_more_text', __( 'Read more', 'higgs-assistant' ) ); + ?>
have_posts() ) : ?> - have_posts() ) : $post->the_post(); ?> + have_posts() ) : + $post->the_post(); + ?>
> - +
@@ -74,27 +81,27 @@ function widget( $args, $instance ) {
- cache_widget( $args, $content ); - } + $this->cache_widget( $args, $content ); + } - /** - * Registers the widget with the WordPress Widget API. - * - * @return void. - */ - public static function register() { - register_widget( __CLASS__ ); + /** + * Registers the widget with the WordPress Widget API. + * + * @return void. + */ + public static function register() { + register_widget( __CLASS__ ); + } } -} endif; add_action( 'widgets_init', array( 'Higgs_Widget_Static_Content', 'register' ) ); diff --git a/includes/widgets/testimonials.php b/includes/widgets/testimonials.php index 73d97f6..fd0c45e 100644 --- a/includes/widgets/testimonials.php +++ b/includes/widgets/testimonials.php @@ -1,113 +1,122 @@ widget_id = 'higgs_testimonials'; - $this->widget_cssclass = 'section-testimonials'; - $this->widget_description = __( 'Displays the testimonails in a simple slideshow.', 'higgs-assistant' ); - $this->widget_name = __( 'Section: Testimonials', 'higgs-assistant' ); - $this->settings = array( - 'orderby' => array( - 'type' => 'select', - 'std' => 'post_date', - 'label' => __( 'Sort by:', 'higgs-assistant' ), - 'options' => array( - 'post_date' => __( 'Date', 'higgs-assistant' ), - 'title' => __( 'Title', 'higgs-assistant' ), - 'rand' => __( 'Random', 'higgs-assistant' ), + /** + * Adds a simple Testimonials cycle slideshow. + * + * @since 1.0.0. + * @package Higgs + */ + class Higgs_Testimonials extends Stag_Widget { + public function __construct() { + $this->widget_id = 'higgs_testimonials'; + $this->widget_cssclass = 'section-testimonials'; + $this->widget_description = __( 'Displays the testimonails in a simple slideshow.', 'higgs-assistant' ); + $this->widget_name = __( 'Section: Testimonials', 'higgs-assistant' ); + $this->settings = array( + 'orderby' => array( + 'type' => 'select', + 'std' => 'post_date', + 'label' => __( 'Sort by:', 'higgs-assistant' ), + 'options' => array( + 'post_date' => __( 'Date', 'higgs-assistant' ), + 'title' => __( 'Title', 'higgs-assistant' ), + 'rand' => __( 'Random', 'higgs-assistant' ), + ), ), - ), - 'number' => array( - 'type' => 'number', - 'std' => '5', - 'label' => __( 'Count:', 'higgs-assistant' ), - 'step' => '1', - 'min' => '1', - 'max' => '20', - ), - ); - - parent::__construct(); - } - - function widget( $args, $instance ) { - if ( $this->get_cached_widget( $args ) ) - return; - - ob_start(); - - extract( $args ); - - $orderby = $instance['orderby']; - $number = absint( $instance['number'] ); - - echo $before_widget; - - $t = new WP_Query( apply_filters( 'higgs_testimonials_args', array( - 'post_type' => 'jetpack-testimonial', - 'post_status' => 'publish', - 'orderby' => $orderby, - 'no_found_rows' => true, - 'posts_per_page' => $number, - 'ignore_sticky_posts' => true, - ) ) ); - - $classes = 'higgs-testimonial-slider cycle-slideshow'; - - // Data attributes - $data_attributes = ' data-cycle-log="false"'; - $data_attributes .= ' data-cycle-slides=".cycle-slide"'; - $data_attributes .= ' data-cycle-auto-height="calc"'; - $data_attributes .= ' data-cycle-center-horz="true"'; - $data_attributes .= ' data-cycle-center-vert="true"'; - $data_attributes .= ' data-cycle-swipe="true"'; - $data_attributes .= ' data-cycle-paused="true"'; - $data_attributes .= ' data-cycle-timeout="6000"'; - $data_attributes .= ' data-cycle-fx="fade"'; - - if ( $t->have_posts() ) : ?> + 'number' => array( + 'type' => 'number', + 'std' => '5', + 'label' => __( 'Count:', 'higgs-assistant' ), + 'step' => '1', + 'min' => '1', + 'max' => '20', + ), + ); + + parent::__construct(); + } + + function widget( $args, $instance ) { + if ( $this->get_cached_widget( $args ) ) { + return; + } + + ob_start(); + + extract( $args ); + + $orderby = $instance['orderby']; + $number = absint( $instance['number'] ); + + echo $before_widget; + + $t = new WP_Query( + apply_filters( + 'higgs_testimonials_args', + array( + 'post_type' => 'jetpack-testimonial', + 'post_status' => 'publish', + 'orderby' => $orderby, + 'no_found_rows' => true, + 'posts_per_page' => $number, + 'ignore_sticky_posts' => true, + ) + ) + ); + + $classes = 'higgs-testimonial-slider cycle-slideshow'; + + // Data attributes + $data_attributes = ' data-cycle-log=false'; + $data_attributes .= ' data-cycle-slides=.cycle-slide'; + $data_attributes .= ' data-cycle-auto-height=calc'; + $data_attributes .= ' data-cycle-center-horz=true'; + $data_attributes .= ' data-cycle-center-vert=true'; + $data_attributes .= ' data-cycle-swipe=true'; + $data_attributes .= ' data-cycle-paused=true'; + $data_attributes .= ' data-cycle-timeout=6000'; + $data_attributes .= ' data-cycle-fx=fade'; + + if ( $t->have_posts() ) : ?>
> - have_posts() ) : $t->the_post(); ?> + have_posts() ) : + $t->the_post(); + ?>
>
- +

- + - post_count ) : ?> + post_count ) : ?>
/
- cache_widget( $args, $content ); - } + $this->cache_widget( $args, $content ); + } - public static function register() { - register_widget( __CLASS__ ); + public static function register() { + register_widget( __CLASS__ ); + } } -} endif; add_action( 'widgets_init', array( 'Higgs_Testimonials', 'register' ) );