Plugin Directory

Changeset 2256406


Ignore:
Timestamp:
03/07/2020 04:59:28 PM (6 years ago)
Author:
moshensky
Message:

v 2.2.4

Location:
cf7-spreadsheets/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cf7-spreadsheets/trunk/CF7-spreadsheets.php

    r2251215 r2256406  
    44Plugin URI: https://github.com/moshenskyDV/CF7-spreadsheets
    55Description: Send Contact form 7 mail to Google spreadsheets
    6 Version: 2.2.3
     6Version: 2.2.4
    77Author: Moshenskyi Danylo
    88Author URI: https://github.com/moshenskyDV/
     
    1212*/
    1313
    14 /*  Copyright 2016  Moshenskyi Danylo  (email: moshensky[email protected])
     14/*  Copyright 2016  Moshenskyi Danylo  (email: moshensky[email protected])
    1515
    1616    This program is free software; you can redistribute it and/or modify
     
    201201    public function main($cf7)
    202202    {
    203         if ('on' == get_post_meta($cf7->id(), 'CF7spreadsheets_option_enabled', true)) {
     203        if ('on' == get_post_meta($cf7->id, 'CF7spreadsheets_option_enabled', true)) {
    204204            require 'vendor/autoload.php';
    205205
     206            $submission = WPCF7_Submission::get_instance();
     207            $posted_data = $submission->get_posted_data();
    206208            $this->client = new Google_Client();
    207209
     
    220222            try {
    221223                // Set the sheet ID
    222                 $fileId = esc_html(get_post_meta($cf7->id(), 'CF7spreadsheets_option_url', true)); // Copy & paste from a spreadsheet URL
     224                $fileId = esc_html(get_post_meta($cf7->id, 'CF7spreadsheets_option_url', true)); // Copy & paste from a spreadsheet URL
    223225                // Build the CellData array
    224                 $params_names = json_decode(get_post_meta($cf7->id(), 'CF7spreadsheets_output_tags', true));
    225                 $params_types = json_decode(get_post_meta($cf7->id(), 'CF7spreadsheets_output_types', true));
     226                $params_names = json_decode(get_post_meta($cf7->id, 'CF7spreadsheets_output_tags', true));
     227                $params_types = json_decode(get_post_meta($cf7->id, 'CF7spreadsheets_output_types', true));
    226228                $values = [];
    227229                foreach ($params_names as $i => $param) {
    228                     $d = $this->replace_tags($this->exec_shortcodes($param), $cf7->scan_form_tags());
     230                    $d = $this->replace_tags($this->exec_shortcodes($param), $posted_data);
    229231                    $cellData = new Google_Service_Sheets_CellData();
    230232                    $value = new Google_Service_Sheets_ExtendedValue();
     
    252254                // Prepare the request
    253255                $append_request = new Google_Service_Sheets_AppendCellsRequest();
    254                 $append_request->setSheetId(esc_html(get_post_meta($cf7->id(), 'CF7spreadsheets_option_id', true))); //<-----SHEET ID
     256                $append_request->setSheetId(esc_html(get_post_meta($cf7->id, 'CF7spreadsheets_option_id', true))); //<-----SHEET ID
    255257                $append_request->setRows($rowData);
    256258                $append_request->setFields('userEnteredValue');
     
    282284
    283285            /*after google send option skip email needed*/
    284             if ('on' != get_post_meta($cf7->id(), 'CF7spreadsheets_option_mail', true)) {
     286            if ('on' != get_post_meta($cf7->id, 'CF7spreadsheets_option_mail', true)) {
    285287                $cf7->skip_mail = true;
    286288            }
     
    679681    }
    680682
    681     private function replace_tags($string, $request_form_tags)
    682     {
    683         $assoc_request_form_tags = [];
    684         foreach ($request_form_tags as $tag) {
    685             $assoc_request_form_tags[$tag->name] = $tag;
    686         }
     683    private function replace_tags($string, $request_data)
     684    {
    687685        $regexp = '/\[.*\]/U';
    688686        preg_match_all($regexp, $string, $arr);
     
    697695                }
    698696
    699                 if (!empty($_POST[$clear_tag]) || '0' === $_POST[$clear_tag]) {
     697                if (!empty($request_data[$clear_tag]) || '0' === $request_data[$clear_tag]) {
    700698                    /*user tags*/
    701699                    $replace_from[] = '/'.quotemeta($tag).'/';
    702                     if (is_array($_POST[$clear_tag])) {
     700                    if (is_array($request_data[$clear_tag])) {
    703701                        /*multiselect or checkboxes*/
    704                         $replace_to[] = implode(', ', $_POST[$clear_tag]);
     702                        $replace_to[] = implode(', ', $request_data[$clear_tag]);
    705703                    } else {
    706                         // TODO: pipes affects placeholders
    707 //                        if (!empty($assoc_request_form_tags[$clear_tag]->pipes->collect_befores())) {
    708 //                            $index = array_search($_POST[$clear_tag], $assoc_request_form_tags[$clear_tag]->pipes->collect_befores());
    709 //                            $replace_to[] = $assoc_request_form_tags[$clear_tag]->pipes->collect_afters()[$index];
    710 //                        } else {
    711                             $replace_to[] = $_POST[$clear_tag];
    712 //                        }
     704                        $replace_to[] = $request_data[$clear_tag];
    713705                    }
    714706                } elseif ($defined = wpcf7_special_mail_tag(false, $clear_tag, false)) {
  • cf7-spreadsheets/trunk/readme.txt

    r2251215 r2256406  
    44Requires at least: 4.7
    55Tested up to: 5.3.2
    6 Stable tag: 2.2.3
     6Stable tag: 2.2.4
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5959
    6060== Changelog ==
     61
     62= 2.2.4 =
     63
     64* Data source became `WPCF7_Submission` instead of `$_POST` (pipes feature works).
    6165
    6266= 2.2.3 =
Note: See TracChangeset for help on using the changeset viewer.