Skip to main content

Actions, Filters and PHP constants

The Servebolt Optimizer plugin and its behavior can be altered by using filters and PHP constants.

Usage and examples

The concept of using filters and PHP constants are very similar – they are used to change values and behaviors. But they do have their differences. Please see below for an example of their difference.

PHP constants are useful for specifying a single value:

define( 'SERVEBOLT_FPC_CACHE_TIME', 1200 ); // Set HTML Cache time to 20 minutes
define( 'SB_CF_REQUEST_DEBUG', true ); // Debug requests to the Cloudflare API

Filters are useful if you would like to write some logic as well as changing a value:

add_filter( 'sb_optimizer_display_admin_bar_menu_by_user_capabilities', function( $display_admin_bar ) {
if ( ! current_user_can( 'my_custom_capability' ) ) {
return false;
}
return $display_admin_bar;
});

Read more about filters in the WordPress documentation.

There are also some built in functions that are handy when working with filters:

  • __return_true
  • __return_false
  • __return_zero
  • __return_empty_array
  • __return_null
  • __return_empty_string

An example of this:

add_filter( 'sb_optimizer_automatic_purge_on_post_save', '__return_true' );
add_filter( 'sb_optimizer_max_number_of_urls_to_be_purged', '__return_zero' );

Actions on the other hans are used to trigger a piece of code on a specific time, for example right after a checkout in a web store. This is useful if you want to integrate with WordPress or 3rd parties like WordPress-plugins.

Read more about filters in the WordPress documentation.

PHP constants

SERVEBOLT_FPC_CACHE_TIME (integer)

Used to set the “Expires”-header. Defaults to 600 seconds. Only active for Servebolt-customers when using HTML caching.


SERVEBOLT_BROWSER_CACHE_TIME (integer)

Used to set the “max-age”-parameter in the “Cache-Control”-header. Defaults to 600 seconds. Only active for Servebolt-customers when using HTML caching.


SB_CF_REQUEST_DEBUG (boolean)

Whether to debug Cloudflare API request data to the error log.


SERVEBOLT_QUEUE_BASED_CACHE_PURGE (boolean)

Whether to use the WP cron to purge the cache (the alternative is that the cache purge happens immediately, without any queue).


SERVEBOLT_QUEUE_BASED_CACHE_PURGE_SHOULD_PARSE_QUEUE (boolean)

Whether to execute cache purge on items in the queue. Can be used to only queue up items for cache purge, but not execute the cache purge.

Actions

Under you will find a full list of all available actions in the plugin and when they will fire:

sb_optimizer_env_file_reader_failure

Runs when the plugin could not read the environment file (Servebolt clients only). In most cases this is because the files has been deleted or they have been disabled in the Servebolt Control Panel.

function action_callback() {
// Do something
}
add_action( 'sb_optimizer_env_file_reader_failure', 'action_callback', 10, 0 );

sb_optimizer_upgrader_process_complete

Runs when after the plugin has been updated, regardless if it's done through WP Admin or WP CLI.

function action_callback() {
// Do something
}
add_action( 'sb_optimizer_upgrader_process_complete', 'action_callback', 10, 0 );

sb_optimizer_fpc_no_cache_headers

Runs when no cache headers are being set.

function action_callback() {
// Do something
}
add_action( 'sb_optimizer_fpc_no_cache_headers', 'action_callback', 10, 0 );

sb_optimizer_fpc_cache_headers

Runs when cache headers are being set.

function action_callback() {
// Do something
}
add_action( 'sb_optimizer_fpc_cache_headers', 'action_callback', 10, 0 );

sb_optimizer_html_cache_enable

Runs when HTML cache is enabled.

function action_callback() {
// Do something
}
add_action( 'sb_optimizer_html_cache_enable', 'action_callback', 10, 0 );

sb_optimizer_html_cache_disable

Runs when HTML cache is disabled.

function action_callback() {
// Do something
}
add_action( 'sb_optimizer_html_cache_disable', 'action_callback', 10, 0 );

sb_optimizer_acd_enable

Runs when Accelerated Domains is enabled.

function action_callback() {
// Do something
}
add_action( 'sb_optimizer_acd_enable', 'action_callback', 10, 0 );

sb_optimizer_acd_disable

Runs when Accelerated Domains is disabled.

function action_callback() {
// Do something
}
add_action( 'sb_optimizer_acd_disable', 'action_callback', 10, 0 );

sb_optimizer_prefetching_manifest_files_written

Runs when manifest files are being written to disk for the Prefetching feature (Accelerated Domains-users only).

function action_callback() {
// Do something
}
add_action( 'sb_optimizer_prefetching_manifest_files_written', 'action_callback', 10, 0 );

sb_optimizer_post_removed_from_html_cache_exclusion

Runs when a post is removed from HTML cache exclusion.

/**
* @param int|string $postId The ID of the post being removed from the HTML cache exclusion list.
*/
function action_callback( $postId ) {
// Do something
}
add_action( 'sb_optimizer_post_removed_from_html_cache_exclusion', 'action_callback', 10, 1 );

sb_optimizer_post_added_to_html_cache_exclusion

Runs when a post is added to HTML cache exclusion.

/**
* @param int|string $postId The ID of the post being added to the HTML cache exclusion list.
*/
function action_callback( $postId ) {
// Do something
}
add_action( 'sb_optimizer_post_added_to_html_cache_exclusion', 'action_callback', 10, 1 );

sb_optimizer_cache_purge_3rd_party_urls

Runs when an object gets purged cache for.

/**
* @param int|string $postId The ID of the post being purged cache for.
* @param object $purgeObjectType An instance of Servebolt\Optimizer\CachePurge\PurgeObject\ObjectTypes\Post.
*/
function action_callback( $postId, $purgeObjectType ) {
// Do something
}
add_action( 'sb_optimizer_cache_purge_3rd_party_urls', 'action_callback', 10, 2 );

sb_optimizer_post_cache_purge_3rd_party_urls

Runs when a post gets purged cache for.

/**
* @param int|string $postId The ID of the post being purged cache for.
* @param object $purgeObjectType An instance of Servebolt\Optimizer\CachePurge\PurgeObject\ObjectTypes\Post.
*/
function action_callback( $postId, $purgeObjectType ) {
// Do something
}
add_action( 'sb_optimizer_post_cache_purge_3rd_party_urls', 'action_callback', 10, 2 );

sb_optimizer_post_cache_purge_3rd_party_urls_post_type_{post_type}

