Skip to content

Commit 27114e1

Browse files
Added Whoops setup.
1 parent 8f45068 commit 27114e1

File tree

4 files changed

+63
-24
lines changed

4 files changed

+63
-24
lines changed

composer.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
"sort-order": true
2525
},
2626
"autoload": {
27-
"files": [
28-
"src/functions.php",
29-
"src/class-admin-bar.php"
30-
],
3127
"psr-4": {
3228
"KnowTheCode\\DebugToolkit\\": "src"
3329
},

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

debug-toolkit.php

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,7 @@ function _get_plugin_root_dir() {
5454

5555
// Load the files and Composer.
5656
require_once __DIR__ . '/vendor/autoload.php';
57+
require_once __DIR__ . '/src/setup.php';
58+
require_once __DIR__ . '/src/vardumper-functions.php';
5759

58-
/**
59-
* Load the Admin Bar.
60-
*
61-
* @since 1.0.0
62-
*/
63-
function load_admin_bar() {
64-
/**
65-
* Filter the admin bar configuration parameters.
66-
*
67-
* @since 1.0.0
68-
*
69-
* @param array $config Array of configuration parameters.
70-
*/
71-
$config = apply_filters( 'debug_toolkit_admin_bar_config', (array) require __DIR__ . '/config/admin-bar.php' );
72-
73-
( new Admin_Bar( $config ) )->init();
74-
}
75-
76-
load_admin_bar();
60+
_setup_plugin();

src/setup.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Set up Whoops.
4+
*
5+
* @package KnowTheCode\DebugToolkit
6+
* @since 1.0.0
7+
* @author hellofromTonya
8+
* @link https://github.com/KnowTheCode/debug-toolkit
9+
* @license GNU-2.0+
10+
*/
11+
12+
namespace KnowTheCode\DebugToolkit;
13+
14+
use Whoops\Handler\PrettyPageHandler;
15+
use Whoops\Run;
16+
17+
/**
18+
* Description.
19+
*
20+
* @since 1.0.0
21+
* @access private
22+
*/
23+
function _setup_plugin() {
24+
_setup_whoops();
25+
_setup_admin_bar();
26+
}
27+
28+
/**
29+
* Set up the Whoops container.
30+
*
31+
* @since 1.0.0
32+
* @access private
33+
*/
34+
function _setup_whoops() {
35+
$whoops = new Run();
36+
$whoops->pushHandler( new PrettyPageHandler );
37+
$whoops->register();
38+
}
39+
40+
/**
41+
* Set up the Admin Bar.
42+
*
43+
* @since 1.0.0
44+
* @access private
45+
*/
46+
function _setup_admin_bar() {
47+
require_once __DIR__ . '/class-admin-bar.php';
48+
49+
/**
50+
* Filter the admin bar configuration parameters.
51+
*
52+
* @since 1.0.0
53+
*
54+
* @param array $config Array of configuration parameters.
55+
*/
56+
$config = apply_filters( 'debug_toolkit_admin_bar_config', (array) require _get_plugin_root_dir() . '/config/admin-bar.php' );
57+
58+
( new Admin_Bar( $config ) )->init();
59+
}

0 commit comments

Comments
 (0)