Skip to content

Instantly share code, notes, and snippets.

Kevin McKernan mckernanin

Block or report user

Report or block mckernanin

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
@mckernanin
mckernanin / social.html
Created Mar 30, 2016
Static Social Icons
View social.html
<div class="social-sharing-shortcode">
<ul class="social_icons_container">
<li class="social_facebook">
<a href="http://www.facebook.com/sharer.php?u=<?php echo urlencode( get_the_permalink() ); ?>" class="social-sharing" rel="nofollow" data-social_name="facebook" data-post_id="<?php the_id(); ?>">
<i class="social_icon social_icon_facebook"></i>
<div class="social_networkname">Facebook</div>
</a>
</li>
<?php
@mckernanin
mckernanin / social.php
Created Mar 30, 2016
Social Sharing PHP
View social.php
<div class="social-sharing-shortcode">
<ul class="social_icons_container">
<li class="social_facebook">
<a href="http://www.facebook.com/sharer.php?u=<?php echo urlencode( get_the_permalink() ); ?>" class="social-sharing" rel="nofollow" data-social_name="facebook" data-post_id="<?php the_id(); ?>">
<i class="social_icon social_icon_facebook"></i>
<div class="social_networkname">Facebook</div>
</a>
</li>
<?php
@mckernanin
mckernanin / nginx.conf
Last active Mar 7, 2016
Example nginx config to get WordPress uploads from remote if they don't exist locally
View nginx.conf
# save space, and grab uploads from the live site
location /wp-content/uploads/ {
if (!-e $request_filename){
rewrite ^/wp-content/uploads/(.*) http://yourlivesite.com/wp-content/uploads/$1 redirect;
}
}
@mckernanin
mckernanin / functions.php
Created Dec 30, 2015
WordPress Taxonomy Radio Buttons
View functions.php
<?php
// limit number of categories a person can have
add_filter('wp_terms_checklist_args', 'digsublime_select_one_category');
function digsublime_select_one_category($args) {
if (isset($args["taxonomy"]) && $args["taxonomy"] == ("lodge" || "chapter" || "section") ) { //put taxonomies to apply this to in quotes
$args["walker"] = new Walker_Category_Radios;
$args["checked_ontop"] = false;
}
return $args;
View main.js
// QA NAVIGATION
//REMOVE ME BEFORE PUBLISHING
$("body").append(' <div id="qanav" style="position: fixed; bottom: 5px; left: 5px; font-size: 12px; z-index:999999999999;"> '+
'<select>'+
'<option value="#" default>QA Nav - Select a Page</option>'+
'<option value="index.html">Home</option>'+
'<option value="browse-by-spf.html">Browse By SPF</option>'+
'<option value="product-detail.html">Product Detail</option>'+
'<option value="products-sport-protection.html">Prodcuts - Sport Protection</option>'+
'<option value="products-tanning.html">Products - Tanning</option>'+
@mckernanin
mckernanin / functions.php
Created Dec 30, 2015
Menu Slug as Class - WordPress Navigation
View functions.php
<?php
//Add Slug to Menu as Class
function add_slug_class_to_menu_item($output){
$ps = get_option('permalink_structure');
if(!empty($ps)){
$idstr = preg_match_all('/<li id="menu-item-(\d+)/', $output, $matches);
foreach($matches[1] as $mid){
$id = get_post_meta($mid, '_menu_item_object_id', true);
$slug = basename(get_permalink($id));
$output = preg_replace('/menu-item-'.$mid.'">/', 'menu-item-'.$mid.' menu-item-'.$slug.'">', $output, 1);
@mckernanin
mckernanin / functions.php
Created Dec 30, 2015
Conditional link in admin bar, based on site URL private Add new snippet
View functions.php
<?php
function migrate_db_admin_bar($wp_admin_bar){
$args = array(
'id' => 'wp-migrate-db-pro',
'title' => 'Migrate DB Pro',
'href' => '/wp-admin/tools.php?page=wp-migrate-db-pro',
'meta' => array(
'class' => 'wp-migrate-db-pro-button'
@mckernanin
mckernanin / functions.php
Created Dec 30, 2015
Enqueue Typekit Fonts
View functions.php
/**
* TypeKit Fonts
*
* @since Theme 1.0
*/
function theme_typekit() {
wp_enqueue_script( 'theme_typekit', '//use.typekit.net/hjy0hsn.js');
}
add_action( 'wp_enqueue_scripts', 'theme_typekit' );
function theme_typekit_inline() {
@mckernanin
mckernanin / functions.php
Created Dec 30, 2015
Gravity Forms WPEditor
View functions.php
<?php
/*
Plugin Name: Rich Text editors for Gravity Forms
Description: Converts the textarea fields in Gravity Forms to WordPress rich text editors
Author: Nathaniel Taintor
Author URI: http://goldenapplesdesign.com
Version: 1.0
License: GPLv2
*/
@mckernanin
mckernanin / functions.php
Created Dec 30, 2015
Add page slug as a body class for WordPress
View functions.php
<?php
//Page Slug Body Class
function add_slug_body_class( $classes ) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
return $classes;
}
You can’t perform that action at this time.