Changeset 1497327
- Timestamp:
- 09/17/2016 05:07:38 AM (10 years ago)
- Location:
- wpf-gravityforms/trunk
- Files:
-
- 1 deleted
- 2 edited
-
README.txt (modified) (2 diffs)
-
languages/index.html (deleted)
-
wpf-gravityforms.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpf-gravityforms/trunk/README.txt
r1404179 r1497327 4 4 Donate link: https://wpfortify.com 5 5 Requires at least: 3.9 6 Tested up to: 4. 57 Stable tag: 2. 2.06 Tested up to: 4.6 7 Stable tag: 2.3.0 8 8 License: GPLv2+ 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 81 81 82 82 == Changelog == 83 = 2.3.0 = 84 * Added conditional logic to form settings. 85 83 86 = 2.2.0 = 84 87 * Added notification delays. -
wpf-gravityforms/trunk/wpf-gravityforms.php
r1212346 r1497327 4 4 Plugin URI: http://wordpress.org/plugins/wpf-gravityforms/ 5 5 Description: wpFortify provides a hosted SSL checkout page for Stripe payments. A free wpFortify account is required for this plugin to work. 6 Version: 2. 2.06 Version: 2.3.0 7 7 Author: wpFortify 8 8 Author URI: https://wpfortify.com 9 Text Domain: wpf-gravityforms 10 Domain Path: /languages 9 11 License: GPLv2+ 10 12 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 22 24 class WPF_GF extends GFAddOn { 23 25 24 protected $_version = '2. 2.0';26 protected $_version = '2.3.0'; 25 27 protected $_min_gravityforms_version = '1.8.9'; 26 28 protected $_slug = 'wpf-gravityforms'; … … 74 76 75 77 return array( 76 77 78 array( 78 79 'title' => __( 'wpFortify', 'wpf-gravityforms' ), … … 94 95 'required' => true 95 96 ) 96 97 97 ), 98 99 98 ) 100 101 99 ); 102 100 … … 109 107 110 108 return array( 111 112 109 array( 113 110 'title' => 'General Settings', … … 136 133 ) 137 134 ), 138 139 135 array( 140 136 'title' => 'Basic', … … 161 157 ) 162 158 ), 163 164 159 array( 165 160 'title' => 'Checkout Settings', … … 202 197 'tooltip' => '<h6>' . __( 'Notifications', 'wpf-gravityforms' ) . '</h6>' . __( "Enable this option if you would like to only send out this form's notifications after payment has been received. Leaving this option disabled will send notifications immediately after the form is submitted.", 'wpf-gravityforms' ) 203 198 ), 199 array( 200 'name' => 'conditional_logic', 201 'label' => __( 'Conditional Logic', 'wpf-gravityforms'), 202 'type' => 'conditional_logic', 203 ), 204 204 ) 205 205 ), 206 207 206 array( 208 207 'title' => 'Optional Settings', … … 263 262 ) 264 263 ) 265 266 264 ); 267 265 … … 274 272 275 273 $order = $this->get_form_settings( $form ); 276 277 if ( $order['enable'] ){ 278 279 $testmode = $order['testmode'] === '1' ? true : false; 274 $conditional_logic = $this->is_conditional_logic_met( $form, $lead ); 275 276 if ( $order['enable'] && $conditional_logic ){ 277 280 278 $site_url = get_bloginfo( 'url' ); 281 $return_url = $order['return_url'];282 $cancel_url = $order['cancel_url'];283 $site_title = get_bloginfo();284 279 $description = sprintf( '%s %s ($%s)', __( 'Order #', 'wpf-gravityforms' ), $lead['id'], $lead[$order['paymentAmount']] ); 285 280 $button = __( 'Pay with Card', 'wpf-gravityforms' ); 286 287 if ( !$return_url ){288 289 $return_url = $site_url;290 291 }292 293 if ( !$cancel_url ){294 295 $cancel_url = $site_url;296 297 }298 299 if ( $order['site_title'] ) {300 301 $site_title = $order['site_title'];302 303 }304 281 305 282 if ( $order['description'] ) { … … 321 298 'version' => $this->_version, 322 299 'action' => 'charge_card', 323 'site_title' => $ site_title,300 'site_title' => $order['site_title'] ?: get_bloginfo(), 324 301 'site_url' => $site_url, 325 302 'listen_url' => $site_url . '/?wpf-gravityforms=callback', 326 'return_url' => $ return_url,327 'cancel_url' => $ cancel_url,303 'return_url' => $order['return_url'] ?: $site_url, 304 'cancel_url' => $order['cancel_url'] ?: $site_url, 328 305 'image_url' => $order['image_url'], 329 306 'customer_id' => '', … … 334 311 'button' => $button, 335 312 'currency' => $order['currency'], 336 'testmode' => $ testmode,313 'testmode' => $order['testmode'] === '1' ? true : false, 337 314 'capture' => true, 338 315 'metadata' => array( … … 353 330 354 331 GFAPI::update_entry_property( $lead['id'], 'payment_status', 'Pending' ); 355 $url = $order['custom_checkout']; 356 357 if ( !$url ){ 358 359 $url = 'https://checkout.wpfortify.com/'; 360 361 } 362 332 $url = $order['custom_checkout'] ?: 'https://checkout.wpfortify.com/'; 363 333 $check_out = sprintf( '%s/token/%s/', untrailingslashit( $url ), $response->token ); 364 334 … … 458 428 459 429 return $html; 430 460 431 } 461 432 … … 468 439 469 440 return isset( $form[ 'wpf-gravityforms' ]['delayNotification'] ) && in_array( $notification['id'], $selected_notifications ) ? true : $is_disabled; 470 } 441 442 } 443 444 /** 445 * Conditional Logic settings for form 446 */ 447 public function settings_conditional_logic( $field, $echo = true ) { 448 449 $name = 'conditional_logic'; 450 451 $checkbox_field = array( 452 'name' => $name, 453 'type' => 'checkbox', 454 'choices' => array( 455 array( 456 'label' => __( 'Enable Conditional Logic.', 'wpf-gravityforms' ), 457 'name' => $name . '_enabled', 458 ), 459 ), 460 'onclick' => "if(this.checked){jQuery('#{$name}_condition_container').slideDown();} else{jQuery('#{$name}_condition_container').slideUp();}", 461 ); 462 463 $is_enabled = $this->get_setting( $name . '_enabled' ) == '1'; 464 $container_style = ! $is_enabled ? "style='display:none;'" : ''; 465 466 $str = sprintf( "%s<div id='%s_condition_container' %s><br>%s<br>%s</div>", 467 $this->settings_checkbox( $checkbox_field, false ), 468 $name, 469 $container_style, 470 __( 'Submit form to wpFortify if the following match:', 'wpf-gravityforms' ), 471 $this->simple_condition( $name ) 472 ); 473 474 echo $str; 475 476 } 477 478 /** 479 * Get conditional logic fields 480 */ 481 public function get_conditional_logic_fields() { 482 483 $form = $this->get_current_form(); 484 $fields = array(); 485 foreach ( $form['fields'] as $field ) { 486 if ( $field->is_conditional_logic_supported() ) { 487 $inputs = $field->get_entry_inputs(); 488 489 if ( $inputs ) { 490 $choices = array(); 491 492 foreach ( $inputs as $input ) { 493 if ( rgar( $input, 'isHidden' ) ) { 494 continue; 495 } 496 $choices[] = array( 497 'value' => $input['id'], 498 'label' => GFCommon::get_label( $field, $input['id'], true ) 499 ); 500 } 501 502 if ( ! empty( $choices ) ) { 503 $fields[] = array( 'choices' => $choices, 'label' => GFCommon::get_label( $field ) ); 504 } 505 506 } else { 507 $fields[] = array( 'value' => $field->id, 'label' => GFCommon::get_label( $field ) ); 508 } 509 510 } 511 } 512 513 return $fields; 514 515 } 516 517 /** 518 * Check if conditional logic fields match 519 */ 520 public function is_conditional_logic_met( $form, $lead ) { 521 522 $settings = $this->get_form_settings( $form ); 523 524 $name = 'conditional_logic'; 525 $is_enabled = rgar( $settings, $name . '_enabled' ); 526 527 if ( ! $is_enabled ) { 528 // The setting is not enabled so we handle it as if the rules are met. 529 530 return true; 531 } 532 533 // Build the logic array to be used by Gravity Forms when evaluating the rules. 534 $logic = array( 535 'logicType' => 'all', 536 'rules' => array( 537 array( 538 'fieldId' => rgar( $settings, $name . '_field_id' ), 539 'operator' => rgar( $settings, $name . '_operator' ), 540 'value' => rgar( $settings, $name . '_value' ), 541 ), 542 ) 543 ); 544 545 return GFCommon::evaluate_conditional_logic( $logic, $form, $lead ); 546 547 } 548 471 549 472 550 /**
Note: See TracChangeset
for help on using the changeset viewer.