Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
57.14% covered (warning)
57.14%
4 / 7
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
14if ( ! defined( 'ABSPATH' ) ) {
15    exit( 0 );
16}
17
18/**
19 * Hook the compatibility functions into Breakdance filters.
20 *
21 * @since 0.7.20
22 *
23 * @return void
24 */
25function load_breakdance_compat() {
26    add_filter( 'breakdance_singular_content', __NAMESPACE__ . '\use_image_cdn' );
27}
28add_action( 'plugins_loaded', __NAMESPACE__ . '\load_breakdance_compat' );
29
30/**
31 * Unless the 'Apply the_content filter to Breakdance content' option is enabled
32 * in the Breakdance settings, the content will not be filtered by the_content filter.
33 * This ensures that images are passed through Image CDN when it's enabled.
34 *
35 * @since 0.7.20
36 *
37 * @param string $content The content to filter.
38 * @return string The filtered content.
39 */
40function use_image_cdn( $content ) {
41    if ( Image_CDN::is_enabled() ) {
42        $content = Image_CDN::filter_the_content( $content );
43    }
44
45    return $content;
46}