Last active
February 3, 2021 17:38
-
-
Save wpmu-authors/6f0927b3bf9807e426c8778a3bf3a797 to your computer and use it in GitHub Desktop.
option-activation.php
This file contains 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
register_activation_hook( __FILE__, 'my_plugin_activation' ); | |
function my_plugin_activation() { | |
add_option( 'my_plugin_activation','just-activated' ); | |
} | |
add_action( 'admin_init','my_plugin_initialize' ); | |
function my_plugin_initialize() { | |
if( is_admin() && get_option( 'my_plugin_activation' ) == 'just-activated' ) { | |
delete_option( 'my_plugin_activation' ); | |
flush_rewrite_rules(); | |
} | |
} | |
add_action( 'init', 'my_custom_post_type' ); | |
function my_custom_post_type() { | |
$args = array( | |
'public' => true, | |
'label' => 'Board Games' | |
); | |
register_post_type( 'boardgames', $args ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment