30, 'headers' => [ 'Accept' => 'application/json', ], ]); if (is_wp_error($response)) { return []; } $response_body = wp_remote_retrieve_body($response); $biggopties = json_decode($response_body); if( isset($biggopties) && isset($biggopties->{'prime-slider'}) ) { $data = $biggopties->{'prime-slider'}; if (is_array($data)) { return $data; } } return []; } /** * Check if a biggopti should be shown based on its enabled status and date range. * * @param object $biggopti The biggopti data from the API. * @return bool True if the biggopti should be shown, false otherwise. */ private function should_show_biggopti($biggopti) { // Development override - set to true to bypass date checks for testing $development_mode = false; // Set to true to bypass date checks if ($development_mode) { return true; } // Check if the biggopti is enabled if (!isset($biggopti->is_enabled) || !$biggopti->is_enabled) { return false; } // Check plugin compatibility if (!$this->is_biggopti_compatible_with_plugin($biggopti)) { return false; } // Check if the biggopti has a start date and end date if (!isset($biggopti->start_date) || !isset($biggopti->end_date)) { return false; } // Get timezone from biggopti or default to UTC $timezone = isset($biggopti->timezone) ? $biggopti->timezone : 'UTC'; // Create DateTime objects with proper timezone (using global namespace) $start_date = new \DateTime($biggopti->start_date, new \DateTimeZone($timezone)); $end_date = new \DateTime($biggopti->end_date, new \DateTimeZone($timezone)); $current_date = new \DateTime('now', new \DateTimeZone($timezone)); // Convert to timestamps for comparison $start_timestamp = $start_date->getTimestamp(); $end_timestamp = $end_date->getTimestamp(); $current_timestamp = $current_date->getTimestamp(); // Check if the current date is within the start and end dates if ($current_timestamp < $start_timestamp || $current_timestamp > $end_timestamp) { return false; } // Check if biggopti should be visible after a certain time if (isset($biggopti->visible_after) && $biggopti->visible_after > 0) { $visible_after_timestamp = $start_timestamp + $biggopti->visible_after; if ($current_timestamp < $visible_after_timestamp) { return false; } } return true; } /** * Check if current user has extended license * * @return bool True if user has extended license, false otherwise. */ private function has_extended_license() { if (!class_exists('PrimeSliderPro\Base\Prime_Slider_Base')) { return false; } $license_info = \PrimeSliderPro\Base\Prime_Slider_Base::get_register_info(); if (empty($license_info) || empty($license_info->license_title)) { return false; } $license_title = strtolower($license_info->license_title); // Check if license title contains 'extended' if (strpos($license_title, 'extended') !== false) { return true; } return false; } /** * Check if a biggopti is compatible with the current plugin installation * * @param object $biggopti The biggopti data from the API. * @return bool True if the biggopti should be shown, false otherwise. */ private function is_biggopti_compatible_with_plugin($biggopti) { // Get current plugin info $current_plugin_slug = $this->get_current_plugin_slug(); $is_pro_active = function_exists('_is_ps_pro_activated') ? _is_ps_pro_activated() : false; $is_lite_active = $current_plugin_slug === 'bdthemes-prime-slider-lite'; $is_pro_plugin = $current_plugin_slug === 'bdthemes-prime-slider'; // Get biggopti targets from API, default to ['both'] $client_targets = (isset($biggopti->client_targets) && is_array($biggopti->client_targets)) ? $biggopti->client_targets : ['both']; // True if 'pro_targeted' is one of the targets $pro_targeted = in_array('pro_targeted', $client_targets, true); // Ensure client_targets is always an array if (!is_array($client_targets)) { $client_targets = [$client_targets]; } // Handle pro_targeted parameter (only for free version) if ($pro_targeted && $is_lite_active) { // If pro_targeted is true, only show if pro is NOT active $should_show = !$is_pro_active; return $should_show; } // Check if any of the client targets match current plugin status foreach ($client_targets as $target) { $target = trim($target); // Clean up any whitespace switch ($target) { case 'pro': // Pro-only biggopties: show only if pro is active if ($is_pro_active) { return true; } break; case 'free': if ($is_lite_active) { return true; } break; } } return false; } /** * Get current plugin slug * * @return string */ private function get_current_plugin_slug() { // Get plugin basename from current file $plugin_file = plugin_basename(BDTPS_CORE__FILE__); // Extract plugin slug from basename $plugin_slug = dirname($plugin_file); return $plugin_slug; } /** * Render API biggopti HTML * * @param object $biggopti * @return string */ private function render_api_biggopti($biggopti) { ob_start(); // Add custom CSS if provided if (isset($biggopti->custom_css) && !empty($biggopti->custom_css)) { echo ''; } // Prepare background styles $background_style = ''; $wrapper_classes = 'bdt-biggopti-wrapper'; if (isset($biggopti->background_color) && !empty($biggopti->background_color)) { $background_style .= 'background-color: ' . esc_attr($biggopti->background_color) . ';'; } if (isset($biggopti->image) && !empty($biggopti->image)) { $background_style .= 'background-image: url(' . esc_url($biggopti->image) . ');'; $wrapper_classes .= ' has-background-image'; } ?>