PluginProbe
Pronamic Client / trunk
Pronamic Client vtrunk
2.4.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.4.0 1.5.0 1.6.0 1.6.1 1.7.0 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 All 54 releases
pronamic-client / classes / QueryMonitorModule.php

QueryMonitorModule.php in Pronamic Client trunk, at classes/QueryMonitorModule.php

81 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Pronamic\WordPress\PronamicClient;
4
5 class QueryMonitorModule {
6 /**
7 * Instance of this class.
8 *
9 * @var QueryMonitorModule
10 */
11 protected static $instance = null;
12
13 /**
14 * Plugin
15 *
16 * @var Plugin
17 */
18 private $plugin;
19
20 /**
21 * Construct Query Monitor module.
22 *
23 * @param Plugin $plugin
24 */
25 private function __construct( Plugin $plugin ) {
26 $this->plugin = $plugin;
27
28 \add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
29 }
30
31 /**
32 * Plugins loaded.
33 *
34 * @return void
35 */
36 public function plugins_loaded() {
37 /**
38 * Check if Query Monitor is active.
39 *
40 * @link https://github.com/johnbillion/query-monitor/blob/60da795c040e0f08850891c74a36b2f566cee14d/query-monitor.php#L36
41 */
42 if ( ! \defined( 'QM_VERSION' ) ) {
43 return;
44 }
45
46 \add_filter( 'override_load_textdomain', [ $this, 'override_load_textdomain' ], 10, 2 );
47 }
48
49 /**
50 * Only English for Query Monitor plugin.
51 *
52 * @link https://github.com/johnbillion/query-monitor/blob/60da795c040e0f08850891c74a36b2f566cee14d/classes/QueryMonitor.php#L162-L167
53 * @link https://github.com/WordPress/wordpress-develop/blob/2bb5679d666474d024352fa53f07344affef7e69/src/wp-includes/l10n.php#L69-L71
54 * @link https://github.com/WordPress/wordpress-develop/blob/2bb5679d666474d024352fa53f07344affef7e69/src/wp-includes/l10n.php#L711-L726
55 * @link https://github.com/pronamic/wp-pronamic-client/issues/24
56 * @param bool $override Whether to override the .mo file loading. Default false.
57 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
58 */
59 public function override_load_textdomain( $override, $domain ) {
60 if ( 'query-monitor' === $domain ) {
61 $override = true;
62 }
63
64 return $override;
65 }
66
67 /**
68 * Return an instance of this class.
69 *
70 * @return object A single instance of this class.
71 */
72 public static function get_instance( $plugin = false ) {
73 // If the single instance hasn't been set, set it now.
74 if ( null === self::$instance ) {
75 self::$instance = new self( $plugin );
76 }
77
78 return self::$instance;
79 }
80 }
81