Skip to content

Instantly share code, notes, and snippets.

View davekuhar's full-sized avatar
🧑‍🚀

Dave Kuhar davekuhar

🧑‍🚀
  • 23:44 (UTC -04:00)
View GitHub Profile
@davekuhar
davekuhar / 0_reuse_code.js
Created May 28, 2014 00:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php
add_action( 'wp_enqueue_scripts', 'child_load_google_fonts' );
/**
* Enqueue Google Fonts using a function
* via Rickaby http://gregrickaby.com/add-google-fonts-wordpress-right-way/
*/
function child_load_google_fonts() {
// Find out which http protocol our server is, so we can match google
@davekuhar
davekuhar / Delete subscribers from WordPress database
Created September 16, 2014 17:35
Delete subscribers from WordPress database
# First, delete all subscribers
DELETE wpu FROM wp_users AS wpu
INNER JOIN wp_usermeta AS wpm ON wpu.ID = wpm.user_id
WHERE wpm.meta_key = 'wp_capabilities' AND wpm.meta_value = 'a:1:{s:10:"subscriber";b:1;}';
UPDATE wp_posts SET post_author = 1;
# Then, delete the user meta
DELETE FROM wp_usermeta WHERE user_id NOT IN (SELECT ID FROM wp_users)
@davekuhar
davekuhar / favicon-package.php
Last active August 29, 2015 14:07
Add favicon package to Genesis theme
// add favicon package
function xmit_add_favicons() {?>
<!-- ADD FAVICON PACKAGE -->
<link rel="apple-touch-icon" sizes="57x57" href="<?php echo get_stylesheet_directory_uri() ?>/images/favicon-package/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="114x114" href="<?php echo get_stylesheet_directory_uri() ?>/images/favicon-package/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="72x72" href="<?php echo get_stylesheet_directory_uri() ?>/images/favicon-package/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="144x144" href="<?php echo get_stylesheet_directory_uri() ?>/images/favicon-package/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="60x60" href="<?php echo get_stylesheet_directory_uri() ?>/images/favicon-package/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="120x120" href="<?php echo get_stylesheet_directory_uri() ?>/images/favicon-package/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="76x76" href="<?
@davekuhar
davekuhar / favicon-url.php
Last active August 29, 2015 14:07
Path to paste into field at realfavicongenerator.net
<?php echo get_stylesheet_directory_uri() ?>/images/favicon-package
@davekuhar
davekuhar / category-slug-as-body-class.php
Last active August 29, 2015 14:08
Add category slug as body class
<?php
// to the body element, add category slug as a class so we can style posts by category
add_filter('body_class','add_category_to_single');
function add_category_to_single($classes) {
if (is_single() ) {
global $post;
foreach((get_the_category($post->ID)) as $category) {
// add category slug to the $classes array
$classes[] = $category->category_nicename;
}
@davekuhar
davekuhar / main-stylesheet-as-editor-styles.php
Last active August 29, 2015 14:08
Add main stylesheet as editor styles
<?php
add_action( 'init', 'cd_add_editor_styles' );
/**
* Apply theme's stylesheet to the visual editor.
*
* @uses add_editor_style() Links a stylesheet to visual editor
* @uses get_stylesheet_uri() Returns URI of theme stylesheet
*/
function cd_add_editor_styles() {
@davekuhar
davekuhar / nav first and last class
Created November 9, 2014 01:37
Add "first" and "last" class to nav
function add_first_and_last($output) {
$output = preg_replace('/class="menu-item/', 'class="first-menu-item menu-item', $output, 1);
$output = substr_replace($output, 'class="last-menu-item menu-item', strripos($output, 'class="menu-item'), strlen('class="menu-item'));
return $output;
}
add_filter('wp_nav_menu', 'add_first_and_last');
@davekuhar
davekuhar / change-woocomm-ship-state
Created December 4, 2014 20:37
Change WooCommerce ‘Ship to a different address?’ Default State
// enable
add_filter( 'woocommerce_ship_to_different_address_checked', '__return_true' );
//disable
add_filter( 'woocommerce_ship_to_different_address_checked', '__return_false' );