| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Merchant |
| 4 |
* Plugin URI: https://athemes.com |
| 5 |
* Description: All-in-one plugin designed to help you grow your WooCommerce store. Pre-orders, Buy Now buttons, product labels, trust badges, payment logos, and more. |
| 6 |
* Version: 1.8 |
| 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 |
* |
| 14 |
* WC requires at least: 6.0 |
| 15 |
* WC tested up to: 8.3 |
| 16 |
* |
| 17 |
* @package Merchant |
| 18 |
* @since 1.0 |
| 19 |
*/ |
| 20 |
|
| 21 |
// Exit if accessed directly. |
| 22 |
if ( ! defined( 'ABSPATH' ) ) { |
| 23 |
exit; |
| 24 |
} |
| 25 |
|
| 26 |
// Merchant constants. |
| 27 |
define( 'MERCHANT_VERSION', '1.8' ); |
| 28 |
define( 'MERCHANT_FILE', __FILE__ ); |
| 29 |
define( 'MERCHANT_BASE', trailingslashit( plugin_basename( MERCHANT_FILE ) ) ); |
| 30 |
define( 'MERCHANT_DIR', trailingslashit( plugin_dir_path( MERCHANT_FILE ) ) ); |
| 31 |
define( 'MERCHANT_URI', trailingslashit( plugins_url( '/', MERCHANT_FILE ) ) ); |
| 32 |
|
| 33 |
/** |
| 34 |
* Merchant class. |
| 35 |
* |
| 36 |
*/ |
| 37 |
class Merchant { |
| 38 |
|
| 39 |
/** |
| 40 |
* The single class instance. |
| 41 |
* |
| 42 |
*/ |
| 43 |
private static $instance = null; |
| 44 |
|
| 45 |
/** |
| 46 |
* Instance. |
| 47 |
* |
| 48 |
*/ |
| 49 |
public static function instance() { |
| 50 |
if ( is_null( self::$instance ) ) { |
| 51 |
self::$instance = new self(); |
| 52 |
} |
| 53 |
return self::$instance; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Constructor. |
| 58 |
* |
| 59 |
*/ |
| 60 |
public function __construct() { |
| 61 |
|
| 62 |
// Translation. |
| 63 |
add_action( 'init', array( $this, 'translation' ) ); |
| 64 |
|
| 65 |
// Declare WooCommerce HPOS Compatibility. |
| 66 |
add_action( 'before_woocommerce_init', function() { |
| 67 |
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { |
| 68 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 69 |
} |
| 70 |
} ); |
| 71 |
|
| 72 |
// Declare incompatibility with Woo 8.3.0+ cart and checkout blocks. |
| 73 |
add_action( 'before_woocommerce_init', function() { |
| 74 |
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) { |
| 75 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, false ); |
| 76 |
} |
| 77 |
} ); |
| 78 |
|
| 79 |
// Load the plugin functionality. |
| 80 |
$this->includes(); |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Translation |
| 85 |
* |
| 86 |
*/ |
| 87 |
public function translation() { |
| 88 |
load_plugin_textdomain( 'merchant', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
| 89 |
} |
| 90 |
|
| 91 |
/** |
| 92 |
* Includes. |
| 93 |
* |
| 94 |
*/ |
| 95 |
public function includes() { |
| 96 |
require_once MERCHANT_DIR . 'admin/class-merchant-admin-loader.php'; |
| 97 |
require_once MERCHANT_DIR . 'inc/class-merchant-loader.php'; |
| 98 |
} |
| 99 |
|
| 100 |
} |
| 101 |
|
| 102 |
/** |
| 103 |
* Function works with the Merchant class instance |
| 104 |
* |
| 105 |
*/ |
| 106 |
function merchant() { |
| 107 |
return Merchant::instance(); |
| 108 |
} |
| 109 |
merchant(); |
| 110 |
|