Moved actionsheduler hook to main file

This commit is contained in:
Mike Jolley 2019-05-14 19:19:24 +01:00
parent 8d45240e02
commit 254e378346
4 changed files with 24 additions and 28 deletions

View File

@ -32,9 +32,6 @@ class WC_Admin_Api_Init {
* Init classes. * Init classes.
*/ */
public function init_classes() { public function init_classes() {
// Core functions.
require_once WC_ADMIN_ABSPATH . 'includes/core-functions.php';
// Interfaces. // Interfaces.
require_once WC_ADMIN_ABSPATH . 'includes/interfaces/class-wc-admin-reports-data-store-interface.php'; require_once WC_ADMIN_ABSPATH . 'includes/interfaces/class-wc-admin-reports-data-store-interface.php';
require_once WC_ADMIN_ABSPATH . 'includes/class-wc-admin-reports-query.php'; require_once WC_ADMIN_ABSPATH . 'includes/class-wc-admin-reports-query.php';

View File

@ -42,24 +42,3 @@ function wc_admin_url( $path, $query = array() ) {
return admin_url( 'admin.php?page=wc-admin#' . $path, dirname( __FILE__ ) ); return admin_url( 'admin.php?page=wc-admin#' . $path, dirname( __FILE__ ) );
} }
/**
* Filter in our ActionScheduler Store class.
*
* @param string $store_class ActionScheduler Store class name.
* @return string ActionScheduler Store class name.
*/
function wc_admin_set_actionscheduler_store_class( $store_class ) {
// Don't override any other overrides.
if ( 'ActionScheduler_wpPostStore' !== $store_class ) {
return $store_class;
}
// Include our store class here instead of wc_admin_plugins_loaded()
// because ActionScheduler is hooked into `plugins_loaded` at a
// much higher priority.
require_once WC_ADMIN_ABSPATH . '/includes/class-wc-admin-actionscheduler-wppoststore.php';
return 'WC_Admin_ActionScheduler_WPPostStore';
}
add_filter( 'action_scheduler_store_class', 'wc_admin_set_actionscheduler_store_class' );

View File

@ -40,10 +40,7 @@ function wc_admin_install() {
require_once dirname( dirname( __FILE__ ) ) . '/includes/class-wc-admin-install.php'; require_once dirname( dirname( __FILE__ ) ) . '/includes/class-wc-admin-install.php';
WC_Admin_Install::create_tables(); WC_Admin_Install::create_tables();
WC_Admin_Install::create_events();
if ( ! wp_next_scheduled( 'wc_admin_daily' ) ) {
wp_schedule_event( time(), 'daily', 'wc_admin_daily' );
}
// Reload capabilities after install, see https://core.trac.wordpress.org/ticket/28374. // Reload capabilities after install, see https://core.trac.wordpress.org/ticket/28374.
$GLOBALS['wp_roles'] = null; // WPCS: override ok. $GLOBALS['wp_roles'] = null; // WPCS: override ok.

View File

@ -57,6 +57,7 @@ class WC_Admin_Feature_Plugin {
$this->define_constants(); $this->define_constants();
register_activation_hook( WC_ADMIN_PLUGIN_FILE, array( $this, 'on_activation' ) ); register_activation_hook( WC_ADMIN_PLUGIN_FILE, array( $this, 'on_activation' ) );
add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) ); add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ) );
add_filter( 'action_scheduler_store_class', array( $this, 'replace_actionscheduler_store_class' ) );
} }
/** /**
@ -117,6 +118,8 @@ class WC_Admin_Feature_Plugin {
* Include WC Admin classes. * Include WC Admin classes.
*/ */
public function includes() { public function includes() {
require_once WC_ADMIN_ABSPATH . 'includes/core-functions.php';
// Initialize the WC API extensions. // Initialize the WC API extensions.
require_once WC_ADMIN_ABSPATH . 'includes/class-wc-admin-reports-sync.php'; require_once WC_ADMIN_ABSPATH . 'includes/class-wc-admin-reports-sync.php';
require_once WC_ADMIN_ABSPATH . 'includes/class-wc-admin-install.php'; require_once WC_ADMIN_ABSPATH . 'includes/class-wc-admin-install.php';
@ -135,6 +138,26 @@ class WC_Admin_Feature_Plugin {
require_once WC_ADMIN_ABSPATH . 'includes/notes/class-wc-admin-notes-welcome-message.php'; require_once WC_ADMIN_ABSPATH . 'includes/notes/class-wc-admin-notes-welcome-message.php';
} }
/**
* Filter in our ActionScheduler Store class.
*
* @param string $store_class ActionScheduler Store class name.
* @return string ActionScheduler Store class name.
*/
public function replace_actionscheduler_store_class( $store_class ) {
// Don't override any other overrides.
if ( 'ActionScheduler_wpPostStore' !== $store_class ) {
return $store_class;
}
// Include our store class here instead of wc_admin_plugins_loaded()
// because ActionScheduler is hooked into `plugins_loaded` at a
// much higher priority.
require_once WC_ADMIN_ABSPATH . '/includes/class-wc-admin-actionscheduler-wppoststore.php';
return 'WC_Admin_ActionScheduler_WPPostStore';
}
/** /**
* Removes core hooks in favor of our local feature plugin handlers. * Removes core hooks in favor of our local feature plugin handlers.
* *