| @@ -5,8 +5,12 @@ | ||
| 5 | 5 | * Sort Order: 20 |
| 6 | 6 | * First Introduced: 1.2 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | + exit( 0 ); | |
| 11 | +} | |
| 12 | + | |
| 9 | 13 | // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files. |
| 10 | 14 | |
| 11 | 15 | add_action( 'widgets_init', 'jetpack_image_widget_init', 11 ); |
| 12 | 16 | /** |
| @@ -36,12 +40,8 @@ | ||
| 36 | 40 | 'description' => __( 'Display an image in your sidebar', 'jetpack' ), |
| 37 | 41 | 'customize_selective_refresh' => true, |
| 38 | 42 | ) |
| 39 | 43 | ); |
| 40 | - | |
| 41 | - if ( is_active_widget( false, false, $this->id_base ) || is_active_widget( false, false, 'monster' ) || is_customize_preview() ) { | |
| 42 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) ); | |
| 43 | - } | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * Loads file for front-end widget style. |
| @@ -78,8 +78,11 @@ | ||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | if ( $instance['img_url'] ) { |
| 81 | 81 | |
| 82 | + // Enqueue front end assets. | |
| 83 | + $this->enqueue_style(); | |
| 84 | + | |
| 82 | 85 | $output = '<img src="' . esc_url( $instance['img_url'] ) . '" '; |
| 83 | 86 | |
| 84 | 87 | if ( '' !== (string) $instance['alt_text'] ) { |
| 85 | 88 | $output .= 'alt="' . esc_attr( $instance['alt_text'] ) . '" '; |
| @@ -97,11 +100,9 @@ | ||
| 97 | 100 | $output .= 'height="' . esc_attr( $instance['img_height'] ) . '" '; |
| 98 | 101 | } |
| 99 | 102 | $output .= '/>'; |
| 100 | 103 | |
| 101 | - if ( class_exists( 'Jetpack_Photon' ) && Jetpack::is_module_active( 'photon' ) ) { | |
| 102 | - $output = Jetpack_Photon::filter_the_content( $output ); | |
| 103 | - } | |
| 104 | + $output = apply_filters( 'jetpack_image_cdn_content', $output ); | |
| 104 | 105 | |
| 105 | 106 | if ( $instance['link'] ) { |
| 106 | 107 | $target = ! empty( $instance['link_target_blank'] ) |
| 107 | 108 | ? 'target="_blank"' |
| @@ -206,8 +207,9 @@ | ||
| 206 | 207 | * |
| 207 | 208 | * @see WP_Widget::form() |
| 208 | 209 | * |
| 209 | 210 | * @param array $instance Previously saved values from database. |
| 211 | + * @return string|void | |
| 210 | 212 | */ |
| 211 | 213 | public function form( $instance ) { |
| 212 | 214 | // Defaults. |
| 213 | 215 | $instance = wp_parse_args( |