From 6e53cb95e60d96cdce6669ad0449e206d79cf888 Mon Sep 17 00:00:00 2001
From: Reinhold Kainhofer <reinhold@kainhofer.com>
Date: Thu, 26 May 2016 19:45:21 +0200
Subject: [PATCH] Fix callbacks with PHP 5.3

---
 Makefile                       |  2 +-
 library/ordernumber_helper.php | 17 ++++++++---------
 readme.txt                     |  2 +-
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index e607b32..f64f3bc 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 BASE=ordernumbers
 PLATTFORM=woocommerce
 VENDOR=opentools
-VERSION=1.3.3
+VERSION=1.3.4
 DIR = $(shell pwd)
 SVNDIR=wordpress-plugin-svn
 
diff --git a/library/ordernumber_helper.php b/library/ordernumber_helper.php
index de0180a..ecb9775 100644
--- a/library/ordernumber_helper.php
+++ b/library/ordernumber_helper.php
@@ -16,7 +16,7 @@ function trl($string) {
 
 class OrdernumberHelper {
 	static $_version = "0.1";
-	protected $_callbacks = array();
+	protected $callbacks = array();
 	public $_styles = array(
 		'counter-table-class' => "table-striped",
 		'counter-table-style' => "",
@@ -103,7 +103,7 @@ class OrdernumberHelper {
 	
 	public function __($string) {
 		if (isset($this->callbacks["translate"])) {
-			return $this->callbacks["translate"]($string);
+			return call_user_func_array($this->callbacks['translate'], func_get_args());
 		} else {
 			return $string;
 		}
@@ -142,7 +142,7 @@ class OrdernumberHelper {
 
 	public function urlPath($type, $file) {
 		if (isset($this->callbacks['urlPath'])) {
-			return $this->callbacks['urlPath']($type, $file);
+			return call_user_func_array($this->callbacks['urlPath'], func_get_args());
 		} else {
 			throw new Exception('No callback defined for urlPath(type, file)!');
 		}
@@ -150,13 +150,13 @@ class OrdernumberHelper {
 	
 	protected function replacementsCallback ($func, &$reps, $details, $nrtype) {
 		if (isset($this->callbacks[$func])) {
-			return $this->callbacks[$func]($reps, $details, $nrtype);
+			return call_user_func_array($this->callbacks[$func], array(&$reps, $details, $nrtype));
 		}
 	}
 
 	protected function getCounter($type, $countername, $default) {
 		if (isset($this->callbacks['getCounter'])) {
-			return $this->callbacks['getCounter']($type, $countername, $default);
+			return call_user_func_array($this->callbacks['getCounter'], func_get_args());
 		} else {
 			throw new Exception('No callback defined for getCounter(type, countername, default)!');
 		}
@@ -164,15 +164,15 @@ class OrdernumberHelper {
 	
 	protected function setCounter($type, $countername, $value) {
 		if (isset($this->callbacks['getCounter'])) {
-			return $this->callbacks['getCounter']($type, $countername, $value);
+			return call_user_func_array($this->callbacks['setCounter'], func_get_args());
 		} else {
 			throw new Exception('No callback defined for setCounter(type, countername, value)!');
 		}
 	}
 	
 	public function getAllCounters($type) {
-		if (isset($this->callbacks['getCounter'])) {
-			return $this->callbacks['getCounter']($type);
+		if (isset($this->callbacks['getAllCounters'])) {
+			return call_user_func_array($this->callbacks['getAllCounters'], func_get_args());
 		} else {
 			throw new Exception ('No callback defined for getAllCounters(type)!');
 		}
@@ -403,7 +403,6 @@ class OrdernumberHelper {
 		$format = $this->doReplacements($format, $reps);
 		$ctrsettings = $this->extractCounterSettings ($format, $type, $ctrsettings);
 
-// JFactory::getApplication()->enqueueMessage("<pre>Replacements for $type:".print_r($reps,1)."</pre>", 'error');
 		// Increment the counter only if the format contains a placeholder for it!
 		if (strpos($ctrsettings["${type}_format"], "#") !== false) {
 			$countername = $ctrsettings["${type}_counter"];
diff --git a/readme.txt b/readme.txt
index e3d429f..67d789e 100644
--- a/readme.txt
+++ b/readme.txt
@@ -4,7 +4,7 @@ Contributors: opentools
 Tags: WooCommerce, Order numbers, orders
 Requires at least: 4.0
 Tested up to: 4.5
-Stable tag: 1.3.3
+Stable tag: 1.3.4
 License: GPLv3 or later
 License URI: http://www.gnu.org/licenses/gpl.html
 
-- 
GitLab