Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am peterbooker on github.
  • I am peterbooker (https://keybase.io/peterbooker) on keybase.
  • I have a public key whose fingerprint is E2D1 65D5 5B52 2988 07AA 1EC8 B872 5CB5 530C 45B7

To claim this, I am signing this object:

@PeterBooker
PeterBooker / autoupdate_plugins.php
Last active August 29, 2015 14:18
WordPress Auto Updates Plugin Whitelist
<?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',
@PeterBooker
PeterBooker / fallback.php
Last active August 29, 2015 14:17
Foundation 5 Top Bar Custom Menu Walker for WordPress
<?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'] ) {
@PeterBooker
PeterBooker / wp-cloudfront.php
Created July 24, 2014 17:09
Make WordPress fully comptible with AWS CloudFront, to use as a full-page caching solution.
<?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() ) {
@PeterBooker
PeterBooker / url_validation.php
Last active August 29, 2015 14:01
WordPress URL Validation Function
<?php
/**
* Validate URLs
*
* @param string $url
* @param boolean $strict
* @return string|boolean
*/
function kbso_validate_url( $url, $strict = false ) {
@PeterBooker
PeterBooker / google_font_importer.php
Created October 28, 2013 15:45
Imports Google Webfonts and creates a Dropdown to select a font from.
<?php
/*
* Google Font Importer
*/
$fonts = "https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyCpfnm5kVng8hhP_jnAnnTXVP7MEUM89-k";
$fonts = file_get_contents($fonts, 0, null, null);
$fp = fopen('fonts.txt', 'w');
@PeterBooker
PeterBooker / plugin_api.php
Last active December 25, 2015 22:29
This gives an example of how to query the wordpress.org plugins API for data on all plugins.
<?php
/*
* Query the wordpress.org Plugins API
*/
$query = array(
'action' => 'query_plugins',
'request' => serialize(
(object) array(
'page' => 1,
@PeterBooker
PeterBooker / twitter_linkify.php
Last active December 23, 2015 07:28
This is taken from my Kebo Twitter Feed plugin for WordPress and linkifies Tweet text (Hashtags, Mentions and URLs).
<?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
<?php
/*
* Display BBC News Headlines
*/
function pb_display_news() {
// Get the News data
$headlines = pb_get_news();
<?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' );