PluginProbe
Tiered Pricing Table for WooCommerce / 2.3.3
Tiered Pricing Table for WooCommerce v2.3.3
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 / Admin / Admin.php

Admin.php in Tiered Pricing Table for WooCommerce 2.3.3, at src/Admin/Admin.php

121 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TierPricingTable\Admin;
4
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 /**
15 * Class Admin
16 *
17 * @package TierPricingTable\Admin
18 */
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 }