woocommerce/plugins/woocommerce-admin/src/Events.php

109 lines
4.1 KiB
PHP
Raw Normal View History

<?php
/**
2019-05-14 22:08:13 +00:00
* Handle cron events.
* NOTE: DO NOT edit this file in WooCommerce core, this is generated from woocommerce-admin.
*
* @package Woocommerce Admin
*/
2019-08-06 19:36:15 +00:00
namespace Automattic\WooCommerce\Admin;
defined( 'ABSPATH' ) || exit;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Choose_Niche;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Giving_Feedback_Notes;
2019-08-06 19:36:15 +00:00
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Mobile_App;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_New_Sales_Record;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Tracking_Opt_In;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Onboarding_Email_Marketing;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Onboarding_Payments;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Personalize_Store;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_EU_VAT_Number;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_WooCommerce_Payments;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Marketing;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Start_Dropshipping_Business;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_WooCommerce_Subscriptions;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Migrate_From_Shopify;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Launch_Checklist;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Real_Time_Order_Alerts;
Remote inbox notification delivery (https://github.com/woocommerce/woocommerce-admin/pull/4143) * Poll and persist specs * Process specs into admin notes * Add send at time rule processor * Fix style issues * Clear actions before recreating them to avoid dupes * Trigger the RINDS engine when a plugin is activated * Unit test SendAtTimeRuleProcessor * Implement plugins activated rule processor * Don't throw exception for unrecognised rule type. Also unit test around this. * add url_is_action_query to tell whether to wrap the URL in wc_admin_url() call or not * Add NOT rule * revert change to install.php * Drop unimplemented resend after dismissal rule * Add OR rule * Explicitly make "fail" a type of rule that can be applied to a spec * Add plugin version rule processor * Tidy up, don't need to pass $spec everywhere * Remove meta record for action state - not really needed * Move spec runner into it's own class, add some checks around re-unactioning a note * Replace if..else with switch * Just update the option * Check that the JSON coming in is an array * Change OR rule to accept an array of operands * Add Pass rule processor * Fix specs that are initially not published * Rename send at rule to publish after * Add publish before rule * Remove unused interface * Can't use PHP7's anonymous classes * New notification: How to draw attention to your online store * Add feature flag for rule-base inbox notes * rename everything to RemoteInboxNotifications from RINDS * Fix merge fail * fix test * Change preunactioned to pending * Move feature flag check into Events.php * Refactor reading a data source * Rename poll_data_sources function * Refactor EvaluateAndGetStatus::evaluate to take the rule evaluator directly * Check that the response body exists * Add validation and defensive checks * Add rule processor interface * Update note created time on status change * Move non-test dependencies into processor constructors * Update to proposed live URL * Remove setting icon as it's being deprecated Co-authored-by: Rebecca Scott <me@becdetat.com>
2020-06-05 01:51:25 +00:00
use \Automattic\WooCommerce\Admin\RemoteInboxNotifications\DataSourcePoller;
use \Automattic\WooCommerce\Admin\RemoteInboxNotifications\RemoteInboxNotificationsEngine;
use \Automattic\WooCommerce\Admin\Loader;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Home_Screen_Feedback;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Need_Some_Inspiration;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Learn_More_About_Product_Settings;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Online_Clothing_Store;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_First_Product;
2019-08-06 19:36:15 +00:00
/**
* WC_Admin_Events Class.
*/
class Events {
/**
* The single instance of the class.
*
* @var object
*/
protected static $instance = null;
/**
* Constructor
*
* @return void
*/
protected function __construct() {}
/**
* Get class instance.
*
* @return object Instance.
*/
final public static function instance() {
if ( null === static::$instance ) {
static::$instance = new static();
}
return static::$instance;
}
/**
* Cron event handlers.
*/
public function init() {
2019-05-14 22:09:02 +00:00
add_action( 'wc_admin_daily', array( $this, 'do_wc_admin_daily' ) );
}
/**
* Daily events to run.
*
* Note: WC_Admin_Notes_Order_Milestones::other_milestones is hooked to this as well.
*/
2019-06-12 02:37:45 +00:00
public function do_wc_admin_daily() {
WC_Admin_Notes_New_Sales_Record::possibly_add_note();
WC_Admin_Notes_Mobile_App::possibly_add_note();
WC_Admin_Notes_Tracking_Opt_In::possibly_add_note();
WC_Admin_Notes_Onboarding_Email_Marketing::possibly_add_note();
WC_Admin_Notes_Onboarding_Payments::possibly_add_note();
WC_Admin_Notes_Personalize_Store::possibly_add_note();
WC_Admin_Notes_WooCommerce_Payments::possibly_add_note();
WC_Admin_Notes_EU_VAT_Number::possibly_add_note();
WC_Admin_Notes_Marketing::possibly_add_note();
WC_Admin_Notes_Giving_Feedback_Notes::possibly_add_note();
WC_Admin_Notes_Start_Dropshipping_Business::possibly_add_note();
WC_Admin_Notes_WooCommerce_Subscriptions::possibly_add_note();
WC_Admin_Notes_Migrate_From_Shopify::possibly_add_note();
WC_Admin_Notes_Launch_Checklist::possibly_add_note();
WC_Admin_Notes_Home_Screen_Feedback::possibly_add_note();
WC_Admin_Notes_Need_Some_Inspiration::possibly_add_note();
WC_Admin_Notes_Learn_More_About_Product_Settings::possibly_add_note();
WC_Admin_Notes_Online_Clothing_Store::possibly_add_note();
WC_Admin_Notes_First_Product::possibly_add_note();
WC_Admin_Notes_Choose_Niche::possibly_add_note();
WC_Admin_Notes_Real_Time_Order_Alerts::possibly_add_note();
Remote inbox notification delivery (https://github.com/woocommerce/woocommerce-admin/pull/4143) * Poll and persist specs * Process specs into admin notes * Add send at time rule processor * Fix style issues * Clear actions before recreating them to avoid dupes * Trigger the RINDS engine when a plugin is activated * Unit test SendAtTimeRuleProcessor * Implement plugins activated rule processor * Don't throw exception for unrecognised rule type. Also unit test around this. * add url_is_action_query to tell whether to wrap the URL in wc_admin_url() call or not * Add NOT rule * revert change to install.php * Drop unimplemented resend after dismissal rule * Add OR rule * Explicitly make "fail" a type of rule that can be applied to a spec * Add plugin version rule processor * Tidy up, don't need to pass $spec everywhere * Remove meta record for action state - not really needed * Move spec runner into it's own class, add some checks around re-unactioning a note * Replace if..else with switch * Just update the option * Check that the JSON coming in is an array * Change OR rule to accept an array of operands * Add Pass rule processor * Fix specs that are initially not published * Rename send at rule to publish after * Add publish before rule * Remove unused interface * Can't use PHP7's anonymous classes * New notification: How to draw attention to your online store * Add feature flag for rule-base inbox notes * rename everything to RemoteInboxNotifications from RINDS * Fix merge fail * fix test * Change preunactioned to pending * Move feature flag check into Events.php * Refactor reading a data source * Rename poll_data_sources function * Refactor EvaluateAndGetStatus::evaluate to take the rule evaluator directly * Check that the response body exists * Add validation and defensive checks * Add rule processor interface * Update note created time on status change * Move non-test dependencies into processor constructors * Update to proposed live URL * Remove setting icon as it's being deprecated Co-authored-by: Rebecca Scott <me@becdetat.com>
2020-06-05 01:51:25 +00:00
if ( Loader::is_feature_enabled( 'remote-inbox-notifications' ) ) {
DataSourcePoller::read_specs_from_data_sources();
RemoteInboxNotificationsEngine::run();
}
}
}