| | 513 | * Validate an input. |
| | 514 | * |
| | 515 | * @since 4.5.0 |
| | 516 | * @see WP_REST_Request::has_valid_params() |
| | 517 | * |
| | 518 | * @param string|array $value The value to validate. |
| | 519 | * @return bool|WP_Error Whether an input isn't valid, or an WP_Error explaining why it isn't valid. |
| | 520 | */ |
| | 521 | public function validate( $value ) { |
| | 522 | $valid = true; |
| | 523 | |
| | 524 | /** |
| | 525 | * Filter a Customize setting value. |
| | 526 | * |
| | 527 | * @todo The version in WP_Customize_Setting::sanitize() does wp_unslash() for an unknown reason. |
| | 528 | * |
| | 529 | * This filter is documented in wp-includes/class-wp-customize-setting.php |
| | 530 | * |
| | 531 | * @since 3.4.0 |
| | 532 | * @since 4.5.0 Added $strict param. |
| | 533 | * |
| | 534 | * @param mixed $value Value of the setting. |
| | 535 | * @param WP_Customize_Setting $this WP_Customize_Setting instance. |
| | 536 | * @param bool $strict Whether strict sanitization (validation) is being applied. |
| | 537 | */ |
| | 538 | $value = apply_filters( "customize_sanitize_{$this->id}", $value, $this, true ); |
| | 539 | if ( null === $value ) { |
| | 540 | $valid = false; |
| | 541 | } else if ( is_wp_error( $value ) ) { |
| | 542 | $valid = $value; |
| | 543 | } |
| | 544 | |
| | 545 | /** |
| | 546 | * Filter the validation state of a Customize setting value. |
| | 547 | * |
| | 548 | * @since 4.5.0 |
| | 549 | * |
| | 550 | * @param |
| | 551 | * @param bool|WP_Error $valid Validity of the value based on sanitization. |
| | 552 | * @param mixed $value Value of the setting. |
| | 553 | * @param WP_Customize_Setting $this WP_Customize_Setting instance. |
| | 554 | */ |
| | 555 | $valid = apply_filters( "customize_validate_{$this->id}", $valid, $value, $this ); |
| | 556 | |
| | 557 | return $valid; |
| | 558 | } |
| | 559 | |
| | 560 | /** |