Skip to content

Instantly share code, notes, and snippets.

@studiograsshopper
studiograsshopper / dump-all-filters.php
Created October 9, 2011 15:05
WP Dump all filters
<?php
add_action( 'all', create_function( '', 'var_dump( current_filter() );' ) );
@studiograsshopper
studiograsshopper / test.php
Created October 9, 2011 14:13
WP Add image sizes to media uploader
<?php
/**
* Filter callback to add image sizes to Media Uploader
*
* WP 3.3 pre-beta adds a new filter 'image_size_names_choose' to
* the list of image sizes which are displayed in the Media Uploader after an image
* has been uploaded.
*
* See image_size_input_fields() in wp-admin/includes/media.php
*
@studiograsshopper
studiograsshopper / sgr-author-details.php
Created October 9, 2011 16:27
WP Show author details on author archive
<?php
/**
* Function to display author details on the author archive page
*
* @uses get_query_var()
*
* @return echo out the author's details
* @author Ade Walker http://www.studiograsshopper.ch
*/
function sgr_author_info() {
@studiograsshopper
studiograsshopper / sgr-remove-default-image-sizes.php
Created October 10, 2011 11:49
WP Remove default image sizes
<?php
/**
* Remove standard image sizes so that these sizes are not
* created during the Media Upload process.
* Note: these sizes will appear "disabled" in the Media Uploader
*
* Hooked to intermediate_image_sizes_advanced filter
* See wp_generate_attachment_metadata( $attachment_id, $file ) in wp-admin/includes/image.php
*
* @param $sizes, array of default and added image sizes
@studiograsshopper
studiograsshopper / genesis-modify-title.php
Created January 2, 2012 15:56
Genesis - modify main loop title only
<?php
add_filter( 'genesis_post_title_text', 'child_modify_title' );
/**
* Add price to post title when category is 'current stock'
*
* This will only show the price on "main loop"
*
* @param string $title, post title text, as per genesis_do_post_title()
* @return string $title, modified title
*/
@studiograsshopper
studiograsshopper / genesis-backtotop-text.php
Created January 2, 2012 16:04
Genesis - Modify Back To Top text
<?php
add_filter( 'genesis_footer_backtotop_text', 'footer_backtotop_filter' );
/**
* Modify Genesis back to to text
*
* @author Ade Walker http://www.studiograsshopper.ch
*
* @param string $backtotop, default text output by Genesis
* @return string $backtotop, modified text
*/
@studiograsshopper
studiograsshopper / genesis-author-info.php
Created January 2, 2012 16:00
Genesis - add author info to author archive pages
<?php
add_action('genesis_before_loop', 'sgr_author_info', 20);
/**
* Function to display author details on the author archive page
*
* Here, we're hooking to genesis_before_loop so that it displays
* above the posts output
*
* @author Ade Walker http://www.studiograsshopper.ch
* @uses get_query_var()
@studiograsshopper
studiograsshopper / subnav-descriptions.php
Created January 5, 2012 19:09
Backcountry theme - subnav descriptions
<?php
/** Add description to secondary navigation */
add_filter( 'walker_nav_menu_start_el', 'add_description', 10, 4 );
function add_description( $item_output, $item, $depth, $args ) {
$args = (array) $args;
if ( $args['theme_location'] != 'primary' ) {
return preg_replace( '/(<a.*?>[^<]*?)</', '$1' . "<span class=\"menu-description\">{$item->post_content}</span><", $item_output );
} else {
@studiograsshopper
studiograsshopper / wp_localize-output.html
Created January 31, 2012 13:14
Output of wp_localize_script()
<script type='text/javascript'>
/* <![CDATA[ */
var carousel_params_1 = {"es_imageW":"150","es_margin":"4"};
/* ]]> */
</script>
<script type='text/javascript'>
/* <![CDATA[ */
var carousel_params_2 = {"es_imageW":"200","es_margin":"5"};
/* ]]> */
</script>
@studiograsshopper
studiograsshopper / gist:2723615
Created May 18, 2012 06:47
bbpress profile redirect
//add_action('bb_init', 'profile_redirect');
// @link http://bbpress.org/forums/topic/one-profile-page-to-rule-them-all
function profile_redirect() {
if (is_bb_profile() && $_GET['tab'] != 'edit' && $_GET['tab'] != 'favorites') {
$user = bb_get_user($_GET['id']);
if ($user) wp_redirect("http://www.example.com/member/" . $user->user_nicename);
}
}