Runs when a post in a specific post type gets purged cache for.

/**
* @param int|string $postId The ID of the post being purged cache for.
* @param object $purgeObjectType An instance of Servebolt\Optimizer\CachePurge\PurgeObject\ObjectTypes\Post.
*/
function action_callback( $postId, $purgeObjectType ) {
// Do something
}
add_action( 'sb_optimizer_post_cache_purge_3rd_party_urls_post_type_{post_type}', 'action_callback', 10, 2 );

sb_optimizer_purged_post_cache

Runs right before cache is being purged for a post.

/**
* @param int|string $postId The ID of the post being purged cache for.
* @param bool $isSimplePurge If true then only the URL of the post is being purged, not other related URLs (archive pages etc.)
*/
function action_callback( $postId, $isSimplePurge ) {
// Do something
}
add_action( 'sb_optimizer_purged_post_cache', 'action_callback', 10, 2 );

sb_optimizer_purged_post_cache_for_{postId}

Runs right before cache is being purged for a post.

/**
* @param bool $isSimplePurge If true then only the URL of the post is being purged, not other related URLs (archive pages etc.)
*/
function action_callback( $isSimplePurge ) {
// Do something
}
add_action( 'sb_optimizer_purged_post_cache_for_{postId}', 'action_callback', 10, 2 );

sb_optimizer_term_cache_purge_3rd_party_urls

Runs when a term gets purged cache for.

/**
* @param int|string $termId The ID of the term being purged cache for.
* @param object $purgeObjectType An instance of Servebolt\Optimizer\CachePurge\PurgeObject\ObjectTypes\Term.
*/
function action_callback( $termId, $purgeObjectType ) {
// Do something
}
add_action( 'sb_optimizer_term_cache_purge_3rd_party_urls', 'action_callback', 10, 2 );

sb_optimizer_term_cache_purge_3rd_party_urls_taxonomy_{taxonomy}

Runs when a term in a specific taxonomy gets purged cache for.

/**
* @param int|string $termId The ID of the term being purged cache for.
* @param object $purgeObjectType An instance of Servebolt\Optimizer\CachePurge\PurgeObject\ObjectTypes\Term.
*/
function action_callback( $termId, $purgeObjectType ) {
// Do something
}
add_action( 'sb_optimizer_term_cache_purge_3rd_party_urls_taxonomy_{taxonomy}', 'action_callback', 10, 2 );

sb_optimizer_purged_term_cache

Runs right before cache is being purged for a term.

/**
* @param int|string $termId The ID of the term being purged cache for.
* @param bool $isSimplePurge If true then only the URL of the term is being purged, not other related URLs (archive pages etc.)
*/
function action_callback( $termId, $isSimplePurge ) {
// Do something
}
add_action( 'sb_optimizer_purged_term_cache', 'action_callback', 10, 2 );

sb_optimizer_purged_term_cache_for_{termId}

Runs right before cache is being purged for a term.

/**
* @param bool $isSimplePurge If true then only the URL of the term is being purged, not other related URLs (archive pages etc.)
*/
function action_callback( $isSimplePurge ) {
// Do something
}
add_action( 'sb_optimizer_purged_term_cache{termId}', 'action_callback', 10, 2 );

Filters

Under you will find a full list of all available filters in the plugin and briefly how they will affect the behavior:

sb_optimizer_add_block_editor_plugin_menu

Whether to display the plugin menu in the Block Editor.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_add_block_editor_plugin_menu', 'filter_function_name', 10, 1 );

sb_optimizer_cache_purge_row_action_post_types

The post types to add cache purge row actions for.

/**
* @param array $post_types
*/
function filter_function_name( $post_types ) {
// array of post types where the purge cache action will show
return $post_types;
}
add_filter( 'sb_optimizer_cache_purge_row_action_post_types', 'filter_function_name', 10, 1 );

sb_optimizer_cache_purge_row_action_post_types_query

The query used to resolve post types to add cache purge row actions for.

/**
* @param array $args
*/
function filter_function_name( $args ) {
return $args;
}
add_filter( 'sb_optimizer_cache_purge_row_action_post_types_query', 'filter_function_name', 10, 1 );

sb_optimizer_cache_purge_row_action_taxonomies

The taxonomies to add cache purge row actions for.

/**
* @param array $taxonomies
*/
function filter_function_name( $taxonomies ) {
// array of taxonomies where the purge cache action will show
return $taxonomies;
}
add_filter( 'sb_optimizer_cache_purge_row_action_taxonomies', 'filter_function_name', 10, 1 );

sb_optimizer_cache_purge_row_action_taxonomies_query

The query used to resolve taxonomies to add cache purge row actions for.

/**
* @param array $args
*/
function filter_function_name( $args ) {
return $args;
}
add_filter( 'sb_optimizer_cache_purge_row_action_taxonomies_query', 'filter_function_name', 10, 1 );

sb_optimizer_cloudflare_feature_compatibility

Whether to add Cloudflare plugin compatibility. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_cloudflare_feature_compatibility', 'filter_function_name', 10, 1 );

sb_optimizer_send_apo_no_cache_headers

Whether to send Cloudflare APO no-cache headers. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_send_apo_no_cache_headers', 'filter_function_name', 10, 1 );

sb_optimizer_send_apo_cache_headers

Whether to send Cloudflare APO cache headers. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_send_apo_cache_headers', 'filter_function_name', 10, 1 );

sb_optimizer_jetpack_compatibility

Whether to add Jetpack plugin compatibility. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_jetpack_compatibility', 'filter_function_name', 10, 1 );

sb_optimizer_woocommerce_compatibility

Whether to add WooCommerce plugin compatibility. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_woocommerce_compatibility', 'filter_function_name', 10, 1 );

sb_optimizer_woocommerce_cache_purge_for_variations

Whether we should purge cache for product variations in WooCommerce context.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_woocommerce_cache_purge_for_variations', 'filter_function_name', 10, 1 );

sb_optimizer_woocommerce_instantpage_urls

Whether to add ?ip=1 to cart and checkout urls to prevent prefetching of cart info. A false response will prevent it.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_woocommerce_instantpage_urls', 'filter_function_name', 10, 1 );

sb_optimizer_wp_rocket_compatibility

Whether to add WP Rocket plugin compatibility. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_wp_rocket_compatibility', 'filter_function_name', 10, 1 );

sb_optimizer_wp_rocket_compatibility_should_delete_cache_folders

