wpai-woocommerce-add-on.php 26.8 KB
Newer Older
Nahla Shiri's avatar
Nahla Shiri committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774
<?php
/*
Plugin Name: WP All Import - WooCommerce Add-On Pro
Plugin URI: http://www.wpallimport.com/
Description: Import to WooCommerce. Adds a section to WP All Import that looks just like WooCommerce. Requires WP All Import.
Version: 2.3.6
Author: Soflyy
*/
/**
 * Plugin root dir with forward slashes as directory separator regardless of actuall DIRECTORY_SEPARATOR value
 * @var string
 */
define('PMWI_ROOT_DIR', str_replace('\\', '/', dirname(__FILE__)));
/**
 * Plugin root url for referencing static content
 * @var string
 */
define('PMWI_ROOT_URL', rtrim(plugin_dir_url(__FILE__), '/'));
/**
 * Plugin prefix for making names unique (be aware that this variable is used in conjuction with naming convention,
 * i.e. in order to change it one must not only modify this constant but also rename all constants, classes and functions which
 * names composed using this prefix)
 * @var string
 */
define('PMWI_PREFIX', 'pmwi_');

define('PMWI_VERSION', '2.3.6');

if ( class_exists('PMWI_Plugin') and PMWI_EDITION == "free"){

	function pmwi_notice(){
		
		?>
		<div class="error"><p>
			<?php printf(__('Please de-activate and remove the free version of the WooCommere add-on before activating the paid version.', 'wpai_woocommerce_addon_plugin'));
			?>
		</p></div>
		<?php				

		deactivate_plugins(PMWI_ROOT_DIR . '/plugin.php');

	}

	add_action('admin_notices', 'pmwi_notice');	

}
else {

	define('PMWI_EDITION', 'paid');

	/**
	 * Main plugin file, Introduces MVC pattern
	 *
	 * @singletone
	 * @author Pavel Kulbakin <p.kulbakin@gmail.com>
	 */

	final class PMWI_Plugin {
		/**
		 * Singletone instance
		 * @var PMWI_Plugin
		 */
		protected static $instance;

		/**
		 * Plugin options
		 * @var array
		 */
		protected $options = array();

		/**
		 * Plugin root dir
		 * @var string
		 */
		const ROOT_DIR = PMWI_ROOT_DIR;
		/**
		 * Plugin root URL
		 * @var string
		 */
		const ROOT_URL = PMWI_ROOT_URL;
		/**
		 * Prefix used for names of shortcodes, action handlers, filter functions etc.
		 * @var string
		 */
		const PREFIX = PMWI_PREFIX;
		/**
		 * Plugin file path
		 * @var string
		 */
		const FILE = __FILE__;	

		/**
		 * Return singletone instance
		 * @return PMWI_Plugin
		 */
		static public function getInstance() {
			if (self::$instance == NULL) {
				self::$instance = new self();
			}
			return self::$instance;
		}

		static public function getEddName(){
			return 'WooCommerce Add-On';
		}

		/**
		 * Common logic for requestin plugin info fields
		 */
		public function __call($method, $args) {
			if (preg_match('%^get(.+)%i', $method, $mtch)) {
				$info = get_plugin_data(self::FILE);
				if (isset($info[$mtch[1]])) {
					return $info[$mtch[1]];
				}
			}
			throw new Exception("Requested method " . get_class($this) . "::$method doesn't exist.");
		}

		/**
		 * Get path to plagin dir relative to wordpress root
		 * @param bool[optional] $noForwardSlash Whether path should be returned withot forwarding slash
		 * @return string
		 */
		public function getRelativePath($noForwardSlash = false) {
			$wp_root = str_replace('\\', '/', ABSPATH);
			return ($noForwardSlash ? '' : '/') . str_replace($wp_root, '', self::ROOT_DIR);
		}

		/**
		 * Check whether plugin is activated as network one
		 * @return bool
		 */
		public function isNetwork() {
			if ( !is_multisite() )
			return false;

			$plugins = get_site_option('active_sitewide_plugins');
			if (isset($plugins[plugin_basename(self::FILE)]))
				return true;

			return false;
		}

		/**
		 * Check whether permalinks is enabled
		 * @return bool
		 */
		public function isPermalinks() {
			global $wp_rewrite;

			return $wp_rewrite->using_permalinks();
		}

		/**
		 * Return prefix for plugin database tables
		 * @return string
		 */
		public function getTablePrefix() {
			global $wpdb;
			return ($this->isNetwork() ? $wpdb->base_prefix : $wpdb->prefix) . self::PREFIX;
		}

		/**
		 * Return prefix for wordpress database tables
		 * @return string
		 */
		public function getWPPrefix() {
			global $wpdb;
			return ($this->isNetwork() ? $wpdb->base_prefix : $wpdb->prefix);
		}

		/**
		 * Class constructor containing dispatching logic
		 * @param string $rootDir Plugin root dir
		 * @param string $pluginFilePath Plugin main file
		 */
		protected function __construct() {
			
			// create/update required database tables

			// register autoloading method
			spl_autoload_register(array($this, 'autoload'));

			// register helpers
			if (is_dir(self::ROOT_DIR . '/helpers')) foreach (PMWI_Helper::safe_glob(self::ROOT_DIR . '/helpers/*.php', PMWI_Helper::GLOB_RECURSE | PMWI_Helper::GLOB_PATH) as $filePath) {
				require_once $filePath;
			}

			// init plugin options
			$option_name = get_class($this) . '_Options';
			$options_default = PMWI_Config::createFromFile(self::ROOT_DIR . '/config/options.php')->toArray();
			$this->options = array_intersect_key(get_option($option_name, array()), $options_default) + $options_default;
			$this->options = array_intersect_key($options_default, array_flip(array('info_api_url'))) + $this->options; // make sure hidden options apply upon plugin reactivation		

			update_option($option_name, $this->options);
			$this->options = get_option(get_class($this) . '_Options');

			register_activation_hook(self::FILE, array($this, 'activation'));

			// register action handlers
			if (is_dir(self::ROOT_DIR . '/actions')) if (is_dir(self::ROOT_DIR . '/actions')) foreach (PMWI_Helper::safe_glob(self::ROOT_DIR . '/actions/*.php', PMWI_Helper::GLOB_RECURSE | PMWI_Helper::GLOB_PATH) as $filePath) {
				require_once $filePath;
				$function = $actionName = basename($filePath, '.php');
				if (preg_match('%^(.+?)[_-](\d+)$%', $actionName, $m)) {
					$actionName = $m[1];
					$priority = intval($m[2]);
				} else {
					$priority = 10;
				}
				add_action($actionName, self::PREFIX . str_replace('-', '_', $function), $priority, 99); // since we don't know at this point how many parameters each plugin expects, we make sure they will be provided with all of them (it's unlikely any developer will specify more than 99 parameters in a function)
			}

			// register filter handlers
			if (is_dir(self::ROOT_DIR . '/filters')) foreach (PMWI_Helper::safe_glob(self::ROOT_DIR . '/filters/*.php', PMWI_Helper::GLOB_RECURSE | PMWI_Helper::GLOB_PATH) as $filePath) {
				require_once $filePath;
				$function = $actionName = basename($filePath, '.php');
				if (preg_match('%^(.+?)[_-](\d+)$%', $actionName, $m)) {
					$actionName = $m[1];
					$priority = intval($m[2]);
				} else {
					$priority = 10;
				}
				add_filter($actionName, self::PREFIX . str_replace('-', '_', $function), $priority, 99); // since we don't know at this point how many parameters each plugin expects, we make sure they will be provided with all of them (it's unlikely any developer will specify more than 99 parameters in a function)
			}

			// register shortcodes handlers
			if (is_dir(self::ROOT_DIR . '/shortcodes')) foreach (PMWI_Helper::safe_glob(self::ROOT_DIR . '/shortcodes/*.php', PMWI_Helper::GLOB_RECURSE | PMWI_Helper::GLOB_PATH) as $filePath) {
				$tag = strtolower(str_replace('/', '_', preg_replace('%^' . preg_quote(self::ROOT_DIR . '/shortcodes/', '%') . '|\.php$%', '', $filePath)));
				add_shortcode($tag, array($this, 'shortcodeDispatcher'));
			}

			// register admin page pre-dispatcher
			add_action('admin_init', array($this, 'adminInit'));
			add_action('init', array($this, 'init'));
		}

		public function init()
		{
			$this->load_plugin_textdomain();
		}

		/**
		 * Load Localisation files.
		 *
		 * Note: the first-loaded translation file overrides any following ones if the same translation is present
		 *
		 * @access public
		 * @return void
		 */
		public function load_plugin_textdomain() {
			
			$locale = apply_filters( 'plugin_locale', get_locale(), 'wpai_woocommerce_addon_plugin' );							
			
			load_plugin_textdomain( 'wpai_woocommerce_addon_plugin', false, dirname( plugin_basename( __FILE__ ) ) . "/i18n/languages" );
		}	

		/**
		 * pre-dispatching logic for admin page controllers
		 */
		public function adminInit() {
			$input = new PMWI_Input();
			$page = strtolower($input->getpost('page', ''));
			if (preg_match('%^' . preg_quote(str_replace('_', '-', self::PREFIX), '%') . '([\w-]+)$%', $page)) {
				$this->adminDispatcher($page, strtolower($input->getpost('action', 'index')));
			}			
		}

		/**
		 * Dispatch shorttag: create corresponding controller instance and call its index method
		 * @param array $args Shortcode tag attributes
		 * @param string $content Shortcode tag content
		 * @param string $tag Shortcode tag name which is being dispatched
		 * @return string
		 */
		public function shortcodeDispatcher($args, $content, $tag) {

			$controllerName = self::PREFIX . preg_replace_callback('%(^|_).%', array($this, "replace_callback"), $tag);// capitalize first letters of class name parts and add prefix
			$controller = new $controllerName();
			if ( ! $controller instanceof PMWI_Controller) {
				throw new Exception("Shortcode `$tag` matches to a wrong controller type.");
			}
			ob_start();
			$controller->index($args, $content);
			return ob_get_clean();
		}

		public function replace_callback($matches){
			return strtoupper($matches[0]);
		}

		/**
		 * Dispatch admin page: call corresponding controller based on get parameter `page`
		 * The method is called twice: 1st time as handler `parse_header` action and then as admin menu item handler
		 * @param string[optional] $page When $page set to empty string ealier buffered content is outputted, otherwise controller is called based on $page value
		 */
		public function adminDispatcher($page = '', $action = 'index') {
			static $buffer = NULL;
			static $buffer_callback = NULL;
			if ('' === $page) {
				if ( ! is_null($buffer)) {
					echo '<div class="wrap">';
					echo $buffer;
					do_action('PMWI_action_after');
					echo '</div>';
				} elseif ( ! is_null($buffer_callback)) {
					echo '<div class="wrap">';
					call_user_func($buffer_callback);
					do_action('PMWI_action_after');
					echo '</div>';
				} else {
					throw new Exception('There is no previousely buffered content to display.');
				}
			} else {
				$controllerName = preg_replace_callback('%(^' . preg_quote(self::PREFIX, '%') . '|_).%', array($this, "replace_callback"),str_replace('-', '_', $page));
				$actionName = str_replace('-', '_', $action);
				if (method_exists($controllerName, $actionName)) {

					if ( ! get_current_user_id() or ! current_user_can('manage_options')) {
					    // This nonce is not valid.
					    die( 'Security check' ); 

					} else {

						$this->_admin_current_screen = (object)array(
							'id' => $controllerName,
							'base' => $controllerName,
							'action' => $actionName,
							'is_ajax' => isset($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest',
							'is_network' => is_network_admin(),
							'is_user' => is_user_admin(),
						);
						add_filter('current_screen', array($this, 'getAdminCurrentScreen'));
						add_filter('admin_body_class', create_function('', 'return "' . PMWI_Plugin::PREFIX . 'plugin";'));

						$controller = new $controllerName();
						if ( ! $controller instanceof PMWI_Controller_Admin) {
							throw new Exception("Administration page `$page` matches to a wrong controller type.");
						}

						if ($this->_admin_current_screen->is_ajax) { // ajax request
							$controller->$action();
							do_action('PMWI_action_after');
							die(); // stop processing since we want to output only what controller is randered, nothing in addition
						} elseif ( ! $controller->isInline) {
							ob_start();
							$controller->$action();
							$buffer = ob_get_clean();
						} else {
							$buffer_callback = array($controller, $action);
						}

					}

				} else { // redirect to dashboard if requested page and/or action don't exist
					wp_redirect(admin_url()); die();
				}
			}
		}

		protected $_admin_current_screen = NULL;
		public function getAdminCurrentScreen()
		{
			return $this->_admin_current_screen;
		}

		/**
		 * Autoloader
		 * It's assumed class name consists of prefix folloed by its name which in turn corresponds to location of source file
		 * if `_` symbols replaced by directory path separator. File name consists of prefix folloed by last part in class name (i.e.
		 * symbols after last `_` in class name)
		 * When class has prefix it's source is looked in `models`, `controllers`, `shortcodes` folders, otherwise it looked in `core` or `library` folder
		 *
		 * @param string $className
		 * @return bool
		 */
		public function autoload($className) {
			$is_prefix = false;
			$filePath = str_replace('_', '/', preg_replace('%^' . preg_quote(self::PREFIX, '%') . '%', '', strtolower($className), 1, $is_prefix)) . '.php';
			if ( ! $is_prefix) { // also check file with original letter case
				$filePathAlt = $className . '.php';
			}
			foreach ($is_prefix ? array('models', 'controllers', 'shortcodes', 'classes') : array('libraries') as $subdir) {
				$path = self::ROOT_DIR . '/' . $subdir . '/' . $filePath;
				if (is_file($path)) {
					require $path;
					return TRUE;
				}
				if ( ! $is_prefix) {
					$pathAlt = self::ROOT_DIR . '/' . $subdir . '/' . $filePathAlt;
					if (is_file($pathAlt)) {
						require $pathAlt;
						return TRUE;
					}
				}
			}

			return FALSE;
		}

		/**
		 * Get plugin option
		 * @param string[optional] $option Parameter to return, all array of options is returned if not set
		 * @return mixed
		 */
		public function getOption($option = NULL) {
			if (is_null($option)) {
				return $this->options;
			} else if (isset($this->options[$option])) {
				return $this->options[$option];
			} else {
				throw new Exception("Specified option is not defined for the plugin");
			}
		}
		/**
		 * Update plugin option value
		 * @param string $option Parameter name or array of name => value pairs
		 * @param mixed[optional] $value New value for the option, if not set than 1st parameter is supposed to be array of name => value pairs
		 * @return array
		 */
		public function updateOption($option, $value = NULL) {
			is_null($value) or $option = array($option => $value);
			if (array_diff_key($option, $this->options)) {
				throw new Exception("Specified option is not defined for the plugin");
			}
			$this->options = $option + $this->options;
			update_option(get_class($this) . '_Options', $this->options);

			return $this->options;
		}

		/**
		 * Plugin activation logic
		 */
		public function activation() {

			// uncaught exception doesn't prevent plugin from being activated, therefore replace it with fatal error so it does
			set_exception_handler(create_function('$e', 'trigger_error($e->getMessage(), E_USER_ERROR);'));

			// create plugin options
			$option_name = get_class($this) . '_Options';
			$options_default = PMWI_Config::createFromFile(self::ROOT_DIR . '/config/options.php')->toArray();
			update_option($option_name, $options_default);		

		}		

		/**
		 * Method returns default import options, main utility of the method is to avoid warnings when new
		 * option is introduced but already registered imports don't have it
		 */
		public static function get_default_import_options() {
			return array(
				'is_multiple_product_type' => 'yes',
				'multiple_product_type' => 'simple',
				'single_product_type' => '',			
				'is_product_virtual' => 'no',
				'single_product_virtual' => '',						
				'is_product_downloadable' => 'no',
				'single_product_downloadable' => '',			
				'is_product_enabled' => 'yes',
				'single_product_enabled' => '',
				'is_variation_enabled' => 'yes',
				'single_variation_enabled' => '',			
				'is_product_featured' => 'no',
				'single_product_featured' => '',
				'is_product_visibility' => 'visible',
				'single_product_visibility' => '',			
				'single_product_sku' => '',
				'single_product_url' => '',
				'single_product_button_text' => '',
				'single_product_regular_price' => '',
				'single_product_sale_price' => '',
				'single_product_files' => '',
				'single_product_files_names' => '',
				'single_product_download_limit' => '',
				'single_product_download_expiry' => '',
				'single_product_download_type' => '',
				'is_multiple_product_tax_status' => 'yes',
				'multiple_product_tax_status' => 'none',
				'single_product_tax_status' => '',
				'is_multiple_product_tax_class' => 'yes',
				'multiple_product_tax_class' => '',
				'single_product_tax_class' => '',			
				'is_product_manage_stock' => 'no',
				'single_product_manage_stock' => '',
				'single_product_stock_qty' => '',			
				'product_stock_status' => 'auto',
				'single_product_stock_status' => '',			
				'product_allow_backorders' => 'no',
				'single_product_allow_backorders' => '',			
				'product_sold_individually' => 'no',
				'single_product_sold_individually' => '',
				'single_product_weight' => '',
				'single_product_length' => '',
				'single_product_width' => '',
				'single_product_height' => '',
				'is_multiple_product_shipping_class' => 'yes',
				'multiple_product_shipping_class' => '',
				'single_product_shipping_class' => '',
				'is_multiple_grouping_product' => 'yes',
				'multiple_grouping_product' => '',
				'single_grouping_product' => '',
				'single_product_up_sells' => '',
				'single_product_cross_sells' => '',
				'attribute_name' => array(),
				'attribute_value' => array(),
				'in_variations' => array(),
				'is_visible' => array(),
				'is_taxonomy' => array(),
				'create_taxonomy_in_not_exists' => array(),

				'is_advanced' => array(),
				'advanced_in_variations' => array(),
				'advanced_in_variations_xpath' => array(),
				'advanced_is_visible' => array(),
				'advanced_is_visible_xpath' => array(),
				'advanced_is_taxonomy' => array(),
				'advanced_is_taxonomy_xpath' => array(),
				'advanced_is_create_terms' => array(),
				'advanced_is_create_terms_xpath' => array(),

				'single_product_purchase_note' => '',
				'single_product_menu_order' => 0,			
				'is_product_enable_reviews' => 'no',
				'single_product_enable_reviews' => '',
				'single_product_id' => '',
				'single_product_parent_id' => '',		
				'single_product_id_first_is_parent_id' => '',
				'single_product_first_is_parent_id_parent_sku' => '',
				'single_product_id_first_is_parent_title' => '',
				'single_product_first_is_parent_title_parent_sku' => '',
				'single_product_id_first_is_variation' => '',	
				'_virtual' => 0,
				'_downloadable' => 0,
				'is_regular_price_shedule' => 0,
				'single_sale_price_dates_from' => 'now',
				'single_sale_price_dates_to' => 'now',
				'product_files_delim' => ',',	
				'product_files_names_delim' => ',',				
				'matching_parent' => 'auto',
				'parent_indicator' => 'custom field',
				'custom_parent_indicator_name' => '',
				'custom_parent_indicator_value' => '',
				'missing_records_stock_status' => 0,
				'variations_xpath' => '',
				'_variable_virtual' => '',
				'_variable_downloadable' => '',
				'variable_stock' => '',
				'variable_regular_price' => '',
				'variable_sale_price' => '',
				'is_variable_sale_price_shedule' => 0,
				'variable_sale_price_dates_from' => '',
				'variable_sale_price_dates_to' => '',
				'variable_weight' => '',
				'variable_length' => '',
				'variable_width' => '',
				'variable_height' => '',
				'variable_shipping_class' => '',
				'variable_tax_class' => '',
				'variable_file_paths' => '',
				'variable_file_names' => '',
				'variable_download_limit' => '',
				'variable_download_expiry' => '',
				'is_variable_product_virtual' => 'no',
				'is_variable_product_manage_stock' => 'no',
				'is_multiple_variable_product_shipping_class' => 'yes',
				'multiple_variable_product_shipping_class' => '',
				'single_variable_product_shipping_class' => '',
				'is_multiple_variable_product_tax_class' => 'yes',
				'multiple_variable_product_tax_class' => 'parent',
				'single_variable_product_tax_class' => '',
				'variable_stock_status' => 'instock',
				'single_variable_stock_status' => '',		
				'variable_allow_backorders' => 'no',
				'single_variable_allow_backorders' => '',
				'is_variable_product_downloadable' => 'no',
				'single_variable_product_downloadable' => '',
				'variable_attribute_name' => array(),
				'variable_attribute_value' => array(),
				'variable_in_variations' => array(),
				'variable_is_visible' => array(),
				'variable_is_taxonomy' => array(),	
				'variable_create_taxonomy_in_not_exists' => array(),		
				'variable_product_files_delim' => ',',
				'variable_product_files_names_delim' => ',',
				'variable_image' => '',
				'variable_sku' => '',
				'is_variable_product_enabled' => 'yes',
				'single_variable_product_enabled' => '',
				'link_all_variations' => 0,
				'variable_stock_use_parent' => 0,
				'variable_regular_price_use_parent' => 0,
				'variable_sale_price_use_parent' => 0,
				'variable_sale_dates_use_parent' => 0,
				'variable_weight_use_parent' => 0,
				'single_variable_product_virtual' => '',
				'single_variable_product_virtual_use_parent' => 0,
				'single_variable_product_manage_stock' => '',
				'single_variable_product_manage_stock_use_parent' => 0,
				'variable_dimensions_use_parent' => 0,
				'variable_image_use_parent' => 0,
				'single_variable_product_shipping_class_use_parent' => 0,
				'single_variable_product_tax_class_use_parent' => 0,
				'single_variable_product_downloadable_use_parent' => 0,
				'variable_download_limit_use_parent' => 0,
				'variable_download_expiry_use_parent' => 0,

				'single_product_variation_description' => '',
				'variable_description' => '',
				'variable_description_use_parent' => 0,

				'first_is_parent' => 'yes',
				'single_product_whosale_price' => '',
				'variable_whosale_price' => '',
				'variable_whosale_price_use_parent' => 0,
				'disable_auto_sku_generation' => 0,
				'is_default_attributes' => 0,
				'default_attributes_type' => 'first',
				'disable_sku_matching' => 1,
				'disable_prepare_price' => 1,
				'prepare_price_to_woo_format' => 0,
				'convert_decimal_separator' => 1,
				'grouping_indicator' => 'xpath',				
				'custom_grouping_indicator_name' => '',
				'custom_grouping_indicator_value' => '',
				'is_update_product_type' => 1,
				'make_simple_product' => 1,
				'variable_sku_add_parent' => 0,
				'set_parent_stock' => 0,
				'single_product_regular_price_adjust' => '',
				'single_product_regular_price_adjust_type' => '%',
				'single_product_sale_price_adjust' => '',
				'single_product_sale_price_adjust_type' => '%',
				
				'is_update_attributes' => 1,
				'update_attributes_logic' => 'full_update',						
				'attributes_list' => array(),
				'attributes_only_list' => array(),
				'attributes_except_list' => array(),

				'is_variation_product_manage_stock' => 'no',
				'single_variation_product_manage_stock' => '',
				'variation_stock' => '',
				'variation_stock_status' => 'auto',
				'put_variation_image_to_gallery' => 0,
				'single_variation_stock_status' => '',
				'pmwi_order' => array(										
					'status' => 'wc-pending',
					'status_xpath' => '',
					'date' => 'now',
					'billing_source' => 'existing',
					'billing_source_match_by' => 'username',
					'billing_source_username' => '',
					'billing_source_email' => '',
					'billing_source_id' => '',
					'billing_source_cf_name' => '',
					'billing_source_cf_value' => '',
					'billing_first_name' => '',
					'billing_last_name' => '',
					'billing_company' => '',
					'billing_address_1' => '',
					'billing_address_2' => '',
					'billing_city' => '',
					'billing_postcode' => '',
					'billing_country' => '',
					'billing_state' => '',
					'billing_email' => '',
					'billing_phone' => '',
					'guest_billing_first_name' => '',
					'guest_billing_last_name' => '',
					'guest_billing_company' => '',
					'guest_billing_address_1' => '',
					'guest_billing_address_2' => '',
					'guest_billing_city' => '',
					'guest_billing_postcode' => '',
					'guest_billing_country' => '',
					'guest_billing_state' => '',
					'guest_billing_email' => '',
					'guest_billing_phone' => '',
					'is_guest_matching' => 0,
					'shipping_source' => 'copy',
					'shipping_first_name' => '',
					'shipping_last_name' => '',
					'shipping_company' => '',
					'shipping_address_1' => '',
					'shipping_address_2' => '',
					'shipping_city' => '',
					'shipping_postcode' => '',
					'shipping_country' => '',
					'shipping_state' => '',
					'shipping_email' => '',
					'shipping_phone' => '',
					'copy_from_billing' => 0,
					'customer_provided_note' => '',
					'payment_method' => '',
					'payment_method_xpath' => '',
					'transaction_id' => '',
					'products_repeater_mode' => 'csv',
					'products_repeater_mode_separator' => '|',
					'products_repeater_mode_foreach' => '',
					'products_source' => 'existing',
					'products' => array(),							
					'manual_products' => array(),
					'fees_repeater_mode' => 'csv',
					'fees_repeater_mode_separator' => '|',
					'fees_repeater_mode_foreach' => '',		
					'fees' => array(),
					'coupons_repeater_mode' => 'csv',
					'coupons_repeater_mode_separator' => '|',
					'coupons_repeater_mode_foreach' => '',
					'coupons' => array(),
					'shipping_repeater_mode' => 'csv',
					'shipping_repeater_mode_separator' => '|',
					'shipping_repeater_mode_foreach' => '',
					'shipping' => array(),					
					'taxes_repeater_mode' => 'csv',
					'taxes_repeater_mode_separator' => '|',
					'taxes_repeater_mode_foreach' => '',
					'taxes' => array(),					
					'order_total_logic' => 'auto',
					'order_total_xpath' => '',															
					'order_refund_amount' => '',
					'order_refund_reason' => '',
					'order_refund_date' => 'now',
					'order_refund_issued_source' => 'existing',
					'order_refund_issued_match_by' => 'username',
					'order_refund_issued_username' => '',
					'order_refund_issued_email' => '',
					'order_refund_issued_cf_name' => '',
					'order_refund_issued_cf_value' => '',
					'order_refund_issued_id' => '',
					'notes_repeater_mode' => 'csv',
					'notes_repeater_mode_separator' => '|',
					'notes_repeater_mode_foreach' => '',		
					'notes' => array(),					
				),
				'is_update_billing_details' => 1,
				'is_update_shipping_details' => 1,
				'is_update_payment' => 1,
				'is_update_notes' => 1,					
				'is_update_products' => 1,
				'update_products_logic' => 'full_update',
				'is_update_fees' => 1,
				'is_update_coupons' => 1,
				'is_update_shipping' => 1,
				'is_update_taxes' => 1,
				'is_update_refunds' => 1,
				'is_update_total' => 1,
				'do_not_send_order_notifications' => 1
			);
		}	
	}

	PMWI_Plugin::getInstance();	

	function wpai_woocommerce_add_on_updater(){
		// retrieve our license key from the DB
		$wpai_woocommerce_addon_options = get_option('PMXI_Plugin_Options');	

		if (!empty($wpai_woocommerce_addon_options['info_api_url'])){
			// setup the updater
			$updater = new PMWI_Updater( $wpai_woocommerce_addon_options['info_api_url'], __FILE__, array( 
					'version' 	=> PMWI_VERSION,		// current version number
					'license' 	=> false, // license key (used get_option above to retrieve from DB)
					'item_name' => PMWI_Plugin::getEddName(), 	// name of this plugin
					'author' 	=> 'Soflyy'  // author of this plugin
				)
			);
		}
	}
		
	add_action( 'admin_init', 'wpai_woocommerce_add_on_updater', 0 );
}