Changeset 2436990
- Timestamp:
- 12/10/2020 11:37:56 PM (5 years ago)
- Location:
- wp-generator-remover-dawsun/trunk
- Files:
-
- 2 edited
-
README.txt (modified) (1 diff)
-
wp-generator-remover-dawsun.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-generator-remover-dawsun/trunk/README.txt
r2075049 r2436990 3 3 Donate link: http://www.dawsun.com/ 4 4 Tags: security, wp generator, generator meta, wp generator meta remove, version 5 Requires at least: 3.0.16 Tested up to: 5. 1.17 Stable tag: 4.95 Requires at least: 5.0 6 Tested up to: 5.6 7 Stable tag: 2.0.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
wp-generator-remover-dawsun/trunk/wp-generator-remover-dawsun.php
r1768589 r2436990 3 3 /** 4 4 * 5 * 5 * The plugin main file 6 6 * 7 7 * @link http://www.dawsun.com … … 11 11 * @wordpress-plugin 12 12 * Plugin Name: WP Generator Remover by Dawsun 13 * Plugin URI: http ://www.dawsun.com13 * Plugin URI: https://www.linkedin.com/in/umardraz/ 14 14 * Description: Hide/Remove WordPress Generator Meta, Hide/Remove Stylesheet Version, Hide/Remove Javascript Version 15 * Version: 2.0. 015 * Version: 2.0.1 16 16 * Author: Umar Draz 17 17 * Author URI: http://www.dawsun.com/ … … 22 22 23 23 // If this file is called directly, abort. 24 if ( !defined('WPINC')) {25 die;24 if ( ! defined( 'WPINC' ) ) { 25 die; 26 26 } 27 27 28 class Wp_Renerator_Remover_Dawsun { 28 29 30 public $options; 29 31 32 public function __construct() { 33 $this->options = get_option( 'wpgrd_settings' ); 34 add_action( 'admin_menu', [ 35 $this, 36 'add_admin_menu', 37 ] ); 38 add_action( 'admin_init', [ 39 $this, 40 'settings_init', 41 ] ); 30 42 31 class Wp_generator_remover_dawsun 32 { 43 register_activation_hook( __FILE__, [ 44 $this, 45 'defaults', 46 ] ); 33 47 34 public $ptions; 35 public function __construct() 36 { 48 $this->apply_settings(); 49 } 37 50 38 $this->options = get_option('wpgrd_settings'); 39 add_action('admin_menu', array( 40 $this, 41 'wpgrd_add_admin_menu' 42 )); 43 add_action('admin_init', array( 44 $this, 45 'wpgrd_settings_init' 46 )); 51 // apply the settings 52 public function apply_settings() { 47 53 48 register_activation_hook(__FILE__, array( 49 $this, 50 'wpgrd_defaults' 51 )); 52 53 $this->apply_settings(); 54 55 56 57 } 58 59 // apply the settings 60 public function apply_settings(){ 61 62 // check for wordpess generator 63 if(isset($this->options['wpgrd_checkbox_field_wp_generator']) && $this->options['wpgrd_checkbox_field_wp_generator'] == 1){ 64 $this->wpgrd_remove_wp_generator_meta(); 65 } 66 67 // check for sytlesheet generator 68 if(isset($this->options['wpgrd_checkbox_field_stylesheet']) && $this->options['wpgrd_checkbox_field_stylesheet'] == 1){ 69 add_filter('style_loader_src', array($this, 'wpgrd_remove_version_script_style'), 20000); 70 } 71 72 // check for script/ javascript generator 73 if(isset($this->options['wpgrd_checkbox_field_script']) && $this->options['wpgrd_checkbox_field_script'] == 1){ 74 add_filter('script_loader_src', array($this, 'wpgrd_remove_version_script_style'), 20000); 75 } 76 54 // check for wordpress generator 55 if ( isset( $this->options['wpgrd_checkbox_field_wp_generator'] ) && $this->options['wpgrd_checkbox_field_wp_generator'] == 1 ) { 56 $this->remove_wp_generator_meta(); 77 57 } 78 58 79 80 81 82 public function wpgrd_add_admin_menu() 83 { 84 85 add_options_page('WP Generator Remover by Dawsun Settings', 'WP Generator Remover Setting', 'manage_options', 'wp_generator_remover_by_dawsun', array( 86 $this, 87 'wpgrd_options_page' 88 )); 89 90 } 91 92 93 public function wpgrd_settings_init() 94 { 95 96 register_setting('wpgrd_options', 'wpgrd_settings'); 97 98 add_settings_section('wpgrd_wpgrd_options_section', __('Update Settings', 'wp_generator_remover_dawsun'), array( 99 $this, 100 'wpgrd_settings_section_callback' 101 ), 'wpgrd_options'); 102 103 add_settings_field('wpgrd_checkbox_field_wp_generator', __('Hide WP Generator Version Meta', 'wp_generator_remover_dawsun'), array( 104 $this, 105 'wpgrd_checkbox_field_wp_generator_render' 106 ), 'wpgrd_options', 'wpgrd_wpgrd_options_section'); 107 108 add_settings_field('wpgrd_checkbox_field_stylesheet', __('Hide Stylesheet Version Link', 'wp_generator_remover_dawsun'), array( 109 $this, 110 'wpgrd_checkbox_field_stylesheet_render' 111 ), 'wpgrd_options', 'wpgrd_wpgrd_options_section'); 112 113 add_settings_field('wpgrd_checkbox_field_script', __('Hide Javascript Version Link', 'wp_generator_remover_dawsun'), array( 114 $this, 115 'wpgrd_checkbox_field_script_render' 116 ), 'wpgrd_options', 'wpgrd_wpgrd_options_section'); 117 118 119 120 } 121 122 123 public function wpgrd_checkbox_field_wp_generator_render() 124 { 125 126 127 ?> 128 129 130 131 <input type='checkbox' name='wpgrd_settings[wpgrd_checkbox_field_wp_generator]' <?php 132 checked(isset($this->options['wpgrd_checkbox_field_wp_generator']), 1); 133 ?> value='1'> 134 <?php 135 136 } 137 138 139 public function wpgrd_checkbox_field_stylesheet_render() 140 { 141 142 143 ?> 144 <input type='checkbox' name='wpgrd_settings[wpgrd_checkbox_field_stylesheet]' <?php 145 checked(isset($this->options['wpgrd_checkbox_field_stylesheet']), 1); 146 ?> value='1'> 147 <?php 148 149 } 150 151 152 public function wpgrd_checkbox_field_script_render() 153 { 154 155 156 ?> 157 <input type='checkbox' name='wpgrd_settings[wpgrd_checkbox_field_script]' <?php 158 checked(isset($this->options['wpgrd_checkbox_field_script']), 1); 159 ?> value='1'> 160 <?php 161 162 } 163 164 165 166 167 168 public function wpgrd_settings_section_callback() 169 { 170 171 echo __('Update options and save', 'wp_generator_remover_dawsun'); 172 173 } 174 175 176 public function wpgrd_options_page() 177 { 178 179 ?> 180 <form action='options.php' method='post'> 181 182 <h2>WP Generator Remover by Dawsun Settings</h2> 183 184 <?php 185 settings_fields('wpgrd_options'); 186 do_settings_sections('wpgrd_options'); 187 submit_button(); 188 ?> 189 190 </form> 191 <?php 192 193 } 194 195 196 public function wpgrd_defaults() 197 { 198 199 $defaults = array( 200 'wpgrd_checkbox_field_wp_generator' => 1, 201 'wpgrd_checkbox_field_stylesheet' => 1, 202 'wpgrd_checkbox_field_script' => 1, 203 ); 204 205 if (is_admin()) { 206 update_option('wpgrd_settings', $defaults); 207 } 208 } 209 210 211 212 // remove WP Generator Meta Tag 213 public function wpgrd_remove_wp_generator_meta() { 214 215 216 remove_action('wp_head', 'wp_generator'); 217 59 // check for stylesheet generator 60 if ( isset( $this->options['wpgrd_checkbox_field_stylesheet'] ) && $this->options['wpgrd_checkbox_field_stylesheet'] == 1 ) { 61 add_filter( 'style_loader_src', [ 62 $this, 63 'remove_version_script_style', 64 ], 20000 ); 218 65 } 219 66 67 // check for script/ javascript generator 68 if ( isset( $this->options['wpgrd_checkbox_field_script'] ) && $this->options['wpgrd_checkbox_field_script'] == 1 ) { 69 add_filter( 'script_loader_src', [ 70 $this, 71 'remove_version_script_style', 72 ], 20000 ); 73 } 74 } 220 75 76 public function add_admin_menu() { 77 add_options_page( 'WP Generator Remover by Dawsun Settings', 'Generator Remover', 'manage_options', 'wp_generator_remover_by_dawsun', [ 78 $this, 79 'options_page', 80 ] ); 81 } 221 82 222 // handle stylesheet/javascript url223 public function wpgrd_remove_version_script_style( $target_url ) {83 public function settings_init() { 84 register_setting( 'wpgrd_options', 'wpgrd_settings' ); 224 85 86 add_settings_section( 'wpgrd_wpgrd_options_section', __( 'Update Settings', 'wp_generator_remover_dawsun' ), [ 87 $this, 88 'settings_section_callback', 89 ], 'wpgrd_options' ); 225 90 226 if(strpos( $target_url, 'ver=' )) { 227 $target_url = remove_query_arg( 'ver', $target_url ); 228 } 91 add_settings_field( 'wpgrd_checkbox_field_wp_generator', __( 'Hide WP Generator Version Meta', 'wp_generator_remover_dawsun' ), [ 92 $this, 93 'checkbox_field_wp_generator_render', 94 ], 'wpgrd_options', 'wpgrd_wpgrd_options_section' ); 229 95 230 return $target_url; 96 add_settings_field( 'wpgrd_checkbox_field_stylesheet', __( 'Hide Stylesheet Version Link', 'wp_generator_remover_dawsun' ), [ 97 $this, 98 'checkbox_field_stylesheet_render', 99 ], 'wpgrd_options', 'wpgrd_wpgrd_options_section' ); 100 101 add_settings_field( 'wpgrd_checkbox_field_script', __( 'Hide Javascript Version Link', 'wp_generator_remover_dawsun' ), [ 102 $this, 103 'checkbox_field_script_render', 104 ], 'wpgrd_options', 'wpgrd_wpgrd_options_section' ); 105 106 } 107 108 public function checkbox_field_wp_generator_render() { 109 ?> 110 <input type='checkbox' name='wpgrd_settings[wpgrd_checkbox_field_wp_generator]' <?php 111 checked( isset( $this->options['wpgrd_checkbox_field_wp_generator'] ), 1 ); 112 ?> value='1'> 113 <?php 114 } 115 116 public function checkbox_field_stylesheet_render() { 117 ?> 118 <input type='checkbox' name='wpgrd_settings[wpgrd_checkbox_field_stylesheet]' <?php 119 checked( isset( $this->options['wpgrd_checkbox_field_stylesheet'] ), 1 ); 120 ?> value='1'> 121 <?php 122 } 123 124 public function checkbox_field_script_render() { 125 ?> 126 <input type='checkbox' name='wpgrd_settings[wpgrd_checkbox_field_script]' <?php 127 checked( isset( $this->options['wpgrd_checkbox_field_script'] ), 1 ); 128 ?> value='1'> 129 <?php 130 } 131 132 public function settings_section_callback() { 133 _e( 'Update options and save', 'wp_generator_remover_dawsun' ); 134 } 135 136 public function options_page() { 137 ?> 138 <form action='options.php' method='post'> 139 <h2><?php _e( 'WP Generator Remover by Dawsun Settings', 'wp_generator_remover_dawsun' ); ?></h2> 140 <?php 141 settings_fields( 'wpgrd_options' ); 142 do_settings_sections( 'wpgrd_options' ); 143 submit_button(); 144 ?> 145 </form> 146 <?php 147 } 148 149 public function defaults() { 150 $defaults = [ 151 'wpgrd_checkbox_field_wp_generator' => 1, 152 'wpgrd_checkbox_field_stylesheet' => 1, 153 'wpgrd_checkbox_field_script' => 1, 154 ]; 155 156 if ( current_user_can('manage_options') ) { 157 update_option( 'wpgrd_settings', $defaults ); 158 } 159 } 160 161 // remove WP Generator Meta Tag 162 public function remove_wp_generator_meta() { 163 remove_action( 'wp_head', 'wp_generator' ); 164 } 165 166 // handle stylesheet/javascript url 167 public function remove_version_script_style( $target_url ) { 168 if ( strpos( $target_url, 'ver=' ) ) { 169 $target_url = remove_query_arg( 'ver', $target_url ); 231 170 } 232 171 233 234 172 return $target_url; 173 } 235 174 } 236 175 237 238 new Wp_ generator_remover_dawsun();176 // fire the plugin 177 new Wp_Renerator_Remover_Dawsun();
Note: See TracChangeset
for help on using the changeset viewer.