PluginProbe
Tiered Pricing Table for WooCommerce / 2.0
Tiered Pricing Table for WooCommerce v2.0
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
← All changes | src/Freemius.php +75 -49 trunk2.0 View file →
@@ -1,20 +1,20 @@
1 1 <?php namespace TierPricingTable;
2 2
3 3 /**
4 4 * Class Freemius
5 - *
6 5 * @package TierPricingTable
7 6 */
8 7 class Freemius {
9 8
10 9 /**
11 - * License
12 - *
13 - * @var self
10 + * @var \Freemius
14 11 */
15 12 private $instance;
16 13
14 + /**
15 + * @var string
16 + */
17 17 private $mainFile;
18 18
19 19 /**
20 20 * Freemius constructor.
@@ -21,11 +21,10 @@
21 21 *
22 22 * @param $mainFile
23 23 */
24 24 public function __construct( $mainFile ) {
25 -
25 + $this->init();
26 26 $this->mainFile = $mainFile;
27 - $this->init();
28 27
29 28 if ( $this->isValid() ) {
30 29 $this->hooks();
31 30 }
@@ -30,71 +29,98 @@
30 29 $this->hooks();
31 30 }
32 31 }
33 32
33 + /**
34 + *
35 + */
34 36 public function hooks() {
35 37 add_action( 'admin_menu', [ $this, 'initPages' ] );
36 -
37 - $this->instance->add_filter( 'templates/pricing.php', function ( $template ) {
38 - ob_start();
39 - ?>
40 -
41 - <style>
42 - #fs_pricing_app {
43 - --fs-ds-blue-300: #faf6f9;
44 - --fs-ds-blue-500: #814c77;
45 - --fs-ds-blue-600: #814c77;
46 - --fs-ds-blue-700: #814c77;
47 - --fs-ds-blue-800: #814c77;
48 - --fs-ds-blue-900: #814c77;
49 -
50 - --fs-ds-theme-background-color: #faf6f9;
51 - }
52 - </style>
53 - <?php
54 -
55 - $style = ob_get_clean();
56 -
57 - return $style . $template;
58 - } );
59 -
60 - $this->instance->add_filter( 'pricing/show_annual_in_monthly', '__return_false' );
61 38 }
62 39
63 - public function isValid(): bool {
40 + /**
41 + * @return bool
42 + */
43 + public function isValid() {
64 44 return $this->instance instanceof \Freemius;
65 45 }
66 46
47 + /**
48 + *
49 + */
67 50 public function init() {
68 51 if ( function_exists( 'tpt_fs' ) ) {
69 - $this->instance = tpt_fs();
52 + $tpt_fs = tpt_fs();
53 +
54 + $tpt_fs->set_basename( true, $this->mainFile );
55 +
56 + $this->instance = $tpt_fs;
70 57 }
71 58 }
72 59
60 + /**
61 + *
62 + */
73 63 public function initPages() {
74 -
75 64 // Account
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 -
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' ] );
80 68 // Contact us
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' ] );
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' ] );
84 71 }
85 72
73 + /**
74 + *
75 + */
86 76 public function renderAccountPage() {
77 + $this->instance->_account_page_load();
78 + $this->instance->_account_page_render();
79 + }
87 80
88 - if ( ! $this->instance->get_user() || $this->instance->is_activation_mode() || $this->instance->is_anonymous() ) {
89 - wp_safe_redirect( admin_url( 'admin.php?page=tier-pricing-table' ) );
90 - exit;
91 - } else {
92 - $this->instance->_account_page_load();
93 - $this->instance->_account_page_render();
94 - }
81 + /**
82 + * @return bool
83 + */
84 + public function isFree() {
85 + return ! $this->instance->is_premium();
95 86 }
96 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 + */
97 109 public function renderContactUsPage() {
98 110 $this->instance->_contact_page_render();
99 111 }
100 -}
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 +}