Skip to content

Instantly share code, notes, and snippets.

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

Eric Mann ericmann

⚒️
Creating ...
View GitHub Profile
<?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
// 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;' );
var loadPosts = document.getElementById( 'loadposts' ),
loadPostsA = loadPosts.querySelectorAll( 'a' ),
$loadPosts = $( loadPosts ),
$loadPostsA = $( loadPostsA );
<?php
function update_wppa_list_limit( $current ) {
return 5;
}
add_filter( 'wppa_list_limit', 'update_wppa_list_limit' );
<?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
class MyTestClass extends PHPUnit_Framework_TestCase {
public function setUp() {
\WP_Mock::setUp();
}
public function tearDown() {
\WP_Mock::tearDown();
}
@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
/*
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/
( function( window, undefined ) {
var Logger = function() {
var SELF = this,
log = [];
SELF.append = function( data ) {
log.push( data );
};
SELF.getData = function() {
@ericmann
ericmann / gist:5206391
Last active December 15, 2015 05:09 — forked from jeremyfelt/gist:5206360
(function (window, $, thirdyo ) ) {
var mycallbackfunction = function() {}
thirdyo.thirdpartyfunction( mycallbackfunction );
})(window, jQuery, thirdyo );