plugin updates

This commit is contained in:
Tony Volpe
2024-11-20 22:40:39 -05:00
parent 0238f0c4ca
commit 3362947c6e
434 changed files with 13405 additions and 9202 deletions

View File

@@ -9,6 +9,7 @@ if ( ! class_exists( 'GFForms' ) ) {
}
use Gravity_Forms\Gravity_Forms\Settings\Settings;
use Gravity_Forms\Gravity_Forms\Settings\GF_Settings_Encryption;
use Gravity_Forms\Gravity_Forms\TranslationsPress_Updater;
use Gravity_Forms\Gravity_Forms\Save_Form\GF_Save_Form_Service_Provider;
use Gravity_Forms\Gravity_Forms\Save_Form\GF_Save_Form_Helper;
@@ -78,6 +79,11 @@ abstract class GFAddOn {
*/
public $app_hook_suffix;
/**
* @var string The '.min' suffix to append to asset files in production mode.
*/
protected $_asset_min;
private $_saved_settings = array();
private $_previous_settings = array();
@@ -93,6 +99,13 @@ abstract class GFAddOn {
*/
private $_setting_field_errors = array();
/**
* Stores the current instance of the Settings encryption class.
*
* @var \Gravity_Forms\Gravity_Forms\Settings\GF_Settings_Encryption
*/
private $_encryptor;
// ------------ Permissions -----------
/**
* @var string|array A string or an array of capabilities or roles that have access to the settings page
@@ -170,6 +183,7 @@ abstract class GFAddOn {
* Class constructor which hooks the instance into the WordPress init action
*/
function __construct() {
$this->_asset_min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
$this->update_path();
$this->bootstrap();
@@ -189,27 +203,86 @@ abstract class GFAddOn {
*/
public function bootstrap() {
add_action( 'init', array( $this, 'init' ), 15 );
if ( $this->_enable_theme_layer ) {
$is_admin_ajax = defined('DOING_AJAX') && DOING_AJAX;
if ( $this->_enable_theme_layer && ! $is_admin_ajax ) {
add_action( 'init', array( $this, 'init_theme_layer' ), 0, 0 );
}
}
/**
* Initializes the theme layer process for the add-on.
*
* @since Unknown
*
*/
public function init_theme_layer() {
$layer = new Theme_Layer_Builder();
$layer->set_name( $this->theme_layer_slug() )
->set_short_title( $this->theme_layer_title() )
->set_priority( $this->theme_layer_priority() )
->set_icon( $this->theme_layer_icon() )
->set_settings_fields( $this->theme_layer_settings_fields() )
->set_overidden_fields( $this->theme_layer_overridden_fields() )
->set_form_css_properties( array( $this, 'theme_layer_form_css_properties' ) )
->set_styles( array( $this, 'theme_layer_styles' ) )
->set_scripts( array( $this, 'theme_layer_scripts' ) )
->set_capability( $this->get_form_settings_capabilities() )
->register();
->set_short_title( $this->theme_layer_title() )
->set_priority( $this->theme_layer_priority() )
->set_icon( $this->theme_layer_icon() )
->set_settings_fields( $this->theme_layer_settings_fields() )
->set_overidden_fields( $this->theme_layer_overridden_fields() )
->set_form_css_properties( array( $this, 'theme_layer_form_css_properties' ) )
->set_styles( array( $this, 'theme_layer_styles' ) )
->set_scripts( array( $this, 'theme_layer_scripts' ) )
->set_capability( $this->get_form_settings_capabilities() )
->register();
add_action( 'gform_form_after_open', array( $this, 'output_third_party_styles' ), 998, 2 );
}
/**
* Helper method that returns the theme styles that should be enqueued for the add-on. Returns an array in the format accepted by the Gravity Forms theme layer set_styles() method
*
* @since 2.9.0
*
* @param array $form The current form object to enqueue styles for.
* @param string $field_type The field type associated with the add-on. Styles will only be enqueued on the frontend if the form has a field with the specified field type.
* @param string $gravity_theme_path The path to the gravity theme style. Optional. Only needed for add-ons that implement the gravity theme outside the default /assets/css/dist/theme.css path.
*
* @return array Returns and array of styles to enqueue in the format accepted by the Gravity Forms theme layer set_styles() method.
*/
public function get_theme_layer_styles( $form, $field_type = '', $gravity_theme_path = '' ) {
$themes = $this->get_themes_to_enqueue( $form, $field_type );
$styles = array();
// Maybe enqueue theme framework.
if ( in_array( 'orbital', $themes ) ) {
$styles['foundation'] = array(
array( "{$this->_slug}_theme_foundation", $this->get_base_url() . "/assets/css/dist/theme-foundation{$this->_asset_min}.css" ),
);
$styles['framework'] = array(
array( "{$this->_slug}_theme_framework", $this->get_base_url() . "/assets/css/dist/theme-framework{$this->_asset_min}.css" ),
);
}
// Maybe enqueue gravity theme.
if ( in_array( 'gravity-theme', $themes ) ) {
$path = $gravity_theme_path ? $gravity_theme_path : $this->get_base_url() . "/assets/css/dist/theme{$this->_asset_min}.css";
$styles['theme'] = array(
array( "{$this->_slug}_gravity_theme", $path ),
);
}
return $styles;
}
/**
* Helper method that returns the themes that should be enqueued for the add-on. Returns an array of theme slugs.
*
* @since 2.9.0
*
* @param array $form The current form object to enqueue styles for.
* @param string|array $field_types The field type(s) associated with the add-on. Themes will only be enqueued on the frontend if the form has a field with the specified field type(s). Can be a string with a single field type or an array of strings with multiple field types.
*
* @return array Returns and array of theme slugs to enqueue.
*/
public function get_themes_to_enqueue ( $form, $field_types = '' ) {
return \GFFormDisplay::get_themes_to_enqueue( $form, $field_types );
}
/**
* Registers an addon so that it gets initialized appropriately
*
@@ -268,6 +341,32 @@ abstract class GFAddOn {
return $instances;
}
/**
* Finds a registered add-on by its slug and return its instance.
*
* @since 2.7.17
*
* @param string $slug The add-on slug.
*
* @return GFAddOn Returns an instance of the add-on with the specified slug.
*/
public static function get_addon_by_slug( $slug ) {
static $map = array();
if ( isset( $map[ $slug ] ) ) {
return $map[ $slug ];
}
$addons = GFAddOn::get_registered_addons( true );
foreach ( $addons as $addon ) {
$map[ $addon->get_slug() ] = $addon;
}
return rgar( $map, $slug );
}
/**
* Initializes all addons.
*
@@ -1528,7 +1627,7 @@ abstract class GFAddOn {
* );
* }
*
* @return array|bool
* @return array|bool
*/
public function get_results_page_config() {
return false;
@@ -1610,8 +1709,8 @@ abstract class GFAddOn {
*/
public function members_register_caps() {
// Get capabilities.
$caps = $this->get_members_caps();
// Get capabilities.
$caps = $this->get_members_caps();
// If no capabilities were found, exit.
if ( empty( $caps ) ) {
@@ -2270,7 +2369,7 @@ abstract class GFAddOn {
}
public function has_setting_field_type( $type, $fields ) {
if ( ! empty( $fields ) ) {
if ( ! empty( $fields ) ) {
foreach ( $fields as &$section ) {
foreach ( $section['fields'] as $field ) {
if ( rgar( $field, 'type' ) == $type ) {
@@ -2312,8 +2411,35 @@ abstract class GFAddOn {
return false;
}
/**
* Sets the current instance of object that handles settings encryption.
*
* @since 2.7.17
*
* @param \Gravity_Forms\Gravity_Forms\Settings\GF_Settings_Encryption $encryptor Settings encryptor.
*
* @return void
*/
public function set_encryptor( $encryptor ) {
$this->_encryptor = $encryptor;
}
/**
* Returns the current instance of the settings encryptor.
*
* @since 2.7.17
*
* @return GF_Settings_Encryption Returns the current instance of the settings encryptor.
*/
public function get_encryptor() {
if ( ! $this->_encryptor ) {
require_once( GFCommon::get_base_path() . '/includes/settings/class-gf-settings-encryption.php' );
$this->_encryptor = new GF_Settings_Encryption();
}
return $this->_encryptor;
}
//------------- Field Types ------------------------------------------------------
/***
@@ -3128,7 +3254,7 @@ abstract class GFAddOn {
}
}
return $fields;
return $fields;
}
/**
@@ -3806,11 +3932,11 @@ abstract class GFAddOn {
$error = $this->get_field_errors( $field );
return '<span
class="gf_tooltip tooltip"
title="<h6>' . esc_html__( 'Validation Error', 'gravityforms' ) . '</h6>' . $error . '"
style="display:inline-block;position:relative;right:-3px;top:1px;font-size:14px;">
<i class="fa fa-exclamation-circle icon-exclamation-sign gf_invalid"></i>
</span>';
class="gf_tooltip tooltip"
title="<h6>' . esc_html__( 'Validation Error', 'gravityforms' ) . '</h6>' . $error . '"
style="display:inline-block;position:relative;right:-3px;top:1px;font-size:14px;">
<i class="fa fa-exclamation-circle icon-exclamation-sign gf_invalid"></i>
</span>';
}
/**
@@ -4771,6 +4897,7 @@ abstract class GFAddOn {
'fields' => $sections,
'initial_values' => $this->get_plugin_settings(),
'save_callback' => array( $this, 'update_plugin_settings' ),
'field_encryption_disabled' => true,
)
);
@@ -4890,15 +5017,30 @@ abstract class GFAddOn {
return $this->method_is_overridden( 'plugin_settings_fields' ) || $this->method_is_overridden( 'plugin_settings_page' ) || $this->method_is_overridden( 'plugin_settings' );
}
/**
* @var array Holds the cached plugin settings.
*
* @since 2.7.17
*/
private static $_plugin_settings = array();
/**
* Returns the currently saved plugin settings
*
* @since Unknown
*
* @return array|false
* @since 2.7.17 Added caching of plugin settings and encrypting of settings.
*
* @return array|false Returns the plugin settings or false if the settings haven't been saved yet.
*/
public function get_plugin_settings() {
return get_option( 'gravityformsaddon_' . $this->get_slug() . '_settings' );
if ( isset( self::$_plugin_settings[ $this->get_slug() ] ) ) {
return self::$_plugin_settings[$this->get_slug() ];
}
self::$_plugin_settings[ $this->get_slug() ] = $this->get_encryptor()->decrypt( get_option( 'gravityformsaddon_' . $this->get_slug() . '_settings' ) );
return self::$_plugin_settings[ $this->get_slug() ];
}
/**
@@ -4915,7 +5057,6 @@ abstract class GFAddOn {
$settings = $this->get_plugin_settings();
return isset( $settings[ $setting_name ] ) ? $settings[ $setting_name ] : null;
}
/**
@@ -4923,10 +5064,14 @@ abstract class GFAddOn {
*
* @since Unknown
*
* @since 2.7.17 Added caching of plugin settings and encrypting of settings.
*
* @param array $settings Plugin settings to be saved.
*/
public function update_plugin_settings( $settings ) {
update_option( 'gravityformsaddon_' . $this->get_slug() . '_settings', $settings );
self::$_plugin_settings[$this->get_slug() ] = $settings;
update_option( 'gravityformsaddon_' . $this->get_slug() . '_settings', $this->get_encryptor()->encrypt( $settings ) );
}
/**

View File

@@ -634,6 +634,16 @@ abstract class GFFeedAddOn extends GFAddOn {
//-------- Feed data methods -------------------------
/**
* Gets the feeds for the specified form id.
*
* @since Unknown
* @since 2.7.17 Added support for decrypting settings fields.
*
* @param int $form_id The form id to get feeds for.
*
* @return array Returns an array of feeds for the specified form id.
*/
public function get_feeds( $form_id = null ) {
global $wpdb;
@@ -646,7 +656,7 @@ abstract class GFFeedAddOn extends GFAddOn {
$results = $wpdb->get_results( $sql, ARRAY_A );
foreach ( $results as &$result ) {
$result['meta'] = json_decode( $result['meta'], true );
$result['meta'] = $this->decrypt_feed_meta( json_decode( $result['meta'], true ) );
}
return $results;
@@ -656,6 +666,7 @@ abstract class GFFeedAddOn extends GFAddOn {
* Queries and returns all active feeds for this Add-On
*
* @since 2.4
* @since 2.7.17 Added support for decrypting settings fields.
*
* @param int $form_id The Form Id to get feeds from.
*
@@ -673,12 +684,23 @@ abstract class GFFeedAddOn extends GFAddOn {
$results = $wpdb->get_results( $sql, ARRAY_A );
foreach ( $results as &$result ) {
$result['meta'] = json_decode( $result['meta'], true );
$result['meta'] = $this->decrypt_feed_meta( json_decode( $result['meta'], true ) );
}
return $results;
}
/**
* Gets the feeds for the specified addon slug and form id.
*
* @since Unknown
* @since 2.7.17 Added support for decrypting settings fields.
*
* @param string $slug The addon slug to get feeds for.
* @param int $form_id (optional) The form id to get feeds for. If not specified, all feeds for the specified addon slug will be returned.
*
* @return array Returns an array of feeds for the specified form id.
*/
public function get_feeds_by_slug( $slug, $form_id = null ) {
global $wpdb;
@@ -694,7 +716,7 @@ abstract class GFFeedAddOn extends GFAddOn {
$results = $wpdb->get_results( $sql, ARRAY_A );
foreach( $results as &$result ) {
$result['meta'] = json_decode( $result['meta'], true );
$result['meta'] = $this->decrypt_feed_meta( json_decode( $result['meta'], true ) );
}
return $results;
@@ -716,6 +738,16 @@ abstract class GFFeedAddOn extends GFAddOn {
}
}
/**
* Gets a feed by its id.
*
* @since Unknown
* @since 2.7.17 Added support for decrypting settings fields.
*
* @param int $id The feed id.
*
* @return array Returns the feed array if found, false otherwise.
*/
public function get_feed( $id ) {
global $wpdb;
@@ -731,7 +763,7 @@ abstract class GFFeedAddOn extends GFAddOn {
return false;
}
$row['meta'] = json_decode( $row['meta'], true );
$row['meta'] = $this->decrypt_feed_meta( json_decode( $row['meta'], true ) );
return $row;
}
@@ -772,6 +804,20 @@ abstract class GFFeedAddOn extends GFAddOn {
return $meets_conditional_logic ? false : $has_active_feed;
}
/**
* Decrypts the feed meta row and return the decripted array.
*
* @since 2.7.17
*
* @param array $row The feed meta row to decrypt.
*
* @return array Returns the feed meta row with values decrypted appropriately.
*/
private function decrypt_feed_meta( $row ) {
return $this->get_encryptor()->decrypt_feed_meta( $row );
}
public function get_single_submission_feed( $entry = false, $form = false ) {
if ( ! $entry && ! $form ) {
@@ -779,26 +825,18 @@ abstract class GFFeedAddOn extends GFAddOn {
}
$feed = false;
if ( ! empty( $this->_single_submission_feed ) && ( ! $form || $this->_single_submission_feed['form_id'] == $form['id'] ) ) {
$feed = $this->_single_submission_feed;
} elseif ( ! empty( $entry['id'] ) ) {
$feeds = $this->get_feeds_by_entry( $entry['id'] );
if ( empty( $feeds ) ) {
$feed = $this->get_single_submission_feed_by_form( $form, $entry );
} else {
$feed = $this->get_feed( $feeds[0] );
}
} elseif ( $form ) {
$feed = $this->get_single_submission_feed_by_form( $form, $entry );
$this->_single_submission_feed = $feed;
}
return $feed;
@@ -924,9 +962,23 @@ abstract class GFFeedAddOn extends GFAddOn {
return true;
}
/**
* Updates the feed meta
*
* @since Unknown
*
* @since 2.7.17 Added support for encrypting of settings fields.
*
* @param int $id Feed ID
* @param array $meta Feed meta to be updated
*
* @return bool
*/
public function update_feed_meta( $id, $meta ) {
global $wpdb;
$meta = $this->get_encryptor()->encrypt_feed_meta( $meta, $this->get_fields_to_encrypt() );
$meta = json_encode( $meta );
$wpdb->update( "{$wpdb->prefix}gf_addon_feed", array( 'meta' => $meta ), array( 'id' => $id ), array( '%s' ), array( '%d' ) );
@@ -942,6 +994,19 @@ abstract class GFFeedAddOn extends GFAddOn {
return $wpdb->rows_affected > 0;
}
/**
* Insert a new feed record.
*
* @since Unknown
*
* @since 2.7.17 Added support for encrypting settings fields.
*
* @param int $form_id Form ID.
* @param bool $is_active If the feed is active or not.
* @param array $meta Feed meta
*
* @return false|int Returns the ID of the newly created feed or false if the feed table does not exist.
*/
public function insert_feed( $form_id, $is_active, $meta ) {
global $wpdb;
@@ -950,12 +1015,47 @@ abstract class GFFeedAddOn extends GFAddOn {
return false;
}
$meta = $this->get_encryptor()->encrypt_feed_meta( $meta, $this->get_fields_to_encrypt() );
$meta = json_encode( $meta );
$wpdb->insert( "{$wpdb->prefix}gf_addon_feed", array( 'addon_slug' => $this->get_slug(), 'form_id' => $form_id, 'is_active' => $is_active, 'meta' => $meta ), array( '%s', '%d', '%d', '%s' ) );
return $wpdb->insert_id;
}
/**
* Get the array of feed settings field names that are configured to be encrypted.
*
* @since 2.7.16
*
* @return array Returns an array with all field names that are configured to be encrypted.
*/
public function get_fields_to_encrypt() {
static $cached_fields_to_encrypt;
if ( rgar( $cached_fields_to_encrypt, $this->_slug ) ) {
return $cached_fields_to_encrypt[ $this->_slug ];
}
$groups = $this->get_feed_settings_fields();
// Loop through feed settings fields and create array of fields that are configured to be encrypted
$fields_to_encrypt = array();
foreach ( $groups as $group ) {
if ( ! isset( $group['fields'] ) ) {
continue;
}
foreach ( $group['fields'] as $field ) {
if ( rgar( $field, 'encrypt' ) ) {
$fields_to_encrypt[] = $field['name'];
}
}
}
$cached_fields_to_encrypt[ $this->_slug ] = $fields_to_encrypt;
return $fields_to_encrypt;
}
public function delete_feed( $id ) {
global $wpdb;
@@ -1390,11 +1490,17 @@ abstract class GFFeedAddOn extends GFAddOn {
},
'before_fields' => function() use ( $form ) {
$script = sprintf( 'var form = %s;', wp_json_encode( $form ) );
$entry_meta = $this->get_feed_settings_entry_meta( $form );
if ( ! empty( $entry_meta ) ) {
$script .= sprintf( 'var entry_meta = %s;', wp_json_encode( $entry_meta ) );
}
return sprintf( '
<input type="hidden" name="gf_feed_id" value="%d" />
<script type="text/javascript">var form = %s;</script>',
%s',
(int) $this->get_current_feed_id(),
wp_json_encode( $form )
GFCommon::get_inline_script_tag( $script, false )
);
},
)
@@ -1439,6 +1545,29 @@ abstract class GFFeedAddOn extends GFAddOn {
$this->get_settings_renderer()->process_postback();
}
/**
* Returns an array of entry meta fields to be assigned to the JavaScript entry_meta variable used by the feed condition setting.
*
* @since 2.9
*
* @param array $form The form the feed is being created or edited for.
* @param array $entry_meta An empty array or the entry meta fields to be assigned to the JavaScript entry_meta variable.
*
* @return array
*/
public function get_feed_settings_entry_meta( $form, $entry_meta = array() ) {
/**
* Allows population of the JavaScript entry_meta variable on the feed configuration page.
*
* @since 2.9
*
* @param array $entry_meta An empty array or the entry meta fields to be assigned to the JavaScript entry_meta variable.
* @param array $form The form the feed is being created or edited for.
* @param GFFeedAddOn $addon The current add-on instance.
*/
return apply_filters( 'gform_entry_meta_pre_render_feed_settings', $entry_meta, $form, $this );
}
/**
* Render feed edit page.
*

View File

@@ -2152,10 +2152,12 @@ abstract class GFPaymentAddOn extends GFFeedAddOn {
// keep 'gform_subscription_payment_failed' for backward compatability
/**
* @deprecated Use gform_post_fail_subscription_payment now
* @deprecated Use gform_post_fail_subscription_payment now.
* @remove-in 3.0
*/
do_action( 'gform_subscription_payment_failed', $entry, $action['subscription_id'] );
if ( has_filter( 'gform_subscription_payment_failed' ) ) {
trigger_error( 'gform_subscription_payment_failed is deprecated and will be removed in version 3.0. Use gform_post_fail_subscription_payment.', E_USER_DEPRECATED );
$this->log_debug( __METHOD__ . '(): Executing functions hooked to gform_subscription_payment_failed.' );
}
/**
@@ -2374,6 +2376,20 @@ abstract class GFPaymentAddOn extends GFFeedAddOn {
//--------- Feed Settings ----------------
/**
* Returning an empty array because payment feed logic is evaluated before entry meta is saved.
*
* @since 2.9
*
* @param array $form The form the feed is being created or edited for.
* @param array $entry_meta An empty array or the entry meta fields to be assigned to the JavaScript entry_meta variable.
*
* @return array
*/
public function get_feed_settings_entry_meta( $form, $entry_meta = array() ) {
return array();
}
/**
* Remove the add new button from the title if the form requires a credit card field.
*

View File

@@ -36,6 +36,10 @@ var GFFrontendFeeds = function( args ) {
};
self.saveToState = function() {
gform.state.set( self.options.formId, 'feeds', self.options.feeds );
}
self.evaluateFeeds = function() {
var feed, isMatch, isActivated;
@@ -67,6 +71,7 @@ var GFFrontendFeeds = function( args ) {
gform.doAction( 'gform_{0}_frontend_feeds_evaluated'.gformFormat( feed.addonSlug ), self.options.feeds, self.options.formId, self );
gform.doAction( 'gform_{0}_frontend_feeds_evaluated_{0}'.gformFormat( feed.addonSlug, self.options.formId ), self.options.feeds, self.options.formId, self );
self.saveToState();
};
self.evaluateFeed = function( feed, formId ) {

View File

@@ -1 +1 @@
var GFFrontendFeeds=function(o){var r=this,f=jQuery;r.init=function(){r.options=o,r.triggerInputIds=r.getTriggerInputIds(r.options.feeds),r.activeFeeds=[],r.evaluateFeeds(),r.bindEvents()},r.bindEvents=function(){gform.addAction("gform_input_change",function(o,e,t){var d=parseInt(t)+"",t=-1!==f.inArray(t,r.triggerInputIds)||-1!==f.inArray(d,r.triggerInputIds);r.options.formId==e&&t&&r.evaluateFeeds()})},r.evaluateFeeds=function(){var o,e,t;for(i=0;i<r.options.feeds.length;i++)o=r.options.feeds[i],e=r.evaluateFeed(o,r.options.formId),t=r.isFeedActivated(o),e||null===t?e&&!t&&(!o.isSingleFeed||o.isSingleFeed&&r.hasPriority(o.feedId,o.addonSlug))&&r.activateFeed(o):r.deactivateFeed(o);gform.doAction("gform_frontend_feeds_evaluated",r.options.feeds,r.options.formId,r),gform.doAction("gform_frontend_feeds_evaluated_{0}".gformFormat(r.options.formId),r.options.feeds,r.options.formId,r),gform.doAction("gform_{0}_frontend_feeds_evaluated".gformFormat(o.addonSlug),r.options.feeds,r.options.formId,r),gform.doAction("gform_{0}_frontend_feeds_evaluated_{0}".gformFormat(o.addonSlug,r.options.formId),r.options.feeds,r.options.formId,r)},r.evaluateFeed=function(o,e){return!o.conditionalLogic||"show"==gf_get_field_action(e,o.conditionalLogic)},r.getTriggerInputIds=function(){for(var o=[],e=0;e<r.options.feeds.length;e++){var t=r.options.feeds[e];if(t.conditionalLogic)for(var d=0;d<t.conditionalLogic.rules.length;d++){var n=r.options.feeds[e].conditionalLogic.rules[d];-1==f.inArray(n.fieldId,o)&&o.push(n.fieldId)}}return o},r.isFeedActivated=function(o){return!("object"!=typeof o&&!(o=r.getFeed(o)))&&(void 0!==o.isActivated?o.isActivated:null)},r.getFeed=function(o){for(var e=0;e<r.options.feeds.length;e++){var t=r.options.feeds[e];if(t.feedId==o)return t}return!1},r.getFeedsByAddon=function(o,e,t){for(var d=[],n=0;n<r.options.feeds.length;n++){var i=r.options.feeds[n];i.addonSlug!=o||e&&i.feedId==e.feedId||t&&!r.isFeedActivated(i)||d.push(i)}return d},r.activateFeed=function(o){o.feedId&&(o=[o]);for(var e=0;e<o.length;e++){var t=o[e];t.isActivated=!0,gform.doAction("gform_frontend_feed_activated",t,r.options.formId),gform.doAction("gform_frontend_feed_activated_{0}".gformFormat(r.options.formId),t,r.options.formId),gform.doAction("gform_{0}_frontend_feed_activated".gformFormat(t.addonSlug),t,r.options.formId),gform.doAction("gform_{0}_frontend_feed_activated_{0}".gformFormat(t.addonSlug,r.options.formId),t,r.options.formId),t.isSingleFeed&&r.deactivateFeed(r.getFeedsByAddon(t.addonSlug,t))}},r.deactivateFeed=function(o){o.feedId&&(o=[o]);for(var e=0;e<o.length;e++){var t=o[e],d=r.isFeedActivated(t);null!==d&&!1!==d&&(t.isActivated=!1,gform.doAction("gform_frontend_feed_deactivated",t,r.options.formId),gform.doAction("gform_frontend_feed_deactivated_{0}".gformFormat(r.options.formId),t,r.options.formId),gform.doAction("gform_{0}_frontend_feed_deactivated".gformFormat(t.addonSlug),t,r.options.formId),gform.doAction("gform_{0}_frontend_feed_deactivated_{0}".gformFormat(t.addonSlug,r.options.formId),t,r.options.formId))}},r.hasPriority=function(o,e){for(var t=r.getFeedsByAddon(e),d=0;d<=t.length;d++){var n=t[d];if(n.feedId!=o&&n.isActivated)return!1;if(n.feedId==o)return!0}return!1},this.init()};
var GFFrontendFeeds=function(o){var r=this,f=jQuery;r.init=function(){r.options=o,r.triggerInputIds=r.getTriggerInputIds(r.options.feeds),r.activeFeeds=[],r.evaluateFeeds(),r.bindEvents()},r.bindEvents=function(){gform.addAction("gform_input_change",function(o,e,t){var d=parseInt(t)+"",t=-1!==f.inArray(t,r.triggerInputIds)||-1!==f.inArray(d,r.triggerInputIds);r.options.formId==e&&t&&r.evaluateFeeds()})},r.saveToState=function(){gform.state.set(r.options.formId,"feeds",r.options.feeds)},r.evaluateFeeds=function(){var o,e,t;for(i=0;i<r.options.feeds.length;i++)o=r.options.feeds[i],e=r.evaluateFeed(o,r.options.formId),t=r.isFeedActivated(o),e||null===t?!e||t||o.isSingleFeed&&(o.isSingleFeed,!r.hasPriority(o.feedId,o.addonSlug))||r.activateFeed(o):r.deactivateFeed(o);gform.doAction("gform_frontend_feeds_evaluated",r.options.feeds,r.options.formId,r),gform.doAction("gform_frontend_feeds_evaluated_{0}".gformFormat(r.options.formId),r.options.feeds,r.options.formId,r),gform.doAction("gform_{0}_frontend_feeds_evaluated".gformFormat(o.addonSlug),r.options.feeds,r.options.formId,r),gform.doAction("gform_{0}_frontend_feeds_evaluated_{0}".gformFormat(o.addonSlug,r.options.formId),r.options.feeds,r.options.formId,r),r.saveToState()},r.evaluateFeed=function(o,e){return!o.conditionalLogic||"show"==gf_get_field_action(e,o.conditionalLogic)},r.getTriggerInputIds=function(){for(var o=[],e=0;e<r.options.feeds.length;e++){var t=r.options.feeds[e];if(t.conditionalLogic)for(var d=0;d<t.conditionalLogic.rules.length;d++){var n=r.options.feeds[e].conditionalLogic.rules[d];-1==f.inArray(n.fieldId,o)&&o.push(n.fieldId)}}return o},r.isFeedActivated=function(o){return!("object"!=typeof o&&!(o=r.getFeed(o)))&&(void 0!==o.isActivated?o.isActivated:null)},r.getFeed=function(o){for(var e=0;e<r.options.feeds.length;e++){var t=r.options.feeds[e];if(t.feedId==o)return t}return!1},r.getFeedsByAddon=function(o,e,t){for(var d=[],n=0;n<r.options.feeds.length;n++){var i=r.options.feeds[n];i.addonSlug!=o||e&&i.feedId==e.feedId||t&&!r.isFeedActivated(i)||d.push(i)}return d},r.activateFeed=function(o){o.feedId&&(o=[o]);for(var e=0;e<o.length;e++){var t=o[e];t.isActivated=!0,gform.doAction("gform_frontend_feed_activated",t,r.options.formId),gform.doAction("gform_frontend_feed_activated_{0}".gformFormat(r.options.formId),t,r.options.formId),gform.doAction("gform_{0}_frontend_feed_activated".gformFormat(t.addonSlug),t,r.options.formId),gform.doAction("gform_{0}_frontend_feed_activated_{0}".gformFormat(t.addonSlug,r.options.formId),t,r.options.formId),t.isSingleFeed&&r.deactivateFeed(r.getFeedsByAddon(t.addonSlug,t))}},r.deactivateFeed=function(o){o.feedId&&(o=[o]);for(var e=0;e<o.length;e++){var t=o[e],d=r.isFeedActivated(t);null!==d&&!1!==d&&(t.isActivated=!1,gform.doAction("gform_frontend_feed_deactivated",t,r.options.formId),gform.doAction("gform_frontend_feed_deactivated_{0}".gformFormat(r.options.formId),t,r.options.formId),gform.doAction("gform_{0}_frontend_feed_deactivated".gformFormat(t.addonSlug),t,r.options.formId),gform.doAction("gform_{0}_frontend_feed_deactivated_{0}".gformFormat(t.addonSlug,r.options.formId),t,r.options.formId))}},r.hasPriority=function(o,e){for(var t=r.getFeedsByAddon(e),d=0;d<=t.length;d++){var n=t[d];if(n.feedId!=o&&n.isActivated)return!1;if(n.feedId==o)return!0}return!1},this.init()};

View File

@@ -1 +1 @@
window.GFToken=null,function(n){GFToken=function(i){for(var t in i)i.hasOwnProperty(t)&&(this[t]=i[t]);this.form=n("#gform_"+this.formId),this.init=function(){var s=this;this.tokens={},this.isAjax||gformInitSpinner(this.formId),this.hasPages&&n(document).bind("gform_page_loaded",function(i,t,e){t==s.formId&&e!=s.pageCount&&s.saveEntryData()}),this.form.submit(function(){s.onSubmit()})},this.onSubmit=function(){this.form.data("gftokensubmitting")||(event.preventDefault(),this.form.data("gftokensubmitting",!0),this.saveEntryData(),this.processTokens())},this.processTokens=function(){for(var i in this.feeds){this.active_feed=this.feeds[i];var t,e={billing_fields:{},id:this.active_feed.id,name:this.active_feed.name};for(t in this.active_feed.billing_fields)field_id=this.active_feed.billing_fields[t],e.billing_fields[t]=this.entry_data[field_id];window[this.callback].createToken(e,this)}},this.saveEntryData=function(){var t=this,e="input_"+this.formId+"_";this.entry_data||(this.entry_data={}),this.form.find('input[id^="'+e+'"], select[id^="'+e+'"], textarea[id^="'+e+'"]').each(function(){var i=n(this).attr("id").replace(e,"").replace("_",".");0<=n.inArray(i,t.fields)&&(t.entry_data[i]=n(this).val())})},this.saveToken=function(i){this.tokens[this.active_feed.id]={feed_id:this.active_feed.id,response:i},this.tokens.length==this.feeds.length&&(this.form.find(this.responseField).val(n.toJSON(this.tokens)),this.form.submit())},this.init()}}(jQuery);
window.GFToken=null,(n=>{GFToken=function(i){for(var t in i)i.hasOwnProperty(t)&&(this[t]=i[t]);this.form=n("#gform_"+this.formId),this.init=function(){var s=this;this.tokens={},this.isAjax||gformInitSpinner(this.formId),this.hasPages&&n(document).bind("gform_page_loaded",function(i,t,e){t==s.formId&&e!=s.pageCount&&s.saveEntryData()}),this.form.submit(function(){s.onSubmit()})},this.onSubmit=function(){this.form.data("gftokensubmitting")||(event.preventDefault(),this.form.data("gftokensubmitting",!0),this.saveEntryData(),this.processTokens())},this.processTokens=function(){for(var i in this.feeds){this.active_feed=this.feeds[i];var t,e={billing_fields:{},id:this.active_feed.id,name:this.active_feed.name};for(t in this.active_feed.billing_fields)field_id=this.active_feed.billing_fields[t],e.billing_fields[t]=this.entry_data[field_id];window[this.callback].createToken(e,this)}},this.saveEntryData=function(){var t=this,e="input_"+this.formId+"_";this.entry_data||(this.entry_data={}),this.form.find('input[id^="'+e+'"], select[id^="'+e+'"], textarea[id^="'+e+'"]').each(function(){var i=n(this).attr("id").replace(e,"").replace("_",".");0<=n.inArray(i,t.fields)&&(t.entry_data[i]=n(this).val())})},this.saveToken=function(i){this.tokens[this.active_feed.id]={feed_id:this.active_feed.id,response:i},this.tokens.length==this.feeds.length&&(this.form.find(this.responseField).val(n.toJSON(this.tokens)),this.form.submit())},this.init()}})(jQuery);