[wp-trac] [WordPress Trac] #31620: get_raw_theme_root does not resolve custom theme folder when is the unique

WordPress Trac noreply at wordpress.org
Thu Jul 9 00:41:26 UTC 2015


#31620: get_raw_theme_root does not resolve custom theme folder when is the unique
-------------------------------------+------------------------------
 Reporter:  giuseppe.mazzapica       |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Themes                   |     Version:  3.1
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+------------------------------

Comment (by toscho):

 A note on readability: can we please get rid of the overly long ternary
 return expression? This is not easy to read:

 {{{
 return strpos( $theme_path_normalized, $content_path_normalized ) === 0 ?
 substr( $theme_path_normalized, strlen( $content_path_normalized ) ) :
 $theme_path_normalized;
 }}}

 It should rather look like this:

 {{{
 if ( strpos( $theme_path_normalized, $content_path_normalized ) === 0 ) {
         $length = strlen( $content_path_normalized );
         return substr( $theme_path_normalized, $length;
 }

 return $theme_path_normalized;
 }}}

 Oh, and what happens when there are multi-byte characters in the content
 path? `strlen()` counts bytes, not characters. Will that still work? This
 is probably not a very common setup, but we should cover this edge case
 with `mb_strlen()` and `mb_substr()`. Thoughts?

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


More information about the wp-trac mailing list