Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
80.00% covered (warning)
80.00%
4 / 5
100.00% covered (success)
100.00%
2 / 2
CRAP
n/a
0 / 0
Automattic\Jetpack\Image_CDN\Compatibility\load_breakdance_compat
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
Automattic\Jetpack\Image_CDN\Compatibility\use_image_cdn
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 * Compatibility functions for the Breakdance plugin.
4 *
5 * @since 0.7.20
6 *
7 * @package automattic/jetpack-image-cdn
8 */
9
10namespace Automattic\Jetpack\Image_CDN\Compatibility;
11
12use Automattic\Jetpack\Image_CDN\Image_CDN;
13
14/**
15 * Hook the compatibility functions into Breakdance filters.
16 *
17 * @since 0.7.20
18 *
19 * @return void
20 */
21function load_breakdance_compat() {
22    add_filter( 'breakdance_singular_content', __NAMESPACE__ . '\use_image_cdn' );
23}
24add_action( 'plugins_loaded', __NAMESPACE__ . '\load_breakdance_compat' );
25
26/**
27 * Unless the 'Apply the_content filter to Breakdance content' option is enabled
28 * in the Breakdance settings, the content will not be filtered by the_content filter.
29 * This ensures that images are passed through Image CDN when it's enabled.
30 *
31 * @since 0.7.20
32 *
33 * @param string $content The content to filter.
34 * @return string The filtered content.
35 */
36function use_image_cdn( $content ) {
37    if ( Image_CDN::is_enabled() ) {
38        $content = Image_CDN::filter_the_content( $content );
39    }
40
41    return $content;
42}