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.0.1 5.2.0-beta.1 10.0.2 5.2.0-rc.1 10.0.3 5.2.0-rc.2 10.0.4 5.2.1 10.0.5 5.2.2 10.0.6 5.2.3 10.1.0 5.2.4 10.1.0-rc.1 5.2.5 10.1.0-rc.2 5.3.0 10.1.0-rc.3 5.3.0-beta.1 10.1.0-rc.4 5.3.0-rc.1 10.1.1 5.3.0-rc.2 10.1.2 5.3.1 10.1.3 5.3.2 10.1.4 5.3.3 10.2.0 5.4.0 10.2.0-beta.1 5.4.0-beta.1 10.2.0-beta.2 5.4.0-rc.1 10.2.0-rc.1 5.4.1 10.2.1 5.4.2 10.2.2 5.4.3 10.2.3 5.4.4 10.2.4 5.4.5 10.3.0 5.5.0 10.3.0-beta.1 5.5.0-beta.1 10.3.0-beta.2 5.5.0-rc.1 10.3.0-rc.1 5.5.0-rc.2 10.3.0-rc.2 5.5.1 10.3.1 5.5.2 10.3.2 5.5.3 10.3.3 5.5.4 10.3.4 5.5.5 10.3.5 5.6.0 10.3.6 5.6.0-beta.1 10.3.7 5.6.0-rc.1 10.3.8 5.6.0-rc.2 10.4.0 5.6.1 10.4.0-beta.1 5.6.2 10.4.0-beta.2 5.6.3 10.4.0-rc.1 5.7.0 10.4.1 5.7.0-beta.1 10.4.2 5.7.0-rc.1 10.4.3 5.7.1 10.4.4 5.7.2 10.5.0 5.7.3 10.5.0-beta.1 5.8.0 10.5.0-beta.2 5.8.0-beta.1 10.5.0-rc.1 5.8.0-beta.2 10.5.0-rc.2 5.8.0-rc.1 10.5.0-rc.3 5.8.1 10.5.1 5.8.2 10.5.2 5.9.0 10.5.3 5.9.0-beta.1 10.6.0 5.9.0-rc.1 10.6.0-beta.1 5.9.0-rc.2 10.6.0-beta.2 5.9.1 10.6.0-rc.1 5.9.2 10.6.1 6.0.0 10.6.2 6.0.0-beta.1 10.7.0 6.0.0-rc.1 10.7.0-beta.1 6.0.1 10.7.0-beta.2 6.0.2 10.7.0-rc.1 6.1.0 3.0.0 6.1.0-beta.1 3.0.1 6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c.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 6 months ago EmailImprovements 1 year ago EmailPreview 1 month ago Emails 2 weeks ago ImportExport 1 year ago Logging 2 weeks ago Marketing 2 years ago Notes 2 weeks ago Onboarding 2 weeks ago Orders 1 month ago ProductForm 2 years ago ProductReviews 2 months ago RemoteFreeExtensions 2 months ago Reports 2 weeks ago Schedulers 2 weeks ago Settings 2 weeks ago Suggestions 2 weeks ago WCPayPromotion 1 year ago ActivityPanels.php 4 years ago Analytics.php 2 weeks ago CategoryLookup.php 4 years ago Coupons.php 2 weeks ago CouponsMovedTrait.php 7 months ago CustomerEffortScoreTracks.php 9 months ago Events.php 2 weeks ago FeaturePlugin.php 2 weeks ago Homescreen.php 2 weeks ago Loader.php 1 month ago Marketing.php 1 year ago Marketplace.php 7 months ago MobileAppBanner.php 4 years ago OrderMilestoneEasterEgg.php 2 months ago RemoteInboxNotifications.php 2 weeks ago Settings.php 2 weeks ago ShippingLabelBanner.php 1 year ago ShippingLabelBannerDisplayRules.php 1 year ago SiteHealth.php 2 weeks ago Survey.php 4 years ago SystemStatusReport.php 2 weeks ago TaxSettingsRecommendations.php 1 month ago Translations.php 1 year ago WCAdminAssets.php 1 week ago WCAdminSharedSettings.php 1 year ago WCAdminUser.php 10 months ago WcPayWelcomePage.php 1 year ago
Events.php
263 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\RemoteInboxNotifications\RemoteInboxNotificationsEngine;
11 use Automattic\WooCommerce\Internal\Admin\Notes\CustomizeStoreWithBlocks;
12 use Automattic\WooCommerce\Internal\Admin\Notes\CustomizingProductCatalog;
13 use Automattic\WooCommerce\Internal\Admin\Notes\EditProductsOnTheMove;
14 use Automattic\WooCommerce\Internal\Admin\Notes\EmailImprovements;
15 use Automattic\WooCommerce\Internal\Admin\Notes\EUVATNumber;
16 use Automattic\WooCommerce\Internal\Admin\Notes\FirstProduct;
17 use Automattic\WooCommerce\Internal\Admin\Notes\InstallJPAndWCSPlugins;
18 use Automattic\WooCommerce\Internal\Admin\Notes\LaunchChecklist;
19 use Automattic\WooCommerce\Internal\Admin\Notes\MagentoMigration;
20 use Automattic\WooCommerce\Internal\Admin\Notes\ManageOrdersOnTheGo;
21 use Automattic\WooCommerce\Internal\Admin\Notes\MarketingJetpack;
22 use Automattic\WooCommerce\Internal\Admin\Notes\MigrateFromShopify;
23 use Automattic\WooCommerce\Internal\Admin\Notes\MobileApp;
24 use Automattic\WooCommerce\Internal\Admin\Notes\NewSalesRecord;
25 use Automattic\WooCommerce\Internal\Admin\Notes\OnboardingPayments;
26 use Automattic\WooCommerce\Internal\Admin\Notes\OnlineClothingStore;
27 use Automattic\WooCommerce\Internal\Admin\Notes\OrderMilestones;
28 use Automattic\WooCommerce\Internal\Admin\Notes\PaymentsMoreInfoNeeded;
29 use Automattic\WooCommerce\Internal\Admin\Notes\PaymentsRemindMeLater;
30 use Automattic\WooCommerce\Internal\Admin\Notes\PerformanceOnMobile;
31 use Automattic\WooCommerce\Internal\Admin\Notes\PersonalizeStore;
32 use Automattic\WooCommerce\Internal\Admin\Notes\RealTimeOrderAlerts;
33 use Automattic\WooCommerce\Internal\Admin\Notes\ScheduledUpdatesPromotion;
34 use Automattic\WooCommerce\Internal\Admin\Notes\SellingOnlineCourses;
35 use Automattic\WooCommerce\Internal\Admin\Notes\TrackingOptIn;
36 use Automattic\WooCommerce\Internal\Admin\Notes\UnsecuredReportFiles;
37 use Automattic\WooCommerce\Internal\Admin\Notes\WooCommercePayments;
38 use Automattic\WooCommerce\Internal\Admin\Notes\WooCommerceSubscriptions;
39 use Automattic\WooCommerce\Internal\Admin\Notes\WooSubscriptionsNotes;
40 use Automattic\WooCommerce\Internal\Admin\Schedulers\MailchimpScheduler;
41 use Automattic\WooCommerce\Admin\Notes\Note;
42 use Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions\PaymentGatewaySuggestionsDataSourcePoller;
43 use Automattic\WooCommerce\Internal\Admin\RemoteFreeExtensions\RemoteFreeExtensionsDataSourcePoller;
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 * Array of note class to be added or updated.
65 *
66 * @var array
67 */
68 private static $note_classes_to_added_or_updated = array(
69 CustomizeStoreWithBlocks::class,
70 CustomizingProductCatalog::class,
71 EditProductsOnTheMove::class,
72 EmailImprovements::class,
73 EUVATNumber::class,
74 FirstProduct::class,
75 LaunchChecklist::class,
76 MagentoMigration::class,
77 ManageOrdersOnTheGo::class,
78 MarketingJetpack::class,
79 MigrateFromShopify::class,
80 MobileApp::class,
81 NewSalesRecord::class,
82 OnboardingPayments::class,
83 OnlineClothingStore::class,
84 PaymentsMoreInfoNeeded::class,
85 PaymentsRemindMeLater::class,
86 PerformanceOnMobile::class,
87 PersonalizeStore::class,
88 RealTimeOrderAlerts::class,
89 ScheduledUpdatesPromotion::class,
90 TrackingOptIn::class,
91 WooCommercePayments::class,
92 WooCommerceSubscriptions::class,
93 );
94
95 /**
96 * The other note classes that are added in other places.
97 *
98 * @var array
99 */
100 private static $other_note_classes = array(
101 InstallJPAndWCSPlugins::class,
102 OrderMilestones::class,
103 SellingOnlineCourses::class,
104 UnsecuredReportFiles::class,
105 WooSubscriptionsNotes::class,
106 );
107
108
109 /**
110 * Get class instance.
111 *
112 * @return object Instance.
113 */
114 final public static function instance() {
115 if ( null === static::$instance ) {
116 static::$instance = new static();
117 }
118 return static::$instance;
119 }
120
121 /**
122 * Cron event handlers.
123 */
124 public function init() {
125 add_action( 'wc_admin_daily', array( $this, 'do_wc_admin_daily' ) );
126 add_filter( 'woocommerce_get_note_from_db', array( $this, 'get_note_from_db' ), 10, 1 );
127
128 // Initialize the WC_Notes_Refund_Returns Note to attach hook.
129 \WC_Notes_Refund_Returns::init();
130 }
131
132 /**
133 * Daily events to run.
134 *
135 * Note: Order_Milestones::possibly_add_note is hooked to this as well.
136 */
137 public function do_wc_admin_daily() {
138 $this->possibly_add_notes();
139 $this->possibly_delete_notes();
140 $this->possibly_update_notes();
141 $this->possibly_refresh_data_source_pollers();
142
143 if ( $this->is_remote_inbox_notifications_enabled() ) {
144 RemoteInboxNotificationsEngine::run();
145 }
146
147 ( new MailchimpScheduler() )->run();
148 }
149
150 /**
151 * Get note.
152 *
153 * @param Note $note_from_db The note object from the database.
154 */
155 public function get_note_from_db( $note_from_db ) {
156 if ( ! $note_from_db instanceof Note || get_user_locale() === $note_from_db->get_locale() ) {
157 return $note_from_db;
158 }
159
160 $note_classes = array_merge( self::$note_classes_to_added_or_updated, self::$other_note_classes );
161 foreach ( $note_classes as $note_class ) {
162 if ( defined( "$note_class::NOTE_NAME" ) && $note_class::NOTE_NAME === $note_from_db->get_name() ) {
163 $note_from_class = method_exists( $note_class, 'get_note' ) ? $note_class::get_note() : null;
164
165 if ( $note_from_class instanceof Note ) {
166 $note = clone $note_from_db;
167 $note->set_title( $note_from_class->get_title() );
168 $note->set_content( $note_from_class->get_content() );
169 $actions = $note_from_class->get_actions();
170 foreach ( $actions as $action ) {
171 $matching_action = $note->get_action( $action->name );
172 if ( $matching_action && $matching_action->id ) {
173 $action->id = $matching_action->id;
174 }
175 }
176 $note->set_actions( $actions );
177 return $note;
178 }
179 break;
180 }
181 }
182 return $note_from_db;
183 }
184
185 /**
186 * Adds notes that should be added.
187 */
188 protected function possibly_add_notes() {
189 foreach ( self::$note_classes_to_added_or_updated as $note_class ) {
190 if ( method_exists( $note_class, 'possibly_add_note' ) ) {
191 $note_class::possibly_add_note();
192 }
193 }
194 }
195
196 /**
197 * Deletes notes that should be deleted.
198 */
199 protected function possibly_delete_notes() {
200 PaymentsRemindMeLater::delete_if_not_applicable();
201 PaymentsMoreInfoNeeded::delete_if_not_applicable();
202 }
203
204 /**
205 * Updates notes that should be updated.
206 */
207 protected function possibly_update_notes() {
208 foreach ( self::$note_classes_to_added_or_updated as $note_class ) {
209 if ( method_exists( $note_class, 'possibly_update_note' ) ) {
210 $note_class::possibly_update_note();
211 }
212 }
213 }
214
215 /**
216 * Checks if remote inbox notifications are enabled.
217 *
218 * @return bool Whether remote inbox notifications are enabled.
219 */
220 protected function is_remote_inbox_notifications_enabled() {
221 // Check if the site has opted out of marketplace suggestions.
222 if ( get_option( 'woocommerce_show_marketplace_suggestions', 'yes' ) !== 'yes' ) {
223 return false;
224 }
225
226 // All checks have passed.
227 return true;
228 }
229
230 /**
231 * Checks if merchant email notifications are enabled.
232 *
233 * @return bool Whether merchant email notifications are enabled.
234 */
235 protected function is_merchant_email_notifications_enabled() {
236 // Check if the feature flag is disabled.
237 if ( get_option( 'woocommerce_merchant_email_notifications', 'no' ) !== 'yes' ) {
238 return false;
239 }
240
241 // All checks have passed.
242 return true;
243 }
244
245 /**
246 * Prime or fetch specs for the following DataSourcePollers on the wc_admin_daily cron job
247 * when their related transients are missing or expired:
248 * - PaymentGatewaySuggestionsDataSourcePoller
249 * - RemoteFreeExtensionsDataSourcePoller
250 */
251 protected function possibly_refresh_data_source_pollers() {
252 $completed_tasks = get_option( 'woocommerce_task_list_tracked_completed_tasks', array() );
253
254 if ( ! in_array( 'payments', $completed_tasks, true ) && ! in_array( 'woocommerce-payments', $completed_tasks, true ) ) {
255 PaymentGatewaySuggestionsDataSourcePoller::get_instance()->get_specs_from_data_sources();
256 }
257
258 if ( ! in_array( 'store_details', $completed_tasks, true ) && ! in_array( 'marketing', $completed_tasks, true ) ) {
259 RemoteFreeExtensionsDataSourcePoller::get_instance()->get_specs_from_data_sources();
260 }
261 }
262 }
263