3.15.3
This commit is contained in:
+390
@@ -0,0 +1,390 @@
|
||||
<?php
|
||||
namespace WP_Rocket\Subscriber\Third_Party\Plugins\Images\Webp;
|
||||
|
||||
use WP_Rocket\Admin\Options_Data;
|
||||
use WP_Rocket\Event_Management\Subscriber_Interface;
|
||||
|
||||
/**
|
||||
* Subscriber for the WebP support with EWWW.
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
class EWWW_Subscriber implements Webp_Interface, Subscriber_Interface {
|
||||
use Webp_Common;
|
||||
|
||||
/**
|
||||
* Options_Data instance.
|
||||
*
|
||||
* @var Options_Data
|
||||
* @access private
|
||||
* @author Remy Perona
|
||||
*/
|
||||
private $options;
|
||||
|
||||
/**
|
||||
* EWWW basename.
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
private $plugin_basename;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param Options_Data $options Options instance.
|
||||
*/
|
||||
public function __construct( Options_Data $options ) {
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function get_subscribed_events() {
|
||||
return [
|
||||
'rocket_webp_plugins' => 'register',
|
||||
'wp_rocket_loaded' => 'load_hooks',
|
||||
];
|
||||
}
|
||||
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
/** HOOKS =================================================================================== */
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Launch filters.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
public function load_hooks() {
|
||||
if ( ! $this->options->get( 'cache_webp' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Every time EWWW is (de)activated, we must "sync" our webp cache option.
|
||||
*/
|
||||
if ( did_action( 'activate_' . $this->get_basename() ) ) {
|
||||
$this->plugin_activation();
|
||||
}
|
||||
if ( did_action( 'deactivate_' . $this->get_basename() ) ) {
|
||||
$this->plugin_deactivation();
|
||||
}
|
||||
add_action( 'activate_' . $this->get_basename(), [ $this, 'plugin_activation' ], 20 );
|
||||
add_action( 'deactivate_' . $this->get_basename(), [ $this, 'plugin_deactivation' ], 20 );
|
||||
|
||||
if ( ! function_exists( 'ewww_image_optimizer_get_option' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Since Rocket already updates the config file after updating its options, there is no need to do it again if the CDN or zone options change.
|
||||
* Sadly, we can’t monitor EWWW options accurately to update our config file.
|
||||
*/
|
||||
|
||||
add_filter( 'rocket_cdn_cnames', [ $this, 'maybe_remove_images_cnames' ], 1000, 2 );
|
||||
add_filter( 'rocket_allow_cdn_images', [ $this, 'maybe_remove_images_from_cdn_dropdown' ] );
|
||||
|
||||
$option_names = [
|
||||
'ewww_image_optimizer_exactdn',
|
||||
'ewww_image_optimizer_webp_for_cdn',
|
||||
];
|
||||
|
||||
foreach ( $option_names as $option_name ) {
|
||||
if ( $this->is_active_for_network() ) {
|
||||
add_filter( 'add_site_option_' . $option_name, [ $this, 'trigger_webp_change' ] );
|
||||
add_filter( 'update_site_option_' . $option_name, [ $this, 'trigger_webp_change' ] );
|
||||
add_filter( 'delete_site_option_' . $option_name, [ $this, 'trigger_webp_change' ] );
|
||||
} else {
|
||||
add_filter( 'add_option_' . $option_name, [ $this, 'trigger_webp_change' ] );
|
||||
add_filter( 'update_option_' . $option_name, [ $this, 'trigger_webp_change' ] );
|
||||
add_filter( 'delete_option_' . $option_name, [ $this, 'trigger_webp_change' ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove CDN hosts for images if EWWW uses ExactDN.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param array $hosts List of CDN URLs.
|
||||
* @param array $zones List of zones. Default is [ 'all' ].
|
||||
* @return array
|
||||
*/
|
||||
public function maybe_remove_images_cnames( $hosts, $zones ) {
|
||||
if ( ! $hosts ) {
|
||||
return $hosts;
|
||||
}
|
||||
if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
||||
return $hosts;
|
||||
}
|
||||
// EWWW uses ExactDN: WPR CDN should be disabled for images.
|
||||
if ( ! in_array( 'images', $zones, true ) ) {
|
||||
// Not asking for images.
|
||||
return $hosts;
|
||||
}
|
||||
if ( ! array_diff( $zones, [ 'all', 'images' ] ) ) {
|
||||
// This is clearly for images: return an empty list of hosts.
|
||||
return [];
|
||||
}
|
||||
|
||||
// We also want other things, like js and css: let's only remove the hosts for 'images'.
|
||||
$cdn_urls = $this->options->get( 'cdn_cnames', [] );
|
||||
|
||||
if ( ! $cdn_urls ) {
|
||||
return $hosts;
|
||||
}
|
||||
|
||||
// Separate image hosts from the other ones.
|
||||
$image_hosts = [];
|
||||
$other_hosts = [];
|
||||
$cdn_zones = $this->options->get( 'cdn_zone', [] );
|
||||
|
||||
foreach ( $cdn_urls as $k => $urls ) {
|
||||
if ( ! in_array( $cdn_zones[ $k ], $zones, true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$urls = explode( ',', $urls );
|
||||
$urls = array_map( 'trim', $urls );
|
||||
|
||||
if ( 'images' === $cdn_zones[ $k ] ) {
|
||||
foreach ( $urls as $url ) {
|
||||
$image_hosts[] = $url;
|
||||
}
|
||||
} else {
|
||||
foreach ( $urls as $url ) {
|
||||
$other_hosts[] = $url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the image hosts are not also used for other things (duplicate).
|
||||
$image_hosts = array_diff( $image_hosts, $other_hosts );
|
||||
|
||||
// Then remove the remaining from the final list.
|
||||
return array_diff( $hosts, $image_hosts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe remove the images option from the CDN dropdown.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param bool $allow true to add the option, false otherwise.
|
||||
* @return bool
|
||||
*/
|
||||
public function maybe_remove_images_from_cdn_dropdown( $allow ) {
|
||||
if ( ! $allow ) {
|
||||
return $allow;
|
||||
}
|
||||
if ( ! ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
||||
return $allow;
|
||||
}
|
||||
|
||||
// EWWW uses ExactDN: WPR CDN should be disabled for images.
|
||||
return false;
|
||||
}
|
||||
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
/** PUBLIC TOOLS ============================================================================ */
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Get the plugin name.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_name() {
|
||||
return 'EWWW';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin identifier.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_id() {
|
||||
return 'ewww';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the plugin converts images to webp.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_converting_to_webp() {
|
||||
if ( ! function_exists( 'ewww_image_optimizer_get_option' ) ) {
|
||||
// No EWWW, no webp.
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the plugin serves webp images on frontend.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_serving_webp() {
|
||||
if ( ! function_exists( 'ewww_image_optimizer_get_option' ) ) {
|
||||
// No EWWW, no webp.
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
||||
// EWWW uses ExactDN (WPR CDN should be disabled for images).
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) ) {
|
||||
// EWWW uses JS to rewrite file extensions.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Decide if rewrite rules are used.
|
||||
if ( ! function_exists( 'ewww_image_optimizer_webp_rewrite_verify' ) ) {
|
||||
// Uh?
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'get_home_path' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'extract_from_markers' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/misc.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns null if rules are present and valid. Otherwise it returns rules to be inserted.
|
||||
* Note: this also returns null if WP Fastest Cache rules for webp are found in the file.
|
||||
*
|
||||
* @see ewww_image_optimizer_wpfc_webp_enabled()
|
||||
*/
|
||||
$use_rewrite_rules = ! ewww_image_optimizer_webp_rewrite_verify();
|
||||
|
||||
/**
|
||||
* Filter wether EWW is using rewrite rules for webp.
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param bool $use_rewrite_rules True when EWWW uses rewrite rules. False otherwise.
|
||||
*/
|
||||
return (bool) apply_filters( 'rocket_webp_ewww_use_rewrite_rules', $use_rewrite_rules );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the plugin uses a CDN-compatible technique to serve webp images on frontend.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_serving_webp_compatible_with_cdn() {
|
||||
if ( ! function_exists( 'ewww_image_optimizer_get_option' ) ) {
|
||||
// No EWWW, no webp.
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_exactdn' ) ) {
|
||||
// EWWW uses ExactDN.
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ewww_image_optimizer_get_option( 'ewww_image_optimizer_webp_for_cdn' ) ) {
|
||||
// EWWW uses JS to rewrite file extensions.
|
||||
return true;
|
||||
}
|
||||
|
||||
// At this point, the plugin is using rewrite rules or nothing.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin basename.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function get_basename() {
|
||||
if ( empty( $this->plugin_basename ) ) {
|
||||
$this->plugin_basename = rocket_has_constant( 'EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE' )
|
||||
? plugin_basename( rocket_get_constant( 'EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE' ) )
|
||||
: 'ewww-image-optimizer/ewww-image-optimizer.php';
|
||||
}
|
||||
|
||||
return $this->plugin_basename;
|
||||
}
|
||||
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
/** PRIVATE TOOLS =========================================================================== */
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Tell if EWWW is active for network.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access private
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function is_active_for_network() {
|
||||
static $is;
|
||||
|
||||
if ( isset( $is ) ) {
|
||||
return $is;
|
||||
}
|
||||
|
||||
if ( ! is_multisite() ) {
|
||||
$is = false;
|
||||
return $is;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
|
||||
$is = is_plugin_active_for_network( $this->get_basename() ) && ! get_site_option( 'ewww_image_optimizer_allow_multisite_override' );
|
||||
|
||||
return $is;
|
||||
}
|
||||
}
|
||||
+435
@@ -0,0 +1,435 @@
|
||||
<?php
|
||||
namespace WP_Rocket\Subscriber\Third_Party\Plugins\Images\Webp;
|
||||
|
||||
use WP_Rocket\Admin\Options_Data;
|
||||
use WP_Rocket\Event_Management\Subscriber_Interface;
|
||||
|
||||
/**
|
||||
* Subscriber for the WebP support with Imagify.
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
class Imagify_Subscriber implements Webp_Interface, Subscriber_Interface {
|
||||
use Webp_Common;
|
||||
|
||||
/**
|
||||
* Options_Data instance.
|
||||
*
|
||||
* @var Options_Data
|
||||
* @access private
|
||||
* @author Remy Perona
|
||||
*/
|
||||
private $options;
|
||||
|
||||
/**
|
||||
* Imagify basename.
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
private $plugin_basename;
|
||||
|
||||
/**
|
||||
* Imagify’s "serve webp" option name.
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
private $plugin_option_name_to_serve_webp;
|
||||
|
||||
/**
|
||||
* Temporarily store the result of $this->is_serving_webp().
|
||||
*
|
||||
* @var bool
|
||||
* @access private
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
private $tmp_is_serving_webp;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param Options_Data $options Options instance.
|
||||
*/
|
||||
public function __construct( Options_Data $options ) {
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of events that this subscriber wants to listen to.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_subscribed_events() {
|
||||
return [
|
||||
'rocket_webp_plugins' => 'register',
|
||||
'wp_rocket_loaded' => 'load_hooks',
|
||||
];
|
||||
}
|
||||
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
/** HOOKS =================================================================================== */
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Launch filters.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
public function load_hooks() {
|
||||
if ( ! $this->options->get( 'cache_webp' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Every time Imagify is (de)activated, we must "sync" our webp cache option.
|
||||
*/
|
||||
add_action( 'imagify_activation', [ $this, 'plugin_activation' ], 20 );
|
||||
add_action( 'imagify_deactivation', [ $this, 'plugin_deactivation' ], 20 );
|
||||
|
||||
if ( ! rocket_has_constant( 'IMAGIFY_VERSION' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Since Rocket already updates the config file after updating its options, there is no need to do it again if the CDN or zone options change.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Every time Imagify’s option changes, we must "sync" our webp cache option.
|
||||
*/
|
||||
$option_name = $this->get_option_name_to_serve_webp();
|
||||
|
||||
if ( $this->is_active_for_network() ) {
|
||||
add_filter( 'add_site_option_' . $option_name, [ $this, 'sync_on_network_option_add' ], 10, 3 );
|
||||
add_filter( 'update_site_option_' . $option_name, [ $this, 'sync_on_network_option_update' ], 10, 4 );
|
||||
add_filter( 'pre_delete_site_option_' . $option_name, [ $this, 'store_option_value_before_network_delete' ], 10, 2 );
|
||||
add_filter( 'delete_site_option_' . $option_name, [ $this, 'sync_on_network_option_delete' ], 10, 2 );
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter( 'add_option_' . $option_name, [ $this, 'sync_on_option_add' ], 10, 2 );
|
||||
add_filter( 'update_option_' . $option_name, [ $this, 'sync_on_option_update' ], 10, 2 );
|
||||
add_filter( 'delete_option', [ $this, 'store_option_value_before_delete' ] );
|
||||
add_filter( 'delete_option_' . $option_name, [ $this, 'sync_on_option_delete' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe deactivate webp cache after Imagify network option has been successfully added.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param string $option Name of the network option.
|
||||
* @param mixed $value Value of the network option.
|
||||
* @param int $network_id ID of the network.
|
||||
*/
|
||||
public function sync_on_network_option_add( $option, $value, $network_id ) {
|
||||
if ( get_current_network_id() === $network_id && ! empty( $value['display_webp'] ) ) {
|
||||
$this->trigger_webp_change();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe activate or deactivate webp cache after Imagify network option has been modified.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param string $option Name of the network option.
|
||||
* @param mixed $value Current value of the network option.
|
||||
* @param mixed $old_value Old value of the network option.
|
||||
* @param int $network_id ID of the network.
|
||||
*/
|
||||
public function sync_on_network_option_update( $option, $value, $old_value, $network_id ) {
|
||||
if ( get_current_network_id() === $network_id ) {
|
||||
$this->sync_on_option_update( $old_value, $value );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the Imagify network option value before it is deleted.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param string $option Option name.
|
||||
* @param int $network_id ID of the network.
|
||||
*/
|
||||
public function store_option_value_before_network_delete( $option, $network_id ) {
|
||||
if ( get_current_network_id() === $network_id ) {
|
||||
$this->tmp_is_serving_webp = $this->is_serving_webp();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe activate webp cache after Imagify network option has been deleted.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param string $option Name of the network option.
|
||||
* @param int $network_id ID of the network.
|
||||
*/
|
||||
public function sync_on_network_option_delete( $option, $network_id ) {
|
||||
if ( get_current_network_id() === $network_id && false !== $this->tmp_is_serving_webp ) {
|
||||
$this->trigger_webp_change();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe deactivate webp cache after Imagify option has been successfully added.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param string $option Name of the option to add.
|
||||
* @param mixed $value Value of the option.
|
||||
*/
|
||||
public function sync_on_option_add( $option, $value ) {
|
||||
if ( ! empty( $value['display_webp'] ) ) {
|
||||
$this->trigger_webp_change();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe activate or deactivate webp cache after Imagify option has been modified.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param mixed $old_value The old option value.
|
||||
* @param mixed $value The new option value.
|
||||
*/
|
||||
public function sync_on_option_update( $old_value, $value ) {
|
||||
$old_display = ! empty( $old_value['display_webp'] );
|
||||
$display = ! empty( $value['display_webp'] );
|
||||
|
||||
if ( $old_display !== $display || $old_value['display_webp_method'] !== $value['display_webp_method'] ) {
|
||||
$this->trigger_webp_change();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the Imagify option value before it is deleted.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param string $option Name of the option to delete.
|
||||
*/
|
||||
public function store_option_value_before_delete( $option ) {
|
||||
if ( $this->get_option_name_to_serve_webp() === $option ) {
|
||||
$this->tmp_is_serving_webp = $this->is_serving_webp();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe activate webp cache after Imagify option has been deleted.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param string $option Name of the deleted option.
|
||||
*/
|
||||
public function sync_on_option_delete( $option ) {
|
||||
if ( false !== $this->tmp_is_serving_webp ) {
|
||||
$this->trigger_webp_change();
|
||||
}
|
||||
}
|
||||
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
/** PUBLIC TOOLS ============================================================================ */
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Get the plugin name.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_name() {
|
||||
return 'Imagify';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin identifier.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_id() {
|
||||
return 'imagify';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the plugin converts images to webp.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_converting_to_webp() {
|
||||
if ( ! function_exists( 'get_imagify_option' ) ) {
|
||||
// No Imagify, no webp.
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) get_imagify_option( 'convert_to_webp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the plugin serves webp images on frontend.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_serving_webp() {
|
||||
if ( ! function_exists( 'get_imagify_option' ) ) {
|
||||
// No Imagify, no webp.
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) get_imagify_option( 'display_webp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the plugin uses a CDN-compatible technique to serve webp images on frontend.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_serving_webp_compatible_with_cdn() {
|
||||
if ( ! $this->is_serving_webp() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return 'rewrite' !== get_imagify_option( 'display_webp_method' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin basename.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function get_basename() {
|
||||
if ( empty( $this->plugin_basename ) ) {
|
||||
$this->plugin_basename = rocket_has_constant( 'IMAGIFY_FILE' )
|
||||
? plugin_basename( rocket_get_constant( 'IMAGIFY_FILE' ) )
|
||||
: 'imagify/imagify.php';
|
||||
}
|
||||
|
||||
return $this->plugin_basename;
|
||||
}
|
||||
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
/** PRIVATE TOOLS =========================================================================== */
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Get the name of the Imagify’s "serve webp" option.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access private
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function get_option_name_to_serve_webp() {
|
||||
if ( ! empty( $this->plugin_option_name_to_serve_webp ) ) {
|
||||
return $this->plugin_option_name_to_serve_webp;
|
||||
}
|
||||
|
||||
$default = 'imagify_settings';
|
||||
|
||||
if ( ! class_exists( '\Imagify_Options' ) || ! method_exists( '\Imagify_Options', 'get_instance' ) ) {
|
||||
$this->plugin_option_name_to_serve_webp = $default;
|
||||
return $this->plugin_option_name_to_serve_webp;
|
||||
}
|
||||
|
||||
$instance = \Imagify_Options::get_instance();
|
||||
|
||||
if ( ! method_exists( $instance, 'get_option_name' ) ) {
|
||||
$this->plugin_option_name_to_serve_webp = $default;
|
||||
return $this->plugin_option_name_to_serve_webp;
|
||||
}
|
||||
|
||||
$this->plugin_option_name_to_serve_webp = $instance->get_option_name();
|
||||
|
||||
return $this->plugin_option_name_to_serve_webp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if Imagify is active for network.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access private
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function is_active_for_network() {
|
||||
static $is;
|
||||
|
||||
if ( isset( $is ) ) {
|
||||
return $is;
|
||||
}
|
||||
|
||||
if ( function_exists( 'imagify_is_active_for_network' ) ) {
|
||||
$is = imagify_is_active_for_network();
|
||||
return $is;
|
||||
}
|
||||
|
||||
if ( ! is_multisite() ) {
|
||||
$is = false;
|
||||
return $is;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
|
||||
$is = is_plugin_active_for_network( $this->get_basename() );
|
||||
|
||||
return $is;
|
||||
}
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
namespace WP_Rocket\Subscriber\Third_Party\Plugins\Images\Webp;
|
||||
|
||||
use WP_Rocket\Event_Management\Subscriber_Interface;
|
||||
|
||||
/**
|
||||
* Subscriber for the WebP support with Optimus.
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
class Optimus_Subscriber implements Webp_Interface, Subscriber_Interface {
|
||||
|
||||
/**
|
||||
* Optimus basename.
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
private $plugin_basename;
|
||||
|
||||
/**
|
||||
* Returns an array of events that this subscriber wants to listen to.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_subscribed_events() {
|
||||
if ( ! defined( 'OPTIMUS_FILE' ) ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
'rocket_webp_plugins' => 'register',
|
||||
];
|
||||
}
|
||||
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
/** HOOKS =================================================================================== */
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Register the plugin.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param array $webp_plugins An array of Webp_Interface objects.
|
||||
* @return array
|
||||
*/
|
||||
public function register( $webp_plugins ) {
|
||||
$webp_plugins[] = $this;
|
||||
return $webp_plugins;
|
||||
}
|
||||
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
/** PUBLIC TOOLS ============================================================================ */
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Get the plugin name.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_name() {
|
||||
return 'Optimus';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin identifier.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_id() {
|
||||
return 'optimus';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the plugin converts images to webp.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_converting_to_webp() {
|
||||
if ( class_exists( '\Optimus' ) && method_exists( '\Optimus', 'get_options' ) ) {
|
||||
$options = \Optimus::get_options();
|
||||
} else {
|
||||
$options = get_option( 'optimus' );
|
||||
}
|
||||
|
||||
return ! empty( $options['webp_convert'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the plugin serves webp images on frontend.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_serving_webp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the plugin uses a CDN-compatible technique to serve webp images on frontend.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_serving_webp_compatible_with_cdn() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin basename.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function get_basename() {
|
||||
if ( empty( $this->plugin_basename ) ) {
|
||||
$this->plugin_basename = defined( 'OPTIMUS_FILE' ) ? plugin_basename( OPTIMUS_FILE ) : 'optimus/optimus.php';
|
||||
}
|
||||
|
||||
return $this->plugin_basename;
|
||||
}
|
||||
}
|
||||
+294
@@ -0,0 +1,294 @@
|
||||
<?php
|
||||
namespace WP_Rocket\Subscriber\Third_Party\Plugins\Images\Webp;
|
||||
|
||||
use WP_Rocket\Admin\Options_Data;
|
||||
use WP_Rocket\Event_Management\Subscriber_Interface;
|
||||
|
||||
/**
|
||||
* Subscriber for the WebP support with ShortPixel.
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
class ShortPixel_Subscriber implements Webp_Interface, Subscriber_Interface {
|
||||
use Webp_Common;
|
||||
|
||||
/**
|
||||
* Options_Data instance.
|
||||
*
|
||||
* @var Options_Data
|
||||
* @access private
|
||||
* @author Remy Perona
|
||||
*/
|
||||
private $options;
|
||||
|
||||
/**
|
||||
* ShortPixel basename.
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
private $plugin_basename;
|
||||
|
||||
/**
|
||||
* ShortPixel’s "serve webp" option name.
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
private $plugin_option_name_to_serve_webp = 'wp-short-pixel-create-webp-markup';
|
||||
|
||||
/**
|
||||
* Temporarily store the result of $this->is_serving_webp().
|
||||
*
|
||||
* @var bool
|
||||
* @access private
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
private $tmp_is_serving_webp;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param Options_Data $options Options instance.
|
||||
*/
|
||||
public function __construct( Options_Data $options ) {
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of events that this subscriber wants to listen to.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_subscribed_events() {
|
||||
return [
|
||||
'rocket_webp_plugins' => 'register',
|
||||
'wp_rocket_loaded' => 'load_hooks',
|
||||
];
|
||||
}
|
||||
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
/** HOOKS =================================================================================== */
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Launch filters.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
public function load_hooks() {
|
||||
if ( ! $this->options->get( 'cache_webp' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Every time ShortPixel is (de)activated, we must "sync" our webp cache option.
|
||||
*/
|
||||
if ( did_action( 'activate_' . $this->get_basename() ) ) {
|
||||
$this->plugin_activation();
|
||||
}
|
||||
if ( did_action( 'deactivate_' . $this->get_basename() ) ) {
|
||||
$this->plugin_deactivation();
|
||||
}
|
||||
add_action( 'activate_' . $this->get_basename(), [ $this, 'plugin_activation' ], 20 );
|
||||
add_action( 'deactivate_' . $this->get_basename(), [ $this, 'plugin_deactivation' ], 20 );
|
||||
|
||||
if ( ! defined( 'SHORTPIXEL_IMAGE_OPTIMISER_VERSION' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Since Rocket already updates the config file after updating its options, there is no need to do it again if the CDN or zone options change.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Every time ShortPixel’s option changes, we must "sync" our webp cache option.
|
||||
*/
|
||||
$option_name = $this->plugin_option_name_to_serve_webp;
|
||||
|
||||
add_filter( 'add_option_' . $option_name, [ $this, 'sync_on_option_add' ], 10, 2 );
|
||||
add_filter( 'update_option_' . $option_name, [ $this, 'sync_on_option_update' ], 10, 2 );
|
||||
add_filter( 'delete_option', [ $this, 'store_option_value_before_delete' ] );
|
||||
add_filter( 'delete_option_' . $option_name, [ $this, 'sync_on_option_delete' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe deactivate webp cache after ShortPixel option has been successfully added.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param string $option Name of the option to add.
|
||||
* @param mixed $value Value of the option.
|
||||
*/
|
||||
public function sync_on_option_add( $option, $value ) {
|
||||
if ( $value ) {
|
||||
$this->trigger_webp_change();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe activate or deactivate webp cache after ShortPixel option has been modified.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param mixed $old_value The old option value.
|
||||
* @param mixed $value The new option value.
|
||||
*/
|
||||
public function sync_on_option_update( $old_value, $value ) {
|
||||
/**
|
||||
* 0 = Don’t serve webp.
|
||||
* 1 = <picture> + buffer
|
||||
* 2 = <picture> + hooks
|
||||
* 3 = .htaccess
|
||||
*/
|
||||
$old_value = $old_value > 0;
|
||||
$value = $value > 0;
|
||||
|
||||
if ( $old_value !== $value ) {
|
||||
$this->trigger_webp_change();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the ShortPixel option value before it is deleted.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param string $option Name of the option to delete.
|
||||
*/
|
||||
public function store_option_value_before_delete( $option ) {
|
||||
if ( $this->plugin_option_name_to_serve_webp === $option ) {
|
||||
$this->tmp_is_serving_webp = $this->is_serving_webp();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe activate webp cache after ShortPixel option has been deleted.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
public function sync_on_option_delete() {
|
||||
if ( false !== $this->tmp_is_serving_webp ) {
|
||||
$this->trigger_webp_change();
|
||||
}
|
||||
}
|
||||
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
/** PUBLIC TOOLS ============================================================================ */
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Get the plugin name.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_name() {
|
||||
return 'ShortPixel';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin identifier.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_id() {
|
||||
return 'shortpixel';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the plugin converts images to webp.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_converting_to_webp() {
|
||||
return (bool) get_option( 'wp-short-create-webp' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the plugin serves webp images on frontend.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_serving_webp() {
|
||||
return (bool) get_option( $this->plugin_option_name_to_serve_webp );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the plugin uses a CDN-compatible technique to serve webp images on frontend.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_serving_webp_compatible_with_cdn() {
|
||||
$display = (int) get_option( $this->plugin_option_name_to_serve_webp );
|
||||
|
||||
if ( ! $display ) {
|
||||
// The option is not enabled, no webp.
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( 3 === $display ) {
|
||||
// The option is set to "rewrite rules".
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin basename.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function get_basename() {
|
||||
if ( empty( $this->plugin_basename ) ) {
|
||||
$this->plugin_basename = defined( 'SHORTPIXEL_PLUGIN_FILE' ) ? plugin_basename( SHORTPIXEL_PLUGIN_FILE ) : 'shortpixel-image-optimiser/wp-shortpixel.php';
|
||||
}
|
||||
|
||||
return $this->plugin_basename;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
namespace WP_Rocket\Subscriber\Third_Party\Plugins\Images\Webp;
|
||||
|
||||
/**
|
||||
* Trait for webp subscribers, focussed on plugins that serve webp images on frontend.
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
trait Webp_Common {
|
||||
|
||||
/**
|
||||
* Register the plugin.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*
|
||||
* @param array $webp_plugins An array of Webp_Interface objects.
|
||||
* @return array
|
||||
*/
|
||||
public function register( $webp_plugins ) {
|
||||
$webp_plugins[] = $this;
|
||||
return $webp_plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* On plugin activation, deactivate Rocket webp cache if the plugin is serving webp.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
public function plugin_activation() {
|
||||
if ( $this->is_serving_webp() ) {
|
||||
$this->trigger_webp_change();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On plugin deactivation, activate Rocket webp cache if the plugin is serving webp.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
public function plugin_deactivation() {
|
||||
if ( $this->is_serving_webp() ) {
|
||||
$this->trigger_webp_change();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger an action when the webp feature is enabled/disabled in a third party plugin.
|
||||
*
|
||||
* @since 3.4
|
||||
* @access public
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
public function trigger_webp_change() {
|
||||
/**
|
||||
* Trigger an action when the webp feature is enabled/disabled in a third party plugin.
|
||||
*
|
||||
* @since 3.4
|
||||
* @author Grégory Viguier
|
||||
*/
|
||||
do_action( 'rocket_third_party_webp_change' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
namespace WP_Rocket\Subscriber\Third_Party\Plugins\Images\Webp;
|
||||
|
||||
/**
|
||||
* Interface to use for webp subscribers.
|
||||
*
|
||||
* @since 3.4
|
||||
*/
|
||||
interface Webp_Interface {
|
||||
|
||||
/**
|
||||
* Get the plugin name.
|
||||
*
|
||||
* @since 3.4
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_name();
|
||||
|
||||
/**
|
||||
* Get the plugin identifier.
|
||||
*
|
||||
* @since 3.4
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_id();
|
||||
|
||||
/**
|
||||
* Tell if the plugin converts images to webp.
|
||||
*
|
||||
* @since 3.4
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_converting_to_webp();
|
||||
|
||||
/**
|
||||
* Tell if the plugin serves webp images on frontend.
|
||||
*
|
||||
* @since 3.4
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_serving_webp();
|
||||
|
||||
/**
|
||||
* Tell if the plugin uses a CDN-compatible technique to serve webp images on frontend.
|
||||
*
|
||||
* @since 3.4
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_serving_webp_compatible_with_cdn();
|
||||
|
||||
/**
|
||||
* Get the plugin basename.
|
||||
*
|
||||
* @since 3.4
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_basename();
|
||||
}
|
||||
Reference in New Issue
Block a user