'; self::dashboard_tab(); echo '
'; self::cache_tab(); echo '
'; self::file_tab(); echo '
'; self::preload_tab(); echo '
'; self::media_tab(); echo '
'; self::excludes_tab(); echo '
'; self::cdn_tab(); echo '
'; do_action('speedycache_image_optm_tmpl'); if(!defined('SPEEDYCACHE_PRO') || (defined('SPEEDYCACHE_PRO_VERSION') && version_compare(SPEEDYCACHE_PRO_VERSION, '1.2.0', '<'))){ self::pro_notice('Image Optimization'); } echo '
'; do_action('speedycache_object_cache_tmpl'); if(!defined('SPEEDYCACHE_PRO') || (defined('SPEEDYCACHE_PRO_VERSION') && version_compare(SPEEDYCACHE_PRO_VERSION, '1.2.0', '<'))){ self::pro_notice('Object Cache'); } echo '
'; do_action('speedycache_bloat_tmpl'); if(!defined('SPEEDYCACHE_PRO') || (defined('SPEEDYCACHE_PRO_VERSION') && version_compare(SPEEDYCACHE_PRO_VERSION, '1.2.0', '<'))){ self::pro_notice('Bloat Settings'); } echo '
'; do_action('speedycache_db_tmpl'); if(!defined('SPEEDYCACHE_PRO') || (defined('SPEEDYCACHE_PRO_VERSION') && version_compare(SPEEDYCACHE_PRO_VERSION, '1.2.0', '<'))){ self::pro_notice('DB Optimization'); } echo '
'; do_action('speedycache_license_tmpl'); echo '

Support

'.esc_html__('If you are facing any issue contact us, our team will help you', 'speedycache').'

Check the Docs Contact Support
'; } static function dashboard_tab(){ global $speedycache; $speed_results = get_option('speedycache_pagespeed_test', []); $speed_score = 0; $speed_colors = ['#0c6', '#00cc663b', '#080']; if(!empty($speed_results)){ $speed_colors = Util::pagespeed_color($speed_results['score']); $speed_score = $speed_results['score']; } $speedycache->object_memory = 'None'; if(!empty($speedycache->object['enable']) && class_exists('Redis') && class_exists('\SpeedyCache\ObjectCache')){ try{ $speedycache->object_memory = \SpeedyCache\ObjectCache::get_memory(); } catch(\Exception $e) { $memory = 'None'; } } $license_expires = ''; if(defined('SPEEDYCACHE_PRO') && !empty($speedycache->license['expires'])){ $license_expires = $speedycache->license['expires']; $license_expires = substr($license_expires, 0, 4).'/'.substr($license_expires, 4, 2).'/'.substr($license_expires, 6); } echo '

Dashboard

Performance Score [Analyze]

'.esc_html($speed_score).'
0-49
50-89
90-100

License

Version: '.esc_html(SPEEDYCACHE_VERSION).' Status: '.(!defined('SPEEDYCACHE_PRO') ? 'Free' : (!empty($speedycache->license) && defined('SPEEDYCACHE_PRO') ? 'Pro' : 'License not Linked')).' Expires on: '.(!defined('SPEEDYCACHE_PRO') ? 'Never' : (!empty($speedycache->license) && !empty($license_expires) ? esc_html($license_expires) : '')).'

Cache Info

File Cache: '.(!empty($speedycache->options['status']) ? esc_html__('Enabled') : esc_html__('Disabled')).' Object Cache: '.(!empty($speedycache->object['enable']) ? esc_html__('Enabled') : esc_html__('Disabled')).' CDN: '.(!empty($speedycache->cdn) && !empty($speedycache->cdn['cdn_type']) ? esc_html(ucfirst($speedycache->cdn['cdn_type'])) : 'OFF').'
'; // TODO: Need to add this stats code in the Pro version. if(defined('SPEEDYCACHE_PRO')){ do_action('speedycache_pro_stats_tmpl'); } echo '

Manage Cache

