Changeset 2256406
- Timestamp:
- 03/07/2020 04:59:28 PM (6 years ago)
- Location:
- cf7-spreadsheets/trunk
- Files:
-
- 2 edited
-
CF7-spreadsheets.php (modified) (8 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cf7-spreadsheets/trunk/CF7-spreadsheets.php
r2251215 r2256406 4 4 Plugin URI: https://github.com/moshenskyDV/CF7-spreadsheets 5 5 Description: Send Contact form 7 mail to Google spreadsheets 6 Version: 2.2. 36 Version: 2.2.4 7 7 Author: Moshenskyi Danylo 8 8 Author URI: https://github.com/moshenskyDV/ … … 12 12 */ 13 13 14 /* Copyright 2016 Moshenskyi Danylo (email: moshensky [email protected])14 /* Copyright 2016 Moshenskyi Danylo (email: moshensky[email protected]) 15 15 16 16 This program is free software; you can redistribute it and/or modify … … 201 201 public function main($cf7) 202 202 { 203 if ('on' == get_post_meta($cf7->id (), 'CF7spreadsheets_option_enabled', true)) {203 if ('on' == get_post_meta($cf7->id, 'CF7spreadsheets_option_enabled', true)) { 204 204 require 'vendor/autoload.php'; 205 205 206 $submission = WPCF7_Submission::get_instance(); 207 $posted_data = $submission->get_posted_data(); 206 208 $this->client = new Google_Client(); 207 209 … … 220 222 try { 221 223 // Set the sheet ID 222 $fileId = esc_html(get_post_meta($cf7->id (), 'CF7spreadsheets_option_url', true)); // Copy & paste from a spreadsheet URL224 $fileId = esc_html(get_post_meta($cf7->id, 'CF7spreadsheets_option_url', true)); // Copy & paste from a spreadsheet URL 223 225 // 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)); 226 228 $values = []; 227 229 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); 229 231 $cellData = new Google_Service_Sheets_CellData(); 230 232 $value = new Google_Service_Sheets_ExtendedValue(); … … 252 254 // Prepare the request 253 255 $append_request = new Google_Service_Sheets_AppendCellsRequest(); 254 $append_request->setSheetId(esc_html(get_post_meta($cf7->id (), 'CF7spreadsheets_option_id', true))); //<-----SHEET ID256 $append_request->setSheetId(esc_html(get_post_meta($cf7->id, 'CF7spreadsheets_option_id', true))); //<-----SHEET ID 255 257 $append_request->setRows($rowData); 256 258 $append_request->setFields('userEnteredValue'); … … 282 284 283 285 /*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)) { 285 287 $cf7->skip_mail = true; 286 288 } … … 679 681 } 680 682 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 { 687 685 $regexp = '/\[.*\]/U'; 688 686 preg_match_all($regexp, $string, $arr); … … 697 695 } 698 696 699 if (!empty($ _POST[$clear_tag]) || '0' === $_POST[$clear_tag]) {697 if (!empty($request_data[$clear_tag]) || '0' === $request_data[$clear_tag]) { 700 698 /*user tags*/ 701 699 $replace_from[] = '/'.quotemeta($tag).'/'; 702 if (is_array($ _POST[$clear_tag])) {700 if (is_array($request_data[$clear_tag])) { 703 701 /*multiselect or checkboxes*/ 704 $replace_to[] = implode(', ', $ _POST[$clear_tag]);702 $replace_to[] = implode(', ', $request_data[$clear_tag]); 705 703 } 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]; 713 705 } 714 706 } elseif ($defined = wpcf7_special_mail_tag(false, $clear_tag, false)) { -
cf7-spreadsheets/trunk/readme.txt
r2251215 r2256406 4 4 Requires at least: 4.7 5 5 Tested up to: 5.3.2 6 Stable tag: 2.2. 36 Stable tag: 2.2.4 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 59 59 60 60 == Changelog == 61 62 = 2.2.4 = 63 64 * Data source became `WPCF7_Submission` instead of `$_POST` (pipes feature works). 61 65 62 66 = 2.2.3 =
Note: See TracChangeset
for help on using the changeset viewer.