| | 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 | |
| | 259 | foreach ( $data as $key => $value ) { |
| | 260 | $new[ $key ] = wp_deep_copy( $value ); |
| | 261 | } |
| | 262 | |
| | 263 | return $new; |
| | 264 | } |
| | 265 | |
| | 266 | return $data; |
| | 267 | } |
| | 268 | |
| | 269 | /** |