| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Instantio - WooCommerce Quick Checkout |
| 4 |
* Plugin URI: https://themefic.com/instantio/ |
| 5 |
* Description: WooCommerce direct checkout plugin with Side Cart, Popup Cart, Floating Cart & Popup Checkout function (+ 4 more WooCommerce Quick Checkout systems). |
| 6 |
* Author: Themefic |
| 7 |
* Text Domain: instantio |
| 8 |
* Domain Path: /lang/ |
| 9 |
* Author URI: https://themefic.com |
| 10 |
* Tags: woocommerce cart, woocommerce checkout, woocommerce direct checkout, multistep checkout, woocommerce side cart |
| 11 |
* Version: 3.3.8 |
| 12 |
* Tested up to: 6.7 |
| 13 |
* Requires PHP: 7.4 |
| 14 |
* WC tested up to: 9.4 |
| 15 |
**/ |
| 16 |
|
| 17 |
// don't load directly |
| 18 |
defined( 'ABSPATH' ) || exit; |
| 19 |
|
| 20 |
class INSTANTIO { |
| 21 |
|
| 22 |
public function __construct() { |
| 23 |
$this->define_constants(); |
| 24 |
$this->includes(); |
| 25 |
$this->init_hooks(); |
| 26 |
$this->ins_public_hooks(); |
| 27 |
|
| 28 |
//enqueue scripts |
| 29 |
add_action( 'admin_enqueue_scripts', [ $this, 'Ins_tourfic_admin_denqueue_script' ], 20 ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Define constants |
| 34 |
*/ |
| 35 |
private function define_constants() { |
| 36 |
if ( ! defined( 'INSTANTIO_VERSION' ) ) { |
| 37 |
define( 'INSTANTIO_VERSION', '3.3.8' ); |
| 38 |
} |
| 39 |
define( 'INS_URL', plugin_dir_url( __FILE__ ) ); |
| 40 |
define( 'INS_INC_URL', INS_URL . 'includes' ); |
| 41 |
define( 'INS_LAYOUTS_URL', INS_URL . 'includes/layouts' ); |
| 42 |
define( 'INS_ASSETS_URL', INS_URL . 'assets' ); |
| 43 |
define( 'INS_ADMIN_URL', INS_URL . 'admin' ); |
| 44 |
|
| 45 |
define( 'INS_PATH', plugin_dir_path( __FILE__ ) ); |
| 46 |
define( 'INS_INC_PATH', INS_PATH . 'includes' ); |
| 47 |
define( 'INS_ADMIN_PATH', INS_PATH . 'admin' ); |
| 48 |
define( 'INS_CONTROLLER_PATH', INS_INC_PATH . '/controller' ); |
| 49 |
define( 'INS_BASE_LOCATION', plugin_basename( __FILE__ ) ); |
| 50 |
define( 'INS_TEMPLATES_PATH', INS_INC_PATH . '/templates' ); |
| 51 |
|
| 52 |
/** |
| 53 |
* Ajax install & activate WooCommerce |
| 54 |
* |
| 55 |
* @since 3.0 |
| 56 |
* @link https://developer.wordpress.org/reference/functions/wp_ajax_install_plugin/ |
| 57 |
*/ |
| 58 |
add_action( "wp_ajax_ins_ajax_install_woocommerce", "wp_ajax_install_plugin" ); |
| 59 |
|
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Include required core files used in admin and on the frontend. |
| 64 |
*/ |
| 65 |
private function includes() { |
| 66 |
require_once __DIR__ . '/vendor/autoload.php'; |
| 67 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 68 |
require_once( 'functions.php' ); |
| 69 |
|
| 70 |
// Ins Quick Setup wizard & Ins_checkout_Editor |
| 71 |
if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { |
| 72 |
require_once INS_INC_PATH . '/controller/class-setup-wizard.php'; |
| 73 |
|
| 74 |
// Ins_checkout_Editor |
| 75 |
require_once INS_INC_PATH . '/controller/checkout_editor.php'; |
| 76 |
} |
| 77 |
|
| 78 |
// ins Promo Banner |
| 79 |
if ( defined('INS_INC_PATH') && !empty(INS_INC_PATH) ) { |
| 80 |
require_once INS_INC_PATH . '/controller/class-promo-notice.php'; |
| 81 |
} |
| 82 |
|
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* Init Instantio when WordPress Initialises. |
| 87 |
*/ |
| 88 |
private function init_hooks() { |
| 89 |
add_action( 'plugins_loaded', array( $this, 'init' ), 0 ); |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* init Instantio when WordPress Initialises. |
| 94 |
* |
| 95 |
* @since 1.0 |
| 96 |
*/ |
| 97 |
public function init() { |
| 98 |
add_action( 'init', array( $this, 'ins_plugin_loaded_action' ) ); |
| 99 |
|
| 100 |
if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { |
| 101 |
new INS\Controller\Assets(); |
| 102 |
} |
| 103 |
|
| 104 |
if ( is_admin() && ! wp_doing_ajax() ) { |
| 105 |
new INS\Controller\Admin(); |
| 106 |
|
| 107 |
// Appsero |
| 108 |
$this->ins_appsero_init_tracker_instantio(); |
| 109 |
|
| 110 |
} else { |
| 111 |
new INS\Controller\App(); |
| 112 |
|
| 113 |
// ins Variation product Quick Views |
| 114 |
add_action( 'wp_ajax_ins_variable_product_quick_view', array( $this, 'ins_ajax_quickview_variable_products' ) ); |
| 115 |
add_action( 'wp_ajax_nopriv_ins_variable_product_quick_view', array( $this, 'ins_ajax_quickview_variable_products' ) ); |
| 116 |
} |
| 117 |
|
| 118 |
} |
| 119 |
|
| 120 |
/** |
| 121 |
* Plugins Loaded Actions |
| 122 |
* |
| 123 |
* Including Option Panel |
| 124 |
* |
| 125 |
* Including Options |
| 126 |
*/ |
| 127 |
public function ins_plugin_loaded_action() { |
| 128 |
|
| 129 |
if ( defined('INS_PATH') && !empty(INS_PATH) ) { |
| 130 |
require_once INS_PATH . 'admin/tf-options/Ins_TF_Options.php'; |
| 131 |
} |
| 132 |
|
| 133 |
} |
| 134 |
|
| 135 |
/** |
| 136 |
* Ajax variable products quick view |
| 137 |
*/ |
| 138 |
|
| 139 |
public function ins_ajax_quickview_variable_products() { |
| 140 |
global $post, $product, $woocommerce; |
| 141 |
|
| 142 |
// return 1; |
| 143 |
check_ajax_referer( 'ins_ajax_nonce', 'security' ); |
| 144 |
|
| 145 |
add_action( 'wcqv_product_data', 'woocommerce_template_single_add_to_cart' ); |
| 146 |
|
| 147 |
$product_id = $_POST['product_id']; |
| 148 |
|
| 149 |
$wiqv_loop = new WP_Query( |
| 150 |
array( |
| 151 |
'post_type' => 'product', |
| 152 |
'p' => $product_id, |
| 153 |
) |
| 154 |
); |
| 155 |
ob_start(); |
| 156 |
if ( $wiqv_loop->have_posts() ) : |
| 157 |
while ( $wiqv_loop->have_posts() ) : |
| 158 |
$wiqv_loop->the_post(); ?> |
| 159 |
<?php wc_get_template( 'single-product/add-to-cart/variation.php' ); ?> |
| 160 |
<script> |
| 161 |
jQuery.getScript("<?php echo $woocommerce->plugin_url(); ?>/assets/js/frontend/add-to-cart-variation.min.js"); |
| 162 |
</script> |
| 163 |
<?php |
| 164 |
do_action( 'wcqv_product_data' ); |
| 165 |
endwhile; |
| 166 |
endif; |
| 167 |
|
| 168 |
echo ob_get_clean(); |
| 169 |
|
| 170 |
wp_die(); |
| 171 |
} |
| 172 |
|
| 173 |
/** |
| 174 |
* Appsero |
| 175 |
* |
| 176 |
* Including Options |
| 177 |
*/ |
| 178 |
public function ins_appsero_init_tracker_instantio() { |
| 179 |
|
| 180 |
if ( ! class_exists( 'Appsero\Client' ) ) { |
| 181 |
require_once( INS_INC_PATH . '/app/src/Client.php' ); |
| 182 |
} |
| 183 |
|
| 184 |
$client = new Appsero\Client( '29e55a76-0819-490f-b692-8368956cbf12', 'instantio', __FILE__ ); |
| 185 |
|
| 186 |
// Change notice text |
| 187 |
$notice = sprintf( $client->__trans( 'Want to help make <strong>%1$s</strong> even more awesome? Allow %1$s to collect non-sensitive diagnostic data and usage information. I agree to get Important Product Updates & Discount related information on my email from %1$s (I can unsubscribe anytime).' ), $client->name ); |
| 188 |
|
| 189 |
$client->insights()->notice( $notice ); |
| 190 |
|
| 191 |
// Active insights |
| 192 |
$client->insights()->init(); |
| 193 |
|
| 194 |
} |
| 195 |
|
| 196 |
private function ins_public_hooks() { |
| 197 |
add_action( 'after_setup_theme', [ $this, 'ins_check_editor' ] ); |
| 198 |
} |
| 199 |
|
| 200 |
public function ins_check_editor() { |
| 201 |
$ins_billing_fields = apply_filters( 'ins_billing_fields_priority', 1000 ); |
| 202 |
$ins_shipping_fields = apply_filters( 'ins_shipping_fields_priority', 1000 ); |
| 203 |
|
| 204 |
add_filter( 'woocommerce_default_address_fields', 'ins_over_checkout_billing_address', $ins_billing_fields, 2 ); |
| 205 |
add_filter( 'woocommerce_checkout_fields', 'ins_over_checkout_billing_fields', $ins_billing_fields, 2 ); |
| 206 |
add_filter( 'woocommerce_checkout_fields', 'ins_over_checkout_shipping_fields', $ins_shipping_fields, 2 ); |
| 207 |
// add_filter('woocommerce_default_address_fields', 'ins_over_checkout_shiping_address'); |
| 208 |
} |
| 209 |
|
| 210 |
public function Ins_tourfic_admin_denqueue_script( $screen ) { |
| 211 |
$ins_options_screens = array( |
| 212 |
'toplevel_page_wiopt', |
| 213 |
'instantio_page_ins_dashboard', |
| 214 |
'instantio_page_tf_license_info', |
| 215 |
'instantio_page_ins_get_help', |
| 216 |
'instantio_page_ins_whats_new', |
| 217 |
'admin_page_ins-setup-wizard', |
| 218 |
'instantio_page_ins-license-activation' |
| 219 |
); |
| 220 |
|
| 221 |
//The tourfic admin js Listings Directory Compatibility |
| 222 |
if ( in_array( $screen, $ins_options_screens ) ) { |
| 223 |
wp_dequeue_style( 'tf-admin' ); |
| 224 |
wp_deregister_style( 'tf-admin' ); |
| 225 |
wp_dequeue_style( 'tf-pro' ); |
| 226 |
wp_dequeue_script( 'tf-pro' ); |
| 227 |
wp_deregister_script('tf-pro'); |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
new INSTANTIO(); |
| 235 |
|
| 236 |
add_action( 'admin_enqueue_scripts', 'ins_admin_enqueue_scripts' ); |
| 237 |
add_action( 'before_woocommerce_init', 'ins_before_woocommerce_init' ); |
| 238 |
|
| 239 |
function ins_before_woocommerce_init() { |
| 240 |
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) { |
| 241 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 242 |
} |
| 243 |
} |
| 244 |
|
| 245 |
function ins_admin_enqueue_scripts($screen) { |
| 246 |
wp_enqueue_style( 'ins-admin', INS_ASSETS_URL . '/admin/css/instantio-admin-style.css', array(), INSTANTIO_VERSION ); |
| 247 |
wp_enqueue_script( 'ins-admin-script', INS_ASSETS_URL . '/admin/js/instantio-admin-script.js', array( 'jquery' ), INSTANTIO_VERSION, true ); |
| 248 |
|
| 249 |
wp_localize_script( 'ins-admin-script', 'ins_admin_params', |
| 250 |
array( |
| 251 |
'ins_nonce' => wp_create_nonce( 'ins_updates' ), |
| 252 |
'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 253 |
) |
| 254 |
); |
| 255 |
} |
| 256 |
|
| 257 |
|