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' => '!=', ], 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', ) );