Changes between Initial Version and Version 1 of Ticket #28300
- Timestamp:
- 05/18/2014 06:56:37 PM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #28300 – Description
initial v1 2 2 3 3 First, 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 5 9 6 10 This 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 8 16 9 17 Second, 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. … … 11 19 After: 12 20 13 if ( $this->is_dir( $potential_folder ) ) { 14 $this->cache[ $folder ] = $potential_folder; 15 return $potential_folder; 16 } 21 22 {{{ 23 if ( $this->is_dir( $potential_folder ) ) { 24 $this->cache[ $folder ] = $potential_folder; 25 return $potential_folder; 26 } 27 }}} 28 17 29 Adding: 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 {{{ 32 else { 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 25 41 26 42 Would test for a valid parent, instead. (E.g. wp-content/themes instead of wp-content/themes/newtheme)