- Timestamp:
- 01/22/2015 12:41:36 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyeleven/inc/widgets.php
r27597 r31265 23 23 $this->alt_option_name = 'widget_twentyeleven_ephemera'; 24 24 25 add_action( 'save_post', array( &$this, 'flush_widget_cache' ) );26 add_action( 'deleted_post', array( &$this, 'flush_widget_cache' ) );27 add_action( 'switch_theme', array( &$this, 'flush_widget_cache' ) );25 add_action( 'save_post', array( &$this, 'flush_widget_cache' ) ); 26 add_action( 'deleted_post', array( &$this, 'flush_widget_cache' ) ); 27 add_action( 'switch_theme', array( &$this, 'flush_widget_cache' ) ); 28 28 } 29 29 … … 39 39 $cache = wp_cache_get( 'widget_twentyeleven_ephemera', 'widget' ); 40 40 41 if ( ! is_array( $cache ) )41 if ( ! is_array( $cache ) ) 42 42 $cache = array(); 43 43 … … 45 45 $args['widget_id'] = null; 46 46 47 if ( isset( $cache[ $args['widget_id']] ) ) {48 echo $cache[ $args['widget_id']];47 if ( isset( $cache[ $args['widget_id'] ] ) ) { 48 echo $cache[ $args['widget_id'] ]; 49 49 return; 50 50 } … … 54 54 55 55 /** This filter is documented in wp-includes/default-widgets.php */ 56 $ title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Ephemera', 'twentyeleven' ) : $instance['title'], $instance, $this->id_base);56 $args['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Ephemera', 'twentyeleven' ) : $instance['title'], $instance, $this->id_base ); 57 57 58 58 if ( ! isset( $instance['number'] ) ) 59 59 $instance['number'] = '10'; 60 60 61 if ( ! $ number= absint( $instance['number'] ) )62 $number= 10;61 if ( ! $args['number'] = absint( $instance['number'] ) ) 62 $args['number'] = 10; 63 63 64 64 $ephemera_args = array( 65 'order' => 'DESC',66 'posts_per_page' => $ number,67 'no_found_rows' => true,68 'post_status' => 'publish',69 'post__not_in' => get_option( 'sticky_posts' ),70 'tax_query' => array(65 'order' => 'DESC', 66 'posts_per_page' => $args['number'], 67 'no_found_rows' => true, 68 'post_status' => 'publish', 69 'post__not_in' => get_option( 'sticky_posts' ), 70 'tax_query' => array( 71 71 array( 72 72 'taxonomy' => 'post_format', 73 'terms' => array( 'post-format-aside', 'post-format-link', 'post-format-status', 'post-format-quote' ),74 'field' => 'slug',73 'terms' => array( 'post-format-aside', 'post-format-link', 'post-format-status', 'post-format-quote' ), 74 'field' => 'slug', 75 75 'operator' => 'IN', 76 76 ), … … 80 80 81 81 if ( $ephemera->have_posts() ) : 82 echo $ before_widget;83 echo $ before_title;84 echo $ title; // Can set this with a widget option, or omit altogether85 echo $a fter_title;82 echo $args['before_widget']; 83 echo $args['before_title']; 84 echo $args['title']; 85 echo $args['after_title']; 86 86 ?> 87 87 <ol> … … 112 112 <?php 113 113 114 echo $a fter_widget;114 echo $args['after_widget']; 115 115 116 116 // Reset the post globals as this query will have stomped on it … … 120 120 endif; 121 121 122 $cache[ $args['widget_id']] = ob_get_flush();122 $cache[ $args['widget_id'] ] = ob_get_flush(); 123 123 wp_cache_set( 'widget_twentyeleven_ephemera', $cache, 'widget' ); 124 124 }
Note: See TracChangeset
for help on using the changeset viewer.