| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Admin\Options; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Utils; |
| 6 |
use WPAdminify\Inc\Admin\AdminSettingsModel; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
die; |
| 10 |
} // Cannot access directly. |
| 11 |
|
| 12 |
class Tweaks_Head extends AdminSettingsModel { |
| 13 |
|
| 14 |
public function __construct() { |
| 15 |
$this->tweaks_head_settings(); |
| 16 |
} |
| 17 |
|
| 18 |
public function get_defaults() { |
| 19 |
return [ |
| 20 |
'generator_wp_version' => false, |
| 21 |
'remove_wc_generator' => false, |
| 22 |
'remove_revslider_generator' => false, |
| 23 |
'remove_visual_composer_generator' => false, |
| 24 |
'remove_wpml_generator' => false, |
| 25 |
'remove_yoast_generator' => false, |
| 26 |
'remove_version_strings' => false, |
| 27 |
'remove_dashicons' => false, |
| 28 |
'remove_link_url' => false, |
| 29 |
'remove_wlwmanifest' => false, |
| 30 |
'remove_dns_prefetch' => false, |
| 31 |
'remove_rsd' => false, |
| 32 |
'remove_shortlink' => false, |
| 33 |
'remove_canonical' => false, |
| 34 |
'remove_emoji' => false, |
| 35 |
'remove_prev_next' => false, |
| 36 |
'remove_recentcomments' => false, |
| 37 |
'disable_xmlrpc' => false, |
| 38 |
]; |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
/** |
| 43 |
* Tweaks: Head Fields |
| 44 |
* |
| 45 |
* @return void |
| 46 |
*/ |
| 47 |
public function tweaks_head_fields( &$head_fields ) { |
| 48 |
$head_fields[] = [ |
| 49 |
'type' => 'subheading', |
| 50 |
'content' => Utils::adminfiy_help_urls( |
| 51 |
__( 'Remove unncessary links, scripts and styles from head section.', 'adminify' ), |
| 52 |
'https://wpadminify.com/kb/wp-adminify-tweaks/', |
| 53 |
'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', |
| 54 |
'https://www.facebook.com/groups/jeweltheme', |
| 55 |
'https://wpadminify.com/support/' |
| 56 |
), |
| 57 |
]; |
| 58 |
|
| 59 |
$head_fields[] = [ |
| 60 |
'id' => 'generator_wp_version', |
| 61 |
'type' => 'switcher', |
| 62 |
'title' => __( 'Remove Generator Version', 'adminify' ), |
| 63 |
'subtitle' => __( 'Remove WordPress Generator WordPress Version from Frontend and RSS Feed', 'adminify' ), |
| 64 |
'label' => __( 'This meta tag just shows your WordPress version. You can remove it for security reasons and keep your head section clean.', 'adminify' ), |
| 65 |
'text_on' => __( 'Yes', 'adminify' ), |
| 66 |
'text_off' => __( 'No', 'adminify' ), |
| 67 |
'text_width' => 80, |
| 68 |
'default' => $this->get_default_field( 'generator_wp_version' ), |
| 69 |
]; |
| 70 |
|
| 71 |
if ( Utils::is_plugin_active( 'woocommerce/woocommerce.php' ) ) { |
| 72 |
$head_fields[] = [ |
| 73 |
'id' => 'remove_wc_generator', |
| 74 |
'type' => 'switcher', |
| 75 |
'title' => __( 'Remove WooCommerce Generator Meta', 'adminify' ), |
| 76 |
'subtitle' => __( 'Remove <meta name="generator" content="WooCommerce x.x.x" /> from head section', 'adminify' ), |
| 77 |
'text_on' => __( 'Yes', 'adminify' ), |
| 78 |
'text_off' => __( 'No', 'adminify' ), |
| 79 |
'text_width' => 80, |
| 80 |
]; |
| 81 |
} |
| 82 |
|
| 83 |
if ( Utils::is_plugin_active( 'revslider/revslider.php' ) ) { |
| 84 |
$head_fields[] = [ |
| 85 |
'id' => 'remove_revslider_generator', |
| 86 |
'type' => 'switcher', |
| 87 |
'title' => __( 'Remove Revolution Slider Generator Meta', 'adminify' ), |
| 88 |
'subtitle' => __( 'Remove <meta name="generator" content="Revolution Slider x.x.x" /> from head section', 'adminify' ), |
| 89 |
'text_on' => __( 'Yes', 'adminify' ), |
| 90 |
'text_off' => __( 'No', 'adminify' ), |
| 91 |
'text_width' => 80, |
| 92 |
]; |
| 93 |
} |
| 94 |
|
| 95 |
if ( Utils::is_plugin_active( 'js_composer/js_composer.php' ) ) { |
| 96 |
$head_fields[] = [ |
| 97 |
'id' => 'remove_visual_composer_generator', |
| 98 |
'type' => 'switcher', |
| 99 |
'title' => __( 'Remove Visual Composer Generator Meta', 'adminify' ), |
| 100 |
'subtitle' => __( 'Remove <meta name="generator" content="Visual Composer x.x.x" /> from head section', 'adminify' ), |
| 101 |
'text_on' => __( 'Yes', 'adminify' ), |
| 102 |
'text_off' => __( 'No', 'adminify' ), |
| 103 |
'text_width' => 80, |
| 104 |
]; |
| 105 |
} |
| 106 |
|
| 107 |
if ( Utils::is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) { |
| 108 |
$head_fields[] = [ |
| 109 |
'id' => 'remove_wpml_generator', |
| 110 |
'type' => 'switcher', |
| 111 |
'title' => __( 'Remove WPML Generator Meta', 'adminify' ), |
| 112 |
'subtitle' => __( 'Remove <meta name="generator" content="Visual Composer x.x.x" /> from head section', 'adminify' ), |
| 113 |
'text_on' => __( 'Yes', 'adminify' ), |
| 114 |
'text_off' => __( 'No', 'adminify' ), |
| 115 |
'text_width' => 80, |
| 116 |
]; |
| 117 |
} |
| 118 |
|
| 119 |
if ( Utils::is_plugin_active( 'wordpress-seo/wp-seo.php' ) ) { |
| 120 |
$head_fields[] = [ |
| 121 |
'id' => 'remove_yoast_generator', |
| 122 |
'type' => 'switcher', |
| 123 |
'title' => __( 'Remove All Yoast HTML Comments', 'adminify' ), |
| 124 |
'subtitle' => __( 'Remove Yoast HTML Comments', 'adminify' ), |
| 125 |
'label' => __( 'Remove message - "This site is optimized with the Yoast WordPress SEO plugin" generated by Yoast', 'adminify' ), |
| 126 |
'text_on' => __( 'Yes', 'adminify' ), |
| 127 |
'text_off' => __( 'No', 'adminify' ), |
| 128 |
'text_width' => 80, |
| 129 |
]; |
| 130 |
} |
| 131 |
|
| 132 |
$head_fields[] = [ |
| 133 |
'id' => 'remove_version_strings', |
| 134 |
'type' => 'switcher', |
| 135 |
'title' => __( 'Remove Version from Style and Script', 'adminify' ), |
| 136 |
'subtitle' => __( 'Remove Version Number from Styles/Scripts', 'adminify' ), |
| 137 |
'text_on' => __( 'Yes', 'adminify' ), |
| 138 |
'text_off' => __( 'No', 'adminify' ), |
| 139 |
'text_width' => 80, |
| 140 |
]; |
| 141 |
|
| 142 |
$head_fields[] = [ |
| 143 |
'id' => 'remove_dashicons', |
| 144 |
'type' => 'switcher', |
| 145 |
'title' => __( 'Remove Dashicons', 'adminify' ), |
| 146 |
'subtitle' => __( 'Remove Dashicons from Admin Bar for non logged in users', 'adminify' ), |
| 147 |
'text_on' => __( 'Yes', 'adminify' ), |
| 148 |
'text_off' => __( 'No', 'adminify' ), |
| 149 |
'text_width' => 80, |
| 150 |
]; |
| 151 |
|
| 152 |
$head_fields[] = [ |
| 153 |
'id' => 'remove_link_url', |
| 154 |
'type' => 'switcher', |
| 155 |
'title' => __( 'Remove Index Link', 'adminify' ), |
| 156 |
'subtitle' => esc_html__( 'Remove "<link rel=\'index\'..." from head section', 'adminify' ), |
| 157 |
'label' => 'Remove Homepage Index Link', |
| 158 |
'text_on' => __( 'Yes', 'adminify' ), |
| 159 |
'text_off' => __( 'No', 'adminify' ), |
| 160 |
'text_width' => 80, |
| 161 |
]; |
| 162 |
|
| 163 |
$head_fields[] = [ |
| 164 |
'id' => 'remove_wlwmanifest', |
| 165 |
'type' => 'switcher', |
| 166 |
'title' => __( 'Remove WLW Manifest Link', 'adminify' ), |
| 167 |
'subtitle' => esc_html__( 'Remove "<link rel=\'wlwmanifest\'..." from head section', 'adminify' ), |
| 168 |
'label' => 'WLW Manifest Link adds support for Windows Live Writer app. If you are not using this app you can remove this link.', |
| 169 |
'text_on' => __( 'Yes', 'adminify' ), |
| 170 |
'text_off' => __( 'No', 'adminify' ), |
| 171 |
'text_width' => 80, |
| 172 |
]; |
| 173 |
|
| 174 |
$head_fields[] = [ |
| 175 |
'id' => 'remove_dns_prefetch', |
| 176 |
'type' => 'switcher', |
| 177 |
'title' => __( 'Remove WP.org DNS Prefetch', 'adminify' ), |
| 178 |
'subtitle' => esc_html__( 'Remove <link rel="dns-prefetch" href="http://www.yourdomain.com/"> from head section', 'adminify' ), |
| 179 |
'label' => __( 'If all of your resources has the same domain yo can disable forcing DNS lookup of specific hostnames', 'adminify' ), |
| 180 |
'text_on' => __( 'Yes', 'adminify' ), |
| 181 |
'text_off' => __( 'No', 'adminify' ), |
| 182 |
'text_width' => 80, |
| 183 |
]; |
| 184 |
|
| 185 |
$head_fields[] = [ |
| 186 |
'id' => 'remove_rsd', |
| 187 |
'type' => 'switcher', |
| 188 |
'title' => __( 'Remove RSD Link (EditURI Link)', 'adminify' ), |
| 189 |
'subtitle' => esc_html__( 'Remove "<link rel=\'EditURI\'..." from head section', 'adminify' ), |
| 190 |
'label' => __( 'RSD (Real Simple Discovery) is the mechanism used by XML-RPC clients. Also this mechanism can be used by spammers. If do not use this clients with your site, you can remove it.', 'adminify' ), |
| 191 |
'text_on' => __( 'Yes', 'adminify' ), |
| 192 |
'text_off' => __( 'No', 'adminify' ), |
| 193 |
'text_width' => 80, |
| 194 |
]; |
| 195 |
|
| 196 |
$head_fields[] = [ |
| 197 |
'id' => 'remove_shortlink', |
| 198 |
'type' => 'switcher', |
| 199 |
'title' => __( 'Remove Shortlink', 'adminify' ), |
| 200 |
'subtitle' => esc_html__( 'Remove "<link rel=\'shortlink\'..." from head section', 'adminify' ), |
| 201 |
'label' => __( 'This meta tag just shows short link (not canonical link) to your posts. You can remove it.', 'adminify' ), |
| 202 |
'text_on' => __( 'Yes', 'adminify' ), |
| 203 |
'text_off' => __( 'No', 'adminify' ), |
| 204 |
'text_width' => 80, |
| 205 |
]; |
| 206 |
|
| 207 |
$head_fields[] = [ |
| 208 |
'id' => 'remove_canonical', |
| 209 |
'type' => 'switcher', |
| 210 |
'title' => __( 'Remove Canonical URL', 'adminify' ), |
| 211 |
'subtitle' => esc_html__( 'Remove <link rel="canonical" href="http://www.site.com/some-url" /> from head section', 'adminify' ), |
| 212 |
'label' => 'Remove Canonical URL. Details: https://support.google.com/webmasters/answer/139066?hl=en', |
| 213 |
'text_on' => __( 'Yes', 'adminify' ), |
| 214 |
'text_off' => __( 'No', 'adminify' ), |
| 215 |
'text_width' => 80, |
| 216 |
]; |
| 217 |
|
| 218 |
$head_fields[] = [ |
| 219 |
'id' => 'remove_emoji', |
| 220 |
'type' => 'switcher', |
| 221 |
'title' => __( 'Remove Emoji Styles and Scripts', 'adminify' ), |
| 222 |
'subtitle' => __( 'Remove Emoji styles and scripts from head section', 'adminify' ), |
| 223 |
'label' => __( 'If you are not using emoji smiles on your site you can disable this feature and keep your head section clean.', 'adminify' ), |
| 224 |
'text_on' => __( 'Yes', 'adminify' ), |
| 225 |
'text_off' => __( 'No', 'adminify' ), |
| 226 |
'text_width' => 80, |
| 227 |
]; |
| 228 |
|
| 229 |
$head_fields[] = [ |
| 230 |
'id' => 'remove_prev_next', |
| 231 |
'type' => 'switcher', |
| 232 |
'title' => __( 'Remove Prev/Next Links', 'adminify' ), |
| 233 |
'subtitle' => esc_html__( 'Remove "<link rel=\'prev\'..." and "<link rel=\'next\'..." from head section', 'adminify' ), |
| 234 |
'label' => 'This is links to the next and previous post that actually not used. You can remove it and keep your head section clean.', |
| 235 |
'text_on' => __( 'Yes', 'adminify' ), |
| 236 |
'text_off' => __( 'No', 'adminify' ), |
| 237 |
'text_width' => 80, |
| 238 |
]; |
| 239 |
|
| 240 |
$head_fields[] = [ |
| 241 |
'id' => 'remove_recentcomments', |
| 242 |
'type' => 'switcher', |
| 243 |
'title' => __( 'Remove Hardcoded Styles for Recent Comments', 'adminify' ), |
| 244 |
'subtitle' => __( 'Remove styles for ".recentcomments a" from head section', 'adminify' ), |
| 245 |
'label' => __( 'This is hard coded CSS for recent comments widget. You can remove it and keep your head section clean.', 'adminify' ), |
| 246 |
'text_on' => __( 'Yes', 'adminify' ), |
| 247 |
'text_off' => __( 'No', 'adminify' ), |
| 248 |
'text_width' => 80, |
| 249 |
]; |
| 250 |
|
| 251 |
$head_fields[] = [ |
| 252 |
'id' => 'disable_xmlrpc', |
| 253 |
'type' => 'switcher', |
| 254 |
'title' => __( 'Disable XML-RPC', 'adminify' ), |
| 255 |
'label' => __( 'Use for WordPress APP, Trackbacks and pingbacks and JetPack Plugin.', 'adminify' ), |
| 256 |
'text_on' => __( 'Yes', 'adminify' ), |
| 257 |
'text_off' => __( 'No', 'adminify' ), |
| 258 |
'text_width' => 80, |
| 259 |
]; |
| 260 |
} |
| 261 |
|
| 262 |
public function tweaks_head_settings() { |
| 263 |
if ( ! class_exists( 'ADMINIFY' ) ) { |
| 264 |
return; |
| 265 |
} |
| 266 |
|
| 267 |
$head_fields = []; |
| 268 |
$this->tweaks_head_fields( $head_fields ); |
| 269 |
|
| 270 |
\ADMINIFY::createSection( |
| 271 |
$this->prefix, |
| 272 |
[ |
| 273 |
'title' => __( 'Head', 'adminify' ), |
| 274 |
'parent' => 'tweaks_performance', |
| 275 |
'icon' => 'fas fa-newspaper', |
| 276 |
'class' => 'wp-adminify-two-columns aminify-title-width-40', |
| 277 |
'fields' => $head_fields, |
| 278 |
] |
| 279 |
); |
| 280 |
} |
| 281 |
} |
| 282 |
|