/**
  * Display the widget on the frontend.
  * @since  1.0.0
  * @param  array $args     Widget arguments.
  * @param  array $instance Widget settings for this instance.
  * @return void
  */
 public function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     /* Our variables from the widget settings. */
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     /* Before widget (defined by themes). */
     $args = array();
     $args['before'] = $before_widget;
     /* After widget (defined by themes). */
     $args['after'] = $after_widget;
     /* Display the widget title if one was input (before and after defined by themes). */
     if ($title) {
         $args['title'] = $title;
         $args['before_title'] = $before_title;
         $args['after_title'] = $after_title;
     }
     /* Widget content. */
     // Add actions for plugins/themes to hook onto.
     do_action($this->woothemes_widget_cssclass . '_top');
     // Integer values.
     if (isset($instance['limit']) && 0 < count($instance['limit'])) {
         $args['limit'] = intval($instance['limit']);
     }
     if (isset($instance['specific_id']) && 0 < count($instance['specific_id'])) {
         $args['id'] = intval($instance['specific_id']);
     }
     if (isset($instance['size']) && 0 < count($instance['size'])) {
         $args['size'] = intval($instance['size']);
     }
     if (isset($instance['per_row']) && 0 < count($instance['per_row'])) {
         $args['per_row'] = intval($instance['per_row']);
     }
     if (isset($instance['category']) && is_numeric($instance['category'])) {
         $args['category'] = intval($instance['category']);
     }
     // Boolean values.
     if (isset($instance['link_title']) && $instance['link_title'] == true && $instance['custom_links_only'] == false) {
         $args['link_title'] = true;
         $args['custom_links_only'] = false;
     } elseif (isset($instance['link_title']) && $instance['link_title'] == true && isset($instance['custom_links_only']) && $instance['custom_links_only'] == true) {
         $args['link_title'] = true;
         $args['custom_links_only'] = true;
     } elseif (isset($instance['link_title']) && $instance['link_title'] == false && isset($instance['custom_links_only']) && $instance['custom_links_only'] == false) {
         $args['link_title'] = false;
         $args['custom_links_only'] = false;
     }
     // Select boxes.
     if (isset($instance['orderby']) && in_array($instance['orderby'], array_keys($this->get_orderby_options()))) {
         $args['orderby'] = $instance['orderby'];
     }
     if (isset($instance['order']) && in_array($instance['order'], array_keys($this->get_order_options()))) {
         $args['order'] = $instance['order'];
     }
     // Display the features.
     woothemes_features($args);
     // Add actions for plugins/themes to hook onto.
     do_action($this->woothemes_widget_cssclass . '_bottom');
 }
 function woothemes_features_shortcode($atts, $content = null)
 {
     $args = (array) $atts;
     $defaults = array('limit' => 5, 'orderby' => 'menu_order', 'order' => 'DESC', 'id' => 0, 'echo' => true, 'size' => 50, 'per_row' => 3, 'link_title' => true);
     $args = shortcode_atts($defaults, $atts);
     // Make sure we return and don't echo.
     $args['echo'] = false;
     // Fix integers.
     if (isset($args['limit'])) {
         $args['limit'] = intval($args['limit']);
     }
     if (isset($args['id'])) {
         $args['id'] = intval($args['id']);
     }
     if (isset($args['size']) && 0 < intval($args['size'])) {
         $args['size'] = intval($args['size']);
     }
     if (isset($args['per_row']) && 0 < intval($args['per_row'])) {
         $args['per_row'] = intval($args['per_row']);
     }
     // Fix booleans.
     foreach (array('link_title') as $k => $v) {
         if (isset($args[$v]) && 'true' == $args[$v]) {
             $args[$v] = true;
         } else {
             $args[$v] = false;
         }
     }
     return woothemes_features($args);
 }
 /**
  * The shortcode function.
  * @since  1.0.0
  * @param  array  $atts    Shortcode attributes.
  * @param  string $content If the shortcode is a wrapper, this is the content being wrapped.
  * @return string          Output using the template tag.
  */
 function woothemes_features_shortcode($atts, $content = null)
 {
     $args = (array) $atts;
     $defaults = array('limit' => 5, 'orderby' => 'menu_order', 'order' => 'DESC', 'id' => 0, 'echo' => true, 'size' => 150, 'per_row' => 3, 'link_title' => true, 'custom_links_only' => false, 'category' => 0);
     $args = shortcode_atts($defaults, $atts);
     // Make sure we return and don't echo.
     $args['echo'] = false;
     // Fix integers.
     if (isset($args['limit'])) {
         $args['limit'] = intval($args['limit']);
     }
     if (isset($args['id'])) {
         $args['id'] = intval($args['id']);
     }
     if (isset($args['size'])) {
         if (is_numeric($args['size'])) {
             $args['size'] = intval($args['size']);
         } else {
             $size = sanitize_title_with_dashes($args['size']);
             $args['size'] = in_array($size, get_intermediate_image_sizes()) ? $size : 'thumbnail';
         }
     }
     if (isset($args['per_row']) && 0 < intval($args['per_row'])) {
         $args['per_row'] = intval($args['per_row']);
     }
     if (isset($args['category']) && is_numeric($args['category'])) {
         $args['category'] = intval($args['category']);
     }
     // Fix booleans.
     foreach (array('link_title', 'custom_links_only') as $k => $v) {
         if (isset($args[$v]) && 'true' == $args[$v]) {
             $args[$v] = true;
         } else {
             $args[$v] = false;
         }
     }
     return woothemes_features($args);
 }