From 660a7eea0eabcd8889645866a0787938e11bd408 Mon Sep 17 00:00:00 2001 From: Paul Dechov Date: Mon, 7 May 2018 08:27:22 -0400 Subject: [PATCH 1/2] Fix plugin installer extracting filename from path --- includes/class-wc-install.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-install.php b/includes/class-wc-install.php index ee80972196b..f21c23cc6d1 100644 --- a/includes/class-wc-install.php +++ b/includes/class-wc-install.php @@ -1078,8 +1078,9 @@ CREATE TABLE {$wpdb->prefix}woocommerce_termmeta ( * @param string $key Plugin relative path. Example: woocommerce/woocommerce.php. */ private static function associate_plugin_file( $plugins, $key ) { - $path = explode( '/', $key ); - $plugins[ $path[1] ] = $key; + $path = explode( '/', $key ); + $filename = array_slice( $path, -1 )[0]; + $plugins[ $filename ] = $key; return $plugins; } From d7dc2d45a4bc1c1cabed53054a3a20601736e182 Mon Sep 17 00:00:00 2001 From: Paul Dechov Date: Mon, 7 May 2018 14:48:18 -0400 Subject: [PATCH 2/2] Use simpler function for retrieving last array item Also avoids array dereferencing syntax incompatible with PHP <5.4. --- includes/class-wc-install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-install.php b/includes/class-wc-install.php index f21c23cc6d1..11a247c872b 100644 --- a/includes/class-wc-install.php +++ b/includes/class-wc-install.php @@ -1079,7 +1079,7 @@ CREATE TABLE {$wpdb->prefix}woocommerce_termmeta ( */ private static function associate_plugin_file( $plugins, $key ) { $path = explode( '/', $key ); - $filename = array_slice( $path, -1 )[0]; + $filename = end( $path ); $plugins[ $filename ] = $key; return $plugins; }