screens() as $slug => $screen ) { if ( ! $screen['menu'] ) { continue; } $product = $registry->product( $screen['product'] ); $parent = '' !== $screen['parent'] ? $screen['parent'] : ( '' !== $product['home']['parent'] ? $product['home']['parent'] : $product['home']['slug'] ); add_submenu_page( $parent, $screen['title'], $screen['menu_title'], $screen['capability'], $slug, static function () use ( $slug ): void { self::render( $slug ); } ); } add_action( 'admin_init', array( self::class, 'register_settings' ) ); } /** * The field a card's form posts with its group's key (0.60.0): the submission is one card's. */ public const CARD_FIELD = 'rooster_admin_settings_card'; /** * Hook admin_init: register_setting() for the screens that asked for it; for every screen, the completion of a * card's submission before the product's sanitizer (complete(), at 9: register_setting()'s runs at 10). */ public static function register_settings(): void { $registry = Library::registry(); if ( null === $registry ) { return; } foreach ( $registry->screens() as $screen ) { if ( ! has_filter( 'sanitize_option_' . $screen['option'], array( self::class, 'complete' ) ) ) { add_filter( 'sanitize_option_' . $screen['option'], array( self::class, 'complete' ), 9, 2 ); } if ( $screen['register'] ) { register_setting( $screen['option_group'], $screen['option'], array( 'type' => 'array', 'sanitize_callback' => array( self::class, 'sanitize' ), 'default' => array(), 'show_in_rest' => false, ) ); } } } /** * Filter sanitize_option_