cleanup.php ➔ isgabmi_active()   A
last analyzed

Complexity

Conditions 4
Paths 6

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 6
nop 1
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
/**
3
 * Clean up HTML
4
 *
5
 * @since:      1.0.0
6
 * @author:     sewmyheadon
7
 * @link:       https://ivycat.com
8
 */
9
10
11
/**
12
 * Remove WordPress Generator HTML comments
13
 */
14
remove_action( 'wp_head', 'wp_generator' );
15
16
/**
17
 * Remove WooCommerce Generator HTML comments.
18
 */
19
remove_action( 'wp_head', 'wc_generator_tag' );
20
21
/**
22
 * Remove All in One SEO Pack HTML comments
23
 * @link //gist.github.com/llgruff/a7ab776167aa0ed307ec445df54e5fdb
24
 */
25 View Code Duplication
if ( defined( 'AIOSEOP_VERSION' ) ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
	add_action( 'get_header', function () {
27
		ob_start(
28
			function ( $o ) {
29
				return preg_replace( '/\n?<.*?One SEO Pack.*?>/mi', '', $o );
30
			}
31
		);
32
	} );
33
	add_action( 'wp_head', function () {
34
		ob_end_flush();
35
	}, 999 );
36
}
37
38
/**
39
 * Remove Yoast SEO HTML comments
40
 * @link //gist.github.com/llgruff/a7ab776167aa0ed307ec445df54e5fdb
41
 * @link //gist.github.com/paulcollett/4c81c4f6eb85334ba076
42
 */
43 View Code Duplication
if ( defined( 'WPSEO_VERSION' ) ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
	add_action( 'get_header', function () {
45
		ob_start(
46
			function ( $o ) {
47
				return preg_replace( '/^<!--.*?[Y]oast.*?-->$/mi', '', $o );
48
			}
49
		);
50
	} );
51
	add_action( 'wp_head', function () {
52
		ob_end_flush();
53
	}, 999 );
54
}
55
56
/**
57
 * Remove Google Analytics by MonsterInsights HTML comments
58
 * @link https://wordpress.org/plugins/remove-google-analytics-comments/
59
 */
60
function isgabmi_active( $plugin ) {
61
	$network_active = false;
62
	if ( is_multisite() ) {
63
		$plugins = get_site_option( 'active_sitewide_plugins' );
64
		if ( isset( $plugins[ $plugin ] ) ) {
65
			$network_active = true;
66
		}
67
	}
68
69
	return in_array( $plugin, get_option( 'active_plugins' ) ) || $network_active;
70
}
71
72 View Code Duplication
if ( isgabmi_active( 'google-analytics-for-wordpress/googleanalytics.php' ) || isgabmi_active( 'google-analytics-premium/googleanalytics.php' ) ) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
73
	add_action( 'get_header', function () {
74
		ob_start( function ( $o ) {
75
			return preg_replace( '/\n?<.*?monsterinsights.*?>/mi', '', $o );
76
		} );
77
	} );
78
	add_action( 'wp_head', function () {
79
		ob_end_flush();
80
	}, 999 );
81
}
82
83