🔒 EXCLUSIVE: Changeset/ - High Quality

Changeset 2084732


Ignore:
Timestamp:
05/09/2019 03:42:59 PM (7 years ago)
Author:
travisnorthcutt
Message:

Version 1.1.0

Location:
convertkit-gravity-forms
Files:
16 added
5 edited

Legend:

Unmodified
Added
Removed
  • convertkit-gravity-forms/trunk/components/gravityforms/class-gf-convertkit.php

    r1840318 r2084732  
    77GFForms::include_feed_addon_framework();
    88
     9/**
     10 * Class GFConvertKit
     11 */
    912class GFConvertKit extends GFFeedAddOn {
    1013
     
    124127                            'name'       => 'n',
    125128                            'label'      => __( 'Name' ),
    126                             'required'   => true,
     129                            'required'   => false,
    127130                            'field_type' => '',
    128131                        ),
     
    131134                ),
    132135                array(
    133                     'name' => 'convertkit_custom_fields',
    134                     'label' => '',
    135                     'type' => 'dynamic_field_map',
    136                     'field_map' => $this->get_custom_fields(),
    137                     'disable_custom' => true,
    138                 ),
    139                 array(
    140136                    'name'    => 'conditions',
    141137                    'label'   => __( 'Conditional Logic' ),
     
    146142        );
    147143
     144        $base_fields = $this->maybe_add_custom_field_mapping( $base_fields );
     145
    148146        return array( $base_fields );
    149147    }
    150148
    151149    /**
     150     * If the connected account returns custom fields, add custom field mapping to the feed settings
     151     * Otherwise, don't insert custom field mapping
     152     *
     153     * @param array $base_fields
     154     *
     155     * @return array
     156     */
     157    public function maybe_add_custom_field_mapping( $base_fields ) {
     158        $custom_mapping = array(
     159            'name'           => 'convertkit_custom_fields',
     160            'label'          => '',
     161            'type'           => 'dynamic_field_map',
     162            'field_map'      => $this->get_custom_fields(),
     163            'disable_custom' => true,
     164        );
     165
     166        if ( $this->get_custom_fields() ) {
     167            array_splice( $base_fields['fields'], 3, 0, array( $custom_mapping ) );
     168        }
     169
     170        return $base_fields;
     171    }
     172
     173    /**
    152174     * Get ConvertKit Custom Fields from the API to be used for the dynamic field map
    153175     *
     
    156178    public function get_custom_fields() {
    157179
    158         $path = 'custom_fields';
    159         $query_args = array();
     180        $path         = 'custom_fields';
     181        $query_args   = array();
    160182        $request_body = null;