Skip to content

Instantly share code, notes, and snippets.

View coauthors_qw_field_example.php
<?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 Mar 6, 2018
An example of creating a custom field for display with Query Wrangler
View custom_qw_field_example.php
<?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 Mar 6, 2018
Custom bbpressRecent replies shortcode.
View bbpress_recent_replies-shortcode.php
<?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 Mar 6, 2018
bbPress - remove "Reply To: " from reply post titles
View bbpress-remove-reply-post_title-filter.php
<?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 Mar 6, 2018
Custom bbpressRecent replies shortcode - optimized.
View bbpress_recent_replies-shortcode-optimized.php
<?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 Aug 29, 2015
Wordcamp AVL 2014 - Introduction to Wordpress Plugin Development
View intro-to-plugin-dev.php
<?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 Aug 29, 2015
Vagrantfile - PuPHPet with hostupdater
View Vagrantfile-puphpet-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 Aug 16, 2014
Drupal 7 force uninstall of disabled modules.
View drupal7-force-modules-uninstall.php
<?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 Mar 6, 2018
Wordpres: Clean up content
View wordpress-cleanup-content.php
<?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 Jul 27, 2015
WordPress post data cleanup. Very basic.
View wordpress-cleanup-basic.php
<?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' );