-
Notifications
You must be signed in to change notification settings - Fork 0
/
envireit-remove-versions.php
117 lines (104 loc) · 2.65 KB
/
envireit-remove-versions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/*
Plugin Name: Envire.it Remove Versions Plugin
Plugin URI: https://www.envire.it
Description: Envire.it Remove Versions Plugin
Author: Sergio De Falco
Version: 1.0
Author URI: https://www.envire.it/
Text Domain: envireit-remove-versions
Domain Path: /languages/
License: GPL v3
*/
register_activation_hook( __FILE__ , array( 'Envireit_Remove_Versions_Loader', 'activate_plugin' ) ); // Registering plugin activation hook.
register_deactivation_hook( __FILE__, array( 'Envireit_Remove_Versions_Loader', 'deactivate_plugin' ) ); // Registering plugin deactivation hook.
/**
* Load the Remove Versions Plugin
*
* @since 1.0
*/
class Envireit_Remove_Versions_Loader {
/**
* Uniquely identify plugin version
* Bust caches based on this value
*
* @since 1.0
* @var string
*/
const VERSION = '1.0';
/**
* Define Simple CDN default settings.
*
* @since 1.0
*
* @var array {}
*/
public $simple_cdn_settings_defaults = array(
'version' => '1.0'
);
/**
* Let's get it started
*
* @since 1.0
*/
public function __construct() {
// Load the textdomain for translations
load_plugin_textdomain( 'envireit-remove-versions', true, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
// Check if is admin and intialize the administration.
if ( ! is_admin() ) {
add_action( 'wp', array( &$this, 'public_init' ) );
}
}
/**
* Handles actions for the plugin activation
*
* @since 1.0
*/
static function activate_plugin() {
}
/**
* Handles actions for the plugin deactivation
*
* @since 1.0
*/
static function deactivate_plugin() {
}
/**
* Intialize the public.
*
* @since 1.0
*/
public function public_init() {
add_filter( 'style_loader_src', array( &$this, 'remove_version_querystring' ), 1000 );
add_filter( 'script_loader_src', array( &$this, 'remove_version_querystring' ), 1000 );
add_filter( 'the_generator', array( &$this, 'remove_wp_version' ), 99);
}
/**
* Remove Query var version from enqueued styles and scripts
*
* @since 1.0
*/
public function remove_version_querystring( $src ) {
if( strpos( $src, '?ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
/**
* Remove WordPress version number from all different areas
*
* @since 1.0
*/
public function remove_wp_version() {
return '';
}
}
/**
* Load plugin function during the WordPress init action
*
* @since 1.0
*/
function remove_versions_plugin_loader_init() {
global $remove_versions_plugin_loader;
$remove_versions_plugin_loader = new Envireit_Remove_Versions_Loader();
}
add_action( 'init', 'remove_versions_plugin_loader_init', 0 ); // load before widgets_init at 1