Skip to content

Instantly share code, notes, and snippets.

View nelsonJM's full-sized avatar

Josh Nelson nelsonJM

View GitHub Profile
@nelsonJM
nelsonJM / gist:5060626
Created February 28, 2013 22:19
WP: Custom Functions Plugin Template
<?php
/**
* Plugin Name: My Custom Functions
* Plugin URI: http://yoursite.com
* Description: This is an awesome custom plugin with functionality that I'd like to keep when switching things.
* Author: Your Name
* Author URI: http://yoursite.com
* Version: 0.1.0
*/
@nelsonJM
nelsonJM / gist:5064253
Created March 1, 2013 12:14
WP: Filter and Action Hook examples
<?php
/**
* Plugin Name: My Custom Functions
* Plugin URI: http://yoursite.com
* Description: This is an awesome custom plugin with functionality that I'd like to keep when switching things.
* Author: Your Name
* Author URI: http://yoursite.com
* Version: 0.1.0
*/
@nelsonJM
nelsonJM / gist:5103885
Created March 6, 2013 22:46
CSS3: Inset effect using Gradients
#somediv {
background: -webkit-linear-gradient(top, #efefef 99%, #ddd 99%, #f2eded 100%, #fff 100%);
}
@nelsonJM
nelsonJM / gist:5263557
Created March 28, 2013 14:29
jQuery: Fade in Gallery
/**
* A jQuery snippet for creating a gallery of images that fade in/out when thumbs are clicked on.
* Give the main images an id of "prod#" where # is the number corresponding to the thumbnail's data-file="prod#"
*
*/
<script>
(function($) {
// var featuredProd = $('.prod');
// featuredProd.filter(':nth-child(n+2)').addClass('hide');
// $('.grid-thumbs li').click(function()
@nelsonJM
nelsonJM / gist:5264305
Created March 28, 2013 15:53
WordPress: Loop through Custom Posts of Specific Category
<ul><!-- read this https://codex.wordpress.org/Class_Reference/WP_Query -->
<?php // The WordPress Loop - customized with WP_Query
$args = array(
'post_type' => 'wpsc-product',
'wpsc_product_category' => 'awesome-products'
);
$custom_query = new WP_Query($args); // exclude Asides category
while($custom_query->have_posts()) : $custom_query->the_post(); ?>
<li>
@nelsonJM
nelsonJM / gist:5273099
Created March 29, 2013 19:40
WordPress: Enqueue Script
<?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?>
@nelsonJM
nelsonJM / gist:5285379
Created April 1, 2013 14:54
CSS3: Inset shadow and highlight
/* Inset look on cancel button */
-webkit-box-shadow: 0px 1px 0px #fff, inset 0px 1px 0px #fff;
@nelsonJM
nelsonJM / gist:5306045
Created April 3, 2013 22:30
WordPress:Theme Options Page
/**************************************
* WP Tuts theme options page
**************************************/
// From here: http://wp.tutsplus.com/tutorials/the-complete-guide-to-the-wordpress-settings-api-part-1/
// Add Theme Options menu to Appearance Menu
function boiler_theme_menu() {
add_theme_page(
@nelsonJM
nelsonJM / gist:5391317
Created April 15, 2013 21:10
WP: Related Articles Plugin
/* append additional article links that are also within the current post's category
cannot contain current posting
must be limited to current category only
must compensate for articles that were posted in more than one category */
add_filter('the_content', function($content){
$id = get_the_id(); // get the id of the current post
if ( !is_singular('post')){ // if it's anything other than a single post, just output content
return $content;
@nelsonJM
nelsonJM / gist:5391591
Created April 15, 2013 21:54
WP: Twitter Shortcode
/* [twitter ]
add_shortcode('twitter', function($atts, $content) { // $atts is an array
// override the $atts we have by returning shortcode_atts in a variable called $atts
$atts = shortcode_atts( // store what's returned by shortcode_atts in $atts
array(
'username' => 'envatowebdev',
'content' => !empty($content) ? $content : 'Follow me on Twitter!'
), $atts // override our defaults above with the attributes supplied by user
);