Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
alexkingorg / wp-hide-formats.php
Last active December 17, 2015 13:59
Hide unused post formats in WordPress 3.6.
<?php
/*
Plugin Name: AK.org Hide Post Format Tabs
Plugin URI: https://gist.github.com/alexkingorg/5557869
Description: Reduce the footprint of the post format tabs in the WordPress admin UI.
Version: 1.0
Author: Alex King
Author URI: http://alexking.org
License: GPL2
@alexkingorg
alexkingorg / wp-3.6-minimalist-post-format-tabs.php
Last active December 17, 2015 05:28
Minimalist tabs for the WordPress 3.6 post formats feature.
<?php
/*
Plugin Name: AK.org Minimalist Post Format Tabs
Plugin URI: https://gist.github.com/alexkingorg/5557869
Description: Reduce the footprint of the post format tabs in the WordPress admin UI.
Version: 1.0
Author: Alex King
Author URI: http://alexking.org
License: GPL2
@alexkingorg
alexkingorg / enqueue-heartbeat.php
Last active December 16, 2015 04:59
WordPress 3.5 Compatible Heartbeat API Usage
<?php
// enqueue the script,
// this fails gracefully if no 'heartbeat' script is registered
wp_enqueue_script('heartbeat');
@alexkingorg
alexkingorg / akorg-open-graph.php
Last active October 12, 2015 02:18 — forked from mjangda/wpcom-open-graph.php
Add Open Graph tags to your WordPress site
<?php
/**
* Plugin Name: AK.org Strict Open Graph Tags
* Description: Add Open Graph tags so that Facebook (and any other service that supports them) can crawl the site better and we provide a better sharing experience
* Author: Automattic and Alex King
* License: GPLv2, baby!
*
* @link http://ogp.me/
* @link http://developers.facebook.com/docs/opengraph/
*/
@alexkingorg
alexkingorg / twitter-tools-blog-post-filters-test.php
Created October 24, 2012 23:02
Twitter Tools 3.0 Blog Post Customizations
function aktt_test_skip_blog_post($bool, $data, $tweet) {
// make decisions here
return false; // no post will be created
}
add_filter('aktt_tweet_create_blog_post', 'aktt_test_skip_blog_post', 10, 3);
function aktt_test_skip_status($format, $data, $tweet) {
// return 'aside'; // string will be used as format
return false; // no format will be set
}
@alexkingorg
alexkingorg / wp-add-thumbnail-support.php
Created October 2, 2012 19:38
Add thumbnail support for a post type without stomping old types.
$thumbnails = get_theme_support('post-thumbnails');
if (is_array($thumbnails)) {
add_theme_support('post-thumbnails', array_merge($thumbnails[0], array(self::$post_type)));
}
else if (!$thumbnails) {
add_theme_support('post-thumbnails', array(self::$post_type));
}
// else already enabled for all post types
@alexkingorg
alexkingorg / wp-test-comment-slash.php
Created September 20, 2012 21:51
WordPress unit test to verify that slashed data is saved properly for comments
<?php
/**
* @group comment
* @group slashes
*/
class Tests_Comment_Slashes extends WP_UnitTestCase {
function setUp() {
parent::setUp();
// we need an admin user to bypass comment flood protection
@alexkingorg
alexkingorg / wp-test-postmeta-slash.php
Created September 20, 2012 20:53
WordPress unit test to verify that slashed data is saved properly for post meta
<?php
/**
* @group meta
* @group slashes
* @ticket 21767
*/
class Tests_Meta_Slashes extends WP_UnitTestCase {
function setUp() {
parent::setUp();
@alexkingorg
alexkingorg / wp-test-post-slash.php
Created September 20, 2012 16:33
WordPress unit test to verify that slashed data is saved properly for posts
<?php
/**
* @group post
* @group slashes
*/
class Tests_Post_Slashes extends WP_UnitTestCase {
function setUp() {
parent::setUp();
$this->author_id = $this->factory->user->create( array( 'role' => 'editor' ) );