| 1 |
<?php |
| 2 |
/** |
| 3 |
* The plugin bootstrap file |
| 4 |
* |
| 5 |
* @link https://webappick.com |
| 6 |
* @since 1.0.0 |
| 7 |
* @package Disco |
| 8 |
* @wordpress-plugin |
| 9 |
* Plugin Name: Disco |
| 10 |
* Plugin URI: https://webappick.com/ |
| 11 |
* Description: Create logical, dynamic and automated discounts for your WooCommerce Store based on product, cart, and cart item information. |
| 12 |
* Version: 1.2.90 |
| 13 |
* Author: WebAppick |
| 14 |
* Author URI: https://webappick.com/ |
| 15 |
* License: GPLv3 or later |
| 16 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html |
| 17 |
* Text Domain: disco |
| 18 |
* Domain Path: /languages |
| 19 |
* |
| 20 |
* WP Requirement & Test |
| 21 |
* Requires at least: 4.4 |
| 22 |
* Tested up to: 6.9 |
| 23 |
* Requires PHP: 5.6 |
| 24 |
* Requires Plugins: woocommerce |
| 25 |
* |
| 26 |
* WC Requirement & Test |
| 27 |
* WC requires at least: 3.0 |
| 28 |
* WC tested up to: 10.3.5 |
| 29 |
*/ |
| 30 |
|
| 31 |
// If this file is called directly, abort. |
| 32 |
use Disco\Engine\Initialize; |
| 33 |
use Micropackage\Requirements\Requirements; |
| 34 |
|
| 35 |
if ( ! defined( 'ABSPATH' ) ) { |
| 36 |
die( 'We\'re sorry, but you can not directly access this file.' ); |
| 37 |
} |
| 38 |
|
| 39 |
const DISCO_VERSION = '1.2.90'; |
| 40 |
const DISCO_TEXTDOMAIN = 'disco'; |
| 41 |
const DISCO_NAME = 'Disco'; |
| 42 |
|
| 43 |
define( 'DISCO_PLUGIN_ROOT', plugin_dir_path( __FILE__ ) ); |
| 44 |
define( 'DISCO_PLUGIN_FILE', __FILE__ ); |
| 45 |
define( 'DISCO_PRO_PLUGIN_FILE', dirname(__DIR__, 1) . '/disco-pro/disco-pro.php' ); |
| 46 |
define( 'DISCO_LIBS_PATH', DISCO_PLUGIN_ROOT . 'libs/' ); |
| 47 |
|
| 48 |
const DISCO_PLUGIN_ABSOLUTE = __FILE__; |
| 49 |
const DISCO_MIN_PHP_VERSION = '5.6'; |
| 50 |
const DISCO_WP_VERSION = '4.4'; |
| 51 |
const DISCO_DB_VERSION = '1.0.0'; |
| 52 |
|
| 53 |
// WooCommerce has detected that some of your active plugins are incompatible with currently enabled WooCommerce features. Please review the details. |
| 54 |
add_action( |
| 55 |
'before_woocommerce_init', |
| 56 |
function () { |
| 57 |
if ( ! class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { |
| 58 |
return; |
| 59 |
} |
| 60 |
|
| 61 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 62 |
} |
| 63 |
); |
| 64 |
|
| 65 |
add_action(// @phpstan-ignore-line |
| 66 |
'init', |
| 67 |
static function () { |
| 68 |
load_plugin_textdomain( 'disco', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
| 69 |
} |
| 70 |
); |
| 71 |
|
| 72 |
if ( version_compare( PHP_VERSION, DISCO_MIN_PHP_VERSION, '<=' ) ) { |
| 73 |
add_action(// @phpstan-ignore-line |
| 74 |
'admin_init', |
| 75 |
static function () { |
| 76 |
deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 77 |
} |
| 78 |
); |
| 79 |
add_action(// @phpstan-ignore-line |
| 80 |
'admin_notices', |
| 81 |
static function () { |
| 82 |
echo wp_kses_post( |
| 83 |
sprintf( |
| 84 |
'<div class="notice notice-error"><p>%s</p></div>', |
| 85 |
__( 'Disco requires PHP 5.6 or newer.', 'disco' )// @phpstan-ignore-line |
| 86 |
) |
| 87 |
); |
| 88 |
} |
| 89 |
); |
| 90 |
|
| 91 |
// Return early to prevent loading the plugin. |
| 92 |
return; |
| 93 |
} |
| 94 |
|
| 95 |
$disco_libraries = require DISCO_PLUGIN_ROOT . 'vendor/autoload.php'; //phpcs:ignore |
| 96 |
|
| 97 |
add_action('woocommerce_init', function () { |
| 98 |
require_once DISCO_PLUGIN_ROOT . 'functions/common.php'; |
| 99 |
require_once DISCO_PLUGIN_ROOT . 'functions/cart.php'; |
| 100 |
require_once DISCO_PLUGIN_ROOT . 'functions/product.php'; |
| 101 |
require_once DISCO_PLUGIN_ROOT . 'functions/order.php'; |
| 102 |
require_once DISCO_PLUGIN_ROOT . 'functions/shipping.php'; |
| 103 |
require_once DISCO_PLUGIN_ROOT . 'functions/bogo.php'; |
| 104 |
require_once DISCO_PLUGIN_ROOT . 'functions/coupon.php'; |
| 105 |
}); |
| 106 |
|
| 107 |
|
| 108 |
$requirements = new Requirements( |
| 109 |
'Disco', |
| 110 |
array( |
| 111 |
'php' => DISCO_MIN_PHP_VERSION, |
| 112 |
'php_extensions' => array( 'mbstring' ), |
| 113 |
'wp' => DISCO_WP_VERSION, |
| 114 |
'plugins' => array( |
| 115 |
array( |
| 116 |
'file' => 'woocommerce/woocommerce.php', |
| 117 |
'name' => 'WooCommerce', |
| 118 |
'version' => '3.5', |
| 119 |
), |
| 120 |
), |
| 121 |
) |
| 122 |
); |
| 123 |
|
| 124 |
if ( ! $requirements->satisfied() ) { |
| 125 |
$requirements->print_notice(); |
| 126 |
|
| 127 |
return; |
| 128 |
} |
| 129 |
|
| 130 |
if ( ! wp_installing() ) { |
| 131 |
register_activation_hook( |
| 132 |
DISCO_TEXTDOMAIN . '/' . DISCO_TEXTDOMAIN . '.php', |
| 133 |
array( |
| 134 |
new \Disco\Backend\ActDeact(), |
| 135 |
'activate', |
| 136 |
) |
| 137 |
); |
| 138 |
register_deactivation_hook( |
| 139 |
DISCO_TEXTDOMAIN . '/' . DISCO_TEXTDOMAIN . '.php', |
| 140 |
array( |
| 141 |
new \Disco\Backend\ActDeact(), |
| 142 |
'deactivate', |
| 143 |
) |
| 144 |
); |
| 145 |
add_action(// @phpstan-ignore-line |
| 146 |
'plugins_loaded', |
| 147 |
static function () use ( $disco_libraries ) { |
| 148 |
new Initialize( $disco_libraries ); |
| 149 |
} |
| 150 |
); |
| 151 |
|
| 152 |
require_once __DIR__ . '/libs/WebAppick/Classes/DiscoWebAppickAPI.php'; |
| 153 |
|
| 154 |
add_action( |
| 155 |
'init', function() { |
| 156 |
DiscoWebAppickAPI::getInstance(); |
| 157 |
} |
| 158 |
); |
| 159 |
|
| 160 |
} |
| 161 |
|
| 162 |
//Add custom link to plugin row meta |
| 163 |
//add_filter('plugin_row_meta', function ( $links, $file ) { |
| 164 |
// if ($file == plugin_basename(__FILE__)) { |
| 165 |
// $links[] = '<a href="https://discoplugin.com/pricing/?utm_source=update&utm_medium=wp_free&utm_campaign=release-update" target="_blank" class="disco-custom-meta-link"><span >🎃 Halloween Special – 30% OFF</span></a>'; |
| 166 |
// } |
| 167 |
// return $links; |
| 168 |
//}, 10, 2); |
| 169 |
|