# booktics/trunk/core/settings/settings.php

Booktics – Appointment Booking Calendar for Service Businesses, version trunk. 153 lines.

- Page: https://pluginprobe.com/plugins/booktics/trunk/code/core/settings/settings.php
- Raw: https://pluginprobe.com/plugins/booktics/trunk/raw/core/settings/settings.php
- Modified: 2026-08-25T17:58:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/booktics/trunk/code/core/settings/settings.php#L10-L20`.

```php
<?php

namespace Booktics\Settings;

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

use Booktics\Services\Schedule_Record;

/**
 * Settings class
 */
class Settings {
    /**
     * Settings option name
     *
     * @var string
     */
    protected static string $option_name = 'booktics_options';

    /**
     * Get settings
     *
     * @param string $key Setting name from options
     * @param mixed $default Default set otherwise return false
     *
     * @return  array|string
     */
    public static function get( $key = null, $default = false ) {
        $default_settings = self::get_default_settings();
        $settings         = get_option( self::$option_name, array() );
        $settings         = wp_parse_args( $settings, $default_settings );

        $schedule_record      = ( new Schedule_Record() )->get_schedules( 0, 'default' );
        $settings['schedule'] = empty( $schedule_record['schedule'] )
            ? (object) array() : $schedule_record['schedule'];
        $settings['custom']   = $schedule_record['custom'];
        $settings['holiday']  = $schedule_record['holiday'];
        $settings             = apply_filters( 'booktics_settings', $settings );

        if ( ! $key ) {
            return $settings;
        }

        if ( isset( $settings[ $key ] ) && $settings[ $key ] ) {
            return $settings[ $key ];
        }

        return $default;
    }

    /**
     * Update settings
     *
     * @param string $key Settings key
     * @param mixed $data Settings data
     *
     * @return  void
     */
    public static function update( $key, $data = array() ) {
        if ( is_array( $key ) ) {
            self::update_multiple_data( $key );
        } else {
            self::update_single_data( $key, $data );
        }
    }

    /**
     * Update multiple settings data
     *
     * @param array $options List of settings data
     */
    private static function update_multiple_data( $options ) {
        $settings = self::get();

        foreach ( $options as $name => $value ) {
            $settings[ $name ] = $options[ $name ];
        }

        return update_option( self::$option_name, $settings );
    }

    /**
     * Update single data
     *
     * @param string $key Settings key
     * @param mixed $data Settings data
     */
    private static function update_single_data( $key, $data ) {
        $settings = self::get();

        $settings[ $key ] = $data;

        return update_option( self::$option_name, $settings );
    }

    /**
     * Get default settings
     *
     * @return  array  List of default settings
     */
    private static function get_default_settings(): array {
        $defaults = array(
            'currency'    => '',
            'date_format' => '',
            'time_format' => '',
            'schedule'    => array(
                'mon'   => array(
                    array(
                        'start_time' => '9:00 AM',
                        'end_time'   => '6:00 PM',
                    ),
                ),
                'tue'   => array(
                    array(
                        'start_time' => '9:00 AM',
                        'end_time'   => '6:00 PM',
                    ),
                ),
                'wed'   => array(
                    array(
                        'start_time' => '9:00 AM',
                        'end_time'   => '6:00 PM',
                    ),
                ),
                'thurs' => array(
                    array(
                        'start_time' => '9:00 AM',
                        'end_time'   => '6:00 PM',
                    ),
                ),
                'fri'   => array(
                    array(
                        'start_time' => '9:00 AM',
                        'end_time'   => '6:00 PM',
                    ),
                ),
            ),
            'holiday'     => array(),
            'custom'      => array(),
            'allow_customer_as_wp_user' => false,
            'pending_reservation_timeout' => 10,
            // WooCommerce checkout is stripped down by default: the booking form
            // already collected the customer, so billing fields would ask twice.
            'wc_show_billing_fields'    => false,
            'wc_thankyou_page'          => 'woocommerce',
        );

        return apply_filters( 'booktics_default_settings', $defaults );
    }
}

```
