[wp-trac] [WordPress Trac] #16744: Theme editor doesn't work on child themes whose parents have a custom theme directory root

WordPress Trac wp-trac at lists.automattic.com
Thu Mar 17 18:09:15 UTC 2011


#16744: Theme editor doesn't work on child themes whose parents have a custom theme
directory root
----------------------------+------------------------------
 Reporter:  DJPaul          |       Owner:
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Administration  |     Version:  3.1
 Severity:  normal          |  Resolution:
 Keywords:                  |
----------------------------+------------------------------
Changes (by officialjunk):

 * version:  3.0 => 3.1


Comment:

 in theme-editor.php, change

 {{{
 if ( 'theme' == $dir ) {
         $file = dirname(dirname($themes[$theme]['Template Dir'])) . $file
 ;
 }
 }}}

 to


 {{{
 if ( 'theme' == $dir ) {
         if($themes[$theme]['Template'] == $themes[$theme]['Stylesheet']){
                 $file = dirname(dirname($themes[$theme]['Template Dir']))
 . $file ;
         }
 }
 }}}

 it's around line #63, for me, just above the call to
 validate_file_to_edit().

 the problem is the path to a bp child theme's file path is already
 complete, and the path to the buddypress directory gets appended to the
 front of it, resulting in a path pointing to a non existent file. so, i
 just put in the test to see if the theme is not a child theme before
 appending the paths, and if it is a child theme, the $file variable is
 left alone.

 this works fine for all normal themes and all child themes of the bp-
 default theme. i would imagine that this would break the editing
 capabilities of a child theme of a normal theme, but as i don't have any
 to test with, so i'm unsure.

 the complete fix should check specifically if the parent theme is bp-
 default or not, but i'll leave that to the experts.


 Replying to [comment:1 DJPaul]:
 > This seems to be caused by the call to validate_file_to_edit() in theme-
 editor.php. The logic when setting $file assumes that the theme root
 directory is always two levels up.
 >
 > On a clean debug install, $file looks like:
 > {{{
 > /Users/paul/Sites/example.com/wp-
 content/plugins/buddypress/Users/paul/Sites/example.com/wp-
 content/themes/test/functions.php
 > }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16744#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list