/**
  * Singleton pattern
  *
  * @return pspGoogleAuthorship Singleton instance
  */
 public static function getInstance($the_plugin = array())
 {
     if (!self::$_instance) {
         self::$_instance = new self($the_plugin);
     }
     return self::$_instance;
 }
 /**
  * The constructor
  */
 function __construct($here = __FILE__)
 {
     $this->is_admin = is_admin() === true ? true : false;
     //$current_url = $_SERVER['HTTP_REFERER'];
     $current_url = $this->get_current_page_url();
     $this->feedback_url = sprintf($this->feedback_url, $this->alias, rawurlencode($current_url));
     // load WP_Filesystem
     include_once ABSPATH . 'wp-admin/includes/file.php';
     WP_Filesystem();
     global $wp_filesystem;
     $this->wp_filesystem = $wp_filesystem;
     $this->update_developer();
     $this->plugin_hash = get_option('WooZoneLight_hash');
     // set the freamwork alias
     $this->buildConfigParams('default', array('alias' => $this->alias));
     // get the globals utils
     global $wpdb;
     // store database instance
     $this->db = $wpdb;
     // instance new WP_ERROR - http://codex.wordpress.org/Function_Reference/WP_Error
     $this->errors = new WP_Error();
     // charset
     $amazon_settings = $this->getAllSettings('array', 'amazon');
     if (isset($amazon_settings['charset']) && !empty($amazon_settings['charset'])) {
         $this->charset = $amazon_settings['charset'];
     }
     // plugin root paths
     $this->buildConfigParams('paths', array('plugin_dir_url' => str_replace('aa-framework/', '', plugin_dir_url(__FILE__)), 'plugin_dir_path' => str_replace('aa-framework/', '', plugin_dir_path(__FILE__))));
     // add plugin lib design paths and url
     $this->buildConfigParams('paths', array('design_dir_url' => $this->cfg['paths']['plugin_dir_url'] . 'lib/design', 'design_dir_path' => $this->cfg['paths']['plugin_dir_path'] . 'lib/design'));
     // add plugin scripts paths and url
     $this->buildConfigParams('paths', array('scripts_dir_url' => $this->cfg['paths']['plugin_dir_url'] . 'lib/scripts', 'scripts_dir_path' => $this->cfg['paths']['plugin_dir_path'] . 'lib/scripts'));
     // add plugin admin paths and url
     $this->buildConfigParams('paths', array('freamwork_dir_url' => $this->cfg['paths']['plugin_dir_url'] . 'aa-framework/', 'freamwork_dir_path' => $this->cfg['paths']['plugin_dir_path'] . 'aa-framework/'));
     // add core-modules alias
     $this->buildConfigParams('core-modules', array('dashboard', 'modules_manager', 'setup_backup', 'remote_support', 'server_status', 'support', 'assets_download', 'stats_prod', 'price_select'));
     // list of freamwork css files
     $this->buildConfigParams('freamwork-css-files', array('core' => 'css/core.css', 'panel' => 'css/panel.css', 'form-structure' => 'css/form-structure.css', 'form-elements' => 'css/form-elements.css', 'form-message' => 'css/form-message.css', 'button' => 'css/button.css', 'table' => 'css/table.css', 'tipsy' => 'css/tooltip.css', 'admin' => 'css/admin-style.css'));
     // list of freamwork js files
     $this->buildConfigParams('freamwork-js-files', array('admin' => 'js/admin.js', 'hashchange' => 'js/hashchange.js', 'ajaxupload' => 'js/ajaxupload.js', 'download_asset' => '../modules/assets_download/app.class.js'));
     require_once $this->cfg['paths']['plugin_dir_path'] . 'aa-framework/menu.php';
     // Run the plugins section load method
     add_action('wp_ajax_WooZoneLightLoadSection', array(&$this, 'load_section'));
     // Plugin Depedencies Verification!
     if (get_option('WooZoneLight_depedencies_is_valid', false)) {
         require_once $this->cfg['paths']['scripts_dir_path'] . '/plugin-depedencies/plugin_depedencies.php';
         $this->pluginDepedencies = new aaTeamPluginDepedencies($this);
         // activation redirect to depedencies page
         if (get_option('WooZoneLight_depedencies_do_activation_redirect', false)) {
             add_action('admin_init', array($this->pluginDepedencies, 'depedencies_plugin_redirect'));
             return false;
         }
         // verify plugin library depedencies
         $depedenciesStatus = $this->pluginDepedencies->verifyDepedencies();
         if ($depedenciesStatus['status'] == 'valid') {
             // go to plugin license code activation!
             add_action('admin_init', array($this->pluginDepedencies, 'depedencies_plugin_redirect_valid'));
         } else {
             // create depedencies page
             add_action('init', array($this->pluginDepedencies, 'initDepedenciesPage'), 5);
             return false;
         }
     }
     // Run the plugins initialization method
     add_action('init', array(&$this, 'initThePlugin'), 5);
     // Run the plugins section options save method
     add_action('wp_ajax_WooZoneLightSaveOptions', array(&$this, 'save_options'));
     // Run the plugins section options save method
     add_action('wp_ajax_WooZoneLightModuleChangeStatus', array(&$this, 'module_change_status'));
     // Run the plugins section options save method
     add_action('wp_ajax_WooZoneLightInstallDefaultOptions', array(&$this, 'install_default_options'));
     // Amazon helper, import new product
     add_action('wp_ajax_WooZoneLightPriceUpdate', array(&$this, 'productPriceUpdate_frm'));
     add_action('wp_ajax_WooZoneLightUpload', array(&$this, 'upload_file'));
     add_action('wp_ajax_WooZoneLightDismissNotice', array(&$this, 'dismiss_notice'));
     if (is_admin()) {
         add_action('admin_head', array(&$this, 'createInstanceFreamwork'));
         $this->check_if_table_exists();
     }
     add_action('admin_init', array($this, 'plugin_redirect'));
     if ($this->debug == true) {
         add_action('wp_footer', array($this, 'print_plugin_usages'));
         add_action('admin_footer', array($this, 'print_plugin_usages'));
     }
     add_action('admin_init', array($this, 'product_assets_verify'));
     if (!is_admin()) {
         add_action('init', array($this, 'frontpage'));
         add_shortcode('amz_corss_sell', array($this, 'cross_sell_box'));
     }
     add_action('admin_bar_menu', array($this, 'update_notifier_bar_menu'), 1000);
     add_action('admin_menu', array($this, 'update_plugin_notifier_menu'), 1000);
     $this->check_amz_multiple_cart();
     require_once $this->cfg['paths']['plugin_dir_path'] . 'aa-framework/ajax-list-table.php';
     new WooZoneLightAjaxListTable($this);
     add_action('woocommerce_after_add_to_cart_button', array($this, 'woocommerce_external_add_to_cart'), 10);
     $config = @unserialize(get_option($this->alias . '_amazon'));
     $p_type = isset($config['onsite_cart']) && $config['onsite_cart'] == "no" ? 'external' : 'external';
     if ($p_type == 'simple') {
         add_action('woocommerce_checkout_init', array($this, 'woocommerce_external_checkout'), 10);
     }
     if (isset($config['AccessKeyID']) && isset($config['SecretAccessKey']) && trim($config['AccessKeyID']) != "" && $config['SecretAccessKey'] != "") {
         require_once $this->cfg['paths']['plugin_dir_path'] . 'aa-framework/amz.helper.class.php';
         if (class_exists('WooZoneLightAmazonHelper')) {
             // $this->amzHelper = new WooZoneLightAmazonHelper( $this );
             $this->amzHelper = WooZoneLightAmazonHelper::getInstance($this);
         }
     }
     // ajax download lightbox
     add_action('wp_ajax_WooZoneLightDownoadAssetLightbox', array($this, 'download_asset_lightbox'));
     // admin ajax action
     require_once $this->cfg['paths']['plugin_dir_path'] . 'aa-framework/utils/action_admin_ajax.php';
     new WooZoneLight_ActionAdminAjax($this);
     // load the plugin styles
     add_action('wp_ajax_WooZoneAdminStyles', array(&$this, 'admin_styles'));
     // hook the assets cron job
     add_action('wp_ajax_WooZoneAssetsCron', array(&$this, 'assets_cron'));
     add_action('wp_ajax_nopriv_WooZoneAssetsCron', array(&$this, 'assets_cron'));
 }