Plugin Directory

Changeset 3436371


Ignore:
Timestamp:
01/10/2026 03:53:19 AM (2 months ago)
Author:
codejitsu
Message:

Update to version 1.10.2 - Preserve cached booking data on API failure

Location:
workzen-connector/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • workzen-connector/trunk/includes/class-online-booking.php

    r3435998 r3436371  
    3333        $is_dev = defined( 'WORKZEN_DEV' ) && WORKZEN_DEV;
    3434
    35         // Try to get cached data first (cache for 5 minutes, skip in dev)
     35        // Try to get cached data first (cache for 12 hours, skip in dev)
    3636        $cache_key = 'wzc_booking_data';
    37         if ( ! $is_dev ) {
    38             $cached_data = get_transient( $cache_key );
    39             if ( false !== $cached_data ) {
    40                 return $cached_data;
    41             }
     37        $cached_data = get_transient( $cache_key );
     38
     39        if ( ! $is_dev && false !== $cached_data ) {
     40            return $cached_data;
    4241        }
    4342
     
    4544        $endpoint = get_option( WZC_Constants::OPTION_ENDPOINT );
    4645        if ( empty( $endpoint ) ) {
    47             return $this->get_fallback_booking_data();
     46            return $this->get_fallback_booking_data( $cached_data );
    4847        }
    4948
     
    5554        $integration_key = get_option( WZC_Constants::OPTION_INTEGRATION_KEY );
    5655        if ( empty( $integration_key ) ) {
    57             return $this->get_fallback_booking_data();
     56            return $this->get_fallback_booking_data( $cached_data );
    5857        }
    5958
     
    7675        if ( is_wp_error( $response ) ) {
    7776            $this->log_error( 'Failed to fetch booking config: ' . $response->get_error_message() );
    78             return $this->get_fallback_booking_data();
     77            return $this->get_fallback_booking_data( $cached_data );
    7978        }
    8079
     
    8281        if ( $response_code !== 200 ) {
    8382            $this->log_error( 'Booking config API returned status: ' . $response_code );
    84             return $this->get_fallback_booking_data();
     83            return $this->get_fallback_booking_data( $cached_data );
    8584        }
    8685
     
    9089        if ( ! is_array( $data ) || ! isset( $data['work_hours'] ) || ! isset( $data['job_types'] ) ) {
    9190            $this->log_error( 'Invalid booking config response format' );
    92             return $this->get_fallback_booking_data();
     91            return $this->get_fallback_booking_data( $cached_data );
    9392        }
    9493
     
    109108     * Get fallback booking data when API is unavailable
    110109     *
    111      * @return array Default booking data structure
    112      */
    113     private function get_fallback_booking_data() {
     110     * If previously cached data exists, return that to preserve existing data.
     111     * Only return default empty data if no cache exists.
     112     *
     113     * @param array|false $cached_data Previously cached data, or false if none
     114     * @return array Booking data structure
     115     */
     116    private function get_fallback_booking_data( $cached_data = false ) {
     117        // If we have cached data, return it to preserve existing job types and work hours
     118        if ( false !== $cached_data && is_array( $cached_data ) ) {
     119            return $cached_data;
     120        }
     121
     122        // Only return defaults if no cached data exists at all
    114123        return array(
    115124            'work_hours' => array(
  • workzen-connector/trunk/readme.txt

    r3435998 r3436371  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 1.10.1
     7Stable tag: 1.10.2
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • workzen-connector/trunk/workzen-connector.php

    r3435998 r3436371  
    33 * Plugin Name: WorkZen Connector
    44 * Description: Connects WordPress forms to WorkZen CRM. Captures leads from Contact Form 7, WPForms, Gravity Forms, and other popular form plugins, sending them securely to your WorkZen account via the WorkZen API (https://api.workzen.io). Includes floating buttons with online booking functionality.
    5  * Version: 1.10.1
     5 * Version: 1.10.2
    66 * Author: Ika Balzam
    77 * Author URI: https://workzen.io
Note: See TracChangeset for help on using the changeset viewer.