This question already has an answer here:
I want to know how to access the comments on the top of a style sheet with PHP, like the way WordPress does.
If we create a new theme for WordPress than we have to enter our name, blog name and some other parameters in the style sheet under comments. WordPress accesses those comments and shows them as your theme information.
So does anyone have any idea how to do it?
</div>
The answer is to find the code that WordPress uses to do this.
I did a quick search for "style.css" within the full WordPress codebase and found a function in upgrade.php line 1764 called function make_site_theme_from_default($theme_name, $template) that seems to do this.
The function uses this code to do this:
// Rewrite the theme header.
$stylelines = explode("
", implode('', file("$site_dir/style.css")));
if ($stylelines) {
$f = fopen("$site_dir/style.css", 'w');
foreach ($stylelines as $line) {
if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name;
elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url');
elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.';
elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1';
elseif (strpos($line, 'Author:') !== false) $line = 'Author: You';
fwrite($f, $line . "
");
}
fclose($f);
}