diff( $given_date ); $this->days_diff = $interval->invert ? -$interval->days : $interval->days; return $this->days_diff; } public function get_renewal_text(): array { if ( $this->days_diff <= 30 && $this->days_diff > 0 ) { return [ 'title' => esc_html__( 'Image Optimization Expires Soon!', 'image-optimization' ), 'description' => esc_html__( 'Renew your subscription to maintain optimized images, faster website load times, and high performance.', 'image-optimization' ), 'btn' => esc_html__( 'Turn Auto Renew On', 'image-optimization' ), 'link' => esc_url( 'https://go.elementor.com/io-renew-30/' ), ]; } if ( $this->days_diff <= 0 && $this->days_diff > -7 ) { return [ 'title' => esc_html__( 'Image Optimization Has Expired!', 'image-optimization' ), 'description' => esc_html__( 'Renew your license today to continue enjoying premium image optimization and fast load times.', 'image-optimization' ), 'btn' => esc_html__( 'Renew Now', 'image-optimization' ), 'link' => esc_url( 'https://go.elementor.com/io-renew-expire/' ), ]; } return [ 'title' => esc_html__( 'It’s Not Too Late! Renew Image Optimization', 'image-optimization' ), 'description' => esc_html__( 'Reactivate your license to get back to top image performance.', 'image-optimization' ), 'btn' => esc_html__( 'Renew and Optimize', 'image-optimization' ), 'link' => esc_url( 'https://go.elementor.com/io-renew-post-expire/' ), ]; } public function render_renewal_notice() { $text = $this->get_renewal_text(); ?>
1'; break; } } return $parent_file; } public function __construct() { add_action('current_screen', function () { // @var ImageOptimizer/Modules/ConnectManager/Module $module = Plugin::instance()->modules_manager->get_modules( 'connect-manager' ); if ( ! $module->connect_instance->is_connected() || ! Utils::user_is_admin() ) { return; } $info = Client::get_subscription_info(); if ( empty( $info ) || $info->auto_renew || $this->date_diff_from_current( ( $info->date_next_payment ?? $info->date_end ) ) > 30 ) { return; } add_filter( 'parent_file', [ $this, 'add_media_menu_badge' ] ); if ( Utils::is_media_page() || Utils::is_plugin_page() || Utils::is_single_attachment_page() || Utils::is_media_upload_page() || Utils::is_wp_dashboard_page() || Utils::is_wp_updates_page() ) { add_action( 'admin_notices', [ $this, 'render_renewal_notice' ] ); } }); } }