'; wp_nonce_field('speedycache_post_nonce'); echo '
'.esc_html__('Delete Minified', 'speedycache').' '.esc_html__('Deletes Minfied/ Combined CSS/JS files', 'speedycache').'
'; if(defined('SPEEDYCACHE_PRO')){ echo '
'.esc_html__('Delete Fonts', 'speedycache').' '.esc_html__('Deletes Local Google Fonts', 'speedycache').'
'; } echo '
'.esc_html__('Delete Gravatars', 'speedycache').' '.esc_html__('Delete locally hosted Gravatars.', 'speedycache').'
'.esc_html__('Preload Cache', 'speedycache').' '.esc_html__('After cache gets deleted, it restarts auto cache generation.', 'speedycache').'
'; if(defined('SPEEDYCACHE_PRO')){ do_action('speedycache_pro_logs_tmpl'); } } static function cache_tab(){ global $speedycache; echo '

Cache Settings

'; wp_nonce_field('speedycache_ajax_nonce'); echo '
'.esc_html__('Enable Cache', 'speedycache').' '.esc_html__('Enables caching', 'speedycache').'
'.esc_html__('Mobile Override', 'speedycache').' '.esc_html__('Disable desktop cache display on mobile devices.', 'speedycache').'
'; if(defined('SPEEDYCACHE_PRO')){ echo '
'.esc_html__('Mobile Cache', 'speedycache').' '.esc_html__('Separate cache for Mobile version of your website, modern themes don\'t require this', 'speedycache').'
'; } else { echo '
'.esc_html__('Mobile Cache', 'speedycache').''.esc_html__('Premium', 'speedycache').' '.esc_html__('Separate cache for Mobile version of your website, modern themes don\'t require this', 'speedycache').'
'; } echo '
'.esc_html__('Preload', 'speedycache').' - Settings '.esc_html__('Create the cache of all the site automatically', 'speedycache').'
'.esc_html__('Preload Settings', 'speedycache').'

'.esc_html__('Select the interval after which you want the preload to run', 'speedycache').'

'.esc_html__('Browser Caching', 'speedycache').' '.esc_html__('Stores web data locally for faster loading.', 'speedycache').'
'.esc_html__('Logged-in Users', 'speedycache').' '.esc_html__('Serve cached version to logged in user.', 'speedycache').'
'.esc_html__('GZIP Compressions', 'speedycache').' '.esc_html__('Compresses the text files to reduce the size to be sent on the network.', 'speedycache').'
'.esc_html__('Purge Varnish', 'speedycache').' - Settings '.esc_html__('Deletes cache created by Varnish on Deletion of cache from SpeedyCache', 'speedycache').'
'.esc_html__('Varnish Settings', 'speedycache').'

'.esc_html__('If you use any different IP for Varnish than the default then set it here.', 'speedycache').'

'.esc_html__('Cache Lifespan', 'speedycache').'

'.esc_html__('This defines the time after which the cache will be automatically deleted. Set to 0 to disable automatic cache deletion.', 'speedycache').'

options['purge_enable_exact_time']) ? checked($speedycache->options['purge_enable_exact_time'], true, false) : '').'/>'.esc_html__('Run at exact time', 'speedycache').'

'.esc_html__('This is dependent on WP Cron, which does not guarantee execution at an exact time. For more details, ', 'speedycache').'click here

options['auto_purge_fonts']) ? checked($speedycache->options['auto_purge_fonts'], true, false) : '').'/>'.esc_html__('Delete Fonts', 'speedycache').' options['auto_purge_gravatar']) ? checked($speedycache->options['auto_purge_gravatar'], true, false) : '').'/>'.esc_html__( 'Delete Gravatar', 'speedycache').'

'.esc_html__('Deletion of these options only takes effect if the lifespan is more than 10 hours.', 'speedycache').'

'; self::save_btn(); echo '
'; } static function file_tab(){ global $speedycache; echo '

File Optimization

