| @@ -1,8 +1,12 @@ | ||
| 1 | 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | 2 | |
| 3 | 3 | // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files. |
| 4 | 4 | |
| 5 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 6 | + exit( 0 ); | |
| 7 | +} | |
| 8 | + | |
| 5 | 9 | add_action( 'widgets_init', 'jetpack_facebook_likebox_init' ); |
| 6 | 10 | /** |
| 7 | 11 | * Register the widget for use in Appearance -> Widgets |
| 8 | 12 | */ |
| @@ -107,12 +111,12 @@ | ||
| 107 | 111 | * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. |
| 108 | 112 | * @param array $instance The settings for the particular instance of the widget. |
| 109 | 113 | */ |
| 110 | 114 | public function widget( $args, $instance ) { |
| 111 | - $before_widget = isset( $args['before_widget'] ) ? $args['before_widget'] : ''; | |
| 112 | - $before_title = isset( $args['before_title'] ) ? $args['before_title'] : ''; | |
| 113 | - $after_title = isset( $args['after_title'] ) ? $args['after_title'] : ''; | |
| 114 | - $after_widget = isset( $args['after_widget'] ) ? $args['after_widget'] : ''; | |
| 115 | + $before_widget = $args['before_widget'] ?? ''; | |
| 116 | + $before_title = $args['before_title'] ?? ''; | |
| 117 | + $after_title = $args['after_title'] ?? ''; | |
| 118 | + $after_widget = $args['after_widget'] ?? ''; | |
| 115 | 119 | $like_args = $this->get_default_args(); |
| 116 | 120 | |
| 117 | 121 | if ( isset( $instance['like_args'] ) ) { |
| 118 | 122 | $like_args = $this->normalize_facebook_args( $instance['like_args'] ); |
| @@ -212,15 +216,15 @@ | ||
| 212 | 216 | */ |
| 213 | 217 | public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 214 | 218 | $instance = array(); |
| 215 | 219 | |
| 216 | - $instance['title'] = trim( wp_strip_all_tags( stripslashes( $new_instance['title'] ) ) ); | |
| 220 | + $instance['title'] = trim( wp_strip_all_tags( stripslashes( $new_instance['title'] ?? '' ) ) ); | |
| 217 | 221 | |
| 218 | 222 | // Set up widget values. |
| 219 | 223 | $instance['like_args'] = array( |
| 220 | - 'href' => trim( wp_strip_all_tags( stripslashes( $new_instance['href'] ) ) ), | |
| 221 | - 'width' => (int) $new_instance['width'], | |
| 222 | - 'height' => (int) $new_instance['height'], | |
| 224 | + 'href' => trim( wp_strip_all_tags( stripslashes( $new_instance['href'] ?? '' ) ) ), | |
| 225 | + 'width' => (int) ( $new_instance['width'] ?? $this->default_width ), | |
| 226 | + 'height' => (int) ( $new_instance['height'] ?? $this->default_height ), | |
| 223 | 227 | 'show_faces' => isset( $new_instance['show_faces'] ), |
| 224 | 228 | 'stream' => isset( $new_instance['stream'] ), |
| 225 | 229 | 'cover' => isset( $new_instance['cover'] ), |
| 226 | 230 | 'small_header' => isset( $new_instance['small_header'] ), |
| @@ -237,8 +241,9 @@ | ||
| 237 | 241 | /** |
| 238 | 242 | * Outputs the widget settings form. |
| 239 | 243 | * |
| 240 | 244 | * @param array $instance Current settings. |
| 245 | + * @return string|void | |
| 241 | 246 | */ |
| 242 | 247 | public function form( $instance ) { |
| 243 | 248 | $instance = wp_parse_args( |
| 244 | 249 | (array) $instance, |
| @@ -425,9 +430,9 @@ | ||
| 425 | 430 | * |
| 426 | 431 | * @param string $url URL to check. |
| 427 | 432 | */ |
| 428 | 433 | public function is_valid_facebook_url( $url ) { |
| 429 | - return ( false !== strpos( $url, 'facebook.com' ) ) ? true : false; | |
| 434 | + return str_contains( $url, 'facebook.com' ); | |
| 430 | 435 | } |
| 431 | 436 | |
| 432 | 437 | /** |
| 433 | 438 | * Normalize an integer value within a given range. |