WordPress.org

Make WordPress Core

#22634 closed defect (bug) (duplicate)

Plugin Editor ignores &plugin= variable

Reported by: ZjanPreijde Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.4.2
Component: Plugins Keywords:
Focuses: Cc:

Description

When a plugin is chosen and subsequently a file belonging to that plugin, a link is followed with the ?file=xx/zz&plugin=xx variables.
The plugin has the following code:

if ( isset($_REQUEST['file']) )
	$plugin = stripslashes($_REQUEST['file']);

if ( empty($plugin) ) {
	$plugin = array_keys($plugins);
	$plugin = $plugin[0];
}

$plugin_files = get_plugin_files($plugin);

if ( empty($file) )
	$file = $plugin_files[0];
else
	$file = stripslashes($file);

The result is :

  1. The plugin select box is reset to the first plugin
  2. The '(active)'/'(inactive)' text does not correspond to the chosen plugin any more.

I think the code should be changed into the following:

if ( isset($_REQUEST['plugin']) )
	$plugin = stripslashes($_REQUEST['plugin']);

if ( isset($_REQUEST['file']) )
	$file = stripslashes($_REQUEST['file']);

if ( empty($plugin) || !in_array($plugin, array_keys($plugins)) ) {
	$plugin = array_keys($plugins);
	$plugin = $plugin[0];
	$file = "";
}

$plugin_files = get_plugin_files($plugin);

if ( empty($file) || !in_array($file, $plugin_files) )
	$file = $plugin_files[0];

I'd attach a diff, if I'd only know how to create one :-)

Change History (5)

comment:1 ZjanPreijde17 months ago

In addition, in
wp-admin/includes/class-wp-plugins-list-table, line 374, the parameter

'?file=' . $plugin_file

should be changed to

'?plugin='. $plugin_file

comment:2 dd3217 months ago

Possibly a duplicate of #17552 or that other ticket related to the plugin var..

comment:3 ZjanPreijde17 months ago

Yes, you're right. The plugin editor should be changed so $plugin points to the plugin (or main plugin file), and $file to the file within the plugin. The class class-wp-plugins-list-table should still also be changed ('?plugin=') to reflect the change in the editor.

comment:4 SergeyBiryukov16 months ago

#22789 was marked as a duplicate.

comment:5 SergeyBiryukov12 months ago

  • Keywords needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  1. The plugin select box is reset to the first plugin
  2. The '(active)'/'(inactive)' text does not correspond to the chosen plugin any more.

#24122 has a patch for point a. #17552 has a patch for point b.

Note: See TracTickets for help on using tickets.