array( 'dashboard_page' => 0, 'login_page' => 0, 'register_page' => 0, 'lost_page' => 0, 'account_page' => 0, 'layout' => 'canvas', 'dashboard_title' => __( 'Dashboard', 'frontglut' ), 'show_credit' => 0, 'audit_retention' => 90, 'audit_full_ip' => 0, ), 'theme' => array( 'primary' => '#2563eb', 'radius' => 10, 'logo' => '', 'font' => 'system', 'mode' => 'auto', ), ) ); } public static function all() { if ( null === self::$cache ) { $saved = get_option( self::OPTION, array() ); self::$cache = self::merge( self::defaults(), is_array( $saved ) ? $saved : array() ); } return self::$cache; } private static function merge( $base, $over ) { foreach ( $over as $k => $v ) { if ( is_array( $v ) && isset( $base[ $k ] ) && is_array( $base[ $k ] ) && self::is_assoc( $v ) ) { $base[ $k ] = self::merge( $base[ $k ], $v ); } else { $base[ $k ] = $v; } } return $base; } private static function is_assoc( $a ) { return array() !== $a && array_keys( $a ) !== range( 0, count( $a ) - 1 ); } public static function get( $path, $default = null ) { $node = self::all(); foreach ( explode( '.', $path ) as $part ) { if ( ! is_array( $node ) || ! array_key_exists( $part, $node ) ) { return $default; } $node = $node[ $part ]; } return $node; } public static function set( $path, $value ) { $saved = get_option( self::OPTION, array() ); $saved = is_array( $saved ) ? $saved : array(); $ref = &$saved; foreach ( explode( '.', $path ) as $part ) { if ( ! isset( $ref[ $part ] ) || ! is_array( $ref[ $part ] ) ) { $ref[ $part ] = array(); } $ref = &$ref[ $part ]; } $ref = $value; unset( $ref ); self::save( $saved ); } public static function save( array $saved ) { update_option( self::OPTION, $saved, false ); self::$cache = null; } public static function flush() { self::$cache = null; } }