'; wp_nonce_field('speedycache_ajax_nonce'); echo ''; if(defined('SPEEDYCACHE_PRO')){ echo '
'.esc_html__('Minify HTML', 'speedycache').' '.esc_html__('Removes comments, extra spaces', 'speedycache').'
'; } else { echo '
'.esc_html__('Minify HTML', 'speedycache').''.esc_html__('Premium', 'speedycache').' '.esc_html__('Removes comments, extra spaces', 'speedycache').'
'; } echo '
'.esc_html__('Minify CSS', 'speedycache').' '.esc_html__('You can decrease the size of CSS files', 'speedycache').'
'.esc_html__('Combine CSS', 'speedycache').' '.esc_html__('Combines CSS files to reduce HTTP requests', 'speedycache').'
'; // Critical CSS Option if(defined('SPEEDYCACHE_PRO') && !empty($speedycache->license) && !empty($speedycache->license['active'])){ echo '
'.esc_html__('Critical CSS', 'speedycache'); if(!empty($speedycache->options['critical_css'])){ echo ' - '.esc_html__('Create Now', 'speedycache').'   |   '.esc_html__('Logs', 'speedycache').''; } echo ''.esc_html__('It extracts the necessary CSS of the viewport on load to improve load speed.', 'speedycache').'
'; echo wp_kses(\SpeedyCache\CriticalCss::status_modal(), array_merge(wp_kses_allowed_html('post'), [ 'div' => [ 'modal-id' => true, 'class' => true, 'title' => true, 'style' => true, ] ])); } else { if(empty($speedycache->license) || empty($speedycache->license['active'])){ $need_key = true; } echo '
'.esc_html__('Critical CSS', 'speedycache').' '.(!empty($need_key) ? 'Link License Key' : 'Premium').' '.esc_html__('It extracts the necessary CSS of the viewport on load to improve load speed.', 'speedycache').'
'; } // Unused CSS if(defined('SPEEDYCACHE_PRO') && !empty($speedycache->license) && !empty($speedycache->license['active'])){ echo '
'.esc_html__('Unused CSS', 'speedycache').' - Settings '.esc_html__('It removes the unused CSS.', 'speedycache').'
'.esc_html__('Unused CSS Settings', 'speedycache').'

'.esc_html__('Extracts the CSS being used on the page.', 'speedycache').'

options['unusedcss_load']) || (!empty($speedycache->options['unusedcss_load']) && $speedycache->options['unusedcss_load'] == 'async') ? 'checked' : '').'/> options['unusedcss_load']) && $speedycache->options['unusedcss_load'] == 'interaction' ? 'checked' : '').'/> options['unusedcss_load']) && $speedycache->options['unusedcss_load'] == 'remove' ? 'checked' : '').'/>


'; } else { echo '
'.esc_html__('Unused CSS', 'speedycache').''.(!empty($need_key) ? 'Link License Key' : 'Premium').' '.esc_html__('It removes the unused CSS from the page.', 'speedycache').'
'; } if(defined('SPEEDYCACHE_PRO')){ echo '
'.esc_html__('Minify JS', 'speedycache').' '.esc_html__('You can decrease the size of JS files', 'speedycache').'
'; } else { echo '
'.esc_html__('Minify JS', 'speedycache').'Premium '.esc_html__('You can decrease the size of JS files', 'speedycache').'
'; } echo '
'.esc_html__('Combine JS', 'speedycache').' '.esc_html__('Reduce HTTP requests by Combining JS files', 'speedycache').'
'; // Delay JS option if(defined('SPEEDYCACHE_PRO')){ echo '
'.esc_html__('Delay JS', 'speedycache').' - Settings '.esc_html__('Delays JS until user interaction(like scroll, click etc) to improve performance', 'speedycache').'
'.esc_html__('Delay JS', 'speedycache').'

'.esc_html__('Delay All is a more aggressive option which can increase the chances of breaking the site too.', 'speedycache').'

options['delay_js_mode']) || (!empty($speedycache->options['delay_js_mode']) && $speedycache->options['delay_js_mode'] == 'selected') ? 'checked' : '').'/> options['delay_js_mode']) && $speedycache->options['delay_js_mode'] == 'all' ? 'checked' : '').'/>
'; }else{ echo '
'.esc_html__('Delay JS', 'speedycache').'Premium '.esc_html__('Delays JS until user interaction(like scroll, click etc) to improve performance', 'speedycache').'
'; } if(defined('SPEEDYCACHE_PRO')){ echo '
'.esc_html__('Defer JS', 'speedycache').' - Settings '.esc_html__('Defers render-blocking JavaScript resources', 'speedycache').'
'.esc_html__('Defer JS', 'speedycache').'
'; } else { echo '
'.esc_html__('Defer JS', 'speedycache').''.esc_html__('Premium', 'speedycache').' '.esc_html__('Defers render-blocking JavaScript resources', 'speedycache').'
'; } echo '
'.esc_html__('Disable Emojis', 'speedycache').' '.esc_html__('You can remove the emoji inline css and wp-emoji-release.min.js', 'speedycache').'
'; // Lazy Render HTML element if(defined('SPEEDYCACHE_PRO')){ echo '
'.esc_html__('Lazy Render HTML Element', 'speedycache').' - Settings '.esc_html__('Lazy Render a HTML element(class or id) if not in view-port.', 'speedycache').'
'.esc_html__('Lazy Render HTML Elements', 'speedycache').'

