Skip to content

Instantly share code, notes, and snippets.

View Garconis's full-sized avatar
🐞
Debugging

Jon Fuller Garconis

🐞
Debugging
View GitHub Profile
@Garconis
Garconis / woocommerce-category-toggle.css
Last active September 27, 2023 03:26
WooCommerce | Expand and collapse child categories with custom toggle in the sidebar widget | https://i.gyazo.com/e1a39ed551096444134324bb429722bb.mp4
/* - woo cat toggling elements, injected via jQuery - */
/* make list item be relative, to be able to position toggle within this item, if desired */
#sidebar .widget_product_categories ul.product-categories > li.cat-parent {
position: relative;
}
/* the new toggle element wrapper, which is added via jQuery */
#sidebar .widget_product_categories ul.product-categories > li.cat-parent .woo-cat-toggle {
cursor: pointer;
display: inline-block;
@Garconis
Garconis / woocommerce-check-category-in-cart.php
Created October 10, 2017 12:21
WooCommerce | Check if Product Category is in the Cart
<?php
/**
* Check if Product Category is in the Cart - WooCommerce
* https://businessbloomer.com/?p=72900
*/
add_action('woocommerce_before_cart', 'fs_check_category_in_cart');
function fs_check_category_in_cart() {
@Garconis
Garconis / woocommerce-shipment-tracking-providers.php
Last active October 24, 2017 20:18 — forked from DustinHartzler/shipment_tracking.php
WooCommerce | Remove options from the Shipment Tracking plugin
<?php
add_filter( 'wc_shipment_tracking_get_providers', 'custom_shipment_tracking' );
function custom_shipment_tracking( $providers ) {
// unset all the ones you don't want (e.g., we kept USPS and FedEx set)
unset($providers['Australia']);
unset($providers['Austria']);
unset($providers['Brazil']);
unset($providers['Belgium']);
@Garconis
Garconis / woocommerce-remove-extensions-menu.php
Last active May 22, 2023 03:07
WooCommerce | Remove the Extensions menu item from all users except for ones with a certain email address
<?php
/**
* Check if WooCommerce is active
**/
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
add_action('admin_menu', 'fs_remove_admin_menu_links', 999);
function fs_remove_admin_menu_links() {
@Garconis
Garconis / divi-wrap-blurb-with-the-link.js
Last active October 26, 2017 18:52
Divi | Automatically wrap the blurb module with its link if it has one by using custom class
@Garconis
Garconis / display-name-as-username.php
Created November 1, 2017 16:53
WordPress | Change user Display Name to be their username after login
<?php
// Replaces default display name to login name (username). As soon as the user logs in, the setting gets changed.
add_action( 'wp_login', 'fs_format_user_display_name_on_login' );
function fs_format_user_display_name_on_login( $username ) {
$user = get_user_by( 'login', $username );
$userdata = array(
@Garconis
Garconis / analytics-events.js
Created January 8, 2018 17:41
Add Google Analytics Events via jQuery
// Category > Action > Label
jQuery(document).ready(function() {
//Log GA Event for Sidebar MailChimp form submit click
jQuery('#mk-sidebar #mc-embedded-subscribe').click(function() {
ga('send', 'event', 'Subscribe', 'Click', 'Sidebar');
});
//Log GA Event for Top Bar MailChimp form submit click
jQuery('#mailchimp-top-bar .mctb-button').click(function() {
ga('send', 'event', 'Subscribe', 'Click', 'Header');
});
@Garconis
Garconis / woocommerce-order-complete-email-text.php
Last active August 31, 2022 07:10
WooCommerce | Add custom text above the Order Table in the Order Complete email
<?php
add_action( 'woocommerce_email_before_order_table', 'add_content', 20, 4 );
function add_content($order, $sent_to_admin, $plain_text, $email) {
// Adds to "completed order" email only
if ( $email->id == 'customer_completed_order' ) {
echo '<h2 id="h2thanks">Access Your Courses</h2><p id="pthanks">Thank you for making this purchase! You can now view your courses online by clicking <a href="https://courses.example.com/my-courses/" target="_blank">here</a>!</p>';
}
}
@Garconis
Garconis / increase-wordpress-memory.php
Created January 9, 2018 13:30
WordPress | Increase available memory for WordPress
<?php
// Add these settings to wp-config.php:
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
define( 'WP_MEMORY_LIMIT', '512M' );
@Garconis
Garconis / home-anonymous-redirect.php
Created January 29, 2018 16:54
WordPress | Redirect pages to the homepage, if the user isn't logged in. Good for maintenance mode.
<?php
// if it's not the homepage and they aren't logged in, redirect to the home URL
add_action( 'template_redirect', 'fs_maintance_mode' );
function fs_maintance_mode() {
if ( !is_home() && !is_user_logged_in() ) {
wp_redirect( esc_url_raw( home_url() ) );
exit;
}
}