WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 20 months ago

#35788 closed defect (bug) (duplicate)

Plugin Editor wrong selected option when file selected

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

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 2 years ago.
Creation of $current_plugin var + better code flavor
35788.1.patch (2.1 KB) - added by jukkarau 2 years ago.
The version attached should work with multiple file selections as well.
35788.diff (5.1 KB) - added by swissspidy 20 months ago.

Download all attachments as: .zip

Change History (10)

@CreativeJuiz
2 years ago

Creation of $current_plugin var + better code flavor

#1 @CreativeJuiz
2 years ago

  • Keywords has-patch needs-testing added

#2 @obenland
2 years ago

  • Version trunk deleted

@jukkarau
2 years ago

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

#3 @jukkarau
2 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
21 months ago

  • Milestone changed from Awaiting Review to 4.7

@swissspidy
20 months ago

#5 follow-up: @swissspidy
20 months 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
20 months ago

  • Component changed from Administration to 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
20 months ago

  • Milestone 4.7 deleted
  • Resolution set to duplicate
  • Status changed from new to 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.