Skip to content

Instantly share code, notes, and snippets.

@arelthia
arelthia / mobile_script.js
Last active August 29, 2015 14:23
Change the mobile menu into a mobile friendly menu.
jQuery(document).ready(function() {
jQuery(".builder-module-navigation .menu").addClass("mobile-menu-hidden");
jQuery(".builder-module-navigation").addClass("mobile");
jQuery(".mobile-menu-hidden").before('<div class="mobile-menu">&#8801; Menu</div>');
jQuery(".mobile-menu").click(function(){
jQuery(this).next().slideToggle();
});
@arelthia
arelthia / gist:47ae6a545a6b0d8c9bec
Last active August 29, 2015 14:23
Return to Shop and continue shopping Redirect
add_filter( 'woocommerce_return_to_shop_redirect', 'syb_shop_redirect' );
function syb_shop_redirect(){
return 'https://simontbailey.com/shiftyourbrilliance/';
}
@arelthia
arelthia / old to be replaced
Last active August 29, 2015 14:23
Only show terms of service for specific product.
//Conditional Terms of Service
add_filter( 'woocommerce_checkout_show_terms' , 'syb_remove_terms' );
function syb_remove_terms( $fields ) {
foreach ( WC()->cart->get_cart() as $item ) {
if ( $item['product_id'] == '401') {
return true;
}
@arelthia
arelthia / tips.php
Created January 8, 2015 01:42
Tips Meta Box
<?php //You will probally need to remove this
function tip_meta_box(){
add_meta_box('tip_box', 'Things to Remember', 'tip_callback', 'post', 'side', 'high');
}
add_action('add_meta_boxes', 'tip_meta_box');
function tip_callback($post){
?>
@arelthia
arelthia / two-shipping-in-cart.php
Last active October 26, 2016 22:54
Woocommerce: Different shipping methods for different products in single cart
/** Seperate freepromo products from other Items - forcing multiple carts **/
add_filter( 'woocommerce_cart_shipping_packages', 'ps_two_shipping_methods_in_cart' );
function ps_two_shipping_methods_in_cart( $packages ) {
$packages = array();
$freepromo_items = array();
$regular_items = array();
$freeshipclass= 'freepromo';
$shipto = array(
'country' => WC()->customer->get_shipping_country(),
@arelthia
arelthia / catreadmore.php
Created July 21, 2014 21:43
Different Read More For Specific Category
//custom readmore for a specific category
add_filter( 'excerpt_more', 'pp_cat_more_link' );
function pp_cat_more_link() {
if(is_category('podcasts' )){
return ' <a class="more-link" href="' . get_permalink() . '">Listen Now</a>';
}else{
return ' <a class="more-link" href=' . get_permalink() . '">Read More...</a>';
}
}
@arelthia
arelthia / cleanstring.js
Created July 16, 2014 17:04
Clean Text Pasted From Microsoft Word
function cleanstring(dirty){
var smartchr = [ "&rsquo;","&lsquo;","&ldquo;","&rdquo;","&ndash;","&mdash;","&hellip;", "&nbsp;", '&bdquo;', '&sbquo;' , '&laquo;','&raquo;', '&lsaquo;', '&rsaquo;'];
var correctchr = ["'", "'", '"', '"', '-', '-', '...', '', '"', "'", '"', '"', "'", "'"];
var thestring = dirty;
var regex;
for (var i = 0; i < smartchr.length; i++) {
regex = new RegExp(smartchr[i], "g");
thestring = thestring.replace(regex, correctchr[i]);
}
@arelthia
arelthia / awac.css
Last active August 29, 2015 14:03
Style Add Widget After Content Optin Box
.awac-wrapper{
border:1px solid #333;
background:#f3f3f7;
margin-bottom:1em;
padding:.8em
}
.awac{
margin-bottom:.8em
}
.awac .gform_wrapper .gform_footer{
@arelthia
arelthia / functions.php
Last active August 29, 2015 14:01
Builder - No Title Extension
<?php
if ( is_admin() )
return;
if ( ! class_exists( 'ExtensionNoTitleLayout' ) ) {
class ExtensionNoTitleLayout {
function ExtensionNoTitleLayout() {
it_classes_load( 'it-file-utility.php' );
$this->_base_url = ITFileUtility::get_url_from_file( dirname( __FILE__ ) );
add_action( 'builder_layout_engine_render', array( &$this, 'change_render_content' ), 0 );
@arelthia
arelthia / showfiles
Last active August 29, 2015 13:56
Show clickable files in directory.
<?php
$path = "http://mydomain.com/myfiles"; //Set this to where files are located;
if ($handle = opendir('.')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
$fullentry = $path.'/'.$entry;
echo "<a href='".$fullentry."'>".$entry."</a><br />";
}
}
closedir($handle);