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 / JetpackModule.php

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

75 lines 1.6 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 JetpackModule {
6 /**
7 * Instance of this class.
8 *
9 * @since 1.4.0
10 *
11 * @var Tracking
12 */
13 protected static $instance = null;
14
15 /**
16 * Plugin
17 *
18 * @var Plugin
19 */
20 private $plugin;
21
22 /**
23 * Construct Jetpack module.
24 *
25 * @param Plugin $plugin
26 */
27 private function __construct( Plugin $plugin ) {
28 $this->plugin = $plugin;
29
30 \add_filter( 'jetpack_just_in_time_msgs', [ $this, 'disable_jetpack_just_in_time_msgs_for_pronamic' ], 50 );
31 }
32
33 /**
34 * Disable Jetpack just in time messages for Pronamic user.
35 *
36 * @link https://github.com/Automattic/jetpack/blob/6.8.1/class.jetpack-jitm.php#L21-L31
37 * @link https://github.com/Automattic/jetpack/blob/6.8.1/class.jetpack.php#L665
38 *
39 * @since 1.3.2
40 *
41 * @param bool $show_jitm Whether to show just in time messages.
42 * @return bool False if current user login is 'pronamic', otherwise the passed in value.
43 */
44 public function disable_jetpack_just_in_time_msgs_for_pronamic( $show_jitm ) {
45 // Prevent fatal error if plugin is network activated.
46 if ( ! \function_exists( '\wp_get_current_user' ) ) {
47 return $show_jitm;
48 }
49
50 $user = \wp_get_current_user();
51
52 if ( 'pronamic' === $user->user_login ) {
53 return false;
54 }
55
56 return $show_jitm;
57 }
58
59 /**
60 * Return an instance of this class.
61 *
62 * @since 1.1.0
63 *
64 * @return object A single instance of this class.
65 */
66 public static function get_instance( $plugin = false ) {
67 // If the single instance hasn't been set, set it now.
68 if ( null === self::$instance ) {
69 self::$instance = new self( $plugin );
70 }
71
72 return self::$instance;
73 }
74 }
75