Passed
Push — master ( 1c2532...62e7b2 )
by Chris
04:52 queued 01:41
created

monsterinsights_seedprod_tracking()   A

Complexity

Conditions 5
Paths 3

Size

Total Lines 24
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 15
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 24
rs 9.4555
1
<?php
2
/**
3
 * SeedProd Tracking for 404 and Coming Soon.
4
 *
5
 * @since 7.3.0
6
 *
7
 * @package MonsterInsights
8
 * @author  Chris Christoff
9
 */
10
11
// Exit if accessed directly
12
if ( ! defined( 'ABSPATH' ) ) {
13
    exit;
14
}
15
16
// 1. Disable SeedProd settings (done in seedprod)
17
// 2. Output tracking code, if settings is not set to use wp_head() (done in seedprod and below)
18
// 3. Disable ga_tracking in their setting (done in seedprod)
19
function monsterinsights_seedprod_tracking( $settings ) {
0 ignored issues
show
Unused Code introduced by
The parameter $settings is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

19
function monsterinsights_seedprod_tracking( /** @scrutinizer ignore-unused */ $settings ) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
20
    require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/class-tracking-abstract.php';
21
22
23
    do_action( 'monsterinsights_tracking_before_analytics' );
24
    do_action( 'monsterinsights_tracking_before', 'analytics' );
25
26
    require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-analytics.php';
27
    $tracking = new MonsterInsights_Tracking_Analytics();
28
    echo $tracking->frontend_output();
29
30
    do_action( 'monsterinsights_tracking_after_analytics' );
31
    do_action( 'monsterinsights_tracking_after', 'analytics' );
32
33
    $events_mode   = monsterinsights_get_option( 'events_mode', false );
34
    $track_user    = monsterinsights_track_user();
35
36
    if ( $track_user && ( $events_mode === 'js' || $events_mode === 'php' ) ) {
37
        require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-analytics-events.php';
38
        new MonsterInsights_Analytics_Events();
39
40
        // Let's run form tracking if we find it
41
        if ( function_exists( 'monsterinsights_forms_output_after_script' ) ) {
42
            monsterinsights_forms_output_after_script( array() );
43
        }
44
    }
45
}
46
add_action( 'seedprod_monsterinsights_output_tracking', 'monsterinsights_seedprod_tracking', 6, 1 );