Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions commands/class-oxygenregeneratecsscache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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' => '!=',
],
Expand Down
21 changes: 20 additions & 1 deletion commands/class-oxygensignshortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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',
)
);

Expand Down