PluginProbe
Tiered Pricing Table for WooCommerce / trunk
Tiered Pricing Table for WooCommerce vtrunk
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 +49 -75 2.1trunk View file →
@@ -1,20 +1,20 @@
1 1 <?php namespace TierPricingTable;
2 2
3 3 /**
4 4 * Class Freemius
5 + *
5 6 * @package TierPricingTable
6 7 */
7 8 class Freemius {
8 9
9 10 /**
10 - * @var \Freemius
11 + * License
12 + *
13 + * @var self
11 14 */
12 15 private $instance;
13 16
14 - /**
15 - * @var string
16 - */
17 17 private $mainFile;
18 18
19 19 /**
20 20 * Freemius constructor.
@@ -21,10 +21,11 @@
21 21 *
22 22 * @param $mainFile
23 23 */
24 24 public function __construct( $mainFile ) {
25 +
26 + $this->mainFile = $mainFile;
25 27 $this->init();
26 - $this->mainFile = $mainFile;
27 28
28 29 if ( $this->isValid() ) {
29 30 $this->hooks();
30 31 }
@@ -29,98 +30,71 @@
29 30 $this->hooks();
30 31 }
31 32 }
32 33
33 - /**
34 - *
35 - */
36 34 public function hooks() {
37 35 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' );
38 61 }
39 62
40 - /**
41 - * @return bool
42 - */
43 - public function isValid() {
63 + public function isValid(): bool {
44 64 return $this->instance instanceof \Freemius;
45 65 }
46 66
47 - /**
48 - *
49 - */
50 67 public function init() {
51 68 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;
69 + $this->instance = tpt_fs();
57 70 }
58 71 }
59 72
60 - /**
61 - *
62 - */
63 73 public function initPages() {
74 +
64 75 // 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' ] );
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 +
68 80 // 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' ] );
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' ] );
71 84 }
72 85
73 - /**
74 - *
75 - */
76 86 public function renderAccountPage() {
77 - $this->instance->_account_page_load();
78 - $this->instance->_account_page_render();
79 - }
80 87
81 - /**
82 - * @return bool
83 - */
84 - public function isFree() {
85 - return ! $this->instance->is_premium();
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 + }
86 95 }
87 96
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 97 public function renderContactUsPage() {
110 98 $this->instance->_contact_page_render();
111 99 }
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 -}
100 +}