Tribe__PUE__Checker::build_full_stats( array $stats )
Build full stats for endpoints
Contents
Parameters
- $stats
-
(array) (Required) Initial stats.
Return
(array)
Source
File: src/Tribe/PUE/Checker.php
public function build_full_stats( $stats ) {
global $wpdb;
$theme = wp_get_theme();
$current_offset = (int) get_option( 'gmt_offset', 0 );
$tzstring = get_option( 'timezone_string' );
// Remove old Etc mappings. Fallback to gmt_offset.
if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) {
$timezone = '';
}
// Create a UTC+- zone if no timezone string exists
if ( empty( $tzstring ) ) {
if ( 0 === $current_offset ) {
$timezone = 'UTC+0';
} elseif ( $current_offset < 0 ) {
$timezone = 'UTC' . $current_offset;
} else {
$timezone = 'UTC+' . $current_offset;
}
}
$stats['versions'] = array(
'wp' => sanitize_text_field( $GLOBALS['wp_version'] ),
'php' => sanitize_text_field( phpversion() ),
'mysql' => sanitize_text_field( $wpdb->db_version() ),
);
$stats['theme'] = array(
'name' => sanitize_text_field( $theme->get( 'Name' ) ),
'version' => sanitize_text_field( $theme->get( 'Version' ) ),
'stylesheet' => sanitize_text_field( $theme->get_stylesheet() ),
'template' => sanitize_text_field( $theme->get_template() ),
);
$stats['site_language'] = sanitize_text_field( get_locale() );
$stats['user_language'] = sanitize_text_field( get_user_locale() );
$stats['is_public'] = (int) get_option( 'blog_public', 0 );
$stats['wp_debug'] = (int) ( defined( 'WP_DEBUG' ) && WP_DEBUG );
$stats['site_timezone'] = sanitize_text_field( $timezone );
$stats['totals'] = array(
'all_post_types' => (int) $wpdb->get_var( "SELECT COUNT(*) FROM `{$wpdb->posts}`" ),
'events' => (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `{$wpdb->posts}` WHERE post_type = %s", 'tribe_events' ) ),
'venues' => (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `{$wpdb->posts}` WHERE post_type = %s", 'tribe_venue' ) ),
'organizers' => (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `{$wpdb->posts}` WHERE post_type = %s", 'tribe_organizer' ) ),
'event_categories' => (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM `{$wpdb->term_taxonomy}` WHERE taxonomy = %s", 'tribe_events_cat' ) ),
);
self::$stats_full = $stats;
return $stats;
}