Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Steven Word stevenkword

🎯
Focusing
View GitHub Profile
@stevenkword
stevenkword / gist:59c994b7ca8925d47f61
Created Mar 11, 2015
Change Escaping Method for GUIDs in WordPress
View gist:59c994b7ca8925d47f61
<?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' );
View WP Head Style Overrides
<?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 Aug 29, 2015
WordPress RSS Unit Tests
View gist:443ec86671bdbd511508
<?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 {
View gist:e794874044acb6daf09e
<?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.
*/
View update-git.sh
#!/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!'
View wp-cli-batch-import.sh
# 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
View bp-remove-notification-item.php
<?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 );
View bp-remove-subnav-item.php
<?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 );
View wp-wildcard-user-search.php
<?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 ) {
View fizz-buzz-tweet.php
<?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/>';}