Plugin Directory

Changeset 2396652


Ignore:
Timestamp:
10/09/2020 12:19:20 PM (5 years ago)
Author:
leadgenerated
Message:

Added fluent forms support

Location:
lead-generated
Files:
21 added
3 edited

Legend:

Unmodified
Added
Removed
  • lead-generated/trunk/includes/class-wsl-divi-api.php

    r2392442 r2396652  
    1515   
    1616    public function __construct($fields) {
     17        $f_fields = $this->get_field_data($fields);
    1718        $data =  array();
    18         foreach($fields as $field){
     19        foreach($f_fields as $field){
    1920           
    2021            $data[] = array(
     
    121122   
    122123    public function set_submission_instance($submission){
    123         $this->submission = $submission;
     124        $form_settings = array();
     125        $set_form = array();
     126        $strip = stripslashes($submission);
     127        $decode_obj = json_decode($strip, true);
     128
     129        // Re-structure Form Settings Array
     130        $form_settings["form_name"] = "Divi Form";
     131        $form_settings["form_fields"] = array();
     132        // Decode Data Object to Follow format Array structure
     133        foreach($decode_obj as $k=>$v){
     134            if($v["field_type"] == 'input'){
     135                $type = "text";
     136            }
     137            if($v["field_type"] == 'text'){
     138                $type = "textarea";
     139            }
     140            // Re-structure Form Settings Array
     141            $set_form[] = array(
     142                "custom_id"     =>$v["original_id"],
     143                "field_label"   =>$v["field_label"],
     144                "placeholder"   =>$v["field_label"],
     145                "field_type"    =>$type,
     146                "required"      =>($v["required_mark"] == "required") ? "true":""
     147            );
     148
     149            $form_settings["form_fields"] = $set_form;
     150        }
     151
     152        $this->submission = $form_settings;
    124153        return $this;
    125154    }
     
    237266        }
    238267    }
     268
     269    public function get_field_data($data_fields){
     270        $fields_form = array();
     271        $strip = stripslashes($data_fields);
     272        $decode_obj = json_decode($strip, true);
     273
     274        // Decode Data Object to Follow format Array structure
     275        foreach($decode_obj as $k=>$v){
     276            if($v["field_type"] == 'input'){
     277                $type = "text";
     278            }
     279            if($v["field_type"] == 'text'){
     280                $type = "textarea";
     281            }
     282
     283            // Re-structure Array Fields
     284            $fields_form[$v["original_id"]] = array(
     285                "id"        =>$v["original_id"],
     286                "type"      =>$type,
     287                "title"     =>$v["field_label"],
     288                "value"     =>$_POST[$v["field_id"]],
     289                "raw_value" =>$_POST[$v["field_id"]],
     290                "required"  =>($v["required_mark"] == "required") ? "1":""
     291            );
     292        }
     293
     294        return $fields_form;
     295    }
    239296   
    240297}
  • lead-generated/trunk/lead-generated.php

    r2392442 r2396652  
    55 * Plugin URI: https://www.leadgenerated.com/
    66 * Description: Save the leads to Lead Generated system generated by various form plugins. We currently support CF7, Ninja Forms, WP Forms, Gravity Forms and Elementor Builder.
    7  * Version: 1.9
     7 * Version: 1.10
    88 * Author: Lead Generated
    99 * Author URI: https://profiles.wordpress.org/leadgenerated/
     
    4141require_once WSL_INCLUDES_DIR . '/class-wsl-elementor-api.php';
    4242require_once WSL_INCLUDES_DIR . '/class-wsl-divi-api.php';
     43require_once WSL_INCLUDES_DIR . '/class-wsl-wpff-api.php';
    4344
    4445if(is_admin()){
     
    142143add_action( 'et_contact_page_email_to', 'wsl_divi' );
    143144
    144 function wsl_divi($contact_email){
    145     $fields = array();
    146     $id_array = array();
    147     $form_settings = array();
    148     $set_form = array();
    149     $form_fields = $_POST["et_pb_contact_email_fields_0"];
    150     $strip = stripslashes($_POST["et_pb_contact_email_fields_0"]);
    151     $decode_obj = json_decode($strip, true);
    152 
    153     $form_settings["form_name"] = "Divi Form";
    154     $form_settings["form_fields"] = array();
    155     foreach($decode_obj as $k=>$v){
    156         if($v["field_type"] == 'input'){
    157             $type = "text";
    158         }
    159         if($v["field_type"] == 'text'){
    160             $type = "textarea";
    161         }
    162    
    163         $fields[$v["original_id"]] = array(
    164             "id"=>$v["original_id"],
    165             "type"=>$type,
    166             "title"=>$v["field_label"],
    167             "value"=>$_POST[$v["field_id"]],
    168             "raw_value"=>$_POST[$v["field_id"]],
    169             "required"=>($v["required_mark"] == "required") ? "1":""
    170         );
    171        
    172         $set_form[] = array(
    173             "custom_id"=>$v["original_id"],
    174             "field_label"=>$v["field_label"],
    175             "placeholder"=>$v["field_label"],
    176             "field_type"=>$type,
    177             "required"=>($v["required_mark"] == "required") ? "true":""
    178         );
    179         $form_settings["form_fields"] = $set_form;
    180     }
    181 
    182     $laravel_api = new Wsl_Divi_Api($fields);
    183     $laravel_api->set_submission_instance($form_settings);
     145function wsl_divi(){
     146    $laravel_api = new Wsl_Divi_Api($_POST["et_pb_contact_email_fields_0"]);
     147    $laravel_api->set_submission_instance($_POST["et_pb_contact_email_fields_0"]);
    184148    $laravel_api->call();
    185149}
     150
     151add_action('fluentform_submission_inserted', 'wsl_fluentforms', 20, 3);
     152
     153function wsl_fluentforms($entryId, $formData, $form)
     154{
     155    $laravel_api = new Wsl_Wpff_Api($form, $formData);
     156    $laravel_api->set_submission_instance($form);
     157    $laravel_api->call();
     158}
  • lead-generated/trunk/readme.txt

    r2392442 r2396652  
    44Requires at least: 2.0
    55Tested up to: 5.2
    6 Stable tag: 1.9
     6Stable tag: 1.10
    77Requires PHP: 5.2.4
    88License: GPLv2 or later
     
    5858= 1.9 =
    5959* Added support for Divi.
     60
     61= 1.10 =
     62* Added fluent forms support
Note: See TracChangeset for help on using the changeset viewer.