Skip to content

Instantly share code, notes, and snippets.

View johndugan's full-sized avatar

John Dugan johndugan

View GitHub Profile
@johndugan
johndugan / gist:4173416
Created November 30, 2012 02:32
WordPress: edit user fields
// Add customer user fields in wp admin
function modify_contactmethods( $contactmethods ) {
// Remove unwanted fields //
unset($contactmethods['aim']);
unset($contactmethods['yim']);
unset($contactmethods['jabber']);
// Add new fields //
$contactmethods['twitter_handle'] = 'Twitter Handle (@)';
$contactmethods['linkedin_url'] = 'LinkedIn Profile (URL)';
return $contactmethods;
@johndugan
johndugan / gist:4359828
Last active April 6, 2018 20:11
WordPress: remove inline width from captions
<?php
add_shortcode('wp_caption', 'fixed_img_caption_shortcode');
add_shortcode('caption', 'fixed_img_caption_shortcode');
function fixed_img_caption_shortcode($attr, $content = null) {
// New-style shortcode with the caption inside the shortcode with the link and image tags.
if ( ! isset( $attr['caption'] ) ) {
if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
$content = $matches[1];
$attr['caption'] = trim( $matches[2] );
}
@johndugan
johndugan / functions.php
Created July 12, 2012 03:14
WordPress: functions.php boilerplate
// ---------------------------------------------------------
// ---------- WordPress functions.php boilerplate ----------
// ---------------------------------------------------------
<?php
// ----------------------------------------------------------------------------
// ---------- Translations can be filed in the /languages/ directory ----------
// ----------------------------------------------------------------------------
load_theme_textdomain( 'html5reset', TEMPLATEPATH . '/languages' );