Skip to content

Instantly share code, notes, and snippets.

View helen's full-sized avatar
🥇
#first-name-club

Helen Hou-Sandi helen

🥇
#first-name-club
View GitHub Profile
@evansolomon
evansolomon / gist:3568555
Created September 1, 2012 09:53
Bash helpers for navigating WordPress code
# Alias ST2's command line tool for a shorter (easier-to-remember) name
alias st="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"
# Search for an open Sublime Text to a function definition
function fx() {
ack "function &?$1\(" | awk {'print $1'} | sed 's/:$//g' | xargs st
}
# Example usage from the root of a WordPress repository
@Rarst
Rarst / wordpress.less
Created April 26, 2012 20:04
WordPress colors vars in LESS
// Logo
// http://wordpress.org/about/logos/
@wp_logo_blue: #21759B;
@wp_logo_orange: #D54E21;
@wp_logo_grey: #464646;
// Admin
// http://dotorgstyleguide.wordpress.com/outline/colors/
@staylor
staylor / comment-count.php
Created April 20, 2012 19:09
Get the actual number of comments + replies per page, WP comments_per_page is really top-level comments only: allows you to identify 1-12 of 13, etc for comments count UI instead of mistakenly labeling page 1 as 1-10
<?php
function get_cpage_comment_count() {
$counter = $start = 0;
wp_list_comments( array( 'callback' => function ( $comment ) use ( &$counter, &$start ) {
global $wpdb;
if ( 0 === $counter ) {
$sql = $wpdb->prepare(
"SELECT COUNT(comment_ID) FROM {$wpdb->comments}
WHERE comment_approved = 1 AND
@markjaquith
markjaquith / gist:2312948
Last active March 13, 2017 20:32
How to get PHP Unit working for WordPress Unit Tests using MAMP Pro

WordPress Unit Tests using MAMP Pro

Note: Work in progress document.

Note: Change the PHP version number as appropriate to your MAMP Pro install.

  1. Add the following you your PATH, making sure that it is first: /Applications/MAMP/bin/php/php5\.3\.6/bin:/Applications/MAMP/bin/apache2/bin:/Applications/MAMP/bin
  2. mv /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf.bak
  3. source ~/.profile (or where ever you made your PATH changes)
  4. sudo pear update-channels &amp;&amp; sudo pear upgrade pear
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@Viper007Bond
Viper007Bond / add-another-category-to-posts.php
Created February 16, 2012 08:24
WordPress: Add Another Category To Posts
<?php
/**
* Takes posts that are in category A and also adds them to category B
*/
// Uncomment this to proceed
exit( "You need to edit the file and enter the hostname and category IDs.\n" );
// What blog? Asking for both for safety reasons.
@markjaquith
markjaquith / .all
Last active October 10, 2018 15:38
Bash stuff
for f in ~/Dropbox/bash/*; do source $f; done
@PeteMall
PeteMall / wp-honeybadger.php
Created January 21, 2012 01:50
This is just the beginning
<?php
add_action( 'init', 'wp_honeybadger_it' );
function wp_honeybadger_it() {
remove_filter( 'the_content', 'capital_P_dangit', 11 );
remove_filter( 'the_title', 'capital_P_dangit', 11 );
remove_filter( 'comment_text', 'capital_P_dangit', 31 );
// more to come...
@johnpbloch
johnpbloch / short-circuit.php
Created November 21, 2011 20:10
Short Circuit a post save in WordPress and give the user a notice saying why.
<?php
namespace JPB;
function wp_insert_post_data( $data, $postarr ){
if($data['foo'] !== 'bar' || $data['baz'] !== 'bat'){
wp_redirect( add_query_arg( array( 'post' => $data['ID'], 'action' => 'edit', 'message' => 11 ), admin_url( 'post.php' ) ) );
exit;
}
return $data;
@PeteMall
PeteMall / svn-rev.php
Created September 9, 2011 16:49
Show the svn revision in admin footer.
<?php
function pm_svn_revision( $msg = '' ) {
if ( $svn = File( '.svn/entries' ) )
$msg .= ' SVN Revision: ' . $svn[3];
return $msg;
}
add_action( 'update_footer', 'pm_svn_revision', 99 );
?>