From 0b211b6ac7439b2db45059c66a4b0bfdc5968782 Mon Sep 17 00:00:00 2001 From: Tim LSC Date: Thu, 7 Nov 2024 23:57:32 +0200 Subject: [PATCH] Fix classic widget form show/save Moved the fix to ESI class(better fit the purpose) Fix wording --- src/admin.cls.php | 5 ----- src/esi.cls.php | 10 +++++++++- tpl/esi_widget_edit.php | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/admin.cls.php b/src/admin.cls.php index 542ee760d..32434280b 100644 --- a/src/admin.cls.php +++ b/src/admin.cls.php @@ -81,11 +81,6 @@ public function admin_init() $this->cls('Media')->after_admin_init(); do_action('litspeed_after_admin_init'); - - if ($this->cls('Router')->esi_enabled()) { - add_action('in_widget_form', array($this->cls('Admin_Display'), 'show_widget_edit'), 100, 3); - add_filter('widget_update_callback', __NAMESPACE__ . '\Admin_Settings::validate_widget_save', 10, 4); - } } /** diff --git a/src/esi.cls.php b/src/esi.cls.php index 93f3528ac..a82d43bbb 100644 --- a/src/esi.cls.php +++ b/src/esi.cls.php @@ -45,11 +45,19 @@ class ESI extends Root */ public function init() { + $esi_enabled = $this->cls('Router')->esi_enabled(); + + if ($esi_enabled) { + // Show add/save widget form data + add_action('in_widget_form', array($this->cls('Admin_Display'), 'show_widget_edit'), 100, 3); + add_filter('widget_update_callback', __NAMESPACE__ . '\Admin_Settings::validate_widget_save', 10, 4); + } + /** * Bypass ESI related funcs if disabled ESI to fix potential DIVI compatibility issue * @since 2.9.7.2 */ - if (Router::is_ajax() || !$this->cls('Router')->esi_enabled()) { + if (Router::is_ajax() || !$esi_enabled) { return; } diff --git a/tpl/esi_widget_edit.php b/tpl/esi_widget_edit.php index 8170275d6..8ab300ae6 100644 --- a/tpl/esi_widget_edit.php +++ b/tpl/esi_widget_edit.php @@ -72,6 +72,7 @@

+