get_bloginfo( 'name' ), 'company_email' => get_option( 'admin_email' ), 'company_phone' => '', 'currency' => 'USD', 'currency_symbol' => '$', 'time_slot_step' => 30, // minutes between offered start times 'min_notice' => 120, // minutes before booking allowed 'max_advance_days' => 60, 'default_status' => 'approved', // or pending 'primary_color' => '#0f766e', 'accent_color' => '#f59e0b', 'font_family' => 'Manrope, system-ui, sans-serif', 'design' => array(), // see Design::defaults() 'require_phone' => false, 'notifications' => array( 'customer_approved' => true, 'customer_pending' => true, 'customer_canceled' => true, 'employee_new' => true, 'admin_new' => true, ), 'templates' => Notifications::default_templates(), ); } public static function all() { $saved = get_option( 'bookzenix_settings', array() ); return self::merge( self::defaults(), is_array( $saved ) ? $saved : array() ); } public static function get( $key, $fallback = null ) { $all = self::all(); return array_key_exists( $key, $all ) ? $all[ $key ] : $fallback; } public static function update( array $values ) { $merged = self::merge( self::all(), $values ); update_option( 'bookzenix_settings', $merged ); return $merged; } /** Recursive merge where $over wins but only for known structure. */ private static function merge( array $base, array $over ) { foreach ( $over as $k => $v ) { if ( isset( $base[ $k ] ) && is_array( $base[ $k ] ) && is_array( $v ) && self::is_assoc( $base[ $k ] ) ) { $base[ $k ] = self::merge( $base[ $k ], $v ); } else { $base[ $k ] = $v; } } return $base; } private static function is_assoc( array $a ) { return array() !== $a && array_keys( $a ) !== range( 0, count( $a ) - 1 ); } /** Settings safe to expose to the public booking widget. */ public static function public_settings() { $s = self::all(); $out = array( 'company_name' => $s['company_name'], 'currency' => $s['currency'], 'currency_symbol' => $s['currency_symbol'], 'primary_color' => $s['primary_color'], 'accent_color' => $s['accent_color'], 'font_family' => $s['font_family'], 'require_phone' => (bool) $s['require_phone'], ); return $out; } }