From a0a9bf87b55e681d994e60ea50ee195d6ba3c3ea Mon Sep 17 00:00:00 2001 From: Eyal Beker Date: Tue, 10 Feb 2026 09:59:30 +0100 Subject: [PATCH 1/4] Update class-event-dates.php --- src/admin/class-event-dates.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/admin/class-event-dates.php b/src/admin/class-event-dates.php index 3c2c5df..4531ba7 100644 --- a/src/admin/class-event-dates.php +++ b/src/admin/class-event-dates.php @@ -838,6 +838,11 @@ public function date_string( $post_id, $long_format = true, $short_format_for_th foreach ( $event_dates as $meta ) { ++$string_index; + // Check if meta is an array. + if ( empty( $meta ) || ! is_array( $meta ) ) { + continue; + } + $type = $dates_type; $meta['repeat_days'] = isset( $meta[ $prefix . 'complex_weekdays' ] ) ? $meta[ $prefix . 'complex_weekdays' ] : array(); if ( empty( $meta['repeat_days'] ) ) { @@ -852,7 +857,7 @@ public function date_string( $post_id, $long_format = true, $short_format_for_th // If it is every monday of every month, then it's just every monday. $month_suffix = trim( $number_insert ) ? _x( 'of the month', 'of the month as in Every last friday of the month', 'openagenda-base' ) : ''; - if ( ( $meta[ $prefix . 'complex_months' ] ) && count( $meta[ $prefix . 'complex_months' ] ) > 0 ) { + if ( isset( $meta[ $prefix . 'complex_months' ] ) && is_array( $meta[ $prefix . 'complex_months' ] ) && count( $meta[ $prefix . 'complex_months' ] ) > 0 ) { $month_suffix = _x( 'of', 'of as in Every last friday of January', 'openagenda-base' ) . ' ' . $this->nice_concat( $this->translate_months( $meta[ $prefix . 'complex_months' ] ) ); if ( ! $long_format ) { // only list "current month". From acf40e0b43e2500b8cdfdd444a61ec8c1be91c1b Mon Sep 17 00:00:00 2001 From: Eyal Beker Date: Tue, 10 Feb 2026 10:12:10 +0100 Subject: [PATCH 2/4] Fix for using WP REST Cache plugin --- src/admin/class-event-dates.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/admin/class-event-dates.php b/src/admin/class-event-dates.php index 4531ba7..e09fa4f 100644 --- a/src/admin/class-event-dates.php +++ b/src/admin/class-event-dates.php @@ -9,6 +9,8 @@ namespace Openagenda_Base_Plugin\Admin; +use WP_Rest_Cache_Plugin\Includes\Caching\Caching; + /** * Event_Dates class. */ @@ -51,8 +53,8 @@ public function cron_weekly() { } // Clear the wp-rest-cache. - if ( class_exists( \Caching::class ) ) { - \Caching::get_instance()->delete_cache_by_endpoint( '%/openagenda/v1/items', \Caching::FLUSH_LOOSE, true ); + if ( class_exists( Caching::class ) ) { + Caching::get_instance()->delete_cache_by_endpoint( '%/openagenda/v1/items', Caching::FLUSH_LOOSE, true ); } } From 26c3116ed3dcb46e4fab46fbeb0b071e4d0f36d1 Mon Sep 17 00:00:00 2001 From: Eyal Beker Date: Tue, 10 Feb 2026 11:02:07 +0100 Subject: [PATCH 3/4] Update class-event-dates.php --- src/admin/class-event-dates.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/admin/class-event-dates.php b/src/admin/class-event-dates.php index e09fa4f..4cfe089 100644 --- a/src/admin/class-event-dates.php +++ b/src/admin/class-event-dates.php @@ -136,8 +136,8 @@ function () use ( $post_id ) { // Do the save-actions. $this->save_handler( $post_id ); // And clear the wp-rest-cache. - if ( class_exists( \Caching::class ) ) { - \Caching::get_instance()->delete_cache_by_endpoint( '%/openagenda/v1/items', \Caching::FLUSH_LOOSE, true ); + if ( class_exists( Caching::class ) ) { + Caching::get_instance()->delete_cache_by_endpoint( '%/openagenda/v1/items', Caching::FLUSH_LOOSE, true ); } } ); From 34d647bbad05cfd8456360f23429a19ae9aad376 Mon Sep 17 00:00:00 2001 From: Eyal Beker Date: Fri, 13 Feb 2026 10:15:03 +0100 Subject: [PATCH 4/4] Remove unneccesary wp rest cache flush, because REST Cache OWC add-on plugin handles this --- src/admin/class-event-dates.php | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/admin/class-event-dates.php b/src/admin/class-event-dates.php index 4cfe089..2739c95 100644 --- a/src/admin/class-event-dates.php +++ b/src/admin/class-event-dates.php @@ -9,8 +9,6 @@ namespace Openagenda_Base_Plugin\Admin; -use WP_Rest_Cache_Plugin\Includes\Caching\Caching; - /** * Event_Dates class. */ @@ -51,11 +49,6 @@ public function cron_weekly() { foreach ( $post_ids as $post_id ) { $this->save_handler( $post_id ); } - - // Clear the wp-rest-cache. - if ( class_exists( Caching::class ) ) { - Caching::get_instance()->delete_cache_by_endpoint( '%/openagenda/v1/items', Caching::FLUSH_LOOSE, true ); - } } /** @@ -128,22 +121,6 @@ public function save_handler( $post_id ) { if ( wp_is_post_autosave( $post_id ) ) { return; } - if ( doing_action( 'save_post_event' ) ) { - // We cannot do this now. The post we are trying to update doesn't exist yet. - add_action( - 'shutdown', - function () use ( $post_id ) { - // Do the save-actions. - $this->save_handler( $post_id ); - // And clear the wp-rest-cache. - if ( class_exists( Caching::class ) ) { - Caching::get_instance()->delete_cache_by_endpoint( '%/openagenda/v1/items', Caching::FLUSH_LOOSE, true ); - } - } - ); - - return; - } // Check the dates types value and make sure only the fields of the selected group is saved. $dates_type = get_post_meta( $post_id, 'event_dates_type', true );