register(); // Admin hooks. if ( is_admin() ) { new PC_CLM_Admin( $post_type ); } // Public hooks. new PC_CLM_Public( $post_type ); } add_action( 'init', 'pc_clm_init' ); /** * Create the changelog page if it doesn't exist. */ function pc_clm_create_changelog_page() { $slug = 'changelog'; // Check if the page already exists by slug $page_check = get_posts(array( 'name' => $slug, 'post_type' => 'page', 'post_status' => 'publish', 'numberposts' => 1 )); if(empty($page_check)){ $new_page = array( 'post_type' => 'page', 'post_title' => 'Changelog', 'post_name' => $slug, 'post_content' => '[changelog]', 'post_status' => 'publish', 'post_author' => 1, ); wp_insert_post($new_page); } } /** * Activation callback. */ function pc_clm_activate() { $pt = new PC_CLM_Post_Type(); $pt->register(); pc_clm_create_changelog_page(); flush_rewrite_rules(); } register_activation_hook( __FILE__, 'pc_clm_activate' ); /** * Deactivation callback. */ function pc_clm_deactivate() { flush_rewrite_rules(); } register_deactivation_hook( __FILE__, 'pc_clm_deactivate' );