Changeset 2084732
- Timestamp:
- 05/09/2019 03:42:59 PM (7 years ago)
- Location:
- convertkit-gravity-forms
- Files:
-
- 16 added
- 5 edited
-
tags/1.1.0 (added)
-
tags/1.1.0/components (added)
-
tags/1.1.0/components/gravityforms (added)
-
tags/1.1.0/components/gravityforms/class-gf-convertkit.php (added)
-
tags/1.1.0/components/gravityforms/functions (added)
-
tags/1.1.0/components/gravityforms/functions/gravityforms.php (added)
-
tags/1.1.0/components/gravityforms/gravityforms.php (added)
-
tags/1.1.0/components/gravityforms/views (added)
-
tags/1.1.0/components/gravityforms/views/section.php (added)
-
tags/1.1.0/convertkit.php (added)
-
tags/1.1.0/functions (added)
-
tags/1.1.0/functions/convertkit.php (added)
-
tags/1.1.0/functions/utility.php (added)
-
tags/1.1.0/languages (added)
-
tags/1.1.0/languages/convertkit.pot (added)
-
tags/1.1.0/readme.txt (added)
-
trunk/components/gravityforms/class-gf-convertkit.php (modified) (8 diffs)
-
trunk/components/gravityforms/views/section.php (modified) (1 diff)
-
trunk/convertkit.php (modified) (3 diffs)
-
trunk/functions/convertkit.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
convertkit-gravity-forms/trunk/components/gravityforms/class-gf-convertkit.php
r1840318 r2084732 7 7 GFForms::include_feed_addon_framework(); 8 8 9 /** 10 * Class GFConvertKit 11 */ 9 12 class GFConvertKit extends GFFeedAddOn { 10 13 … … 124 127 'name' => 'n', 125 128 'label' => __( 'Name' ), 126 'required' => true,129 'required' => false, 127 130 'field_type' => '', 128 131 ), … … 131 134 ), 132 135 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(140 136 'name' => 'conditions', 141 137 'label' => __( 'Conditional Logic' ), … … 146 142 ); 147 143 144 $base_fields = $this->maybe_add_custom_field_mapping( $base_fields ); 145 148 146 return array( $base_fields ); 149 147 } 150 148 151 149 /** 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 /** 152 174 * Get ConvertKit Custom Fields from the API to be used for the dynamic field map 153 175 * … … 156 178 public function get_custom_fields() { 157 179 158 $path = 'custom_fields';159 $query_args = array();180 $path = 'custom_fields'; 181 $query_args = array(); 160 182 $request_body = null; 161 183 $request_args = array(); 162 $fields = array();184 $fields = array(); 163 185 164 186 $response = ckgf_convertkit_api_request( $path, $query_args, $request_body, $request_args ); 165 $custom_fields = $response['custom_fields']; 166 167 if ( $custom_fields && ! is_wp_error( $custom_fields ) ) { 187 188 // We don't want to do anything if there's an error... 189 if ( is_wp_error( $response ) ) { 190 return $fields; 191 } 192 193 // Or if the `custom_fields` field is empty 194 if ( empty( $response['custom_fields'] ) ) { 195 return $fields; 196 } 197 198 $fields[] = array( 199 'label' => __( 'Choose a ConvertKit Field', 'convertkit' ), 200 ); 201 202 foreach ( $response['custom_fields'] as $field ) { 168 203 169 204 $fields[] = array( 170 'label' => __( 'Choose a ConvertKit Field', 'convertkit' ), 171 ); 172 173 foreach ( $custom_fields as $field ) { 174 175 $fields[] = array( 176 'value' => $field['key'], 177 'label' => $field['label'], 178 ); 179 } 205 'value' => $field['key'], 206 'label' => $field['label'], 207 ); 180 208 } 181 209 … … 251 279 252 280 if ( is_array( $forms ) && isset( $forms[ $form_id ] ) ) { 253 $form = $forms[ $form_id ]; 254 255 return sprintf( '<a href="%s" target="_blank">%s</a>', esc_attr( esc_url( $form['url'] ) ), esc_html( $forms[ $form_id ]['name'] ) ); 281 $form_url = sprintf( '%s/forms/designers/%s/edit', CKGF_APP_BASE_URL, $form_id ); 282 283 return sprintf( '<a href="%s" target="_blank">%s</a>', 284 esc_attr( esc_url( $form_url ) ), 285 esc_html( $forms[ $form_id ]['name'] ) 286 ); 256 287 } else { 257 288 return __( 'N/A' ); … … 278 309 279 310 $fields = array(); 311 312 $email = $this->get_field_value( $form, $entry, $field_map_e ); 313 $name = $this->get_field_value( $form, $entry, $field_map_n ); 280 314 281 315 $custom_fields = $this->get_custom_fields(); … … 289 323 } 290 324 291 ckgf_convertkit_api_add_email( $form_id, $e ntry[ $field_map_e ], $entry[ $field_map_n ], null, $fields );325 ckgf_convertkit_api_add_email( $form_id, $email, $name, null, $fields ); 292 326 } 293 327 -
convertkit-gravity-forms/trunk/components/gravityforms/views/section.php
r1406616 r2084732 4 4 5 5 <p> 6 <?php printf(__('If you already have an account, <a href="%s" target="_blank">click here to retrieve your API Key</a>.'), esc_attr(esc_html('https://app.convertkit.com/account/edit'))); ?> 6 <?php printf( __( 'If you already have an account, <a href="%s" target="_blank">click here to retrieve your API Key</a>.' ), 7 esc_attr( esc_html( CKGF_APP_BASE_URL . '/account/edit' ) ) ); ?> 7 8 </p> -
convertkit-gravity-forms/trunk/convertkit.php
r1840318 r2084732 3 3 * Plugin Name: Gravity Forms ConvertKit Add-On 4 4 * Description: Integrates Gravity Forms with ConvertKit allowing form submissions to be automatically sent to your ConvertKit account. 5 * Version: 1. 0.45 * Version: 1.1.0 6 6 * Author: ConvertKit 7 7 * Author URI: https://convertkit.com/ … … 30 30 31 31 if ( ! defined( 'CKGF_VERSION' ) ) { 32 define( 'CKGF_VERSION', '1. 0.4' );32 define( 'CKGF_VERSION', '1.1.0' ); 33 33 } 34 34 … … 47 47 if ( ! defined( 'CKGF_SHORT_TITLE' ) ) { 48 48 define( 'CKGF_SHORT_TITLE', 'ConvertKit' ); 49 } 50 51 if ( ! defined( 'CKGF_API_BASE_URL' ) ) { 52 define( 'CKGF_API_BASE_URL', 'https://api.convertkit.com/v3' ); 53 } 54 55 if ( ! defined( 'CKGF_APP_BASE_URL' ) ) { 56 define( 'CKGF_APP_BASE_URL', 'https://app.convertkit.com' ); 49 57 } 50 58 -
convertkit-gravity-forms/trunk/functions/convertkit.php
r1840318 r2084732 17 17 function ckgf_convertkit_api_request( $path, $query_args = array(), $request_body = null, $request_args = array() ) { 18 18 $path = ltrim( $path, '/' ); 19 $request_url = "https://api.convertkit.com/v3/{$path}";19 $request_url = sprintf( '%s/%s', CKGF_API_BASE_URL, $path ); 20 20 21 21 $request_args = array_merge(array( -
convertkit-gravity-forms/trunk/readme.txt
r1840318 r2084732 1 1 === Gravity Forms ConvertKit Add-On === 2 Contributors: nathanbarry, growdev 2 Contributors: nathanbarry, growdev, travisnorthcutt 3 3 Donate link: https://convertkit.com 4 4 Tags: email, marketing, embed form, convertkit, capture 5 5 Requires at least: 3.6 6 Tested up to: 4.9.47 Stable tag: 1. 0.46 Tested up to: 5.2 7 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 39 39 == Changelog == 40 40 41 ### 1.1.0 2019-06-09 42 43 * Correctly send full name to ConvertKit when used in a field mapping 44 * Only show field mappings for ConvertKit custom fields if they exist 45 * Output correct form URL on feed settings screen 46 * No longer requires a name field mapping, for email-only forms 47 41 48 ### 1.0.4 2018-03-14 42 49
Note: See TracChangeset
for help on using the changeset viewer.