Skip to content

Instantly share code, notes, and snippets.

View krogsgard's full-sized avatar

Brian Krogsgard krogsgard

View GitHub Profile
<?php
add_action( 'pre_new_day', 'krogs_alter_new_day' );
/**
* krogs_alter_new_day function.
*
* @access public
* @param mixed $day
<?php
// add shopping cart thingy
function mystore_shopping_cart() {
global $woocommerce;
?>
<aside class="header-cart-info">
<a href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="View your shopping carts" class="cart-contents">
@krogsgard
krogsgard / featured-posts.php
Created March 27, 2013 16:37
Recent posts shortcode example. Inspired by Bill Erickson's excellent Display Posts shortcode.
// Twitter Feed
add_shortcode( 'tweet-tweet', 'infom_get_twitter_feed' );
function infom_get_twitter_feed( $atts ) {
extract(shortcode_atts(array(
'handle' => 'krogsgard',
'count' => '1'
), $atts));
$handle = sanitize_text_field( $handle );
$count = intval( $count );
@krogsgard
krogsgard / filter-byline.php
Last active December 15, 2015 03:49
Filter byline w/ Hybrid Core
<?php
/* filter byline in hybrid core themes that utilize one
*
* Change "inforock" to your own textdomain for your theme
* Use shortcodes as shown for various byline info
* More available shortcodes can be found in Hybrid Core docs
*/
add_filter( "{$prefix}_byline", 'krogsgard_alter_byline' );
@krogsgard
krogsgard / custom-query-nav.php
Created February 6, 2013 19:34
Simple navigation for pagination using previous_posts_link and next_posts_link for custom WP_Query
<?php
echo '<div class="loop-nav">';
previous_posts_link( '<div class="previous">' . __( 'Newer Entries', 'your-textdomain' ) . '</div>', $my_custom_query->max_num_pages );
next_posts_link( '<div class="next">' . __( 'Older Entries', 'your-textdomain' ) . '</div>', $my_custom_query->max_num_pages );
echo '</div><!-- .loop-nav -->';
@krogsgard
krogsgard / pull-shortcode-from-main-site.php
Last active December 10, 2015 23:48
In this example, enables a user to use audio and form shortcodes from the main site in sub sites with a wrapper shortcode. Could be altered for any shortcode that is typically only available on the main site. Especially useful for "global" forms and other things to be managed from the main site. Use with discretion : ) These are shortcodes after…
<?php
/*
* Plugin Name: Krogsgard enable main site forms and audio
* Plugin URI: http://infomedia.com/
* Description: enables a user to use audio and form shortcodes from the main site in sub sites with a wrapper shortcode
* Version: 0.1
* Author: Brian Krogsgard
* Author URI: http://krogsgard.com/
* Network: true
*/
@krogsgard
krogsgard / responsive-ad-slots.js
Last active December 10, 2015 07:38
Responsive Ad Slots for Google Ads. Load different ad slots depending on the window size. Doesn't currently work on resize.
var window_innerwidth = window.innerWidth;
if ( window_innerwidth < 630 ) {
GA_googleFillSlot( "Skinny-Ad" );
} else if ( window_innerwidth >= 630 && window_innerwidth < 728 ) {
GA_googleFillSlot( "In-Line-Ad" );
} else if ( window_innerwidth >= 728 && window_innerwidth < 950 ) {
GA_googleFillSlot( "Skinny-Ad" );
} else {
GA_googleFillSlot( "In-Line-Ad" );
@krogsgard
krogsgard / example-settings.php
Created October 24, 2012 20:11
Example settings page for featuring a specific post somewhere for client sites
<?php
/*
* Sample settings page
* forked from Tom McFarlin's more extensive example https://github.com/tommcfarlin/WordPress-Settings-Sandbox/
*
* @author Brian Krogsgard
*/
/**
* This function introduces the theme options into a top-level