PluginProbe
Tiered Pricing Table for WooCommerce / 2.3.2
Tiered Pricing Table for WooCommerce v2.3.2
7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 All 90 releases
tier-pricing-table / src / Freemius.php

Freemius.php in Tiered Pricing Table for WooCommerce 2.3.2, at src/Freemius.php

126 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable;
2
3 /**
4 * Class Freemius
5 * @package TierPricingTable
6 */
7 class Freemius {
8
9 /**
10 * @var \Freemius
11 */
12 private $instance;
13
14 /**
15 * @var string
16 */
17 private $mainFile;
18
19 /**
20 * Freemius constructor.
21 *
22 * @param $mainFile
23 */
24 public function __construct( $mainFile ) {
25 $this->init();
26 $this->mainFile = $mainFile;
27
28 if ( $this->isValid() ) {
29 $this->hooks();
30 }
31 }
32
33 /**
34 *
35 */
36 public function hooks() {
37 add_action( 'admin_menu', [ $this, 'initPages' ] );
38 }
39
40 /**
41 * @return bool
42 */
43 public function isValid() {
44 return $this->instance instanceof \Freemius;
45 }
46
47 /**
48 *
49 */
50 public function init() {
51 if ( function_exists( 'tpt_fs' ) ) {
52 $tpt_fs = tpt_fs();
53
54 $tpt_fs->set_basename( true, $this->mainFile );
55
56 $this->instance = $tpt_fs;
57 }
58 }
59
60 /**
61 *
62 */
63 public function initPages() {
64 // Account
65 add_submenu_page( null, __( 'Freemius Account', 'tier-price-table' ),
66 __( 'Freemius Account', 'tier-price-table' ),
67 'manage_options', 'tired-pricing-table-account', [ $this, 'renderAccountPage' ] );
68 // Contact us
69 add_submenu_page( null, __( 'Contact Us', 'tier-price-table' ), __( 'Contact Us', 'tier-price-table' ),
70 'manage_options', 'tired-pricing-table-contact-us', [ $this, 'renderContactUsPage' ] );
71 }
72
73 /**
74 *
75 */
76 public function renderAccountPage() {
77 $this->instance->_account_page_load();
78 $this->instance->_account_page_render();
79 }
80
81 /**
82 * @return bool
83 */
84 public function isFree() {
85 return ! $this->instance->is_premium();
86 }
87
88 /**
89 * @return bool
90 */
91 public function isPremium() {
92 return ! $this->instance->is_premium();
93 }
94
95 public function isPremiumOnly() {
96 return $this->instance->is__premium_only();
97 }
98
99 /**
100 * @return string
101 */
102 public function getAccountPageUrl() {
103 return admin_url( 'admin.php?page=tired-pricing-table-account' );
104 }
105
106 /**
107 *
108 */
109 public function renderContactUsPage() {
110 $this->instance->_contact_page_render();
111 }
112
113 /**
114 * @return string
115 */
116 public function getUpgradeLink() {
117 return $this->instance->get_upgrade_url();
118 }
119
120 /**
121 * @return string
122 */
123 public function getContactUsPageUrl() {
124 return admin_url( 'admin.php?page=tired-pricing-table-contact-us' );
125 }
126 }