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 | |
/** | |
* Validate URLs | |
* | |
* @param string $url | |
* @param boolean $strict | |
* @return string|boolean | |
*/ | |
function kbso_validate_url( $url, $strict = false ) { |
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 | |
/** | |
* Add Last-Modified and Cache-Control Headers to WP Responses | |
*/ | |
function wp_cloudfront_filter_headers( $headers ) { | |
/* | |
* WP already sets Cache-Control headers to avoid caching in the admin. | |
*/ | |
if ( is_admin() ) { |
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 | |
/* | |
* Provide fallback output incase no Menu is selected. | |
*/ | |
public static function fallback( $args = array() ) { | |
/* | |
* No content for left side Fallback | |
*/ | |
if ( 'left' == $args['menu_class'] ) { |
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 | |
/* | |
* Plugin Auto Updates Whitelist | |
* Allows Forced Updates for listed Plugin Slugs | |
*/ | |
function prefix_forced_update_whitelist_plugins( $update, $item ) { | |
// Examples, please add plugin slugs that you trust. | |
$plugins = array ( | |
'jetpack', 'wordpress-seo', 'plugin-slug', |
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 | |
/* | |
* Background Caching with Transients | |
* Using BBC News API as an example | |
*/ | |
function pb_get_news() { | |
/* | |
* Get transient and if expired refresh data immediately |
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 pb_get_news() { | |
/* | |
* Get transient and if expired refresh data immediately | |
*/ | |
if ( false === ( $news = get_transient( 'pb_bbc_news' ) ) ) { | |
// Uses BBC News API to fetch new data |
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 | |
/* | |
* Refreshes the Transient data. | |
*/ | |
function pb_refresh_news() { | |
// Make HTTP request to BBC News API. | |
$response = wp_remote_request( 'http://api.bbcnews.appengine.co.uk/stories/headlines' ); | |
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 | |
/* | |
* Display BBC News Headlines | |
*/ | |
function pb_display_news() { | |
// Get the News data | |
$headlines = pb_get_news(); |
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 | |
/* | |
* Converts Tweet text urls, account names and hashtags into HTML links. | |
* Accepts return data from Twitter API (v1.1) | |
*/ | |
function kebo_twitter_linkify( $tweets ) { | |
foreach ( $tweets as $tweet ) { | |
$hash_length = 45; // Length of HTML added to hashtags |
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 | |
/* | |
* Query the wordpress.org Plugins API | |
*/ | |
$query = array( | |
'action' => 'query_plugins', | |
'request' => serialize( | |
(object) array( | |
'page' => 1, |
OlderNewer