Skip to content

Instantly share code, notes, and snippets.

/*
* Disable Gutenberg globally
*/
add_filter( 'use_block_editor_for_post', '__return_false' );
/*
* Disable Gutenberg for specific post types
*/
function disable_block_editor_cpt( $use_block_editor, $post_type ){
if( 'page' == $post_type || 'post' == $post_type){
@mmilosheski
mmilosheski / woo-featured-product-video.php
Last active February 6, 2019 11:15
removing the featured product image, and replacing it with a featured video, this code uses ACF (configured upload field for product post type, to return the URL of the upload)
# nginx configuration
location ~ ^/tag/?$ {
rewrite ^(.*)$ https://example.com/ redirect;
}
location ~ ^/page/?$ {
rewrite ^(.*)$ https://example.com/ redirect;
}
<?php
/**
* @snippet Hide Price & Add to Cart for Logged Out Users
* @author Mile Milosheski
* @testedwith WooCommerce 3.3.4
*/
function hide_add_cart_not_logged_in() {
if ( !is_user_logged_in() ) {
<div class="pricing__slider">
<?php
if(count($plan_options) > 2) :
?>
<div id="pricingSlider2" class="swiper-container"
data-simulateTouch = "true"
data-scrollbar=".swiper-scrollbar"
data-slidesPerView = "2"
data-slidesPerView320="auto"
data-slidesPerView576="2"
@mmilosheski
mmilosheski / smtp.php
Created July 2, 2021 11:06
WordPress PHPMailer SMTP
<?php
use PHPMailer\PHPMailer\PHPMailer;
class SMTP {
public function __construct() {
add_action('phpmailer_init', [$this, 'configure_smtp']);
}
@mmilosheski
mmilosheski / delivery-date-message.php
Created July 22, 2021 07:17
Adding Custom Delivery Date Message to Cart Totals (Checkout + Cart Pages / Woo)
<?php
add_action( 'woocommerce_cart_totals_after_shipping', 'add_delivery_date_message', 20 );
add_action( 'woocommerce_review_order_after_shipping', 'add_delivery_date_message', 20 );
function add_delivery_date_message() {
// Loop through cart items and calculate total volume
foreach( WC()->cart->get_cart() as $cart_item ){
// if you need cart items for some calculations
}