register( [ 'id' => 'acme', 'title' => 'Acme', 'type' => 'commerce' ] ); * } ); * * // 2. The facade — guard with class_exists() since the call is direct. * if ( class_exists( 'Agentimus_Discovery' ) ) { * Agentimus_Discovery::register( [ 'id' => 'acme', 'title' => 'Acme', 'type' => 'commerce' ] ); * } * * @package Agentimus */ defined( 'ABSPATH' ) || exit; if ( ! class_exists( 'Agentimus_Discovery' ) ) { /** * Convenience facade over the Agentimus discovery registry. Named without * the reserved `WP_` prefix so it cannot collide with a future core class. */ final class Agentimus_Discovery { /** @var array Buffered registrations awaiting collection. */ private static $queue = array(); /** * Register a discovery resource. Buffered until the registry collects. * * @param array $resource Resource definition (see the spec / Resource). * @return void */ public static function register( $resource ) { if ( is_array( $resource ) ) { self::$queue[] = $resource; } } /** * Drain and return the queued registrations. Called once by the Registry * during collection; not part of the public author API. * * @return array */ public static function drain() { $queued = self::$queue; self::$queue = array(); return $queued; } } }