diff --git a/RWListFieldCalculations.php b/RWListFieldCalculations.php index 562b25e..f0d56c7 100644 --- a/RWListFieldCalculations.php +++ b/RWListFieldCalculations.php @@ -3,7 +3,7 @@ Plugin Name: Gravity Forms List Field Calculations Add-On Plugin URI: Description: A simple add-on to enable the use of List fields in calculations. -Version: 0.6 +Version: 0.7 Author: Richard Wawrzyniak Author URI: @@ -27,12 +27,12 @@ //------------------------------------------ -if ( class_exists( 'GFForms' ) ) { +add_action( 'gform_loaded', function(){ GFForms::include_addon_framework(); class RWListFieldCalculations extends GFAddOn { - protected $_version = '0.6'; + protected $_version = '0.7'; protected $_min_gravityforms_version = '2.3'; protected $_slug = 'RWListFieldCalculations'; protected $_path = 'RWListFieldCalculations/RWListFieldCalculations.php'; @@ -47,7 +47,7 @@ public function init() { add_filter( 'gform_custom_merge_tags', array( $this, 'list_field_calculations_merge_tags' ), 10, 4 ); } - function has_list_field_merge_tag( $form ) { + public static function has_list_field_merge_tag( $form ) { foreach ( $form['fields'] as $field ) { if ( ! $field->has_calculation() ) { continue; @@ -62,7 +62,7 @@ function has_list_field_merge_tag( $form ) { // get the $field object for the provided id $field_id = $match[1]; $lfield = GFAPI::get_field( $form, $field_id ); - + // check that we have a field if ( ! $lfield ) { continue; @@ -84,7 +84,7 @@ function has_list_field_merge_tag( $form ) { return false; } - function list_field_calculations_script( $form ) { + public function list_field_calculations_script( $form ) { if ( self::has_list_field_merge_tag( $form ) ) { wp_enqueue_script( 'LFCalc', $this->get_base_url() . '/js/LFCalc.js', array( @@ -95,7 +95,7 @@ function list_field_calculations_script( $form ) { } - function list_field_calculations( $formula, $field, $form, $lead ) { + public function list_field_calculations( $formula, $field, $form, $lead ) { // {List:1.3} - {Label:ID.Column} - sum column values // {List:1} - {Label:ID} - count rows @@ -112,7 +112,7 @@ function list_field_calculations( $formula, $field, $form, $lead ) { // get the $field object for the provided id $field_id = $match[1]; $field = GFAPI::get_field( $form, $field_id ); - + // check that we have a field if ( ! $field ) { continue; @@ -163,7 +163,7 @@ function list_field_calculations( $formula, $field, $form, $lead ) { return $formula; } - function list_field_calculations_merge_tags( $merge_tags, $form_id, $fields, $element_id ) { + public function list_field_calculations_merge_tags( $merge_tags, $form_id, $fields, $element_id ) { // check the type of merge tag dropdown if ( $element_id != 'field_calculation_formula' ) { @@ -206,4 +206,4 @@ function list_field_calculations_merge_tags( $merge_tags, $form_id, $fields, $el } new RWListFieldCalculations(); -} +}, 10, 0 ); diff --git a/changelog.txt b/changelog.txt index c8e6d03..150b7b7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +------------------------------------------------------------------------------------------------------------------- +Version 0.7 + - Use gravity form hook gform_loaded for loading the addon + ------------------------------------------------------------------------------------------------------------------- Version 0.6 - Updated min Gravity Forms version to 2.3