From f646e1f107eaaf78f39f92e07108487e370efe0b Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Tue, 8 Oct 2019 13:38:33 -0400 Subject: [PATCH] Get content from POST submission if it exists --- plugins/wporg-5ftf/includes/pledge-meta.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/wporg-5ftf/includes/pledge-meta.php b/plugins/wporg-5ftf/includes/pledge-meta.php index dc1fa69..b2a38ae 100755 --- a/plugins/wporg-5ftf/includes/pledge-meta.php +++ b/plugins/wporg-5ftf/includes/pledge-meta.php @@ -307,17 +307,23 @@ function get_input_filters() { * @return array Pledge data */ function get_pledge_meta( $pledge_id = 0, $context = '' ) { + // Get existing pledge, if it exists. $pledge = get_post( $pledge_id ); $keys = get_pledge_meta_config( $context ); $meta = array(); + // Get POST'd submission, if it exists. + $submission = filter_input_array( INPUT_POST, get_input_filters() ); + foreach ( $keys as $key => $config ) { - if ( ! $pledge instanceof WP_Post ) { - $meta[ $key ] = $config['default'] ?: ''; - } else { + if ( isset( $submission[ $key ] ) ) { + $meta[ $key ] = $submission[ $key ]; + } else if ( $pledge instanceof WP_Post ) { $meta_key = META_PREFIX . $key; $meta[ $key ] = get_post_meta( $pledge->ID, $meta_key, true ); + } else { + $meta[ $key ] = $config['default'] ?: ''; } }