Exemple #1
0
 /**
  * Default widget front end display method.
  *
  * @since 1.0.0
  *
  * @param array $args Args specific to the widget area (sidebar).
  * @param array $instance Widget instance settings.
  */
 function widget($args, $instance)
 {
     extract($args);
     $instance['title_raw'] = $instance['title'];
     $instance['title'] = apply_filters('widget_title', empty($instance['title']) ? get_the_title($instance['post_id']) : $instance['title'], $instance, $this->id_base);
     $instance['title'] = apply_filters('audiotheme_widget_title', $instance['title'], $instance, $args, $this->id_base);
     echo $before_widget;
     // Output filter is for backwards compatibility.
     if ($output = apply_filters('audiotheme_widget_video_output', '', $instance, $args)) {
         echo empty($instance['title']) ? '' : $before_title . $instance['title'] . $after_title;
         echo $output;
     } else {
         $post = get_post($instance['post_id']);
         $image_size = apply_filters('audiotheme_widget_video_image_size', 'thumbnail', $instance, $args);
         $image_size = apply_filters('audiotheme_widget_video_image_size-' . $args['id'], $image_size, $instance, $args);
         $data = array();
         $data['args'] = $args;
         $data['after_title'] = $args['after_title'];
         $data['before_title'] = $args['before_title'];
         $data['image_size'] = $image_size;
         $data['post'] = get_post($instance['post_id']);
         $data = array_merge($instance, $data);
         $template = audiotheme_locate_template(array("widgets/{$args['id']}_video.php", 'widgets/video.php'));
         audiotheme_load_template($template, $data);
     }
     echo $after_widget;
 }
 /**
  * Default widget front end display method.
  *
  * @since 1.0.0
  *
  * @param array $args Args specific to the widget area (sidebar).
  * @param array $instance Widget instance settings.
  */
 function widget($args, $instance)
 {
     $cache = (array) wp_cache_get('audiotheme_widget_upcoming_gigs', 'widget');
     if (isset($cache[$this->id])) {
         echo $cache[$this->id];
         return;
     }
     extract($args);
     $instance['title_raw'] = empty($instance['title']) ? '' : $instance['title'];
     $instance['title'] = apply_filters('widget_title', empty($instance['title']) ? __('Upcoming Gigs', 'audiotheme') : $instance['title'], $instance, $this->id_base);
     $instance['title'] = apply_filters('audiotheme_widget_title', $instance['title'], $instance, $args, $this->id_base);
     $instance['date_format'] = apply_filters('audiotheme_widget_upcoming_gigs_date_format', get_option('date_format'));
     $instance['number'] = empty($instance['number']) || !absint($instance['number']) ? 5 : absint($instance['number']);
     $loop = new Audiotheme_Gig_Query(apply_filters('audiotheme_widget_upcoming_gigs_loop_args', array('no_found_rows' => true, 'posts_per_page' => $instance['number'])));
     // Add a class with the number of gigs to display.
     $output = preg_replace('/class="([^"]+)"/', 'class="$1 widget-items-' . $instance['number'] . '"', $before_widget);
     if ($inside = apply_filters('audiotheme_widget_upcoming_gigs_output', '', $instance, $args, $loop)) {
         // Call loop have_posts() for backwards compatibility with themes
         // that don't call it in their filters.
         $loop->have_posts();
         $output .= empty($instance['title']) ? '' : $before_title . $instance['title'] . $after_title;
         $output .= $inside;
     } else {
         $data = array();
         $data['args'] = $args;
         $data['after_title'] = $args['after_title'];
         $data['before_title'] = $args['before_title'];
         $data['loop'] = $loop;
         $data = array_merge($instance, $data);
         ob_start();
         $template = audiotheme_locate_template(array("widgets/{$args['id']}_upcoming-gigs.php", 'widgets/upcoming-gigs.php'));
         audiotheme_load_template($template, $data);
         $output .= ob_get_clean();
     }
     wp_reset_postdata();
     $output .= $after_widget;
     echo $output;
     $cache[$this->id] = $output;
     wp_cache_set('audiotheme_widget_upcoming_gigs', $cache, 'widget');
 }
 /**
  * Helper method to generate widget output.
  *
  * @since 1.0.0
  *
  * @param array $args Args specific to the widget area (sidebar).
  * @param array $instance Widget instance settings.
  */
 function render($args, $instance)
 {
     $output = $args['before_widget'];
     // Allow the output to be filtered.
     if ($inside = apply_filters('audiotheme_widget_recent_posts_output', '', $instance, $args)) {
         $output .= $inside;
     } else {
         $data = array();
         $data['args'] = $args;
         $data['after_title'] = $args['after_title'];
         $data['before_title'] = $args['before_title'];
         $data['feed_link'] = 'post' === $instance['post_type'] ? get_bloginfo('rss2_url') : get_post_type_archive_feed_link($instance['post_type']);
         $data['instance'] = $instance;
         $data['loop'] = new WP_Query($instance['loop_args']);
         $data['show_date'] = !empty($instance['show_date']);
         $data['show_excerpts'] = !empty($instance['show_excerpts']);
         $data['show_feed_link'] = !empty($instance['show_feed_link']) && !empty($data['feed_link']);
         $data['title'] = empty($instance['title']) ? '' : $instance['title'];
         $data = array_merge($instance, $data);
         ob_start();
         $template = audiotheme_locate_template(array("widgets/{$args['id']}_recent-posts.php", 'widgets/recent-posts.php'));
         audiotheme_load_template($template, $data);
         $output .= ob_get_clean();
         wp_reset_postdata();
     }
     $output .= $args['after_widget'];
     return $output;
 }