Skip to content

Instantly share code, notes, and snippets.

@fgrweb
Last active February 9, 2022 18:52
Show Gist options
  • Save fgrweb/be069e8a477170eb9f8621e6c5081182 to your computer and use it in GitHub Desktop.
Save fgrweb/be069e8a477170eb9f8621e6c5081182 to your computer and use it in GitHub Desktop.
Grabar de manera serializada un array en un post meta de WordPress, "limpiando" primero las comillas simples del array
function stripslashes_deep( $value ) {
$value = is_array( $value ) ? array_map( 'stripslashes_deep', $value ) : stripslashes( $value );
return $value;
}
function fgr_grabar_meta( $post_id, $array_data ) {
$new_data = maybe_serialize( stripslashes_deep( $array_sata ) );
update_post_meta( $post_id, 'fgr_meta', $new_data );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment