Skip to content

Instantly share code, notes, and snippets.

Daniel Bachhuber danielbachhuber

Block or report user

Report or block danielbachhuber

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
danielbachhuber / gist:9123282
Last active Aug 29, 2015
Show editorial comments on "Edit Comments"
View gist:9123282
* Add editorial comments to the Edit Comments list view
add_filter( 'comments_clauses', 'efx_add_editorial_comments' );
function efx_add_editorial_comments( $clauses ) {
global $pagenow;
if ( 'edit-comments.php' != $pagenow ) {
danielbachhuber / gist:9508957
Created Mar 12, 2014
Helpful P2 comment settings
View gist:9508957
* Permit anyone to post HTML in the comments
* Because ThunderP2 is only accessible by qualified users,
* this is just fine.
add_action( 'init', function() {
remove_filter( 'pre_comment_content', 'wp_filter_kses' );
add_filter( 'pre_comment_content', 'wp_filter_post_kses' );
danielbachhuber / gist:9550397
Created Mar 14, 2014
In multisite, give editors and above the ability to upload whatever they want.
View gist:9550397
* Allow editors and above to upload whatever they want
add_filter( 'map_meta_cap', function( $caps, $cap, $user_id ) {
if ( 'unfiltered_upload' !== $cap ) {
return $caps;
danielbachhuber / gist:c1554c1777dbb0460bfb
Created May 12, 2014
Serve a subset of terms at /term-slug instead of /tag/term-slug
View gist:c1554c1777dbb0460bfb
* 'special-term' is a unique butterfly
function dbx_get_special_terms() {
return array( 'special-term' );
View gist:062f822e605b6a688828
* Hack to restore the post_name that get_default_post_to_edit() noops
* Our assigned post_name via wp_insert_post_data can get fubar on post-new.php
* @see
add_filter( 'post_updated_messages', function( $messages ) {
global $pagenow, $post;
danielbachhuber / gist:218df6da18f79ba2b854
Created Apr 16, 2015
Character countdown for Fieldmanager
View gist:218df6da18f79ba2b854
$('.fm-item').on('fm_added_element', $.proxy( this.setupMaxLengthCountdown, this ) );
* Set up max length countdown
setupMaxLengthCountdown: function() {
$('.fm-element[data-fusion-enable-max-length-countdown]').each( function(){
var el = $(this);
View Create new MySQL database
CREATE DATABASE databasename;
GRANT ALL PRIVILEGES ON databasename.* TO username@localhost IDENTIFIED BY "password";
danielbachhuber / Show author metadata if available
Created May 16, 2010
Shows WordPress author metadata if available
View Show author metadata if available
<?php $author = get_post_meta($post->ID, 'author', true);
if ($author) { echo $author; } else { the_author(); } ?>
View Shows associated image if available
<?php $images = get_post_meta($post->ID, 'image');
if ($images) {
foreach ($images as $image) {
$image = explode('{}', $image);
echo '<div class="image"><img src="/media' . $image[0] . '" />';
if ($image[1]) {
echo '<p class="credit">' . $image[1] . '</p>';
echo '</div>';
danielbachhuber / gist:756687
Created Dec 27, 2010
Disable email notifications of post status changes
View gist:756687
// Handy method to remove the hook for email notifications of custom post status changes
function ef_remove_post_status_notifications() {
global $edit_flow;
// Edit Flow originally hooks into 'transition_post_status' to know when to send custom post status notifications
remove_action( 'transition_post_status', array( &$edit_flow->notifications, 'notification_status_change' ), 10, 3 );
// Hook this action into init so Edit Flow is already loaded
add_action( 'init', 'ef_remove_post_status_notifications' );
You can’t perform that action at this time.