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 | |
// Take from posts-to-posts (http://scribu.net/wordpress/posts-to-posts) | |
public function get_related( $post_id, $extra_qv = array() ) { | |
$post_id = (array) $post_id; | |
$connected = $this->get_connected( $post_id, $extra_qv ); | |
if ( !$connected ) | |
return false; | |
if ( !$connected->have_posts() ) |
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 | |
function get_hottest_cities( $force = false ) { | |
$hottest_cities = get_transient( 'zdt-hottest-cities' ); | |
if ( false === $hottest_cities || $force ) { | |
$hottest_cities = retrieve_hottest_cities(); | |
if ( $hottest_cities ) | |
set_transient( 'zdt-hottest-cities', $hottest_cities ); | |
} | |
return $hottest_cities; |
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 | |
function get_hottest_cities( $force = false ) { | |
$hottest_cities = get_transient( 'zdt-hottest-cities' ); | |
if ( false === $hottest_cities || $force ) { | |
if ( $force ) { | |
$hottest_cities = retrieve_hottest_cities(); | |
if ( $hottest_cities ) { | |
set_transient( 'zdt-hottest-cities', $hottest_cities ); |
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 | |
/** | |
* Get a unique ID key for current $wp_the_query object. | |
* | |
* @return string|int unique key on success, 0 on failure | |
*/ | |
function zdt_get_object_key() { | |
$queried_object = get_queried_object(); | |
$queried_object_id = get_queried_object_id(); |
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 | |
function ohsc_get_ratings( $prime_cache = false ) { | |
$movies = array( | |
'The Usual Suspects', | |
'Braveheart', | |
'The King\s Speech' | |
); | |
$cache_key = 'ohsc-' . serialize( $movies ); | |
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 | |
function ohsc_add_get_ratings_refresh() { | |
$button = array( | |
'id' => 'ohsc-add-get-ratings-refresh', | |
'title' => 'Movie Ratings', | |
'function' => 'ohsc_get_ratings', | |
'args' => array( true ), | |
); | |
afc_add_item( $button ); | |
} |
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
.gist { | |
color: #e4322e; | |
} | |
.gistdiv { | |
padding: 0; | |
margin: 0; | |
} | |
.gist .gist-file { |
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 | |
function zt_get_top_posts() { | |
// Define the cache key | |
$cache_key = 'zt-top-posts'; | |
// Attempt to get data from cache | |
$top_posts = wp_cache_get( $cache_key ); | |
// If not found in cache regenerate | |
if ( false === $top_posts ) { |
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 | |
function zt_generate_top_posts() { | |
// These URLs will not be be returned | |
$blacklisted_paths = array( | |
'/', | |
'about-us', | |
'that-page-no-one-needed-to-see' | |
); | |
// URLs with these components will not be returned |
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 | |
function zt_get_top_posts( $force = false ) { | |
// Define our cache key | |
$cache_key = 'zt-top-posts'; | |
// Attempt to grab data from cache | |
$top_posts = wp_cache_get( $cache_key ); | |
// If not found in cache or forced, regenerate | |
if ( false === $top_posts || true === $force ) { |