Ejemplo n.º 1
0
 /**
  * Frontend Contructor Class
  * @since 1.4.1
  * @return none
  * @constructor
  */
 function __construct()
 {
     Woopra::__construct();
     //	Should we be upgrading the options?
     if (version_compare($this->get_option('version'), $this->version, '!=') && !empty($this->options)) {
         $this->check_upgrade();
     }
     //	Store Plugin Location Information
     $this->plugin_file = dirname(dirname(__FILE__)) . '/woopra.php';
     $this->plugin_basename = plugin_basename($this->plugin_file);
     //	Load Transations File
     load_plugin_textdomain('woopra', false, '/woopra/locale');
     //	Run this when installed or upgraded.
     register_activation_hook($this->plugin_file, array(&$this, 'init'));
     register_deactivation_hook($this->plugin_file, array(&$this, 'init_deactivate'));
     //	Only run if activated!
     if ($this->get_option('activated')) {
         //	Admin Actions
         add_action('admin_enqueue_scripts', array(&$this, 'enqueue'));
         add_action('admin_menu', array(&$this, 'woopra_add_menu'));
         //	AJAX Render
         add_action('wp_ajax_woopra', array(&$this, 'render_page'));
     }
     add_action('admin_menu', array(&$this, 'register_settings_page'));
     add_action('admin_init', array(&$this, 'admin_init'));
     //	Process Events
     $this->event = new WoopraEvents();
 }
Ejemplo n.º 2
0
 function __construct()
 {
     //Construct parent class
     Woopra::__construct();
     //Load configuration
     $this->config = array();
     $this->woopra_config();
     // Load PHP SDK
     $this->woopra = new WoopraTracker($this->config);
     // Load Event Processing
     $this->events = new WoopraEvents();
     //Detect Wordpress user
     $this->user = array();
     add_action('init', array(&$this, 'woopra_detect'));
     //If event tracking is turned on, process events
     if ($this->get_option('process_event')) {
         $this->register_events();
         $this->register_woocommerce_events();
     }
     if ($this->get_option('other_events')) {
         add_action("woopra_track", array(&$this->woopra, "track"), 10, 3);
     }
     //Register front-end tracking
     add_action('init', array(&$this, 'set_tracker'));
 }
Ejemplo n.º 3
0
 /**
  * getUserLabels Helper
  *
  * @param     array $data
  * @param     function $callback
  * @return    mixed
  */
 static function getUserLabels(array $data, $callback = false)
 {
     // validate data parameters
     if (!isset($data['website'])) {
         throw new \InvalidArgumentException('website is required.');
     }
     // validate data parameters
     if (!isset($data['search'])) {
         throw new \InvalidArgumentException('search is required.');
     }
     $woopra_labels = Woopra::getAllLabels($data);
     $search = new Search($data);
     $rsp = $search->search(array('website' => $data['website'], 'search' => $data['search']));
     $labels = array();
     foreach ($rsp->visitors as $visitor) {
         foreach ($visitor->labels as $label) {
             if (array_key_exists($label, $woopra_labels)) {
                 $labels[$label] = $woopra_labels[$label];
             }
         }
     }
     // run callback or return the label data
     if (is_callable($callback)) {
         $callback($labels);
     } else {
         return $labels;
     }
 }
Ejemplo n.º 4
0
 /**
  * Events Contructor Class
  * @since 1.4.1
  * @return 
  * @constructor
  */
 function __construct()
 {
     Woopra::__construct();
     // Register Events!
     $this->register_events();
 }