|null */ private static ?array $types = null; /** * Accept one event. * * @param mixed $type Event type. * @param mixed $data Body. * @param mixed $occurredAt Unix time, or null. * * @internal Hooked to {@see Events::ACTION}. */ public static function accept( $type, $data, $occurredAt = null ): void { if ( ! is_string( $type ) || ! is_array( $data ) ) { return; } if ( ! isset( self::types()[ $type ] ) ) { \Rahkar\WP\Support\Logger::warning( 'hub', 'Dropped an event type no module registered.', [ 'type' => $type ] ); return; } Outbox::add( $type, $data, Outbox::ORIGIN_LIVE, is_int( $occurredAt ) ? $occurredAt : null ); } /** * Every registered type. * * @return array */ private static function types(): array { if ( null === self::$types ) { /** * Filters the event types modules may send to the hub. * * @param list $types Contract event types. */ // Events::TYPES_FILTER, spelled out so the plugin prefix is visible to Plugin Check. $types = (array) apply_filters( 'rahkar_wp_event_types', self::CORE_TYPES ); self::$types = array_fill_keys( array_filter( $types, 'is_string' ), true ); } return self::$types; } }