diff --git a/plugins/wporg-5ftf/includes/pledge-meta.php b/plugins/wporg-5ftf/includes/pledge-meta.php index 2a76380..dc1fa69 100755 --- a/plugins/wporg-5ftf/includes/pledge-meta.php +++ b/plugins/wporg-5ftf/includes/pledge-meta.php @@ -156,43 +156,6 @@ function render_meta_boxes( $pledge, $box ) { } } -/** - * Check that an array contains values for all required keys. - * - * @return bool|WP_Error True if all required values are present. Otherwise WP_Error. - */ -function has_required_pledge_meta( array $submission ) { - $error = new WP_Error(); - - $required = array_keys( get_pledge_meta_config( 'user_input' ) ); - - foreach ( $required as $key ) { - if ( ! isset( $submission[ $key ] ) || is_null( $submission[ $key ] ) ) { - $error->add( - 'required_field_empty', - sprintf( - __( 'The %s field does not have a value.', 'wporg' ), - sanitize_key( $key ) - ) - ); - } elseif ( false === $submission[ $key ] ) { - $error->add( - 'required_field_invalid', - sprintf( - __( 'The %s field has an invalid value.', 'wporg' ), - sanitize_key( $key ) - ) - ); - } - } - - if ( ! empty( $error->get_error_messages() ) ) { - return $error; - } - - return true; -} - /** * Save the pledge data. * @@ -279,6 +242,43 @@ function update_generated_meta( $meta_id, $object_id, $meta_key, $_meta_value ) } } +/** + * Check that an array contains values for all required keys. + * + * @return bool|WP_Error True if all required values are present. Otherwise WP_Error. + */ +function has_required_pledge_meta( array $submission ) { + $error = new WP_Error(); + + $required = array_keys( get_pledge_meta_config( 'user_input' ) ); + + foreach ( $required as $key ) { + if ( ! isset( $submission[ $key ] ) || is_null( $submission[ $key ] ) ) { + $error->add( + 'required_field_empty', + sprintf( + __( 'The %s field does not have a value.', 'wporg' ), + sanitize_key( $key ) + ) + ); + } elseif ( false === $submission[ $key ] ) { + $error->add( + 'required_field_invalid', + sprintf( + __( 'The %s field has an invalid value.', 'wporg' ), + sanitize_key( $key ) + ) + ); + } + } + + if ( ! empty( $error->get_error_messages() ) ) { + return $error; + } + + return true; +} + /** * Get the input filters for submitted content. *