Skip to content

Instantly share code, notes, and snippets.

@oneblackcrayon
Last active July 5, 2023 01:28
Show Gist options
  • Save oneblackcrayon/0dbccd51ff71f04064b187caa9c9fb26 to your computer and use it in GitHub Desktop.
Save oneblackcrayon/0dbccd51ff71f04064b187caa9c9fb26 to your computer and use it in GitHub Desktop.
Must Use Plugin for Woocommerce not working
<?php
/*
Plugin Name: MU Woo Snippets
Plugin URI: https://gist.github.com/oneblackcrayon
Description:
Version: 1.0.0
Author: OneBlackCrayon
Author URI: https://gist.github.com/oneblackcrayon
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
*/
defined( 'ABSPATH' ) or exit;
// Add a class to the checkout page body tag
if( class_exists( 'WooCommerce' ) ){
if( is_checkout() ) {
echo 'Testing Checkout';
function obc_woocom_kadencewp_class_body_checkout() { ?>
<script id="obc_woocom_kadencewp_class_body_checkout">
(function($){
jQuery(document).ready(function($){
// Plugins go here
$('body').addClass('content-width-normal').removeClass('content-width-fullwidth');
});
})(jQuery);
</script>
<?php
}
add_action('wp_footer', 'obc_woocom_kadencewp_class_body_checkout');
}
}
<?php
/*
Plugin Name: MU Woo Snippets
Plugin URI: https://gist.github.com/oneblackcrayon
Description:
Version: 1.0.0
Author: OneBlackCrayon
Author URI: https://gist.github.com/oneblackcrayon
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
*/
defined( 'ABSPATH' ) or exit;
// Add a class to the checkout page body tag
function obc_woocom_kadencewp_class_body_checkout() {
if( class_exists( 'WooCommerce' ) && is_checkout() ){ ?>
<script id="obc_woocom_kadencewp_class_body_checkout">
(function($){
jQuery(document).ready(function($){
$('body').addClass('content-width-normal').removeClass('content-width-fullwidth');
});
})(jQuery);
</script>
} <?php
}
add_action('wp_head', 'obc_woocom_kadencewp_class_body_checkout');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment