diff --git a/includes/widgets/class-amp-widget-archives.php b/includes/widgets/class-amp-widget-archives.php index 2c232ffc0fe..69a9649ac7d 100644 --- a/includes/widgets/class-amp-widget-archives.php +++ b/includes/widgets/class-amp-widget-archives.php @@ -15,17 +15,80 @@ class AMP_Widget_Archives extends WP_Widget_Archives { /** * Echoes the markup of the widget. * - * @todo filter $output, to strip the onchange attribute - * @see https://github.com/Automattic/amp-wp/issues/864 + * Mainly copied from WP_Widget_Archives::widget() + * Changes include: + * An id for the
. + * More escaping. + * The dropdown is now filtered with 'wp_dropdown_cats.' + * This enables adding an 'on' attribute, with the id of the form. + * So changing the dropdown value will redirect to the category page, with valid AMP. + * * @param array $args Widget display data. * @param array $instance Data for widget. * @return void. */ public function widget( $args, $instance ) { - ob_start(); - parent::widget( $args, $instance ); - $output = ob_get_clean(); - echo AMP_Theme_Support::filter_the_content( $output ); // WPCS: XSS ok. + $c = ! empty( $instance['count'] ) ? '1' : '0'; + $d = ! empty( $instance['dropdown'] ) ? '1' : '0'; + + /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ + $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Archives', 'default' ) : $instance['title'], $instance, $this->id_base ); + echo wp_kses_post( $args['before_widget'] ); + if ( $title ) : + echo wp_kses_post( $args['before_title'] . $title . $args['after_title'] ); + endif; + + if ( $d ) : + $dropdown_id = "{$this->id_base}-dropdown-{$this->number}"; + ?> + + + +
+ + + diff --git a/tests/test-class-amp-widget-media-audio.php b/tests/test-class-amp-widget-media-audio.php index 758b58f9c0c..c66aee65a05 100644 --- a/tests/test-class-amp-widget-media-audio.php +++ b/tests/test-class-amp-widget-media-audio.php @@ -50,7 +50,7 @@ public function test_construct() { */ public function test_render_media() { $widget = new AMP_Widget_Media_Audio(); - $audio = '/tmp/small-audio.mp3'; + $audio = '/tmp/small-audio.mp3'; copy( DIR_TESTDATA . '/uploads/small-audio.mp3', $audio ); $attachment_id = self::factory()->attachment->create_object( array( 'file' => $audio,