Skip to content

Instantly share code, notes, and snippets.

View boywondercreative's full-sized avatar

shawn boywondercreative

View GitHub Profile
@boywondercreative
boywondercreative / box-shadow.html
Created May 23, 2019 21:51 — forked from ocean90/box-shadow.html
CSS3 Box Shadow, only top/right/bottom/left and all
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
@boywondercreative
boywondercreative / flickity-carousel.php
Created May 7, 2019 17:46 — forked from KreigD/flickity-carousel.php
Flickity WordPress Carousel
@boywondercreative
boywondercreative / functions.php
Created March 13, 2019 22:46 — forked from xadapter/functions.php
Switch UPS account and origin address based on destination. wtih XAdapter UPS plugin WooCommerce UPS Shipping Plugin with Print Label
<?php
/**
* Snippet to Change UPS account based on destination country while confirming shipment (not while generating packages).
*
*/
add_filter( 'wf_ups_shipment_confirm_request_data', 'switch_origin_adress_based_on_country', 10, 2 );
if( ! function_exists('switch_origin_adress_based_on_country') )
{
@boywondercreative
boywondercreative / functions.php
Created March 13, 2019 22:44 — forked from xadapter/functions.php
How to change default shipping method programmatically.
function wf_default_shipping_method( $method ) {
$the_cheapest_cost = 1000000;
$packages = WC()->shipping()->get_packages()[0]['rates'];
foreach ( array_keys( $packages ) as $key ) {
if ( ( $packages[$key]->cost > 0 ) && ( $packages[$key]->cost < $the_cheapest_cost ) ) {
$the_cheapest_cost = $packages[$key]->cost;
$method_id = $packages[$key]->id;
}
}
@boywondercreative
boywondercreative / functions.php
Created March 13, 2019 22:42 — forked from varun-pluginhive/functions.php
Snippet to hide specified shipping methods with zero cost. PluginHive Plugins : https://www.pluginhive.com/plugins/
/**
* Snippet to hide specified shipping methods with zero cost.
* Created at : 07 Nov 2018
* Updated at : 07 Nov 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/varun-pluginhive/a7b88d265b5ecb89d823ffe9d06daf7c
*/
add_filter( 'woocommerce_package_rates', function( $shipping_rates ){
$shipping_methods = array( 'wf_woocommerce_shipping_pro:1shipping-pro-1'); // Array of Shipping method ids
@boywondercreative
boywondercreative / functions.php
Created March 8, 2019 07:16 — forked from mikejolley/functions.php
WooCommerce - Split shipping class items into a new package and limit shipping methods
/**
* This function loops over cart items, and moves any item with shipping class 'special-class' into a new package.
* The new package in this example only takes flat rate shipping.
*/
function split_special_shipping_class_items( $packages ) {
$found_item = false;
$special_class = 'special-class'; // edit this with the slug of your shippig class
$new_package = current( $packages );
$new_package['contents'] = array();
$new_package['contents_cost'] = 0;
@boywondercreative
boywondercreative / import-ftp-proxy.php
Created February 2, 2019 04:53 — forked from m-thomson/import-ftp-proxy.php
This script reads the specified file over FTP and outputs it over HTTP. Thus, you can point WP ALL Import at the URL for this script on your server to provide a "bridge" between FTP and HTTP. This is provided with the hope it will be useful but custom PHP and importing over FTP is not officially supported.
<?php
// Note: Anyone could access your data if they guess this URL. You should remove this file from the server
// after importing or name it to something "unguessable". For even better security use an .htaccess rule.
//
// If you're experiencing problems you can uncomment the following line so errors will be sent to the file.
// ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
//
// Enter the FTP (or HTTP) URL of your data file below.
$url = "ftp://username:password@hostname.com/full/path/to/file.csv";
@boywondercreative
boywondercreative / install-docker-elementary-loki.sh
Created November 24, 2018 07:36 — forked from ChrisTimperley/install-docker-elementary-loki.sh
Installs Docker on Elementary OS 0.4 (Loki)
#!/bin/bash
sudo apt-get install apt-transport-https ca-certificates -y
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo rm -f /etc/apt/sources.list.d/docker.list
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -u -cs) \
stable"
sudo apt-get update
sudo apt-get purge lxc-docker
@boywondercreative
boywondercreative / archive-product.php
Created April 2, 2018 05:08 — forked from yanknudtskov/archive-product.php
FacetWP Pagination for Enfold and WooCommerce #woocommerce #enfold
<?php
/**
* The Template for displaying product archives, including the main shop page which is a post type archive.
*
* Override this template by copying it to yourtheme/woocommerce/archive-product.php
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.0.0
*/
@boywondercreative
boywondercreative / img-iframe-wysiwyg-wodpress-acf-prevent.php
Created March 7, 2018 10:37
Prevent Wordpress from wrapping images and iframes in p tags (default WYSIWYG and Advanced Custom Fields Wordpress WYSIWYG Plugin)
/**
*
* Prevent Wordpress from wrapping images and iframes in p tags
* http://css-tricks.com/snippets/wordpress/remove-paragraph-tags-from-around-images/
* ( <p> and <iframe> and ACF support - http://wordpress.stackexchange.com/questions/136840/how-to-remove-p-tags-around-img-and-iframe-tags-in-the-acf-wysiwyg-field
*/
// Default Wordpress WYSIWYG
function filter_ptags_on_images_iframes($content)
{
$content = preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);