Created
May 3, 2012 23:21
-
-
Save tollmanz/2590362 to your computer and use it in GitHub Desktop.
A Skeleton
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MostDiscussed_Widget extends WP_Widget { | |
private $excluded_posts; | |
function __construct() { | |
} | |
function widget( $args, $instance ) { | |
$excluded_posts = get_transient( 'consumerist_most_discussed_exclude' ); | |
if ( false === $excluded_posts ) | |
$excluded_posts = $this->generate_most_discussed_excluded_posts(); | |
$pop_query = get_transient( 'consumerist_most_discussed_exclude' ); | |
if ( false === $pop_query ) | |
$pop_query = $this->generate_most_discussed_query(); | |
// Get your loop on | |
} | |
function update( $new_instance, $old_instance ) { | |
// Do the normal validation | |
$this->generate_most_discussed_excluded_posts(); | |
$this->generate_most_discussed_query(); | |
return $instance; | |
} | |
function form( $instance ) { | |
} | |
function generate_most_discussed_excluded_posts() { | |
// Query for the excluded posts and save to transient | |
$excluded_posts = wp_list_pluck( $excluded_posts->posts, 'ID' ); | |
set_transient( 'consumerist_most_discussed_exclude', $excluded_posts ); // no expiration | |
$this->excluded_posts = $excluded_posts; | |
return $excluded_posts; | |
} | |
function generate_most_discussed_query() { | |
// Query for most discussed posts and save to transient | |
set_transient( 'consumerist_most_discussed', $pop_query ); // no expiration | |
return $pop_query; | |
} | |
function filter_most_discussed( $where = '' ) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment