usage in ::cdn_url for documentation of this filter
$custom_photon_url = apply_filters( 'jetpack_photon_domain', '', $url );
$custom_photon_url = esc_url( $custom_photon_url );
return in_array( $parsed_url['host'], array( 'i0.wp.com', 'i1.wp.com', 'i2.wp.com' ), true )
|| wp_parse_url( $custom_photon_url, PHP_URL_HOST ) === $parsed_url['host'];
}
/**
* URL-encodes each path component.
*
* Example:
* Input: "foo/bar baz/baz"
* Output: "foo/bar%20baz/baz"
*
* @param string $path The path to escape.
* @return string The escaped path.
*/
private static function escape_path( $path ) {
$parts = explode( '/', $path );
$parts = array_map( 'rawurldecode', $parts );
$parts = array_map( 'rawurlencode', $parts );
return implode( '/', $parts );
}
/**
* Parses WP.com-hosted image args to replicate the crop.
*
* @param mixed $args Args set during Photon's processing.
* @param string $image_url URL of the image.
* @return array|string Args for Photon to use for the URL.
*/
public static function parse_wpcom_query_args( $args, $image_url ) {
$parsed_url = wp_parse_url( $image_url );
if ( ! $parsed_url ) {
return $args;
}
$image_url_parts = wp_parse_args(
$parsed_url,
array(
'host' => '',
'query' => '',
)
);
if ( ! str_ends_with( $image_url_parts['host'], '.files.wordpress.com' ) ) {
return $args;
}
if ( empty( $image_url_parts['query'] ) ) {
return $args;
}
$wpcom_args = wp_parse_args( $image_url_parts['query'] );
if ( empty( $wpcom_args['w'] ) || empty( $wpcom_args['h'] ) ) {
return $args;
}
// Keep the crop by using "resize".
if ( ! empty( $wpcom_args['crop'] ) ) {
if ( is_array( $args ) ) {
$args = array_merge( array( 'resize' => array( $wpcom_args['w'], $wpcom_args['h'] ) ), $args );
} else {
$args = 'resize=' . rawurlencode( absint( $wpcom_args['w'] ) . ',' . absint( $wpcom_args['h'] ) ) . '&' . $args;
}
} elseif ( is_array( $args ) ) {
$args = array_merge( array( 'fit' => array( $wpcom_args['w'], $wpcom_args['h'] ) ), $args );
} else {
$args = 'fit=' . rawurlencode( absint( $wpcom_args['w'] ) . ',' . absint( $wpcom_args['h'] ) ) . '&' . $args;
}
return $args;
}
/**
* Sets the scheme for a URL
*
* @param string $url URL to set scheme.
* @param string $scheme Scheme to use. Accepts http, https, network_path.
*
* @return string URL.
*/
public static function cdn_url_scheme( $url, $scheme ) {
if ( ! in_array( $scheme, array( 'http', 'https', 'network_path' ), true ) ) {
if ( preg_match( '#^(https?:)?//#', $url ) ) {
return $url;
}
$scheme = 'http';
}
if ( 'network_path' === $scheme ) {
$scheme_slashes = '//';
} else {
$scheme_slashes = "$scheme://";
}
return preg_replace( '#^([a-z:]+)?//#i', $scheme_slashes, $url );
}
/**
* Check to skip Photon for a known domain that shouldn't be Photonized.
*
* @param bool $skip If the image should be skipped by Photon.
* @param string $image_url URL of the image.
*
* @return bool Should the image be skipped by Photon.
*/
public static function banned_domains( $skip, $image_url ) {
$banned_host_patterns = array(
'/^chart\.googleapis\.com$/',
'/^chart\.apis\.google\.com$/',
'/^graph\.facebook\.com$/',
'/\.fbcdn\.net$/',
'/\.paypalobjects\.com$/',
'/\.dropbox\.com$/',
'/\.cdninstagram\.com$/',
'/^(commons|upload)\.wikimedia\.org$/',
'/\.wikipedia\.org$/',
'/^m\.media-amazon\.com$/',
);
$host = wp_parse_url( $image_url, PHP_URL_HOST );
if ( ! $host ) {
return $skip;
}
foreach ( $banned_host_patterns as $banned_host_pattern ) {
if ( 1 === preg_match( $banned_host_pattern, $host ) ) {
return true;
}
}
return $skip;
}
/**
* Check whether a string ends with a specific substring.
*
* @param string $haystack String we are filtering.
* @param string $needle The substring we are looking for.
* @return bool
*/
public static function ends_with( $haystack, $needle ) {
if ( ! $haystack || ! $needle || ! is_scalar( $haystack ) || ! is_scalar( $needle ) ) {
return false;
}
$haystack = (string) $haystack;
$needle = (string) $needle;
return str_ends_with( $haystack, $needle );
}
/**
* This is a copy of Jetpack::get_content_width()
* for backwards compatibility.
*/
public static function get_jetpack_content_width() {
$content_width = ( isset( $GLOBALS['content_width'] ) && is_numeric( $GLOBALS['content_width'] ) )
? $GLOBALS['content_width']
: false;
/**
* Filter the Content Width value.
*
* @since 2.2.3
*
* @param string $content_width Content Width value.
*/
return apply_filters( 'jetpack_content_width', $content_width );
}
}
Fatal error: Uncaught Error: Class 'Automattic\Jetpack\Image_CDN\Image_CDN_Core' not found in /var/www/html/dportilho.com.br/web/wp-content/plugins/jetpack/jetpack.php:214
Stack trace:
#0 /var/www/html/dportilho.com.br/web/wp-settings.php(526): include_once()
#1 /var/www/html/dportilho.com.br/web/wp-config.php(126): require_once('/var/www/html/d...')
#2 /var/www/html/dportilho.com.br/web/wp-load.php(50): require_once('/var/www/html/d...')
#3 /var/www/html/dportilho.com.br/web/wp-blog-header.php(13): require_once('/var/www/html/d...')
#4 /var/www/html/dportilho.com.br/web/index.php(17): require('/var/www/html/d...')
#5 {main}
thrown in /var/www/html/dportilho.com.br/web/wp-content/plugins/jetpack/jetpack.php on line 214