Whether Servebolt Optimizer should delete the cache folders originating from WP Rocket.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_wp_rocket_compatibility_should_delete_cache_folders', 'filter_function_name', 10, 1 );

sb_optimizer_wp_rocket_compatibility_cache_folders

Filter for the array of WP Rocket PHP constants that defines the path to their cache-related folders. Used when Servebolt Optimizer is disabling the cache feature in WP Rocket.

function filter_function_name( $array ) {
return $array;
}
add_filter( 'sb_optimizer_wp_rocket_compatibility_cache_folders', 'filter_function_name', 10, 1 );

sb_optimizer_yoast_seo_premium_compatibility

Whether to add Yoast SEO Premium plugin compatibility. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_yoast_seo_premium_compatibility', 'filter_function_name', 10, 1 );

sb_optimizer_yoast_seo_premium_redirect_url_format

Filter to ensure that the URL format is correct whenever a Yoast Redirect is changed. Mostly this is to ensure that we're not trying to purge relative URLs, ensuring that the full URL is used.

/**
* @param string $url The URL with the correct format, using the full URL.
* @param string $raw_url The raw URL.
*/
function filter_function_name( $url, $raw_url ) {
return $url;
}
add_filter( 'sb_optimizer_yoast_seo_premium_redirect_url_format', 'filter_function_name', 10, 2 );

sb_optimizer_fpc_send_sb_cache_headers

Whether to print cache headers in the HTML cache feature. Defaults to true.

/**
* @param bool $boolean Whether we should print cache headers.
* @param string $context Can be either "cache" or "no-cache", meaning that the headers about to be printed indicates whether the page should be cached or not.
*/
function filter_function_name( $boolean, $context ) {
return $boolean;
}
add_filter( 'sb_optimizer_fpc_send_sb_cache_headers', 'filter_function_name', 10, 2 );

sb_optimizer_fullpage_cache_header_item

Every header is run through this filter so they can be adapted at will.

/**
* @param string $string the complete header item information.
*
* @return string
*/
function filter_function_name( $string ) {
return $string;
}
add_filter( 'sb_optimizer_fullpage_cache_header_item', 'filter_function_name', 10 );

sb_optimizer_html_cache_is_active

Whether the HTML cache feature is active.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_html_cache_is_active', 'filter_function_name', 10, 1 );

sb_optimizer_html_cache_should_debug_headers

Whether to print debug headers related to the HTML caching (only for Servebolt-hosted sites).

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_html_cache_should_debug_headers', 'filter_function_name', 10, 1 );

sb_optimizer_fpc_ecommerce_pages_no_cache_bool

In HTML caching context, use this boolean to override whether the current request is to a eCommerce page that should not be cached.

function filter_function_name( $boolean ) {
// Determine whether we are looking at a eCommerce page that should not be cached
return $boolean;
}
add_filter( 'sb_optimizer_fpc_ecommerce_pages_no_cache_bool', 'filter_function_name', 10, 1 );

sb_optimizer_fpc_ecommerce_pages_cache_bool

In HTML cache context, use this boolean to override whether the current request is to a eCommerce page that should be cached.

function filter_function_name( $boolean ) {
// Determine whether we are looking at a eCommerce page that should be cached
return $boolean;
}
add_filter( 'sb_optimizer_fpc_ecommerce_pages_cache_bool', 'filter_function_name', 10, 1 );

sb_optimizer_display_admin_bar_menu

Whether to display the plugin admin bar menu item.

function filter_function_name( $boolean, $wpAdminBar ) {
// Determine if we should display the our menu item in the WP admin bar
return $boolean;
}
add_filter( 'sb_optimizer_display_admin_bar_menu', 'filter_function_name', 10, 2 );

sb_optimizer_admin_bar_display_control_panel_node

Whether to display the Servebolt Control Panel node in the admin bar menu.

function filter_function_name( $boolean ) {
// Determine if we should display the Servebolt Control Panel menu node in the WP admin bar.
// Default to true if hosted on Servebolt and current user has manage-options capibility
return $boolean;
}
add_filter( 'sb_optimizer_admin_bar_display_control_panel_node', 'filter_function_name', 10, 1 );

sb_optimizer_admin_bar_cache_purge_can_purge_all

Whether to display the Purge All Cache node in the admin bar menu.

function filter_function_name( $boolean ) {
// Determine if we should display the Purge All Cache menu node in the WP admin bar.
// Default to true if caching has been enabled, and not on network admin screens.
return $boolean;
}
add_filter( 'sb_optimizer_admin_bar_cache_purge_can_purge_all', 'filter_function_name', 10, 1 );

sb_optimizer_admin_bar_display_network_cache_purge_node

Whether to display the Purge a URL node in the network admin bar menu.

function filter_function_name( $boolean ) {
// Determine if we should display the Purge a URL in network admin menu node in the network WP admin bar.
// Default to true if caching has been enabled, is a multisite, and is on a network admin screen.
return $boolean;
}
add_filter( 'sb_optimizer_admin_bar_display_network_cache_purge_node', 'filter_function_name', 10, 1 );

sb_optimizer_admin_bar_display_settings_node

Whether to display the Settings node in admin bar menu.

function filter_function_name( $boolean ) {
// Determine if we should display the Settings node in the network WP admin bar.
// Default to true if user has manage-options capability.
return $boolean;
}
add_filter( 'sb_optimizer_admin_bar_display_settings_node', 'filter_function_name', 10, 1 );

sb_optimizer_admin_bar_display_error_log_node

Whether to display the ErrorLog node in admin bar menu - Only shows when hosted at Servebolt

function filter_function_name( $boolean ) {
// Determine if we should display the ErrorLog node in the WP admin bar.
// Default to true if user has manage-options capability. Will not show menu item if not currently hosted at Servebolt.
return $boolean;
}
add_filter( 'sb_optimizer_admin_bar_display_error_log_node', 'filter_function_name', 10 );

sb_optimizer_admin_bar_cache_purge_can_purge_url

Whether to display the Purge a URL node in admin bar menu

function filter_function_name( $boolean ) {
// Determine if we should display the Purge a URL node in the WP admin bar.
// Default to true if user has edit_others_posts capability.
return $boolean;
}
add_filter( 'sb_optimizer_admin_bar_cache_purge_can_purge_url', 'filter_function_name', 10 );

sb_optimizer_allow_admin_bar_cache_purge_for_post

Whether to display the Purge [post type] cache node in admin bar menu for the currently viewed page or admin edit screen

function filter_function_name( $boolean ) {
// Determine if we should display the Purge {post} cache node in the WP admin bar.
// Defaults to true.
return $boolean;
}
add_filter( 'sb_optimizer_allow_admin_bar_cache_purge_for_post', 'filter_function_name', 10 );

sb_optimizer_allow_admin_bar_cache_purge_for_term

Whether to display the Purge [taxonomy type] cache node in admin bar menu for the currently edited taxonomy term

function filter_function_name( $boolean ) {
// Determine if we should display the Purge {category} cache node in the WP admin bar.
// Defaults to true.
return $boolean;
}
add_filter( 'sb_optimizer_allow_admin_bar_cache_purge_for_term', 'filter_function_name', 10 );

sb_optimizer_display_network_super_admin_menu

Whether to display the network admin menu.

function filter_function_name( $boolean ) {
// Determine if we should display the network admiin menu
return $boolean;
}
add_filter( 'sb_optimizer_display_network_super_admin_menu', 'filter_function_name', 10, 1) ;

sb_optimizer_display_subsite_menu

Whether to display the subsite admin menu (if multisite).

function filter_function_name( $boolean ) {
// Determine if we should display the admin menu on a subsite in a multisite network
return $boolean;
}
add_filter( 'sb_optimizer_display_subsite_menu', 'filter_function_name', 10, 1 );

sb_optimizer_display_single_site_admin_menu

Whether to display the admin menu on a single site. Defaults to true.

function filter_function_name( $boolean ) {
// Determine if we should display the admin menu
return $boolean;
}
add_filter( 'sb_optimizer_display_single_site_admin_menu', 'filter_function_name', 10, 1 );

sb_optimizer_purge_item_list_limit

The number of items to display in the cache purge list. Currently not in use.

function filter_function_name( $limit ) {
return 500; // Only display 500 items in the purge queue list
}
add_filter( 'sb_optimizer_purge_item_list_limit', 'filter_function_name', 10, 1 );

sb_optimizer_log_file_path

The path of the log file – only available when hosted in Servebolt.

/**
* @param string $log_file_path The path to the log file that should be read by our code and displayed in the WP Admin GUI.
*/
function filter_function_name( $log_file_path ) {
return '/custom/path/to/logfile.log'; // Override the path to the log file to inspect
}
add_filter( 'sb_optimizer_log_file_path', 'filter_function_name', 10, 1 );

sb_optimizer_cache_purge_settings_form_validation_active

Whether to use JavaScript-based validation when editing the Cache Purge configuration. Defaults to true.

function filter_function_name( $boolean ) {
return false; // Disable JavaScript validation for Cache Purge configuration form
}
add_filter( 'sb_optimizer_cache_purge_settings_form_validation_active', 'filter_function_name', 10, 1 );

sb_optimizer_cache_purge_date_archive_active

Whether to include date archive URLs when purging cache for a post/term. Defaults to false.

function filter_function_name( $boolean ) {
return false;
}
add_filter( 'sb_optimizer_cache_purge_date_archive_active', 'filter_function_name', 10, 1 );

sb_optimizer_cache_purge_post_type_should_be_purged

Whether this post type should be purged cache for.

/**
* @param bool $boolean Whether this post type should be purged cache for.
* @param string $postType The post type in question.
*/
function filter_function_name( $boolean, $postType ) {
return $boolean;
}
add_filter( 'sb_optimizer_cache_purge_post_type_should_be_purged', 'filter_function_name', 10, 2 );

`sb_optimizer_cache_tags_fine_grain_control`

Runs just before generating the cache tags for either caching or purging.

/**
* @param $value|bool
* @return $value|bool
*/
function filter_callback( $value ) {
// leave as TRUE, or to not filter at all to use complex cache tags.

// return FALSE to use minimal cache tags.
return false;
}
add_filter( 'sb_optimizer_cache_tags_fine_grain_control', 'filter_callback', 10, 1 );

sb_optimizer_acd_image_resize_has_access

Whether you have access to Accelerated Domains Image Resize. Defaults to true. Note that you need to have access to Accelerated Domains for this feature to work.

/**
* @param bool $boolean
*/
function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_acd_image_resize_has_access', 'filter_function_name', 10, 1 );

sb_optimizer_prefetching_alternative_immediate_manifest_file_generation

Whether to allow for immediately generating manifest files (alternative strategy). Defaults to false.

/**
* @param bool $boolean
*/
function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_prefetching_alternative_immediate_manifest_file_generation', 'filter_function_name', 10, 1 );

sb_optimizer_should_generate_other_urls

Whether to generate other URLs (archives, front page) when purging cache for a WP object. Defaults to true.

function filter_function_name( $boolean ) {
return false; // When purging cache, don't purge other related URLs like archives etc.
}
add_filter( 'sb_optimizer_should_generate_other_urls', 'filter_function_name', 10, 1 );

sb_optimizer_alter_urls_for_cache_purge_object

Use this filter to alter the URLs when purging cache.

function filter_function_name( $urls, $purge_item_id, $purge_item_type ) {
$urls[] = 'https://my-custom-purge.com/some-path/';
return $urls;
}
add_filter( 'sb_optimizer_alter_urls_for_cache_purge_object', 'filter_function_name', 10, 3 );

sb_optimizer_disable_automatic_purge

Whether to disable the automatic cache purge feature (for example when saving a post etc.). Defaults to false.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_disable_automatic_purge', 'filter_function_name', 10, 1 );

sb_optimizer_automatic_purge_on_post_save

Whether to purge cache automatically on post update. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_automatic_purge_on_post_save', 'filter_function_name', 10, 1 );

sb_optimizer_automatic_purge_on_comment

Whether to purge cache automatically on comment post. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_automatic_purge_on_comment', 'filter_function_name', 10, 1 );

sb_optimizer_automatic_purge_on_comment_approval

Whether to purge cache automatically on comment approval. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_automatic_purge_on_comment_approval', 'filter_function_name', 10, 1 );

sb_optimizer_automatic_purge_on_published_comment_edited

Whether to purge cache automatically on published comment edited. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_automatic_purge_on_published_comment_edited', 'filter_function_name', 10, 1 );

sb_optimizer_automatic_purge_on_comment_trashed

Whether to purge cache automatically on published comment sent to trash. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_automatic_purge_on_comment_trashed', 'filter_function_name', 10, 1 );

sb_optimizer_automatic_purge_on_comment_untrashed

Whether to purge cache automatically when approved comment is restored from trash. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_automatic_purge_on_comment_untrashed', 'filter_function_name', 10, 1 );

