-
-
Save pavlo-bondarchuk/f01cbd2ce6c34f82ecf1c824be842795 to your computer and use it in GitHub Desktop.
CPT Class as Plugin
This file contains hidden or 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. | |
| * | |
| * Plugin Name: Plugin | |
| * Version: 1.0.0 | |
| * License: MIT | |
| * Text Domain: plugin | |
| */ | |
| class FlushTester | |
| { | |
| public function __construct() { | |
| $this->register(); | |
| } | |
| public function custom_post_type() { | |
| register_post_type( | |
| 'test', | |
| [ | |
| 'public' => true, | |
| 'has_archive' => true, | |
| 'rewrite' => ['slug' => 'testing'], | |
| 'label' => esc_html__( 'Test', 'flushtester' ), | |
| 'supports' => ['title', 'editor', 'thumbnail'], | |
| 'menu_icon' => 'dashicons-screenoptions', | |
| ] | |
| ); | |
| } | |
| public function register() { | |
| add_action( 'init', [ $this, 'custom_post_type' ] ); | |
| } | |
| static function flush() { | |
| delete_option( 'rewrite_rules' ); | |
| // flush_rewrite_rules(); | |
| } | |
| } | |
| $dpc = new FlushTester(); | |
| register_activation_hook( __FILE__, [ FlushTester::class, 'flush' ] ); | |
| register_deactivation_hook( __FILE__, [ FlushTester::class, 'flush' ] ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment