<?php

if (WP_ENV == 'development') {
	if(!function_exists('get_core_updates')) {
		require_once ABSPATH . 'wp-admin/includes/update.php';
	}

	if ( ! class_exists( 'WP_Debug_Data' ) ) {
		require_once ABSPATH . 'wp-admin/includes/class-wp-debug-data.php';
	}

	// Add new data collectors
	add_action( 'template_redirect', 'add_debug_collectors' );

	// Add WordPress info to debugger log
	add_action( 'template_redirect', 'log_wordpress_info' );

	function add_debug_collectors () {
		global $bar;
		global $wpdb;
		global $wp_version;
		$bar->addCollector(new WordpressDatabaseCollector($wpdb));
		$bar->addCollector(new WordpressCollector($wp_version));
		$bar->addCollector(new WarningCollector());
		$wp_info = WP_Debug_Data::debug_data();
		$bar->addCollector(new InfoCollector($wp_info));
	}

	function log_wordpress_info () {
		debug_info(wp_get_current_user(), 'user');
		debug_info(get_page(get_queried_object_id()), 'page');
	}

	if(!function_exists('got_url_rewrite') && !is_admin()) {
		function got_url_rewrite () {
			return false;
		}
	}
}

if(!function_exists('debug_log')){
	function debug_log ($message = '', $path = '', $label = '') {
		return '';
	}
}