debug_message( '' . __METHOD__ . '()' ); global $exactdn; if ( \is_object( $exactdn ) ) { $this->debug_message( 'you are doing it wrong' ); return; } $this->content_url(); // Bail out on customizer. if ( \is_customize_preview() ) { return; } $this->request_uri = \add_query_arg( '', '' ); if ( false === \strpos( $this->request_uri, 'page=ewww-image-optimizer-options' ) ) { $this->debug_message( "request uri is {$this->request_uri}" ); } else { $this->debug_message( 'request uri is EWWW IO settings' ); } if ( '/robots.txt' === $this->request_uri || '/sitemap.xml' === $this->request_uri ) { return; } \add_filter( 'exactdn_skip_page', array( $this, 'skip_page' ), 10, 2 ); /** * Allow pre-empting the parsers by page. * * @param bool Whether to skip parsing the page. * @param string The URI/path of the page. */ if ( \apply_filters( 'exactdn_skip_page', false, $this->request_uri ) ) { return; } if ( ! $this->scheme ) { $scheme = 'http'; if ( \strpos( $this->site_url, 'https://' ) !== false ) { $this->debug_message( "{$this->site_url} contains https" ); $scheme = 'https'; } elseif ( \strpos( \get_home_url(), 'https://' ) !== false ) { $this->debug_message( \get_home_url() . ' contains https' ); $scheme = 'https'; } elseif ( \strpos( $this->content_url, 'https://' ) !== false ) { $this->debug_message( $this->content_url . ' contains https' ); $scheme = 'https'; } elseif ( isset( $_SERVER['HTTPS'] ) && 'off' !== $_SERVER['HTTPS'] ) { $this->debug_message( 'page requested over https' ); $scheme = 'https'; } else { $this->debug_message( 'using plain http' ); } $this->scheme = $scheme; } if ( \is_multisite() && \defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) { $this->debug_message( 'working in sub-domain mode' ); } elseif ( \is_multisite() ) { if ( \defined( 'EXACTDN_SUB_FOLDER' ) && EXACTDN_SUB_FOLDER ) { $this->sub_folder = true; $this->debug_message( 'working in sub-folder mode due to constant override' ); } elseif ( \defined( 'EXACTDN_SUB_FOLDER' ) ) { $this->debug_message( 'working in sub-domain mode due to constant override' ); } elseif ( \get_site_option( 'exactdn_sub_folder' ) ) { $this->sub_folder = true; $this->debug_message( 'working in sub-folder mode due to global option' ); } elseif ( \get_current_blog_id() > 1 ) { $network_site_url = \network_site_url(); $network_domain = $this->parse_url( $network_site_url, PHP_URL_HOST ); if ( $network_domain === $this->upload_domain ) { $this->sub_folder = true; $this->debug_message( 'working in sub-folder mode due to matching domain' ); } } } // Make sure we have an ExactDN domain to use. if ( ! $this->setup() ) { return; } // Enables scheduled health checks via wp-cron. \add_action( 'easyio_verification_checkin', array( $this, 'health_check' ) ); if ( empty( $this->asset_domains ) ) { $this->asset_domains = \apply_filters( 'exactdn_asset_domains', $this->get_exactdn_option( 'asset_domains' ) ); } // Images in post content and galleries. \add_filter( 'the_content', array( $this, 'filter_the_content' ), 999999 ); // Start an output buffer before any output starts. \add_filter( $this->prefix . 'filter_page_output', array( $this, 'filter_page_output' ), 5 ); // Core image retrieval. if ( \defined( 'EIO_DISABLE_DEEP_INTEGRATION' ) && EIO_DISABLE_DEEP_INTEGRATION ) { $this->debug_message( 'deep (image_downsize) integration disabled' ); } elseif ( ! \function_exists( '\aq_resize' ) ) { \add_filter( 'image_downsize', array( $this, 'filter_image_downsize' ), 10, 3 ); } else { $this->debug_message( 'aq_resize detected, image_downsize filter disabled' ); } // Disable image_downsize filter during themify_get_image(). \add_action( 'themify_before_post_image', array( $this, 'disable_image_downsize' ) ); if ( \defined( 'EXACTDN_IMAGE_DOWNSIZE_SCALE' ) && EXACTDN_IMAGE_DOWNSIZE_SCALE ) { \add_action( 'exactdn_image_downsize_array', array( $this, 'image_downsize_scale' ) ); } // Check REST API requests to see if ExactDN should be running. \add_filter( 'rest_request_before_callbacks', array( $this, 'parse_restapi_maybe' ), 10, 3 ); // Check to see if the OMGF plugin is active, and suppress our font rewriting if it is. if ( ( \defined( 'OMGF_PLUGIN_FILE' ) || \defined( 'OMGF_DB_VERSION' ) ) && ! \defined( 'EASYIO_REPLACE_GOOGLE_FONTS' ) ) { \define( 'EASYIO_REPLACE_GOOGLE_FONTS', false ); } // Overrides for admin-ajax images. \add_filter( 'exactdn_admin_allow_image_downsize', array( $this, 'allow_admin_image_downsize' ), 10, 2 ); \add_filter( 'exactdn_admin_allow_image_srcset', array( $this, 'allow_admin_image_downsize' ), 10, 2 ); \add_filter( 'exactdn_admin_allow_plugin_url', array( $this, 'allow_admin_image_downsize' ), 10, 2 ); // Overrides for "pass through" images. \add_filter( 'exactdn_pre_args', array( $this, 'exactdn_remove_args' ), 10, 3 ); // Overrides for user exclusions. \add_filter( 'exactdn_skip_image', array( $this, 'exactdn_skip_user_exclusions' ), 9, 2 ); \add_filter( 'exactdn_skip_for_url', array( $this, 'exactdn_skip_user_exclusions' ), 9, 2 ); // Responsive image srcset substitution. \add_filter( 'wp_calculate_image_srcset', array( $this, 'filter_srcset_array' ), 1001, 5 ); \add_filter( 'wp_calculate_image_sizes', array( $this, 'filter_sizes' ), 1, 2 ); // Early so themes can still filter. // Filter for generic use by other plugins/themes. \add_filter( 'exactdn_local_to_cdn_url', array( $this, 'plugin_get_image_url' ) ); // Filter for Divi Pixel plugin SVG images. \add_filter( 'dipi_image_mask_image_url', array( $this, 'plugin_get_image_url' ) ); // Filter to check for Elementor full_width layouts. \add_filter( 'elementor/frontend/builder_content_data', array( $this, 'elementor_builder_content_data' ) ); // Filter for FacetWP JSON responses. \add_filter( 'facetwp_render_output', array( $this, 'filter_facetwp_json_output' ) ); // Filter for Envira image URLs. \add_filter( 'envira_gallery_output_item_data', array( $this, 'envira_gallery_output_item_data' ) ); \add_filter( 'envira_gallery_image_src', array( $this, 'plugin_get_image_url' ) ); // Filters for BuddyBoss image URLs. \add_filter( 'bp_media_get_preview_image_url', array( $this, 'bp_media_get_preview_image_url' ), PHP_INT_MAX, 5 ); \add_filter( 'bb_video_get_thumb_url', array( $this, 'bb_video_get_thumb_url' ), PHP_INT_MAX, 5 ); \add_filter( 'bp_document_get_preview_url', array( $this, 'bp_document_get_preview_url' ), PHP_INT_MAX, 6 ); \add_filter( 'bb_video_get_symlink', array( $this, 'bb_video_get_symlink' ), PHP_INT_MAX, 4 ); // Filters for BuddyBoss URL symlinks. \add_filter( 'bb_media_do_symlink', array( $this, 'buddyboss_do_symlink' ), PHP_INT_MAX ); \add_filter( 'bb_document_do_symlink', array( $this, 'buddyboss_do_symlink' ), PHP_INT_MAX ); \add_filter( 'bb_video_do_symlink', array( $this, 'buddyboss_do_symlink' ), PHP_INT_MAX ); \add_filter( 'bb_video_create_thumb_symlinks', array( $this, 'buddyboss_do_symlink' ), PHP_INT_MAX ); // Filters for BuddyBoss media access checks. \add_filter( 'bb_media_check_default_access', '__return_true', PHP_INT_MAX ); \add_filter( 'bb_media_settings_callback_symlink_direct_access', array( $this, 'buddyboss_media_directory_allow_access' ), PHP_INT_MAX, 2 ); // Filter for NextGEN image URLs within JS. \add_filter( 'ngg_pro_lightbox_images_queue', array( $this, 'ngg_pro_lightbox_images_queue' ) ); \add_filter( 'ngg_get_image_url', array( $this, 'plugin_get_image_url' ) ); // Filter Slider Revolution 7 REST API JSON. if ( \defined( 'EXACTDN_ENABLE_JSON_FILTERS' ) ) { \add_filter( 'sr_get_full_slider_JSON', array( $this, 'sr7_slider_object' ) ); } // This one is just to get at the slider background image, do not use it for anything else. \add_filter( 'revslider_add_slider_base', array( $this, 'sr7_slider_object' ) ); // This is for the slide background image contained in a