`sb_optimizer_disable_automatic_purge_on_deletion`

Whether to disable automatic cache purging when a post/term is deleted. Defaults to false.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_disable_automatic_purge_on_deletion', 'filter_function_name', 10, 1 );

sb_optimizer_automatic_purge_on_term_save

Whether to purge cache automatically on term update. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_automatic_purge_on_term_save', 'filter_function_name', 10, 1 );

sb_optimizer_automatic_purge_on_term_delete

Whether to purge cache automatically on term deletion. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_automatic_purge_on_term_delete', 'filter_function_name', 10, 1 );

sb_optimizer_automatic_purge_on_attachment_delete

Whether to purge cache automatically on attachment deletion. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_automatic_purge_on_attachment_delete', 'filter_function_name', 10, 1 );

sb_optimizer_automatic_purge_on_post_delete

Whether to purge cache automatically on post deletion. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_automatic_purge_on_post_delete', 'filter_function_name', 10, 1 );

sb_optimizer_automatic_purge_on_post_trash

Whether to purge cache automatically on post trash. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_automatic_purge_on_post_trash', 'filter_function_name', 10, 1 );

sb_optimizer_disable_automatic_purge_on_slug_change

Whether to disable automatic cache purging on slug change (both for posts and terms). Defaults to false.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_disable_automatic_purge_on_slug_change', 'filter_function_name', 10, 1 );

sb_optimizer_automatic_purge_on_term_permalink_change

Whether to purge cache automatically on term permalink change. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_automatic_purge_on_term_permalink_change', 'filter_function_name', 10, 1 );

sb_optimizer_automatic_purge_on_post_permalink_change

Whether to purge cache automatically on post permalink change. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_automatic_purge_on_post_permalink_change', 'filter_function_name', 10, 1 );

sb_optimizer_should_purge_term_cache

Use this filter to override the check that decides whether we should purge term cache or not.

function filter_function_name( $boolean, $term_id, $taxonomy ) {
return $boolean;
}
add_filter( 'sb_optimizer_should_purge_term_cache', 'filter_function_name', 10, 3 );

sb_optimizer_should_purge_post_cache

Use this filter to override the check that decides whether we should purge post cache or not.

function filter_function_name( $boolean, $post_id ) {
return $boolean;
}
add_filter( 'sb_optimizer_should_purge_post_cache', 'filter_function_name', 10, 2 );

sb_optimizer_prevent_cache_purge_on_unapproved_comments

Whether we should purge cache on unapproved comment post. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_prevent_cache_purge_on_unapproved_comments', 'filter_function_name', 10, 1 );

sb_optimizer_comment_approved_cache_purge

Whether a comment is considered as approved on comment post in the context of our automatic cache purge.

function filter_function_name( $boolean, $comment_data, $comment_id, $post_id ) {
return $boolean;
}
add_filter( 'sb_optimizer_comment_approved_cache_purge', 'filter_function_name', 10, 4 );

sb_optimizer_cf_image_resize_alter_srcset

Whether to alter the srcset-attribute when using the Cloudflare image resize feature. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_cf_image_resize_alter_srcset', 'filter_function_name', 10, 1 );

sb_optimizer_cf_image_resize_alter_src

Whether to alter the src-attribute when using the Cloudflare image resize feature. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_cf_image_resize_alter_src', 'filter_function_name', 10, 1 );

sb_optimizer_cf_image_resize_alter_intermediate_sizes

Whether to affect the generation of image sizes when uploading an image. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_cf_image_resize_alter_intermediate_sizes', 'filter_function_name', 10, 1 );

sb_optimizer_image_resize_always_create_sizes

When generating images and using the Cloudflare/Accelerated Domains image resize feature, then use this filter to decide which image sizes that should always be created files for (meaning WordPress actually creates files on disk for the image size).

/**
* @param array $sizes
*/
function filter_function_name( $sizes ) {
// Make changes to $sizes
return $sizes;
}
add_filter( 'sb_optimizer_image_resize_always_create_sizes', 'filter_function_name', 10, 1 );

sb_optimizer_cf_image_resize_max_width

Cloudflare image resize max width. Defaults to 1920.

/**
* @param int $maxWidth
*/
function filter_function_name( $maxWidth ) {
return $maxWidth; // Override max width for Cloudflare image resize
}
add_filter( 'sb_optimizer_cf_image_resize_max_width', 'filter_function_name', 10, 1 );

sb_optimizer_cf_image_resize_max_height

Cloudflare image resize max height. Defaults to 1080.

/**
* @param int $maxHeight
*/
function filter_function_name( $maxHeight ) {
return $maxHeight; // Override max height for Cloudflare image resize
}
add_filter( 'sb_optimizer_cf_image_resize_max_height', 'filter_function_name', 10, 1 );

sb_optimizer_cf_image_resize_url

The image URL after modification when using the Cloudflare image resize feature.

function filter_function_name( $url, $original_url, $cdi_uri, $cf_params, $cf_parameter_string ) {
// Do something with $url
return $url;
}
add_filter( 'sb_optimizer_cf_image_resize_url', 'filter_function_name', 10, 5 );

sb_optimizer_cf_image_resize_default_params_additional

The additional URL parameters (before arguments are merged with default arguments) used when modifying the URL to use Cloudflare image resize.

function filter_function_name( $parameters ) {
// Do something with $parameters
return $parameters;
}
add_filter( 'sb_optimizer_cf_image_resize_default_params_additional', 'filter_function_name', 10, 1 );

sb_optimizer_cf_image_resize_default_params

The default URL parameters (before arguments are merged with additional arguments) used when modifying the URL to use Cloudflare image resize.

function filter_function_name( $parameters ) {
// Do something with $parameters
return $parameters;
}
add_filter( 'sb_optimizer_cf_image_resize_default_params', 'filter_function_name', 10, 1 );

sb_optimizer_cf_image_resize_default_params_concatenated

The URL parameters (after arguments are merged with default arguments) used when modifying the URL to use Cloudflare image resize.

function filter_function_name( $parameters ) {
// Do something with $parameters
return $parameters;
}
add_filter( 'sb_optimizer_cf_image_resize_default_params_concatenated', 'filter_function_name', 10, 1 );

sb_optimizer_upscale_images

Whether to use upscale the images when using the Cloudflare / Accelerated Domains image resize-feature. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_upscale_images', 'filter_function_name', 10, 1 );

sb_optimizer_image_resize_upscale_dimensions

