woocommerce-advanced-ordernumbers.php 2.69 KB
Newer Older
1 2
<?php
/**
3 4
 * Plugin Name: Woocommerce Advanced Ordernumbers
 * Plugin URI: http://open-tools.net/woocommerce/advanced-ordernumbers-for-woocommerce.html
5
 * Description: Lets the user freely configure the order numbers in WooCommerce.
6
 * Version: 1.3.5
7
 * Author: Open Tools
8 9 10 11
 * Author URI: http://open-tools.net
 * Text Domain: woocommerce-advanced-ordernumbers
 * Domain Path: 
 * License: GPL2+
12
 * Network: true
13 14
 * WC requires at least: 2.2
 * WC tested up to: 2.5
15 16 17 18 19
*/

if ( ! defined( 'ABSPATH' ) ) { 
	exit; // Exit if accessed directly
}
20 21 22 23 24
// Define a global flag so the basic plugin can deactivate itself if this plugin is loaded
if ( !defined('OPENTOOLS_ADVANCED_ORDERNUMBERS') ) {
	define ('OPENTOOLS_ADVANCED_ORDERNUMBERS', true);
}

25 26 27 28 29 30 31 32 33
// *****************************************************************
// * PLUGIN UPDATES
// *****************************************************************
require 'opentools-update-checker.php';
$myUpdateChecker = new OpenToolsPluginUpdateChecker(
    'http://www.open-tools.net/UpdateServer/index.php?package=WooCommerce&extension=AdvancedOrdernumbers',
    __FILE__,
    'woocommerce-advanced-ordernumbers'
);
34 35 36 37
$myUpdateChecker->declareCredentials(array(
	'order_number' => __('Order Number:'), 
	'order_pass'   => __('Order Password:'),
));
38 39 40 41 42
$myUpdateChecker->addAccessCheckQueryArgFilter('oton_addAccessCheckArg');
function oton_addAccessCheckArg($downloadurl) {
	return $downloadurl . (parse_url($downloadurl, PHP_URL_QUERY) ? '&' : '?') . 'check_access=1';
}

43 44 45 46
// $myUpdateChecker->checkForUpdates();
// *****************************************************************


47
function otaon_is_wc_active() {
48 49 50 51
// Makes sure the plugin is defined before trying to use it
	if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
		require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
	}
52 53
	return 
		in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) 
54
		||
55 56 57
		is_plugin_active_for_network( 'woocommerce/woocommerce.php' );
}

58 59 60
/**
 * Check if WooCommerce is active
 **/
61
if ( otaon_is_wc_active() ) {
62

63
	if (file_exists(plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce.php') && !class_exists("OpenToolsOrdernumbers")) {
64
		require_once( plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce.php');
65 66 67
	} 
	if (!class_exists("OpenToolsOrdernumbersBasic"))
		require_once( plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce_basic.php');
68

69
	// instantiate the plugin class
70
	if (class_exists("OpenToolsOrdernumbers")) {
71 72 73
		$ordernumber_plugin = new OpenToolsOrdernumbers(plugin_basename(__FILE__));
	} elseif (class_exists("OpenToolsOrdernumbersBasic")) {
		$ordernumber_plugin = new OpenToolsOrdernumbersBasic(plugin_basename(__FILE__));
74
	}
75

76
}