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