Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
CRAP
n/a
0 / 0
jetpack_mu_wpcom_i_voted_widget_init
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
Jetpack_I_Voted_Widget
n/a
0 / 0
n/a
0 / 0
5
n/a
0 / 0
 __construct
n/a
0 / 0
n/a
0 / 0
1
 widget
n/a
0 / 0
n/a
0 / 0
2
 update
n/a
0 / 0
n/a
0 / 0
1
 form
n/a
0 / 0
n/a
0 / 0
1
1<?php
2/**
3 * WARNING: This file is distributed verbatim in Jetpack.
4 * There should be nothing WordPress.com specific in this file.
5 *
6 * @hide-in-jetpack
7 * @package automattic/jetpack-mu-wpcom
8 * @deprecated
9 */
10
11if ( ! class_exists( 'Jetpack_I_Voted_Widget' ) ) {
12    /**
13     * The "I Voted" widget.
14     *
15     * @package automattic/jetpack-mu-wpcom
16     * @deprecated
17     */
18    class Jetpack_I_Voted_Widget extends WP_Widget {
19
20        /**
21         * Constructor.
22         */
23        public function __construct() {
24            $widget_ops = array(
25                'classname'   => 'widget_i_voted',
26                'description' => __( 'Show your readers that you voted with an "I Voted" sticker.', 'jetpack-mu-wpcom' ),
27            );
28
29            parent::__construct( 'i_voted', __( 'I Voted', 'jetpack-mu-wpcom' ), $widget_ops );
30        }
31
32        /**
33         * Display the widget.
34         *
35         * @param array $args     Widget arguments.
36         * @param array $instance Widget instance.
37         */
38        public function widget( $args, $instance ) {
39            echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
40
41            $title = $instance['title'] ?? null;
42            $title = apply_filters( 'widget_title', $title );
43
44            if ( $title ) {
45                echo $args['before_title'] . esc_html( $title ) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
46            }
47
48            echo '<img src="//i0.wp.com/wordpress.com/i/i-voted.png" alt="I Voted" style="max-width:100%;height:auto;" />';
49
50            echo "\n" . $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
51
52            do_action( 'jetpack_stats_extra', 'widget_view', 'i_voted' );
53        }
54
55        /**
56         * Update the widget settings.
57         *
58         * @param array $new_instance New settings.
59         * @param array $old_instance Old settings.
60         */
61        public function update( $new_instance, $old_instance ) {
62            $instance = $old_instance;
63
64            $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
65
66            return $instance;
67        }
68
69        /**
70         * Display the widget settings form.
71         *
72         * @param array $instance Current settings.
73         * @return never
74         */
75        public function form( $instance ) {
76            $defaults = array(
77                'title' => '',
78            );
79            $instance = wp_parse_args( (array) $instance, $defaults );
80
81            $title = esc_attr( $instance['title'] );
82
83            echo '<p><label for="' . esc_attr( $this->get_field_id( 'title' ) ) . '">' . esc_html__( 'Title:', 'jetpack-mu-wpcom' ) . '
84        <input class="widefat" id="' . esc_attr( $this->get_field_id( 'title' ) ) . '" name="' . esc_attr( $this->get_field_name( 'title' ) ) . '" type="text" value="' . esc_attr( $title ) . '" />
85        </label></p>';
86        }
87    }
88
89    /**
90     * Register the widget
91     */
92    function jetpack_mu_wpcom_i_voted_widget_init() { // phpcs:ignore Universal.Files.SeparateFunctionsFromOO.Mixed
93        register_widget( 'Jetpack_I_Voted_Widget' );
94    }
95    add_action( 'widgets_init', 'jetpack_mu_wpcom_i_voted_widget_init' );
96}