| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace RenzoJohnson\Blocks\Settings\Tabs; |
| 6 |
|
| 7 |
use RenzoJohnson\Blocks\Settings\FieldDefinition; |
| 8 |
use RenzoJohnson\Blocks\Settings\FieldType; |
| 9 |
use RenzoJohnson\Blocks\Settings\Requirement; |
| 10 |
use RenzoJohnson\Blocks\Settings\SanitizerType; |
| 11 |
use RenzoJohnson\Blocks\Settings\SectionDefinition; |
| 12 |
use RenzoJohnson\Blocks\Settings\SettingDefinition; |
| 13 |
use RenzoJohnson\Blocks\Settings\TabDefinition; |
| 14 |
use RenzoJohnson\Blocks\Settings\TabProvider; |
| 15 |
|
| 16 |
\defined( 'ABSPATH' ) || exit; |
| 17 |
|
| 18 |
final class PerformanceTab implements TabProvider { |
| 19 |
|
| 20 |
public function definition(): TabDefinition { |
| 21 |
return new TabDefinition( |
| 22 |
'performance', |
| 23 |
\__( 'Performance', 'blocks' ), |
| 24 |
array( |
| 25 |
new SectionDefinition( |
| 26 |
'blocks_performance_section', |
| 27 |
\__( 'Performance', 'blocks' ), |
| 28 |
array( |
| 29 |
\__( 'Remove unnecessary CSS, JS, and editor bloat from the frontend.', 'blocks' ), |
| 30 |
), |
| 31 |
array( |
| 32 |
new FieldDefinition( |
| 33 |
'blocks_perf_disable_gutenberg', |
| 34 |
\__( 'Disable Block Editor', 'blocks' ), |
| 35 |
\__( 'Force the classic editor for all post types.', 'blocks' ), |
| 36 |
FieldType::Checkbox, |
| 37 |
array( |
| 38 |
new SettingDefinition( 'blocks_perf_disable_gutenberg', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 39 |
), |
| 40 |
array(), |
| 41 |
Requirement::Always, |
| 42 |
), |
| 43 |
new FieldDefinition( |
| 44 |
'blocks_perf_remove_global_styles', |
| 45 |
\__( 'Remove Global Styles', 'blocks' ), |
| 46 |
\__( 'Remove Gutenberg global styles, SVG filters, and layout support.', 'blocks' ), |
| 47 |
FieldType::Checkbox, |
| 48 |
array( |
| 49 |
new SettingDefinition( 'blocks_perf_remove_global_styles', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 50 |
), |
| 51 |
array(), |
| 52 |
Requirement::Always, |
| 53 |
), |
| 54 |
new FieldDefinition( |
| 55 |
'blocks_perf_remove_jquery_migrate', |
| 56 |
\__( 'Remove jQuery Migrate', 'blocks' ), |
| 57 |
\__( 'Deregister jQuery Migrate on the frontend.', 'blocks' ), |
| 58 |
FieldType::Checkbox, |
| 59 |
array( |
| 60 |
new SettingDefinition( 'blocks_perf_remove_jquery_migrate', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 61 |
), |
| 62 |
array(), |
| 63 |
Requirement::Always, |
| 64 |
), |
| 65 |
new FieldDefinition( |
| 66 |
'blocks_perf_dequeue_block_css', |
| 67 |
\__( 'Dequeue Block Library CSS', 'blocks' ), |
| 68 |
\__( 'Remove wp-block-library styles on the homepage.', 'blocks' ), |
| 69 |
FieldType::Checkbox, |
| 70 |
array( |
| 71 |
new SettingDefinition( 'blocks_perf_dequeue_block_css', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 72 |
), |
| 73 |
array(), |
| 74 |
Requirement::Always, |
| 75 |
), |
| 76 |
new FieldDefinition( |
| 77 |
'blocks_perf_dequeue_woo_css', |
| 78 |
\__( 'Dequeue WooCommerce CSS', 'blocks' ), |
| 79 |
\__( 'Remove WooCommerce layout, general, and smallscreen CSS on homepage.', 'blocks' ), |
| 80 |
FieldType::Checkbox, |
| 81 |
array( |
| 82 |
new SettingDefinition( 'blocks_perf_dequeue_woo_css', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 83 |
), |
| 84 |
array(), |
| 85 |
Requirement::Always, |
| 86 |
), |
| 87 |
new FieldDefinition( |
| 88 |
'blocks_perf_dequeue_woo_block_css', |
| 89 |
\__( 'Dequeue WooCommerce Block CSS', 'blocks' ), |
| 90 |
\__( 'Remove WooCommerce block styles and vendors CSS on homepage.', 'blocks' ), |
| 91 |
FieldType::Checkbox, |
| 92 |
array( |
| 93 |
new SettingDefinition( 'blocks_perf_dequeue_woo_block_css', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 94 |
), |
| 95 |
array(), |
| 96 |
Requirement::Always, |
| 97 |
), |
| 98 |
new FieldDefinition( |
| 99 |
'blocks_perf_dequeue_cart_fragments', |
| 100 |
\__( 'Dequeue Cart Fragments', 'blocks' ), |
| 101 |
\__( 'Disable WooCommerce AJAX cart fragment loading on homepage.', 'blocks' ), |
| 102 |
FieldType::Checkbox, |
| 103 |
array( |
| 104 |
new SettingDefinition( 'blocks_perf_dequeue_cart_fragments', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 105 |
), |
| 106 |
array(), |
| 107 |
Requirement::Always, |
| 108 |
), |
| 109 |
new FieldDefinition( |
| 110 |
'blocks_perf_dequeue_stripe_css', |
| 111 |
\__( 'Dequeue Stripe Checkout CSS', 'blocks' ), |
| 112 |
\__( 'Remove Stripe payment gateway CSS on homepage.', 'blocks' ), |
| 113 |
FieldType::Checkbox, |
| 114 |
array( |
| 115 |
new SettingDefinition( 'blocks_perf_dequeue_stripe_css', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 116 |
), |
| 117 |
array(), |
| 118 |
Requirement::Always, |
| 119 |
), |
| 120 |
new FieldDefinition( |
| 121 |
'blocks_perf_disable_emoji', |
| 122 |
\__( 'Disable WP Emoji', 'blocks' ), |
| 123 |
\__( 'Remove WordPress emoji scripts and styles sitewide.', 'blocks' ), |
| 124 |
FieldType::Checkbox, |
| 125 |
array( |
| 126 |
new SettingDefinition( 'blocks_perf_disable_emoji', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 127 |
), |
| 128 |
array(), |
| 129 |
Requirement::Always, |
| 130 |
), |
| 131 |
new FieldDefinition( |
| 132 |
'blocks_perf_dequeue_classic_theme_styles', |
| 133 |
\__( 'Dequeue Classic Theme Styles', 'blocks' ), |
| 134 |
\__( 'Remove block editor classic theme inline styles on homepage.', 'blocks' ), |
| 135 |
FieldType::Checkbox, |
| 136 |
array( |
| 137 |
new SettingDefinition( 'blocks_perf_dequeue_classic_theme_styles', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 138 |
), |
| 139 |
array(), |
| 140 |
Requirement::Always, |
| 141 |
), |
| 142 |
new FieldDefinition( |
| 143 |
'blocks_perf_dequeue_img_auto_sizes', |
| 144 |
\__( 'Dequeue Image Auto Sizes CSS', 'blocks' ), |
| 145 |
\__( 'Remove wp-img-auto-sizes-contain inline CSS sitewide.', 'blocks' ), |
| 146 |
FieldType::Checkbox, |
| 147 |
array( |
| 148 |
new SettingDefinition( 'blocks_perf_dequeue_img_auto_sizes', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 149 |
), |
| 150 |
array(), |
| 151 |
Requirement::Always, |
| 152 |
), |
| 153 |
new FieldDefinition( |
| 154 |
'blocks_perf_dequeue_woo_inline_css', |
| 155 |
\__( 'Dequeue WooCommerce Inline CSS', 'blocks' ), |
| 156 |
\__( 'Remove WooCommerce inline CSS on the homepage.', 'blocks' ), |
| 157 |
FieldType::Checkbox, |
| 158 |
array( |
| 159 |
new SettingDefinition( 'blocks_perf_dequeue_woo_inline_css', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 160 |
), |
| 161 |
array(), |
| 162 |
Requirement::Always, |
| 163 |
), |
| 164 |
new FieldDefinition( |
| 165 |
'blocks_perf_dequeue_woo_noscript', |
| 166 |
\__( 'Dequeue WooCommerce Gallery/NoJS', 'blocks' ), |
| 167 |
\__( 'Remove WooCommerce gallery noscript styles and no-js class swap script on the homepage.', 'blocks' ), |
| 168 |
FieldType::Checkbox, |
| 169 |
array( |
| 170 |
new SettingDefinition( 'blocks_perf_dequeue_woo_noscript', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 171 |
), |
| 172 |
array(), |
| 173 |
Requirement::Always, |
| 174 |
), |
| 175 |
new FieldDefinition( |
| 176 |
'blocks_perf_dequeue_apfs', |
| 177 |
\__( 'Dequeue Subscribe & Save (APFS) Assets', 'blocks' ), |
| 178 |
\__( 'Remove WooCommerce Subscriptions wcsatt-frontend / wcsatt-css from all pages except product/cart/checkout. Safe when no product uses "Subscribe & Save".', 'blocks' ), |
| 179 |
FieldType::Checkbox, |
| 180 |
array( |
| 181 |
new SettingDefinition( 'blocks_perf_dequeue_apfs', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 182 |
), |
| 183 |
array(), |
| 184 |
Requirement::Always, |
| 185 |
), |
| 186 |
new FieldDefinition( |
| 187 |
'blocks_perf_disable_speculation_rules', |
| 188 |
\__( 'Disable Speculation Rules', 'blocks' ), |
| 189 |
\__( 'Disable WordPress speculation rules (prefetch/prerender) sitewide.', 'blocks' ), |
| 190 |
FieldType::Checkbox, |
| 191 |
array( |
| 192 |
new SettingDefinition( 'blocks_perf_disable_speculation_rules', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 193 |
), |
| 194 |
array(), |
| 195 |
Requirement::Always, |
| 196 |
), |
| 197 |
new FieldDefinition( |
| 198 |
'blocks_perf_delay_analytics', |
| 199 |
\__( 'Delay Analytics Script', 'blocks' ), |
| 200 |
\__( 'Load Google Analytics (gtag.js) after first user interaction or shortly after page load. Events fired earlier are queued and replayed.', 'blocks' ), |
| 201 |
FieldType::Checkbox, |
| 202 |
array( |
| 203 |
new SettingDefinition( 'blocks_perf_delay_analytics', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 204 |
), |
| 205 |
array(), |
| 206 |
Requirement::Always, |
| 207 |
), |
| 208 |
), |
| 209 |
false, |
| 210 |
), |
| 211 |
new SectionDefinition( |
| 212 |
'blocks_javascript_minification_section', |
| 213 |
\__( 'JavaScript Minification', 'blocks' ), |
| 214 |
array( |
| 215 |
\__( 'Cache minified copies of selected local registered JavaScript while preserving WordPress handle metadata. Remote scripts are never fetched.', 'blocks' ), |
| 216 |
), |
| 217 |
array( |
| 218 |
new FieldDefinition( |
| 219 |
'blocks_perf_minify_js', |
| 220 |
\__( 'Minify JavaScript', 'blocks' ), |
| 221 |
\__( 'Minify the built-in Blocks JavaScript handles on the frontend.', 'blocks' ), |
| 222 |
FieldType::Checkbox, |
| 223 |
array( |
| 224 |
new SettingDefinition( 'blocks_perf_minify_js', 'boolean', false, SanitizerType::Boolean, sensitive: false, exportable: true, public_token: null ), |
| 225 |
), |
| 226 |
array(), |
| 227 |
Requirement::Always, |
| 228 |
), |
| 229 |
new FieldDefinition( |
| 230 |
'blocks_perf_minify_js_handles', |
| 231 |
\__( 'Additional Script Handles', 'blocks' ), |
| 232 |
\__( 'One local WordPress handle per line. Blocks handles are automatic. Chimpmatic can use spartan. URLs and paths are rejected.', 'blocks' ), |
| 233 |
FieldType::Textarea, |
| 234 |
array( |
| 235 |
new SettingDefinition( 'blocks_perf_minify_js_handles', 'string', '', SanitizerType::ScriptHandleList, sensitive: false, exportable: true, public_token: null ), |
| 236 |
), |
| 237 |
array(), |
| 238 |
Requirement::Always, |
| 239 |
), |
| 240 |
), |
| 241 |
false, |
| 242 |
), |
| 243 |
new SectionDefinition( |
| 244 |
'blocks_resource_hints_section', |
| 245 |
\__( 'Resource Hints', 'blocks' ), |
| 246 |
array( |
| 247 |
\__( 'Tell the browser to start the DNS + TCP + TLS handshake with third-party origins before they are needed. Useful for analytics, payment SDKs, or CDN-hosted CSS that the page loads on every request.', 'blocks' ), |
| 248 |
), |
| 249 |
array( |
| 250 |
new FieldDefinition( |
| 251 |
'blocks_perf_preconnect_origins', |
| 252 |
\__( 'Preconnect Origins', 'blocks' ), |
| 253 |
\__( 'One origin per line. Use https://host (no path). Empty = no hints. Browsers will silently ignore origins not allowed by your CSP connect-src.', 'blocks' ), |
| 254 |
FieldType::Textarea, |
| 255 |
array( |
| 256 |
new SettingDefinition( 'blocks_perf_preconnect_origins', 'string', '', SanitizerType::Textarea, sensitive: false, exportable: true, public_token: null ), |
| 257 |
), |
| 258 |
array(), |
| 259 |
Requirement::Always, |
| 260 |
), |
| 261 |
), |
| 262 |
false, |
| 263 |
), |
| 264 |
), |
| 265 |
Requirement::Always, |
| 266 |
); |
| 267 |
} |
| 268 |
} |
| 269 |
|