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
View Create new MySQL database
CREATE DATABASE databasename;
GRANT ALL PRIVILEGES ON databasename.* TO username@localhost IDENTIFIED BY "password";
FLUSH PRIVILEGES;
EXIT;
@danielbachhuber
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
danielbachhuber / gist:756687
Created Dec 27, 2010
Disable email notifications of post status changes
View gist:756687
<?php
// 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' );
?>
@danielbachhuber
danielbachhuber / load_site_headlines.html
Created Feb 24, 2011
Loads the most recent headline and excerpt from each website in the array
View load_site_headlines.html
REPLACE THIS WITH ANY ASSIGNMENT INTRODUCTION TEXT YOU WANT
<div class="assignment-headlines"></div>
<script type="text/javascript" src="http://static.journalism.cuny.edu/useful_js/load_site_headlines.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
// Load all of the websites in an array
var websites = new Array();
websites[0] = 'http://ernest.entrepreneurial.2011.journalism.cuny.edu/';
websites[1] = 'http://hong.entrepreneurial.2011.journalism.cuny.edu/';
View The Local signup form
<script type="text/javascript">var host = (("https:" == document.location.protocol) ? "https://secure." : "http://");document.write(unescape("%3Cscript src='" + host + "wufoo.com/scripts/embed/form.js' type='text/javascript'%3E%3C/script%3E"));</script>
<script type="text/javascript">
var p7p1q1 = new WufooForm();
p7p1q1.initialize({
'userName':'cunyjschool',
'formHash':'p7p1q1',
'autoResize':true,
'height':'340',
'ssl':true});
@danielbachhuber
danielbachhuber / gist:1106704
Created Jul 26, 2011
WordPress admin improvements
View gist:1106704
<?php
/**
* Random set of improvements
*/
/**
* Tidy up the admin and remove options we don't need
*/
function db_clean_up_admin() {
@danielbachhuber
danielbachhuber / gist:1117115
Created Jul 31, 2011
Set WordPress user display name
View gist:1117115
<?php
require_once('./wp-load.php');
$all_users = get_users();
foreach( $all_users as $user ) {
if ( $user->user_login == $user->display_name ) {
$user_info = get_userdata( $user->ID );
$new_display_name = $user_info->first_name . ' ' . $user_info->last_name;
View p2-resolved-posts.php
<?php
/* Plugin Name: P2 Resolved Posts
* Description: Allows you to mark P2 posts for resolution.
* Author: Andrew Nacin
* Author URI: http://andrewnacin.com/
*/
/* WARNING about studying and copying this code:
*
* P2 is not currently an ideal platform for developing extensions. Some of this
@danielbachhuber
danielbachhuber / gist:1409229
Created Nov 30, 2011
Handling WordPress search
View gist:1409229
<?php
/**
* Give the user a 404 if they do an internal WP search
*/
function db_unresolve_search() {
global $wp_query;
if ( $wp_query->is_search )
$wp_query->is_404 = true;
}
add_action( 'template_redirect', 'db_unresolve_search' );
You can’t perform that action at this time.