| 1 |
<?php |
| 2 |
|
| 3 |
namespace SpringDevs\Subscription; |
| 4 |
|
| 5 |
use SpringDevs\Subscription\Admin\Integrations; |
| 6 |
use SpringDevs\Subscription\Admin\Required; |
| 7 |
use SpringDevs\Subscription\Admin\Links; |
| 8 |
use SpringDevs\Subscription\Admin\Menu; |
| 9 |
use SpringDevs\Subscription\Admin\Order as AdminOrder; |
| 10 |
use SpringDevs\Subscription\Admin\Product; |
| 11 |
use SpringDevs\Subscription\Admin\ProSettingsFields; |
| 12 |
use SpringDevs\Subscription\Admin\Settings; |
| 13 |
use SpringDevs\Subscription\Admin\Subscriptions; |
| 14 |
use SpringDevs\Subscription\Illuminate\Comments; |
| 15 |
|
| 16 |
/** |
| 17 |
* The admin class |
| 18 |
*/ |
| 19 |
class Admin { |
| 20 |
|
| 21 |
/** |
| 22 |
* Initialize the class |
| 23 |
*/ |
| 24 |
public function __construct() { |
| 25 |
$this->dispatch_actions(); |
| 26 |
if ( ! function_exists( 'is_plugin_active' ) ) { |
| 27 |
include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 28 |
} |
| 29 |
// Only show required plugins notice if Pro is NOT active |
| 30 |
if ( ! is_plugin_active( 'subscription-pro/subscription-pro.php' ) ) { |
| 31 |
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) { |
| 32 |
// Show required notice only, do not load other admin content |
| 33 |
new Required(); |
| 34 |
return; |
| 35 |
} else { |
| 36 |
new Required(); |
| 37 |
} |
| 38 |
} |
| 39 |
// Only load admin content if WooCommerce is active |
| 40 |
if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { |
| 41 |
new Menu(); |
| 42 |
new Integrations(); |
| 43 |
new Product(); |
| 44 |
new Subscriptions(); |
| 45 |
new AdminOrder(); |
| 46 |
new Comments(); |
| 47 |
new Settings(); |
| 48 |
new ProSettingsFields(); |
| 49 |
new Links(); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Dispatch and bind actions |
| 55 |
* |
| 56 |
* @return void |
| 57 |
*/ |
| 58 |
public function dispatch_actions() { |
| 59 |
add_action( 'save_post_product', array( $this, 'flush_gsc_cache' ) ); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Bust the GSC product-exists cache when any product is saved. |
| 64 |
* |
| 65 |
* @return void |
| 66 |
*/ |
| 67 |
public function flush_gsc_cache() { |
| 68 |
delete_transient( 'subscrpt_has_enabled_product' ); |
| 69 |
} |
| 70 |
} |
| 71 |
|