Skip to content

Commit

Permalink
Improve plugin structure
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeHana committed Apr 27, 2017
1 parent c34e9fc commit 0663a53
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 28 deletions.
5 changes: 4 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: http://paypal.me/anex
Tags: forms, referer, tracking
Requires at least: 4.5.0
Tested up to: 4.7
Stable tag: 1.1.2
Stable tag: 1.2.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -24,6 +24,9 @@ Saves Referers within a Cookie and submits them within hidden fields from a (gra
-

== Changelog ==
= 1.2.0 - 27/04/2017 =
* Improved plugin structure.

= 1.1.2 - 21/04/2017 =
* Improved parameter check.

Expand Down
30 changes: 23 additions & 7 deletions gravityforms-referer-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Gravity Forms - Referer Tracking
* Plugin URI: https://github.com/ANEX-Agency/Gravityforms-Referer-Tracking
* Description: Saves Referers within a Cookie and submits them within hidden fields from a (gravity) form submission
* Version: 1.1.2
* Version: 1.2.0
* Author: ANEX
* Author URI: http://anex.at
* License: GPL-2.0+
Expand All @@ -13,14 +13,30 @@
* Domain Path: /languages
*/

// If this file is called directly or Gravity Forms isn't loaded, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}

add_action( 'gform_loaded', function() {
define( 'GF_REFERER_TRACKING_VERSION', '1.2.0' );

require __DIR__ . '/main.php';

GFAddOn::register( 'Rebits_GF_RefTrack' );

});
add_action( 'gform_loaded', array( 'GF_Referer_Tracking_Bootstrap', 'load' ), 5 );

class GF_Referer_Tracking_Bootstrap {

public static function load(){

if ( ! method_exists( 'GFForms', 'include_feed_addon_framework' ) ) {
return;
}

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

GFAddOn::register( 'Rebits_GF_RefTrack' );

}
}

function gf_referer_tracking(){
return Rebits_GF_RefTrack::get_instance();
}
File renamed without changes.
38 changes: 20 additions & 18 deletions main.php → includes/class-gf-referer-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

GFForms::include_addon_framework();

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

class Rebits_GF_RefTrack extends GFAddOn {

protected $_version = '0.1';
protected $_min_gravityforms_version = '2.1';
protected $_version = '1.2.0';
protected $_min_gravityforms_version = '2.2';
protected $_slug = 'gravityforms-referer-tracking';
protected $_path = 'gravityforms-referer-tracking/gravityforms-referer-tracking.php';
protected $_full_path = __FILE__;
Expand All @@ -31,7 +31,7 @@ public function init() {

parent::init();

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

$this->_engine = new Rebits_GF_RefTrack_Engine($this);
}
Expand All @@ -48,33 +48,27 @@ public function plugin_settings_fields() {
array(
'title' => esc_html__( 'Referer Tracking Settings', 'gravityforms-referer-tracking' ),
'fields' => array(
'params' => array(
'name' => 'params',
'tooltip' => esc_html__( 'White-list one url parameter per line here', 'gravityforms-referer-tracking' ),
'label' => esc_html__( 'URL Parameters', 'gravityforms-referer-tracking' ),
'type' => 'textarea',
),

'cookie_name' => array(
'name' => 'cookie_name',
'tooltip' => esc_html__( 'Cookie Name', 'gravityforms-referer-tracking' ),
'label' => esc_html__( 'Cookie Name', 'gravityforms-referer-tracking' ),
'tooltip' => esc_html__( 'Name your Cookie here', 'gravityforms-referer-tracking' ),
'name' => 'cookie_name',
'type' => 'text',
'default' => '__gf_reftrack',
'default' => '__gf_referertrack',
),

'cookie_expiry' => array(
'name' => 'cookie_expiry',
'tooltip' => esc_html__( 'Cookie Expiration in seconds (default: 60*60*24*60 = 5184000 = 60 days', 'gravityforms-referer-tracking' ),
'label' => esc_html__( 'Cookie Expiry', 'gravityforms-referer-tracking' ),
'tooltip' => esc_html__( 'Cookie Expiration in seconds (default: 60*60*24*60 = 5184000 = 60 days', 'gravityforms-referer-tracking' ),
'name' => 'cookie_expiry',
'type' => 'text',
'default' => 5184000,
),

'cookie_merge_strategy' => array(
'name' => 'cookie_merge_strategy',
'tooltip' => esc_html__( 'How to behave if the cookie is already set?', 'gravityforms-referer-tracking' ),
'label' => esc_html__( 'Cookie Merge Strategy', 'gravityforms-referer-tracking' ),
'tooltip' => esc_html__( 'How to behave if the cookie is already set?', 'gravityforms-referer-tracking' ),
'name' => 'cookie_merge_strategy',
'type' => 'select',
'default' => 'keep',
'choices' => array(
Expand All @@ -91,8 +85,16 @@ public function plugin_settings_fields() {
'label' => __( 'Merge with current request parameters', 'gravityforms-referer-tracking' )
)
)
),

'params' => array(
'label' => esc_html__( 'URL Parameters', 'gravityforms-referer-tracking' ),
'tooltip' => esc_html__( 'White-list one url parameter per line here', 'gravityforms-referer-tracking' ),
'name' => 'params',
'type' => 'textarea',
'class' => 'medium',
)
)
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function get_form_editor_field_settings() {
);
}

public function get_field_input() {
public function get_field_input( $form, $value = '', $entry = NULL ) {
return '';
}

Expand All @@ -38,7 +38,7 @@ public function get_field_content($value, $force_frontend_label, $form) {
return $field_content;
}

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

$engine = Rebits_GF_RefTrack::get_instance()->getEngine();

Expand Down

0 comments on commit 0663a53

Please sign in to comment.