'.esc_html__('Lazy Rendering HTML is usually good for Comments.', 'speedycache').'

'; }else{ echo '
'.esc_html__('Lazy Render HTML Element', 'speedycache').''.esc_html__('Premium', 'speedycache').' '.esc_html__('Lazy Render a HTML element(class or id) if not in view-port.', 'speedycache').'
'; } self::save_btn(); echo '
'; } static function preload_tab(){ global $speedycache; echo '

Preload Settings

'; wp_nonce_field('speedycache_ajax_nonce'); echo ''; if(defined('SPEEDYCACHE_PRO')){ echo '
'.esc_html__('Preload Critical Images', 'speedycache').' - Settings '.esc_html__('Preloads critical Images to improve LCP', 'speedycache').'
'.esc_html__('Preload Critical Images', 'speedycache').'

'.esc_html__('Select the number of images you want to be preloaded.', 'speedycache').'

'.esc_html__('Critical Image Count', 'speedycache').'
'; } else { echo '
'.esc_html__('Preload Critical Images', 'speedycache').''.esc_html__('Premium', 'speedycache').' '.esc_html__('Preloads critical Images to improve LCP', 'speedycache').'
'; } if(defined('SPEEDYCACHE_PRO')){ echo '
'.esc_html__('Instant Page', 'speedycache').' '.esc_html__('Improves page load speed', 'speedycache').'
'; } else { echo '
'.esc_html__('Instant Page', 'speedycache').''.esc_html__('Premium', 'speedycache').' '.esc_html__('Improves page load speed', 'speedycache').'
'; } echo '
'.esc_html__('DNS Prefetch', 'speedycache').' - Settings '.esc_html__('DNS prefetching can make external files load faster.', 'speedycache').'
'.esc_html__('Prefetch DNS Requests', 'speedycache').'

'.esc_html__('How DNS Prefetch can help?', 'speedycache').'

'.esc_html__('DNS prefetch can improve page load performance by resolving domain names in advance, so that the browser can start loading resources from those domains as soon as possible.', 'speedycache').'

'; if(defined('SPEEDYCACHE_PRO')){ echo '
'.esc_html__('Preload Resources', 'speedycache').' - Settings '.esc_html__('Hints browser to load resources early.', 'speedycache').'
'; } else { echo '
'. esc_html__('Preload Resources', 'speedycache').''.esc_html__('Premium', 'speedycache').' '. esc_html__('Hints browser to load resources early.', 'speedycache').'
'; } if(defined('SPEEDYCACHE_PRO')){ echo '
'. esc_html__('PreConnect', 'speedycache').' - Settings '.esc_html__('Establish early connections to speed up page load.', 'speedycache').'
'; } else { echo '
'. esc_html__('Preconnect', 'speedycache') .''.esc_html__('Premium', 'speedycache').' '. esc_html__('Establish early connections to speed up page load.', 'speedycache').'
'; } self::save_btn(); echo '
'; if(defined('SPEEDYCACHE_PRO')){ echo '
'.esc_html__('Preload Resource', 'speedycache').'
'. wp_kses(self::preload_modal_options('preload_resource', ['type' => true, 'crossorigin' => true]), [ 'input' => ['type' => true, 'value' => true, 'style' => true, 'name' => true, 'placeholder' => true], 'option' => ['value' => true], 'select' => ['name' => true, 'required' => true], 'label' => ['for' => true], 'div' => ['class' => true], 'span' => true, ]).'
'; if(!empty($speedycache->options['preload_resource_list']) && count($speedycache->options['preload_resource_list']) > 7){ echo '

Note: Preloading too many resources can actually slow down your website, so it\'s important to only preload the resources that are absolutely necessary for the initial load. These might include fonts, image, CSS or JS files.

