PluginProbe
Tiered Pricing Table for WooCommerce / 2.2.2
Tiered Pricing Table for WooCommerce v2.2.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
← All changes | src/Admin/Admin.php +117 -117 2.3.42.2.2 View file →
@@ -1,126 +1,126 @@
1 -<?php namespace TierPricingTable\Admin;
1 +<?php
2 2
3 -use TierPricingTable\Admin\ProductManagers\ProductManager;
4 -use TierPricingTable\Freemius;
5 -use TierPricingTable\Settings\Settings;
6 -use TierPricingTable\TierPricingTablePlugin;
7 -use Premmerce\SDK\V2\FileManager\FileManager;
8 -use TierPricingTable\Admin\ProductManagers\SimpleProductManager;
9 -use TierPricingTable\Admin\ProductManagers\VariationProductManager;
10 -use TierPricingTable\Admin\Export\Woocommerce as WooCommerceExport;
11 -use TierPricingTable\Admin\Import\Woocommerce as WooCommerceImport;
3 +namespace TierPricingTable\Admin;
12 4
5 +use TierPricingTable\Freemius ;
6 +use TierPricingTable\Settings\Settings ;
7 +use TierPricingTable\TierPricingTablePlugin ;
8 +use Premmerce\SDK\V2\FileManager\FileManager ;
9 +use TierPricingTable\Admin\ProductManagers\SimpleProductManager ;
10 +use TierPricingTable\Admin\ProductManagers\VariationProductManager ;
11 +use TierPricingTable\Admin\Export\Woocommerce as WooCommerceExport ;
12 +use TierPricingTable\Admin\Import\Woocommerce as WooCommerceImport ;
13 13 /**
14 14 * Class Admin
15 15 *
16 16 * @package TierPricingTable\Admin
17 17 */
18 -class Admin {
18 +class Admin
19 +{
20 + /**
21 + * @var FileManager
22 + */
23 + private $fileManager ;
24 + /**
25 + * @var Settings
26 + */
27 + private $settings ;
28 + /**
29 + * @var array
30 + */
31 + private $managers ;
32 + /**
33 + * @var Freemius
34 + */
35 + private $licence ;
36 + /**
37 + * Admin constructor.
38 + *
39 + * Register menu items and handlers
40 + *
41 + * @param FileManager $fileManager
42 + * @param Freemius $licence
43 + * @param Settings $settings
44 + */
45 + public function __construct( FileManager $fileManager, Freemius $licence, Settings $settings )
46 + {
47 + $this->fileManager = $fileManager;
48 + $this->settings = $settings;
49 + $this->licence = $licence;
50 + $this->initManagers();
51 + add_action( 'admin_enqueue_scripts', [ $this, 'enqueueAssets' ] );
52 + if ( get_transient( 'tier_pricing_table_activated' ) ) {
53 + add_action( 'admin_notices', [ $this, 'showActivationMessage' ] );
54 + }
55 +
56 + if ( $this->licence->isFree() ) {
57 +
58 + if ( tpt_fs()->is_anonymous() || !tpt_fs()->is_installed_on_site() ) {
59 + $template = 'opt-in-alert.php';
60 + } else {
61 + $template = 'upgrade-alert.php';
62 + }
63 +
64 + add_action( 'woocommerce_settings_' . Settings::SETTINGS_PAGE, function () use( $template ) {
65 + $this->fileManager->includeTemplate( 'admin/alerts/' . $template, [
66 + 'upgradeUrl' => $this->licence->getUpgradeLink(),
67 + 'contactUsUrl' => $this->licence->getContactUsPageUrl(),
68 + ] );
69 + $this->fileManager->includeTemplate( 'admin/only-in-premium-script.php' );
70 + } );
71 + }
72 +
73 + }
74 +
75 + /**
76 + * Init Managers
77 + */
78 + public function initManagers()
79 + {
80 + $this->managers = [
81 + SimpleProductManager::class => new SimpleProductManager( $this->fileManager, $this->settings, $this->licence ),
82 + VariationProductManager::class => new VariationProductManager( $this->fileManager, $this->settings, $this->licence ),
83 + WooCommerceExport::class => new WooCommerceExport(),
84 + WooCommerceImport::class => new WooCommerceImport(),
85 + ];
86 + }
87 +
88 + /**
89 + * Show message about activation plugin and advise next step
90 + */
91 + public function showActivationMessage()
92 + {
93 + $link = $this->settings->getLink();
94 + $this->fileManager->includeTemplate( 'admin/alerts/activation-alert.php', [
95 + 'link' => $link,
96 + ] );
97 + delete_transient( 'tiered_pricing_table_activated' );
98 + }
99 +
100 + /**
101 + * Register assets on product create/update page
102 + *
103 + * @param $page
104 + */
105 + public function enqueueAssets( $page )
106 + {
107 + global $post, $page ;
108 +
109 + if ( isset( $_GET['tab'] ) && $_GET['tab'] == Settings::SETTINGS_PAGE || ($page == 'post.php' || ($page = 'post_new.php')) && $post && $post->post_type == 'product' ) {
110 + wp_enqueue_script(
111 + 'tier-pricing-table-admin-js',
112 + $this->fileManager->locateAsset( 'admin/main.js' ),
113 + 'jquery',
114 + TierPricingTablePlugin::VERSION
115 + );
116 + wp_enqueue_style(
117 + 'tier-pricing-table-admin-css',
118 + $this->fileManager->locateAsset( 'admin/style.css' ),
119 + null,
120 + TierPricingTablePlugin::VERSION
121 + );
122 + }
123 +
124 + }
19 125
20 - /**
21 - * @var FileManager
22 - */
23 - private $fileManager;
24 -
25 - /**
26 - * @var Settings
27 - */
28 - private $settings;
29 -
30 - /**
31 - * @var array
32 - */
33 - private $managers;
34 -
35 - /**
36 - * @var Freemius
37 - */
38 - private $licence;
39 -
40 - /**
41 - * Admin constructor.
42 - *
43 - * Register menu items and handlers
44 - *
45 - * @param FileManager $fileManager
46 - * @param Freemius $licence
47 - * @param Settings $settings
48 - */
49 - public function __construct( FileManager $fileManager, Freemius $licence, Settings $settings ) {
50 - $this->fileManager = $fileManager;
51 - $this->settings = $settings;
52 - $this->licence = $licence;
53 -
54 - $this->initManagers();
55 -
56 - add_action( 'admin_enqueue_scripts', [ $this, 'enqueueAssets' ] );
57 -
58 - if ( get_transient( 'tier_pricing_table_activated' ) ) {
59 - add_action( 'admin_notices', [ $this, 'showActivationMessage' ] );
60 - }
61 -
62 - if ( $this->licence->isFree() ) {
63 -
64 - $template = 'upgrade-alert.php';
65 -
66 - add_action( 'woocommerce_settings_' . Settings::SETTINGS_PAGE, function () use ( $template ) {
67 - $this->fileManager->includeTemplate( 'admin/alerts/' . $template, [
68 - 'upgradeUrl' => tpt_fs()->get_upgrade_url(),
69 - 'contactUsUrl' => $this->licence->getContactUsPageUrl()
70 - ] );
71 -
72 - $this->fileManager->includeTemplate( 'admin/only-in-premium-script.php' );
73 - } );
74 - }
75 -
76 - if ( tpt_fs()->is__premium_only() ) {
77 - add_action( 'woocommerce_settings_' . Settings::SETTINGS_PAGE, function () {
78 - $this->fileManager->includeTemplate( 'admin/alerts/premium-thanking-alert.php', [
79 - 'accountUrl' => $this->licence->getAccountPageUrl(),
80 - 'contactUsUrl' => $this->licence->getContactUsPageUrl()
81 - ] );
82 - } );
83 - }
84 - }
85 -
86 - /**
87 - * Init Managers
88 - */
89 - public function initManagers() {
90 -
91 - $this->managers = [
92 - ProductManager::class => new ProductManager( $this->fileManager, $this->settings,
93 - $this->licence ),
94 - VariationProductManager::class => new VariationProductManager( $this->fileManager, $this->settings,
95 - $this->licence ),
96 - WooCommerceExport::class => new WooCommerceExport(),
97 - WooCommerceImport::class => new WooCommerceImport()
98 - ];
99 - }
100 -
101 - /**
102 - * Show message about activation plugin and advise next step
103 - */
104 - public function showActivationMessage() {
105 - $link = $this->settings->getLink();
106 - $this->fileManager->includeTemplate( 'admin/alerts/activation-alert.php', [ 'link' => $link ] );
107 -
108 - delete_transient( 'tiered_pricing_table_activated' );
109 - }
110 -
111 - /**
112 - * Register assets on product create/update page
113 - *
114 - * @param $page
115 - */
116 - public function enqueueAssets( $page ) {
117 - global $post, $page;
118 -
119 - if ( ( isset( $_GET['tab'] ) && $_GET['tab'] == Settings::SETTINGS_PAGE ) || ( ( $page == 'post.php' || $page = 'post-new.php' ) && $post && $post->post_type == 'product' ) ) {
120 - wp_enqueue_script( 'tier-pricing-table-admin-js', $this->fileManager->locateAsset( 'admin/main.js' ),
121 - 'jquery', TierPricingTablePlugin::VERSION );
122 - wp_enqueue_style( 'tier-pricing-table-admin-css', $this->fileManager->locateAsset( 'admin/style.css' ),
123 - null, TierPricingTablePlugin::VERSION );
124 - }
125 - }
126 126 }