Skip to content

Commit 39ec0e9

Browse files
committed
Output doesn't have schema restrictions as input, so fire the hook for output even if no schema is provided
1 parent 1c8be4a commit 39ec0e9

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/wp-includes/abilities-api/class-wp-ability.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -584,22 +584,22 @@ protected function do_execute( $input = null ) {
584584
protected function validate_output( $output ) {
585585
$output_schema = $this->get_output_schema();
586586
if ( empty( $output_schema ) ) {
587-
return true;
588-
}
589-
590-
$valid_output = rest_validate_value_from_schema( $output, $output_schema, 'output' );
591-
if ( is_wp_error( $valid_output ) ) {
592-
$is_valid = new WP_Error(
593-
'ability_invalid_output',
594-
sprintf(
595-
/* translators: %1$s ability name, %2$s error message. */
596-
__( 'Ability "%1$s" has invalid output. Reason: %2$s' ),
597-
esc_html( $this->name ),
598-
$valid_output->get_error_message()
599-
)
600-
);
601-
} else {
602587
$is_valid = true;
588+
} else {
589+
$valid_output = rest_validate_value_from_schema( $output, $output_schema, 'output' );
590+
if ( is_wp_error( $valid_output ) ) {
591+
$is_valid = new WP_Error(
592+
'ability_invalid_output',
593+
sprintf(
594+
/* translators: %1$s ability name, %2$s error message. */
595+
__( 'Ability "%1$s" has invalid output. Reason: %2$s' ),
596+
esc_html( $this->name ),
597+
$valid_output->get_error_message()
598+
)
599+
);
600+
} else {
601+
$is_valid = true;
602+
}
603603
}
604604

605605
/**

0 commit comments

Comments
 (0)