Use multiple post metas instead of serialized array

This commit is contained in:
Takumi
2013-07-26 00:16:29 +10:00
parent aaa545e966
commit f0b3e72231
2 changed files with 28 additions and 35 deletions

View File

@@ -23,9 +23,14 @@ function sp_save_post( $post_id ) {
if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id;
if ( !isset( $_POST['sportspress_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_nonce'], plugin_basename( __FILE__ ) ) ) return $post_id;
foreach ( $sportspress as $key => $value ):
if ( is_array( $value ) )
$value = serialize( $value );
update_post_meta( $post_id, $key, $value );
delete_post_meta( $post_id, $key );
if ( is_array( $value ) ):
foreach ( $value as $single_value ):
add_post_meta( $post_id, $key, $single_value, false );
endforeach;
else:
update_post_meta( $post_id, $key, $value );
endif;
endforeach;
endif;
endif;