From 3b3efb645f6abc86a026dee7dd24294d3f8bf091 Mon Sep 17 00:00:00 2001 From: Zafar Kamal Date: Tue, 26 Sep 2023 16:41:46 +0500 Subject: [PATCH] :100: Fix cpt conflict by redirecting to 404 and flushing rules --- build/admin.asset.php | 2 +- build/editor.asset.php | 2 +- build/style.asset.php | 2 +- build/styles-manager-addon-style.asset.php | 2 +- .../gutenberghub-styles-manager-admin.php | 18 ++++++++++++++++++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/build/admin.asset.php b/build/admin.asset.php index 5b4bdaa2..ea8054a8 100644 --- a/build/admin.asset.php +++ b/build/admin.asset.php @@ -1 +1 @@ - array('wp-polyfill'), 'version' => '3325fa0e31c8d56f849cff4cc5cb1f8a'); \ No newline at end of file + array('wp-polyfill'), 'version' => '8a111d7e6103544a4b92b4d831e8e636'); \ No newline at end of file diff --git a/build/editor.asset.php b/build/editor.asset.php index 05538db9..c78f4eab 100644 --- a/build/editor.asset.php +++ b/build/editor.asset.php @@ -1 +1 @@ - array('wp-polyfill'), 'version' => '826b1a7f75ffcee6417c3bea7442eb3b'); \ No newline at end of file + array('wp-polyfill'), 'version' => 'b18f44b145c6705da98f72c96c3b4861'); \ No newline at end of file diff --git a/build/style.asset.php b/build/style.asset.php index 8963cda4..9edaae3c 100644 --- a/build/style.asset.php +++ b/build/style.asset.php @@ -1 +1 @@ - array('wp-polyfill'), 'version' => 'f02afffefdcd14a37884d25410b0be1d'); \ No newline at end of file + array('wp-polyfill'), 'version' => '315602804433712a9d480f29ec95226c'); \ No newline at end of file diff --git a/build/styles-manager-addon-style.asset.php b/build/styles-manager-addon-style.asset.php index e03c1a81..b7baa3f7 100644 --- a/build/styles-manager-addon-style.asset.php +++ b/build/styles-manager-addon-style.asset.php @@ -1 +1 @@ - array('wp-polyfill'), 'version' => '75df66909d8e14b922ee4ee023ca871b'); \ No newline at end of file + array('wp-polyfill'), 'version' => '3209b8b8b4e7bd37fd5acda1a96c379b'); \ No newline at end of file diff --git a/includes/addons/styles-manager/gutenberghub-styles-manager-admin.php b/includes/addons/styles-manager/gutenberghub-styles-manager-admin.php index d6c941fd..3f748d3b 100644 --- a/includes/addons/styles-manager/gutenberghub-styles-manager-admin.php +++ b/includes/addons/styles-manager/gutenberghub-styles-manager-admin.php @@ -167,6 +167,16 @@ public function register() { ), ); + \register_setting( + 'general', + '_ek_is_styles_manager_cpt_flashed', + array( + 'default' => false, + 'show_in_rest' => false, + 'type' => 'boolean', + ) + ); + register_post_type( static::$post_type, $args ); // Adding necessary metadata. @@ -206,6 +216,14 @@ public function register() { ) ); + // Flushing rewrite rules if we haven't already to address the issue where + // Custom Post Type redirects to 404 page. + if ( false === get_option( '_ek_is_styles_manager_cpt_flashed' ) ) { + // This is an expensive operation, so making sure that it only runs once. + flush_rewrite_rules( false ); + update_option( '_ek_is_styles_manager_cpt_flashed', true ); + } + } }