PluginProbe
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More / 2.6.0
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More v2.6.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.10 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 47 releases
content-control / classes / Controllers / Compatibility / QueryMonitor.php

QueryMonitor.php in Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More 2.6.0, at classes/Controllers/Compatibility/QueryMonitor.php

70 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * QueryMonitor
4 *
5 * @package ContentControl
6 */
7
8 namespace ContentControl\Controllers\Compatibility;
9
10 use ContentControl\Base\Controller;
11 use ContentControl\QueryMonitor\Output;
12 use ContentControl\QueryMonitor\Collector;
13 use QM_Collectors;
14
15 use function ContentControl\is_frontend;
16
17 /**
18 * QueryMonitor
19 */
20 class QueryMonitor extends Controller {
21
22 /**
23 * Initialize the class
24 *
25 * @return void
26 */
27 public function init() {
28 $this->register_collector();
29 add_filter( 'qm/outputter/html', [ $this, 'register_output_html' ], 10 );
30 }
31
32 /**
33 * Check if controller is enabled.
34 *
35 * @return bool
36 */
37 public function controller_enabled() {
38 return class_exists( 'QueryMonitor' );
39 }
40
41 /**
42 * Register collector.
43 *
44 * @return void
45 */
46 public function register_collector() {
47 QM_Collectors::add( new Collector() );
48 }
49
50 /**
51 * Add Query Monitor outputter.
52 *
53 * @param array<string,\QM_Output_Html> $output Outputters.
54 * @return array<string,\QM_Output_Html> Outputters.
55 */
56 public function register_output_html( $output ) {
57 if ( ! is_frontend() ) {
58 return $output;
59 }
60
61 $collector = QM_Collectors::get( 'content-control' );
62
63 if ( $collector ) {
64 $output['content-control'] = new Output( $collector );
65 }
66
67 return $output;
68 }
69 }
70