From f1dd7f2edcd987681d6b6c025ecdb06bdca72b7b Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Thu, 6 Dec 2018 22:31:04 +1100 Subject: [PATCH] Disable REST API when Gutenberg is active to prevent blank screen bug --- includes/class-sp-post-types.php | 10 ++++++---- modules/sportspress-calendars.php | 2 +- modules/sportspress-league-tables.php | 2 +- modules/sportspress-officials.php | 2 +- modules/sportspress-player-lists.php | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/includes/class-sp-post-types.php b/includes/class-sp-post-types.php index f7638240..d0f92759 100644 --- a/includes/class-sp-post-types.php +++ b/includes/class-sp-post-types.php @@ -223,6 +223,8 @@ class SP_Post_types { public static function register_post_types() { do_action( 'sportspress_register_post_type' ); + $show_in_rest = ! function_exists( 'register_block_type' ); + register_post_type( 'sp_result', apply_filters( 'sportspress_register_post_type_result', array( @@ -436,7 +438,7 @@ class SP_Post_types { 'has_archive' => false, 'show_in_nav_menus' => true, 'menu_icon' => 'dashicons-calendar', - 'show_in_rest' => true, + 'show_in_rest' => $show_in_rest, 'rest_controller_class' => 'SP_REST_Posts_Controller', 'rest_base' => 'events', ); @@ -477,7 +479,7 @@ class SP_Post_types { 'has_archive' => false, 'show_in_nav_menus' => true, 'menu_icon' => 'dashicons-shield-alt', - 'show_in_rest' => true, + 'show_in_rest' => $show_in_rest, 'rest_controller_class' => 'SP_REST_Posts_Controller', 'rest_base' => 'teams', ) @@ -514,7 +516,7 @@ class SP_Post_types { 'has_archive' => false, 'show_in_nav_menus' => true, 'menu_icon' => 'dashicons-groups', - 'show_in_rest' => true, + 'show_in_rest' => $show_in_rest, 'rest_controller_class' => 'SP_REST_Posts_Controller', 'rest_base' => 'players', ) @@ -551,7 +553,7 @@ class SP_Post_types { 'has_archive' => false, 'show_in_nav_menus' => true, 'menu_icon' => 'dashicons-businessman', - 'show_in_rest' => true, + 'show_in_rest' => $show_in_rest, 'rest_controller_class' => 'SP_REST_Posts_Controller', 'rest_base' => 'staff', ) diff --git a/modules/sportspress-calendars.php b/modules/sportspress-calendars.php index c3c538bb..d7aa468e 100644 --- a/modules/sportspress-calendars.php +++ b/modules/sportspress-calendars.php @@ -91,7 +91,7 @@ class SportsPress_Calendars { 'show_in_nav_menus' => true, 'show_in_menu' => 'edit.php?post_type=sp_event', 'show_in_admin_bar' => true, - 'show_in_rest' => true, + 'show_in_rest' => ! function_exists( 'register_block_type' ), 'rest_controller_class' => 'SP_REST_Posts_Controller', 'rest_base' => 'calendars', ) diff --git a/modules/sportspress-league-tables.php b/modules/sportspress-league-tables.php index 509e85c2..0cac1116 100644 --- a/modules/sportspress-league-tables.php +++ b/modules/sportspress-league-tables.php @@ -88,7 +88,7 @@ class SportsPress_League_Tables { 'show_in_nav_menus' => true, 'show_in_menu' => 'edit.php?post_type=sp_team', 'show_in_admin_bar' => true, - 'show_in_rest' => true, + 'show_in_rest' => ! function_exists( 'register_block_type' ), 'rest_controller_class' => 'SP_REST_Posts_Controller', 'rest_base' => 'tables', ) diff --git a/modules/sportspress-officials.php b/modules/sportspress-officials.php index b9542617..93cb7e32 100644 --- a/modules/sportspress-officials.php +++ b/modules/sportspress-officials.php @@ -154,7 +154,7 @@ class SportsPress_Officials { 'has_archive' => false, 'show_in_nav_menus' => true, 'menu_icon' => 'dashicons-flag', - 'show_in_rest' => true, + 'show_in_rest' => ! function_exists( 'register_block_type' ), 'rest_controller_class' => 'SP_REST_Posts_Controller', 'rest_base' => 'officials', ) diff --git a/modules/sportspress-player-lists.php b/modules/sportspress-player-lists.php index ade50df9..de7d6c82 100644 --- a/modules/sportspress-player-lists.php +++ b/modules/sportspress-player-lists.php @@ -88,7 +88,7 @@ class SportsPress_Player_Lists { 'show_in_nav_menus' => true, 'show_in_menu' => 'edit.php?post_type=sp_player', 'show_in_admin_bar' => true, - 'show_in_rest' => true, + 'show_in_rest' => ! function_exists( 'register_block_type' ), 'rest_controller_class' => 'SP_REST_Posts_Controller', 'rest_base' => 'lists', )