← All changes
|
modules/widgets/milestone/class-milestone-widget.php
+8
-3
12.2.3
→
16.3-a.1
View file →
| @@ -6,8 +6,12 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | use Automattic\Jetpack\Assets; |
| 9 | 9 | |
| 10 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 11 | + exit( 0 ); | |
| 12 | +} | |
| 13 | + | |
| 10 | 14 | /** |
| 11 | 15 | * Class Milestone_Widget |
| 12 | 16 | */ |
| 13 | 17 | class Milestone_Widget extends WP_Widget { |
| @@ -134,11 +138,11 @@ | ||
| 134 | 138 | public static function sanitize_color_hex( $hex, $prefix = '#' ) { |
| 135 | 139 | $hex = trim( $hex ); |
| 136 | 140 | |
| 137 | 141 | /* Strip recognized prefixes. */ |
| 138 | - if ( 0 === strpos( $hex, '#' ) ) { | |
| 142 | + if ( str_starts_with( $hex, '#' ) ) { | |
| 139 | 143 | $hex = substr( $hex, 1 ); |
| 140 | - } elseif ( 0 === strpos( $hex, '%23' ) ) { | |
| 144 | + } elseif ( str_starts_with( $hex, '%23' ) ) { | |
| 141 | 145 | $hex = substr( $hex, 3 ); |
| 142 | 146 | } |
| 143 | 147 | |
| 144 | 148 | if ( 0 !== preg_match( '/^[0-9a-fA-F]{6}$/', $hex ) ) { |
| @@ -231,9 +235,9 @@ | ||
| 231 | 235 | $config['content_id'] = $widget_id . '-content'; |
| 232 | 236 | |
| 233 | 237 | self::$config_js['instances'][] = $config; |
| 234 | 238 | |
| 235 | - echo sprintf( '<div id="%s" class="milestone-content">', esc_html( $config['content_id'] ) ); | |
| 239 | + printf( '<div id="%s" class="milestone-content">', esc_html( $config['content_id'] ) ); | |
| 236 | 240 | |
| 237 | 241 | echo '<div class="milestone-header">'; |
| 238 | 242 | echo '<strong class="event">' . esc_html( $instance['event'] ) . '</strong>'; |
| 239 | 243 | echo '<span class="date">' . esc_html( date_i18n( get_option( 'date_format' ), $data['milestone'] ) ) . '</span>'; |
| @@ -631,8 +635,9 @@ | ||
| 631 | 635 | /** |
| 632 | 636 | * Form |
| 633 | 637 | * |
| 634 | 638 | * @param array $instance Widget instance. |
| 639 | + * @return string|void | |
| 635 | 640 | */ |
| 636 | 641 | public function form( $instance ) { |
| 637 | 642 | $instance = $this->sanitize_instance( $instance ); |
| 638 | 643 | |