PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
← All changes | modules/widgets/my-community.php +20 -14 12.5.2 → 16.3-beta View file →
@@ -3,13 +3,11 @@
3 3 // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
4 4
5 5 use Automattic\Jetpack\Redirect;
6 6
7 -/**
8 - * Disable direct access/execution to/of the widget code.
9 - */
7 +// Disable direct access/execution to/of the widget code.
10 8 if ( ! defined( 'ABSPATH' ) ) {
11 - exit;
9 + exit( 0 );
12 10 }
13 11
14 12 /**
15 13 * Jetpack_My_Community_Widget displays community members of this site.
@@ -45,12 +43,8 @@
45 43 'customize_selective_refresh' => true,
46 44 )
47 45 );
48 46
49 - if ( is_active_widget( false, false, $this->id_base ) || is_active_widget( false, false, 'monster' ) || is_customize_preview() ) {
50 - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) );
51 - }
52 -
53 47 $this->default_title = esc_html__( 'Community', 'jetpack' );
54 48
55 49 add_filter( 'widget_types_to_hide_from_legacy_widget_block', array( $this, 'hide_widget_in_block_editor' ) );
56 50 }
@@ -83,9 +77,9 @@
83 77 *
84 78 * @return string|void
85 79 */
86 80 public function form( $instance ) {
87 - $title = isset( $instance['title'] ) ? $instance['title'] : false;
81 + $title = $instance['title'] ?? false;
88 82 if ( false === $title ) {
89 83 $title = $this->default_title;
90 84 }
91 85
@@ -147,21 +141,21 @@
147 141 * @return array Updated safe values to be saved.
148 142 */
149 143 public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
150 144 $instance = array();
151 - $instance['title'] = wp_kses( $new_instance['title'], array() );
145 + $instance['title'] = wp_kses( $new_instance['title'] ?? '', array() );
152 146 if ( $instance['title'] === $this->default_title ) {
153 147 $instance['title'] = false; // Store as false in case of language change.
154 148 }
155 149
156 - $instance['number'] = (int) $new_instance['number'];
150 + $instance['number'] = (int) ( $new_instance['number'] ?? 0 );
157 151 if ( ! in_array( $instance['number'], array( 10, 50 ), true ) ) {
158 152 $instance['number'] = 10;
159 153 }
160 154
161 - $instance['include_likers'] = (bool) $new_instance['include_likers'];
162 - $instance['include_followers'] = (bool) $new_instance['include_followers'];
163 - $instance['include_commenters'] = (bool) $new_instance['include_commenters'];
155 + $instance['include_likers'] = ! empty( $new_instance['include_likers'] );
156 + $instance['include_followers'] = ! empty( $new_instance['include_followers'] );
157 + $instance['include_commenters'] = ! empty( $new_instance['include_commenters'] );
164 158
165 159 delete_transient( "$this->id-v2-{$instance['number']}" . (int) $instance['include_likers'] . (int) $instance['include_followers'] . (int) $instance['include_commenters'] );
166 160
167 161 return $instance;
@@ -175,8 +169,17 @@
175 169 * @param array $args Widget arguments.
176 170 * @param array $instance Saved values from database.
177 171 */
178 172 public function widget( $args, $instance ) {
173 + $args = wp_parse_args(
174 + $args,
175 + array(
176 + 'before_widget' => '',
177 + 'after_widget' => '',
178 + 'before_title' => '',
179 + 'after_title' => '',
180 + )
181 + );
179 182 $instance = wp_parse_args(
180 183 $instance,
181 184 array(
182 185 'title' => false,
@@ -191,8 +194,11 @@
191 194
192 195 if ( false === $title ) {
193 196 $title = $this->default_title;
194 197 }
198 +
199 + // Enqueue front end assets.
200 + $this->enqueue_style();
195 201
196 202 echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
197 203
198 204 /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */