DEPRECATED LSCWP Third Party Plugin Integration Framework

The following elements have been deprecated. Please see this page for the most current information.

Components

  1. A class to handle the compatibility code. A template is available below.
  2. Initiator for the class. Can be in the plugin's own file space or appended to the registry.

API/Functions

lscwp_purge_single_post

If a plugin does something that may update pages, such as a “like” button that updates a counter using ajax for example, add the following to purge the updated pages from cache.

if (defined('LITESPEED_CACHE_ENABLED')) {
     do_action('lscwp_purge_single_post', $post_id);
}

Note: This action may be called multiple times for multiple post ids if needed, but it must be called prior to any response body output. This includes any 'echo' outputs.

The $tag parameter

This parameter is used to distinguish pages. Generally speaking, there are two components to the tag, the name and the ID. That said, any number of components are allowed. Each component should be separated via a period, '.'.

The name should be short, but unique. As an example, if the plugin MySlideShowPlugin has a class SlideShow, it might use MSSP_SS.1.

LiteSpeed_Cache_Tags::add_cache_tag($tag)

Adds a single or group of cache tags to the list of cache tags associated with the current page. These will be appended to the LiteSpeed Cache Plugin generated list of cache tags. This may be useful to purge by a custom tag rather than resorting to the WordPress site wide tags.

Parameters

$tag String/Array A (list of) cache tag(s) to associate with the page.

LiteSpeed_Cache_Tags::add_purge_tag($tag)

Adds a single or group of purge tags to the list of tags to be purged with the request. This may be useful for situations where another plugin needs to purge custom cache tags or associated pages.

Parameters

$tag String/Array A (list of) purge tag(s) to append to the list.

Adds a single or group of vary cookies to the list of cookies to vary the page on. This may be useful for situations where a page is displayed differently depending on a cookie. For example, a different page based on language.

Parameters

$cookie String/Array A (list of) vary cookie(s) to append to the list.

LiteSpeed_Cache_Tags::set_use_frontpage_ttl()

Notify the plugin to use the front page TTL for this page.

LiteSpeed_Cache_Tags::set_mobile()

Notify the plugin that this page was built for a mobile display.

LiteSpeed_Cache_Tags::set_noncacheable()

Notify the plugin that this page is not cacheable. This is meant to be used outside of the litespeed_cache_is_cacheable filter.

LiteSpeed_Cache_Tags::get_cache_tags()

LiteSpeed_Cache_Tags::get_purge_tags()

LiteSpeed_Cache_Tags::get_vary_cookies()

LiteSpeed_Cache_Tags::get_use_frontpage_ttl()

LiteSpeed_Cache_Tags::is_mobile()

LiteSpeed_Cache_Tags::is_noncacheable()

Hook Points

These hook points are provided for hooking into the cache's run time functionality. It is not required to hook into any of these hook points; these are provided more for convenience. It is possible that a plugin only needs to hook into its own hook points.

Action - litespeed_cache_detect_thirdparty

This action may be used to check if it is necessary to add any further functionality to the current request. For example, if a user visits a shopping page, there is no need for the forum plugin to do its extra checks/add its tags because the page is unrelated.

If, however, the callback determines that it is a forum page, it is recommended to add any needed actions/filters in the callback.

Action - litespeed_cache_on_purge_post

Triggered when a post is about to be purged. Use this hook point if purging a page should purge other pages related to your plugin.

An example use case: Suppose a user replies to a forum topic. This will cause the forum topic to be purged. When the plugin is about to notify the server, the forum plugin will see that the cache is about to purge the topic page. The plugin then adds purge tags, notifying the server to purge the forum and forum list as well. This ensures that all related pages are up to date.

Action - litespeed_cache_add_purge_tags

Called at the end of every request. This hook provides an access point to any plugin that needs to add purge tags to the current request.

Action - litespeed_cache_add_cache_tags

Called at the end of every cacheable request. This hook provides an access point to any plugin that needs to add cache tags to the current request.

Filter - litespeed_cache_is_cacheable($cacheable)

Triggered when the cache plugin is checking if the current page is cacheable. This filter will not trigger on admin pages nor regular pages when visited by a logged in user.

Parameters

$cacheable boolean Represents whether a previous filter determined the cache to be cacheable or not. If this is false, it is strongly recommended to return false immediately to optimize performance.

Returns

  • boolean True if cacheable, false otherwise. If $cacheable was false and true is returned, the result is undefined behavior.

Filter - litespeed_cache_get_options($options)

Triggered when getting a list of third party options. This will gather all option keys that third party plugins may require.

Parameters

$options array The list of option keys.

Returns

  • array The updated list of option keys.

Filter - litespeed_cache_add_config_tab($tp_tabs, $options, $option_name)

This hook allows third party plugins to create litespeed cache specific configurations.

Each config should append an array containing the following:

  • 'title' (required) - The tab's title.
  • 'slug' (required) - The slug used for the tab. [a-z][A-Z], [0-9], -, _ permitted.
  • 'content' (required) - The tab's content.

Upon saving, only the options with the option group in the input's name will be retrieved. For example, name=“litespeed-cache-conf[my-opt]”.

Parameters

$tp_tabs array An array of third party configurations as described above.

$options array The current configuration options.

$option_group string The option group to use for options.

$disableall boolean Whether to disable the settings or not.

Returns

  • mixed An array of third party configs else false on failure.

Filter - litespeed_cache_save_options($options, $input)

Triggered when the admin saves the LiteSpeed cache options. It will pass in the current options and input options.

Parameters

$options array The current configuration options.

$input array The input configuration options.

Returns

  • array The updated configuration options.
 
litespeed_wiki/cache/lscwp/api/deprecated.txt · Last modified: 2017/08/22 19:08 by Lisa Clarke