PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
← All changes | inc/3rd-party/wp-rocket/classes/Main.php +11 -3 2.3.1 → trunk View file →
@@ -49,12 +49,20 @@
49 49
50 50 $container = apply_filters( 'rocket_container', null );
51 51
52 52 if ( is_object( $container ) && method_exists( $container, 'get' ) ) {
53 - $cdn = $container->get( 'cdn' );
53 + try {
54 + // WP Rocket does not register the 'cdn' service in every context.
55 + if ( ! method_exists( $container, 'has' ) || $container->has( 'cdn' ) ) {
56 + $cdn = $container->get( 'cdn' );
54 57
55 - if ( $cdn && method_exists( $cdn, 'get_cdn_urls' ) ) {
56 - $url = $cdn->get_cdn_urls( [ 'all', 'images' ] );
58 + if ( $cdn && method_exists( $cdn, 'get_cdn_urls' ) ) {
59 + $url = $cdn->get_cdn_urls( [ 'all', 'images' ] );
60 + }
61 + }
62 + } catch ( \Throwable $e ) {
63 + // Container could not resolve or build the service: fall back to get_rocket_cdn_cnames().
64 + $url = null;
57 65 }
58 66 }
59 67
60 68 if ( ! isset( $url ) && function_exists( 'get_rocket_cdn_cnames' ) ) {