Use array_combine() in get_file_data() and avoid variable variables when an array is just fine. fixes #20126.

git-svn-id: http://svn.automattic.com/wordpress/trunk@20088 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2012-03-02 21:07:31 +00:00
parent 50fea9b10f
commit c8a4cb1112

View File

@ -3372,29 +3372,21 @@ function get_file_data( $file, $default_headers, $context = '' ) {
// PHP will close file handle, but we are good citizens.
fclose( $fp );
if ( $context != '' ) {
$extra_headers = apply_filters( "extra_{$context}_headers", array() );
$extra_headers = array_flip( $extra_headers );
foreach( $extra_headers as $key=>$value ) {
$extra_headers[$key] = $key;
}
if ( $context && $extra_headers = apply_filters( "extra_{$context}_headers", array() ) ) {
$extra_headers = array_combine( $extra_headers, $extra_headers ); // keys equal values
$all_headers = array_merge( $extra_headers, (array) $default_headers );
} else {
$all_headers = $default_headers;
}
foreach ( $all_headers as $field => $regex ) {
preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, ${$field});
if ( !empty( ${$field} ) )
${$field} = _cleanup_header_comment( ${$field}[1] );
if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] )
$all_headers[ $field ] = _cleanup_header_comment( $match[1] );
else
${$field} = '';
$all_headers[ $field ] = '';
}
$file_data = compact( array_keys( $all_headers ) );
return $file_data;
return $all_headers;
}
/**