| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yatra\Core; |
| 4 |
|
| 5 |
defined('ABSPATH') || exit; |
| 6 |
|
| 7 |
/** |
| 8 |
* Yatra Premium Features Management |
| 9 |
* |
| 10 |
* Handles premium feature display, upgrades, and restrictions |
| 11 |
* |
| 12 |
* @class Premium |
| 13 |
* @package Yatra\Core |
| 14 |
* @since 2.2.14 |
| 15 |
*/ |
| 16 |
class Premium |
| 17 |
{ |
| 18 |
/** |
| 19 |
* Premium upgrade URL |
| 20 |
*/ |
| 21 |
const UPGRADE_URL = 'https://wpyatra.com/pricing/'; |
| 22 |
|
| 23 |
/** |
| 24 |
* Premium features list |
| 25 |
*/ |
| 26 |
private static $premium_features = [ |
| 27 |
'services' => [ |
| 28 |
'title' => 'Yatra Services', |
| 29 |
'description' => 'Add extra services which can be free or paid into your tour package', |
| 30 |
'icon' => 'dashicons-admin-tools', |
| 31 |
'benefits' => [ |
| 32 |
'Add unlimited extra services to tours', |
| 33 |
'Configure free or paid services', |
| 34 |
'Service selection during booking', |
| 35 |
'Flexible pricing options', |
| 36 |
'Enhanced customer experience' |
| 37 |
] |
| 38 |
], |
| 39 |
'availability_conditions' => [ |
| 40 |
'title' => 'Availability Conditions', |
| 41 |
'description' => 'Enable/disable tour packages on specific date conditions with advanced availability management', |
| 42 |
'icon' => 'dashicons-calendar-alt', |
| 43 |
'benefits' => [ |
| 44 |
'Date-specific availability rules', |
| 45 |
'Advanced booking conditions', |
| 46 |
'Flexible tour scheduling', |
| 47 |
'Seasonal availability control', |
| 48 |
'Automated availability management' |
| 49 |
] |
| 50 |
], |
| 51 |
'downloads' => [ |
| 52 |
'title' => 'Yatra Downloads', |
| 53 |
'description' => 'Add downloadable files like PDF, DOC, images, ZIP into your tour packages', |
| 54 |
'icon' => 'dashicons-download', |
| 55 |
'benefits' => [ |
| 56 |
'Multiple file format support', |
| 57 |
'Easy file management', |
| 58 |
'Customer download access', |
| 59 |
'Tour documentation sharing', |
| 60 |
'Enhanced tour information' |
| 61 |
] |
| 62 |
], |
| 63 |
'partial_payment' => [ |
| 64 |
'title' => 'Yatra Partial Payment', |
| 65 |
'description' => 'Enable deposit payment feature for tour bookings with flexible payment options', |
| 66 |
'icon' => 'dashicons-money-alt', |
| 67 |
'benefits' => [ |
| 68 |
'Deposit payment system', |
| 69 |
'Flexible payment schedules', |
| 70 |
'Improved booking conversion', |
| 71 |
'Customer payment flexibility', |
| 72 |
'Better cash flow management' |
| 73 |
] |
| 74 |
], |
| 75 |
'reviews_rating' => [ |
| 76 |
'title' => 'Review and Rating', |
| 77 |
'description' => 'Enable review and rating feature on tour packages to build trust and credibility', |
| 78 |
'icon' => 'dashicons-star-filled', |
| 79 |
'benefits' => [ |
| 80 |
'Customer review system', |
| 81 |
'Star rating display', |
| 82 |
'Trust building features', |
| 83 |
'Social proof elements', |
| 84 |
'Enhanced tour credibility' |
| 85 |
] |
| 86 |
], |
| 87 |
'payment_gateways' => [ |
| 88 |
'title' => 'Premium Payment Gateways', |
| 89 |
'description' => 'Multiple premium payment options including Stripe, Authorize.Net, Square, and Razorpay', |
| 90 |
'icon' => 'dashicons-money', |
| 91 |
'benefits' => [ |
| 92 |
'Stripe payment integration', |
| 93 |
'Authorize.Net support', |
| 94 |
'Square payment gateway', |
| 95 |
'Razorpay integration', |
| 96 |
'Secure payment processing' |
| 97 |
] |
| 98 |
], |
| 99 |
'downloads' => [ |
| 100 |
'title' => 'Yatra Downloads', |
| 101 |
'description' => 'Add downloadable files like PDF, DOC, images, ZIP into your tour packages', |
| 102 |
'icon' => 'dashicons-download', |
| 103 |
'benefits' => [ |
| 104 |
'Multiple file format support', |
| 105 |
'Easy file management', |
| 106 |
'Customer download access', |
| 107 |
'Tour documentation sharing', |
| 108 |
'Enhanced tour information' |
| 109 |
] |
| 110 |
], |
| 111 |
'google_calendar' => [ |
| 112 |
'title' => 'Google Calendar Integration', |
| 113 |
'description' => 'Sync tour schedules with Google Calendar for seamless booking management', |
| 114 |
'icon' => 'dashicons-calendar-alt', |
| 115 |
'benefits' => [ |
| 116 |
'Automatic calendar sync', |
| 117 |
'Real-time availability updates', |
| 118 |
'Google Calendar API integration', |
| 119 |
'Seamless booking workflow', |
| 120 |
'Enhanced scheduling management' |
| 121 |
] |
| 122 |
] |
| 123 |
]; |
| 124 |
|
| 125 |
/** |
| 126 |
* Initialize premium features |
| 127 |
*/ |
| 128 |
public static function init() |
| 129 |
{ |
| 130 |
add_action('admin_menu', [__CLASS__, 'add_premium_menus'], 100); |
| 131 |
add_action('add_meta_boxes', [__CLASS__, 'add_premium_metaboxes']); |
| 132 |
add_action('admin_enqueue_scripts', [__CLASS__, 'enqueue_premium_assets']); |
| 133 |
add_action('wp_ajax_yatra_premium_redirect', [__CLASS__, 'handle_premium_redirect']); |
| 134 |
add_filter('yatra_settings_tabs_array', [__CLASS__, 'add_premium_settings_tabs'], 999); |
| 135 |
} |
| 136 |
|
| 137 |
/** |
| 138 |
* Add premium submenus under Tours |
| 139 |
*/ |
| 140 |
public static function add_premium_menus() |
| 141 |
{ |
| 142 |
// Services submenu |
| 143 |
add_submenu_page( |
| 144 |
'edit.php?post_type=tour', |
| 145 |
__('Services', 'yatra'), |
| 146 |
__('Services', 'yatra'), |
| 147 |
'manage_options', |
| 148 |
'yatra-services', |
| 149 |
[__CLASS__, 'render_services_page'] |
| 150 |
); |
| 151 |
|
| 152 |
// Availability Conditions submenu |
| 153 |
add_submenu_page( |
| 154 |
'edit.php?post_type=tour', |
| 155 |
__('Availability Conditions', 'yatra'), |
| 156 |
__('Availability Conditions', 'yatra'), |
| 157 |
'manage_options', |
| 158 |
'yatra-availability-conditions', |
| 159 |
[__CLASS__, 'render_availability_conditions_page'] |
| 160 |
); |
| 161 |
} |
| 162 |
|
| 163 |
/** |
| 164 |
* Render Services premium page |
| 165 |
*/ |
| 166 |
public static function render_services_page() |
| 167 |
{ |
| 168 |
self::render_premium_page('services'); |
| 169 |
} |
| 170 |
|
| 171 |
/** |
| 172 |
* Render Availability Conditions premium page |
| 173 |
*/ |
| 174 |
public static function render_availability_conditions_page() |
| 175 |
{ |
| 176 |
self::render_premium_page('availability_conditions'); |
| 177 |
} |
| 178 |
|
| 179 |
/** |
| 180 |
* Render premium upgrade page |
| 181 |
*/ |
| 182 |
private static function render_premium_page($feature) |
| 183 |
{ |
| 184 |
$feature_data = self::$premium_features[$feature] ?? null; |
| 185 |
|
| 186 |
if (!$feature_data) { |
| 187 |
return; |
| 188 |
} |
| 189 |
|
| 190 |
?> |
| 191 |
<div class="yatra-saas-page"> |
| 192 |
<!-- Hero Section with Premium Design --> |
| 193 |
<div class="yatra-saas-hero"> |
| 194 |
<div class="yatra-hero-bg-pattern" data-speed="0.5"></div> |
| 195 |
<div class="yatra-container"> |
| 196 |
<div class="yatra-hero-content" data-aos="fade-up" data-aos-delay="100"> |
| 197 |
<div class="yatra-hero-badge"> |
| 198 |
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 199 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"/> |
| 200 |
</svg> |
| 201 |
<span><?php _e('Premium Feature', 'yatra'); ?></span> |
| 202 |
</div> |
| 203 |
|
| 204 |
<div class="yatra-hero-icon" data-aos="zoom-in" data-aos-delay="200"> |
| 205 |
<div class="yatra-icon-wrapper"> |
| 206 |
<span class="dashicons <?php echo esc_attr($feature_data['icon']); ?>"></span> |
| 207 |
<div class="yatra-icon-glow"></div> |
| 208 |
</div> |
| 209 |
</div> |
| 210 |
|
| 211 |
<h1 data-aos="fade-up" data-aos-delay="300"><?php echo esc_html($feature_data['title']); ?></h1> |
| 212 |
<p data-aos="fade-up" data-aos-delay="400"><?php echo esc_html($feature_data['description']); ?></p> |
| 213 |
|
| 214 |
<!-- Premium Stats --> |
| 215 |
<div class="yatra-hero-stats" data-aos="fade-up" data-aos-delay="500"> |
| 216 |
<div class="yatra-stat"> |
| 217 |
<span class="yatra-stat-number">1000+</span> |
| 218 |
<span class="yatra-stat-label"><?php _e('Worldwide Customers', 'yatra'); ?></span> |
| 219 |
</div> |
| 220 |
<div class="yatra-stat"> |
| 221 |
<span class="yatra-stat-number">7 Days</span> |
| 222 |
<span class="yatra-stat-label"><?php _e('Money Back', 'yatra'); ?></span> |
| 223 |
</div> |
| 224 |
<div class="yatra-stat"> |
| 225 |
<span class="yatra-stat-number">24/7</span> |
| 226 |
<span class="yatra-stat-label"><?php _e('Support', 'yatra'); ?></span> |
| 227 |
</div> |
| 228 |
</div> |
| 229 |
|
| 230 |
<div class="yatra-hero-cta" data-aos="fade-up" data-aos-delay="600"> |
| 231 |
<a href="https://wpyatra.com/pricing/" class="yatra-cta-primary" target="_blank"> |
| 232 |
<span><?php _e('Upgrade to Pro', 'yatra'); ?></span> |
| 233 |
<svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 234 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7l5 5m0 0l-5 5m5-5H6"/> |
| 235 |
</svg> |
| 236 |
</a> |
| 237 |
<p class="yatra-cta-note"> |
| 238 |
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 239 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/> |
| 240 |
</svg> |
| 241 |
<?php _e('7-day money-back guarantee', 'yatra'); ?> |
| 242 |
</p> |
| 243 |
</div> |
| 244 |
</div> |
| 245 |
</div> |
| 246 |
</div> |
| 247 |
|
| 248 |
<!-- Benefits Section --> |
| 249 |
<div class="yatra-saas-benefits"> |
| 250 |
<div class="yatra-container"> |
| 251 |
<div class="yatra-section-header" data-aos="fade-up"> |
| 252 |
<h2><?php _e('What you get with this feature:', 'yatra'); ?></h2> |
| 253 |
<p><?php _e('Unlock powerful capabilities that will transform your tour business', 'yatra'); ?></p> |
| 254 |
</div> |
| 255 |
<div class="yatra-benefits-grid"> |
| 256 |
<?php foreach ($feature_data['benefits'] as $index => $benefit): ?> |
| 257 |
<div class="yatra-benefit-card" data-aos="fade-up" data-aos-delay="<?php echo ($index * 100) + 200; ?>"> |
| 258 |
<div class="yatra-benefit-icon"> |
| 259 |
<svg width="24" height="24" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 260 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/> |
| 261 |
</svg> |
| 262 |
</div> |
| 263 |
<div class="yatra-benefit-content"> |
| 264 |
<h4><?php echo esc_html($benefit); ?></h4> |
| 265 |
</div> |
| 266 |
</div> |
| 267 |
<?php endforeach; ?> |
| 268 |
</div> |
| 269 |
</div> |
| 270 |
</div> |
| 271 |
|
| 272 |
<!-- Showcase Section --> |
| 273 |
<div class="yatra-saas-showcase"> |
| 274 |
<div class="yatra-container"> |
| 275 |
<div class="yatra-section-header" data-aos="fade-up"> |
| 276 |
<h2><?php _e('Complete Premium Suite', 'yatra'); ?></h2> |
| 277 |
<p><?php _e('Get access to all premium features with one upgrade', 'yatra'); ?></p> |
| 278 |
</div> |
| 279 |
<div class="yatra-showcase-grid"> |
| 280 |
<?php foreach (self::$premium_features as $key => $extension): ?> |
| 281 |
<div class="yatra-showcase-card <?php echo $key === $feature ? 'featured' : ''; ?>" data-aos="fade-up" data-aos-delay="<?php echo ($key === $feature ? 0 : 100); ?>"> |
| 282 |
<div class="yatra-showcase-header"> |
| 283 |
<div class="yatra-showcase-icon"> |
| 284 |
<span class="dashicons <?php echo esc_attr($extension['icon']); ?>"></span> |
| 285 |
</div> |
| 286 |
<?php if ($key === $feature): ?> |
| 287 |
<div class="yatra-featured-badge"> |
| 288 |
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 289 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"/> |
| 290 |
</svg> |
| 291 |
<span><?php _e('Current Feature', 'yatra'); ?></span> |
| 292 |
</div> |
| 293 |
<?php endif; ?> |
| 294 |
</div> |
| 295 |
<div class="yatra-showcase-content"> |
| 296 |
<h3><?php echo esc_html($extension['title']); ?></h3> |
| 297 |
<p><?php echo esc_html($extension['description']); ?></p> |
| 298 |
</div> |
| 299 |
<div class="yatra-showcase-footer"> |
| 300 |
<div class="yatra-feature-status"> |
| 301 |
<?php if ($key === $feature): ?> |
| 302 |
<span class="yatra-status-current"><?php _e('This Feature', 'yatra'); ?></span> |
| 303 |
<?php else: ?> |
| 304 |
<span class="yatra-status-available"><?php _e('Available in Pro', 'yatra'); ?></span> |
| 305 |
<?php endif; ?> |
| 306 |
</div> |
| 307 |
</div> |
| 308 |
</div> |
| 309 |
<?php endforeach; ?> |
| 310 |
</div> |
| 311 |
</div> |
| 312 |
</div> |
| 313 |
|
| 314 |
<!-- Bottom CTA Section --> |
| 315 |
<div class="yatra-saas-cta"> |
| 316 |
<div class="yatra-cta-bg-pattern" data-speed="0.3"></div> |
| 317 |
<div class="yatra-container"> |
| 318 |
<div class="yatra-cta-content" data-aos="fade-up"> |
| 319 |
<div class="yatra-cta-badge"> |
| 320 |
<svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 321 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/> |
| 322 |
</svg> |
| 323 |
<span><?php _e('Limited Time Offer', 'yatra'); ?></span> |
| 324 |
</div> |
| 325 |
<h2><?php _e('Ready to transform your tour business?', 'yatra'); ?></h2> |
| 326 |
<p><?php _e('Join thousands of successful tour operators who have upgraded to Yatra Pro', 'yatra'); ?></p> |
| 327 |
|
| 328 |
<div class="yatra-cta-actions"> |
| 329 |
<a href="https://wpyatra.com/pricing/" class="yatra-cta-primary large" target="_blank"> |
| 330 |
<span><?php _e('View Pricing Plans', 'yatra'); ?></span> |
| 331 |
<svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 332 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7l5 5m0 0l-5 5m5-5H6"/> |
| 333 |
</svg> |
| 334 |
</a> |
| 335 |
<a href="https://demo.wpyatra.com/" class="yatra-cta-secondary" target="_blank"> |
| 336 |
<span><?php _e('View Live Demo', 'yatra'); ?></span> |
| 337 |
</a> |
| 338 |
</div> |
| 339 |
|
| 340 |
<div class="yatra-cta-guarantees"> |
| 341 |
<div class="yatra-guarantee"> |
| 342 |
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 343 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/> |
| 344 |
</svg> |
| 345 |
<span><?php _e('7-day money-back guarantee', 'yatra'); ?></span> |
| 346 |
</div> |
| 347 |
<div class="yatra-guarantee"> |
| 348 |
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 349 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 5.636l-3.536 3.536m0 5.656l3.536 3.536M9.172 9.172L5.636 5.636m3.536 9.192L5.636 18.364M12 2.25a9.75 9.75 0 100 19.5 9.75 9.75 0 000-19.5z"/> |
| 350 |
</svg> |
| 351 |
<span><?php _e('24/7 premium support', 'yatra'); ?></span> |
| 352 |
</div> |
| 353 |
<div class="yatra-guarantee"> |
| 354 |
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 355 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"/> |
| 356 |
</svg> |
| 357 |
<span><?php _e('Lifetime updates', 'yatra'); ?></span> |
| 358 |
</div> |
| 359 |
</div> |
| 360 |
</div> |
| 361 |
</div> |
| 362 |
</div> |
| 363 |
</div> |
| 364 |
<?php |
| 365 |
} |
| 366 |
|
| 367 |
/** |
| 368 |
* Add premium metaboxes to tour post type |
| 369 |
*/ |
| 370 |
public static function add_premium_metaboxes() |
| 371 |
{ |
| 372 |
add_meta_box( |
| 373 |
'yatra_premium_features', |
| 374 |
__('Premium Features', 'yatra'), |
| 375 |
[__CLASS__, 'render_premium_metabox'], |
| 376 |
'tour', |
| 377 |
'side', |
| 378 |
'high' |
| 379 |
); |
| 380 |
} |
| 381 |
|
| 382 |
/** |
| 383 |
* Render premium metabox |
| 384 |
*/ |
| 385 |
public static function render_premium_metabox($post) |
| 386 |
{ |
| 387 |
?> |
| 388 |
<div class="yatra-premium-metabox-compact"> |
| 389 |
<div class="yatra-metabox-header"> |
| 390 |
<div class="yatra-metabox-icon"> |
| 391 |
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 392 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"/> |
| 393 |
</svg> |
| 394 |
</div> |
| 395 |
<h4><?php _e('Premium Features', 'yatra'); ?></h4> |
| 396 |
</div> |
| 397 |
|
| 398 |
<div class="yatra-metabox-features-list"> |
| 399 |
<div class="yatra-feature-item"> |
| 400 |
<span class="dashicons dashicons-admin-tools"></span> |
| 401 |
<span><?php _e('Services', 'yatra'); ?></span> |
| 402 |
</div> |
| 403 |
<div class="yatra-feature-item"> |
| 404 |
<span class="dashicons dashicons-calendar-alt"></span> |
| 405 |
<span><?php _e('Availability Conditions', 'yatra'); ?></span> |
| 406 |
</div> |
| 407 |
<div class="yatra-feature-item"> |
| 408 |
<span class="dashicons dashicons-download"></span> |
| 409 |
<span><?php _e('Downloads', 'yatra'); ?></span> |
| 410 |
</div> |
| 411 |
<div class="yatra-feature-item"> |
| 412 |
<span class="dashicons dashicons-money-alt"></span> |
| 413 |
<span><?php _e('Partial Payment', 'yatra'); ?></span> |
| 414 |
</div> |
| 415 |
<div class="yatra-feature-item"> |
| 416 |
<span class="dashicons dashicons-star-filled"></span> |
| 417 |
<span><?php _e('Reviews & Ratings', 'yatra'); ?></span> |
| 418 |
</div> |
| 419 |
<div class="yatra-feature-item"> |
| 420 |
<span class="dashicons dashicons-money"></span> |
| 421 |
<span><?php _e('Payment Gateways', 'yatra'); ?></span> |
| 422 |
</div> |
| 423 |
</div> |
| 424 |
|
| 425 |
<div class="yatra-metabox-cta"> |
| 426 |
<a href="https://wpyatra.com/pricing/" class="yatra-upgrade-button" target="_blank"> |
| 427 |
<?php _e('Upgrade to Pro', 'yatra'); ?> |
| 428 |
</a> |
| 429 |
</div> |
| 430 |
</div> |
| 431 |
<?php |
| 432 |
} |
| 433 |
|
| 434 |
/** |
| 435 |
* Enqueue premium assets |
| 436 |
*/ |
| 437 |
public static function enqueue_premium_assets($hook) |
| 438 |
{ |
| 439 |
// Only load on relevant admin pages |
| 440 |
if (!self::should_load_premium_assets($hook)) { |
| 441 |
return; |
| 442 |
} |
| 443 |
|
| 444 |
wp_enqueue_style( |
| 445 |
'yatra-premium-admin', |
| 446 |
YATRA_PLUGIN_URI . '/assets/admin/css/premium.css', |
| 447 |
[], |
| 448 |
YATRA_VERSION |
| 449 |
); |
| 450 |
|
| 451 |
wp_enqueue_script( |
| 452 |
'yatra-premium-admin', |
| 453 |
YATRA_PLUGIN_URI . '/assets/admin/js/premium.js', |
| 454 |
['jquery'], |
| 455 |
YATRA_VERSION, |
| 456 |
true |
| 457 |
); |
| 458 |
|
| 459 |
wp_localize_script('yatra-premium-admin', 'yatraPremium', [ |
| 460 |
'upgradeUrl' => self::UPGRADE_URL, |
| 461 |
'nonce' => wp_create_nonce('yatra_premium_nonce'), |
| 462 |
'strings' => [ |
| 463 |
'upgrading' => __('Redirecting to upgrade...', 'yatra'), |
| 464 |
'error' => __('Something went wrong. Please try again.', 'yatra') |
| 465 |
] |
| 466 |
]); |
| 467 |
} |
| 468 |
|
| 469 |
/** |
| 470 |
* Check if premium assets should be loaded |
| 471 |
*/ |
| 472 |
private static function should_load_premium_assets($hook) |
| 473 |
{ |
| 474 |
global $post_type; |
| 475 |
|
| 476 |
// Tour edit screens |
| 477 |
if ($post_type === 'tour' && in_array($hook, ['post.php', 'post-new.php'])) { |
| 478 |
return true; |
| 479 |
} |
| 480 |
|
| 481 |
// Yatra settings page |
| 482 |
if (isset($_GET['page']) && $_GET['page'] === 'yatra-settings') { |
| 483 |
return true; |
| 484 |
} |
| 485 |
|
| 486 |
// Premium feature pages |
| 487 |
if (isset($_GET['page']) && in_array($_GET['page'], ['yatra-services', 'yatra-availability-conditions'])) { |
| 488 |
return true; |
| 489 |
} |
| 490 |
|
| 491 |
return false; |
| 492 |
} |
| 493 |
|
| 494 |
/** |
| 495 |
* Handle premium redirect AJAX |
| 496 |
*/ |
| 497 |
public static function handle_premium_redirect() |
| 498 |
{ |
| 499 |
check_ajax_referer('yatra_premium_nonce', 'nonce'); |
| 500 |
|
| 501 |
wp_send_json_success([ |
| 502 |
'redirect_url' => self::UPGRADE_URL |
| 503 |
]); |
| 504 |
} |
| 505 |
|
| 506 |
/** |
| 507 |
* Get premium features |
| 508 |
*/ |
| 509 |
public static function get_premium_features() |
| 510 |
{ |
| 511 |
return self::$premium_features; |
| 512 |
} |
| 513 |
|
| 514 |
/** |
| 515 |
* Check if feature is premium |
| 516 |
*/ |
| 517 |
public static function is_premium_feature($feature) |
| 518 |
{ |
| 519 |
return array_key_exists($feature, self::$premium_features); |
| 520 |
} |
| 521 |
|
| 522 |
/** |
| 523 |
* Get upgrade URL |
| 524 |
*/ |
| 525 |
public static function get_upgrade_url() |
| 526 |
{ |
| 527 |
return self::UPGRADE_URL; |
| 528 |
} |
| 529 |
|
| 530 |
/** |
| 531 |
* Add premium settings tabs |
| 532 |
*/ |
| 533 |
public static function add_premium_settings_tabs($tabs) |
| 534 |
{ |
| 535 |
// Add Downloads premium tab |
| 536 |
$tabs['downloads'] = array( |
| 537 |
'label' => __('Downloads', 'yatra'), |
| 538 |
'description' => __('Manage downloadable files and tour resources', 'yatra'), |
| 539 |
'icon' => '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7,10 12,15 17,10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>', |
| 540 |
'premium' => true, |
| 541 |
'redirect_url' => 'https://wpyatra.com/pricing/' |
| 542 |
); |
| 543 |
|
| 544 |
// Add Google premium tab |
| 545 |
$tabs['google'] = array( |
| 546 |
'label' => __('Google', 'yatra'), |
| 547 |
'description' => __('Configure Google Calendar integration and API settings', 'yatra'), |
| 548 |
'icon' => '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><polygon points="10,8 16,12 10,16 10,8"/></svg>', |
| 549 |
'premium' => true, |
| 550 |
'redirect_url' => 'https://wpyatra.com/pricing/' |
| 551 |
); |
| 552 |
|
| 553 |
return $tabs; |
| 554 |
} |
| 555 |
|
| 556 |
/** |
| 557 |
* Handle premium settings page output |
| 558 |
*/ |
| 559 |
public static function output_premium_settings_page($tab) |
| 560 |
{ |
| 561 |
if ($tab === 'downloads' || $tab === 'google') { |
| 562 |
self::render_premium_settings_page($tab); |
| 563 |
} |
| 564 |
} |
| 565 |
|
| 566 |
/** |
| 567 |
* Render premium settings page |
| 568 |
*/ |
| 569 |
private static function render_premium_settings_page($feature) |
| 570 |
{ |
| 571 |
$feature_data = self::$premium_features[$feature] ?? null; |
| 572 |
|
| 573 |
if (!$feature_data) { |
| 574 |
return; |
| 575 |
} |
| 576 |
|
| 577 |
?> |
| 578 |
<div class="yatra-premium-settings-page"> |
| 579 |
<div class="yatra-premium-settings-header"> |
| 580 |
<div class="yatra-premium-icon"> |
| 581 |
<span class="dashicons <?php echo esc_attr($feature_data['icon']); ?>"></span> |
| 582 |
</div> |
| 583 |
<div class="yatra-premium-content"> |
| 584 |
<h2><?php echo esc_html($feature_data['title']); ?></h2> |
| 585 |
<p><?php echo esc_html($feature_data['description']); ?></p> |
| 586 |
</div> |
| 587 |
<div class="yatra-premium-badge"> |
| 588 |
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 589 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"/> |
| 590 |
</svg> |
| 591 |
<span><?php _e('Premium Feature', 'yatra'); ?></span> |
| 592 |
</div> |
| 593 |
</div> |
| 594 |
|
| 595 |
<div class="yatra-premium-settings-content"> |
| 596 |
<div class="yatra-premium-card"> |
| 597 |
<div class="yatra-premium-card-header"> |
| 598 |
<h3><?php _e('Feature Benefits', 'yatra'); ?></h3> |
| 599 |
</div> |
| 600 |
<div class="yatra-premium-benefits"> |
| 601 |
<?php foreach ($feature_data['benefits'] as $benefit): ?> |
| 602 |
<div class="yatra-benefit-item"> |
| 603 |
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 604 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/> |
| 605 |
</svg> |
| 606 |
<span><?php echo esc_html($benefit); ?></span> |
| 607 |
</div> |
| 608 |
<?php endforeach; ?> |
| 609 |
</div> |
| 610 |
</div> |
| 611 |
|
| 612 |
<div class="yatra-premium-cta"> |
| 613 |
<div class="yatra-cta-content"> |
| 614 |
<h3><?php _e('Ready to unlock this feature?', 'yatra'); ?></h3> |
| 615 |
<p><?php _e('Upgrade to Yatra Pro and get access to all premium features', 'yatra'); ?></p> |
| 616 |
<div class="yatra-cta-buttons"> |
| 617 |
<a href="https://wpyatra.com/pricing/" class="yatra-cta-primary" target="_blank"> |
| 618 |
<?php _e('Upgrade to Pro', 'yatra'); ?> |
| 619 |
</a> |
| 620 |
<a href="https://demo.wpyatra.com/" class="yatra-cta-secondary" target="_blank"> |
| 621 |
<?php _e('View Demo', 'yatra'); ?> |
| 622 |
</a> |
| 623 |
</div> |
| 624 |
<div class="yatra-cta-guarantees"> |
| 625 |
<span><?php _e('7-day money-back guarantee', 'yatra'); ?></span> |
| 626 |
<span><?php _e('24/7 support', 'yatra'); ?></span> |
| 627 |
</div> |
| 628 |
</div> |
| 629 |
</div> |
| 630 |
</div> |
| 631 |
</div> |
| 632 |
<?php |
| 633 |
} |
| 634 |
} |