| @@ -1,14 +1,16 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace TierPricingTable\Admin; |
| 4 | 4 | |
| 5 | +use TierPricingTable\Freemius ; | |
| 6 | +use TierPricingTable\Settings\Settings ; | |
| 7 | +use TierPricingTable\TierPricingTablePlugin ; | |
| 5 | 8 | use Premmerce\SDK\V2\FileManager\FileManager ; |
| 6 | 9 | use TierPricingTable\Admin\ProductManagers\SimpleProductManager ; |
| 7 | 10 | use TierPricingTable\Admin\ProductManagers\VariationProductManager ; |
| 8 | -use TierPricingTable\Freemius ; | |
| 9 | -use TierPricingTable\Settings\Settings ; | |
| 10 | -use TierPricingTable\TierPricingTablePlugin ; | |
| 11 | +use TierPricingTable\Admin\Export\Woocommerce as WooCommerceExport ; | |
| 12 | +use TierPricingTable\Admin\Import\Woocommerce as WooCommerceImport ; | |
| 11 | 13 | /** |
| 12 | 14 | * Class Admin |
| 13 | 15 | * |
| 14 | 16 | * @package TierPricingTable\Admin |
| @@ -49,22 +51,38 @@ | ||
| 49 | 51 | add_action( 'admin_enqueue_scripts', [ $this, 'enqueueAssets' ] ); |
| 50 | 52 | if ( get_transient( 'tier_pricing_table_activated' ) ) { |
| 51 | 53 | add_action( 'admin_notices', [ $this, 'showActivationMessage' ] ); |
| 52 | 54 | } |
| 55 | + | |
| 53 | 56 | 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 | + 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(), | |
| 57 | 68 | ] ); |
| 69 | + $this->fileManager->includeTemplate( 'admin/only-in-premium-script.php' ); | |
| 58 | 70 | } ); |
| 59 | 71 | } |
| 72 | + | |
| 60 | 73 | } |
| 61 | 74 | |
| 75 | + /** | |
| 76 | + * Init Managers | |
| 77 | + */ | |
| 62 | 78 | public function initManagers() |
| 63 | 79 | { |
| 64 | 80 | $this->managers = [ |
| 65 | 81 | SimpleProductManager::class => new SimpleProductManager( $this->fileManager, $this->settings, $this->licence ), |
| 66 | 82 | VariationProductManager::class => new VariationProductManager( $this->fileManager, $this->settings, $this->licence ), |
| 83 | + WooCommerceExport::class => new WooCommerceExport(), | |
| 84 | + WooCommerceImport::class => new WooCommerceImport(), | |
| 67 | 85 | ]; |
| 68 | 86 | } |
| 69 | 87 | |
| 70 | 88 | /** |
| @@ -72,9 +90,9 @@ | ||
| 72 | 90 | */ |
| 73 | 91 | public function showActivationMessage() |
| 74 | 92 | { |
| 75 | 93 | $link = $this->settings->getLink(); |
| 76 | - $this->fileManager->includeTemplate( 'admin/activation-message.php', [ | |
| 94 | + $this->fileManager->includeTemplate( 'admin/alerts/activation-alert.php', [ | |
| 77 | 95 | 'link' => $link, |
| 78 | 96 | ] ); |
| 79 | 97 | delete_transient( 'tiered_pricing_table_activated' ); |
| 80 | 98 | } |
| @@ -85,11 +103,11 @@ | ||
| 85 | 103 | * @param $page |
| 86 | 104 | */ |
| 87 | 105 | public function enqueueAssets( $page ) |
| 88 | 106 | { |
| 89 | - global $post ; | |
| 107 | + global $post, $page ; | |
| 90 | 108 | |
| 91 | - if ( ($page == 'post.php' || ($page = 'post_new.php')) && $post && $post->post_type == 'product' ) { | |
| 109 | + if ( isset( $_GET['tab'] ) && $_GET['tab'] == Settings::SETTINGS_PAGE || ($page == 'post.php' || ($page = 'post_new.php')) && $post && $post->post_type == 'product' ) { | |
| 92 | 110 | wp_enqueue_script( |
| 93 | 111 | 'tier-pricing-table-admin-js', |
| 94 | 112 | $this->fileManager->locateAsset( 'admin/main.js' ), |
| 95 | 113 | 'jquery', |