When using the Cloudflare / Accelerated Domains image resize feature – use this filter to adjust the upscale dimensions of the image.

/**
* @param array $dimensions An array containing the dimensions or the image to potentially be upscaled.
*/
function filter_function_name( $dimensions ) {
// Do something with $dimensions
return $dimensions;
}
add_filter( 'sb_optimizer_image_resize_upscale_dimensions', 'filter_function_name', 10, 1 );

sb_optimizer_should_purge_cache_queue

Whether the system should parse the cache purge queue and execute the cache purge. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_should_purge_cache_queue', 'filter_function_name', 10, 1 );

sb_optimizer_cf_api_request_debug

Whether to debug the request to the Cloudflare API. Defaults to false.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_cf_api_request_debug', 'filter_function_name', 10, 1 );

sb_optimizer_max_number_of_urls_to_be_purged

Limit the number of URLs being sent for purging in the Cloudflare API/the Servebolt API (depends on which driver is active). This is due to limitations in the API – maximum 30 URLs per purge request. Using this filter is recommended, but it will prevent an error until a better solution is implemented.

/**
* @param int $max_number The maximum number of URLs that should be purged during a request to the API (either Cloudflare of the Servebolt API).
* @param string $context The context of the cache purge, can be either "post" or "term".
* @param object $cache_purge_driver The instance of the cache purge driver.
*/
function filter_function_name( $max_number, $context, $cache_purge_driver ) {
return 30; // Set an upper limit for the number of URLs when purging cache
}
add_filter( 'sb_optimizer_max_number_of_urls_to_be_purged', 'filter_function_name', 10, 3 );

sb_optimizer_urls_to_be_purged

The array of URLs to be purged cache for.

/**
* @param array $urls An array of URLs to be purged.
*/
function filter_function_name( $urls ) {
// Do something with $urls
return $urls;
}
add_filter( 'sb_optimizer_urls_to_be_purged', 'filter_function_name', 10, 1 );

sb_optimizer_menu_optimizer_run_timing

Whether to run the timing metrics during in the Menu Optimizer feature. Defaults to false.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_menu_optimizer_run_timing', 'filter_function_name', 10, 1 );

sb_optimizer_menu_optimizer_disabled_for_unauthenticated_users

Whether the Menu Optimizer feature should be disabled for unauthenticated users. Defaults to false.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_menu_optimizer_disabled_for_unauthenticated_users', 'filter_function_name', 10, 1 );

sb_optimizer_menu_optimizer_print_cached_comment

Whether the Menu Optimizer should print a comment in the markup that will indicate whether the menu output came from cache or not. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_menu_optimizer_print_cached_comment', 'filter_function_name', 10, 1 );

sb_optimizer_mcrypt_key

The mcrypt key/secret used to store options.

function filter_function_name( $key ) {
return 'custom-key'; // Use custom encryption key for Mcrypt
}
add_filter( 'sb_optimizer_mcrypt_key', 'filter_function_name', 10, 1 );

sb_optimizer_openssl_keys

The OpenSSL key/secret used to store/get options.

/**
* @param array $keys An array containing OpenSSL secret key and IV.
*/
function filter_function_name( $keys ) {
// Do something with $keys
return $keys;
}
add_filter( 'sb_optimizer_openssl_keys', 'filter_function_name', 10, 1 );

sb_optimizer_pluggable_check

The OpenSSL key/secret used to store/get options.

/**
* @param bool $defaultValue = false
* @return bool return true to force additonal check that pluggable is loaded.
*/
function filter_function_name( $defaultValue ) {
return true;
}
add_filter( 'sb_optimizer_pluggable_check', 'filter_function_name' );

sb_optimizer_get_option_(option_name)

Filter for value of option.

/**
* @param mixed $value The option value.
*/
function filter_function_name( $value ) {
return 'custom-option-value';
}
add_filter( 'sb_optimizer_get_option_{option_name}', 'filter_function_name', 10, 1 );

sb_optimizer_get_blog_option_(option_name)

Filter for value of blog option.

/**
* @param mixed $value The blog option value.
*/
function filter_function_name( $value ) {
return 'custom-blog-option-value';
}
add_filter( 'sb_optimizer_get_blog_option_{option_name}', 'filter_function_name', 10, 1 );

sb_paginate_links_as_array_args

The arguments passed to the function “paginate_links” when generating pagination links in the context of the cache purge-feature.

function filter_function_name( $args ) {
return $args;
}
add_filter( 'sb_paginate_links_as_array_args', 'filter_function_name', 10, 1 );

sb_optimizer_skip_generic_optimizations

Whether to apply the generic optimizations (primarily trimming the contents in the head-tag as well as preventing script concatenation which is default behaviour in Wordpress). Defaults to false.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_skip_generic_optimizations', 'filter_function_name', 10, 1 );

sb_optimizer_ajax_user_allowed

Used to control the allowance (user capabilities) to send AJAX request to the AJAX endpoints of this plugin.

function filter_function_name( $user_allowed ) {
if ( ! current_user_can('my_custom_capability') ) {
return false;
}
return $user_allowed;
}
add_filter( 'sb_optimizer_ajax_user_allowed', 'filter_function_name', 10, 1 );

sb_optimizer_site_iteration

This filter is used when executing a closure for each blog in a multisite-network.

function filter_function_name( $sites ) {
// Do something with $sites
return $sites;
}
add_filter( 'sb_optimizer_site_iteration', 'filter_function_name', 10, 1 );

sb_optimizer_add_version_parameter_to_asset_src

Whether to add version parameter to assets URLs. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_add_version_parameter_to_asset_src', 'filter_function_name', 10, 1 );

sb_optimizer_version_parameter_name

The string used to create the version parameter for asset URLs.

/**
* @param string $parameter_name The name of the parameter being used in the asset URL.
* @param string $file_path The path of the asset file.
*/
function filter_function_name( $parameter_name, $file_path ) {
return $parameter_name;
}
add_filter( 'sb_optimizer_version_parameter_name', 'filter_function_name', 10, 2 );

sb_optimizer_version_parameter_value

The string used to create the version parameter for asset URLs.

/**
* @param string $parameter_value The value of the parameter being used in the asset URL.
* @param string $parameter_name The name of the parameter being used in the asset URL.
* @param string $file_path The path of the asset file.
*/
function filter_function_name( $parameter_value, $parameter_name, $file_path ) {
return $parameter_value;
}
add_filter( 'sb_optimizer_version_parameter_value', 'filter_function_name', 10, 3 );

