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; } }