Make WordPress Core

Opened 11 years ago

Closed 9 years ago

Last modified 9 years ago

#27201 closed defect (bug) (fixed)

Any file called index.php is labeled as Main Index Template by theme editor, even if it is not the main index template.

Reported by: shelob9's profile Shelob9 Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version: 1.5
Component: Themes Keywords: has-patch theme-editor
Focuses: administration Cc:

Description

In the theme editor, any file called index.php is labeled as 'Main Index Template' even if it is in a subdirectory of the theme and is not actually the main index template for the theme.

Attachments (9)

27201.diff (662 bytes) - added by Shelob9 11 years ago.
27201.2.diff (1.3 KB) - added by Shelob9 11 years ago.
27201-3.patch (2.2 KB) - added by bravokeyl 11 years ago.
27201-3.2.patch (2.2 KB) - added by bravokeyl 11 years ago.
27201.4.diff (2.5 KB) - added by MikeHansenMe 11 years ago.
small changes and minor code cleanup
27201.patch (5.7 KB) - added by bravokeyl 11 years ago.
different approach instead of comparing to 'themes' directory.
27201-5.patch (5.7 KB) - added by bravokeyl 11 years ago.
Corrected Missing space after variable
27201.6.diff (5.8 KB) - added by MikeHansenMe 10 years ago.
27201.3.diff (4.3 KB) - added by wonderboymusic 9 years ago.

Download all attachments as: .zip

Change History (26)

@Shelob9
11 years ago

@Shelob9
11 years ago

#1 @Shelob9
11 years ago

I have attached two patches for this issue. 27201.diff fixes the issue by labeling any file called index.php that is not the main index template with its path and file name. So, for example, 'inc/index.php' will be labeled as 'inc/index.php'. This is a nice easy solution, but not the greatest. There must be a better way to label these index files, I just don't know what.

27201.2.diff does the same thing, and also adds braces to the two conditionals in the same section of the file, as is called for by WordPress coding standards. It seemed odd to have it right for one conditional, but wrong for the two right before it, but I was worried about the patch exceeding the scope of the issue, so I made two patches.

#2 @SergeyBiryukov
11 years ago

  • Component changed from General to Themes
  • Version changed from trunk to 1.5

#3 @SergeyBiryukov
11 years ago

Please use tabs rather than spaces for indentation (per WordPress Coding Standards).

#4 @bravokeyl
11 years ago

Not just index.php , any standard WP theme descriptive file of $wp_file_descriptions .

@bravokeyl
11 years ago

#5 @bravokeyl
11 years ago

Any comments on the patch..

#6 @SergeyBiryukov
11 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 3.9

@MikeHansenMe
11 years ago

small changes and minor code cleanup

#7 @MikeHansenMe
11 years ago

27201.4.diff removes the return ""; so that at the end of the function it returns the default and consistent filename rather than an empty string. Also converted spaces to tabs and some other minor clean up.

Last edited 11 years ago by MikeHansenMe (previous) (diff)

#8 @bravokeyl
11 years ago

It seems good to me and ready to go.

Last edited 11 years ago by bravokeyl (previous) (diff)

#9 @aaroncampbell
11 years ago

  • Keywords needs-patch added; has-patch removed

First, we prefer to use "yoda conditions" so it should be 'themes' == basename( dirname( dirname( $file ) ) )

Having said that though, we can't actually compare to 'themes' because you can specify a custom themes directory using register_theme_directory(). Take a look at get_theme_root() and get_raw_theme_root() to see what I'm talking about. They fall back to WP_CONTENT_DIR/themes/ but they allow for something custom first.

#10 @aaroncampbell
11 years ago

  • Milestone changed from 3.9 to Future Release

Since this patch isn't ready, we're already in Beta, and this isn't critical or new, I'm going to move it out of the 3.9 milestone.

This ticket was mentioned in IRC in #wordpress-dev by AaronCampbell. View the logs.


11 years ago

@bravokeyl
11 years ago

different approach instead of comparing to 'themes' directory.

@bravokeyl
11 years ago

Corrected Missing space after variable

#12 @bravokeyl
11 years ago

A different approach to get file description by passing relative path and comparing using pathinfo() as whether the files are in the base level or not.

And implementing brace-style standards.

#13 @bravokeyl
11 years ago

  • Keywords has-patch added; needs-patch removed

#14 @obenland
10 years ago

  • Keywords theme-editor added

#15 @wonderboymusic
9 years ago

  • Keywords changed from has-patch, theme-editor to has-patch theme-editor
  • Milestone changed from Future Release to 4.4
  • Owner set to wonderboymusic
  • Status changed from new to assigned

#16 @wonderboymusic
9 years ago

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

In 34658:

Theme Editor: ensure that files named index.php in theme subfolders are not labeled as "Main Index Template"

Props MikeHansenMe, wonderboymusic, bravokeyl, Shelob9.
Fixes #27201.

#17 @SergeyBiryukov
9 years ago

#34828 was marked as a duplicate.

Note: See TracTickets for help on using tickets.