sb_optimizer_asset_base_path

The base path used when converting an asset URL to asset path.

/**
* @param string $base_path The base path to your WP install as resolved by WordPress.
* @param string $src The URL of the asset in question.
* @param array $parsed_url The URL represented as an array using PHP-function "parse_url".
*/
function filter_function_name( $base_path, $src, $parsed_url ) {
return $base_path;
}
add_filter( 'sb_optimizer_asset_base_path', 'filter_function_name', 10, 3 );

sb_optimizer_asset_parsed_url_path

The URL path used when converting an asset URL to asset path.

function filter_function_name( $src ) {
return $src;
}
add_filter( 'sb_optimizer_asset_parsed_url_path', 'filter_function_name', 10, 1 );

sb_optimizer_add_version_parameter_to_script_src

Whether to add version parameter to asset script URLs. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_add_version_parameter_to_script_src', 'filter_function_name', 10, 1 );

sb_optimizer_add_version_parameter_to_style_src

Whether to add version parameter to asset style URLs. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_add_version_parameter_to_style_src', 'filter_function_name', 10, 1 );

sb_optimizer_add_version_parameter_to_script_src_{handle}

Whether to add version parameter to the asset script URL for a certain handle. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_add_version_parameter_to_script_src_{handle}', 'filter_function_name', 10, 1 );

sb_optimizer_add_version_parameter_to_style_src_{handle}

Whether to add version parameter to the asset style URL for a certain handle. Defaults to true.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_add_version_parameter_to_style_src_{handle}', 'filter_function_name', 10, 1 );

sb_optimizer_asset_url_to_path_conversion

The converted path of an asset URL.

/**
* @param string $path The resolved path of an assets URL.
* @param array $parsed_url The asset URL represented as an array using PHP-function "parse_url".
*/
function filter_function_name( $path, $parsed_url ) {
return $path;
}
add_filter( 'sb_optimizer_asset_url_to_path_conversion', 'filter_function_name', 10, 2 );

sb_optimizer_asset_url_to_path_conversion_(handle)

The converted path of an asset URL for a certain handle.

/**
* @param string $path The resolved path of an assets URL.
* @param array $parsed_url The asset URL represented as an array using PHP-function "parse_url".
*/
function filter_function_name( $path, $parsed_url ) {
return $path;
}
add_filter( 'sb_optimizer_asset_url_to_path_conversion_{handle}', 'filter_function_name', 10, 2 );

sb_optimizer_should_init_assets

Whether to initiate the assets of Servebolt Optimizer. Defaults to true if the user is logged in, false if otherwise.

/**
* @param bool $boolean
*/
function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_should_init_assets', 'filter_function_name', 10, 2 );

sb_optimizer_should_load_common_assets

Whether to load the common assets (scripts and styling).

/**
* @param bool $boolean Whether to load the common assets.
* @param string $type Which asset type we are considering, will be either "styling" or "scripts".
*/
function filter_function_name( $boolean, $type ) {
return $boolean;
}
add_filter( 'sb_optimizer_should_load_common_assets', 'filter_function_name', 10, 2 );

sb_optimizer_generic_optimizations_concatenate_scripts_disable

Whether to concatenate script files using WordPress constant "CONCATENATE_SCRIPTS". Note that if the constant is already set elsewhere this will not have any effect. Also note that if the filter `sb_optimizer_should_load_common_assets` is set to false then this will override this filter.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_generic_optimizations_concatenate_scripts_disable', 'filter_function_name', 10, 1 );

sb_optimizer_generic_optimizations_disable_meta_tag_generator

Whether to disable the meta tag generator in the header-tag on the webpage. Also note that if the filter `sb_optimizer_should_load_common_assets` is set to false then this will override this filter.

function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_generic_optimizations_disable_meta_tag_generator', 'filter_function_name', 10, 1 );

sb_optimizer_acd_image_resize_force_add_height

Whether to set the image height during image resize regardless of the max height. Affects the Accelerated Domain Image Resize feature.

/**
* @param bool $boolean Whether to set height parameter.
*/
function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_acd_image_resize_force_add_height', 'filter_function_name', 10, 1 );

sb_optimizer_acd_image_resize_additional_params

This array is being built into the resize parameters for the image resize feature. Contains the initial information about height and/or width. Affects the Accelerated Domain Image Resize feature.

/**
* @param array $additional_params An array containing additional parameters, usually width and height. If the image is not cropped then either width or height will be specified, using the highest value.
*/
function filter_function_name( $additional_params ) {
return $additional_params;
}
add_filter( 'sb_optimizer_acd_image_resize_additional_params', 'filter_function_name', 10, 1 );

sb_optimizer_acd_image_resize_default_params

This array is used as default when building the parameter array for the image resize URL. Will be merged with the additional parameters (see the previous filter). Affects the Accelerated Domain Image Resize feature.

/**
* @param array $default_params An array containing the default parameters for image resizing. This would typically be image quality and other settings related to the resize procedure.
*/
function filter_function_name( $default_params ) {
return $default_params;
}
add_filter( 'sb_optimizer_acd_image_resize_default_params', 'filter_function_name', 10, 1 );

sb_optimizer_acd_image_resize_params_concatenated

This array is used to build the parameters for the image resize URL. Affects the Accelerated Domain Image Resize feature.

/**
* @param array $params An array containing all parameters used during the image resize procedure.
*/
function filter_function_name( $params ) {
return $params;
}
add_filter( 'sb_optimizer_acd_image_resize_params_concatenated', 'filter_function_name', 10, 1 );

sb_optimizer_acd_image_resize_max_width

The maximum allowed width of images in the image resize feature. Affects the Accelerated Domain Image Resize feature.

/**
* @param int $maxWidth The maximum width in pixels an image should be during the image resize procedure.
*/
function filter_function_name( $maxWidth ) {
return $maxWidth;
}
add_filter( 'sb_optimizer_acd_image_resize_max_width', 'filter_function_name', 10, 1 );

sb_optimizer_acd_image_resize_max_height

The maximum allowed height of images in the image resize feature. Affects the Accelerated Domain Image Resize feature.

/**
* @param int $maxHeight The maximum height in pixels an image should be during the image resize procedure.
*/
function filter_function_name( $maxHeight ) {
return $maxHeight;
}
add_filter( 'sb_optimizer_acd_image_resize_max_height', 'filter_function_name', 10, 1 );

sb_optimizer_acd_image_resize_cgi_prefix

