- // We don't need to write to the file, so just open for reading.
- $fp = fopen($plugin_file, 'r');
-
- // Pull only the first 8kiB of the file in.
- $plugin_data = fread( $fp, 8192 );
-
- // PHP will close file handle, but we are good citizens.
- fclose($fp);
-
- preg_match( '|Plugin Name:(.*)$|mi', $plugin_data, $name );
- preg_match( '|Plugin URI:(.*)$|mi', $plugin_data, $uri );
- preg_match( '|Version:(.*)|i', $plugin_data, $version );
- preg_match( '|Description:(.*)$|mi', $plugin_data, $description );
- preg_match( '|Author:(.*)$|mi', $plugin_data, $author_name );
- preg_match( '|Author URI:(.*)$|mi', $plugin_data, $author_uri );
- preg_match( '|Text Domain:(.*)$|mi', $plugin_data, $text_domain );
- preg_match( '|Domain Path:(.*)$|mi', $plugin_data, $domain_path );
-
- foreach ( array( 'name', 'uri', 'version', 'description', 'author_name', 'author_uri', 'text_domain', 'domain_path' ) as $field ) {
- if ( !empty( ${$field} ) )
- ${$field} = _cleanup_header_comment(${$field}[1]);
- else
- ${$field} = '';
- }