Switch to class autoloading via Composer.

pull/669/head
John Blackbourn 2 years ago
parent be719c3910
commit 7adacf83f2

@ -43,8 +43,6 @@ class Debug_Bar {
* @return void
*/
public function init_panels() {
require_once 'debug_bar_panel.php';
/**
* Filters the debug bar panel list. This mimics the same filter called in the Debug Bar plugin.
*

@ -66,14 +66,11 @@ function register_qm_collectors_debug_bar() {
global $debug_bar;
if ( class_exists( 'Debug_Bar' ) || qm_debug_bar_being_activated() ) {
if ( class_exists( 'Debug_Bar', false ) || qm_debug_bar_being_activated() ) {
return;
}
$collectors = QM_Collectors::init();
$qm = QueryMonitor::init();
require_once $qm->plugin_path( 'classes/debug_bar.php' );
$debug_bar = new Debug_Bar();
$redundant = array(

@ -320,8 +320,6 @@ class QM_Collector_PHP_Errors extends QM_Collector {
wp_load_translations_early();
}
require_once dirname( __DIR__ ) . '/output/Html.php';
// This hides the subsequent message from the fatal error handler in core. It cannot be
// disabled by a plugin so we'll just hide its output.
echo '<style type="text/css"> .wp-die-message { display: none; } </style>';

@ -70,6 +70,12 @@
]
},
"autoload": {
"classmap": [
"classes",
"output"
]
},
"autoload-dev": {
"psr-4": {
"QM\\Tests\\": "tests/integration"
}

@ -62,9 +62,6 @@ class QM_Dispatcher_AJAX extends QM_Dispatcher {
* @return void
*/
protected function before_output() {
require_once $this->qm->plugin_path( 'output/Headers.php' );
foreach ( glob( $this->qm->plugin_path( 'output/headers/*.php' ) ) as $file ) {
require_once $file;
}

@ -337,9 +337,6 @@ class QM_Dispatcher_Html extends QM_Dispatcher {
* @return void
*/
protected function before_output() {
require_once $this->qm->plugin_path( 'output/Html.php' );
foreach ( glob( $this->qm->plugin_path( 'output/html/*.php' ) ) as $file ) {
require_once $file;
}

@ -51,9 +51,6 @@ class QM_Dispatcher_REST extends QM_Dispatcher {
* @return void
*/
protected function before_output() {
require_once $this->qm->plugin_path( 'output/Headers.php' );
foreach ( glob( $this->qm->plugin_path( 'output/headers/*.php' ) ) as $file ) {
include_once $file;
}

@ -47,8 +47,6 @@ class QM_Dispatcher_REST_Envelope extends QM_Dispatcher {
* @return void
*/
protected function before_output() {
require_once $this->qm->plugin_path( 'output/Raw.php' );
foreach ( glob( $this->qm->plugin_path( 'output/raw/*.php' ) ) as $file ) {
include_once $file;
}

@ -50,9 +50,6 @@ class QM_Dispatcher_Redirect extends QM_Dispatcher {
* @return void
*/
protected function before_output() {
require_once $this->qm->plugin_path( 'output/Headers.php' );
foreach ( glob( $this->qm->plugin_path( 'output/headers/*.php' ) ) as $file ) {
require_once $file;
}

@ -51,8 +51,6 @@ class QM_Dispatcher_WP_Die extends QM_Dispatcher {
return;
}
require_once $this->qm->plugin_path( 'output/Html.php' );
$switched_locale = self::switch_to_locale( get_user_locale() );
$stack = array();
$filtered_trace = $this->trace->get_filtered_trace();

@ -37,6 +37,7 @@ define( 'QM_VERSION', '3.9.0' );
$qm_dir = dirname( __FILE__ );
// This must be required before vendor/autoload.php so QM can serve its own message about PHP compatibility.
require_once "{$qm_dir}/classes/PHP.php";
if ( ! QM_PHP::version_met() ) {
@ -44,15 +45,11 @@ if ( ! QM_PHP::version_met() ) {
return;
}
# No autoloaders for us. See https://github.com/johnbillion/query-monitor/issues/7
foreach ( array( 'Plugin', 'Activation', 'Util', 'QM' ) as $qm_class ) {
require_once "{$qm_dir}/classes/{$qm_class}.php";
}
require_once "{$qm_dir}/vendor/autoload.php";
QM_Activation::init( __FILE__ );
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once "{$qm_dir}/classes/CLI.php";
QM_CLI::init( __FILE__ );
}
@ -71,13 +68,6 @@ if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
return;
}
foreach ( array( 'QueryMonitor', 'Backtrace', 'Collectors', 'Collector', 'Dispatchers', 'Dispatcher', 'Hook', 'Output', 'Timer' ) as $qm_class ) {
require_once "{$qm_dir}/classes/{$qm_class}.php";
}
unset(
$qm_dir,
$qm_class
);
unset( $qm_dir );
QueryMonitor::init( __FILE__ )->set_up();

@ -1,7 +1,5 @@
<?php
require_once dirname( __DIR__, 2 ) . '/classes/Backtrace.php';
// QM constants:
define( 'QM_COOKIE', '' );

@ -42,7 +42,7 @@ if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
return;
}
# No autoloaders for us. See https://github.com/johnbillion/query-monitor/issues/7
// This must be required before vendor/autoload.php so QM can serve its own message about PHP compatibility.
$qm_dir = dirname( dirname( __FILE__ ) );
$qm_php = "{$qm_dir}/classes/PHP.php";
@ -55,11 +55,11 @@ if ( ! QM_PHP::version_met() ) {
return;
}
$backtrace = "{$qm_dir}/classes/Backtrace.php";
if ( ! is_readable( $backtrace ) ) {
require_once "{$qm_dir}/vendor/autoload.php";
if ( ! class_exists( 'QM_Backtrace' ) ) {
return;
}
require_once $backtrace;
if ( ! defined( 'SAVEQUERIES' ) ) {
define( 'SAVEQUERIES', true );

Loading…
Cancel
Save