defaults() ); } if ( ! wp_next_scheduled( 'aiforya_al_cleanup' ) ) { wp_schedule_event( time() + HOUR_IN_SECONDS, 'daily', 'aiforya_al_cleanup' ); } update_option( 'aiforya_al_db_version', self::DB_VERSION, false ); } /** * @return void */ public static function deactivate(): void { $timestamp = wp_next_scheduled( 'aiforya_al_cleanup' ); if ( $timestamp ) { wp_unschedule_event( $timestamp, 'aiforya_al_cleanup' ); } wp_clear_scheduled_hook( 'aiforya_al_cleanup' ); } /** * Crée la table du journal via dbDelta. * * @return void */ public static function install_schema(): void { global $wpdb; $table = $wpdb->prefix . 'aiforya_al_events'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE {$table} ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, event_time datetime NOT NULL, user_id bigint(20) unsigned NOT NULL DEFAULT 0, user_login varchar(191) NOT NULL DEFAULT '', action varchar(64) NOT NULL DEFAULT '', object_type varchar(32) NOT NULL DEFAULT '', object_id bigint(20) unsigned NOT NULL DEFAULT 0, description text NULL, ip varchar(45) NOT NULL DEFAULT '', PRIMARY KEY (id), KEY event_time (event_time), KEY user_id (user_id) ) {$charset_collate};"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta( $sql ); } } endif;