| 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 |
|
| 10 |
namespace Automattic\Jetpack\Image_CDN\Compatibility; |
| 11 |
|
| 12 |
use Automattic\Jetpack\Image_CDN\Image_CDN; |
| 13 |
|
| 14 |
if ( ! 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 |
*/ |
| 25 |
function load_breakdance_compat() { |
| 26 |
add_filter( 'breakdance_singular_content', __NAMESPACE__ . '\use_image_cdn' ); |
| 27 |
} |
| 28 |
add_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 |
*/ |
| 40 |
function use_image_cdn( $content ) { |
| 41 |
if ( Image_CDN::is_enabled() ) { |
| 42 |
$content = Image_CDN::filter_the_content( $content ); |
| 43 |
} |
| 44 |
|
| 45 |
return $content; |
| 46 |
} |
| 47 |
|