| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | if (!defined('ABSPATH')){ |
|---|
| 4 | exit; |
|---|
| 5 | } |
|---|
| 6 | |
|---|
| 7 | class AWCDP_Compatibility |
|---|
| 8 | { |
|---|
| 9 | /** |
|---|
| 10 | * @var object |
|---|
| 11 | * @access private |
|---|
| 12 | * @since 1.0.0 |
|---|
| 13 | */ |
|---|
| 14 | private static $_instance = null; |
|---|
| 15 | |
|---|
| 16 | /** |
|---|
| 17 | * The version number. |
|---|
| 18 | * @var string |
|---|
| 19 | * @access public |
|---|
| 20 | * @since 1.0.0 |
|---|
| 21 | */ |
|---|
| 22 | public $_version; |
|---|
| 23 | private $_active = false; |
|---|
| 24 | |
|---|
| 25 | public function __construct() { |
|---|
| 26 | |
|---|
| 27 | if ($this->check_woocommerce_active()) { |
|---|
| 28 | add_action('init', array($this, 'awcdp_load_compatibility')); |
|---|
| 29 | add_action( 'init', array( $this, 'awcdp_wc_register_custom_post_status' ),1 ); |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | function awcdp_load_compatibility(){ |
|---|
| 35 | |
|---|
| 36 | if ( class_exists( 'WFFN_Core' ) ) { |
|---|
| 37 | require_once realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR . 'compatibility/funnel-builder.php'; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | if ( class_exists( 'WC_Bookings' ) ) { |
|---|
| 41 | require_once realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR . 'compatibility/woocommerce-bookings.php'; |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | if ( class_exists( 'WC_Appointments' ) ) { |
|---|
| 45 | require_once realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR . 'compatibility/woocommerce-appointments.php'; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | if ( class_exists( 'Iconic_Flux_Checkout' ) ) { |
|---|
| 49 | require_once realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR . 'compatibility/flux-checkout.php'; |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | if (in_array('woo-stripe-payment/stripe-payments.php', apply_filters('active_plugins', get_option('active_plugins'))) ) { |
|---|
| 53 | require_once realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR . 'compatibility/woo-stripe-payment.php'; |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | if ( class_exists( 'WC_Order_Export_Admin' ) ) { |
|---|
| 57 | require_once realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR . 'compatibility/woocommerce-order-export.php'; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | if ( class_exists( 'YITH_WCBK' ) ) { |
|---|
| 61 | require_once realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR . 'compatibility/yith-woocommerce-booking-premium.php'; |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | require_once realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR . 'compatibility/merchant-pro.php'; |
|---|
| 65 | |
|---|
| 66 | // pixelyoursite |
|---|
| 67 | if( function_exists('PYS') || class_exists('PixelYourSite\PYS') || class_exists('PixelYourSite\Events') || function_exists('pys_get_option') ){ |
|---|
| 68 | require_once realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR . 'compatibility/pixelyoursite.php'; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | if ( in_array('mollie-payments-for-woocommerce/mollie-payments-for-woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))) |
|---|
| 72 | || defined('M4W_PLUGIN_DIR') |
|---|
| 73 | || class_exists('\Mollie\WooCommerce\Payment\MollieOrderService') ) { |
|---|
| 74 | require_once realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR . 'compatibility/mollie-payments.php'; |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | // require_once realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR . 'compatibility/pymntpl-paypal-woocommerce.php'; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | public function awcdp_wc_register_custom_post_status() { |
|---|
| 82 | if ( is_admin() ) { |
|---|
| 83 | register_post_status( 'wc-partial-payment', array( |
|---|
| 84 | 'label' => '<span class="status-partial-payment tips" data-tip="' . wc_sanitize_tooltip( _x( 'Partially Paid', 'deposits-partial-payments-for-woocommerce', 'deposits-partial-payments-for-woocommerce' ) ) . '">' . _x( 'Partially Paid', 'deposits-partial-payments-for-woocommerce', 'deposits-partial-payments-for-woocommerce' ) . '</span>', |
|---|
| 85 | 'exclude_from_search' => false, |
|---|
| 86 | 'public' => true, |
|---|
| 87 | 'show_in_admin_all_list' => true, |
|---|
| 88 | 'show_in_admin_status_list' => true, |
|---|
| 89 | 'label_count' => _n_noop( 'Partially Paid <span class="count">(%s)</span>', 'Partially Paid <span class="count">(%s)</span>', 'deposits-partial-payments-for-woocommerce' ), |
|---|
| 90 | ) ); |
|---|
| 91 | } |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | public function check_woocommerce_active() { |
|---|
| 95 | if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { |
|---|
| 96 | return true; |
|---|
| 97 | } |
|---|
| 98 | if (is_multisite()) { |
|---|
| 99 | $plugins = get_site_option('active_sitewide_plugins'); |
|---|
| 100 | if (isset($plugins['woocommerce/woocommerce.php'])){ |
|---|
| 101 | return true; |
|---|
| 102 | } |
|---|
| 103 | } |
|---|
| 104 | return false; |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | public static function instance($file = '', $version = '1.0.0') { |
|---|
| 108 | if (is_null(self::$_instance)) { |
|---|
| 109 | self::$_instance = new self($file, $version); |
|---|
| 110 | } |
|---|
| 111 | return self::$_instance; |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | public function is_active() { |
|---|
| 115 | return $this->_active !== false; |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | /** |
|---|
| 119 | * Permission Callback |
|---|
| 120 | **/ |
|---|
| 121 | public function get_permission() |
|---|
| 122 | { |
|---|
| 123 | if (current_user_can('administrator') || current_user_can('manage_woocommerce')) { |
|---|
| 124 | return true; |
|---|
| 125 | } else { |
|---|
| 126 | return false; |
|---|
| 127 | } |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | /** |
|---|
| 131 | * Cloning is forbidden. |
|---|
| 132 | * |
|---|
| 133 | * @since 1.0.0 |
|---|
| 134 | */ |
|---|
| 135 | public function __clone() |
|---|
| 136 | { |
|---|
| 137 | _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?'), $this->_version); |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | /** |
|---|
| 141 | * Unserializing instances of this class is forbidden. |
|---|
| 142 | * |
|---|
| 143 | * @since 1.0.0 |
|---|
| 144 | */ |
|---|
| 145 | public function __wakeup() |
|---|
| 146 | { |
|---|
| 147 | _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?'), $this->_version); |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | } |
|---|