Skip to content

Commit

Permalink
💯 Fix cpt conflict by redirecting to 404 and flushing rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ZafarKamal123 committed Sep 26, 2023
1 parent efbf60d commit 3b3efb6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/admin.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-polyfill'), 'version' => '3325fa0e31c8d56f849cff4cc5cb1f8a');
<?php return array('dependencies' => array('wp-polyfill'), 'version' => '8a111d7e6103544a4b92b4d831e8e636');
2 changes: 1 addition & 1 deletion build/editor.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-polyfill'), 'version' => '826b1a7f75ffcee6417c3bea7442eb3b');
<?php return array('dependencies' => array('wp-polyfill'), 'version' => 'b18f44b145c6705da98f72c96c3b4861');
2 changes: 1 addition & 1 deletion build/style.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-polyfill'), 'version' => 'f02afffefdcd14a37884d25410b0be1d');
<?php return array('dependencies' => array('wp-polyfill'), 'version' => '315602804433712a9d480f29ec95226c');
2 changes: 1 addition & 1 deletion build/styles-manager-addon-style.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-polyfill'), 'version' => '75df66909d8e14b922ee4ee023ca871b');
<?php return array('dependencies' => array('wp-polyfill'), 'version' => '3209b8b8b4e7bd37fd5acda1a96c379b');
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 );
}

}

}
Expand Down

0 comments on commit 3b3efb6

Please sign in to comment.