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