Skip to content

Instantly share code, notes, and snippets.

View stevenkword's full-sized avatar
🎯
Focusing

Steven Word stevenkword

🎯
Focusing
View GitHub Profile
@stevenkword
stevenkword / gist:59c994b7ca8925d47f61
Created March 11, 2015 23:37
Change Escaping Method for GUIDs in WordPress
<?php
remove_filter( 'the_guid', 'esc_url' );
function html_escape_the_guid( $guid ) {
return esc_html( $guid );
}
add_filter( 'the_guid', 'html_escape_the_guid' );
<?php
/**
* Output style tags in wp_head
*
* @return null
*/
function wpe_action_wp_head_styles() {
// Only add this variable on the enterprise form
if ( is_single( 'enterprise-solutions-contact-form' ) ) {
@stevenkword
stevenkword / gist:443ec86671bdbd511508
Last active August 29, 2015 14:15
WordPress RSS Unit Tests
<?php
/**
* test the RSS 2.0 feed by generating a feed, parsing it, and checking that the
* parsed contents match the contents of the posts stored in the database. Since
* we're using a real XML parser, this confirms that the feed is valid, well formed,
* and contains the right stuff.
*
* @group feed
*/
class Tests_Feed_RSS2 extends WP_UnitTestCase {
<?php
/*
* Plugin Name: WP Engine GeoIP Debugger
* Version: 0.5
* Description: Debug tool for WP Engine GeoIP
* Author: WP Engine
* Author URI: http://wpengine.com
*
* This will help confirm if GeoIP is returning the correct information. Check the error log after loading the front page of the site.
*/
@stevenkword
stevenkword / update-git.sh
Created October 30, 2014 17:10
Git Batch Update
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
for FOLDER in $DIR/*/; do cd $FOLDER; echo "Updating " $FOLDER; git pull; cd $DIR; done
echo 'Done!'
# Activate the wordpress importer
wp plugin activate wordpress-importer --url=http://localhost/example.com/
# Iterate over all of the import files in a given folder.
for f in myfolder/*.xml; do wp import $f --authors=skip --skip=attachment --url=localhost/example.com/; done
<?php
// Remove Messages->Notices
function skw_remove_notices_subnav() {
global $bp;
if ( $bp->current_component == $bp->messages->slug ) {
bp_core_remove_subnav_item( $bp->messages->slug, 'notices' );
}
}
add_action( 'wp', 'skw_remove_notices_subnav', 11 );
<?php
// Remove Settings->Notifications SubMenu
function skw_remove_notifications_subnav(){
global $bp;
if ( $bp->current_component == $bp->settings->slug ) {
bp_core_remove_subnav_item( $bp->settings->slug, 'notifications' );
}
}
add_action( 'wp', 'skw_remove_notifications_subnav', 2 );
<?php
/**
* Search for users by name and return a JSON object of matches
*
* An example method that demonstrates how to use wildcards (*'s) when
* looking up users. This particular example would be used to create
* a new endpoint that would output a JSON array of returned users.
* Something like this would be useful for JS autocomplete queries.
*/
function skw_user_autocomplete( $search_term ) {
@stevenkword
stevenkword / fizz-buzz-tweet.php
Last active August 29, 2015 14:01
Fizz Buzz Tweet
<?php
// FizzBuzz? Here, let me tweet that to you:
foreach(range(1,100)as$n){echo$n.':'.((0==$n%5)?'Fizz':'').((0==$n%3)?'Buzz':'').'<br/>';}