mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-04 18:05:45 +03:00
Get content from POST submission if it exists
This commit is contained in:
parent
a7a8a37019
commit
f646e1f107
1 changed files with 9 additions and 3 deletions
|
@ -307,17 +307,23 @@ function get_input_filters() {
|
||||||
* @return array Pledge data
|
* @return array Pledge data
|
||||||
*/
|
*/
|
||||||
function get_pledge_meta( $pledge_id = 0, $context = '' ) {
|
function get_pledge_meta( $pledge_id = 0, $context = '' ) {
|
||||||
|
// Get existing pledge, if it exists.
|
||||||
$pledge = get_post( $pledge_id );
|
$pledge = get_post( $pledge_id );
|
||||||
|
|
||||||
$keys = get_pledge_meta_config( $context );
|
$keys = get_pledge_meta_config( $context );
|
||||||
$meta = array();
|
$meta = array();
|
||||||
|
|
||||||
|
// Get POST'd submission, if it exists.
|
||||||
|
$submission = filter_input_array( INPUT_POST, get_input_filters() );
|
||||||
|
|
||||||
foreach ( $keys as $key => $config ) {
|
foreach ( $keys as $key => $config ) {
|
||||||
if ( ! $pledge instanceof WP_Post ) {
|
if ( isset( $submission[ $key ] ) ) {
|
||||||
$meta[ $key ] = $config['default'] ?: '';
|
$meta[ $key ] = $submission[ $key ];
|
||||||
} else {
|
} else if ( $pledge instanceof WP_Post ) {
|
||||||
$meta_key = META_PREFIX . $key;
|
$meta_key = META_PREFIX . $key;
|
||||||
$meta[ $key ] = get_post_meta( $pledge->ID, $meta_key, true );
|
$meta[ $key ] = get_post_meta( $pledge->ID, $meta_key, true );
|
||||||
|
} else {
|
||||||
|
$meta[ $key ] = $config['default'] ?: '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue