Skip to content

Instantly share code, notes, and snippets.

@dlh01
dlh01 / wp-zoninator-main-query.php
Created June 10, 2013 06:13
religionnews.com uses the Zoninator plugin to control our front page story hierarchy. This function collects our 'Headlines' zone as part of the main front page query, rather than ignoring the main query and starting a new one.
add_action( 'pre_get_posts', 'rns_get_headlines_zone', 10 );
/**
* Get the posts in the 'Headlines' zone in the front page main query
*
* @param obj $query The query to pass to the database
* @see Zoninator's get_zone_query()
*/
function rns_get_headlines_zone( $query ) {
if ( ! is_admin() && $query->is_main_query() && $query->is_home() ) {
global $zoninator;
@dlh01
dlh01 / Gruntfile.js
Last active December 18, 2015 11:29 — forked from anonymous/Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
// [other stuff...]
compass: {
options: {
sassDir: 'sass',
javascriptsDir: 'javascripts',
@dlh01
dlh01 / wp-sane-ctags.sh
Created June 14, 2013 00:48
generate a tags file that isn't 12 GB
ctags -R --languages=php,javascript --exclude=node_modules
@dlh01
dlh01 / trac.md
Last active December 20, 2015 11:29
notes about trac from WCSF 13 contributor day
  • report 16 (needs patch) are tickets looking for help
  • svn diff > [ticket number].diff
    • e.g. 23456.diff
  • cp ~/path/to/downloaded/patch.diff ./trunk/
    • patch -p0 < file.diff
  • how do you know where to start?
    • find a ticket in a section of WP you want to work in.
  • patience.
    • get in IRC
@dlh01
dlh01 / bwp_recent_comments_template.php
Created September 27, 2013 02:07
BetterWP Recent Comments: Allows you to define the "Template for comments" from a plugin or theme
add_action( 'wp_head', 'my_bwp_recent_comments_template' );
function my_bwp_recent_comments_template() {
global $bwp_rc;
$bwp_rc->options['template_comment'] = '<p>My template here</p>';
}
@dlh01
dlh01 / apigen.sh
Created December 16, 2013 01:42
10.9 + Homebrew PHP + PEAR ApiGen quick fix for error "PHP Warning: require(Texy.php): failed to open stream: No such file or directory in /usr/local/Cellar/php54/5.4.11/bin/apigen on line 48"
sudo ln -s /usr/local/Cellar/php54/5.4.11/lib/php/texy/src/texy.php /usr/local/Cellar/php54/5.4.11/lib/php
@dlh01
dlh01 / distribute_user.sh
Last active June 27, 2023 20:25
WP-CLI: Add a user to all sites in a network
#!/bin/bash
# Usage: ./distribute_user.sh [username] [role]
ARGS="$@"
echo "Adding user $1 as $2 to all sites"
SITES=$(wp site list --field=url --format=csv)
for site in $SITES
do
<?php
/*
Plugin Name: Members
*/
function member_init() {
register_post_type( 'member', array(
'labels' => array(
'name' => __( 'Members', 'foobar' ),
'singular_name' => __( 'Member', 'foobar' ),
@dlh01
dlh01 / header.php
Last active May 8, 2017 21:45
Try to stop Chrome from caching WordPress feeds during development
<?php
add_action( 'send_headers', function ( $wp ) {
if ( ! empty( $wp->query_vars['feed'] ) ) {
header( 'Cache-Control: no-cache, no-store, must-revalidate' );
}
}, 100 );
@dlh01
dlh01 / wp-cli.php
Last active January 8, 2025 04:12
wp-cli command docs
<?php
/**
* Print syndication debugging information about a post.
*
* ## OPTIONS
*
* <id>
* : Post ID.
*