API
5 years ago
Composer
5 years ago
DateTimeProvider
5 years ago
Features
5 years ago
Marketing
5 years ago
Notes
5 years ago
Overrides
5 years ago
PluginsProvider
5 years ago
RemoteInboxNotifications
5 years ago
Schedulers
5 years ago
CategoryLookup.php
5 years ago
DeprecatedClassFacade.php
5 years ago
Events.php
5 years ago
FeaturePlugin.php
5 years ago
Install.php
5 years ago
Loader.php
5 years ago
PageController.php
5 years ago
PluginsHelper.php
5 years ago
ReportCSVEmail.php
5 years ago
ReportCSVExporter.php
5 years ago
ReportExporter.php
5 years ago
ReportsSync.php
5 years ago
Events.php
145 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Handle cron events. |
| 4 | * NOTE: DO NOT edit this file in WooCommerce core, this is generated from woocommerce-admin. |
| 5 | */ |
| 6 | |
| 7 | namespace Automattic\WooCommerce\Admin; |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; |
| 10 | |
| 11 | use \Automattic\WooCommerce\Admin\Notes\ChooseNiche; |
| 12 | use \Automattic\WooCommerce\Admin\Notes\GivingFeedbackNotes; |
| 13 | use \Automattic\WooCommerce\Admin\Notes\MobileApp; |
| 14 | use \Automattic\WooCommerce\Admin\Notes\NewSalesRecord; |
| 15 | use \Automattic\WooCommerce\Admin\Notes\TrackingOptIn; |
| 16 | use \Automattic\WooCommerce\Admin\Notes\OnboardingEmailMarketing; |
| 17 | use \Automattic\WooCommerce\Admin\Notes\OnboardingPayments; |
| 18 | use \Automattic\WooCommerce\Admin\Notes\PersonalizeStore; |
| 19 | use \Automattic\WooCommerce\Admin\Notes\EUVATNumber; |
| 20 | use \Automattic\WooCommerce\Admin\Notes\WooCommercePayments; |
| 21 | use \Automattic\WooCommerce\Admin\Notes\Marketing; |
| 22 | use \Automattic\WooCommerce\Admin\Notes\StartDropshippingBusiness; |
| 23 | use \Automattic\WooCommerce\Admin\Notes\WooCommerceSubscriptions; |
| 24 | use \Automattic\WooCommerce\Admin\Notes\MigrateFromShopify; |
| 25 | use \Automattic\WooCommerce\Admin\Notes\LaunchChecklist; |
| 26 | use \Automattic\WooCommerce\Admin\Notes\RealTimeOrderAlerts; |
| 27 | use \Automattic\WooCommerce\Admin\RemoteInboxNotifications\DataSourcePoller; |
| 28 | use \Automattic\WooCommerce\Admin\RemoteInboxNotifications\RemoteInboxNotificationsEngine; |
| 29 | use \Automattic\WooCommerce\Admin\Loader; |
| 30 | use \Automattic\WooCommerce\Admin\Notes\InsightFirstSale; |
| 31 | use \Automattic\WooCommerce\Admin\Notes\HomeScreenFeedback; |
| 32 | use \Automattic\WooCommerce\Admin\Notes\NeedSomeInspiration; |
| 33 | use \Automattic\WooCommerce\Admin\Notes\OnlineClothingStore; |
| 34 | use \Automattic\WooCommerce\Admin\Notes\FirstProduct; |
| 35 | use \Automattic\WooCommerce\Admin\Notes\CustomizeStoreWithBlocks; |
| 36 | use \Automattic\WooCommerce\Admin\Notes\GoogleAdsAndMarketing; |
| 37 | use \Automattic\WooCommerce\Admin\Notes\TestCheckout; |
| 38 | use \Automattic\WooCommerce\Admin\Notes\EditProductsOnTheMove; |
| 39 | use \Automattic\WooCommerce\Admin\Notes\PerformanceOnMobile; |
| 40 | use \Automattic\WooCommerce\Admin\Notes\ManageOrdersOnTheGo; |
| 41 | use \Automattic\WooCommerce\Admin\Notes\NavigationFeedback; |
| 42 | use \Automattic\WooCommerce\Admin\Notes\NavigationFeedbackFollowUp; |
| 43 | use \Automattic\WooCommerce\Admin\Notes\FilterByProductVariationsInReports; |
| 44 | |
| 45 | /** |
| 46 | * Events Class. |
| 47 | */ |
| 48 | class Events { |
| 49 | /** |
| 50 | * The single instance of the class. |
| 51 | * |
| 52 | * @var object |
| 53 | */ |
| 54 | protected static $instance = null; |
| 55 | |
| 56 | /** |
| 57 | * Constructor |
| 58 | * |
| 59 | * @return void |
| 60 | */ |
| 61 | protected function __construct() {} |
| 62 | |
| 63 | /** |
| 64 | * Get class instance. |
| 65 | * |
| 66 | * @return object Instance. |
| 67 | */ |
| 68 | final public static function instance() { |
| 69 | if ( null === static::$instance ) { |
| 70 | static::$instance = new static(); |
| 71 | } |
| 72 | return static::$instance; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Cron event handlers. |
| 77 | */ |
| 78 | public function init() { |
| 79 | add_action( 'wc_admin_daily', array( $this, 'do_wc_admin_daily' ) ); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Daily events to run. |
| 84 | * |
| 85 | * Note: Order_Milestones::other_milestones is hooked to this as well. |
| 86 | */ |
| 87 | public function do_wc_admin_daily() { |
| 88 | NewSalesRecord::possibly_add_note(); |
| 89 | MobileApp::possibly_add_note(); |
| 90 | TrackingOptIn::possibly_add_note(); |
| 91 | OnboardingEmailMarketing::possibly_add_note(); |
| 92 | OnboardingPayments::possibly_add_note(); |
| 93 | PersonalizeStore::possibly_add_note(); |
| 94 | WooCommercePayments::possibly_add_note(); |
| 95 | EUVATNumber::possibly_add_note(); |
| 96 | Marketing::possibly_add_note(); |
| 97 | GivingFeedbackNotes::possibly_add_note(); |
| 98 | StartDropshippingBusiness::possibly_add_note(); |
| 99 | WooCommerceSubscriptions::possibly_add_note(); |
| 100 | MigrateFromShopify::possibly_add_note(); |
| 101 | InsightFirstSale::possibly_add_note(); |
| 102 | LaunchChecklist::possibly_add_note(); |
| 103 | HomeScreenFeedback::possibly_add_note(); |
| 104 | NeedSomeInspiration::possibly_add_note(); |
| 105 | OnlineClothingStore::possibly_add_note(); |
| 106 | FirstProduct::possibly_add_note(); |
| 107 | ChooseNiche::possibly_add_note(); |
| 108 | RealTimeOrderAlerts::possibly_add_note(); |
| 109 | CustomizeStoreWithBlocks::possibly_add_note(); |
| 110 | GoogleAdsAndMarketing::possibly_add_note(); |
| 111 | TestCheckout::possibly_add_note(); |
| 112 | EditProductsOnTheMove::possibly_add_note(); |
| 113 | PerformanceOnMobile::possibly_add_note(); |
| 114 | ManageOrdersOnTheGo::possibly_add_note(); |
| 115 | NavigationFeedback::possibly_add_note(); |
| 116 | NavigationFeedbackFollowUp::possibly_add_note(); |
| 117 | FilterByProductVariationsInReports::possibly_add_note(); |
| 118 | |
| 119 | if ( $this->is_remote_inbox_notifications_enabled() ) { |
| 120 | DataSourcePoller::read_specs_from_data_sources(); |
| 121 | RemoteInboxNotificationsEngine::run(); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Checks if remote inbox notifications are enabled. |
| 127 | * |
| 128 | * @return bool Whether remote inbox notifications are enabled. |
| 129 | */ |
| 130 | protected function is_remote_inbox_notifications_enabled() { |
| 131 | // Check if the feature flag is disabled. |
| 132 | if ( ! Loader::is_feature_enabled( 'remote-inbox-notifications' ) ) { |
| 133 | return false; |
| 134 | } |
| 135 | |
| 136 | // Check if the site has opted out of marketplace suggestions. |
| 137 | if ( 'yes' !== get_option( 'woocommerce_show_marketplace_suggestions', 'yes' ) ) { |
| 138 | return false; |
| 139 | } |
| 140 | |
| 141 | // All checks have passed. |
| 142 | return true; |
| 143 | } |
| 144 | } |
| 145 |