Skip to content

Instantly share code, notes, and snippets.

studiograsshopper

Block or report user

Report or block studiograsshopper

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 premium-plugin-class.php
<?php
class Premium_Plugin {
/**
* Plugin API Url
*
* @access protected
* @var string
@studiograsshopper
studiograsshopper / sgr_wp_debug_activation.php
Created Apr 15, 2013
Plugin debugging - tracking down "The plugin generated xxx characters of unexpected output during activation." errors. I didn't invent it, but found it on a few places on the web, including wp.org support forums.
View sgr_wp_debug_activation.php
<?php
add_action('activated_plugin','save_error');
/**
* Place entire block of code at foot of wp-admin/includes/plugin.php
* Don't forget to remove code after use!
*
* Location of error_activation.html must be writeable, eg in your uploads folder somewhere
*/
function save_error(){
file_put_contents( ABSPATH . 'wp-content/{somewhere writeable}/error_activation.html', ob_get_contents() );
@studiograsshopper
studiograsshopper / sgr_jq_stick_footer.js
Created Apr 4, 2013
JQuery script for keeping footer at bottom of viewport when viewing short pages.
View sgr_jq_stick_footer.js
@studiograsshopper
studiograsshopper / sgr_wp_get_theme.php
Last active Dec 15, 2015
wp_get_theme() - false positives...
View sgr_wp_get_theme.php
<?php
/*
Installed themes:
Parent theme = Genesis version 1.9.1
Child theme = Child version 1.0
*/
// EXAMPLE 1:
$theme = wp_get_theme( get_template_directory() );
@studiograsshopper
studiograsshopper / gist:2723615
Created May 18, 2012
bbpress profile redirect
View gist:2723615
//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);
}
}
@studiograsshopper
studiograsshopper / wp_localize-output.html
Created Jan 31, 2012
Output of wp_localize_script()
View wp_localize-output.html
<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 / subnav-descriptions.php
Created Jan 5, 2012
Backcountry theme - subnav descriptions
View subnav-descriptions.php
<?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 / genesis-author-info.php
Created Jan 2, 2012
Genesis - add author info to author archive pages
View genesis-author-info.php
<?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 / genesis-modify-title.php
Created Jan 2, 2012
Genesis - modify main loop title only
View genesis-modify-title.php
<?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 Jan 2, 2012
Genesis - Modify Back To Top text
View genesis-backtotop-text.php
<?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
*/
You can’t perform that action at this time.