getAll(); } return $settings->get( $path, $default ); } } if ( ! function_exists( 'aisentic_update_option' ) ) { /** * Update Aisentic setting value * * @param string $path Dot-notation path (e.g., 'publicChat.model'). * @param mixed $value Value to set. * @return bool True on success, false on failure. */ function aisentic_update_option( $path, $value ) { $settings = new Settings(); $settings->set( $path, $value ); $all_settings = $settings->getAll(); return $settings->save( $all_settings ); } } if ( ! function_exists( 'aisentic_timezone_string' ) ) { /** * Site timezone as an IANA name or UTC offset string. * * WP-5.2-compatible reimplementation of core's wp_timezone_string() * (added in WP 5.3): reads the same options and returns an identical * value, so behaviour matches core on 5.3+ while remaining safe on 5.2. * * @return string Timezone identifier (e.g. 'Europe/London') or offset (e.g. '+05:30'). */ function aisentic_timezone_string(): string { $timezone_string = get_option( 'timezone_string' ); if ( $timezone_string ) { return $timezone_string; } $offset = (float) get_option( 'gmt_offset' ); $hours = (int) $offset; $minutes = ( $offset - $hours ); $sign = ( $offset < 0 ) ? '-' : '+'; $abs_hour = abs( $hours ); $abs_mins = abs( $minutes * 60 ); $tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins ); return $tz_offset; } } if ( ! function_exists( 'aisentic_current_datetime' ) ) { /** * Current date/time as an immutable object in the site timezone. * * WP-5.2-compatible reimplementation of core's current_datetime() * (added in WP 5.3), built on aisentic_timezone_string(). * * @return \DateTimeImmutable */ function aisentic_current_datetime(): \DateTimeImmutable { return new \DateTimeImmutable( 'now', new \DateTimeZone( aisentic_timezone_string() ) ); } }