/**
* Require the plugin files for Query Monitor, faking a
* plugin activation, if it's the first time.
*/
function wpcom_vip_qm_require()
{
/**
* Filter whether Query Monitor is activated; return true,
* if QM should be activated.
*
* @param bool $enable False by default
*/
if (!apply_filters('wpcom_vip_qm_enable', false)) {
return;
}
if (!defined('SAVEQUERIES')) {
define('SAVEQUERIES', true);
}
// For hyperdb, which doesn't use SAVEQUERIES
global $wpdb;
$wpdb->save_queries = SAVEQUERIES;
$wpcom_vip_qm_file = __DIR__ . '/query-monitor/query-monitor.php';
require_once $wpcom_vip_qm_file;
// Because we're including Query Monitor as an MU plugin, we need to
// manually call the `activate` method on `activation`.
if (0 === get_option('wpcom_vip_qm_activated', 0)) {
QueryMonitor::init($wpcom_vip_qm_file)->activate(true);
update_option('wpcom_vip_qm_activated', 1, true);
}
// We don't want to share our environment information via Query Monitor
remove_filter('qm/collectors', 'register_qm_collector_environment', 20, 2);
// We know we haven't got the QM DB drop-in in place, so don't show the message
add_filter('qm/show_extended_query_prompt', '__return_false');
}