PluginProbe
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More / 2.0.12
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More v2.0.12
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.0.12, at classes/Controllers/Compatibility/QueryMonitor.php

65 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 if ( ! class_exists( 'QueryMonitor' ) ) {
29 return;
30 }
31
32 $this->register_collector();
33 add_filter( 'qm/outputter/html', [ $this, 'register_output_html' ], 10 );
34 }
35
36 /**
37 * Register collector.
38 *
39 * @return void
40 */
41 public function register_collector() {
42 QM_Collectors::add( new Collector() );
43 }
44
45 /**
46 * Add Query Monitor outputter.
47 *
48 * @param array<string,\QM_Output_Html> $output Outputters.
49 * @return array<string,\QM_Output_Html> Outputters.
50 */
51 public function register_output_html( $output ) {
52 if ( ! is_frontend() ) {
53 return $output;
54 }
55
56 $collector = QM_Collectors::get( 'content-control' );
57
58 if ( $collector ) {
59 $output['content-control'] = new Output( $collector );
60 }
61
62 return $output;
63 }
64 }
65