00;--wp--preset--color--luminous-vivid-amber: #fcb900;--wp--preset--color--light-green-cyan: #7bdcb5;--wp--preset--color--vivid-green-cyan: #00d084;--wp--preset--color--pale-cyan-blue: #8ed1fc;--wp--preset--color--vivid-cyan-blue: #0693e3;--wp--preset--color--vivid-purple: #9b51e0;--wp--preset--gradient--vivid-cyan-blue-to-vivid-purple: linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%);--wp--preset--gradient--light-green-cyan-to-vivid-green-cyan: linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%);--wp--preset--gradient--luminous-vivid-amber-to-luminous-vivid-orange: linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%);--wp--preset--gradient--luminous-vivid-orange-to-vivid-red: linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%);--wp--preset--gradient--very-light-gray-to-cyan-bluish-gray: linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%);--wp--preset--gradient--cool-to-warm-spectrum: linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%);--wp--preset--gradient--blush-light-purple: linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%);--wp--preset--gradient--blush-bordeaux: linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%);--wp--preset--gradient--luminous-dusk: linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%);--wp--preset--gradient--pale-ocean: linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%);--wp--preset--gradient--electric-grass: linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%);--wp--preset--gradient--midnight: linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%);--wp--preset--font-size--small: 13px;--wp--preset--font-size--medium: 20px;--wp--preset--font-size--large: 36px;--wp--preset--font-size--x-large: 42px;--wp--preset--spacing--20: 0.44rem;--wp--preset--spacing--30: 0.67rem;--wp--preset--spacing--40: 1rem;--wp--preset--spacing--50: 1.5rem;--wp--preset--spacing--60: 2.25rem;--wp--preset--spacing--70: 3.38rem;--wp--preset--spacing--80: 5.06rem;--wp--preset--shadow--natural: 6px 6px 9px rgba(0, 0, 0, 0.2);--wp--preset--shadow--deep: 12px 12px 50px rgba(0, 0, 0, 0.4);--wp--preset--shadow--sharp: 6px 6px 0px rgba(0, 0, 0, 0.2);--wp--preset--shadow--outlined: 6px 6px 0px -3px rgba(255, 255, 255, 1), 6px 6px rgba(0, 0, 0, 1);--wp--preset--shadow--crisp: 6px 6px 0px rgba(0, 0, 0, 1);}:where(.is-layout-flex){gap: 0.5em;}:where(.is-layout-grid){gap: 0.5em;}body .is-layout-flex{display: flex;}.is-layout-flex{flex-wrap: wrap;align-items: center;}.is-layout-flex > :is(*, div){margin: 0;}body .is-layout-grid{display: grid;}.is-layout-grid > :is(*, div){margin: 0;}:where(.wp-block-columns.is-layout-flex){gap: 2em;}:where(.wp-block-columns.is-layout-grid){gap: 2em;}:where(.wp-block-post-template.is-layout-flex){gap: 1.25em;}:where(.wp-block-post-template.is-layout-grid){gap: 1.25em;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-color{color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-color{color: var(--wp--preset--color--white) !important;}.has-pale-pink-color{color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-color{color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-color{color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-color{color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-color{color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-color{color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-color{color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-color{color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-color{color: var(--wp--preset--color--vivid-purple) !important;}.has-black-background-color{background-color: var(--wp--pr $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 whether 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; } }