Skip to content

Instantly share code, notes, and snippets.

View Viper007Bond's full-sized avatar
😎
Writing Code

Alex Mills Viper007Bond

😎
Writing Code
View GitHub Profile
<?php
wp_oembed_add_provider( 'http://instagram.com/p/*', 'http://api.instagram.com/oembed' );
add_shortcode( 'instagram', 'shortcode_instagram' );
function shortcode_instagram( $atts ) {
global $wp_embed;
return $wp_embed->shortcode( $atts, $atts['url'] );
<?php
$items = implode(
', ',
array_merge(
wp_list_pluck( (array) get_the_tags(), 'name' ),
wp_list_pluck( (array) get_the_category(), 'slug' )
)
);
if ( $items ) {
@Viper007Bond
Viper007Bond / gist:3832072
Created October 4, 2012 07:57
WordPress.com's watermarker plugin
<?php
/*
* Plugin Name: WordPress.com Watermark Image Uploads
* Description: Applies a watermark image of your choosing to all uploaded images.
* Author: Alex Mills
* Author URI: http://automattic.com/
*/
class WPcom_Watermark_Uploads {
@Viper007Bond
Viper007Bond / gist:3547740
Created August 31, 2012 01:57
WordPress Date Query Unit Tests
<?php
class Tests_WP_Query_Date_Base extends WP_UnitTestCase {
public $q;
public function setUp() {
parent::setUp();
// Be careful modifying this. Tests are coded to expect this exact sample data.
@Viper007Bond
Viper007Bond / gist:3419572
Created August 21, 2012 21:27
WordPress Stats
<?php
require_once( 'wp-load.php' );
$data = array(
'posts' => wp_count_posts( 'post' )->publish,
'pages' => wp_count_posts( 'page' )->publish,
'categories' => wp_count_terms( 'category' ),
'tags' => wp_count_terms( 'post_tag' ),
'comments' => wp_count_comments()->approved,
@Viper007Bond
Viper007Bond / sticky-custom-post-types.php
Created August 21, 2012 04:33
Bug fixes and coding standards for Sticky Custom Post Types
<?php
/*
Plugin Name: Sticky Custom Post Types
Plugin URI: http://superann.com/sticky-custom-post-types/
Description: Enables support for sticky custom post types. Set options in Settings &rarr; Reading.
Version: 1.2.2
Author: Ann Oyama
Author URI: http://superann.com
License: GPL2
@Viper007Bond
Viper007Bond / sticky-custom-post-types.php
Created August 21, 2012 04:30
Bug fixes for Sticky Custom Post Types
<?php
/*
Plugin Name: Sticky Custom Post Types
Plugin URI: http://superann.com/sticky-custom-post-types/
Description: Enables support for sticky custom post types. Set options in Settings &rarr; Reading.
Version: 1.2.2
Author: Ann Oyama
Author URI: http://superann.com
License: GPL2
@Viper007Bond
Viper007Bond / gist:3259814
Created August 4, 2012 20:45
Custom Post Password Cookie Expiry Time
<?php /*
**************************************************************************
Plugin Name: Custom Post Password Cookie Expiry Time
Description: WordPress doesn't allow you to customize how long a post password cookie lasts. This plugin allows you to customize that value;
Version: 1.0.0
Author: Alex Mills (Viper007Bond)
Author URI: http://www.viper007bond.com/
@Viper007Bond
Viper007Bond / generate-thumbnails.php
Created May 25, 2012 02:33
WordPress: When a thumbnail image is requested of a specific width/height (rather than by name), generate it if it doesn't exist.
<?php /*
**************************************************************************
Plugin Name: Generate Thumbnails On The Fly
Description: When a thumbnail image is requested of a specific width/height (rather than by name), generate it if it doesn't exist.
Version: 1.0.0
Author: Alex Mills (Viper007Bond)
Author URI: http://www.viper007bond.com/
@Viper007Bond
Viper007Bond / gist:2778130
Created May 23, 2012 22:10
Check to see if an e-mail address has a Gravatar or not
<?php
function sunset_has_gravatar( $email ) {
$hash = md5( strtolower( trim( $email ) ) );
// If not in the cache, check again
if ( false === $has_gravatar = wp_cache_get( $hash, 'sunset_has_gravatar' ) ) {
$request = wp_remote_head( 'http://0.gravatar.com/avatar/' . $hash . '?d=404' );