'; } echo ''; if(empty($speedycache->options['preload_resource_list']) || !is_array($speedycache->options['preload_resource_list'])){ echo ''; } else { foreach($speedycache->options['preload_resource_list'] as $pkey => $preload_resource){ echo ''; } } echo '
'.esc_html__('Resource', 'speedycache').' '. esc_html__('Type', 'speedycache').' '. esc_html__('CS', 'speedycache').'
No Resource Preload added yet
'.esc_url($preload_resource['resource']).' '.esc_html($preload_resource['type']).' '.(!empty($preload_resource['crossorigin']) ? 'Yes' : 'No').'
'. esc_html__('Preconnect', 'speedycache').'
'.wp_kses(self::preload_modal_options('pre_connect', ['crossorigin' => true]), [ 'input' => ['type' => true, 'value' => true, 'style' => true, 'name' => true, 'placeholder' => true], 'option' => ['value' => true], 'select' => ['name' => true, 'required' => true], 'label' => ['for' => true], 'div' => ['class' => true], 'span' => true, ]).'
'; if(!empty($speedycache->options['pre_connect_list']) && count($speedycache->options['pre_connect_list']) > 6){ echo '

Note: A good rule of thumb is to limit the number of preconnects to 6-8. However, the exact number will vary depending on the specific website and the resources that are being loaded.

'; } echo ''; if(empty($speedycache->options['pre_connect_list']) || !is_array($speedycache->options['pre_connect_list'])){ echo ''; } else { foreach($speedycache->options['pre_connect_list'] as $pkey => $pre_connect){ echo ''; } } echo '
'.esc_html__('Resource', 'speedycache').' '. esc_html__('Crossorigin', 'speedycache').'
'.esc_html__('No PreConnect added yet', 'speedycache').'
'.esc_html($pre_connect['resource']).' '.(!empty($pre_connect['crossorigin']) ? 'Yes' : 'No').'
'; } } static function cdn_tab(){ global $speedycache; $default_file_types = ['aac', 'css', 'eot', 'gif', 'jpeg', 'js', 'jpg', 'less', 'mp3', 'mp4', 'ogg', 'otf', 'pdf', 'png', 'svg', 'swf', 'ttf', 'webm', 'webp', 'woff', 'woff2']; echo '

CDN Settings

'; wp_nonce_field('speedycache_ajax_nonce'); echo '
'.esc_html__('Enable CDN', 'speedycache').' '.esc_html__('This will start rewriting asset URL\'s to the CDN URL', 'speedycache').'
'.esc_html__('It is the URL that CDN Provider provides you.', 'speedycache').'
'.esc_html__('API keys/ tokens are not required but used to purge cache on CDN when cache from SpeedyCache gets purged.', 'speedycache').'
'.esc_html__('Types of files you want to be served through the CDN(one file per line)', 'speedycache').'
'.esc_html__('Files you do not want to be rewritten to a CDN url(one file per line).', 'speedycache').'
'.esc_html__('Specific files which you want to be rewritten using CDN URL(one file per line).', 'speedycache').'
'; self::save_btn(); echo '
'; } static function excludes_tab(){ $excludes = get_option('speedycache_exclude', []); echo '

Exclude Settings

'; if(empty($excludes)){ echo ''; } else { foreach($excludes as $id => $exclude){ echo ''; if($exclude['prefix'] == 'post_id'){ if(!is_array($exclude['content'])){ $exclude['content'] = explode(',', $exclude['content']); } echo ''; } else{ echo''; } echo''; } } echo '
Type Prefix Content Actions
'.esc_html__('No exclude rule added yet','speedycache').'
'.esc_html($exclude['type']).' '.esc_html($exclude['prefix']).''.'#ID:'; foreach($exclude['content'] as $exclude){ $post = get_post($exclude); if(empty($post) || is_wp_error($post)){ continue; } $post_link = get_permalink($post->ID); echo ''.esc_html($exclude); // We show a tool tip with the excluded page URL and title echo ''; } echo ''.esc_html($exclude['content']).'
'.esc_html__('Add Exclude Rule', 'speedycache').'
'; wp_nonce_field('speedycache_ajax_nonce'); echo '
'; } static function media_tab(){ global $speedycache; // Backward compatibility if(!empty($speedycache->options['lazy_load_keywords']) && is_string($speedycache->options['lazy_load_keywords'])){ $speedycache->options['lazy_load_keywords'] = explode(',', $speedycache->options['lazy_load_keywords']); } echo '

