Skip to content

Instantly share code, notes, and snippets.

@woodwardtw
Created November 8, 2022 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woodwardtw/0e886338dcb841dfb9bf618b9e6d8016 to your computer and use it in GitHub Desktop.
Save woodwardtw/0e886338dcb841dfb9bf618b9e6d8016 to your computer and use it in GitHub Desktop.
add useful usage data to the base JSON of the WordPress site
/*---------------------------------JSON MOD FOR ADDITIONAL SITE INFO----------------------------------*/
function extraJsonData($response){
$blog_id = get_current_blog_id();
$blog_details = get_blog_details($blog_id);
$data = $response->data;
$data['created'] =$blog_details->registered;
$data['last_updated'] =$blog_details->last_updated;
$data['post_count'] =$blog_details->post_count;
$data['page_count'] = wp_count_posts('page','publish');
$response->set_data($data);
return $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment