PluginProbe
Tiered Pricing Table for WooCommerce / 2.0.2
Tiered Pricing Table for WooCommerce v2.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 2.3.4 All 90 releases
tier-pricing-table / src / Admin / Admin.php

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

108 lines 3.1 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 Premmerce\SDK\V2\FileManager\FileManager ;
6 use TierPricingTable\Admin\ProductManagers\SimpleProductManager ;
7 use TierPricingTable\Admin\ProductManagers\VariationProductManager ;
8 use TierPricingTable\Freemius ;
9 use TierPricingTable\Settings\Settings ;
10 use TierPricingTable\TierPricingTablePlugin ;
11 /**
12 * Class Admin
13 *
14 * @package TierPricingTable\Admin
15 */
16 class Admin
17 {
18 /**
19 * @var FileManager
20 */
21 private $fileManager ;
22 /**
23 * @var Settings
24 */
25 private $settings ;
26 /**
27 * @var array
28 */
29 private $managers ;
30 /**
31 * @var Freemius
32 */
33 private $licence ;
34 /**
35 * Admin constructor.
36 *
37 * Register menu items and handlers
38 *
39 * @param FileManager $fileManager
40 * @param Freemius $licence
41 * @param Settings $settings
42 */
43 public function __construct( FileManager $fileManager, Freemius $licence, Settings $settings )
44 {
45 $this->fileManager = $fileManager;
46 $this->settings = $settings;
47 $this->licence = $licence;
48 $this->initManagers();
49 add_action( 'admin_enqueue_scripts', [ $this, 'enqueueAssets' ] );
50 if ( get_transient( 'tier_pricing_table_activated' ) ) {
51 add_action( 'admin_notices', [ $this, 'showActivationMessage' ] );
52 }
53 if ( $this->licence->isFree() ) {
54 add_action( 'woocommerce_settings_' . Settings::SETTINGS_PAGE, function () {
55 $this->fileManager->includeTemplate( 'admin/upgrade-message.php', [
56 'upgradeLink' => $this->licence->getUpgradeLink(),
57 ] );
58 } );
59 }
60 }
61
62 public function initManagers()
63 {
64 $this->managers = [
65 SimpleProductManager::class => new SimpleProductManager( $this->fileManager, $this->settings, $this->licence ),
66 VariationProductManager::class => new VariationProductManager( $this->fileManager, $this->settings, $this->licence ),
67 ];
68 }
69
70 /**
71 * Show message about activation plugin and advise next step
72 */
73 public function showActivationMessage()
74 {
75 $link = $this->settings->getLink();
76 $this->fileManager->includeTemplate( 'admin/activation-message.php', [
77 'link' => $link,
78 ] );
79 delete_transient( 'tiered_pricing_table_activated' );
80 }
81
82 /**
83 * Register assets on product create/update page
84 *
85 * @param $page
86 */
87 public function enqueueAssets( $page )
88 {
89 global $post ;
90
91 if ( ($page == 'post.php' || ($page = 'post_new.php')) && $post && $post->post_type == 'product' ) {
92 wp_enqueue_script(
93 'tier-pricing-table-admin-js',
94 $this->fileManager->locateAsset( 'admin/main.js' ),
95 'jquery',
96 TierPricingTablePlugin::VERSION
97 );
98 wp_enqueue_style(
99 'tier-pricing-table-admin-css',
100 $this->fileManager->locateAsset( 'admin/style.css' ),
101 null,
102 TierPricingTablePlugin::VERSION
103 );
104 }
105
106 }
107
108 }