Skip to content

Commit

Permalink
Further Code Improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeHana committed May 2, 2017
1 parent dee7cb4 commit fe5b23a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
27 changes: 23 additions & 4 deletions gravityforms-referer-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,22 @@

define( 'GF_REFERER_TRACKING_VERSION', '1.3.0' );

// If Gravity Forms is loaded, bootstrap the Referer Tracking Add-On.
add_action( 'gform_loaded', array( 'GF_Referer_Tracking_Bootstrap', 'load' ), 5 );

/**
* Class GF_Referer_Tracking_Bootstrap
*
* Handles the loading of the Referer Tracking Add-On and registers with the Add-On Framework.
*/
class GF_Referer_Tracking_Bootstrap {


/**
* If the Feed Add-On Framework exists, Referer Tracking Add-On is loaded.
*
* @access public
* @static
*/
public static function load(){

if ( ! method_exists( 'GFForms', 'include_feed_addon_framework' ) ) {
Expand All @@ -32,11 +44,18 @@ public static function load(){

require_once 'includes/class-gf-referer-tracking.php';

GFAddOn::register( 'GF_Referer_Tracking_Addon' );
GFAddOn::register( 'GF_Referer_Tracking' );

}
}

function gf_referer_tracking(){
return GF_Referer_Tracking_Addon::get_instance();
/**
* Returns an instance of the GF_Referer_Tracking class
*
* @see GF_Referer_Tracking::get_instance()
*
* @return object GF_Referer_Tracking
*/
function gf_referer_tracking() {
return GF_Referer_Tracking::get_instance();
}
9 changes: 6 additions & 3 deletions includes/class-gf-referer-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author ANEX
* @copyright Copyright (c) 2017, ANEX
*/
class GF_Referer_Tracking_Addon extends GFAddOn {
class GF_Referer_Tracking extends GFAddOn {

/**
* Contains an instance of this class, if available.
Expand Down Expand Up @@ -82,7 +82,7 @@ class GF_Referer_Tracking_Addon extends GFAddOn {
* @access protected
* @var string $_title The title of the Add-On.
*/
protected $_title = 'Referer Tracking';
protected $_title = 'Gravity Forms Referer Tracking';

/**
* Defines the short title of the Add-On.
Expand All @@ -108,7 +108,7 @@ class GF_Referer_Tracking_Addon extends GFAddOn {
* @since 1.0.0
* @access public
*
* @return GF_Referer_Tracking_Addon
* @return GF_Referer_Tracking
*/
public static function get_instance() {

Expand Down Expand Up @@ -139,6 +139,7 @@ public function pre_init() {

require_once 'fields/class-gf-field-referer-tracking.php';


}
}

Expand All @@ -154,6 +155,8 @@ public function init() {

$this->_engine = new GF_Referer_Tracking_Engine( $this );

require_once 'template-functions.php';

}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/fields/class-gf-field-referer-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function get_field_content( $value, $force_frontend_label, $form ) {

public function get_value_save_entry( $value, $form, $input_name, $lead_id, $lead ) {

$engine = GF_Referer_Tracking_Addon::get_instance()->get_engine();
$engine = GF_Referer_Tracking::get_instance()->get_engine();

return serialize( $engine->get_cookie_data() );

Expand Down
5 changes: 5 additions & 0 deletions includes/template-functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php



//var_dump( gf_referer_tracking() );

0 comments on commit fe5b23a

Please sign in to comment.