From d25072f127993d7aed270b781edcc5345381c3fc Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Tue, 18 Sep 2018 19:26:02 +1000 Subject: [PATCH] Initial commit to disable Gutenberg editor for SP post types --- modules/sportspress-gutenberg.php | 58 +++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 modules/sportspress-gutenberg.php diff --git a/modules/sportspress-gutenberg.php b/modules/sportspress-gutenberg.php new file mode 100644 index 00000000..75ef5452 --- /dev/null +++ b/modules/sportspress-gutenberg.php @@ -0,0 +1,58 @@ +define_constants(); + + add_filter( 'gutenberg_can_edit_post_type', array( $this, 'can_edit_post_type' ), 10, 2 ); + } + + /** + * Define constants. + */ + private function define_constants() { + if ( !defined( 'SP_GUTENBERG_VERSION' ) ) + define( 'SP_GUTENBERG_VERSION', '2.6.8' ); + + if ( !defined( 'SP_GUTENBERG_URL' ) ) + define( 'SP_GUTENBERG_URL', plugin_dir_url( __FILE__ ) ); + + if ( !defined( 'SP_GUTENBERG_DIR' ) ) + define( 'SP_GUTENBERG_DIR', plugin_dir_path( __FILE__ ) ); + } + + /** + * Modify Gutenberg behavior for custom post types. + */ + function can_edit_post_type( $enabled, $post_type ) { + return is_sp_post_type( $post_type ) ? false : $enabled; + } +} + +endif; + +new SportsPress_Gutenberg();