Moved actionsheduler hook to main file
This commit is contained in:
parent
8d45240e02
commit
254e378346
|
@ -32,9 +32,6 @@ class WC_Admin_Api_Init {
|
|||
* Init classes.
|
||||
*/
|
||||
public function init_classes() {
|
||||
// Core functions.
|
||||
require_once WC_ADMIN_ABSPATH . 'includes/core-functions.php';
|
||||
|
||||
// Interfaces.
|
||||
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';
|
||||
|
|
|
@ -42,24 +42,3 @@ function wc_admin_url( $path, $query = array() ) {
|
|||
|
||||
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' );
|
||||
|
|
|
@ -40,10 +40,7 @@ function wc_admin_install() {
|
|||
require_once dirname( dirname( __FILE__ ) ) . '/includes/class-wc-admin-install.php';
|
||||
|
||||
WC_Admin_Install::create_tables();
|
||||
|
||||
if ( ! wp_next_scheduled( 'wc_admin_daily' ) ) {
|
||||
wp_schedule_event( time(), 'daily', 'wc_admin_daily' );
|
||||
}
|
||||
WC_Admin_Install::create_events();
|
||||
|
||||
// Reload capabilities after install, see https://core.trac.wordpress.org/ticket/28374.
|
||||
$GLOBALS['wp_roles'] = null; // WPCS: override ok.
|
||||
|
|
|
@ -57,6 +57,7 @@ class WC_Admin_Feature_Plugin {
|
|||
$this->define_constants();
|
||||
register_activation_hook( WC_ADMIN_PLUGIN_FILE, array( $this, 'on_activation' ) );
|
||||
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.
|
||||
*/
|
||||
public function includes() {
|
||||
require_once WC_ADMIN_ABSPATH . 'includes/core-functions.php';
|
||||
|
||||
// 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-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';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue