Plugin Directory

Changeset 1897488


Ignore:
Timestamp:
06/23/2018 03:53:51 AM (8 years ago)
Author:
zaus
Message:

v1.7.6: support for form plugin redirection, GET/POST as admin setting

  • version bump, readme updates
  • some example cleanup (minor, didn't make them functional, just removed old php args)
Location:
forms-3rdparty-integration/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • forms-3rdparty-integration/trunk/3rd-parties/mailchimp/functions.mailchimp.php

    r625080 r1897488  
    55#region ------------------------------- CUSTOM FUNCTION CALLS ---------------------------------
    66
    7 if(!class_exists('Cf73rdParty_MailchimpCallbacks')):
     7if(!class_exists('Forms3rdpartyIntegration_MailchimpCallbacks')):
    88/**
    99 * Encapsulate any and all 3rd-party service callback functions
    1010 */
    11 class Cf73rdParty_MailchimpCallbacks {
     11class Forms3rdpartyIntegration_MailchimpCallbacks {
    1212    public function __construct(){
    1313        /** newsletter - mailchimp - subscribe **/
     
    1515        //actions require 2 parameters: 3rd-party response, results placeholders
    1616        ///NOTE: customize this hook name to match your Service (in the admin settings)
    17         add_action('Cf73rdPartyIntegration_service_a5', array(&$this, 'mailchimp_newsletter_action'), 10, 2);
     17        add_action('Forms3rdpartyIntegrationIntegration_service_a5', array(&$this, 'mailchimp_newsletter_action'), 10, 2);
    1818       
    1919    }//--   function __construct
     
    2323     * Callback hook for 3rd-party service Mailchimp - Newsletter signup form
    2424     * @param $response the remote-request response (in this case, it's a serialized string)
    25      * @param &$results the callback return results (passed by reference since function can't return a value; also must be "constructed by reference"; see plugin)
     25     * @param $results the callback return results (kind of passed by reference since function can't return a value; also must be "constructed by reference"; see plugin)
    2626     */
    27     public function mailchimp_newsletter_action($response, &$results){
     27    public function mailchimp_newsletter_action($response, $results){
    2828        try{
    2929            // look once more for success message, in case someone didn't set up the success clause
     
    4343   
    4444
    45 }//---  class Cf73rdParty_MailchimpCallbacks
     45}//---  class Forms3rdpartyIntegration_MailchimpCallbacks
    4646
    4747//start 'em up
    48 $cf73rdpartycallback_instance = new Cf73rdParty_MailchimpCallbacks();
     48$Forms3rdpartyIntegrationcallback_instance = new Forms3rdpartyIntegration_MailchimpCallbacks();
    4949endif;  //class-exists
    5050
  • forms-3rdparty-integration/trunk/3rd-parties/multitouch/functions.multitouch.php

    r625080 r1897488  
    55#region ------------------------------- CUSTOM FUNCTION CALLS ---------------------------------
    66
    7 if(!class_exists('Cf73rdPartyCallbacks')):
     7if(!class_exists('Forms3rdpartyIntegrationCallbacks')):
    88/**
    99 * Encapsulate any and all 3rd-party service callback functions
    1010 */
    11 class Cf73rdPartyCallbacks {
     11class Forms3rdpartyIntegrationCallbacks {
    1212    public function __construct(){
    1313        //actions require 2 parameters: 3rd-party response, results placeholders
    14         add_action('Cf73rdPartyIntegration_service_a0', array(&$this, 'multitouch1'), 10, 2);
     14        add_action('Forms3rdpartyIntegrationIntegration_service_a0', array(&$this, 'multitouch1'), 10, 2);
    1515        //filters require 4 parameters: placeholder, value to filter, field, and service array
    16         add_filter('Cf73rdPartyIntegration_service_filter_post_0', array(&$this, 'multitouch1_filter'), 10, 3);
     16        add_filter('Forms3rdpartyIntegrationIntegration_service_filter_post_0', array(&$this, 'multitouch1_filter'), 10, 3);
    1717    }//--   function __construct
    1818   
     
    2020     * Callback hook for 3rd-party service Multitouch
    2121     * @param $response the remote-request response (in this case, it's a serialized string)
    22      * @param &$results the callback return results (passed by reference since function can't return a value; also must be "constructed by reference"; see plugin)
     22     * @param &$results the callback return results (kind of passed by reference since function can't return a value; also must be "constructed by reference"; see plugin)
    2323     */
    24     public function multitouch1($response, &$results){
     24    public function multitouch1($response, $results){
    2525        try{
    2626            //unserialize results to append to email
     
    107107     * @param $values array of post values
    108108     * @param $service reference to service detail array
    109      * @param $cf7 reference to Contact Form 7 object
     109     * @param $form reference to form object/array
    110110     */
    111     public function multitouch1_filter($values, &$service, &$cf7){
     111    public function multitouch1_filter($values, $service, $form){
    112112        foreach($values as $field => &$value):
    113113        //filter depending on field
     
    129129    }//--   function multitouch1_filter
    130130
    131 }//---  class Cf73rdPartyCallbacks
     131}//---  class Forms3rdpartyIntegrationCallbacks
    132132
    133133//start 'em up
    134 $cf73rdpartycallback_instance = new Cf73rdPartyCallbacks();
     134$Forms3rdpartyIntegrationcallback_instance = new Forms3rdpartyIntegrationCallbacks();
    135135endif;  //class-exists
    136136
  • forms-3rdparty-integration/trunk/README.md

    r1755842 r1897488  
    1313**Requires at least:** 3.0
    1414
    15 **Tested up to:** 4.7.2
     15**Tested up to:** 4.9.6
    1616
    1717**Stable tag:** trunk
     
    105105### How do I make a GET request instead of POST? ###
    106106
     107Since v1.7.6, it's an admin setting for GET and POST, but for anything other than those two that you'd write a hook.
     108
    107109_from http://wordpress.org/support/topic/method-get?replies=2#post-5996489_
    108110
     
    239241
    240242## Changelog ##
     243
     244### 1.7.6 ###
     245* exposing http method (get/post); result redirection
     246
     247### 1.7.5 ###
     248* late-bind GF confirmation for script tags
    241249
    242250### 1.7.4 ###
  • forms-3rdparty-integration/trunk/forms-3rdparty-integration.php

    r1890883 r1897488  
    66Description: Send plugin Forms Submissions (Gravity, CF7, Ninja Forms, etc) to a 3rd-party URL
    77Author: zaus, atlanticbt, spkane
    8 Version: 1.7.5
     8Version: 1.7.6
    99Author URI: http://drzaus.com
    1010Changelog:
     
    3535    1.7.4 - another slight fix to make GF Resend do submission hooks too (so Reformat will work with it as well)
    3636    1.7.5 - late-bind GF confirmation for script tags
     37    1.7.6 - exposing http method (get/post); result redirection
    3738*/
    3839
     
    617618            //@see http://planetozh.com/blog/2009/08/how-to-make-http-requests-with-wordpress/
    618619
    619             $response = wp_remote_post(
    620620            // allow hooks to modify the URL with submission, like send as url-encoded XML, etc
    621                 apply_filters($this->N('service_filter_url'), $service['url'], $post_args),
    622                 $post_args
    623             );
     621            $url = apply_filters($this->N('service_filter_url'), $service['url'], $post_args);
     622
     623            $response = isset($service['method']) && $service['method'] == 'get'
     624                ? wp_remote_get($url, $post_args)
     625                : wp_remote_post($url, $post_args)
     626                ;
    624627        }
    625628
     
    677680            //hack for pass-by-reference
    678681            //holder for callback return results
    679             $callback_results = array('success'=>false, 'errors'=>false, 'attach'=>'', 'message' => '');
     682            $callback_results = array('success'=>false, 'errors'=>false, 'attach'=>'', 'message' => '', 'redirect' => '');
    680683            // TODO: use object?
    681684            $param_ref = array();   foreach($callback_results as $k => &$v){ $param_ref[$k] = &$v; }
  • forms-3rdparty-integration/trunk/plugin-ui.php

    r1517065 r1897488  
    131131                    </div>
    132132                   
     133                    <div class="field">
     134                        <?php
     135                        $methods = apply_filters($this->N('submit_methods'), array(
     136                            'post' => 'Post',
     137                            'get' => 'Get'
     138                        ), $eid, $P, $entity);
     139                        if(empty($entity['method'])) $entity['method'] = 'post';
     140                        foreach($methods as $mkey => $mlabel):
     141                        ?>
     142                        <input id="mthd-<?php echo $mkey, $eid?>" type="radio" class="radio" name="<?php echo $P?>[<?php echo $eid?>][method]" value="<?php echo esc_attr($mkey)?>" <?php checked($entity['method'], $mkey) ?> />
     143                        <label for="mthd-<?php echo $mkey, $eid?>">Submit as <?php _e($mlabel, $P) ?></label>
     144                        <?php endforeach; ?>
     145                        <em class="description"><?php _e('How to submit the request.', $P);?></em>
     146                    </div>
    133147       
    134148                    <div class="field">
  • forms-3rdparty-integration/trunk/plugins/contactform7.php

    r1651476 r1897488  
    142142
    143143    /**
     144     * How to update the confirmation redirect for a successful result
     145     * @param $form the form "object"
     146     * @param $redirect the url to redirect to
     147     * @return $form, altered to contain the message
     148     */
     149    protected function SET_OKAY_REDIRECT($form, $redirect) {
     150        $messages = $form->prop('messages');
     151        $url = esc_url_raw( $redirect );
     152        $messages['mail_sent_ok'] .= "<script type=\"text/javascript\">window.open('$url', '_blank');</script>";
     153        $form->set_properties(array('messages'=>$messages));
     154
     155        return $form;
     156    }
     157
     158
     159    /**
    144160     * Fetch the original error message for the form
    145161     */
  • forms-3rdparty-integration/trunk/plugins/fplugin_base.php

    r1610285 r1897488  
    9494
    9595    /**
     96     * How to update the confirmation redirect for a successful result
     97     * @param $form the form "object"
     98     * @param $redirect the url to redirect to
     99     * @return $form, altered to contain the message
     100     */
     101    abstract protected function SET_OKAY_REDIRECT($form, $redirect);
     102
     103    /**
    96104     * How to update the confirmation message for a failure/error
    97105     * @param $form the form "object"
     
    259267        }
    260268
     269        //if requested, attach redirect to success notification
     270        if( !empty($callback_results['redirect']) ) {
     271            $form = $this->SET_OKAY_REDIRECT($form, $callback_results['redirect']);
     272        }
     273       
    261274        ###_log(__FUNCTION__, $form);
    262275
  • forms-3rdparty-integration/trunk/plugins/gravityforms.php

    r1890883 r1897488  
    202202
    203203    /**
     204     * How to update the confirmation redirect for a successful result
     205     * @param $form the form "object"
     206     * @param $redirect the url to redirect to
     207     * @return $form, altered to contain the message
     208     */
     209    protected function SET_OKAY_REDIRECT($form, $redirect) {
     210        // https://docs.gravityforms.com/gform_confirmation/#4-open-the-page-or-redirect-in-a-new-tab
     211
     212        add_filter( 'gform_confirmation', array(&$this, 'gform_confirmation'), 10, 4 );
     213
     214        return $form;
     215    }
     216
     217    public function gform_confirmation($confirmation, $form, $entry, $ajax) {
     218        if ( isset( $confirmation['redirect'] ) ) {
     219            $url          = esc_url_raw( $redirect );
     220            $confirmation .= "<script type=\"text/javascript\">window.open('$url', '_blank');</script>";
     221        }
     222       
     223        return $confirmation;
     224    }
     225   
     226    /**
    204227     * Fetch the original error message for the form
    205228     */
  • forms-3rdparty-integration/trunk/plugins/ninjaforms.php

    r1624462 r1897488  
    134134
    135135    /**
     136     * How to update the confirmation redirect for a successful result
     137     * @param $form the form "object"
     138     * @param $redirect the url to redirect to
     139     * @return $form, altered to contain the message
     140     */
     141    protected function SET_OKAY_REDIRECT($form, $redirect) {
     142        $setting = 'success_msg';
     143        $message = $form->get_form_setting($setting);
     144        $url = esc_url_raw( $redirect );
     145        $message .= "<script type=\"text/javascript\">window.open('$url', '_blank');</script>";
     146        $form->update_form_setting($setting, wpautop($message));
     147
     148        return $form; // just to match expectation
     149    }
     150
     151
     152    /**
    136153     * How to update the confirmation message for a failure/error
    137154     * @param $form the form "object"
  • forms-3rdparty-integration/trunk/readme.txt

    r1755842 r1897488  
    44Tags: contact form, form, contact form 7, CF7, gravity forms, GF, CRM, mapping, 3rd-party service, services, remote request
    55Requires at least: 3.0
    6 Tested up to: 4.7.2
     6Tested up to: 4.9.6
    77Stable tag: trunk
    88License: GPLv2 or later
     
    9797= How do I make a GET request instead of POST? =
    9898
     99Since v1.7.6, it's an admin setting for GET and POST, but for anything other than those two that you'd write a hook.
     100
    99101_from http://wordpress.org/support/topic/method-get?replies=2#post-5996489_
    100102
     
    233235== Changelog ==
    234236
     237= 1.7.6 =
     238* exposing http method (get/post); result redirection
     239
     240= 1.7.5 =
     241* late-bind GF confirmation for script tags
     242
    235243= 1.7.4 =
    236244* another slight fix to make GF Resend do submission hooks too (so Reformat will work with it as well)
     
    238246= 1.7.3 =
    239247* slight refactor of `before_send` to make reposting GF submissions easier
    240 
    241248
    242249= 1.7.2.1 =
Note: See TracChangeset for help on using the changeset viewer.