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