Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Last active November 6, 2023 20:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save claudiosanches/d0231798eb6041e4911b4bca409ec1ac to your computer and use it in GitHub Desktop.
Save claudiosanches/d0231798eb6041e4911b4bca409ec1ac to your computer and use it in GitHub Desktop.
Disable Gutenberg in Edit Product screen for WooCommerce 3.4.x or older
<?php
/**
* Plugin Name: No Gutenberg for old versins of WooCommerce
* Plugin URI: https://gist.github.com/claudiosanches/d0231798eb6041e4911b4bca409ec1ac
* Description: Disable Gutenberg in Edit Product screen for WooCommerce 3.4.x.
* Author: Claudio Sanches
* Author URI: https://claudiosanches.com
* Version: 1.0.0
* License: GPLv3
*
* @package WC_No_Gutenberg
*/
defined( 'ABSPATH' ) || exit;
/**
* Disable gutenberg for old versions of WooCommerce.
*
* @param bool $is_enabled If editor is enabled.
* @param string $post_type Post type.
* @return bool
*/
function wc_no_gutenberg_for_products( $is_enabled, $post_type ) {
if ( 'product' === $post_type ) {
return false;
}
return $is_enabled;
}
add_filter( 'use_block_editor_for_post_type', 'wc_no_gutenberg_for_products', 10, 2 );
@lordspace
Copy link

Nice coding style :)
there's a very tiny typo in "versins"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment