| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Merchant |
| 4 |
* Plugin URI: https://athemes.com/merchant |
| 5 |
* Description: All-in-one WooCommerce plugin for pre-orders, product labels, buy now, quick view, discount rules and more. |
| 6 |
* Version: 2.2.3 |
| 7 |
* Author: aThemes |
| 8 |
* Author URI: https://athemes.com |
| 9 |
* License: GPLv3 or later License |
| 10 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html |
| 11 |
* Text Domain: merchant |
| 12 |
* Domain Path: /languages |
| 13 |
* Requires PHP: 7.3 |
| 14 |
* |
| 15 |
* WC requires at least: 6.0 |
| 16 |
* WC tested up to: 10.5.0 |
| 17 |
* |
| 18 |
* @package Merchant |
| 19 |
* @since 1.0 |
| 20 |
*/ |
| 21 |
|
| 22 |
// Exit if accessed directly. |
| 23 |
if ( ! defined( 'ABSPATH' ) ) { |
| 24 |
exit; |
| 25 |
} |
| 26 |
|
| 27 |
// Merchant constants. |
| 28 |
define( 'MERCHANT_VERSION', '2.2.3' ); |
| 29 |
define( 'MERCHANT_DB_VERSION', '1.1.0' ); // Update only when the database structure changes. In inc/classes/class-merchant-db-tables.php |
| 30 |
define( 'MERCHANT_FILE', __FILE__ ); |
| 31 |
define( 'MERCHANT_BASE', trailingslashit( plugin_basename( MERCHANT_FILE ) ) ); |
| 32 |
define( 'MERCHANT_DIR', trailingslashit( plugin_dir_path( MERCHANT_FILE ) ) ); |
| 33 |
define( 'MERCHANT_URI', trailingslashit( plugins_url( '/', MERCHANT_FILE ) ) ); |
| 34 |
define( 'MERCHANT_REVIEW_URL', 'https://wordpress.org/support/plugin/merchant/reviews/#new-post' ); |
| 35 |
|
| 36 |
/** |
| 37 |
* Merchant class. |
| 38 |
* |
| 39 |
*/ |
| 40 |
class Merchant { |
| 41 |
|
| 42 |
/** |
| 43 |
* The single class instance. |
| 44 |
* |
| 45 |
*/ |
| 46 |
private static $instance = null; |
| 47 |
|
| 48 |
/** |
| 49 |
* Instance. |
| 50 |
* |
| 51 |
*/ |
| 52 |
public static function instance() { |
| 53 |
if ( is_null( self::$instance ) ) { |
| 54 |
self::$instance = new self(); |
| 55 |
} |
| 56 |
return self::$instance; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Constructor. |
| 61 |
* |
| 62 |
*/ |
| 63 |
public function __construct() { |
| 64 |
|
| 65 |
// aThemes White Label Compatibility. |
| 66 |
if ( function_exists( 'athemes_wl_get_data' ) ) { |
| 67 |
$merchant_awl_data = athemes_wl_get_data(); |
| 68 |
|
| 69 |
if ( ! empty( $merchant_awl_data[ 'activate_white_label' ] ) ) { |
| 70 |
define( 'MERCHANT_AWL_ACTIVE', true ); |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
// Translation. |
| 75 |
add_action( 'init', array( $this, 'translation' ) ); |
| 76 |
|
| 77 |
// Declare WooCommerce HPOS Compatibility. |
| 78 |
add_action( 'before_woocommerce_init', function() { |
| 79 |
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { |
| 80 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 81 |
} |
| 82 |
} ); |
| 83 |
|
| 84 |
// Declare incompatibility with Woo 8.3.0+ cart and checkout blocks. |
| 85 |
add_action( 'before_woocommerce_init', function() { |
| 86 |
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) { |
| 87 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, false ); |
| 88 |
} |
| 89 |
} ); |
| 90 |
|
| 91 |
// Load the plugin functionality. |
| 92 |
$this->includes(); |
| 93 |
|
| 94 |
// Initialize the merchant database tables. |
| 95 |
Merchant_DB_Tables::init(); |
| 96 |
} |
| 97 |
|
| 98 |
/** |
| 99 |
* Translation |
| 100 |
* |
| 101 |
*/ |
| 102 |
public function translation() { |
| 103 |
load_plugin_textdomain( 'merchant', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
| 104 |
} |
| 105 |
|
| 106 |
/** |
| 107 |
* Includes. |
| 108 |
* |
| 109 |
*/ |
| 110 |
public function includes() { |
| 111 |
require_once MERCHANT_DIR . 'admin/class-merchant-admin-loader.php'; |
| 112 |
require_once MERCHANT_DIR . 'inc/class-merchant-loader.php'; |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
/** |
| 117 |
* Run the plugin. |
| 118 |
*/ |
| 119 |
Merchant::instance(); |