Skip to content

Instantly share code, notes, and snippets.

View davekuhar's full-sized avatar
🧑‍🚀

Dave Kuhar davekuhar

🧑‍🚀
  • 03:09 (UTC -04:00)
View GitHub Profile
@davekuhar
davekuhar / woocommerce-add-click-to-enlarge.php
Last active May 13, 2017 07:24
Add "Click to enlarge" image under product thumbnail on single product page (woocommerce)
<?php
// Add "Click to enlarge image" under procuct thumbnail on single product page
add_action( 'woocommerce_product_thumbnails', 'woocommerce_click_to_enlarge', 10 );
function woocommerce_click_to_enlarge() {
echo '<a itemprop="image" href="';
echo wp_get_attachment_url( get_post_thumbnail_id() );
echo '" class="zoom" rel="thumbnails" title="';
echo get_the_title( get_post_thumbnail_id() );
echo '">Click to enlarge image</a>';
}
@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' );
<?php
add_action('set_current_user', 'xmit_hide_admin_bar');
function xmit_hide_admin_bar() {
if (!current_user_can('edit_posts')) {
show_admin_bar(false);
}
}
?>
<?php
// Add our custom image sizes
add_image_size( 'Featured Image', '350', '200', array( "1", "") );
add_image_size( 'slider', '1148', '400', array( "1", "") );
add_image_size( 'department-slider', '810', '360', false );
add_image_size( 'featured-image', '350', '200', false );
// Add custom image sizes to Media insertion dropdown menu
/*add_filter('image_size_names_choose', 'xmit_image_sizes');
function xmit_image_sizes($sizes) {
@davekuhar
davekuhar / images.php
Last active September 10, 2015 23:52 — forked from BrandonShutter/images.php
Remove WordPress automatic cropping
<?php
/**
* Remove standard image sizes so that these sizes are not created during the Media Upload process
*
* @param $sizes, array of default images
* @return $sizes, new array of images
*/
function cn_image_sizes( $sizes) {
@davekuhar
davekuhar / color-selections.css
Last active October 17, 2015 04:29
partnershc color selections
/* title bar background colors
--------------------------------------------- */
.color1 {
background-color:rgba(0,175,170,.65); /* teal */
}
.color2 {
background-color:rgba(110,205,178,.65); /* mint */
}
.color3 {
background-color:rgba(107,163,185,.65); /* blue */
@davekuhar
davekuhar / partnershc-page.php
Created October 16, 2015 22:27
Custom page template for Partners
<?php get_header(); ?>
<?php
// display user's selected header image; if not chosen, display generic header image
// header image is 2000px x 900px minimum
$header_image = get_field('post_header_image');
if( !empty($header_image) ): ?>
<div class="xmit-page-header" style="background-image: url(<?php echo $header_image['url']; ?>);">
<?php elseif (empty($header_image)): ?>
@davekuhar
davekuhar / open-partnershc-page.php
Created October 16, 2015 22:29
Get header image and display it
<?php
// display user's selected header image; if not chosen, display generic header image
// header image is 2000px x 900px minimum
$header_image = get_field('post_header_image');
if( !empty($header_image) ): ?>
<div class="xmit-page-header" style="background-image: url(<?php echo $header_image['url']; ?>);">
<?php elseif (empty($header_image)): ?>
<div class="xmit-page-header" style="background-image:url(<?php bloginfo('stylesheet_directory');?>/images/generic-header.jpg);">
<?php endif;