class-admin-notice-custom-css.php
1 week ago
class-admin-notices.php
1 week ago
class-admin.php
1 week ago
class-attachment-fields.php
1 week ago
class-columns.php
1 week ago
class-demo-content.php
1 week ago
class-extensions.php
1 week ago
class-gallery-attachment-modal.php
1 week ago
class-gallery-datasources.php
1 week ago
class-gallery-editor.php
1 week ago
class-gallery-metabox-fields.php
1 week ago
class-gallery-metabox-items.php
1 week ago
class-gallery-metabox-settings-helper.php
1 week ago
class-gallery-metabox-settings.php
1 week ago
class-gallery-metabox-template.php
1 week ago
class-gallery-metaboxes.php
1 week ago
class-menu.php
1 week ago
class-pro-promotion.php
1 week ago
class-settings.php
1 week ago
class-silent-installer-skin.php
1 week ago
class-trial-mode.php
1 week ago
demo-content-galleries.php
1 week ago
demo-content-images.php
1 week ago
index.php
1 week ago
pro-features.php
1 week ago
view-features.php
1 week ago
view-help-demos.php
1 week ago
view-help-getting-started.php
1 week ago
view-help-pro.php
1 week ago
view-help.php
1 week ago
view-system-info.php
1 week ago
class-trial-mode.php
82 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /* |
| 8 | * FooGallery Trial Mode class |
| 9 | */ |
| 10 | |
| 11 | if ( ! class_exists( 'FooGallery_Trial_Mode' ) ) { |
| 12 | class FooGallery_Trial_Mode { |
| 13 | |
| 14 | private $current_plan; |
| 15 | private $is_free; |
| 16 | private $is_trial; |
| 17 | private $plan_starter; |
| 18 | private $plan_expert; |
| 19 | private $plan_commerce; |
| 20 | |
| 21 | function __construct() { |
| 22 | add_action( 'admin_init', array( $this, 'init_trial_mode' ) ); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Returns true if the trial mode is enabled |
| 27 | * @return bool |
| 28 | */ |
| 29 | private function is_trial_mode_enabled() { |
| 30 | return foogallery_get_setting( 'enable_trial_mode' ) === 'on'; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Initialize the trial mode |
| 35 | */ |
| 36 | function init_trial_mode() { |
| 37 | if ( $this->is_trial_mode_enabled() ) { |
| 38 | // Determine current plan, and show promotions based on the current plan. |
| 39 | $fs_instance = foogallery_fs(); |
| 40 | $this->current_plan = $fs_instance->get_plan_name(); |
| 41 | $this->is_free = $fs_instance->is_free_plan(); |
| 42 | $this->is_trial = $fs_instance->is_trial(); |
| 43 | |
| 44 | $this->plan_starter = false; |
| 45 | $this->plan_expert = false; |
| 46 | $this->plan_commerce = false; |
| 47 | |
| 48 | if ( !$this->is_free ) { |
| 49 | if ( FOOGALLERY_PRO_PLAN_STARTER === $this->current_plan ) { |
| 50 | $this->plan_starter = true; |
| 51 | } else if ( FOOGALLERY_PRO_PLAN_EXPERT == $this->current_plan ) { |
| 52 | $this->plan_expert = true; |
| 53 | } else if ( FOOGALLERY_PRO_PLAN_COMMERCE == $this->current_plan ) { |
| 54 | $this->plan_commerce = true; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | add_filter( 'foogallery_gallery_templates', array( $this, 'change_gallery_templates' ), 999 ); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | function change_gallery_templates( $templates ) { |
| 63 | |
| 64 | // add a pulse to the card, so it stands out. |
| 65 | if ( array_key_exists( 'polaroid_new', $templates ) ) { |
| 66 | $templates['polaroid_new']['html'] = '<div data-balloon="' . __( 'This layout is part of PRO Starter plan', 'foogallery' ) . '" class="pulse pro-starter"></div>'; |
| 67 | } |
| 68 | if ( array_key_exists( 'foogridpro', $templates ) ) { |
| 69 | $templates['foogridpro']['html'] = '<div data-balloon="' . __( 'This layout is part of PRO Starter plan', 'foogallery' ) . '" class="pulse pro-starter"></div>'; |
| 70 | } |
| 71 | if ( array_key_exists( 'slider', $templates ) ) { |
| 72 | $templates['slider']['html'] = '<div data-balloon="' . __( 'This layout is part of PRO Starter plan', 'foogallery' ) . '" class="pulse pro-starter"></div>'; |
| 73 | } |
| 74 | if ( array_key_exists( 'product', $templates ) ) { |
| 75 | $templates['product']['html'] = '<div data-balloon="' . __( 'This layout is part of PRO Commerce plan', 'foogallery') . '" class="pulse pro-commerce"></div>'; |
| 76 | } |
| 77 | |
| 78 | return $templates; |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 |