Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4 from bluehost/add-site-id-to-core-data
Browse files Browse the repository at this point in the history
Add filter to append site id to core data
  • Loading branch information
wpscholar authored Jul 12, 2022
2 parents 68a24bd + 6321da5 commit 8d2f695
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
use Bluehost\WP\Data\Customer;
use Bluehost\SiteMeta;

if ( function_exists( 'add_action' ) ) {
add_action( 'after_setup_theme', 'bluehost_register_data_package' );
Expand All @@ -9,18 +10,26 @@
* Register the customer data module
*/
function bluehost_register_data_package() {

// add filter callback to add customer data
add_filter( 'newfold_wp_data_module_cron_data_filter', 'bluehost_data_cron_callback' );

// Add filter callback to add site_id to core data
add_filter( 'newfold_wp_data_module_core_data_filter', 'bluehost_append_site_id' );
}

/**
* Filter the cron event data object with bluehost specific customer data
*
*
* @param array $data prepared to send in the cron event
* @return array filtered data to send in the cron event
*/
function bluehost_data_cron_callback( $data ) {
$data['customer'] = Customer::collect();
return $data;
}
}

function bluehost_append_site_id( $data ) {
$data['site_id'] = SiteMeta::get_id();
return $data;
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}
},
"require": {
"newfold-labs/wp-module-data": "^2.0"
"newfold-labs/wp-module-data": "^2.2"
},
"require-dev": {
"bluehost/wp-php-standards": "^1.1"
Expand All @@ -53,4 +53,4 @@
"fix": "Automatically fix coding standards issues where possible.",
"lint": "Check files against coding standards."
}
}
}

0 comments on commit 8d2f695

Please sign in to comment.