Skip to content

Instantly share code, notes, and snippets.

🐞
Debugging

Jon Fuller Garconis

🐞
Debugging
Block or report user

Report or block Garconis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Garconis
Garconis / magnific-popup-youtube.js
Created Nov 8, 2019
Magnific Popup | Find YouTube anchor link and open it in popup, while also adding additional parameters such as a Playlist ID. Note, this requires magnificPopup JS to be loaded on the page.
View magnific-popup-youtube.js
jQuery(window).load(function(){
// target YouTube anchor links within this ID
jQuery('#fs-video-playlist a[href*="youtube.com/watch"]').magnificPopup({
type: 'iframe',
iframe: {
markup: '<div class="mfp-iframe-scaler">'+
'<div class="mfp-close"></div>'+
'<iframe class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+
'</div>', // HTML markup of popup, `mfp-close` will be replaced by the close button
@Garconis
Garconis / woocommerce-adjust-shipping-title-based-on-shipping-class-in-cart.php
Created Nov 4, 2019
WooCommerce | Adjust the title of the Shipping Method based if a Shipping Class product is in the Cart
View woocommerce-adjust-shipping-title-based-on-shipping-class-in-cart.php
<?php
add_filter('woocommerce_package_rates', 'change_shipping_method_name_based_on_shipping_class', 50, 2);
function change_shipping_method_name_based_on_shipping_class($rates, $package){
// HERE set the shipping class for "Pickup"
$shipping_class_id = 125;
$pickup = false;
$deliver = false;
// Check for the "Pickup" shipping class in cart items
@Garconis
Garconis / .htaccess
Created Aug 24, 2019
Cloudways | .htaccess rewrite URL to HTTPS with WWW
View .htaccess
# Cloudways force HTTPS with WWW
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
View force-woocommerce-orders-to-automatically-complete.php
<?php
/**
* Auto Complete all WooCommerce orders.
*/
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
@Garconis
Garconis / home-woocommerce-pages-anonymous-redirect.php
Created Aug 8, 2019
WooCommerce | Hide WooCommerce products and pages for logged-out users and redirect to homepage
View home-woocommerce-pages-anonymous-redirect.php
<?php
// redirecting woocommerce pages to homepage for logged out users
add_action( 'template_redirect', 'fs_wc_redirect' );
function fs_wc_redirect() {
if ( ! is_user_logged_in() && (is_woocommerce() || is_cart() || is_checkout()) ) {
wp_redirect( home_url() );
exit;
}
}
@Garconis
Garconis / pressable-batcache-append-to-wp-config.php
Created Aug 6, 2019
Pressable | Add custom batcache settings to end of wp-config.php file
View pressable-batcache-append-to-wp-config.php
<?php
$n = '
/** Custom Batcache settings for the end of wp-config.php **/
global $batcache;
if ($batcache && WP_CACHE) {
$batcache->max_age = 86400; // Seconds the cached render of a page will be stored
$batcache->seconds = 3600; // The amount of time at least 2 people are required to visit your page for a cached render to be stored.
}
';
@Garconis
Garconis / functions.php
Created Aug 5, 2019
How to display the Shipping Class of each item in the WooCommerce shopping cart
View functions.php
<?php
/**
* Add the shipping class to the bottom of each item in the cart
*/
add_filter( 'woocommerce_cart_item_name', 'shipping_class_in_item_name', 20, 3);
function shipping_class_in_item_name( $item_name, $cart_item, $cart_item_key ) {
// If the page is NOT the Shopping Cart or the Checkout, then return the product title (otherwise continue...)
if( ! ( is_cart() || is_checkout() ) ) {
return $item_name;
@Garconis
Garconis / woocommerce-small-image-thumbnail-cropping.php
Created Aug 2, 2019
WooCommerce | Thumbnail upscale & correct crop in WordPress
View woocommerce-small-image-thumbnail-cropping.php
<?php
/* Upscale images that are otherwise too small for thumbnail cropping */
function gc_thumbnail_upscale( $default, $orig_w, $orig_h, $new_w, $new_h, $crop ){
if ( !$crop ) return null; // let the WordPress default function handle this
$aspect_ratio = $orig_w / $orig_h;
$size_ratio = max($new_w / $orig_w, $new_h / $orig_h);
$crop_w = round($new_w / $size_ratio);
@Garconis
Garconis / woocommerce-shipping-class-in-shopping-cart.php
Created Jul 31, 2019
WooCommerce | Display the shipping class of items in the cart, and change shipping methods (and verbiage) based on the shipping classes in the cart
View woocommerce-shipping-class-in-shopping-cart.php
<?php
/**
* Hide a Flat Rate option (instance #7) when the "Call for Quote" shipping class is in the cart
* from: https://www.bolderelements.net/support/knowledgebase/hide-shipping-method-when-cart-contains-shipping-class/
*/
function fs_hide_shipping_when_class_is_in_cart( $rates, $package ) {
// shipping class IDs (slugs) that need the method removed
$shipping_classes = array('call-for-quote');
$if_exists = false;
@Garconis
Garconis / shortcode-loop-of-cpt-with-acf-fields.php
Created Jul 16, 2019
WordPress | Shortcode Loop of CPT with ACF Fields (Bing Devils score cards) [work-in-progress]
View shortcode-loop-of-cpt-with-acf-fields.php
<?php
// create shortcode to list all Games in Page
add_shortcode( 'fs-game-schedule-page-loop', 'fs_sc_game_schedule_page_loop' );
function fs_sc_game_schedule_page_loop( $atts ) {
ob_start();
// define attributes and their defaults
extract( shortcode_atts( array (
'post_type' => 'fs_schedule',
You can’t perform that action at this time.