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
tier-pricing-table / src / Freemius.php

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

101 lines 2.1 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 *
6 * @package TierPricingTable
7 */
8 class Freemius {
9
10 /**
11 * License
12 *
13 * @var self
14 */
15 private $instance;
16
17 private $mainFile;
18
19 /**
20 * Freemius constructor.
21 *
22 * @param $mainFile
23 */
24 public function __construct( $mainFile ) {
25
26 $this->mainFile = $mainFile;
27 $this->init();
28
29 if ( $this->isValid() ) {
30 $this->hooks();
31 }
32 }
33
34 public function hooks() {
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' );
61 }
62
63 public function isValid(): bool {
64 return $this->instance instanceof \Freemius;
65 }
66
67 public function init() {
68 if ( function_exists( 'tpt_fs' ) ) {
69 $this->instance = tpt_fs();
70 }
71 }
72
73 public function initPages() {
74
75 // 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
80 // 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' ] );
84 }
85
86 public function renderAccountPage() {
87
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 }
95 }
96
97 public function renderContactUsPage() {
98 $this->instance->_contact_page_render();
99 }
100 }
101