| 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_Performance extends AdminSettingsModel { |
| 13 |
|
| 14 |
public function __construct() { |
| 15 |
$this->tweaks_performance_settings(); |
| 16 |
} |
| 17 |
|
| 18 |
public function get_defaults() { |
| 19 |
return [ |
| 20 |
'remove_jquery_migrate' => false, |
| 21 |
'remove_gutenberg_scripts' => false, |
| 22 |
'defer_parsing_js_footer' => false, |
| 23 |
'cache_gzip_compression' => false, |
| 24 |
]; |
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
/** |
| 29 |
* Tweaks: Performance Fields |
| 30 |
* |
| 31 |
* @param [type] $performance_fields |
| 32 |
* |
| 33 |
* @return void |
| 34 |
*/ |
| 35 |
public function tweaks_performance_fields( &$performance_fields ) { |
| 36 |
$performance_fields[] = [ |
| 37 |
'type' => 'subheading', |
| 38 |
'content' => Utils::adminfiy_help_urls( |
| 39 |
__( 'Performance Section for speed up your website speed and other Configurations', 'adminify' ), |
| 40 |
'https://wpadminify.com/kb/wp-adminify-tweaks/', |
| 41 |
'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', |
| 42 |
'https://www.facebook.com/groups/jeweltheme', |
| 43 |
'https://wpadminify.com/support/' |
| 44 |
), |
| 45 |
]; |
| 46 |
|
| 47 |
$performance_fields[] = [ |
| 48 |
'id' => 'remove_jquery_migrate', |
| 49 |
'type' => 'switcher', |
| 50 |
'title' => esc_html__( 'Remove jQuery Migrate', 'adminify' ), |
| 51 |
'subtitle' => esc_html__( 'Enable if you want to remove jQuery Migrate Script', 'adminify' ), |
| 52 |
'text_on' => __( 'Yes', 'adminify' ), |
| 53 |
'text_off' => __( 'No', 'adminify' ), |
| 54 |
'text_width' => 80, |
| 55 |
'default' => $this->get_default_field( 'remove_jquery_migrate' ), |
| 56 |
]; |
| 57 |
|
| 58 |
$performance_fields[] = [ |
| 59 |
'id' => 'remove_gutenberg_scripts', |
| 60 |
'type' => 'switcher', |
| 61 |
'title' => esc_html__( 'Remove Gutenberg Scripts', 'adminify' ), |
| 62 |
'subtitle' => esc_html__( 'Remove Gutenberg Blocks Scripts/Styles', 'adminify' ), |
| 63 |
'text_on' => __( 'Yes', 'adminify' ), |
| 64 |
'text_off' => __( 'No', 'adminify' ), |
| 65 |
'text_width' => 80, |
| 66 |
'default' => $this->get_default_field( 'remove_gutenberg_scripts' ), |
| 67 |
]; |
| 68 |
|
| 69 |
$performance_fields[] = [ |
| 70 |
'id' => 'defer_parsing_js_footer', |
| 71 |
'type' => 'switcher', |
| 72 |
'title' => esc_html__( 'Enable Defer Parsing JS to Footer', 'adminify' ), |
| 73 |
'subtitle' => esc_html__( 'Secure method for Defer Parsing of JavaScript moving ALL JS from Header to Footer', 'adminify' ), |
| 74 |
'text_on' => __( 'Yes', 'adminify' ), |
| 75 |
'text_off' => __( 'No', 'adminify' ), |
| 76 |
'text_width' => 80, |
| 77 |
'default' => $this->get_default_field( 'defer_parsing_js_footer' ), |
| 78 |
]; |
| 79 |
|
| 80 |
$performance_fields[] = [ |
| 81 |
'id' => 'cache_gzip_compression', |
| 82 |
'type' => 'switcher', |
| 83 |
'title' => esc_html__( 'Cache & GZIP Compressions', 'adminify' ), |
| 84 |
'subtitle' => esc_html__( 'Browser Cache Expires & GZIP Compression', 'adminify' ), |
| 85 |
'text_on' => __( 'Yes', 'adminify' ), |
| 86 |
'text_off' => __( 'No', 'adminify' ), |
| 87 |
'text_width' => 80, |
| 88 |
'default' => $this->get_default_field( 'cache_gzip_compression' ), |
| 89 |
]; |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
public function tweaks_performance_settings() { |
| 95 |
if ( ! class_exists( 'ADMINIFY' ) ) { |
| 96 |
return; |
| 97 |
} |
| 98 |
|
| 99 |
$performance_fields = []; |
| 100 |
$this->tweaks_performance_fields( $performance_fields ); |
| 101 |
|
| 102 |
\ADMINIFY::createSection( |
| 103 |
$this->prefix, |
| 104 |
[ |
| 105 |
'title' => __( 'Performance', 'adminify' ), |
| 106 |
'parent' => 'tweaks_performance', |
| 107 |
'icon' => 'fas fa-rocket', |
| 108 |
'fields' => $performance_fields, |
| 109 |
] |
| 110 |
); |
| 111 |
} |
| 112 |
} |
| 113 |
|