self::panel_background(), ]; } public static function panel_background(): string { $raw = self::option( 'ips_portal_summary_panel_background', self::DEFAULT_PANEL_BACKGROUND ); $color = is_scalar( $raw ) ? trim( (string) $raw ) : ''; if ( function_exists( 'sanitize_hex_color' ) ) { $sanitized = sanitize_hex_color( $color ); return is_string( $sanitized ) && '' !== $sanitized ? strtolower( $sanitized ) : self::DEFAULT_PANEL_BACKGROUND; } return preg_match( '/^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/', $color ) ? strtolower( $color ) : self::DEFAULT_PANEL_BACKGROUND; } /** * @return array */ public static function surfaces(): array { $raw = self::option( 'ips_portal_summary_panel_background_surfaces', self::DEFAULT_SURFACES ); if ( ! is_array( $raw ) ) { return self::DEFAULT_SURFACES; } return array_values( array_filter( array_map( static function ( $surface ): string { return is_scalar( $surface ) ? sanitize_key( (string) $surface ) : ''; }, $raw ), static function ( string $surface ): bool { return in_array( $surface, self::ALLOWED_SURFACES, true ); } ) ); } /** * @param mixed $default * @return mixed */ private static function option( string $key, $default ) { if ( function_exists( 'wooordercart_get_cached_option' ) ) { return wooordercart_get_cached_option( $key, self::SECTION, $default ); } if ( function_exists( 'wooordercart_get_option' ) ) { return wooordercart_get_option( $key, self::SECTION, $default ); } return $default; } }