Skip to content

Instantly share code, notes, and snippets.

View Savantos's full-sized avatar

Bob Savant Savantos

View GitHub Profile
@Savantos
Savantos / functions.php
Created September 16, 2016 08:48 — forked from neilgee/functions.php
Tabs to Accordions
<?php
//* Enqueue scripts and styles
add_action( 'wp_enqueue_scripts', 'tabsalot_enqueue_scripts_styles' );
function tabsalot_enqueue_scripts_styles() {
wp_enqueue_script( 'tabs-init' , get_stylesheet_directory_uri() . '/js/tabs-init.js', array( 'tabsjs' ), '1', true );
wp_enqueue_script( 'tabsjs' , get_stylesheet_directory_uri() . '/js/jquery.responsiveTabs.js', array( 'jquery' ), '1', true );
wp_enqueue_style( 'tabscss' , get_stylesheet_directory_uri() . '/css/responsive-tabs.css', array(), '1.0.0', 'all' );
wp_enqueue_style( 'dashicons' ); // for the + and - on the accordions
@Savantos
Savantos / wp_trim_excerpt.php
Created September 16, 2016 08:28 — forked from neilgee/wp_trim_excerpt.php
WP Excerpt - allow HTML Tags in Excerpt
<?php
//ref - http://wordpress.stackexchange.com/questions/141125/allow-html-in-excerpt/141136
function wpb_excerpt_allowedtags() {
// Add custom tags to this string
return '<script>,<style>,<br>,<em>,<i>,<ul>,<ol>,<li>,<a>,<p>,<img>,<video>,<audio>';
}
<?php
// Change 'add to cart' text on single product page (depending on product IDs)
add_filter( 'woocommerce_product_single_add_to_cart_text', 'bryce_id_multiple_add_to_cart_text' );
function bryce_id_multiple_add_to_cart_text( $default ) {
if ( get_the_ID() == 386 ) {
return __( 'Yes! I WANT this!', 'your-slug' );
} elseif ( get_the_ID() == 125 ) {
return __( 'This is number 125! Add!', 'your-slug' );
} elseif ( get_the_ID() == 225 ) {
@Savantos
Savantos / gist:96d01fb6d0c6d3a3912e4f36f4029b9c
Created September 15, 2016 16:52 — forked from ChromeOrange/gist:9559252
Deactivate Flat Rate Shipping if products with specific shipping classes are in the cart
/**
* Deactivate Flat Rate Shipping if products with specific shipping
* classes are in the cart
*
* Add the shipping class slugs to the $shippingclass_array array
*/
add_filter( 'woocommerce_shipping_flat_rate_is_available', 'unset_woocommerce_shipping_methods_flat_rate', 10 ,2 );
function unset_woocommerce_shipping_methods_flat_rate ( $return, $package ) {
// Setup an array of shipping classes that do not allow Flat Rate Shipping
// Some basic javascript Date examples
// NOTE: Javascript dates have 0 indexed months, because they are awesome
// January 1, 2012 (Chicago, IL)
var firstOfYear = new Date(2012, 0, 1),
// 6 Hour offset (before DST change)
hoursOffset = firstOfYear.getTimezoneOffset() / 60;
// April 1, 2012 (Chicago, IL)