Created
October 31, 2018 10:00
-
-
Save thierrypigot/d71f8ca2c5b0bbceb62eb34f75b0a3ad to your computer and use it in GitHub Desktop.
Disable Gutenberg in WordPress 5.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: WeAreWP Gutenberg | |
Description: Disable Gutenberg in WordPress 5.0 | |
Plugin URI: https://www.wearewp.pro | |
Version: 1.0 | |
Author: WeAre[WP] | |
Author URI: https://www.wearewp.pro | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
die( 'Cannot access pages directly.' ); | |
} | |
/** | |
* | |
* Disbale Gutenberg only for All Custom Post Type | |
* | |
**/ | |
// Newer versions of Gutenberg (4.1+), and WordPress 5.0 beta | |
add_filter('use_block_editor_for_post', '__return_false'); | |
// Older versions of Gutenberg (less than 4.1), and WordPress versions less than 5.0 beta | |
add_filter('gutenberg_can_edit_post_type', '__return_false'); | |
/** ---------------------------------------------------------------------------------- **/ | |
/** | |
* | |
* Disbale Gutenberg only for Custom Post Type Testinonial | |
* | |
**/ | |
// Newer versions of Gutenberg (4.1+), and WordPress 5.0 beta | |
add_filter('use_block_editor_for_post_type', 'wearewp_disable_gutenberg', 10, 2); | |
// Older versions of Gutenberg (less than 4.1), and WordPress versions less than 5.0 beta | |
add_filter('gutenberg_can_edit_post_type', 'wearewp_disable_gutenberg', 10, 2); | |
function wearewp_disable_gutenberg( $is_enabled, $post_type ) { | |
// Change testimonial to your post type | |
if ($post_type === 'testimonial'){ | |
return false; | |
} | |
return $is_enabled; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment