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
@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 / 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 / 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: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 {
<?php
$items = implode(
', ',
array_merge(
wp_list_pluck( (array) get_the_tags(), 'name' ),
wp_list_pluck( (array) get_the_category(), 'slug' )
)
);
if ( $items ) {
<?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'] );
@Viper007Bond
Viper007Bond / gist:4153141
Created November 27, 2012 08:35
Auto-play YouTube embeds
<?php
add_filter( 'embed_oembed_html', 'blogsuccessjrnl_youtube_autoplay', 10, 4 );
function blogsuccessjrnl_youtube_autoplay( $html, $url, $attr, $post_ID ) {
// Abort if not in a single-post view. You don't want these auto-playing on you homepage.
if ( ! is_singular() )
return $html;
<?php
$current_category = get_queried_object();
if ( $current_category->category_parent ) {
$parent_category = get_category( $current_category->category_parent );
$parent = $parent_category->name;
}
<?php
class WP_Widget_Text_HTML_In_Title extends WP_Widget {
function __construct() {
$widget_ops = array( 'classname' => 'widget_text_html_in_title', 'description' => 'Arbitrary text or HTML. Allows HTML in title field.' );
$control_ops = array( 'width' => 400, 'height' => 350 );
parent::__construct( 'text-html-in-title', 'Text (Allows HTML In Title)', $widget_ops, $control_ops );
}
<?php
add_action( 'plugins_loaded', 'tomnelseon_remove_birchschedule_hook' );
function tomnelseon_remove_birchschedule_hook() {
global $birchschedule;
remove_action( 'wp_ajax_birs_get_avaliable_time', array( $birchschedule->shortcode, 'ajax_get_avaliable_time' ) );
}