Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#35788 closed defect (bug) (duplicate)

Plugin Editor wrong selected option when file selected

Reported by: CreativeJuiz Owned by:
Priority: normal Milestone:
Component: Plugins Version:
Severity: normal Keywords: has-patch needs-testing
Cc: Focuses: ui, administration

Description

Hi there,

I just seen that when you are in the Plugin Editor page of the WP Admin, the selected option in the top right corner (the name of the plugin) is always the first option if you are editing a plugin file.

For example, with Akismet and WooCommerce installed, select WooCommerce and click the readme.txt file (or another one is not the first WooCommerce file). The select show the first option instead of WooCommerce (here Akismet).

I have a tested fix for that.
See the patch file in attachment.

Thank you for your time and advises.

Attachments (3)

35788.patch​ (2.5 KB ) - added by CreativeJuiz 11 years ago.
Creation of $current_plugin var + better code flavor
35788.1.patch​ (2.1 KB ) - added by jukkarau 10 years ago.
The version attached should work with multiple file selections as well.
35788.diff​ (5.1 KB ) - added by swissspidy 10 years ago.

Download all attachments as: .zip

Change History (10)

@CreativeJuiz
11 years ago

Creation of $current_plugin var + better code flavor

#1 @CreativeJuiz
11 years ago

  • Keywords has-patch needs-testing added

#2 @obenland
11 years ago

  • Version trunk

@jukkarau
10 years ago

The version attached should work with multiple file selections as well.

#3 @jukkarau
10 years ago

Your version worked when choosing a plugin and then selecting a different file for the first time. However if you after the first file change selected an another file from the same plugin, the selected plugin reverted to the wrong one.

This was my first contribution here, so please advise on how to continue from here and what I possibly did wrong. Tried to follow the best practices with the new changes.

#4 @swissspidy
10 years ago

  • Milestone Awaiting Review → 4.7

@swissspidy
10 years ago

#5 follow-up: @swissspidy
10 years ago

explode() isn't really reliable and doesn't solve the root of the problems, which is that $file and $plugin are used interchangeably when they in fact shouldn't.

35788.diff​ correctly passes $plugin when the main plugin file is needed and $file when the current file is needed.

This solves quite a few bugs:

  • The currently selected plugin is always correct, even when editing files in subdirectories.
  • Gets rid of wp_reset_vars(), see #38073.
  • Correctly marks an active plugin as active, even when editing files in subdirectories.

Unfortunately plugin-editor.php is a mess. There are many many things that should be cleaned up someday, like removing <big> tags.

#6 in reply to: ↑ 5 ; follow-up: @SergeyBiryukov
10 years ago

  • Component Administration → Plugins
  • Focuses administration added

Replying to swissspidy:

35788.diff​ correctly passes $plugin when the main plugin file is needed and $file when the current file is needed.

This ticket sounds like a duplicate of #17552 and #24122, no?

#7 in reply to: ↑ 6 @swissspidy
10 years ago

  • Milestone 4.7
  • Resolution → duplicate
  • Status new → closed

Replying to SergeyBiryukov:

Replying to swissspidy:

35788.diff​ correctly passes $plugin when the main plugin file is needed and $file when the current file is needed.

This ticket sounds like a duplicate of #17552 and #24122, no?

Ugh, it absolutely is. Thanks!

Note: See TracTickets for help on using tickets.