| 247 | * Performs a deep copy of an item to ensure that arrays of objects |
| 248 | * are properly duplicated |
| 249 | * |
| 250 | * @param mixed $data The data to be duplicated |
| 251 | * @return mixed copy of the data |
| 252 | */ |
| 253 | function wp_deep_copy( $data ) { |
| 254 | if ( is_object( $data ) ) { |
| 255 | return clone $data; |
| 256 | } elseif ( is_array( $data ) ) { |
| 257 | $new = array(); |
| 258 | foreach ( $data as $key => $value ) { |
| 259 | if ( is_object( $value ) ) { |
| 260 | $new[ $key ] = clone $value; |
| 261 | } elseif ( is_array( $value ) ) { |
| 262 | $new[ $key ] = wp_deep_copy( $value ); |
| 263 | } else { |
| 264 | $new[ $key ] = $value; |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | return $new; |
| 269 | } else { |
| 270 | return $data; |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | /** |