Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #28300


Ignore:
Timestamp:
05/18/2014 06:56:37 PM (10 years ago)
Author:
ocean90
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28300 – Description

    initial v1  
    22
    33First, it adds a "/" to the replacement expression when the source replacement already contains a "/" (Note that ABSPATH has a trailing slash):
    4             $potential_folder = preg_replace( '#^' . preg_quote( $dir, '#' ) . '/#i', trailingslashit( constant( $constant ) ), $folder );
     4
     5{{{
     6$potential_folder = preg_replace( '#^' . preg_quote( $dir, '#' ) . '/#i', trailingslashit( constant( $constant ) ), $folder );
     7}}}
     8
    59
    610This should be:
    7                $potential_folder = preg_replace( '#^' . preg_quote( trailingslashit($dir), '#' ) . '#i', trailingslashit( constant( $constant ) ), $folder );
     11
     12{{{
     13$potential_folder = preg_replace( '#^' . preg_quote( trailingslashit($dir), '#' ) . '#i', trailingslashit( constant( $constant ) ), $folder );
     14}}}
     15
    816
    917Second, it checks that the directory exists. This is not the case during theme and plugin installs, where the not existing directory is specified. Instead, only the parent should be checked.
     
    1119After:
    1220
    13                 if ( $this->is_dir( $potential_folder ) ) {
    14                     $this->cache[ $folder ] = $potential_folder;
    15                     return $potential_folder;
    16                 }
     21
     22{{{
     23if ( $this->is_dir( $potential_folder ) ) {
     24    $this->cache[ $folder ] = $potential_folder;
     25    return $potential_folder;
     26}
     27}}}
     28
    1729Adding:
    18               else {
    19                     $potential_parent_folder = trailingslashit(preg_replace('#[^/]*/$#', '', $potential_folder));
    20                     if ( $this->is_dir( $potential_parent_folder ) ) {
    21                         $this->cache[ $folder ] = $potential_folder;
    22                         return $potential_folder;
    23                     }
    24                 }
     30
     31{{{
     32else {
     33      $potential_parent_folder = trailingslashit(preg_replace('#[^/]*/$#', '', $potential_folder));
     34      if ( $this->is_dir( $potential_parent_folder ) ) {
     35            $this->cache[ $folder ] = $potential_folder;
     36            return $potential_folder;
     37      }
     38}
     39}}}
     40
    2541
    2642Would test for a valid parent, instead. (E.g. wp-content/themes instead of wp-content/themes/newtheme)