| @@ -5,18 +5,18 @@ | ||
| 5 | 5 | * |
| 6 | 6 | * @package TierPricingTable |
| 7 | 7 | */ |
| 8 | 8 | class Freemius { |
| 9 | - | |
| 9 | + | |
| 10 | 10 | /** |
| 11 | 11 | * License |
| 12 | 12 | * |
| 13 | - * @var \Freemius | |
| 13 | + * @var self | |
| 14 | 14 | */ |
| 15 | 15 | private $instance; |
| 16 | - | |
| 16 | + | |
| 17 | 17 | private $mainFile; |
| 18 | - | |
| 18 | + | |
| 19 | 19 | /** |
| 20 | 20 | * Freemius constructor. |
| 21 | 21 | * |
| 22 | 22 | * @param $mainFile |
| @@ -21,20 +21,20 @@ | ||
| 21 | 21 | * |
| 22 | 22 | * @param $mainFile |
| 23 | 23 | */ |
| 24 | 24 | public function __construct( $mainFile ) { |
| 25 | - | |
| 25 | + | |
| 26 | 26 | $this->mainFile = $mainFile; |
| 27 | 27 | $this->init(); |
| 28 | - | |
| 28 | + | |
| 29 | 29 | if ( $this->isValid() ) { |
| 30 | 30 | $this->hooks(); |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | - | |
| 33 | + | |
| 34 | 34 | public function hooks() { |
| 35 | 35 | add_action( 'admin_menu', [ $this, 'initPages' ] ); |
| 36 | - | |
| 36 | + | |
| 37 | 37 | $this->instance->add_filter( 'templates/pricing.php', function ( $template ) { |
| 38 | 38 | ob_start(); |
| 39 | 39 | ?> |
| 40 | 40 | |
| @@ -50,42 +50,42 @@ | ||
| 50 | 50 | --fs-ds-theme-background-color: #faf6f9; |
| 51 | 51 | } |
| 52 | 52 | </style> |
| 53 | 53 | <?php |
| 54 | - | |
| 54 | + | |
| 55 | 55 | $style = ob_get_clean(); |
| 56 | - | |
| 56 | + | |
| 57 | 57 | return $style . $template; |
| 58 | 58 | } ); |
| 59 | - | |
| 59 | + | |
| 60 | 60 | $this->instance->add_filter( 'pricing/show_annual_in_monthly', '__return_false' ); |
| 61 | 61 | } |
| 62 | - | |
| 62 | + | |
| 63 | 63 | public function isValid(): bool { |
| 64 | 64 | return $this->instance instanceof \Freemius; |
| 65 | 65 | } |
| 66 | - | |
| 66 | + | |
| 67 | 67 | public function init() { |
| 68 | 68 | if ( function_exists( 'tpt_fs' ) ) { |
| 69 | 69 | $this->instance = tpt_fs(); |
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | - | |
| 72 | + | |
| 73 | 73 | public function initPages() { |
| 74 | - | |
| 74 | + | |
| 75 | 75 | // Account |
| 76 | 76 | add_submenu_page( '__freemius', __( 'Freemius Account', 'tier-price-table' ), |
| 77 | - __( 'Freemius Account', 'tier-price-table' ), 'manage_options', 'tiered-pricing-table-account', | |
| 78 | - [ $this, 'renderAccountPage' ] ); | |
| 79 | - | |
| 77 | + __( 'Freemius Account', 'tier-price-table' ), 'manage_options', 'tiered-pricing-table-account', | |
| 78 | + [ $this, 'renderAccountPage' ] ); | |
| 79 | + | |
| 80 | 80 | // Contact us |
| 81 | 81 | add_submenu_page( '__freemius', __( 'Contact Us', 'tiered-price-table' ), |
| 82 | - __( 'Contact Us', 'tier-price-table' ), 'manage_options', 'tiered-pricing-table-contact-us', | |
| 83 | - [ $this, 'renderContactUsPage' ] ); | |
| 82 | + __( 'Contact Us', 'tier-price-table' ), 'manage_options', 'tiered-pricing-table-contact-us', | |
| 83 | + [ $this, 'renderContactUsPage' ] ); | |
| 84 | 84 | } |
| 85 | - | |
| 85 | + | |
| 86 | 86 | public function renderAccountPage() { |
| 87 | - | |
| 87 | + | |
| 88 | 88 | if ( ! $this->instance->get_user() || $this->instance->is_activation_mode() || $this->instance->is_anonymous() ) { |
| 89 | 89 | wp_safe_redirect( admin_url( 'admin.php?page=tier-pricing-table' ) ); |
| 90 | 90 | exit; |
| 91 | 91 | } else { |
| @@ -92,9 +92,9 @@ | ||
| 92 | 92 | $this->instance->_account_page_load(); |
| 93 | 93 | $this->instance->_account_page_render(); |
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | - | |
| 96 | + | |
| 97 | 97 | public function renderContactUsPage() { |
| 98 | 98 | $this->instance->_contact_page_render(); |
| 99 | 99 | } |
| 100 | 100 | } |