Used to alter the CGI prefix that is used when generating the resized image URL. Affects the Accelerated Domain Image Resize feature.

/**
* @param string $full_url_prefix The full prefix including version.
* @param string $prefix The CGI prefix that is used when generate resized image URL.
* @param string $version The version of the image resize service, currently v1.
*/
function filter_function_name( $full_url_prefix, $cgiPrefix, $version ) {
return $prefix;
}
add_filter( 'sb_optimizer_acd_image_resize_cgi_prefix', 'filter_function_name', 10, 3 );

sb_optimizer_acd_image_resize_url

Filters the altered URL for the image to be resized.

/**
* @param string $altered_url The altered URL (causing the image to be resized).
* @param string $url The original URL.
* @param array $url_parts
* @param string $path_prefix
* @param array $resize_parameters
* @param string $resize_parameters_string
*/
function filter_function_name( $altered_url, $url, $url_parts, $path_prefix, $resize_parameters, $resize_parameters_string ) {
return $alteredUrl;
}
add_filter( 'sb_optimizer_acd_image_resize_url', 'filter_function_name', 10, 6 );

sb_optimizer_acd_image_resize_should_touch

In a image resize context you can use this filter to exclude/include certain image types. By default SVG images will be excluded from the image resize feature. Affects the Accelerated Domain Image Resize feature.

/**
* @param bool $boolean Whether to touch image or not.
* @param string $mime_type The MIME type of the attachment.
* @param int|string $attachment_id The ID of the attachment.
*/
function filter_function_name( $boolean, $mime_type, $attachment_id ) {
return $boolean;
}
add_filter( 'sb_optimizer_acd_image_resize_should_touch', 'filter_function_name', 10, 3 );

sb_optimizer_acd_image_resize_should_touch_svg

In an image resize context you can use this filter to exclude/include SVG images. Affects the Accelerated Domain Image Resize feature.

/**
* @param bool $boolean Whether to touch image or not.
* @param string $mime_type The MIME type of the attachment.
* @param int|string $attachment_id The ID of the attachment.
*/
function filter_function_name( $boolean, $mime_type, $attachment_id ) {
return $boolean;
}
add_filter( 'sb_optimizer_acd_image_resize_should_touch_svg', 'filter_function_name', 10, 3 );

sb_optimizer_acd_image_resize_should_touch_by_file_extension

In an image resize context you can use this filter to exclude/include certain image types. By default SVG images will be excluded from the image resize feature. Affects the Accelerated Domain Image Resize feature.

/**
* @param bool $boolean Whether to touch image or not.
* @param string $file_extension The file extension of the attachment.
* @param string $mime_type The MIME type of the attachment.
* @param int|string $attachment_id The ID of the attachment.
*/
function filter_function_name( $boolean, $file_extension, $mime_type, $attachment_id ) {
return $boolean;
}
add_filter( 'sb_optimizer_acd_image_resize_should_touch_by_file_extension', 'filter_function_name', 10, 4 );

sb_optimizer_acd_image_resize_alter_src

Whether to resize the image URL used in the src-attribute of an image. Affects the Accelerated Domain Image Resize feature.

/**
* @param bool $boolean Whether to alter the URL of the src-attribute.
*/
function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_acd_image_resize_alter_src', 'filter_function_name', 10, 1 );

sb_optimizer_acd_image_resize_alter_srcset

Whether to resize the image URLs used in the srcset-attribute of an image. Affects the Accelerated Domain Image Resize feature.

/**
* @param bool $boolean Whether to alter the URLs of the srcset-attribute.
*/
function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_acd_image_resize_alter_srcset', 'filter_function_name', 10, 1 );

sb_optimizer_acd_image_resize_alter_intermediate_sizes

Whether we should prevent some image sized from being resized by our feature. See the class `ImageSizeCreationOverride` for more info. Affects the Accelerated Domain Image Resize feature.

/**
* @param bool $boolean Whether to prevent certain image sizes from being resized by our feature.
*/
function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_acd_image_resize_alter_intermediate_sizes', 'filter_function_name', 10, 1 );

sb_optimizer_acd_image_resize_add_half_sizes

Whether to add half sizes of the existing sizes to the srcset-attributes, giving the browser more image sizes to chose from when evaluating the viewport size against the images in the srcset-attribute. Accelerated Domain Image Resize feature.

/**
* @param bool $boolean Whether to add half sizes of existing sizes in the srcset-attribute.
*/
function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_acd_image_resize_add_half_sizes', 'filter_function_name', 10, 1 );

sb_optimizer_acd_add_custom_sizes_to_srcset

Whether to add custom sizes to the srcset-attribute. These sizes can be controlled via WP CLI, see command `wp servebolt acd image-sizes`. Accelerated Domain Image Resize feature.

/**
* @param bool $boolean Whether to add custom sizes to the srcset-attribute.
*/
function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_acd_add_custom_sizes_to_srcset', 'filter_function_name', 10, 1 );

sb_optimizer_acd_limit_srcset_width_to_image_width

Whether to limit the width of the images in the srcset-attribute to the width of the image in the src-attribute. Defaults to true. This feature is handy when you have added huge custom image sizes for example. Accelerated Domain Image Resize feature.

/**
* @param bool $boolean Whether to contain the width of the images in the srcset-attribute to the width of the image in the src-attribute.
*/
function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_acd_limit_srcset_width_to_image_width', 'filter_function_name', 10, 1 );

sb_optimizer_acd_limit_srcset_width_to_image_width

Whether to limit the width of the custom image sizes in the srcset-attribute to the width of the image in the src-attribute. Defaults to true. This feature is handy when you have added huge custom image sizes for example. Accelerated Domain Image Resize feature.

/**
* @param bool $boolean Whether to contain the width of the custom image sizes in the srcset-attribute to the width of the image in the src-attribute.
*/
function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_acd_limit_srcset_width_to_image_width', 'filter_function_name', 10, 1 );

sb_optimizer_acd_limit_all_srcset_width_to_image_width

Whether to limit the width of the all the images in the srcset-attribute to the width of the image in the src-attribute. Defaults to true. This feature is handy when you have added huge custom image sizes for example. Accelerated Domain Image Resize feature.

/**
* @param bool $boolean Whether to contain the width of all the images in the srcset-attribute to the width of the image in the src-attribute.
*/
function filter_function_name( $boolean ) {
return $boolean;
}
add_filter( 'sb_optimizer_acd_limit_all_srcset_width_to_image_width', 'filter_function_name', 10, 1 );