Skip to content

Commit ef26dc0

Browse files
authored
Merge pull request #9 from WordPress-Phoenix/develop
hotpatch: php5 backwards compat fix
2 parents bbf7c75 + b9e535b commit ef26dc0

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#### 2.5.2
2+
* Remove PHP7 function and replace with PHP5+ function for backwards compatibility.
3+
14
#### 2.5.1
25
* Fix single site issue
36

src/abstract-plugin.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @author Seth Carstens
66
* @package abtract-plugin-base
7-
* @version 2.5.0
7+
* @version 2.5.1
88
* @license GPL 2.0 - please retain comments that express original build of this file by the author.
99
*/
1010

@@ -238,8 +238,8 @@ public function autoload( $class ) {
238238
protected function configure_defaults() {
239239
$this->modules = new \stdClass();
240240
$this->modules->count = 0;
241-
$this->installed_dir = dirname( static::$current_file, 1 );
242-
$this->plugin_basedir = dirname( static::$current_file, 2 );
241+
$this->installed_dir = static::dirname( static::$current_file, 1 );
242+
$this->plugin_basedir = static::dirname( static::$current_file, 2 );
243243
$assumed_plugin_name = basename( $this->plugin_basedir );
244244
$this->plugin_file = $this->plugin_basedir . '/' . $assumed_plugin_name . '.php';
245245
$this->wp_plugin_slug = $assumed_plugin_name . '/' . $assumed_plugin_name . '.php';
@@ -283,6 +283,22 @@ public static function deactivate() {
283283
*/
284284
abstract protected function defines_and_globals();
285285

286+
/**
287+
* Dirname function that mimics PHP7 dirname() enhancements so that we can enable PHP5.6 support.
288+
*
289+
* @param $path
290+
* @param int $count
291+
*
292+
* @return string
293+
*/
294+
public static function dirname($path, $count=1){
295+
if ($count > 1){
296+
return dirname(static::dirname($path, --$count));
297+
}else{
298+
return dirname($path);
299+
}
300+
}
301+
286302
/**
287303
* Utility function to get class name from filename if you follow this abstract plugin's naming standards
288304
*

0 commit comments

Comments
 (0)