Make WordPress Core

Opened 7 years ago

Closed 5 years ago

#4131 closed task (blessed) (fixed)

Edit Theme should allow editing files in subfolders

Reported by: drhallows Owned by: ryan
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.0.10
Component: Themes Keywords: edit themes has-patch
Focuses: Cc:


I have noticed an error that occurs while editing themes from Wordpress' control panel. If there are folders inside the theme folder (i.e. theme/widgets/) the 'widgets' folder is not listed..

Attachments (1)

4131.diff (2.4 KB) - added by DD32 6 years ago.

Download all attachments as: .zip

Change History (19)

comment:1 foolswisdom7 years ago

  • Milestone changed from 2.0.11 to 2.4
  • Summary changed from Editing subfolders of a Wordpress Theme to Edit Theme should allow editing files in subfolders

ENV: WP trunk (2.2) r5237
Reproduced bug using default theme. At wp-admin/theme-editor.php I do not see default/images/header-img.php in the list.

comment:2 foolswisdom7 years ago

  • Keywords edit themes added; theme wordpress removed

comment:3 rob1n7 years ago

  • Milestone changed from 2.4 to 2.3

comment:4 follow-up: thee177 years ago

Looking at the code the problem would be with

wp-admin/theme-editor.php on line 21

$allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']);

This appears to be where the file list is called, maybe it might be possible to follow the sub folders of $themes[$theme]

comment:5 in reply to: ↑ 4 Nazgul7 years ago

  • Milestone changed from 2.3 to 2.4

Replying to thee17:

Looking at the code the problem would be with
wp-admin/theme-editor.php on line 21

No, the problem is inside get_themes(), which is called on line 9.

comment:6 thee176 years ago

  • Keywords hunt-inactive added

DD326 years ago

comment:7 DD326 years ago

  • Keywords has-patch added; hunt-inactive removed

Patch allows get_themes to see Template files in sub-dirs, Has the main impact of allowing the theme editor to view them.

As a side effect of allowing get_themes() to return template files in subdirectories(only a single level -- And stylesheets are not looked for), Templates could exist in the folder, Under the current situation template files can only exist within the main theme directory.

As such, I added a function theme_basename() it basically returns the path of a file relitive to its theme directory, ie. theme_basename('wp-content/themes/my-theme/extra-templates/template1.php') will return 'extra-templates/template1.php'. That allows for the templates to continue working correctly.

Templates can now exist in those subdirectories.

comment:8 thee176 years ago

  • Milestone changed from 2.5 to 2.6

comment:9 mrmist6 years ago

See also #6531

comment:10 thee176 years ago

  • Component changed from Administration to Themes
  • Owner anonymous deleted

comment:11 thee176 years ago

  • Component changed from Themes to Template
  • Owner set to anonymous

comment:12 navjotjsingh5 years ago

  • Milestone changed from 2.9 to 2.8

Seeing recent changes in editing capabilites in 2.8 coming, shouldn't this also get fixed in 2.8 Any progress? I would love to see this too...its tiring to edit some files via FTP and remaining via WP-Admin..it would be good if I could edit right from dashboard now that syntax highlighting is also there.

comment:13 ryan5 years ago

  • Type changed from defect (bug) to task (blessed)

comment:14 ryan5 years ago

  • Owner changed from anonymous to ryan

comment:15 ryan5 years ago

  • Component changed from Template to Themes

comment:16 zeronex5 years ago

would be nice to allow Full screen mode, similar to post editing.

comment:17 zeronex5 years ago

and additionally it would be cool to have API lookup AJAX based for quick lookup.

comment:18 ryan5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [10835]) Show template files in subdirs. Props DD32. fixes #4131

Note: See TracTickets for help on using tickets.