Rest-Easy
Rest-Easy copied to clipboard
A serializer that can process an entire array
trafficstars
I find myself doing this pattern a lot when writing a filter:
$args = array(
...
);
$attachments = get_posts($args);
foreach($attachments as $attachment) {
$post_data['something'][] = apply_filters('rez_serialize_attachment', $attachment);
}
Generally it's for pages/posts or attachments. Would be handy to have a serializer that worked like this:
$args = array(
...
);
$attachments = get_posts($args);
$post_data['something'] = apply_filters('rez_serialize_array', $attachments);
I imagine it would then look at the contents of $attachments can correctly serialize a post or an attachment.