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rc.2 3.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / src / Internal / Admin / Events.php
woocommerce / src / Internal / Admin Last commit date
Agentic 4 months ago BlockTemplates 4 weeks ago EmailImprovements 1 year ago EmailPreview 4 weeks ago Emails 1 year ago ImportExport 1 year ago Logging 1 year ago Marketing 2 years ago Notes 4 weeks ago Onboarding 5 months ago Orders 4 weeks ago ProductForm 2 years ago ProductReviews 4 weeks ago RemoteFreeExtensions 4 weeks ago Schedulers 4 weeks ago Settings 5 days ago Suggestions 4 weeks ago WCPayPromotion 10 months ago ActivityPanels.php 3 years ago Analytics.php 4 weeks ago CategoryLookup.php 4 years ago Coupons.php 1 year ago CouponsMovedTrait.php 5 months ago CustomerEffortScoreTracks.php 7 months ago Events.php 2 months ago FeaturePlugin.php 4 months ago Homescreen.php 1 month ago Loader.php 4 weeks ago Marketing.php 1 year ago Marketplace.php 5 months ago MobileAppBanner.php 4 years ago OrderMilestoneEasterEgg.php 4 weeks ago RemoteInboxNotifications.php 3 years ago Settings.php 5 days ago ShippingLabelBanner.php 1 year ago ShippingLabelBannerDisplayRules.php 1 year ago SiteHealth.php 3 years ago Survey.php 4 years ago SystemStatusReport.php 1 year ago Translations.php 1 year ago WCAdminAssets.php 5 days ago WCAdminSharedSettings.php 1 year ago WCAdminUser.php 9 months ago WcPayWelcomePage.php 1 year ago
Events.php
271 lines
1 <?php
2 /**
3 * Handle cron events.
4 */
5
6 namespace Automattic\WooCommerce\Internal\Admin;
7
8 defined( 'ABSPATH' ) || exit;
9
10 use Automattic\WooCommerce\Admin\Features\Features;
11 use Automattic\WooCommerce\Admin\RemoteInboxNotifications\RemoteInboxNotificationsEngine;
12 use Automattic\WooCommerce\Internal\Admin\Notes\CustomizeStoreWithBlocks;
13 use Automattic\WooCommerce\Internal\Admin\Notes\CustomizingProductCatalog;
14 use Automattic\WooCommerce\Internal\Admin\Notes\EditProductsOnTheMove;
15 use Automattic\WooCommerce\Internal\Admin\Notes\EmailImprovements;
16 use Automattic\WooCommerce\Internal\Admin\Notes\EUVATNumber;
17 use Automattic\WooCommerce\Internal\Admin\Notes\FirstProduct;
18 use Automattic\WooCommerce\Internal\Admin\Notes\InstallJPAndWCSPlugins;
19 use Automattic\WooCommerce\Internal\Admin\Notes\LaunchChecklist;
20 use Automattic\WooCommerce\Internal\Admin\Notes\MagentoMigration;
21 use Automattic\WooCommerce\Internal\Admin\Notes\ManageOrdersOnTheGo;
22 use Automattic\WooCommerce\Internal\Admin\Notes\MarketingJetpack;
23 use Automattic\WooCommerce\Internal\Admin\Notes\MigrateFromShopify;
24 use Automattic\WooCommerce\Internal\Admin\Notes\MobileApp;
25 use Automattic\WooCommerce\Internal\Admin\Notes\NewSalesRecord;
26 use Automattic\WooCommerce\Internal\Admin\Notes\OnboardingPayments;
27 use Automattic\WooCommerce\Internal\Admin\Notes\OnlineClothingStore;
28 use Automattic\WooCommerce\Internal\Admin\Notes\OrderMilestones;
29 use Automattic\WooCommerce\Internal\Admin\Notes\PaymentsMoreInfoNeeded;
30 use Automattic\WooCommerce\Internal\Admin\Notes\PaymentsRemindMeLater;
31 use Automattic\WooCommerce\Internal\Admin\Notes\PerformanceOnMobile;
32 use Automattic\WooCommerce\Internal\Admin\Notes\PersonalizeStore;
33 use Automattic\WooCommerce\Internal\Admin\Notes\RealTimeOrderAlerts;
34 use Automattic\WooCommerce\Internal\Admin\Notes\ScheduledUpdatesPromotion;
35 use Automattic\WooCommerce\Internal\Admin\Notes\SellingOnlineCourses;
36 use Automattic\WooCommerce\Internal\Admin\Notes\TrackingOptIn;
37 use Automattic\WooCommerce\Internal\Admin\Notes\UnsecuredReportFiles;
38 use Automattic\WooCommerce\Internal\Admin\Notes\WooCommercePayments;
39 use Automattic\WooCommerce\Internal\Admin\Notes\WooCommerceSubscriptions;
40 use Automattic\WooCommerce\Internal\Admin\Notes\WooSubscriptionsNotes;
41 use Automattic\WooCommerce\Internal\Admin\Schedulers\MailchimpScheduler;
42 use Automattic\WooCommerce\Admin\Notes\Note;
43 use Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions\PaymentGatewaySuggestionsDataSourcePoller;
44 use Automattic\WooCommerce\Internal\Admin\RemoteFreeExtensions\RemoteFreeExtensionsDataSourcePoller;
45
46 /**
47 * Events Class.
48 */
49 class Events {
50 /**
51 * The single instance of the class.
52 *
53 * @var object
54 */
55 protected static $instance = null;
56
57 /**
58 * Constructor
59 *
60 * @return void
61 */
62 protected function __construct() {}
63
64 /**
65 * Array of note class to be added or updated.
66 *
67 * @var array
68 */
69 private static $note_classes_to_added_or_updated = array(
70 CustomizeStoreWithBlocks::class,
71 CustomizingProductCatalog::class,
72 EditProductsOnTheMove::class,
73 EmailImprovements::class,
74 EUVATNumber::class,
75 FirstProduct::class,
76 LaunchChecklist::class,
77 MagentoMigration::class,
78 ManageOrdersOnTheGo::class,
79 MarketingJetpack::class,
80 MigrateFromShopify::class,
81 MobileApp::class,
82 NewSalesRecord::class,
83 OnboardingPayments::class,
84 OnlineClothingStore::class,
85 PaymentsMoreInfoNeeded::class,
86 PaymentsRemindMeLater::class,
87 PerformanceOnMobile::class,
88 PersonalizeStore::class,
89 RealTimeOrderAlerts::class,
90 ScheduledUpdatesPromotion::class,
91 TrackingOptIn::class,
92 WooCommercePayments::class,
93 WooCommerceSubscriptions::class,
94 );
95
96 /**
97 * The other note classes that are added in other places.
98 *
99 * @var array
100 */
101 private static $other_note_classes = array(
102 InstallJPAndWCSPlugins::class,
103 OrderMilestones::class,
104 SellingOnlineCourses::class,
105 UnsecuredReportFiles::class,
106 WooSubscriptionsNotes::class,
107 );
108
109
110 /**
111 * Get class instance.
112 *
113 * @return object Instance.
114 */
115 final public static function instance() {
116 if ( null === static::$instance ) {
117 static::$instance = new static();
118 }
119 return static::$instance;
120 }
121
122 /**
123 * Cron event handlers.
124 */
125 public function init() {
126 add_action( 'wc_admin_daily', array( $this, 'do_wc_admin_daily' ) );
127 add_filter( 'woocommerce_get_note_from_db', array( $this, 'get_note_from_db' ), 10, 1 );
128
129 // Initialize the WC_Notes_Refund_Returns Note to attach hook.
130 \WC_Notes_Refund_Returns::init();
131 }
132
133 /**
134 * Daily events to run.
135 *
136 * Note: Order_Milestones::possibly_add_note is hooked to this as well.
137 */
138 public function do_wc_admin_daily() {
139 $this->possibly_add_notes();
140 $this->possibly_delete_notes();
141 $this->possibly_update_notes();
142 $this->possibly_refresh_data_source_pollers();
143
144 if ( $this->is_remote_inbox_notifications_enabled() ) {
145 RemoteInboxNotificationsEngine::run();
146 }
147
148 if ( Features::is_enabled( 'core-profiler' ) ) {
149 ( new MailchimpScheduler() )->run();
150 }
151 }
152
153 /**
154 * Get note.
155 *
156 * @param Note $note_from_db The note object from the database.
157 */
158 public function get_note_from_db( $note_from_db ) {
159 if ( ! $note_from_db instanceof Note || get_user_locale() === $note_from_db->get_locale() ) {
160 return $note_from_db;
161 }
162
163 $note_classes = array_merge( self::$note_classes_to_added_or_updated, self::$other_note_classes );
164 foreach ( $note_classes as $note_class ) {
165 if ( defined( "$note_class::NOTE_NAME" ) && $note_class::NOTE_NAME === $note_from_db->get_name() ) {
166 $note_from_class = method_exists( $note_class, 'get_note' ) ? $note_class::get_note() : null;
167
168 if ( $note_from_class instanceof Note ) {
169 $note = clone $note_from_db;
170 $note->set_title( $note_from_class->get_title() );
171 $note->set_content( $note_from_class->get_content() );
172 $actions = $note_from_class->get_actions();
173 foreach ( $actions as $action ) {
174 $matching_action = $note->get_action( $action->name );
175 if ( $matching_action && $matching_action->id ) {
176 $action->id = $matching_action->id;
177 }
178 }
179 $note->set_actions( $actions );
180 return $note;
181 }
182 break;
183 }
184 }
185 return $note_from_db;
186 }
187
188 /**
189 * Adds notes that should be added.
190 */
191 protected function possibly_add_notes() {
192 foreach ( self::$note_classes_to_added_or_updated as $note_class ) {
193 if ( method_exists( $note_class, 'possibly_add_note' ) ) {
194 $note_class::possibly_add_note();
195 }
196 }
197 }
198
199 /**
200 * Deletes notes that should be deleted.
201 */
202 protected function possibly_delete_notes() {
203 PaymentsRemindMeLater::delete_if_not_applicable();
204 PaymentsMoreInfoNeeded::delete_if_not_applicable();
205 }
206
207 /**
208 * Updates notes that should be updated.
209 */
210 protected function possibly_update_notes() {
211 foreach ( self::$note_classes_to_added_or_updated as $note_class ) {
212 if ( method_exists( $note_class, 'possibly_update_note' ) ) {
213 $note_class::possibly_update_note();
214 }
215 }
216 }
217
218 /**
219 * Checks if remote inbox notifications are enabled.
220 *
221 * @return bool Whether remote inbox notifications are enabled.
222 */
223 protected function is_remote_inbox_notifications_enabled() {
224 // Check if the feature flag is disabled.
225 if ( ! Features::is_enabled( 'remote-inbox-notifications' ) ) {
226 return false;
227 }
228
229 // Check if the site has opted out of marketplace suggestions.
230 if ( get_option( 'woocommerce_show_marketplace_suggestions', 'yes' ) !== 'yes' ) {
231 return false;
232 }
233
234 // All checks have passed.
235 return true;
236 }
237
238 /**
239 * Checks if merchant email notifications are enabled.
240 *
241 * @return bool Whether merchant email notifications are enabled.
242 */
243 protected function is_merchant_email_notifications_enabled() {
244 // Check if the feature flag is disabled.
245 if ( get_option( 'woocommerce_merchant_email_notifications', 'no' ) !== 'yes' ) {
246 return false;
247 }
248
249 // All checks have passed.
250 return true;
251 }
252
253 /**
254 * Prime or fetch specs for the following DataSourcePollers on the wc_admin_daily cron job
255 * when their related transients are missing or expired:
256 * - PaymentGatewaySuggestionsDataSourcePoller
257 * - RemoteFreeExtensionsDataSourcePoller
258 */
259 protected function possibly_refresh_data_source_pollers() {
260 $completed_tasks = get_option( 'woocommerce_task_list_tracked_completed_tasks', array() );
261
262 if ( ! in_array( 'payments', $completed_tasks, true ) && ! in_array( 'woocommerce-payments', $completed_tasks, true ) ) {
263 PaymentGatewaySuggestionsDataSourcePoller::get_instance()->get_specs_from_data_sources();
264 }
265
266 if ( ! in_array( 'store_details', $completed_tasks, true ) && ! in_array( 'marketing', $completed_tasks, true ) ) {
267 RemoteFreeExtensionsDataSourcePoller::get_instance()->get_specs_from_data_sources();
268 }
269 }
270 }
271