Skip to content

Instantly share code, notes, and snippets.

<?php
/*
Plugin Name: Coauthors Plus QW Field
Description: Example of coauthors custom Query Wrangler field
Author: Jonathan Daggerhart
Version: 1.0
*/
add_filter('qw_fields', 'coauthors_plus_qw_field');
@daggerhart
daggerhart / custom_qw_field_example.php
Last active March 6, 2018 11:42
An example of creating a custom field for display with Query Wrangler
<?php
/*
Plugin Name: Custom QW Field Example
Description: Example of custom Query Wrangler field with $post and $field parameters.
Author: Jonathan Daggerhart
Version: 1.0
*/
add_filter('qw_fields', 'custom_qw_field');
@daggerhart
daggerhart / bbpress_recent_replies-shortcode.php
Last active March 6, 2018 11:42
Custom bbpressRecent replies shortcode.
<?php
/*
* Get the most recently replied-to topics, and their most recent reply
*/
function custom_bbpress_recent_replies_by_topic($atts){
$short_array = shortcode_atts(array('show' => 5, 'forum' => false, 'include_empty_topics' => false), $atts);
extract($short_array);
// default values
@daggerhart
daggerhart / bbpress-remove-reply-post_title-filter.php
Last active March 6, 2018 11:42
bbPress - remove "Reply To: " from reply post titles
<?php
/*
* Filter for bbpress reply post_title, without "Reply To: " prefix
* - reference: https://bbpress.trac.wordpress.org/browser/trunk/src/includes/replies/template.php
*/
function custom_bbp_get_reply_title_fallback( $post_title = '', $post_id = 0 ){
// Bail if title not empty, or post is not a reply
if ( ! empty( $post_title ) || ! bbp_is_reply( $post_id ) ) {
return $post_title;
@daggerhart
daggerhart / bbpress_recent_replies-shortcode-optimized.php
Last active March 6, 2018 11:42
Custom bbpressRecent replies shortcode - optimized.
<?php
/*
* Get the most recently replied-to topics, and their most recent reply
*/
function custom_bbpress_recent_replies_by_topic($atts){
$short_array = shortcode_atts(array('show' => 5), $atts);
extract($short_array);
// get the 5 topics with the most recent replies
@daggerhart
daggerhart / intro-to-plugin-dev.php
Last active August 29, 2015 14:02
Wordcamp AVL 2014 - Introduction to Wordpress Plugin Development
<?php
/*
Plugin Name: Intro to Wordpres Plugin Development
Description: Generic example plugin
Plugin URI: http://www.daggerhart.com/blog/introduction-wordpress-plugin-development/
Author: Jonathan Daggerhart
Author URI: http://www.daggerhart.com
Version: 1.0
Text Domain: intro-to-plugin-dev
Domain: /lang
@daggerhart
daggerhart / Vagrantfile-puphpet-hostupdater
Last active August 29, 2015 14:03
Vagrantfile - PuPHPet with hostupdater
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
# jon -
box_name = "ubuntu-trusty"
# end jon -
dir = File.dirname(File.expand_path(__FILE__))
configValues = YAML.load_file("#{dir}/puphpet/config.yaml")
@daggerhart
daggerhart / drupal7-force-modules-uninstall.php
Created August 16, 2014 15:48
Drupal 7 force uninstall of disabled modules.
<?php
// get disabled modules, skip 'test' modules
$modules = db_query("SELECT `name` FROM {system} WHERE TYPE = 'module' AND `status` = 0 AND `name` NOT LIKE '%test%' ORDER BY `name` DESC")->fetchCol();
// ensure disabled
module_disable($modules);
// force uninstall
foreach ($modules as $module) {
@daggerhart
daggerhart / wordpress-cleanup-content.php
Last active March 6, 2018 11:42
Wordpres: Clean up content
<?php
function __cleanup_post_data(){
global $wpdb;
// default wordpress "allowed html" for posts
$allowed_tags = wp_kses_allowed_html( 'post' );
// don't allow spans
unset($allowed_tags['span']);
@daggerhart
daggerhart / wordpress-cleanup-basic.php
Created July 27, 2015 20:36
WordPress post data cleanup. Very basic.
<?php
/**
* Example of using wp_kses() to clean up WordPress post data.
*/
function __cleanup_post_data(){
global $wpdb;
// default wordpress "allowed html" for posts
$allowed_tags = wp_kses_allowed_html( 'post' );