woocommerce-basic-ordernumbers.php 2.14 KB
Newer Older
1 2 3 4
<?php
/**
 * Plugin Name: WooCommerce Basic Ordernumbers
 * Plugin URI: http://open-tools.net/woocommerce/advanced-ordernumbers-for-woocommerce.html
5
 * Description: Configure WooCommerce ordernumbers to have a running counter and arbitrary, fixed text (prefix / postfix).
6
 * Version: 1.3.2
7 8 9 10
 * Author: Open Tools
 * Author URI: http://open-tools.net
 * Text Domain: woocommerce-advanced-ordernumbers
 * License: GPL2+
11
 * Network: true
12 13
 * WC requires at least: 2.2
 * WC tested up to: 2.5
14 15 16 17 18 19 20 21
*/

if ( ! defined( 'ABSPATH' ) ) { 
	exit; // Exit if accessed directly
}
/**
 * Check if WooCommerce is active
 **/
22
function oton_is_wc_active() {
23 24 25
	if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
		require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
	}
26 27 28 29 30 31 32 33 34 35
	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() ) {
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

	if (file_exists(plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce_basic.php') && !class_exists("OpenToolsOrdernumbersBasic") ) {
		require_once( plugin_dir_path( __FILE__ ) . '/ordernumbers_woocommerce_basic.php');
	}

	function ordernumbers_print_basic_admin_notice() { 
		deactivate_plugins( plugin_basename( __FILE__ ) );
		?>
		<div class="error">
			<p><?php _e( 'The <b>OpenTools Advanced Ordernumbers</b> plugin is <b>installed</b> and activated, the <b>basic ordernumber plugin</b> with similar, but limited functionality will be <b>deactivated</b>.', 'opentools-advanced-ordernumbers' ); ?></p>
		</div>
		<?php
	}
	function ordernumbers_check_deactivate() {
		if (defined ('OPENTOOLS_ADVANCED_ORDERNUMBERS')) {
51 52
			$hook = is_multisite() ? 'network_' : '';
			add_action( "{$hook}admin_notices", 'ordernumbers_print_basic_admin_notice');
53 54 55 56 57 58 59 60 61
		}
	}
	add_action( 'plugins_loaded', 'ordernumbers_check_deactivate', 99 );
	
	// instantiate the plugin class
	if (class_exists("OpenToolsOrdernumbersBasic")) {
		$ordernumber_plugin = new OpenToolsOrdernumbersBasic(plugin_basename(__FILE__));
	}
 
62 63 64
// } else {
//    echo "Woocommerce not activated!";
   }