[wp-trac] [WordPress Trac] #24122: When opening a file in Plugin Editor, show correct plugin in the dropdown selector

WordPress Trac noreply at wordpress.org
Fri Jun 27 11:20:18 UTC 2014


#24122: When opening a file in Plugin Editor, show correct plugin in the dropdown
selector
--------------------------+------------------------------
 Reporter:  Daedalon      |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Plugins       |     Version:
 Severity:  minor         |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------

Comment (by jayarjo):

 I think the root of this problem is in different place. Here is where
 $plugin variable gets its awkward value:

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

 $plugin_files = get_plugin_files($plugin);

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

 It seems that it is done to invoke the get_plugin_files(), even when
 $plugin is not set. I think the whole thing should be the other way
 around:


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

 if ( empty($file) )
         $file = $plugin;

 $plugin_files = get_plugin_files($file);
 }}}

 If $plugin is not set it will auto-resolve to the first plugin in the
 list. If $file is not set it will default to $plugin, which at this moment
 will be a path to the plugins entry file. Then to retain the logic of
 retrieving only a single level of files to list in the sidebar (another
 awkward behavior I think), we pass $file, instead of $plugin to
 get_plugin_files().

--
Ticket URL: <https://core.trac.wordpress.org/ticket/24122#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list