Skip to content

Instantly share code, notes, and snippets.

View robertstaddon's full-sized avatar

Robert Staddon robertstaddon

View GitHub Profile
@robertstaddon
robertstaddon / functions.php
Last active June 14, 2023 18:17
Divi - remove Divi sidebar from all WooCommerce Product pages (as well as Shop and Category pages) pages with a hook
<?php
/**
* Remove Divi sidebar from all WooCommerce Product pages (as well as Shop and Category pages)
*/
function mytheme_divi_output_content_wrapper_end() {
echo '
</div> <!-- #left-area -->
</div> <!-- #content-area -->
</div> <!-- .container -->
@robertstaddon
robertstaddon / functions.php
Last active October 30, 2022 05:44
Turn a WordPress Menu into a LiteSpeed ESI Block
<?php
add_filter( 'wp_nav_menu', function( $nav_menu_html, $args ) {
if ( $args->menu_id == "menu-id-to-replace" ) {
if ( apply_filters( 'litespeed_esi_status', false ) )
return apply_filters( 'litespeed_esi_url', 'my-esi-menu', 'Navigation Menu', array( 'nav_menu_html' => $nav_menu_html, 'args' => $args ), $control = 'private,no-vary', $silence = false );
}
return $nav_menu_html;
}, 10, 2);
@robertstaddon
robertstaddon / functions.php
Last active October 30, 2022 05:44
Turn Astra Secondary Menu into LiteSpeed ESI Block
<?php
add_filter( 'wp_nav_menu', function( $nav_menu_html, $args ) {
if ( $args->menu_id == "ast-hf-menu-2" ) {
if ( apply_filters( 'litespeed_esi_status', false ) )
return apply_filters( 'litespeed_esi_url', 'astra_secondary_menu', 'Secondary Menu', array( 'nav_menu_html' => $nav_menu_html, 'args' => $args ), $control = 'private,no-vary', $silence = false );
}
return $nav_menu_html;
}, 10, 2);
@robertstaddon
robertstaddon / functions.php
Created May 17, 2022 15:30
Remove Square Digital Wallet Payments for Smart Coupons Products that Autogenerate Coupons
add_filter( 'wc_square_digital_wallet_js_args', function ( $args ) {
if ( isset( WC()->cart ) && class_exists( 'WC_Smart_Coupons' ) ) {
$sc = WC_Smart_Coupons::get_instance();
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$coupon_titles = $sc->get_coupon_titles( array( 'product_object' => $product ) );
if ( $coupon_titles ) {
$args['payment_request'] = array();
@robertstaddon
robertstaddon / class-rcp-anet-payment-gateway.php snippet
Last active April 9, 2021 18:43
Restrict Content Pro Authorize.net Integration Handle Failed Payments
/**
* Subscription payment failed.
*
* 'payload' => array (
* 'name' => '', // Subscription name
* 'amount' => 00.00, // Subscription price
* 'status' => 'suspended', // Subscription status
* 'profile' => array (
* 'customerProfileId' => 123,
@robertstaddon
robertstaddon / gist:78cbcdf8de6fc7a6e264efbf5a320abb
Created October 28, 2020 20:31
divi_mobile_col_1_2_switch.css
/* Custom Divi Row Order .mobile_col_2_1 */
@media all and (max-width: 980px) {
.mobile_col_2_1 {
display: flex;
flex-wrap: wrap;
}
.mobile_col_2_1 .et_pb_column_1,
.mobile_col_2_1 .et_pb_column_1_2 {
order: 2;
@robertstaddon
robertstaddon / functions.php
Last active August 20, 2020 17:55
Divi - remove Divi sidebar from all WooCommerce Product pages with a hook
<?php
/**
* Remove Divi sidebar from all WooCommerce Product pages
*/
function mytheme_divi_output_content_wrapper_end() {
echo '
</div> <!-- #left-area -->
</div> <!-- #content-area -->
</div> <!-- .container -->
</div> <!-- #main-content -->';
@robertstaddon
robertstaddon / functions.php
Created April 20, 2020 18:59
Fix YITH My Account Divi Color Picker Compatibility
<?php
add_action('admin_head', 'yith_divi_color_picker_compatibility');
function yith_divi_color_picker_compatibility() {
echo '
<style>
.yith-plugin-ui .wp-picker-container a.wp-color-result {
width: 30px;
height: 30px;
box-shadow: none;
@robertstaddon
robertstaddon / lscwp-3rd-user-switching.cls.php
Last active January 8, 2020 15:20
Register User Switching plugin switch back URL nonce as a Third Party integration with LiteSpeed Cache
<?php
/**
* The Third Party integration with User Switching plugin.
*
* @since 2.9.9.2
* @package LiteSpeed_Cache
* @subpackage LiteSpeed_Cache/thirdparty
* @author LiteSpeed Technologies <info@litespeedtech.com>
*/
if ( ! defined( 'ABSPATH' ) ) {
@robertstaddon
robertstaddon / functions.php
Created January 8, 2020 00:51
LiteSpeed - register WordPress menu as ESI block
<?php
add_action( 'init', function() {
if ( method_exists( 'LiteSpeed_Cache_API', 'esi_enabled' ) && LiteSpeed_Cache_API::esi_enabled() ) {
LiteSpeed_Cache_API::hook_tpl_not_esi( function () {
add_filter( 'wp_nav_menu', function( $nav_menu_html, $args ) {
if ( $args->menu_id == "menu-id-to-replace" ) {
return LiteSpeed_Cache_API::esi_url( 'my_custom_menu_esi_hook', 'My Menu to Use with ESI' );
}
return $nav_menu_html;