Changeset 2947522
- Timestamp:
- 08/04/2023 05:52:51 AM (3 years ago)
- Location:
- wpcf7-redirect/tags/3.0.0/classes
- Files:
-
- 3 edited
-
actions/class-wpcf7r-action-send-to-api.php (modified) (20 diffs)
-
class-wpcf7r-action.php (modified) (1 diff)
-
class-wpcf7r-settings.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wpcf7-redirect/tags/3.0.0/classes/actions/class-wpcf7r-action-send-to-api.php
r2944825 r2947522 43 43 $this->clear_error_log( $this->post->id() ); 44 44 45 // always save last call results for debugging45 // always save last call results for debugging 46 46 $record = $this->get_record( $submission, $tags_map, $record_type, $template ); 47 47 $record['url'] = $base_url; … … 85 85 * @param $submission 86 86 * @param $tags_map 87 * @param string $type88 * @param string $template87 * @param string $type 88 * @param string $template 89 89 */ 90 90 function get_record( $submission, $tags_map, $type = 'params', $template = '' ) { … … 97 97 if ( is_array( $qs_cf7_form_key ) ) { 98 98 99 // arrange checkbox arrays99 // arrange checkbox arrays 100 100 if ( isset( $submited_data[ $form_key ] ) ) { 101 101 $value = apply_filters( 'set_record_value', $submited_data[ $form_key ], $qs_cf7_form_key, $form_key ); … … 106 106 $value = apply_filters( 'set_record_value', $value, $qs_cf7_form_key, $form_key ); 107 107 108 // flattan radio108 // flattan radio 109 109 if ( is_array( $value ) ) { 110 110 $value = reset( $value ); … … 112 112 } 113 113 114 // set defaults114 // set defaults 115 115 116 116 if ( ! $value ) { … … 121 121 foreach ( $this->defaults[ $form_key ] as $key => $sub_value ) { 122 122 if ( isset( $this->functions[ $key ] ) && $this->functions[ $key ] ) { 123 $sub_value = $this->run_function( $this->functions[ $key ], $sub_value , $key);123 $sub_value = $this->run_function( $this->functions[ $key ], $sub_value, $key ); 124 124 } 125 125 … … 141 141 if ( isset( $this->functions[ $form_key ] ) && $this->functions[ $form_key ] ) { 142 142 143 // dont call the function again on arrays (checkvoxes)143 // dont call the function again on arrays (checkvoxes) 144 144 145 145 if ( ! is_array( $this->functions[ $form_key ] ) ) { 146 $value = $this->run_function( $this->functions[ $form_key ], $value , $form_key );146 $value = $this->run_function( $this->functions[ $form_key ], $value, $form_key ); 147 147 } 148 148 } … … 152 152 } 153 153 154 // replace special mail tags154 // replace special mail tags 155 155 156 156 foreach ( WPCF7R_Form::get_special_mail_tags() as $mail_tag ) { … … 159 159 } 160 160 161 // clean unchanged tags161 // clean unchanged tags 162 162 163 163 $template = $this->replace_tags( $template ); … … 188 188 if ( is_array( $qs_cf7_form_key ) ) { 189 189 190 // arrange checkbox arrays190 // arrange checkbox arrays 191 191 foreach ( $submited_data[ $form_key ] as $value ) { 192 192 if ( $value ) { … … 201 201 $value = isset( $submited_data[ $form_key ] ) ? $submited_data[ $form_key ] : ''; 202 202 203 // flattan radio203 // flattan radio 204 204 if ( is_array( $value ) && count( $value ) === 1 ) { 205 205 $value = reset( $value ); … … 223 223 public function set_defaults_and_run_functions( $record, $tags_map ) { 224 224 225 // set default values225 // set default values 226 226 227 227 if ( $this->defaults && array_values( $this->defaults ) ) { … … 234 234 } 235 235 236 // run functions on values236 // run functions on values 237 237 238 238 if ( $this->functions && array_values( $this->functions ) ) { … … 242 242 243 243 if ( $function && $field_value ) { 244 $record['fields'][ $api_key ] = $this->run_function( $function, $field_value , $api_key );244 $record['fields'][ $api_key ] = $this->run_function( $function, $field_value, $api_key ); 245 245 } 246 246 } … … 256 256 * @param $field_value 257 257 */ 258 public function run_function( $function, $field_value , $key ) {258 public function run_function( $function, $field_value, $key ) { 259 259 260 260 $function = WPCF7r_Utils::get_available_text_functions( $function, 'all' ); … … 264 264 $method = $function[1]; 265 265 266 $file_path = $this->get_file_path( $key);267 268 if ( $file_path ){266 $file_path = $this->get_file_path( $key ); 267 268 if ( $file_path ) { 269 269 $field_value = $file_path; 270 270 } 271 // check if this is a file272 273 return call_user_func( array( $class, $method ), $field_value , $key );271 // check if this is a file 272 273 return call_user_func( array( $class, $method ), $field_value, $key ); 274 274 } 275 275 … … 277 277 } 278 278 279 private function get_file_path( $key){280 if ( $this->files ){281 foreach ( $this->files as $file_key => $files ){282 if ( $key == $file_key ){283 return reset( $files);279 private function get_file_path( $key ) { 280 if ( $this->files ) { 281 foreach ( $this->files as $file_key => $files ) { 282 if ( $key == $file_key ) { 283 return reset( $files ); 284 284 } 285 285 } … … 291 291 * @param $record 292 292 * @param boolean $debug 293 * @param string $method294 * @param string $record_type293 * @param string $method 294 * @param string $record_type 295 295 */ 296 296 private function send_lead( $record, $debug = false, $method = 'GET', $record_type = 'params' ) { … … 380 380 $url = apply_filters( 'qs_cf7_api_post_url', $url ); 381 381 $url = $this->replace_tags( $url ); 382 382 383 383 $result = wp_remote_request( $url, $args ); 384 384 } … … 421 421 } 422 422 } 423 -
wpcf7-redirect/tags/3.0.0/classes/class-wpcf7r-action.php
r2944825 r2947522 93 93 private $wpcf7_submission; 94 94 95 /** 96 * Hold the action id. 97 * 98 * @var [int] 99 */ 100 public $action_id; 101 95 102 /** 96 103 * Class constructor -
wpcf7-redirect/tags/3.0.0/classes/class-wpcf7r-settings.php
r2944825 r2947522 25 25 */ 26 26 private $page_slug; 27 28 /** 29 * Fields array. 30 * 31 * @var [type] 32 */ 33 public $fields; 27 34 28 35 public function __construct() {
Note: See TracChangeset
for help on using the changeset viewer.