Opened 20 years ago
Closed 19 years ago
#2781 closed defect (bug) (fixed)
Notice: Undefined variable: template in c:\Inetpub\wwwroot\wp\wp-admin\admin-functions.php on line 1504
| Reported by: | Denis-de-Bernardy | Owned by: | rob1n |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.2 |
| Component: | Administration | Version: | 2.0.2 |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: | Focuses: |
Description
Notice: Undefined variable: template in c:\Inetpub\wwwroot\wp\wp-admin\admin-functions.php on line 1504
Attachments (1)
Change History (11)
#2
@
20 years ago
also of interest, in the same area:
Notice: Undefined offset: 1 in c:\Inetpub\wwwroot\wp\wp-admin\admin-functions.php on line 1489 Notice: Undefined offset: 1 in c:\Inetpub\wwwroot\wp\wp-admin\admin-functions.php on line 1491 Notice: Undefined offset: 1 in c:\Inetpub\wwwroot\wp\wp-admin\admin-functions.php on line 1494 Notice: Undefined offset: 1 in c:\Inetpub\wwwroot\wp\wp-admin\admin-functions.php on line 1498 Notice: Undefined offset: 1 in c:\Inetpub\wwwroot\wp\wp-admin\admin-functions.php on line 1499 Notice: Undefined offset: 1 in c:\Inetpub\wwwroot\wp\wp-admin\admin-functions.php on line 1494
#3
@
20 years ago
function get_plugin_data($plugin_file) {
$plugin_data = implode('', file($plugin_file));
preg_match("|Plugin Name:(.*)|i", $plugin_data, $plugin_name);
preg_match("|Plugin URI:(.*)|i", $plugin_data, $plugin_uri);
preg_match("|Description:(.*)|i", $plugin_data, $description);
preg_match("|Author:(.*)|i", $plugin_data, $author_name);
preg_match("|Author URI:(.*)|i", $plugin_data, $author_uri);
if (preg_match("|Version:(.*)|i", $plugin_data, $version))
$version = $version[1];
else
$version = '';
$description = isset($description[1]) ? wptexturize($description[1]) : '';
$name = isset($plugin_name[1]) ? $plugin_name[1] : '';
$name = trim($name);
$plugin = $name;
if (isset($plugin_uri[1]) && '' != $plugin_uri[1] && '' != $name) {
$plugin = '<a href="'.$plugin_uri[1].'" title="'.__('Visit plugin homepage').'">'.$plugin.'</a>';
}
if (isset($author_name[1]) && isset($author_uri[1]) && '' == $author_uri[1]) {
$author = $author_name[1];
} elseif (isset($author_name[1]) && isset($author_uri[1])) {
$author = '<a href="'.$author_uri[1].'" title="'.__('Visit author homepage').'">'.$author_name[1].'</a>';
} else {
$author = '';
}
return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version);
}
#4
@
20 years ago
likewise:
function get_theme_data($theme_file) {
$theme_data = implode('', file($theme_file));
preg_match("|Theme Name:(.*)|i", $theme_data, $theme_name);
preg_match("|Theme URI:(.*)|i", $theme_data, $theme_uri);
preg_match("|Description:(.*)|i", $theme_data, $description);
preg_match("|Author:(.*)|i", $theme_data, $author_name);
preg_match("|Author URI:(.*)|i", $theme_data, $author_uri);
preg_match("|Template:(.*)|i", $theme_data, $template);
if ( preg_match("|Version:(.*)|i", $theme_data, $version) )
$version = $version[1];
else
$version ='';
if ( preg_match("|Status:(.*)|i", $theme_data, $status) )
$status = $status[1];
else
$status ='publish';
$description = isset($description[1]) ? wptexturize($description[1]) : '';
$name = isset($theme_name[1]) ? $theme_name[1] : '';
$name = trim($name);
$theme = $name;
if ( isset($author_name[1]) && isset($author_uri[1]) && '' == $author_uri[1] ) {
$author = $author_name[1];
} elseif (isset($author_name[1]) && isset($author_uri[1])) {
$author = '<a href="' . $author_uri[1] . '" title="' . __('Visit author homepage') . '">' . $author_name[1] . '</a>';
} else {
$author = '';
}
$template = isset($template[1]) ? $template[1] : '';
return array('Name' => $name, 'Title' => $theme, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Status' => $status);
}
#5
@
19 years ago
- Resolution → worksforme
- Status new → closed
I'm unable to reproduce this on my 2.0.x blog.
Feel free to reopen this if you have additional information.
#7
@
19 years ago
- Owner changed from to
- Status reopened → new
I can see this.
get_plugin_data has dodgy vars as it looks very like a copy and paste error from loading template_data.
Attaching a patch to fix this and make it return a few extra bits of usefull info for plugin authors to be able to use.
#8
@
19 years ago
- Keywords has-patch commit added
Attached patch removes the use of an undefined variable from the return of get_plugin_data and brings in some of the smaller changes from #3047
Basically you can now easily access off of the plugin info the following extra data:
[PluginURI] => Straight from the comment in the plugin file. [AuthorURI] => Straight from the comment in the plugin file. [URL] => URL of the folder containing the plugin - to make creating urls to suborinate files easy [Path] => Absolute path of the folder containing the plugin - to make including easy etc.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
should likely be:
return array ('Name' => $name, 'Title' => $plugin, 'Description' => $description, 'Author' => $author, 'Version' => $version);