From f4d525b943d4338a0faebfe2652d5d5d3823b7dd Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Thu, 8 Dec 2016 19:15:01 +1100 Subject: [PATCH] Add recursive post meta function --- includes/sp-core-functions.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index 63150584..dcd83f4f 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -1095,9 +1095,8 @@ if ( !function_exists( 'sp_update_post_meta' ) ) { } } -if ( !function_exists( 'sp_update_post_meta_recursive' ) ) { - function sp_update_post_meta_recursive( $post_id, $meta_key, $meta_value ) { - delete_post_meta( $post_id, $meta_key ); +if ( !function_exists( 'sp_add_post_meta_recursive' ) ) { + function sp_add_post_meta_recursive( $post_id, $meta_key, $meta_value ) { $values = new RecursiveIteratorIterator( new RecursiveArrayIterator( $meta_value ) ); foreach ( $values as $value ): add_post_meta( $post_id, $meta_key, $value, false ); @@ -1105,6 +1104,13 @@ if ( !function_exists( 'sp_update_post_meta_recursive' ) ) { } } +if ( !function_exists( 'sp_update_post_meta_recursive' ) ) { + function sp_update_post_meta_recursive( $post_id, $meta_key, $meta_value ) { + delete_post_meta( $post_id, $meta_key ); + sp_add_post_meta_recursive( $post_id, $meta_key, $meta_value ); + } +} + if ( !function_exists( 'sp_update_user_meta_recursive' ) ) { function sp_update_user_meta_recursive( $user_id, $meta_key, $meta_value ) { delete_user_meta( $user_id, $meta_key );