Skip to content

Instantly share code, notes, and snippets.

Darren Ethier nerrad

Block or report user

Report or block nerrad

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
nerrad /
Created Jul 19, 2019
Evaluating WordPress load time via command line

The commands on this page are useful for measuring php response times etc for your WordPress installation via commandline. This gives useful info to help debug issues at the php level separate from the http routes.

I'm pretty sure I didn't come up with this, but I have shared it in a few different places so just adding it to my personal gist repo for reference.

Create the base script

Create a script (name it whatever you want, something like t.php should suffice) in the root directory of your wp install (i.e. the same directory as the wp-config.php and main index.php file for WP. You can substitue whatever you want in the $_SERVER['REQUEST_URI'] to test different pages if you want.

nerrad /
Last active Feb 13, 2019
Add admin bar notification when gutenberg plugin is active


Drop this file in your wp-content/mu-plugin folder if you want to fire and forget or just into your wp-content/plugins folder if you want to be able to activate.


Now that WordPress 5.0+ has the new block editor merged in, the Gutenberg plugin is for development of features that are not in WordPress core. Since I contribute to the plugin among other projects I do I find that sometimes I forget whether or not the GB plugin is active or not. So I created this handy snippet that inserts a GB is Active indicator in the WordPress admin bar menu when the plugin is active.

nerrad / filter-events-to-posts.php
Last active Aug 29, 2015
Filter for injecting Event Espresso event post type events into everywhere posts are queried in WP
View filter-events-to-posts.php
* This is an alternative filter for adding events to posts.
* 1. Adds events to ANY query for posts (including core wp functions like wp_recent_posts() that suppress filters ).
* 2. Ensures we don't accidentally add posts (and events) into custom queries for other post types. (eg sliders).
function add_espresso_events_to_posts( $WP_Query ) {
if ( $WP_Query instanceof WP_Query && ( $WP_Query->is_feed || $WP_Query->is_posts_page || ( $WP_Query->is_home && ! $WP_Query->is_page ) || ( isset( $WP_Query->query_vars['post_type'] ) && ( $WP_Query->query_vars['post_type'] == 'post' || is_array( $WP_Query->query_vars['post_type'] ) && in_array( 'post', $WP_Query->query_vars['post_type'] ) ) ) ) ) {
nerrad / rse-fix-wpmandrill
Last active Mar 1, 2016
Fix Mandrill plugin
View rse-fix-wpmandrill
<?php if ( ! defined('ABSPATH')) exit('No direct script access allowed');
Plugin Name: Fix wpMandrill.
Plugin URI:
Description: wpMandrill doesn't setup formatted to field addresses to work correctly with the mandrill api. This fixes that.
Version: 1.0.0
Author: Darren Ethier
Author URI:
License: GPLv2
nerrad / espresso_bump_my_dates.php
Last active Aug 29, 2015
Trying to Test EE4 but all of your example dates have expired ?Use this function to bump all of your event and ticket dates forward in time by 1 month.
View espresso_bump_my_dates.php
class EEBumpDatesForward {
* constant and properties related to wp cron schedules.
const bumpDatesScheduleInterval = 'daily';
private $_scheduleIntervals;
public function __construct() {
nerrad / convert_zero_to_free_filter_example.php
Last active Aug 29, 2015
Usage of FHEE__EEH_Template__format_currency__amount filter to return free instead of 0.00 for free tickets
View convert_zero_to_free_filter_example.php
function convert_zero_to_free( $amount, $return_raw ) {
// we don't want to mess with requests for unformated values because those may get used in calculations
return $return_raw || $amount >= 0 ? $amount : __('free', 'event_espresso');
add_filter( 'FHEE__EEH_Template__format_currency__amount', 'convert_zero_to_free', 10, 2 );
nerrad / Messages_CSS_File_Filter_Example.php
Created Mar 18, 2014
using new messages css file filters
View Messages_CSS_File_Filter_Example.php
function ee_inline_css_swap( $path_or_url, $type ) {
$upload_dir = wp_upload_dir();
if ( $type == 'preview' ) {
$path_or_url = $upload_dir['baseurl'] . '/email-messenger-inline-preview-css.template.css';
} elseif ( $type === FALSE ) {
$path_or_url = $upload_dir['basedir'] . '/email-messenger-inline-css.template.css';
return $path_or_url;
nerrad / cssclassgenerator.php
Created Mar 7, 2014
Example for dynamic css class generators for use in EE
View cssclassgenerator.php
//here's the example function
function get_ticket_css_class( EE_Ticket $ticket, $context = 'ticket-item' ) {
return apply_filters( 'FHEE__get_ticket_css_class', $context . '-' . sanitize_title( $ticket->get('TKT_name') ), $ticket, $context );
//then in html template
<tr class="<?php echo get_ticket_css_class($ticket, 'ticket-row'); ?>">
nerrad / docblock example.php
Created Feb 27, 2014
An example of how spacing can cause problems with phpdoc parsing.
View docblock example.php
//below is an example of proper spacing
* This is a summary
* This is a longer description etc.
* @abstract
* @param string $some_param A string
* @returns void
nerrad / test-fix-cpt-strategy.php
Created Feb 11, 2014
possible fix for Warning: Illegal offset type in isset or empty in .../plugins/event-espresso-core-reg/core/CPTs/EE_CPT_Strategy.core.php on line 159
View test-fix-cpt-strategy.php
* in file /core/CPTs/EE_CPT_Strategy around line 155 you'll see
* public function pre_get_posts( $WP_Query ) {
* Right after that line on a new line add the following:
if ( ! $WP_Query instanceof WP_Query || empty( $WP_Query->query_vars ) )
You can’t perform that action at this time.