PluginProbe
WebberZone Top 10 — Popular Posts / 4.5.2
WebberZone Top 10 — Popular Posts v4.5.2
4.5.2 4.5.1 4.5.0 4.4.3 4.4.2 4.4.1 4.4.0 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 trunk 1.0 1.0.1 1.1 1.2 1.3 1.4 1.4.1 1.5 1.5.1 1.5.2 1.5.3 1.6 All 118 releases
← All changes | includes/admin/settings/class-settings-form.php +84 -21 4.4.2 → 4.5.2 View file →
@@ -73,9 +73,9 @@
73 73 *
74 74 * @return string Description of the field.
75 75 */
76 76 public function get_field_description( $args ) {
77 - $desc = ! empty( $args['desc'] ) ? '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>' : '';
77 + $desc = ! empty( $args['desc'] ) ? '<p class="description">' . wp_kses( $args['desc'], $this->get_allowed_html() ) . '</p>' : '';
78 78
79 79 /**
80 80 * After Settings Output filter
81 81 *
@@ -106,9 +106,9 @@
106 106 $default = $this->get_field_default( $args );
107 107 if ( is_array( $default ) ) {
108 108 $default = implode( ',', array_map( 'strval', $default ) );
109 109 }
110 - $default = trim( (string) $default );
110 + $default = trim( (string) $default, " \t\n\r\0\x0B" );
111 111
112 112 // Map option keys to their labels where the field has a choices list.
113 113 if ( ! empty( $args['options'] ) && is_array( $args['options'] ) ) {
114 114 if ( 'radiodesc' === $type && '' !== $default ) {
@@ -124,9 +124,9 @@
124 124 }
125 125 } elseif ( '' !== $default && 'multicheck' === $type ) {
126 126 $labels = array();
127 127 foreach ( explode( ',', $default ) as $key ) {
128 - $key = trim( $key );
128 + $key = trim( $key, " \t\n\r\0\x0B" );
129 129 $labels[] = isset( $args['options'][ $key ] ) && is_string( $args['options'][ $key ] ) ? $args['options'][ $key ] : $key;
130 130 }
131 131 $default = implode( ', ', $labels );
132 132 }
@@ -196,9 +196,9 @@
196 196 if ( is_array( $value ) || is_array( $default ) || in_array( $type, array( 'multicheck', 'posttypes', 'taxonomies' ), true ) ) {
197 197 return $this->normalize_list_value( $value ) !== $this->normalize_list_value( $default );
198 198 }
199 199
200 - return trim( (string) $value ) !== trim( (string) $default );
200 + return trim( (string) $value, " \t\n\r\0\x0B" ) !== trim( (string) $default, " \t\n\r\0\x0B" );
201 201 }
202 202
203 203 /**
204 204 * Normalize a list-style value (array or comma-separated string) into a
@@ -280,9 +280,9 @@
280 280 $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['field_class'] ?? '' ) ) );
281 281 if ( $default_class ) {
282 282 $class = $default_class . ' ' . $class;
283 283 }
284 - return trim( $class );
284 + return trim( $class, " \t\n\r\0\x0B" );
285 285 }
286 286
287 287 /**
288 288 * Get placeholder attribute string.
@@ -351,8 +351,20 @@
351 351 );
352 352 }
353 353
354 354 /**
355 + * Get the rendered field ID for a field definition.
356 + *
357 + * @param array $args Field arguments.
358 + * @return string Field ID.
359 + */
360 + public function get_field_id( $args ) {
361 + $field_attributes = $this->get_field_attributes( $args );
362 +
363 + return $field_attributes['field_id'];
364 + }
365 +
366 + /**
355 367 * Returns the allowed HTML tags and attributes for settings form output.
356 368 *
357 369 * Use the `{prefix}_settings_form_allowed_html` filter to add extra tags or
358 370 * attributes needed by custom field types or `field_attributes` entries.
@@ -433,14 +445,33 @@
433 445 'class' => true,
434 446 'style' => true,
435 447 ),
436 448 'button' => array(
437 - 'type' => true,
438 - 'id' => true,
439 - 'class' => true,
440 - 'style' => true,
441 - 'disabled' => true,
449 + 'type' => true,
450 + 'id' => true,
451 + 'class' => true,
452 + 'style' => true,
453 + 'disabled' => true,
454 + 'aria-controls' => true,
455 + 'aria-expanded' => true,
456 + 'aria-label' => true,
442 457 ),
458 + 'div' => array(
459 + 'id' => true,
460 + 'class' => true,
461 + 'style' => true,
462 + 'aria-hidden' => true,
463 + 'aria-busy' => true,
464 + 'role' => true,
465 + ),
466 + 'span' => array(
467 + 'class' => true,
468 + 'style' => true,
469 + 'aria-hidden' => true,
470 + 'aria-live' => true,
471 + 'aria-atomic' => true,
472 + 'role' => true,
473 + ),
443 474 'template' => array(
444 475 'class' => true,
445 476 'data-id' => true,
446 477 ),
@@ -555,8 +586,34 @@
555 586 echo wp_kses( apply_filters( $this->prefix . '_after_setting_output', $html, $args ), $this->get_allowed_html() ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound
556 587 }
557 588
558 589 /**
590 + * Display local date/time fields.
591 + *
592 + * @param array $args Field arguments.
593 + */
594 + public function callback_datetime( $args ) {
595 + $value = $this->get_field_value( $args );
596 + $class = $this->get_field_class( $args );
597 + $attributes = $this->get_boolean_attributes( $args ) . $this->build_field_attributes( $args );
598 + $placeholder = $this->get_placeholder_attribute( $args );
599 + $field_attributes = $this->get_field_attributes( $args );
600 +
601 + $html = sprintf(
602 + '<input type="datetime-local" id="%1$s" name="%2$s" class="%3$s" value="%4$s" step="60" %5$s %6$s />',
603 + $field_attributes['field_id'],
604 + $field_attributes['field_name'],
605 + $class . ' regular-text',
606 + esc_attr( stripslashes( (string) $value ) ),
607 + $attributes,
608 + $placeholder
609 + );
610 + $html .= $this->get_field_description( $args );
611 +
612 + echo wp_kses( apply_filters( $this->prefix . '_after_setting_output', $html, $args ), $this->get_allowed_html() ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound
613 + }
614 +
615 + /**
559 616 * Display url fields.
560 617 *
561 618 * @param array $args Array of arguments.
562 619 */
@@ -939,9 +996,9 @@
939 996 public function callback_number( $args ) {
940 997 $value = $this->get_field_value( $args );
941 998 $max = isset( $args['max'] ) ? intval( $args['max'] ) : 999999;
942 999 $min = isset( $args['min'] ) ? intval( $args['min'] ) : 0;
943 - $step = isset( $args['step'] ) ? intval( $args['step'] ) : 1;
1000 + $step = isset( $args['step'] ) && ( is_numeric( $args['step'] ) || 'any' === $args['step'] ) ? $args['step'] : 1;
944 1001 $size = $args['size'] ?? 'regular';
945 1002 $placeholder = $this->get_placeholder_attribute( $args );
946 1003 $attributes = $this->get_boolean_attributes( $args );
947 1004
@@ -1306,12 +1363,18 @@
1306 1363 $item_id = '{{ROW_ID}}';
1307 1364 }
1308 1365
1309 1366 $parent_disabled = $this->is_field_disabled( $args );
1367 + $content_id = sprintf(
1368 + '%s-%s-%s-content',
1369 + sanitize_key( $this->settings_key ),
1370 + sanitize_key( $args['id'] ),
1371 + '{{ROW_ID}}' === $item_id ? '{{ROW_ID}}' : sanitize_key( $item_id )
1372 + );
1310 1373 ?>
1311 1374 <div class="wz-repeater-item" data-row-id="<?php echo esc_attr( $item_id ); ?>">
1312 1375 <input type="hidden" name="<?php echo esc_attr( $this->settings_key ); ?>[<?php echo esc_attr( $args['id'] ); ?>][<?php echo esc_attr( $index ); ?>][row_id]" value="<?php echo esc_attr( $item_id ); ?>" <?php disabled( $parent_disabled ); ?> />
1313 - <div class="repeater-item-header">
1376 + <button type="button" class="repeater-item-header" aria-expanded="false" aria-controls="<?php echo esc_attr( $content_id ); ?>">
1314 1377 <?php
1315 1378 $display_field = ! empty( $args['live_update_field'] ) ? $args['live_update_field'] : 'name';
1316 1379 $live_options = ! empty( $args['live_update_field_options'] ) && is_array( $args['live_update_field_options'] ) ? $args['live_update_field_options'] : array();
1317 1380 $raw_live_value = ! empty( $item['fields'][ $display_field ] ) ? (string) $item['fields'][ $display_field ] : '';
@@ -1319,11 +1382,11 @@
1319 1382 ? ( isset( $live_options[ $raw_live_value ] ) ? $live_options[ $raw_live_value ] : $raw_live_value )
1320 1383 : $fallback_title;
1321 1384 ?>
1322 1385 <span class="repeater-title"><?php echo esc_html( $display_value ); ?></span>
1323 - <span class="toggle-icon">▼</span>
1324 - </div>
1325 - <div class="repeater-item-content" style="display: none;">
1386 + <span class="toggle-icon" aria-hidden="true">▼</span>
1387 + </button>
1388 + <div id="<?php echo esc_attr( $content_id ); ?>" class="repeater-item-content" aria-hidden="true" style="display: none;">
1326 1389 <?php
1327 1390 foreach ( $args['fields'] as $field ) {
1328 1391 $field_id = sanitize_key( $field['id'] );
1329 1392
@@ -1378,16 +1441,16 @@
1378 1441 </div>
1379 1442
1380 1443 <div class="repeater-item-footer">
1381 1444 <div class="repeater-item-actions">
1382 - <button type="button" class="button button-secondary move-up" <?php disabled( $parent_disabled ); ?>>
1383 - <span class="dashicons dashicons-arrow-up-alt2"></span>
1445 + <button type="button" class="button button-secondary move-up" aria-label="<?php echo esc_attr( $this->translation_strings['repeater_move_up'] ?? 'Move item up' ); ?>" <?php disabled( $parent_disabled ); ?>>
1446 + <span class="dashicons dashicons-arrow-up-alt2" aria-hidden="true"></span>
1384 1447 </button>
1385 - <button type="button" class="button button-secondary move-down" <?php disabled( $parent_disabled ); ?>>
1386 - <span class="dashicons dashicons-arrow-down-alt2"></span>
1448 + <button type="button" class="button button-secondary move-down" aria-label="<?php echo esc_attr( $this->translation_strings['repeater_move_down'] ?? 'Move item down' ); ?>" <?php disabled( $parent_disabled ); ?>>
1449 + <span class="dashicons dashicons-arrow-down-alt2" aria-hidden="true"></span>
1387 1450 </button>
1388 - <button type="button" class="button button-secondary remove-item" <?php disabled( $parent_disabled ); ?>>
1389 - <span class="dashicons dashicons-trash"></span>
1451 + <button type="button" class="button button-secondary remove-item" aria-label="<?php echo esc_attr( $this->translation_strings['repeater_remove_item'] ?? 'Remove item' ); ?>" <?php disabled( $parent_disabled ); ?>>
1452 + <span class="dashicons dashicons-trash" aria-hidden="true"></span>
1390 1453 </button>
1391 1454 </div>
1392 1455 </div>
1393 1456 </div>