has_cap( self::CAP ) ) { $role->add_cap( self::CAP ); } self::ensure_status_page(); \ActionReceipts\Admin\GettingStarted::mark_activated(); if ( ! wp_next_scheduled( self::CRON_HOOK ) ) { wp_schedule_event( time() + HOUR_IN_SECONDS, 'daily', self::CRON_HOOK ); } } public static function deactivate(): void { wp_clear_scheduled_hook( self::CRON_HOOK ); } public static function maybe_upgrade(): void { if ( get_option( 'actr_db_version' ) !== ACTR_DB_VERSION ) { Schema::install(); } } /** * Creates the "Track your submission" page on first activation. */ private static function ensure_status_page(): void { $settings = Settings::get(); $page_id = (int) $settings['status_page_id']; if ( $page_id && 'publish' === get_post_status( $page_id ) ) { return; } $page_id = wp_insert_post( array( 'post_title' => __( 'Track your submission', 'action-receipts' ), 'post_content' => '', 'post_status' => 'publish', 'post_type' => 'page', ) ); if ( $page_id && ! is_wp_error( $page_id ) ) { $settings['status_page_id'] = (int) $page_id; Settings::save( $settings ); } } }