Skip to content

Instantly share code, notes, and snippets.

View ericmann's full-sized avatar
⚒️
Creating ...

Eric Mann ericmann

⚒️
Creating ...
View GitHub Profile
<?php
/*
author: jeedo aquino
file: wp-index-redis.php
credit: jim westergren
updated: 2012-10-23
this is a redis caching system for wordpress inspired by jim westergren.
see more here: www.jimwestergren.com/wordpress-with-redis-as-a-frontend-cache/
@ericmann
ericmann / gist:5245768
Created March 26, 2013 14:28
Three code snippets from my talk at the Portland WordPress User Group meetup on 3/25/2013
<?php
/**
* Custom Hacks for PDXWP Meetup
*/
/**
* Clean up the output of the <head> block
*/
function pdxwp_clean_header() {
remove_action( 'wp_head', 'feed_links_extra', 3 ); // Display the links to the extra feeds such as category feeds
<?php
class MyTestClass extends PHPUnit_Framework_TestCase {
public function setUp() {
\WP_Mock::setUp();
}
public function tearDown() {
\WP_Mock::tearDown();
}
<?php
$fb_request_url = 'http://api.facebook.com/restserver.php';
$fb_request_url = add_query_arg(
array(
'method' => 'links.getStats',
'urls' => $url
),
$fb_request_url
);
<?php
function update_wppa_list_limit( $current ) {
return 5;
}
add_filter( 'wppa_list_limit', 'update_wppa_list_limit' );
var loadPosts = document.getElementById( 'loadposts' ),
loadPostsA = loadPosts.querySelectorAll( 'a' ),
$loadPosts = $( loadPosts ),
$loadPostsA = $( loadPostsA );
// load posts
var loadPosts = document.getElementById( 'loadposts' ),
$loadPostsA = $( loadPosts.querySelectorAll( 'a' ) ),
$articles = $( document.getElementById( 'articles' ) );
$loadPostsA.on( 'click', function(e) {
e.preventDefault();
var $this = $( this );
$this.html( 'Loading&hellip;' );
<?php
function add_img_titles( $content ) {
global $post;
preg_match_all( '/<img[^>]*>/', $content, $matches );
$replacements = array();
foreach( $matches[0] as $match ) {
// If this image has a title, skip it
<?php
// Interface
inferface ArchiveElement {
public function do_something();
}
class TC_Video implements ArchiveElement {
public function do_something() {
// does something
}
<?php
$post_args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 10,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'has_been_twittered',
'value' => 'no',