/** * Front-end display content for recent reviews widget. * * @since 1.0.0 * @since 1.5.1 Declare function public. * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { // prints the widget extract($args, EXTR_SKIP); /** This filter is documented in geodirectory_widgets.php */ $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory')); /** * Filter the number of reviews to display. * * @since 1.0.0 * * @param int $instance['count'] Number of reviews to display. */ $count = empty($instance['count']) ? '5' : apply_filters('widget_count', $instance['count']); /** * Filter the height and width of the avatar image in pixels. * * @since 1.0.0 * * @param int $g_size Height and width of the avatar image in pixels. Default 30. */ $g_size = apply_filters('geodir_recent_reviews_g_size', 30); /** * Filter the excerpt length * * @since 1.0.0 * * @param int $excerpt_length Excerpt length. Default 100. */ $excerpt_length = apply_filters('geodir_recent_reviews_excerpt_length', 100); $comments_li = geodir_get_recent_reviews($g_size, $count, $excerpt_length, false); if ($comments_li) { echo $before_widget; ?> <div class="widget geodir_recent_reviews_section"> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <ul class="geodir_recent_reviews"><?php echo $comments_li; ?> </ul> </div> <?php echo $after_widget; } }
/** * The geodirectory recent reviews shortcode. * * This implements the functionality of the shortcode for displaying recent reviews. * * @since 1.0.0 * @since 1.5.0 New title attribute added. * @package GeoDirectory * @param array $atts { * Attributes of the shortcode. * * @type string $title The title displayed above recent reviews. Default empty. * @type int $count Number of reviews you want to display. Default. 5. * * } * @return string Recent reviews HTML. */ function geodir_sc_recent_reviews($atts) { ob_start(); $defaults = array('title' => '', 'count' => 5); $params = shortcode_atts($defaults, $atts); $count = absint($params['count']); if (0 == $count) { $count = 1; } $title = !empty($params['title']) ? __($params['title'], 'geodirectory') : ''; $comments_li = geodir_get_recent_reviews(30, $count, 100, false); if ($comments_li) { if ($title != '') { ?> <h3 class="geodir-sc-recent-reviews-title widget-title"><?php echo $title; ?> </h3> <?php } ?> <div class="geodir_sc_recent_reviews_section"> <ul class="geodir_sc_recent_reviews"><?php echo $comments_li; ?> </ul> </div> <?php } $output = ob_get_contents(); ob_end_clean(); return $output; }