From 3407f1e79189febf711a77c2969251099944be3f Mon Sep 17 00:00:00 2001 From: maxmeelay <95044326+maxmeelay@users.noreply.github.com> Date: Mon, 24 Jun 2024 18:25:44 +0200 Subject: [PATCH 1/2] Check oxygen version Since Oxygen 4.8.3 "ct_builder_json" meta changed name to prefixed version. --- commands/class-oxygensignshortcode.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/commands/class-oxygensignshortcode.php b/commands/class-oxygensignshortcode.php index 7df8a26..097bc33 100644 --- a/commands/class-oxygensignshortcode.php +++ b/commands/class-oxygensignshortcode.php @@ -6,6 +6,25 @@ */ class OxygenSignShortcode extends WP_CLI_Command { + private function get_oxygen_version($plugin_file = 'oxygen/functions.php') { + // Define the full path to the plugin file + $plugin_path = WP_PLUGIN_DIR . '/' . $plugin_file; + + // Check if the file exists + if (!file_exists($plugin_path)) { + return false; + } + + // Read the file content + $file_content = file_get_contents($plugin_path); + + // Use regex to extract the version from the plugin header + if (preg_match('/^.*Version:\s*([^\s]+).*$/mi', $file_content, $matches)) { + return $matches[1]; + } + + return false; + } /** * Shortcode Signing. * @@ -33,7 +52,7 @@ function sign_shortcode($args, $assoc_args) { 'numberposts' => -1, 'orderby' => 'ID', 'order' => 'ASC', - 'meta_key' => 'ct_builder_shortcodes', + 'meta_key' => $this->get_oxygen_version() >= '4.8.3' ? '_ct_builder_shortcodes' : 'ct_builder_shortcodes', ) ); From 56c09ab5e0557020606019c9f3d866eab452b82d Mon Sep 17 00:00:00 2001 From: maxmeelay <95044326+maxmeelay@users.noreply.github.com> Date: Mon, 24 Jun 2024 18:35:54 +0200 Subject: [PATCH 2/2] Update class-oxygenregeneratecsscache.php Since Oxygen 4.8.3 "ct_builder_json" meta changed name to prefixed version. --- commands/class-oxygenregeneratecsscache.php | 24 +++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/commands/class-oxygenregeneratecsscache.php b/commands/class-oxygenregeneratecsscache.php index 31ae945..74cf8f3 100644 --- a/commands/class-oxygenregeneratecsscache.php +++ b/commands/class-oxygenregeneratecsscache.php @@ -6,6 +6,26 @@ */ class OxygenRegenerateCssCache extends WP_CLI_Command { + + private function get_oxygen_version($plugin_file = 'oxygen/functions.php') { + // Define the full path to the plugin file + $plugin_path = WP_PLUGIN_DIR . '/' . $plugin_file; + + // Check if the file exists + if (!file_exists($plugin_path)) { + return false; + } + + // Read the file content + $file_content = file_get_contents($plugin_path); + + // Use regex to extract the version from the plugin header + if (preg_match('/^.*Version:\s*([^\s]+).*$/mi', $file_content, $matches)) { + return $matches[1]; + } + + return false; + } /** * WP CLI entry method. * @@ -52,12 +72,12 @@ private function regenerateEverything():void { 'meta_query' => [ 'relation' => 'OR', [ - 'key' => 'ct_builder_shortcodes', + 'key' => $this->get_oxygen_version() >= '4.8.3' ? '_ct_builder_shortcodes' : 'ct_builder_shortcodes', 'value' => '', 'compare' => '!=', ], [ - 'key' => 'ct_builder_json', + 'key' => $this->get_oxygen_version() >= '4.8.3' ? '_ct_builder_json' : 'ct_builder_json', 'value' => '', 'compare' => '!=', ],