1 | <?php |
||
8 | class JetpackTracking { |
||
9 | static $product_name = 'jetpack'; |
||
|
|||
10 | |||
11 | static function track_jetpack_usage() { |
||
12 | if ( ! Jetpack::is_active() ) { |
||
13 | return; |
||
14 | } |
||
15 | |||
16 | // For tracking stuff via js/ajax |
||
17 | add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_tracks_scripts' ) ); |
||
18 | |||
19 | add_action( 'jetpack_pre_activate_module', array( __CLASS__, 'track_activate_module'), 1, 1 ); |
||
20 | add_action( 'jetpack_pre_deactivate_module', array( __CLASS__, 'track_deactivate_module'), 1, 1 ); |
||
21 | add_action( 'jetpack_user_authorized', array( __CLASS__, 'track_user_linked' ) ); |
||
22 | } |
||
23 | |||
24 | static function enqueue_tracks_scripts() { |
||
25 | wp_enqueue_script( 'jptracks', plugins_url( '_inc/lib/tracks/tracks-ajax.js', JETPACK__PLUGIN_FILE ), array(), JETPACK__VERSION, true ); |
||
26 | wp_localize_script( 'jptracks', 'jpTracksAJAX', array( |
||
27 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
||
28 | 'jpTracksAJAX_nonce' => wp_create_nonce( 'jp-tracks-ajax-nonce' ), |
||
29 | ) ); |
||
30 | } |
||
31 | |||
32 | /* User has linked their account */ |
||
33 | static function track_user_linked() { |
||
50 | |||
51 | /* Activated module */ |
||
52 | static function track_activate_module( $module ) { |
||
55 | |||
56 | /* Deactivated module */ |
||
57 | static function track_deactivate_module( $module ) { |
||
60 | |||
61 | static function record_user_event( $event_type, $data ) { |
||
62 | |||
81 | } |
||
82 | |||
84 |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.