Skip to content

Instantly share code, notes, and snippets.

@jan-koch
jan-koch / remove-woo-scripts.php
Created February 28, 2020 09:14
Remove WooCommerce related resources except on WooCommerce-based pages (products, cart, checkout, etc). Use on a testing environment before pasting this into your live website!
/**
* This code snippet removes JavaScript and CSS files loaded from WooCommerce if they are not necessary.
*
* Please test this on a staging copy of your website before putting this into the functions.php of your live website.
*/
add_action( 'wp_enqueue_scripts', 'my_remove_woo_assets', 99 );
function my_remove_woo_assets() {
if ( function_exists( 'is_woocommerce' ) ) { // Check if Woo is installed.
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) { // Only run on non-Woo pages.
// Remove unnecessary stylesheets.
@clarklab
clarklab / block-helpers.php
Last active August 3, 2021 15:58
Wordpress check if block is used first
<?php
/**
* Block helpers
* add special classes when certain blocks appear, put this in your functions.php file or include it somewhere
*/
// add block classes in body and post class
function blocks_body_class( $classes ) {
global $post;
@peltopiri
peltopiri / archive-product.php
Created March 27, 2019 12:38
WooCommerce - Nested Category/Subcategory Layout, FIXED: show subcategory content
<?php
/**
* The Template for displaying product archives, including the main shop page which is a post type archive
*
* This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@twoelevenjay
twoelevenjay / woocommerce-give-subcat-list-items-their-own-ul.php
Last active November 9, 2023 15:30
Move WooCommerce subcategory list items into their own <ul> separate from the product <ul>.
<?php
/**
* Move WooCommerce subcategory list items into
* their own <ul> separate from the product <ul>.
*/
add_action( 'init', 'move_subcat_lis' );
function move_subcat_lis() {
// Remove the subcat <li>s from the old location.
@robincornett
robincornett / update.txt
Last active May 31, 2018 14:45
Updated responsive, mobile first, accessible, navigation menus for Genesis child themes. Uses SVG icons, and submenu toggle buttons on all screens. Submenus open on click/keypress/hover, but can be bypassed. Do not include Genesis support for accessible menus. Accommodations for no-JS users.
now located at: https://github.com/robincornett/leaven-responsive-menu
@christophherr
christophherr / change-custom-logo-schema-markup.php
Last active February 15, 2019 11:07
Change custom_logo Schema markup
/**
* Use one of the filters. Not multiple...
* I'd use the third.
*/
add_filter( 'wp_get_attachment_image_attributes', function ( $attr ) {
if ( isset( $attr['class'] ) && 'custom-logo' === $attr['class'] ) {
$attr['itemprop'] = 'image';
}
@linkhousemedia
linkhousemedia / functions.php
Last active May 6, 2020 22:56
Remove Genesis breadcrumbs from WooCommerce Pages with help from @wpsmith
<?php
/**
* Based on the work of @wpsmith https://gist.github.com/wpsmith/4950715
*/
add_action( 'genesis_before', 'linkhouse_remove_genesis_breadcrumbs' );
/**
* Remove Genesis Breadcrumbs from woocommerce
*/
function linkhouse_remove_genesis_breadcrumbs() {
// Set a minimum amount of oder based on shipping zone before checking out
add_action( 'woocommerce_check_cart_items', 'cw_min_num_products' );
// Only run in the Cart or Checkout pages
function cw_min_num_products() {
if( is_cart() || is_checkout() ) {
global $woocommerce;
@cartpauj
cartpauj / mepr-email-validate-field.php
Last active June 3, 2021 04:50
Add Email Validation Field to MemberPress checkout form
<?php
//The following code could be pasted into a plugin like My Custom Functions
function display_validate_email_field() {
?>
<div class="mp-form-row mepr_validate_email">
<div class="mp-form-label">
<label><?php _ex('Verify Email:*', 'ui', 'memberpress'); ?></label>
<span class="cc-error"><?php _ex('Invalid Email', 'ui', 'memberpress'); ?></span>
</div>
<input type="email" name="user_validate_email" id="user_validate_email" class="mepr-form-input" value="" required />
@gemmadlou
gemmadlou / remove-visual-composer-shortcodes.md
Last active October 16, 2024 00:28
Removing Visual Composer & Shortcodes From Wordpress Content

Adding @k1sul1's suggestion from the comments as it's more concise than what I had before:

I just wanted them all gone, so I ran this in the MySQL shell.

UPDATE wp_posts SET post_content = REGEXP_REPLACE(post_content, "\\[\/?vc(.*?)\]", "");

Note the double backslash. If you forget it, you'll replace all v's and c's with nothing, and the shortcodes will still be there. This works for other shortcode as well, just replace vc.