Media Settings

'; wp_nonce_field('speedycache_ajax_nonce'); echo '
'.esc_html__('Gravatar Cache', 'speedycache').' '.esc_html__('Locally host Gravatar', 'speedycache').'
'; if(defined('SPEEDYCACHE_PRO')){ echo '
options['lazy_load_exclude_full_size_img']) ? esc_attr($speedycache->options['lazy_load_exclude_full_size_img']) : '').' id="speedycache_lazy_load_exclude_full_size_img" name="lazy_load_exclude_full_size_img">
'.esc_html__('Lazy Load', 'speedycache').' - Settings '.esc_html__('Load images and iframes when they enter the browsers viewport', 'speedycache').'
'.esc_html__('Lazy Load Settings', 'speedycache').'

'.esc_html__('Image Placeholder', 'speedycache').'

'.esc_html__('Specify an image to be used as a placeholder while other images finish loading.', 'speedycache').'

'; $hide_css_class = ''; if(isset($speedycache->options['lazy_load_placeholder']) && $speedycache->options['lazy_load_placeholder'] != 'custom'){ $hide_css_class = 'speedycache-hidden '; } echo '

'.esc_html__('Exclude above fold images', 'speedycache').'

'.esc_html__('Number of images you want to exclude from getting lazyloaded from top of the screen', 'speedycache').'

'.esc_html__('Exclude Sources', 'speedycache').'

'.esc_html__('It is enough to write a keyword such as', 'speedycache').' home.jpg or iframe or .gif instead of full url.

'; echo '
'; } else { echo '
'.esc_html__('Lazy Load', 'speedycache').''.esc_html__('Premium', 'speedycache').' '.esc_html__('Load images and iframes when they enter the browsers viewport', 'speedycache').'
'; } if(defined('SPEEDYCACHE_PRO')){ echo '
'.esc_html__('Image Dimensions', 'speedycache').' '.esc_html__('Adds dimensions to the image, to reduce CLS', 'speedycache').'
'; } else { echo '
'.esc_html__('Image Dimensions', 'speedycache').''. esc_html__('Premium', 'speedycache').' '.esc_html__('Adds dimensions to the image, to reduce CLS', 'speedycache').'
'; } if(defined('SPEEDYCACHE_PRO')){ echo '
'.esc_html__('Local Google Fonts', 'speedycache').' '.esc_html__('Loads google fonts from your local server', 'speedycache').'
'; } else { echo '
'.esc_html__('Local Google Fonts', 'speedycache').''.esc_html__('Premium', 'speedycache').' '.esc_html__('Loads google fonts from your local server', 'speedycache').'
'; } if(defined('SPEEDYCACHE_PRO')){ echo '
'.esc_html__('Google Fonts', 'speedycache').' '.esc_html__('Load Google Fonts asynchronously', 'speedycache').'
'; } else { echo '
'.esc_html__('Google Fonts', 'speedycache').''.esc_html__('Premium', 'speedycache').' '.esc_html__('Load Google Fonts asynchronously', 'speedycache').'
'; } echo '
'.esc_html__('Improve Font Rendering', 'speedycache').' '.esc_html__('Improved Font rendeing by adding text-rendring CSS.', 'speedycache').'
'; self::save_btn(); echo '
'; } static function preload_modal_options($field_name, $fields){ if(empty($fields)){ return ''; } switch($field_name){ case 'pre_connect': $placeholder = 'https://fonts.google.com'; break; default: $placeholder = site_url() . '/wp-content/uploads/image.jpg'; } $html = '
'; $html .= '
'; if(isset($fields['parent_selector'])){ $html .= ''; } if(isset($fields['crossorigin'])){ $html .= ''; } $html .= '
'; if(isset($fields['type'])){ $html .= ''; } if(isset($fields['priority'])){ $html .= ''; } $html .= '
'; return $html; } static function pro_notice($tab_name){ echo '

'.esc_html($tab_name).'

'.esc_html__('This is a part of SpeedyCache Pro, so update/upgrade to pro to utilize this feature', 'speedycache').'

'; } static function save_btn(){ echo '
'; } }