wordpress插件之SG Optimizer

SG Optimizer的作者是SiteGround,目前有900,000+个有效安装。已经Tested with 5.5.0版本的wordpress。
Description

This plugin is designed to link WordPress with the SiteGround Performance services. It WILL NOT WORK on another hosting provider.

The SG Optimizer plugin has few different parts handling speciffic performance optimizations:

CONFIGURATION

For detailed information on our plugin and how it works, please check out our SG Optimizer Tutorial.

SUPERCACHER SETTINGS

In this tab, you can configure your Dynamic Caching and Memcached. Make sure you’ve enabled them from your cPanel before using the plugin. You can enable/disable the automatic cache purge, exclude URLs from the cache and test your pages if they are properly cached.

ENVIRONMENT OPTIMIZATION

Here, you can force HTTPS for your site, switch between different PHP Versions (compatibility check available), and enable or disable Gzip Compression and Borwser Caching rules for your site.

FRONTEND OPTIMIZATION

In this tab, you can enable or disable Minification of your HTML, JS and CSS resources, remove the Emoji support and remove the query strings from your static resources.

IMAGE OPTIMIZATION

Here, you can enable or disable optimization for your newly uploaded images, bulk optimize your old ones and enable lazy loading for your site images.

PLUGIN COMPATIBILITY

If your plugin does not trigger standard WordPress hooks or you need us to purge the cache, you can use this public function in your code:

if (function_exists('sg_cachepress_purge_cache')) {
sg_cachepress_purge_cache();
}

Preferrably, you can pass an URL to the function to clear the cache just for it instead of purging the entire cache. For example:

if (function_exists('sg_cachepress_purge_cache')) {
sg_cachepress_purge_cache('http://yoursite.com/pluginpage');
}

You can exclude styles from being combined and minified using the filters we’ve designed for that purpose. Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_css_combine_exclude', 'css_combine_exclude' );
function css_combine_exclude( $exclude_list ) {
// Add the style handle to exclude list.
$exclude_list[] = 'style-handle';
$exclude_list[] = 'style-handle-2';

return $exclude_list;
}

add_filter( 'sgo_css_minify_exclude', 'css_minify_exclude' );
function css_minify_exclude( $exclude_list ) {
// Add the style handle to exclude list.
$exclude_list[] = 'style-handle';
$exclude_list[] = 'style-handle-2';

return $exclude_list;
}

You can exclude script from being minified using the filter we’ve designed for that purpose. Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_js_minify_exclude', 'js_minify_exclude' );
function js_minify_exclude( $exclude_list ) {
$exclude_list[] = 'script-handle';
$exclude_list[] = 'script-handle-2';

return $exclude_list;
}

You can exclude script from being combined using the filter we’ve designed for that purpose. Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_javascript_combine_exclude', 'js_combine_exclude' );
function js_combine_exclude( $exclude_list ) {
$exclude_list[] = 'script-handle';
$exclude_list[] = 'script-handle-2';

return $exclude_list;
}

You can exclude external script from being combined using the filter we’ve designed for that purpose. Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_javascript_combine_excluded_external_paths', 'js_combine_exclude_external_script' );
function js_combine_exclude_external_script( $exclude_list ) {
$exclude_list[] = 'script-host.com';
$exclude_list[] = 'script-host-2.com';

return $exclude_list;
}

You can exclude inline script from being combined using the filter we’ve designed for that purpose. Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_javascript_combine_excluded_inline_content', 'js_combine_exclude_inline_script' );
function js_combine_exclude_inline_script( $exclude_list ) {
$exclude_list[] = 'first few symbols of inline content script';

return $exclude_list;
}

You can exclude script from being loaded asynchronous using the filter we’ve designed for that purpose. Here’s an example of the code, you can add to your functions.php file:

add_filter( 'sgo_js_async_exclude', 'js_async_exclude' );
function js_async_exclude( $exclude_list ) {
$exclude_list[] = 'script-handle';
$exclude_list[] = 'script-handle-2';

return $exclude_list;
}

You can exclude url or url that contain specific query param using the following filters:

add_filter( 'sgo_html_minify_exclude_params', 'html_minify_exclude_params' );
function html_minify_exclude_params( $exclude_params ) {
// Add the query params that you want to exclude.
$exclude_params[] = 'test';

return $exclude_params;
}

add_filter( 'sgo_html_minify_exclude_urls', 'html_minify_exclude' );
function html_minify_exclude( $exclude_urls ) {
// Add the url that you want to exclude.
$exclude_urls[] = 'http://mydomain.com/page-slug';

return $exclude_urls;
}

You can exclude images from Lazy Load using the following filter:

add_filter( 'sgo_lazy_load_exclude_classes', 'exclude_images_with_specific_class' );
function exclude_images_with_specific_class( $classes ) {
// Add the class name that you want to exclude from lazy load.
$classes[] = 'test-class';

return $classes;
}

WP-CLI SUPPORT

In version 5.0 we’ve added full WP-CLI support for all plugin options and functionalities.

wp sg purge (url) – purges the entire cache or if URL is passed
wp sg memcached enable|disable – enables or disables Memcached
wp sg forcehttp enable|disable – enables or disables HTTPS for your site
wp sg phpver check (–version=) – checks your site for compatibility with PHP 7.1 or the version you specify
wp sg optimize – enables or disables different optimization options for your site:
wp sg optimize html enable|disable – enables or disables HTML minification
wp sg optimize js enable|disable – enables or disables JS minification
wp sg optimize css enable|disable – enables or disables CSS minification
wp sg optimize combine-css enable|disable – enables or disables CSS combination
wp sg optimize combine-js enable|disable – enables or disables JS combination
wp sg optimize querystring enable|disable – enables or disables query strings removal
wp sg optimize emojis enable|disable – enables or disables stripping of the Emoji scripts
wp sg optimize images enable|disable – enables or disables New image optimization
wp sg optimize webp enable|disable – enables or disables WebP image optimization
wp sg optimize lazyload enable|disable – enables or disables Lazy loading of images
wp sg optimize gzip enable|disable – enables or disables Gzip compression for your site
wp sg optimize browsercache enable|disable – enables or disables Browser caching rules
wp sg optimize dynamic-cache enable|disable – enables or disables Dynamic caching rules
wp sg optimize google-fonts enable|disable – enables or disables Google Fonts Combination
wp sg status dynamic-cache|autoflush-cache|mobile-cache|html|js|js-async|css|combine-css|querystring|emojis|images|lazyload_images|lazyload_gravatars|lazyload_thumbnails|lazyload_responsive|lazyload_textwidgets|gzip|browser-caching|memcache|ssl|ssl-fix|google-fonts|combine-js|webp – returns optimization current status (enabled|disabled)
REQUIREMENTS

In order to work correctly, this plugin requires that your server meets the following criteria:

SiteGround account
WordPress 4.7
PHP 5.5
If you’re not hosted with SiteGround this plugin WILL NOT WORK because it relies on a specific server configuration

Our plugin uses a cookie in order to function properly. It does not store personal data and is used solely for the needs of our caching system.

微慕商城——精选wordpress插件及wordpress主题,帮助站长快速生成wordpress小程序。
微慕WordPress小程序商城 » wordpress插件之SG Optimizer

提供最优质的资源集合

立即查看 了解详情