Файловый менеджер - Редактировать - /var/www/xthruster/html/wp-content/uploads/flags/compatibilities.tar
Назад
wp_bakery.php 0000644 00000002601 14717653355 0007257 0 ustar 00 <?php /** * Class Optml_wp_bakery * * @reason Adding images from wpbakery pages to offload. */ class Optml_wp_bakery extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'js_composer/js_composer.php' ) && Optml_Main::instance()->admin->settings->get( 'offload_media' ) === 'enabled'; } /** * Register integration details. */ public function register() { add_filter( 'optml_content_images_to_update', [ $this, 'add_images_from_wp_bakery_to_offload' ], PHP_INT_MAX, 2 ); } /** * Ads the product pages to the list of posts parents when querying images for offload. * * @param array $found_images The found images from the default workflow. * @param string $content Post content to look for images. * * @return array The images array with the specific bakery images. */ public function add_images_from_wp_bakery_to_offload( $found_images, $content ) { $regex = '/image="(\d+)"/Uu'; preg_match_all( $regex, $content, $images_to_append ); return array_merge( $found_images, $images_to_append[1] ); } /** * Should we early load the compatibility? * * @return bool Whether to load the compatibility or not. */ public function should_load_early() { return true; } } metaslider.php 0000644 00000004056 14717653355 0007433 0 ustar 00 <?php /** * Class Optml_metaslider. * * @reason Metaslider behaves strange when the noscript tag is present near the image tag. */ class Optml_metaslider extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'ml-slider/ml-slider.php' ) || is_plugin_active( 'ml-slider-pro/ml-slider-pro.php' ); } /** * Register integration details. */ public function register() { add_filter( 'optml_ignore_noscript_on', [ $this, 'add_noscript_flags' ], PHP_INT_MAX, 1 ); add_filter( 'optml_possible_lazyload_flags', [ $this, 'add_ignore_lazyload' ], PHP_INT_MAX, 1 ); add_filter( 'optml_watcher_lz_classes', [ $this, 'add_watcher_class' ], 10 ); add_filter( 'metaslider_coin_slider_image_attributes', [ $this, 'setup_listner' ], PHP_INT_MAX, 1 ); add_filter( 'optml_lazyload_bg_selectors', function ( $all_watchers ) { $all_watchers[] = '.coin-slider > .coin-slider > a'; $all_watchers[] = '.coin-slider > .coin-slider'; return $all_watchers; } ); } /** * Disable lazyload on coinslider type. * * @param array $attributes Old attributes. * * @return mixed Slider attributes. */ public function setup_listner( $attributes ) { $attributes['class'] .= 'no-optml-lazyload'; return $attributes; } /** * Add ignore lazyload flag. * * @param array $flags Old flags. * * @return array New flags. */ public function add_ignore_lazyload( $flags = [] ) { $flags[] = 'no-optml-lazyload'; return $flags; } /** * Add nive slider watcher class. * * @param array $classes Old watcher. * * @return array New watchers. */ public function add_watcher_class( $classes ) { $classes[] = 'nivo-main-image'; return $classes; } /** * Return metaslider flags. * * @param array $flags Old flags. * * @return array New flags. */ public function add_noscript_flags( $flags = [] ) { $flags[] = 'slide-'; return $flags; } } w3_total_cache.php 0000644 00000002027 14717653355 0010155 0 ustar 00 <?php /** * Class Optml_w3_total_cache. * * @reason Cache_w3_total_cache stores the content of the page before Optimole starts replacing url's */ class Optml_w3_total_cache extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'w3-total-cache/w3-total-cache.php' ); } /** * Register integration details. */ public function register() { if ( Optml_Main::instance()->admin->settings->get( 'cdn' ) === 'enabled' ) { add_filter( 'w3tc_minify_processed', [ Optml_Main::instance()->manager, 'replace_content' ], 10 ); } add_action( 'optml_settings_updated', function () { if ( function_exists( 'w3tc_flush_all' ) ) { w3tc_flush_all(); } } ); } /** * Should we early load the compatibility? * * @return bool Whether to load the compatibility or not. */ public function should_load_early() { return true; } } sg_optimizer.php 0000644 00000001327 14717653355 0010013 0 ustar 00 <?php /** * Class Optml_sg_optimizer. * * @reason Sg_optimizer has ob_start on init */ class Optml_sg_optimizer extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return Optml_Main::instance()->admin->settings->get( 'cdn' ) === 'enabled' && is_plugin_active( 'sg-cachepress/sg-cachepress.php' ); } /** * Register integration details. */ public function register() { add_action( 'init', [ Optml_Main::instance()->manager, 'process_template_redirect_content', ], defined( 'OPTML_SITE_MIRROR' ) ? PHP_INT_MAX : PHP_INT_MIN ); } } smart_search_woocommerce.php 0000644 00000002321 14717653355 0012345 0 ustar 00 <?php /** * Class Optml_smart_search_woocommerce. * * @reason Smart search by searchanise stores the content of the image urls before they are processed. */ class Optml_smart_search_woocommerce extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'smart-search-for-woocommerce/woocommerce-searchanise.php' ); } /** * Register integration details. */ public function register() { add_filter( 'se_get_product_image_post', [ $this, 'filter_image_url' ], 1, 3 ); } /** * Process image url before is send to the server. * * @param string $image_url The original image url. * @param int $image_id The image id . * @param int $size The image size. * @return string */ public function filter_image_url( $image_url, $image_id, $size ) { Optml_Url_Replacer::instance()->init(); return apply_filters( 'optml_content_url', $image_url ); } /** * Should we early load the compatibility? * * @return bool Whether to load the compatibility or not. */ public function should_load_early() { return true; } } master_slider.php 0000644 00000001743 14717653355 0010137 0 ustar 00 <?php /** * Class Optml_master_slider. * * @reason Added classes to watch for background lazyload, * we can only hook the css before storing in db ('masterslider_get_all_custom_css'), but we can not reliably regenerate it when settings are changing */ class Optml_master_slider extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'master-slider/master-slider.php' ); } /** * Register integration details. */ public function register() { add_filter( 'optml_lazyload_bg_selectors', function ( $all_watchers ) { $all_watchers[] = '.master-slider'; return $all_watchers; } ); add_filter( 'optml_dont_replace_url', function ( $old, $url = null ) { if ( strpos( $url, 'blank.gif' ) !== false ) { return true; } return $old; }, 10, 2 ); } } cache_enabler.php 0000644 00000001776 14717653355 0010043 0 ustar 00 <?php /** * Class Optml_cache_enabler. * * @reason Cache_enabler stores the content of the page before Optimole starts replacing url's */ class Optml_cache_enabler extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'cache-enabler/cache-enabler.php' ); } /** * Register integration details. */ public function register() { // www.keycdn.com/support/wordpress-cache-enabler-plugin#hooks add_filter( 'cache_enabler_page_contents_before_store', [ Optml_Main::instance()->manager, 'replace_content' ], PHP_INT_MAX, 1 ); add_action( 'optml_settings_updated', function () { do_action( 'cache_enabler_clear_site_cache' ); } ); } /** * Should we early load the compatibility? * * @return bool Whether to load the compatibility or not. */ public function should_load_early() { return true; } } divi_builder.php 0000644 00000004450 14717653355 0007741 0 ustar 00 <?php /** * Class Optml_divi_builder * * @reason Adding selectors for background lazyload */ class Optml_divi_builder extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { return ( strcmp( wp_get_theme(), 'Divi' ) === 0 || is_plugin_active( 'divi-builder/divi-builder.php' ) ); } /** * Register integration details. */ public function register() { add_action( 'et_core_static_file_created', [ $this, 'optimize_divi_static_files' ] ); add_action( 'optml_settings_updated', [ $this, 'clear_divi_static_files' ] ); add_filter( 'optml_lazyload_bg_selectors', function ( $all_watchers ) { $all_watchers[] = '.et_pb_slides > .et_pb_slide'; $all_watchers[] = '.et_parallax_bg'; $all_watchers[] = '.et_pb_video_overlay'; $all_watchers[] = '.et_pb_module:not([class*="et_pb_blog"])'; $all_watchers[] = '.et_pb_row'; $all_watchers[] = '.et_pb_section.et_pb_section_1'; $all_watchers[] = '.et_pb_with_background'; return $all_watchers; } ); } /** * Replace image urls upon divi's static css files creation * * @param ET_Core_PageResource $page_resource ET_Core_PageResource object. * @return void */ public function optimize_divi_static_files( $page_resource ) { if ( class_exists( 'ET_Core_PageResource' ) && null !== ET_Core_PageResource::$wpfs ) { if ( isset( $page_resource->path ) ) { $data = $page_resource->get_data( 'file' ); if ( ! empty( $data ) ) { $data = Optml_Main::instance()->manager->replace_content( $data ); ET_Core_PageResource::$wpfs->put_contents( $page_resource->path, $data, 0644 ); } } } } /** * Clear divi static files when plugin settings are changed * * @return void */ public function clear_divi_static_files() { if ( class_exists( 'ET_Core_PageResource' ) && method_exists( ET_Core_PageResource::class, 'remove_static_resources' ) ) { // same call as in et_core_page_resource_auto_clear but that function is not declared at this point ET_Core_PageResource::remove_static_resources( 'all', 'all' ); } } /** * Should we early load the compatibility? * * @return bool Whether to load the compatibility or not. */ public function should_load_early() { return true; } } give_wp.php 0000644 00000002551 14717653355 0006740 0 ustar 00 <?php /** * Class Optml_elementor_builder * * @reason Adding selectors for background lazyload */ class Optml_give_wp extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return Optml_Main::instance()->admin->settings->use_lazyload() && is_plugin_active( 'give/give.php' ); } /** * Register integration details. */ public function register() { add_filter( 'optml_should_ignore_image_tags', [ $this, 'check_givewp_page' ], 10 ); if ( Optml_Main::instance()->admin->settings->get( 'video_lazyload' ) === 'enabled' ) { add_filter( 'optml_iframe_lazyload_flags', [ $this, 'add_ignore_lazyload_iframe' ] ); } } /** * Add ignore page lazyload flag. * * @param bool $old_value Previous returned value. * * @return bool If we should lazyload the page. */ public function check_givewp_page( $old_value ) { if ( array_key_exists( 'giveDonationFormInIframe', $_GET ) && $_GET['giveDonationFormInIframe'] === '1' ) { return true; } return $old_value; } /** * Add ignore lazyload iframe flag. * * @param array $flags Old flags. * * @return array New flags. */ public function add_ignore_lazyload_iframe( $flags = [] ) { $flags[] = 'give-embed-form'; return $flags; } } jet_elements.php 0000644 00000001431 14717653355 0007752 0 ustar 00 <?php /** * Class Optml_jet_elements. * * @reason Disable lazyload on jetelements slider. */ class Optml_jet_elements extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'jet-elements/jet-elements.php' ); } /** * Register integration details. */ public function register() { add_filter( 'optml_possible_lazyload_flags', [ $this, 'add_ignore_lazyload' ], PHP_INT_MAX, 1 ); } /** * Add ignore lazyload flag. * * @param array $flags Old flags. * * @return array New flags. */ public function add_ignore_lazyload( $flags = [] ) { $flags[] = 'sp-image'; return $flags; } } envira.php 0000644 00000004005 14717653355 0006560 0 ustar 00 <?php use Optimole\Sdk\Resource\ImageProperty\ResizeTypeProperty; use Optimole\Sdk\ValueObject\Position; /** * Class Optml_shortcode_ultimate. * * @reason The gallery output contains a different src attribute used for lazyload * which prevented optimole to parse the tag. */ class Optml_envira extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return ( is_plugin_active( 'envira-gallery-lite/envira-gallery-lite.php' ) || is_plugin_active( 'envira-gallery/envira-gallery.php' ) ); } /** * Register integration details. */ public function register() { add_filter( 'optml_possible_lazyload_flags', [ $this, 'add_lazyflag' ], 10 ); add_filter( 'optml_parse_resize_from_tag', [ $this, 'check_resize_tag' ], 10, 2 ); add_filter( 'envira_gallery_image_src', [ $this, 'revert_src' ], 10 ); } /** * Revert the optimole url to the original state in * order to allow to be parsed by the image tag parser. * * @param string $image Image url. * * @return string Original url. */ public function revert_src( $image ) { $pos = strpos( $image, '/http' ); if ( $pos !== false ) { return ltrim( substr( $image, $pos ), '/' ); } return $image; } /** * Alter default resize for image tag parsing. * * @param array $old_resize Old array, if any. * @param string $tag Image tag. * * @return array Resize conf. */ public function check_resize_tag( $old_resize, $tag ) { if ( preg_match( '/(_c)\.(?:' . implode( '|', array_keys( Optml_Config::$image_extensions ) ) . ')/i', $tag, $match ) ) { return [ 'type' => ResizeTypeProperty::FILL, 'gravity' => Position::CENTER, ]; } return []; } /** * Add envira lazyload flag. * * @param array $strings Old strings. * * @return array New flags. */ public function add_lazyflag( $strings = [] ) { $strings[] = 'envira-gallery-image'; return $strings; } } otter_blocks.php 0000644 00000002201 14717653355 0007762 0 ustar 00 <?php /** * Class Optml_otter_blocks. * * @reason Adding selectors for background lazyload */ class Optml_otter_blocks extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'otter-blocks/otter-blocks.php' ); } /** * Register integration details. */ public function register() { add_filter( 'optml_lazyload_bg_selectors', function ( $all_watchers ) { $all_watchers[] = '.o-flip-front'; $all_watchers[] = '.o-flip-back'; $all_watchers[] = '.wp-block-themeisle-blocks-advanced-columns'; $all_watchers[] = '.wp-block-themeisle-blocks-advanced-columns-overlay'; $all_watchers[] = '.wp-block-themeisle-blocks-advanced-column'; $all_watchers[] = '.wp-block-themeisle-blocks-advanced-column-overlay'; return $all_watchers; } ); // Replace the image URL with the optimized one in Otter-generated CSS. add_filter( 'otter_apply_dynamic_image', [ Optml_Main::instance()->manager->url_replacer, 'build_url' ], 99 ); } } elementor_builder_late.php 0000644 00000002652 14717653355 0012007 0 ustar 00 <?php /** * Class Optml_elementor_builder_late * * @reason Adding action for elementor meta replacement */ class Optml_elementor_builder_late extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'elementor/elementor.php' ); } /** * Register integration details. */ public function register() { add_filter( 'get_post_metadata', [ $this, 'replace_meta' ], PHP_INT_MAX, 4 ); } /** * Replace urls in post meta values. * * @param mixed $metadata Metadata. * @param int $object_id Post id. * @param string $meta_key Meta key. * @param bool $single Is single. * * @return mixed Altered meta. */ public function replace_meta( $metadata, $object_id, $meta_key, $single ) { $meta_needed = '_elementor_data'; if ( ! empty( $meta_key ) && $meta_needed === $meta_key ) { remove_filter( 'get_post_metadata', [ $this, 'replace_meta' ], PHP_INT_MAX ); $current_meta = get_post_meta( $object_id, $meta_needed, $single ); add_filter( 'get_post_metadata', [ $this, 'replace_meta' ], PHP_INT_MAX, 4 ); if ( ! is_string( $current_meta ) ) { return $metadata; } return Optml_Main::instance()->manager->replace_content( $current_meta ); } // Return original if the check does not pass return $metadata; } } translate_press.php 0000644 00000001275 14717653355 0010513 0 ustar 00 <?php /** * Class Optml_translate_press. * * @reason Optml_translate_page conflict on buffer start need to hook earlier */ class Optml_translate_press extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'translatepress-multilingual/index.php' ); } /** * Register integration details. */ public function register() { add_action( 'init', [ Optml_Main::instance()->manager, 'process_template_redirect_content', ], defined( 'OPTML_SITE_MIRROR' ) ? PHP_INT_MAX : PHP_INT_MIN ); } } foogallery.php 0000644 00000001712 14717653355 0007441 0 ustar 00 <?php /** * Class Optml_shortcode_ultimate. * * @reason The gallery output contains a different src attribute used for lazyload * which prevented optimole to parse the tag. */ class Optml_foogallery extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'foogallery/foogallery.php' ); } /** * Register integration details. */ public function register() { add_filter( 'optml_possible_src_attributes', [ $this, 'add_lazysrc' ], 10 ); add_filter( 'optml_possible_lazyload_flags', [ $this, 'add_lazysrc' ], 10 ); } /** * Add foogallery lazysrc attribute. * * @param array $attributes Old src attributes. * * @return array New src attributes. */ public function add_lazysrc( $attributes = [] ) { $attributes[] = 'data-src-fg'; return $attributes; } } essential_grid.php 0000644 00000001513 14717653355 0010271 0 ustar 00 <?php /** * Class Optml_metaslider. * * @reason Metaslider behaves strange when the noscript tag is present near the image tag. */ class Optml_essential_grid extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'essential-grid/essential-grid.php' ); } /** * Register integration details. */ public function register() { add_filter( 'optml_lazyload_bg_classes', [ $this, 'add_bg_class' ], PHP_INT_MAX, 1 ); } /** * Adds essential grid listener class. * * @param array $classes Old classes. * * @return array New classes. */ public function add_bg_class( $classes ) { $classes[] = 'esg-media-poster'; return $classes; } } swift_performance.php 0000644 00000001327 14717653355 0011015 0 ustar 00 <?php /** * Class Optml_swift_performance. * * @reason Cache_swift_performance stores the content of the page before Optimole starts replacing url's */ class Optml_swift_performance extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return Optml_Main::instance()->admin->settings->get( 'cdn' ) === 'enabled' && is_plugin_active( 'swift-performance-lite/performance.php' ); } /** * Register integration details. */ public function register() { add_filter( 'swift_performance_buffer', [ Optml_Main::instance()->manager, 'replace_content' ], 10 ); } } elementor_builder.php 0000644 00000006631 14717653355 0011003 0 ustar 00 <?php /** * Class Optml_elementor_builder * * @reason Adding selectors for background lazyload */ class Optml_elementor_builder extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'elementor/elementor.php' ); } /** * Register integration details. */ public function register() { add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'add_src' ], PHP_INT_MIN, 1 ); add_filter( 'elementor/frontend/builder_content/before_enqueue_css_file', [ $this, 'add_src_filter' ], PHP_INT_MIN, 1 ); add_filter( 'elementor/frontend/builder_content/before_print_css', [ $this, 'remove_src_filter' ], PHP_INT_MIN, 1 ); add_filter( 'optml_lazyload_bg_selectors', function ( $all_watchers ) { $all_watchers[] = '.elementor-widget-container'; $all_watchers[] = '.elementor-background-slideshow__slide__image'; return $all_watchers; } ); add_action( 'optml_settings_updated', function () { if ( did_action( 'elementor/loaded' ) ) { if ( class_exists( '\Elementor\Plugin' ) ) { \Elementor\Plugin::instance()->files_manager->clear_cache(); } } } ); } /** * Remove filter for the image src after the css is saved by elementor. * * @param bool $with_css Flag used to determine if the css will be inline or not. Not used. * @return bool * @uses filter:elementor/frontend/builder_content/before_print_css */ public function remove_src_filter( $with_css ) { remove_filter( 'wp_get_attachment_image_src', [ $this, 'optimize_src' ], PHP_INT_MAX ); return $with_css; } /** * Add filter for the image src after the css is enqueued. * * @param object $css Elementor css info. Not used. * @return object * @uses filter:elementor/frontend/builder_content/before_enqueue_css_file */ public function add_src_filter( $css ) { // check if the filter was added to avoid duplication if ( has_filter( 'wp_get_attachment_image_src', [ $this, 'optimize_src' ] ) ) { return $css; } add_filter( 'wp_get_attachment_image_src', [ $this, 'optimize_src' ], PHP_INT_MAX, 4 ); return $css; } /** * Add action to add the filter for the image src. * * @return void */ public function add_src() { if ( ! has_filter( 'wp_get_attachment_image_src', [ $this, 'optimize_src' ] ) ) { add_filter( 'wp_get_attachment_image_src', [ $this, 'optimize_src' ], PHP_INT_MAX, 4 ); } } /** * Optimize the image src when it is requested in elementor. * * @param array $image Image data. * @param int $attachment_id Attachment id. * @param string|int[] $size Image size. * @param bool $icon Whether to use icon or not. * @return array * @uses filter:wp_get_attachment_image_src */ public function optimize_src( $image, $attachment_id, $size, $icon ) { if ( ! isset( $image[0] ) ) { return $image; } // We can't run the replacer before the setup is done, otherwise it will throw errors. if ( ! did_action( 'optml_replacer_setup' ) ) { return $image; } $image[0] = Optml_Main::instance()->manager->url_replacer->build_url( $image[0] ); return $image; } /** * Should we early load the compatibility? * * @return bool Whether to load the compatibility or not. */ public function should_load_early() { return true; } } beaver_builder.php 0000644 00000002032 14717653355 0010244 0 ustar 00 <?php /** * Class Optml_beaver_builder. * * @reason Beaver builder offload the CSS in a separate file, which we access and process the image urls. */ class Optml_beaver_builder extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'bb-plugin/fl-builder.php' ) || is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ); } /** * Register integration details. */ public function register() { add_filter( 'optml_lazyload_bg_selectors', function ( $all_watchers ) { $all_watchers[] = '.fl-col-content'; $all_watchers[] = '.fl-row-bg-photo > .fl-row-content-wrap'; return $all_watchers; } ); add_filter( 'fl_builder_render_css', [ Optml_Main::instance()->manager, 'replace_content' ], PHP_INT_MAX, 1 ); add_filter( 'fl_builder_render_js', [ Optml_Main::instance()->manager, 'replace_content' ], PHP_INT_MAX, 1 ); } } spectra.php 0000644 00000002714 14717653355 0006742 0 ustar 00 <?php /** * Class Optml_spectra * * @reason Optimizing Block images when saved to a CSS file. */ class Optml_spectra extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php' ) && 'enabled' === get_option( '_uagb_allow_file_generation', 'enabled' ); } /** * Register integration details. */ public function register() { add_filter( 'uagb_block_attributes_for_css_and_js', [ $this, 'optimize_src' ], PHP_INT_MAX, 2 ); } /** * Optimize the src attribute. * * @param array $attrs Array of attributes. * @param string $name Name of the block. * * @return array */ public function optimize_src( $attrs, $name ) { $attrs = $this->iterate_array( $attrs ); return $attrs; } /** * Iterate through the array and replace the url. * * @param array $attrs Array of attributes. * @return array */ public function iterate_array( $attrs ) { foreach ( $attrs as $key => $value ) { if ( is_array( $value ) ) { $attrs[ $key ] = $this->iterate_array( $value ); } if ( is_string( $value ) && preg_match( '/(http|https):\/\/.*\.(?:png|jpg|jpeg|gif|webp)/i', $value ) ) { $attrs[ $key ] = Optml_Main::instance()->manager->url_replacer->build_url( $value ); } } return $attrs; } } thrive.php 0000644 00000003041 14717653355 0006574 0 ustar 00 <?php /** * Class Optml_thrive. * * @reason @reason Adding selectors for background lazyload */ class Optml_thrive extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'thrive-visual-editor/thrive-visual-editor.php' ); } /** * Register integration details. */ public function register() { add_filter( 'optml_lazyload_bg_selectors', function ( $all_watchers ) { $all_watchers[] = '.tve-content-box-background'; $all_watchers[] = '.tve-page-section-out'; $all_watchers[] = '.thrv_text_element'; return $all_watchers; } ); if ( Optml_Main::instance()->admin->settings->get( 'offload_media' ) === 'enabled' ) { add_action( 'optml_updated_post', [ $this, 'update_trive_postmeta' ], 1, 1 ); } } /** * Update tve_updated_post meta with the correct status for images: offloaded/rollback. * * @param int $post_id The post id to be updated. */ public function update_trive_postmeta( $post_id ) { $post_meta = tve_get_post_meta( $post_id, 'tve_updated_post' ); $content = Optml_Media_Offload::instance()->filter_uploaded_images( [ 'post_content' => $post_meta ] ); tve_update_post_meta( $post_id, 'tve_updated_post', $content['post_content'] ); } /** * Should we early load the compatibility? * * @return bool Whether to load the compatibility or not. */ public function should_load_early() { return true; } } facetwp.php 0000644 00000004363 14717653355 0006734 0 ustar 00 <?php /** * Class Optml_facetwp * * @reason Adding filter to force replacement on api request. */ class Optml_facetwp extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'facetwp/index.php' ); } /** * Register integration details. */ public function register() { add_filter( 'facetwp_ajax_response', [ $this, 'api_replacement_filter' ], 1, 2 ); add_action( 'facetwp_inject_template', [ $this, 'api_replacement_action' ], 1 ); } /** * Add filter to replace images from api requests. * * Modifies template for a facetwp template. * NOTE: $output needs to be json decoded before modification and re encoded before returning. * * @param string $output The output before optimization. * @param array $data More data about the request. * @return string The output with the optimized images. */ public function api_replacement_filter( $output, $data ) { do_action( 'optml_replacer_setup' ); $output = json_decode( $output ); if ( isset( $output->template ) ) { $output->template = Optml_Main::instance()->manager->replace_content( $output->template ); } // Ignore invalid UTF-8 characters in PHP 7.2+ if ( version_compare( phpversion(), '7.2', '<' ) ) { $output = json_encode( $output ); } else { $output = json_encode( $output, JSON_INVALID_UTF8_IGNORE ); } $output = Optml_Main::instance()->manager->replace_content( $output ); return $output; } /** * Add action to replace images from facetwp api requests. * * Modifies template for a non-facetwp template. * * @param array $output The output before optimization. * @return void */ public function api_replacement_action( $output ) { do_action( 'optml_replacer_setup' ); if ( ! isset( $output['template'] ) || ! function_exists( 'FWP' ) ) { return; } $output['template'] = Optml_Main::instance()->manager->replace_content( $output['template'] ); FWP()->request->output = $output; } /** * Should we early load the compatibility? * * @return bool Whether to load the compatibility or not. */ public function should_load_early() { return true; } } wp_rest_cache.php 0000644 00000002157 14717653355 0010110 0 ustar 00 <?php /** * Class Optml_wp_rest_cache. * * @reason Wp rest cache stores the api response before Optimole starts replacing urls */ class Optml_wp_rest_cache extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'wp-rest-cache/wp-rest-cache.php' ); } /** * Register integration details. */ public function register() { add_filter( 'rest_pre_echo_response', [ $this, 'api_optimization' ], 10, 3 ); } /** * Replace the urls in the api response. * * @param array $result An array containing the result before our optimization. * @param WP_REST_Server $server Server instance. * @param WP_REST_Request $request Request used to generate the response. * @return array The decoded result with the replaced urls. */ public function api_optimization( $result, $server, $request ) { $result = json_decode( Optml_Main::instance()->manager->process_urls_from_content( json_encode( $result ) ) ); return $result; } } pinterest.php 0000644 00000006071 14717653355 0007316 0 ustar 00 <?php /** * Class Pinterest. * * @reason Pinterest plugins picks eco images to share */ class Optml_pinterest extends Optml_compatibility { /** * String with all css selectors to target * * @var string */ private $selectors; /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; $load = false; $selectors_array = []; if ( $this->isShareaholic() ) { $selectors_array[] = 'li.shareaholic-share-button[data-service=\"pinterest\"]'; $load = true; } if ( $this->isSassySocialShare() ) { $selectors_array[] = '.heateorSssSharing.heateorSssPinterestBackground'; $load = true; } $this->selectors = implode( ', ', array_filter( $selectors_array ) ); return $load; } /** * Register integration details. */ public function register() { add_action( 'wp_enqueue_scripts', function () { wp_register_script( 'optml-pinterest', false ); wp_enqueue_script( 'optml-pinterest' ); $script = sprintf( ' (function(w, d){ w.addEventListener("load", function() { const addCustomEventListener = function (selector, event, handler) { let rootElement = document.querySelector(\'body\'); rootElement.addEventListener(event, function (evt) { var targetElement = evt.target; while (targetElement != null) { if (targetElement.matches(selector)) { handler(evt); return; } targetElement = targetElement.parentElement; } }, true ); }; addCustomEventListener(\'%s\',\'mouseover\',function(){ let images = d.getElementsByTagName( "img" ); for ( let i = 0; i < images.length; i++ ) { if ( "optSrc" in images[i].dataset ) { images[i].src = images[i].dataset.optSrc ; } } }); }); }(window, document)); ', $this->selectors ); wp_add_inline_script( 'optml-pinterest', $script ); } ); } /** Check if plugin is active. @return bool */ private function isShareaholic() { if ( ! is_plugin_active( 'shareaholic/shareaholic.php' ) ) { return false; } return true; } /** * Check if plugin is active. * * @return bool */ private function isSassySocialShare() { if ( ! is_plugin_active( 'sassy-social-share/sassy-social-share.php' ) ) { return false; } $ss_options = get_option( 'heateor_sss' ); $ss_bars = [ 'vertical_re_providers', 'horizontal_re_providers' ]; if ( ! is_array( $ss_options ) ) { return false; } foreach ( $ss_bars as $key => $bar ) { if ( ! isset( $ss_options[ $bar ] ) ) { continue; } foreach ( $ss_options[ $bar ] as $index => $value ) { if ( isset( $value ) && is_string( $value ) ) { if ( strpos( $value, 'pinterest' ) !== false ) { return true; } } } } return false; } } yith_quick_view.php 0000644 00000001613 14717653355 0010501 0 ustar 00 <?php /** * Class Optml_yith_quick_view. * * @reason We need to turn on the image replacement on quick view ajax response, to do this we hook the product image filter. */ class Optml_yith_quick_view extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'yith-woocommerce-quick-view/init.php' ); } /** * Register integration details. */ public function register() { Optml_Url_Replacer::instance()->init(); add_filter( 'woocommerce_single_product_image_thumbnail_html', [ Optml_Main::instance()->manager, 'replace_content' ] ); } /** * Should we early load the compatibility? * * @return bool Whether to load the compatibility or not. */ public function should_load_early() { return true; } } shortcode_ultimate.php 0000644 00000004065 14717653355 0011200 0 ustar 00 <?php use Optimole\Sdk\Resource\ImageProperty\ResizeTypeProperty; use Optimole\Sdk\ValueObject\Position; /** * Class Optml_shortcode_ultimate. * * @reason Shortcode Ultimate uses a strange image resizing feature * which has by default the hard cropping on. As we are following the WordPress * image size defaults, we need to change the default cropping * for shortcode's output. */ class Optml_shortcode_ultimate extends Optml_compatibility { /** * Tags where we subscribe the compatibility. * * @var array Allowed tags. */ private $allowed_tags = [ 'su_slider' => true, 'su_carousel' => true, 'su_custom_gallery' => true, ]; /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'shortcodes-ultimate/shortcodes-ultimate.php' ); } /** * Register integration details. */ public function register() { add_filter( 'do_shortcode_tag', [ $this, 'alter_shortcode_output' ], 10, 3 ); } /** * Alter shortcode output by replacing the image urls. * * @param string $output Previous shortcode output. * @param string $tag Shortcode tag. * @param array $attr Shortcode attrs. * * @return mixed New output. */ public function alter_shortcode_output( $output, $tag, $attr ) { if ( ! isset( $this->allowed_tags[ $tag ] ) ) { return $output; } add_filter( 'optml_default_crop', [ $this, 'change_default_crop' ] ); add_filter( 'optml_parse_resize_from_tag', [ $this, 'change_default_crop' ] ); $output = Optml_Main::instance()->manager->process_images_from_content( $output ); remove_filter( 'optml_default_crop', [ $this, 'change_default_crop' ] ); remove_filter( 'optml_parse_resize_from_tag', [ $this, 'change_default_crop' ] ); return $output; } /** * Change default crop. * * @return array New default cropping. */ public function change_default_crop() { return [ 'type' => ResizeTypeProperty::FILL, 'gravity' => Position::CENTER, ]; } } wpml.php 0000644 00000005633 14717653355 0006263 0 ustar 00 <?php /** * Class Optml_wpml * * @reason Wpml duplicates everything so we need to offload/update every image/page attachment. */ class Optml_wpml extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) && Optml_Main::instance()->admin->settings->get( 'offload_media' ) === 'enabled'; } /** * Register integration details. */ public function register() { add_filter( 'optml_offload_duplicated_images', [ $this, 'wpml_get_duplicates' ], PHP_INT_MAX, 2 ); add_filter( 'optml_ensure_source_attachment_id', [ $this, 'get_source_attachment' ], PHP_INT_MAX ); } /** * Ads the duplicated pages/images when offloading. * * @param array $duplicated_attachments The duplicated attachments array. * @param string | int $attachment_id The attachment id that is first offloaded. * * @return array The images array with the specific bakery images. */ public function wpml_get_duplicates( $duplicated_attachments, $attachment_id ) { // Get the TRID (Translation ID) from element. REF: https://wpml.org/wpml-hook/wpml_element_trid/ $trid = apply_filters( 'wpml_element_trid', null, $attachment_id, 'post_attachment' ); // Get all translations (elements with the same TRID). REF: https://wpml.org/wpml-hook/wpml_get_element_translations/ $translations = apply_filters( 'wpml_get_element_translations', null, $trid, 'post_attachment' ); foreach ( $translations as $translation ) { if ( isset( $translation->element_id ) ) { $duplicated_attachments[] = $translation->element_id; } } return $duplicated_attachments; } /** * Get the source attachment ID for the given attachment ID that might be a duplicate. * * @param int $attachment_id the attachment ID. * * @return int */ public function get_source_attachment( $attachment_id ) { if ( $this->is_offload_source( $attachment_id ) ) { return $attachment_id; } $duplicates = $this->wpml_get_duplicates( [], $attachment_id ); foreach ( $duplicates as $duplicate_id ) { if ( $this->is_offload_source( $duplicate_id ) ) { return (int) $duplicate_id; } } return $attachment_id; } /** * Checks if the given attachment is the source of the initial offload. * On some instances, it seems that WPML meta is faulty. * We are sure that the main attachment that has been offloaded has the proper attachment_meta. * * @param int $id The attachment ID. * * @return bool */ private function is_offload_source( $id ) { return ! empty( get_post_meta( (int) $id, Optml_Media_Offload::META_KEYS['offloaded'], true ) ); } /** * Should we early load the compatibility? * * @return bool Whether to load the compatibility or not. */ public function should_load_early() { return true; } } woocommerce.php 0000644 00000003614 14717653355 0007620 0 ustar 00 <?php /** * Class Optml_woocommerce * * @reason Adding flags for ignoring the lazyloaded tags. */ class Optml_woocommerce extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'woocommerce/woocommerce.php' ); } /** * Register integration details. */ public function register() { if ( Optml_Main::instance()->admin->settings->use_lazyload() ) { add_filter( 'optml_lazyload_early_flags', [ $this, 'add_lazyload_early_flag' ], PHP_INT_MAX, 1 ); } } /** * Add ignore lazyload flag. * * @param array $flags Old flags. * * @return array New flags. */ public function add_lazyload_early_flag( $flags = [] ) { $flags[] = 'data-large_image'; return $flags; } /** * Ads the product pages to the list of posts parents when querying images for offload. * * @param array $parents Default post parents. * * @return array New post parents that include product pages. */ public function add_product_pages_to_image_query( $parents = [ 0 ] ) { $paged = 1; $query_args = [ 'post_type' => 'product', 'fields' => 'ids', 'posts_per_page' => 150, 'post_status' => 'publish', 'paged' => $paged, ]; $products = new \WP_Query( $query_args ); $ids = $products->get_posts(); while ( ! empty( $ids ) ) { ++$paged; $parents = array_merge( $parents, $ids ); $query_args['paged'] = $paged; $products = new \WP_Query( $query_args ); $ids = $products->get_posts(); } return $parents; } /** * Should we early load the compatibility? * * @return bool Whether to load the compatibility or not. */ public function should_load_early() { if ( Optml_Main::instance()->admin->settings->get( 'offload_media' ) === 'enabled' ) { return true; } return false; } } wp_fastest_cache.php 0000644 00000001354 14717653355 0010602 0 ustar 00 <?php /** * Class Optml_wp_fastest_cache. * * @reason Wp fastest cache stores the content of the page before Optimole starts replacing url's for the minified css/js files */ class Optml_wp_fastest_cache extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return Optml_Main::instance()->admin->settings->get( 'cdn' ) === 'enabled' && is_plugin_active( 'wp-fastest-cache/wpFastestCache.php' ); } /** * Register integration details. */ public function register() { add_filter( 'wpfc_buffer_callback_filter', [ Optml_Main::instance()->manager, 'replace_content' ], 10 ); } } compatibility.php 0000644 00000001303 14717653355 0010143 0 ustar 00 <?php /** * Class Optml_compatibility. */ abstract class Optml_compatibility { /** * Register compatibility actions/filters. */ abstract public function register(); /** * Should we load the compatibility? * * @return bool Compatiblity */ abstract public function should_load(); /** * Will the compatibility be loaded? * * @return bool */ final public function will_load() { if ( ! Optml_Main::instance()->admin->settings->is_connected() ) { return false; } return $this->should_load(); } /** * Should we early load the compatibility? * * @return bool Whether to load the compatibility or not. */ public function should_load_early() { return false; } } revslider.php 0000644 00000002766 14717653355 0007307 0 ustar 00 <?php /** * Class Optml_revslider. * * @reason The slider output dont needs the data-opt-src and uses a background lazyload approach. */ class Optml_revslider extends Optml_compatibility { /** * Should we load the integration logic. * * @return bool Should we load. */ public function should_load() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active( 'revslider/revslider.php' ); } /** * Register integration details. */ public function register() { add_filter( 'optml_possible_lazyload_flags', [ $this, 'add_lazyflag' ], 10 ); add_filter( 'optml_ignore_data_opt_flag', [ $this, 'add_data_ignore' ], 10 ); add_filter( 'optml_lazyload_bg_classes', [ $this, 'add_bg_class' ], 10 ); } /** * Add Slider Revolution lazyload flag. * * @param array $strings Old strings. * * @return array New flags. */ public function add_lazyflag( $strings = [] ) { $strings[] = 'rev-slidebg'; $strings[] = 'rs-lazyload'; return $strings; } /** * Add classes for lazyload on background. * * @param array $classes Old classes. * * @return array New classes. */ public function add_bg_class( $classes = [] ) { $classes[] = 'tp-bgimg'; return $classes; } /** * Adds flag that should ignore applying the data-opt-src * * @param array $flags Flag that should ignore. * * @return array New flags. */ public function add_data_ignore( $flags = [] ) { $flags[] = 'rev-slidebg'; $flags[] = 'rs-lazyload'; return $flags; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.3-4ubuntu2.24 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка