| @@ -1,43 +1,38 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -use Automattic\Jetpack\Image_CDN\Image_CDN; | |
| 3 | +defined( 'ABSPATH' ) or exit; | |
| 4 | 4 | |
| 5 | -defined('ABSPATH') or exit; | |
| 5 | +add_filter( 'boxzilla_box_content', 'wptexturize' ); | |
| 6 | +add_filter( 'boxzilla_box_content', 'convert_smilies' ); | |
| 7 | +add_filter( 'boxzilla_box_content', 'convert_chars' ); | |
| 8 | +add_filter( 'boxzilla_box_content', 'wpautop' ); | |
| 9 | +add_filter( 'boxzilla_box_content', 'shortcode_unautop' ); | |
| 10 | +add_filter( 'boxzilla_box_content', 'do_shortcode', 11 ); | |
| 6 | 11 | |
| 7 | -add_filter('boxzilla_box_content', 'wptexturize'); | |
| 8 | -add_filter('boxzilla_box_content', 'convert_smilies'); | |
| 9 | -add_filter('boxzilla_box_content', 'convert_chars'); | |
| 10 | -add_filter('boxzilla_box_content', 'wpautop'); | |
| 11 | -add_filter('boxzilla_box_content', 'shortcode_unautop'); | |
| 12 | -add_filter('boxzilla_box_content', 'do_shortcode', 11); | |
| 13 | - | |
| 14 | 12 | /** |
| 15 | -* Allow Jetpack to filter images inside Boxzilla box content. | |
| 13 | +* Allow Jetpack Photon to filter on Boxzilla box content. | |
| 16 | 14 | */ |
| 17 | -if (class_exists(Image_CDN::class) && method_exists(Image_CDN::class, 'filter_the_content')) { | |
| 18 | - add_filter('boxzilla_box_content', [ Image_CDN::class, 'filter_the_content' ], 999999); | |
| 15 | +if ( class_exists( 'Jetpack' ) && class_exists( 'Jetpack_Photon' ) && Jetpack::is_module_active( 'photon' ) ) { | |
| 16 | + add_filter( 'boxzilla_box_content', array( 'Jetpack_Photon', 'filter_the_content' ), 999999 ); | |
| 19 | 17 | } |
| 20 | 18 | |
| 21 | - | |
| 22 | 19 | /** |
| 23 | 20 | * Filter nav menu items to use an onclick event instead of a href attribute. |
| 21 | + * | |
| 22 | + * TODO: Move this to JavaScript instead? | |
| 24 | 23 | */ |
| 25 | 24 | add_filter( |
| 26 | - 'nav_menu_link_attributes', | |
| 27 | - function ($atts) { | |
| 28 | - if (empty($atts['href'])) { | |
| 29 | - return $atts; | |
| 30 | - } | |
| 25 | + 'nav_menu_link_attributes', | |
| 26 | + function( $atts ) { | |
| 27 | + if ( strpos( $atts['href'], '#boxzilla-' ) !== 0 ) { | |
| 28 | + return $atts; | |
| 29 | + } | |
| 31 | 30 | |
| 32 | - if (strpos($atts['href'], '#boxzilla-') !== 0) { | |
| 33 | - return $atts; | |
| 34 | - } | |
| 35 | - | |
| 36 | - $id = (int) substr($atts['href'], strlen('#boxzilla-')); | |
| 37 | - $atts['onclick'] = "Boxzilla.show({$id}); return false;"; | |
| 38 | - $atts['href'] = ''; | |
| 39 | - return $atts; | |
| 40 | - }, | |
| 41 | - 10, | |
| 42 | - 1 | |
| 31 | + $id = substr( $atts['href'], strlen( '#boxzilla-' ) ); | |
| 32 | + $atts['onclick'] = sprintf( 'Boxzilla.show(%d); return false;', $id ); | |
| 33 | + $atts['href'] = ''; | |
| 34 | + return $atts; | |
| 35 | + }, | |
| 36 | + 10, | |
| 37 | + 1 | |
| 43 | 38 | ); |