In WordPress, comment lines are used to find theme summary, plugin summary, template name and so on.
for example:-
<?php
/*
Template Name: Snarfer
*/
?>
How WordPress doing this? What code is used to read comment lines.
In WordPress, comment lines are used to find theme summary, plugin summary, template name and so on.
for example:-
<?php
/*
Template Name: Snarfer
*/
?>
How WordPress doing this? What code is used to read comment lines.
This is done in the function get_file_data
in wp-includes/functions.php
with the key code section being this:
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] );
else
${$field} = '';
}
For example for a plugin it is referenced in wp-admin/includes/plugin.php
in the function get_plugin_data
:
$plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' );