true, 'defer' => true, 'speculation' => 'moderate', 'third_party' => 'delay', 'third_party_allow' => array(), 'inline_critical_css' => true, 'used_css' => true, 'defer_scripts' => true, 'delay_scripts' => true, 'delay_modules' => true, 'trim_products_state' => true, 'cart_mode' => 'blocks', 'checkout_mode' => 'blocks', ); private static $group = null; public static function boot() { add_action( 'update_option_rooster', array( __CLASS__, 'follow_theme' ), 10, 2 ); add_action( 'add_option_rooster', array( __CLASS__, 'follow_theme_added' ), 10, 2 ); } public static function get( $key, $default = null ) { $group = self::group(); if ( array_key_exists( $key, $group ) ) { return $group[ $key ]; } return array_key_exists( $key, self::DEFAULTS ) ? self::DEFAULTS[ $key ] : $default; } public static function all() { return array_merge( self::DEFAULTS, array_intersect_key( self::group(), self::DEFAULTS ) ); } public static function save( array $values ) { self::$group = array_intersect_key( $values, self::DEFAULTS ); update_option( self::OPTION, self::$group, true ); } private static function group() { if ( null === self::$group ) { $saved = get_option( self::OPTION, null ); if ( ! is_array( $saved ) ) { $theme = get_option( 'rooster', array() ); $saved = is_array( $theme ) && is_array( $theme['performance'] ?? null ) ? array_intersect_key( $theme['performance'], self::DEFAULTS ) : array(); add_option( self::OPTION, $saved, '', true ); } self::$group = $saved; } return self::$group; } public static function follow_theme( $old, $new ) { if ( is_array( $new ) && is_array( $new['performance'] ?? null ) && ( ! is_array( $old ) || ( $old['performance'] ?? null ) !== $new['performance'] ) ) { self::save( array_merge( self::group(), $new['performance'] ) ); } } public static function follow_theme_added( $option, $value ) { self::follow_theme( null, $value ); } } AIEO_Engine_Settings::boot(); }