Commit 7966244e authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

V1.2: Make random variable indicators case-insensitive; First shot at multisite

parent 5bdc0ab7
BASE=ordernumbers
PLATTFORM=woocommerce
VENDOR=opentools
VERSION=1.1
VERSION=1.2
DIR = $(shell pwd)
SVNDIR=wordpress-plugin-svn
......@@ -40,7 +40,7 @@ clean:
$(SVNDIR)/tags/$(VERSION) :
cd $(SVNDIR) && svn cp trunk tags/$(VERSION)
svn: $(SVNDIR)/trunk $(SVNDIR)/tags/$(VERSION)
svn: $(SVNDIR)/trunk
rsync -avP $(PLUGINFILES) $(BASICPLUGINFILES) $(TRANSLATIONS) $(SVNDIR)/trunk
svn-release: svn $(SVNDIR)/tags/$(VERSION)
......
......@@ -328,7 +328,7 @@ class OrdernumberHelper {
protected function doReplacements ($fmt, $reps) {
// First, replace all random...[n] fields. This needs to be done with a regexp and a callback:
$fmt = preg_replace_callback ('/\[(random)(.*?)([0-9]*?)\]/', array($this, 'replaceRandom'), $fmt);
$fmt = preg_replace_callback ('/\[(random)(.*?)([0-9]*?)\]/i', array($this, 'replaceRandom'), $fmt);
// Only use string-valued variables for replacement (array-valued variables can be used in custom variable definitions!)
$reps = array_filter($reps, function($v) { return !is_array($v);} );
return str_ireplace (array_keys($reps), array_values($reps), $fmt);
......
......@@ -53,7 +53,12 @@ class OrdernumberHelperWooCommerce extends OrdernumberHelper {
wp_enqueue_script( 'ordernumber-script');
// Handle the translations:
$localizations = array( 'ajax_url' => admin_url( 'admin-ajax.php' ) );
// Check for MS dashboard
if( is_network_admin() )
$url = network_admin_url( 'admin-ajax.php' );
else
$url = admin_url( 'admin-ajax.php' );
$localizations = array( 'ajax_url' => $url );
$localizations['ORDERNUMBER_JS_JSONERROR'] = $this->__("Error reading response from server:");
$localizations['ORDERNUMBER_JS_NOT_AUTHORIZED'] = $this->__("You are not authorized to modify order number counters.");
......
......@@ -11,6 +11,9 @@ if ( ! defined( 'ABSPATH' ) ) {
}
require_once( plugin_dir_path( __FILE__ ) . '/ordernumber_helper_woocommerce.php');
class OpenToolsOrdernumbersBasic {
public $ordernumber_meta = "_oton_number_";
public $ordernumber_new_placeholder = "[New Order]";
......
......@@ -2,7 +2,7 @@
Contributors: opentools
Tags: WooCommerce, Order numbers, orders
Requires at least: 4.0
Tested up to: 4.1.1
Tested up to: 4.4
Stable tag: trunk
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl.html
......@@ -67,6 +67,10 @@ The Advanced Ordernumbers for WooCommerce plugin supports some invoicing plugins
== Changelog ==
= 1.2 =
* Make random variable indicators case-insensitive
* First attempts at making the plugin multisite-enabled
= 1.0 =
* Initial release
......
=== WooCommerce Basic Ordernumbers ===
Plugin Name: Ordernumbers for WooCommerce
Contributors: opentools
Tags: WooCommerce, Order numbers, orders
Requires at least: 4.0
Tested up to: 4.1.1
Stable tag: 1.1
Tested up to: 4.4
Stable tag: 1.2
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl.html
......@@ -71,6 +72,14 @@ The Advanced Ordernumbers for WooCommerce plugin supports some invoicing plugins
== Changelog ==
= 1.2 =
* Make random variable indicators case-insensitive
* First attempts at making the plugin multisite-enabled
= 1.1.1 =
* Renamed the plugin files
* Added icon for the plugin directory
= 1.1 =
* Some smaller bugfixes
* Removed variable definition for year
......
......@@ -3,12 +3,13 @@
* Plugin Name: Woocommerce Advanced Ordernumbers
* Plugin URI: http://open-tools.net/woocommerce/advanced-ordernumbers-for-woocommerce.html
* Description: Lets the user freely configure the order numbers in WooCommerce.
* Version: 1.1
* Version: 1.2
* Author: Open Tools
* Author URI: http://open-tools.net
* Text Domain: woocommerce-advanced-ordernumbers
* Domain Path:
* License: GPL2+
* Network: true
WC requires at least: 2.2
WC tested up to: 2.3
*/
......@@ -21,10 +22,17 @@ if ( !defined('OPENTOOLS_ADVANCED_ORDERNUMBERS') ) {
define ('OPENTOOLS_ADVANCED_ORDERNUMBERS', true);
}
function otaon_is_wc_active() {
return
in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) )
||
is_plugin_active_for_network( 'woocommerce/woocommerce.php' );
}
/**
* Check if WooCommerce is active
**/
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
if ( otaon_is_wc_active() ) {
if (file_exists(plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce.php') && !class_exists("OpenToolsOrdernumbers")) {
require_once( plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce.php');
......
......@@ -3,11 +3,12 @@
* Plugin Name: WooCommerce Basic Ordernumbers
* Plugin URI: http://open-tools.net/woocommerce/advanced-ordernumbers-for-woocommerce.html
* Description: Configure WooCommerce ordernumbers to have a running counter and arbitrary, fixed text (prefix / postfix).
* Version: 1.1
* Version: 1.2
* Author: Open Tools
* Author URI: http://open-tools.net
* Text Domain: woocommerce-advanced-ordernumbers
* License: GPL2+
* Network: true
WC requires at least: 2.2
WC tested up to: 2.3
*/
......@@ -18,7 +19,17 @@ if ( ! defined( 'ABSPATH' ) ) {
/**
* Check if WooCommerce is active
**/
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
function oton_is_wc_active() {
return
in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) )
||
is_plugin_active_for_network( 'woocommerce/woocommerce.php' );
}
/**
* Check if WooCommerce is active
**/
if ( oton_is_wc_active() ) {
if (file_exists(plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce_basic.php') && !class_exists("OpenToolsOrdernumbersBasic") ) {
require_once( plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce_basic.php');
......@@ -34,7 +45,8 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
}
function ordernumbers_check_deactivate() {
if (defined ('OPENTOOLS_ADVANCED_ORDERNUMBERS')) {
add_action( 'admin_notices', 'ordernumbers_print_basic_admin_notice');
$hook = is_multisite() ? 'network_' : '';
add_action( "{$hook}admin_notices", 'ordernumbers_print_basic_admin_notice');
}
}
add_action( 'plugins_loaded', 'ordernumbers_check_deactivate', 99 );
......@@ -44,4 +56,6 @@ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', g
$ordernumber_plugin = new OpenToolsOrdernumbersBasic(plugin_basename(__FILE__));
}
}
// } else {
// echo "Woocommerce not activated!";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment