From 7308b512c6b8f123d394ddeaa4c3a491e0c191a5 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 12 Dec 2022 11:34:31 -0500 Subject: [PATCH] Fix the bad class name used in cron filter --- bootstrap.php | 55 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/bootstrap.php b/bootstrap.php index 5278300..7562dc6 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -6,7 +6,7 @@ use function NewfoldLabs\WP\ModuleLoader\register as registerModule; /** - * Register the data module + * Register the newfold customer data module for bluehost */ if ( function_exists( 'add_action' ) ) { @@ -18,9 +18,7 @@ function () { array( 'name' => 'newfold-customer-bluehost', 'label' => __( 'Customer Bluehost', 'newfold-customer-bluehost' ), - 'callback' => function ( Container $container ) { - new CustomerBluehost( $container ); - }, + 'callback' => 'newfold_module_load_customer_bluehost', 'isActive' => true, 'isHidden' => true, ) @@ -28,24 +26,37 @@ function () { } ); +} + +/** + * Initialize CustomerBluehost class instance and add required filters + * + * @param Container the module loader container + * @return void + */ +function newfold_module_load_customer_bluehost( Container $container ) { + new CustomerBluehost( $container ); - // Add filter callback to add bluehost customer data to data module in cron event data - add_filter( - 'newfold_wp_data_module_cron_data_filter', - function( $data ) { - // Filter the cron event data object with bluehost specific customer data - $data['customer'] = Customer\Bluehost::collect(); - return $data; - } - ); - - // Add filter callback to add site_id to core data module data - add_filter( - 'newfold_wp_data_module_core_data_filter', - function( $data ) { - $data['site_id'] = SiteMeta::get_id(); - return $data; - } - ); + + if ( function_exists( 'add_filter' ) ) { + // Add filter for adding bluehost customer data to data module in cron event data + add_filter( + 'newfold_wp_data_module_cron_data_filter', + function( $data ) { + // Filter the cron event data object with bluehost specific customer data + $data['customer'] = CustomerBluehost::collect(); + return $data; + } + ); + + // Add filter to add site_id to core data module data + add_filter( + 'newfold_wp_data_module_core_data_filter', + function( $data ) { + $data['site_id'] = SiteMeta::get_id(); + return $data; + } + ); + } }