Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wpforms-.../includes
File: class-process.php
private function get_captcha( $provider ) {
[1000] Fix | Delete
[1001] Fix | Delete
$captcha_providers = $this->get_captcha_providers();
[1002] Fix | Delete
[1003] Fix | Delete
if ( ! isset( $captcha_providers[ $provider ] ) ) {
[1004] Fix | Delete
return [];
[1005] Fix | Delete
}
[1006] Fix | Delete
[1007] Fix | Delete
return $captcha_providers[ $provider ];
[1008] Fix | Delete
}
[1009] Fix | Delete
[1010] Fix | Delete
/**
[1011] Fix | Delete
* Check if combined upload size exceeds allowed maximum.
[1012] Fix | Delete
*
[1013] Fix | Delete
* @since 1.6.0
[1014] Fix | Delete
*
[1015] Fix | Delete
* @param \WP_Post $form Form post object.
[1016] Fix | Delete
*/
[1017] Fix | Delete
public function validate_combined_upload_size( $form ) {
[1018] Fix | Delete
[1019] Fix | Delete
$form_id = (int) $form->ID;
[1020] Fix | Delete
$upload_fields = wpforms_get_form_fields( $form, [ 'file-upload' ] );
[1021] Fix | Delete
[1022] Fix | Delete
if ( ! empty( $upload_fields ) && ! empty( $_FILES ) ) {
[1023] Fix | Delete
[1024] Fix | Delete
// Get $_FILES keys generated by WPForms only.
[1025] Fix | Delete
$files_keys = preg_filter( '/^/', 'wpforms_' . $form_id . '_', array_keys( $upload_fields ) );
[1026] Fix | Delete
[1027] Fix | Delete
// Filter uploads without errors. Individual errors are handled by WPForms_Field_File_Upload class.
[1028] Fix | Delete
$files = wp_list_filter( wp_array_slice_assoc( $_FILES, $files_keys ), [ 'error' => 0 ] );
[1029] Fix | Delete
$files_size = array_sum( wp_list_pluck( $files, 'size' ) );
[1030] Fix | Delete
$files_size_max = wpforms_max_upload( true );
[1031] Fix | Delete
[1032] Fix | Delete
if ( $files_size > $files_size_max ) {
[1033] Fix | Delete
[1034] Fix | Delete
// Add new header error preserving previous ones.
[1035] Fix | Delete
$this->errors[ $form_id ]['header'] = ! empty( $this->errors[ $form_id ]['header'] ) ? $this->errors[ $form_id ]['header'] . '<br>' : '';
[1036] Fix | Delete
$this->errors[ $form_id ]['header'] .= esc_html__( 'Uploaded files combined size exceeds allowed maximum.', 'wpforms-lite' );
[1037] Fix | Delete
}
[1038] Fix | Delete
}
[1039] Fix | Delete
}
[1040] Fix | Delete
[1041] Fix | Delete
/**
[1042] Fix | Delete
* Validate the form return hash.
[1043] Fix | Delete
*
[1044] Fix | Delete
* @since 1.0.0
[1045] Fix | Delete
*
[1046] Fix | Delete
* @param string $hash Base64-encoded hash of form and entry IDs.
[1047] Fix | Delete
*
[1048] Fix | Delete
* @return array|false False for invalid or form id.
[1049] Fix | Delete
*/
[1050] Fix | Delete
public function validate_return_hash( $hash = '' ) {
[1051] Fix | Delete
[1052] Fix | Delete
$query_args = base64_decode( $hash );
[1053] Fix | Delete
[1054] Fix | Delete
parse_str( $query_args, $output );
[1055] Fix | Delete
[1056] Fix | Delete
// Verify hash matches.
[1057] Fix | Delete
if ( wp_hash( $output['form_id'] . ',' . $output['entry_id'] ) !== $output['hash'] ) {
[1058] Fix | Delete
return false;
[1059] Fix | Delete
}
[1060] Fix | Delete
[1061] Fix | Delete
// Get lead and verify it is attached to the form we received with it.
[1062] Fix | Delete
$entry = wpforms()->get( 'entry' )->get( $output['entry_id'], [ 'cap' => false ] );
[1063] Fix | Delete
[1064] Fix | Delete
if ( empty( $entry->form_id ) ) {
[1065] Fix | Delete
return false;
[1066] Fix | Delete
}
[1067] Fix | Delete
[1068] Fix | Delete
if ( $output['form_id'] !== $entry->form_id ) {
[1069] Fix | Delete
return false;
[1070] Fix | Delete
}
[1071] Fix | Delete
[1072] Fix | Delete
return [
[1073] Fix | Delete
'form_id' => absint( $output['form_id'] ),
[1074] Fix | Delete
'entry_id' => absint( $output['form_id'] ),
[1075] Fix | Delete
'fields' => $entry !== null && isset( $entry->fields ) ? $entry->fields : [],
[1076] Fix | Delete
];
[1077] Fix | Delete
}
[1078] Fix | Delete
[1079] Fix | Delete
/**
[1080] Fix | Delete
* Check if the confirmation data are valid.
[1081] Fix | Delete
*
[1082] Fix | Delete
* @since 1.6.4
[1083] Fix | Delete
*
[1084] Fix | Delete
* @param array $data The confirmation data.
[1085] Fix | Delete
*
[1086] Fix | Delete
* @return bool
[1087] Fix | Delete
*/
[1088] Fix | Delete
protected function is_valid_confirmation( $data ) {
[1089] Fix | Delete
[1090] Fix | Delete
if ( empty( $data['type'] ) ) {
[1091] Fix | Delete
return false;
[1092] Fix | Delete
}
[1093] Fix | Delete
[1094] Fix | Delete
// Confirmation type: redirect, page or message.
[1095] Fix | Delete
$type = $data['type'];
[1096] Fix | Delete
[1097] Fix | Delete
return isset( $data[ $type ] ) && ! wpforms_is_empty_string( $data[ $type ] );
[1098] Fix | Delete
}
[1099] Fix | Delete
[1100] Fix | Delete
/**
[1101] Fix | Delete
* Redirect user to a page or URL specified in the form confirmation settings.
[1102] Fix | Delete
*
[1103] Fix | Delete
* @since 1.0.0
[1104] Fix | Delete
*
[1105] Fix | Delete
* @param array $form_data Form data and settings.
[1106] Fix | Delete
* @param string $hash Base64-encoded hash of form and entry IDs.
[1107] Fix | Delete
*/
[1108] Fix | Delete
public function entry_confirmation_redirect( $form_data = [], $hash = '' ) {
[1109] Fix | Delete
[1110] Fix | Delete
// Maybe process return hash.
[1111] Fix | Delete
if ( ! empty( $hash ) ) {
[1112] Fix | Delete
[1113] Fix | Delete
$hash_data = $this->validate_return_hash( $hash );
[1114] Fix | Delete
[1115] Fix | Delete
if ( ! $hash_data || ! is_array( $hash_data ) ) {
[1116] Fix | Delete
return;
[1117] Fix | Delete
}
[1118] Fix | Delete
[1119] Fix | Delete
$this->valid_hash = true;
[1120] Fix | Delete
$this->entry_id = absint( $hash_data['entry_id'] );
[1121] Fix | Delete
$this->fields = json_decode( $hash_data['fields'], true );
[1122] Fix | Delete
$this->form_data = wpforms()->get( 'form' )->get(
[1123] Fix | Delete
absint( $hash_data['form_id'] ),
[1124] Fix | Delete
[
[1125] Fix | Delete
'content_only' => true,
[1126] Fix | Delete
]
[1127] Fix | Delete
);
[1128] Fix | Delete
[1129] Fix | Delete
} else {
[1130] Fix | Delete
[1131] Fix | Delete
$this->form_data = $form_data;
[1132] Fix | Delete
}
[1133] Fix | Delete
[1134] Fix | Delete
// Backward compatibility.
[1135] Fix | Delete
if ( empty( $this->form_data['settings']['confirmations'] ) ) {
[1136] Fix | Delete
$this->form_data['settings']['confirmations'][1]['type'] = ! empty( $this->form_data['settings']['confirmation_type'] ) ? $this->form_data['settings']['confirmation_type'] : 'message';
[1137] Fix | Delete
$this->form_data['settings']['confirmations'][1]['message'] = ! empty( $this->form_data['settings']['confirmation_message'] ) ? $this->form_data['settings']['confirmation_message'] : esc_html__( 'Thanks for contacting us! We will be in touch with you shortly.', 'wpforms-lite' );
[1138] Fix | Delete
$this->form_data['settings']['confirmations'][1]['message_scroll'] = ! empty( $this->form_data['settings']['confirmation_message_scroll'] ) ? $this->form_data['settings']['confirmation_message_scroll'] : 1;
[1139] Fix | Delete
$this->form_data['settings']['confirmations'][1]['page'] = ! empty( $this->form_data['settings']['confirmation_page'] ) ? $this->form_data['settings']['confirmation_page'] : '';
[1140] Fix | Delete
$this->form_data['settings']['confirmations'][1]['redirect'] = ! empty( $this->form_data['settings']['confirmation_redirect'] ) ? $this->form_data['settings']['confirmation_redirect'] : '';
[1141] Fix | Delete
}
[1142] Fix | Delete
[1143] Fix | Delete
if ( empty( $this->form_data['settings']['confirmations'] ) || ! is_array( $this->form_data['settings']['confirmations'] ) ) {
[1144] Fix | Delete
return;
[1145] Fix | Delete
}
[1146] Fix | Delete
[1147] Fix | Delete
$confirmations = $this->form_data['settings']['confirmations'];
[1148] Fix | Delete
[1149] Fix | Delete
// Reverse sort confirmations by id to process newer ones first.
[1150] Fix | Delete
krsort( $confirmations );
[1151] Fix | Delete
[1152] Fix | Delete
$default_confirmation_key = min( array_keys( $confirmations ) );
[1153] Fix | Delete
[1154] Fix | Delete
foreach ( $confirmations as $confirmation_id => $confirmation ) {
[1155] Fix | Delete
// Last confirmation should execute in any case.
[1156] Fix | Delete
if ( $default_confirmation_key === $confirmation_id ) {
[1157] Fix | Delete
break;
[1158] Fix | Delete
}
[1159] Fix | Delete
[1160] Fix | Delete
if ( ! $this->is_valid_confirmation( $confirmation ) ) {
[1161] Fix | Delete
continue;
[1162] Fix | Delete
}
[1163] Fix | Delete
[1164] Fix | Delete
// phpcs:disable WPForms.PHP.ValidateHooks.InvalidHookName
[1165] Fix | Delete
[1166] Fix | Delete
/**
[1167] Fix | Delete
* Process confirmation filter.
[1168] Fix | Delete
*
[1169] Fix | Delete
* @since 1.4.8
[1170] Fix | Delete
*
[1171] Fix | Delete
* @param bool $process Whether to process the logic or not.
[1172] Fix | Delete
* @param array $fields List of submitted fields.
[1173] Fix | Delete
* @param array $form_data Form data and settings.
[1174] Fix | Delete
* @param int $id Confirmation ID.
[1175] Fix | Delete
*/
[1176] Fix | Delete
$process_confirmation = apply_filters( 'wpforms_entry_confirmation_process', true, $this->fields, $this->form_data, $confirmation_id );
[1177] Fix | Delete
// phpcs:enable WPForms.PHP.ValidateHooks.InvalidHookName
[1178] Fix | Delete
[1179] Fix | Delete
if ( $process_confirmation ) {
[1180] Fix | Delete
break;
[1181] Fix | Delete
}
[1182] Fix | Delete
}
[1183] Fix | Delete
[1184] Fix | Delete
$url = '';
[1185] Fix | Delete
// Redirect if needed, to either a page or URL, after form processing.
[1186] Fix | Delete
if ( ! empty( $confirmations[ $confirmation_id ]['type'] ) && 'message' !== $confirmations[ $confirmation_id ]['type'] ) {
[1187] Fix | Delete
[1188] Fix | Delete
if ( $confirmations[ $confirmation_id ]['type'] === 'redirect' ) {
[1189] Fix | Delete
[1190] Fix | Delete
$rawurlencode_callback = static function ( $value ) {
[1191] Fix | Delete
return $value === null ? null : rawurlencode( $value );
[1192] Fix | Delete
};
[1193] Fix | Delete
[1194] Fix | Delete
add_filter( 'wpforms_smarttags_process_field_id_value', $rawurlencode_callback );
[1195] Fix | Delete
[1196] Fix | Delete
$url = wpforms_process_smart_tags( $confirmations[ $confirmation_id ]['redirect'], $this->form_data, $this->fields, $this->entry_id );
[1197] Fix | Delete
[1198] Fix | Delete
remove_filter( 'wpforms_smarttags_process_field_id_value', $rawurlencode_callback );
[1199] Fix | Delete
}
[1200] Fix | Delete
[1201] Fix | Delete
if ( 'page' === $confirmations[ $confirmation_id ]['type'] ) {
[1202] Fix | Delete
$url = get_permalink( (int) $confirmations[ $confirmation_id ]['page'] );
[1203] Fix | Delete
}
[1204] Fix | Delete
}
[1205] Fix | Delete
[1206] Fix | Delete
if ( ! empty( $url ) ) {
[1207] Fix | Delete
$url = apply_filters( 'wpforms_process_redirect_url', $url, $this->form_data['id'], $this->fields, $this->form_data, $this->entry_id );
[1208] Fix | Delete
if ( wpforms_is_amp() ) {
[1209] Fix | Delete
/** This filter is documented in wp-includes/pluggable.php */
[1210] Fix | Delete
$url = apply_filters( 'wp_redirect', $url, 302 );
[1211] Fix | Delete
$url = wp_sanitize_redirect( $url );
[1212] Fix | Delete
header( sprintf( 'AMP-Redirect-To: %s', $url ) );
[1213] Fix | Delete
header( 'Access-Control-Expose-Headers: AMP-Redirect-To', false );
[1214] Fix | Delete
wp_send_json(
[1215] Fix | Delete
[
[1216] Fix | Delete
'message' => __( 'Redirecting…', 'wpforms-lite' ),
[1217] Fix | Delete
'redirecting' => true,
[1218] Fix | Delete
],
[1219] Fix | Delete
200
[1220] Fix | Delete
);
[1221] Fix | Delete
} else {
[1222] Fix | Delete
wp_redirect( esc_url_raw( $url ) ); // phpcs:ignore
[1223] Fix | Delete
}
[1224] Fix | Delete
do_action( 'wpforms_process_redirect', $this->form_data['id'] );
[1225] Fix | Delete
do_action( "wpforms_process_redirect_{$this->form_data['id']}", $this->form_data['id'] );
[1226] Fix | Delete
exit;
[1227] Fix | Delete
}
[1228] Fix | Delete
[1229] Fix | Delete
// Pass a message to a frontend if no redirection happened.
[1230] Fix | Delete
if ( ! empty( $confirmations[ $confirmation_id ]['type'] ) && 'message' === $confirmations[ $confirmation_id ]['type'] ) {
[1231] Fix | Delete
$this->confirmation = $confirmations[ $confirmation_id ];
[1232] Fix | Delete
$this->confirmation_message = $confirmations[ $confirmation_id ]['message'];
[1233] Fix | Delete
[1234] Fix | Delete
if ( ! empty( $confirmations[ $confirmation_id ]['message_scroll'] ) ) {
[1235] Fix | Delete
wpforms()->get( 'frontend' )->confirmation_message_scroll = true;
[1236] Fix | Delete
}
[1237] Fix | Delete
}
[1238] Fix | Delete
}
[1239] Fix | Delete
[1240] Fix | Delete
/**
[1241] Fix | Delete
* Get confirmation message.
[1242] Fix | Delete
*
[1243] Fix | Delete
* @since 1.5.3
[1244] Fix | Delete
*
[1245] Fix | Delete
* @param array $form_data Form data and settings.
[1246] Fix | Delete
* @param array $fields Sanitized field data.
[1247] Fix | Delete
* @param int $entry_id Entry id.
[1248] Fix | Delete
*
[1249] Fix | Delete
* @return string Confirmation message.
[1250] Fix | Delete
*/
[1251] Fix | Delete
public function get_confirmation_message( $form_data, $fields, $entry_id ) {
[1252] Fix | Delete
[1253] Fix | Delete
if ( empty( $this->confirmation_message ) ) {
[1254] Fix | Delete
return '';
[1255] Fix | Delete
}
[1256] Fix | Delete
[1257] Fix | Delete
$confirmation_message = wpforms_process_smart_tags( $this->confirmation_message, $form_data, $fields, $entry_id, 'confirmation' );
[1258] Fix | Delete
$confirmation_message = apply_filters( 'wpforms_frontend_confirmation_message', wpautop( $confirmation_message ), $form_data, $fields, $entry_id );
[1259] Fix | Delete
[1260] Fix | Delete
return $confirmation_message;
[1261] Fix | Delete
}
[1262] Fix | Delete
[1263] Fix | Delete
/**
[1264] Fix | Delete
* Get current confirmation.
[1265] Fix | Delete
*
[1266] Fix | Delete
* @since 1.6.9
[1267] Fix | Delete
*
[1268] Fix | Delete
* @return array
[1269] Fix | Delete
*/
[1270] Fix | Delete
public function get_current_confirmation() {
[1271] Fix | Delete
[1272] Fix | Delete
return ! empty( $this->confirmation ) ? $this->confirmation : [];
[1273] Fix | Delete
}
[1274] Fix | Delete
[1275] Fix | Delete
/**
[1276] Fix | Delete
* Catch the post_max_size overflow.
[1277] Fix | Delete
*
[1278] Fix | Delete
* @since 1.5.2
[1279] Fix | Delete
*
[1280] Fix | Delete
* @return bool
[1281] Fix | Delete
*/
[1282] Fix | Delete
public function post_max_size_overflow() {
[1283] Fix | Delete
[1284] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification
[1285] Fix | Delete
if ( empty( $_SERVER['CONTENT_LENGTH'] ) || empty( $_GET['wpforms_form_id'] ) ) {
[1286] Fix | Delete
return false;
[1287] Fix | Delete
}
[1288] Fix | Delete
[1289] Fix | Delete
$form_id = (int) $_GET['wpforms_form_id'];
[1290] Fix | Delete
$total_size = (int) $_SERVER['CONTENT_LENGTH'];
[1291] Fix | Delete
$post_max_size = wpforms_size_to_bytes( ini_get( 'post_max_size' ) );
[1292] Fix | Delete
[1293] Fix | Delete
if ( ! ( $total_size > $post_max_size && empty( $_POST ) && $form_id > 0 ) ) {
[1294] Fix | Delete
return false;
[1295] Fix | Delete
}
[1296] Fix | Delete
// phpcs:enable WordPress.Security.NonceVerification
[1297] Fix | Delete
[1298] Fix | Delete
$error_msg = esc_html__( 'Form has not been submitted, please see the errors below.', 'wpforms-lite' );
[1299] Fix | Delete
$error_msg .= '<br>' . sprintf( /* translators: %1$.3f - total size of the selected files in megabytes, %2$.3f - allowed file upload limit in megabytes.*/
[1300] Fix | Delete
esc_html__( 'The total size of the selected files %1$.3f MB exceeds the allowed limit %2$.3f MB.', 'wpforms-lite' ),
[1301] Fix | Delete
esc_html( $total_size / 1048576 ),
[1302] Fix | Delete
esc_html( $post_max_size / 1048576 )
[1303] Fix | Delete
);
[1304] Fix | Delete
[1305] Fix | Delete
$this->errors[ $form_id ]['header'] = $error_msg;
[1306] Fix | Delete
[1307] Fix | Delete
return true;
[1308] Fix | Delete
}
[1309] Fix | Delete
[1310] Fix | Delete
/**
[1311] Fix | Delete
* Send entry email notifications.
[1312] Fix | Delete
*
[1313] Fix | Delete
* @since 1.0.0
[1314] Fix | Delete
*
[1315] Fix | Delete
* @param array $fields List of fields.
[1316] Fix | Delete
* @param array $entry Submitted form entry.
[1317] Fix | Delete
* @param array $form_data Form data and settings.
[1318] Fix | Delete
* @param int $entry_id Saved entry id.
[1319] Fix | Delete
* @param string $context In which context this email is sent.
[1320] Fix | Delete
*/
[1321] Fix | Delete
public function entry_email( $fields, $entry, $form_data, $entry_id, $context = '' ) {
[1322] Fix | Delete
[1323] Fix | Delete
// Check that the form was configured for email notifications.
[1324] Fix | Delete
if ( empty( $form_data['settings']['notification_enable'] ) ) {
[1325] Fix | Delete
return;
[1326] Fix | Delete
}
[1327] Fix | Delete
[1328] Fix | Delete
/**
[1329] Fix | Delete
* Allow entry email notifications to be disabled.
[1330] Fix | Delete
*
[1331] Fix | Delete
* @since 1.0.0
[1332] Fix | Delete
*
[1333] Fix | Delete
* @param bool $enabled Whether to send the email.
[1334] Fix | Delete
* @param array $fields List of fields.
[1335] Fix | Delete
* @param array $entry Form submission raw data.
[1336] Fix | Delete
* @param array $form_data Form data and settings.
[1337] Fix | Delete
*/
[1338] Fix | Delete
if ( ! apply_filters( 'wpforms_entry_email', true, $fields, $entry, $form_data ) ) { // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
[1339] Fix | Delete
return;
[1340] Fix | Delete
}
[1341] Fix | Delete
[1342] Fix | Delete
// Make sure we have and entry id.
[1343] Fix | Delete
if ( empty( $this->entry_id ) ) {
[1344] Fix | Delete
$this->entry_id = (int) $entry_id;
[1345] Fix | Delete
}
[1346] Fix | Delete
[1347] Fix | Delete
/**
[1348] Fix | Delete
* Filter entry email notifications data.
[1349] Fix | Delete
*
[1350] Fix | Delete
* @since 1.0.0
[1351] Fix | Delete
*
[1352] Fix | Delete
* @param array $fields List of fields.
[1353] Fix | Delete
* @param array $entry Form submission raw data.
[1354] Fix | Delete
* @param array $form_data Form data and settings.
[1355] Fix | Delete
*/
[1356] Fix | Delete
$fields = apply_filters( 'wpforms_entry_email_data', $fields, $entry, $form_data ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
[1357] Fix | Delete
[1358] Fix | Delete
// Backwards compatibility for notifications before v1.4.3.
[1359] Fix | Delete
if ( empty( $form_data['settings']['notifications'] ) && ! empty( $form_data['settings']['notification_email'] ) ) {
[1360] Fix | Delete
$notifications[1] = [
[1361] Fix | Delete
'email' => $form_data['settings']['notification_email'],
[1362] Fix | Delete
'subject' => $form_data['settings']['notification_subject'],
[1363] Fix | Delete
'sender_name' => $form_data['settings']['notification_fromname'],
[1364] Fix | Delete
'sender_address' => $form_data['settings']['notification_fromaddress'],
[1365] Fix | Delete
'replyto' => $form_data['settings']['notification_replyto'],
[1366] Fix | Delete
'message' => '{all_fields}',
[1367] Fix | Delete
];
[1368] Fix | Delete
} else {
[1369] Fix | Delete
$notifications = $form_data['settings']['notifications'];
[1370] Fix | Delete
}
[1371] Fix | Delete
[1372] Fix | Delete
foreach ( $notifications as $notification_id => $notification ) :
[1373] Fix | Delete
[1374] Fix | Delete
if ( empty( $notification['email'] ) ) {
[1375] Fix | Delete
continue;
[1376] Fix | Delete
}
[1377] Fix | Delete
[1378] Fix | Delete
/**
[1379] Fix | Delete
* Allow entry email notifications to be disabled for a specific notification.
[1380] Fix | Delete
*
[1381] Fix | Delete
* @since 1.0.0
[1382] Fix | Delete
*
[1383] Fix | Delete
* @param bool $enabled Whether to send the email.
[1384] Fix | Delete
* @param array $fields List of fields.
[1385] Fix | Delete
* @param array $form_data Form data and settings.
[1386] Fix | Delete
* @param int $notification_id Notification ID.
[1387] Fix | Delete
* @param string $context In which context this email is sent.
[1388] Fix | Delete
*/
[1389] Fix | Delete
$process_email = apply_filters( 'wpforms_entry_email_process', true, $fields, $form_data, $notification_id, $context );
[1390] Fix | Delete
[1391] Fix | Delete
if ( ! $process_email ) {
[1392] Fix | Delete
continue;
[1393] Fix | Delete
}
[1394] Fix | Delete
[1395] Fix | Delete
$email = [];
[1396] Fix | Delete
$is_carboncopy_enabled = wpforms_setting( 'email-carbon-copy', false );
[1397] Fix | Delete
[1398] Fix | Delete
// Setup email properties.
[1399] Fix | Delete
$email['subject'] = ! empty( $notification['subject'] ) ?
[1400] Fix | Delete
$notification['subject'] :
[1401] Fix | Delete
sprintf( /* translators: %s - form name. */
[1402] Fix | Delete
esc_html__( 'New %s Entry', 'wpforms-lite' ),
[1403] Fix | Delete
$form_data['settings']['form_title']
[1404] Fix | Delete
);
[1405] Fix | Delete
$email['address'] = explode( ',', wpforms_process_smart_tags( $notification['email'], $form_data, $fields, $this->entry_id, 'notification-send-to-email' ) );
[1406] Fix | Delete
$email['address'] = array_filter( array_map( 'sanitize_email', $email['address'] ) );
[1407] Fix | Delete
$email['sender_address'] = ! empty( $notification['sender_address'] ) ? $notification['sender_address'] : get_option( 'admin_email' );
[1408] Fix | Delete
$email['sender_name'] = ! empty( $notification['sender_name'] ) ? $notification['sender_name'] : get_bloginfo( 'name' );
[1409] Fix | Delete
$email['replyto'] = ! empty( $notification['replyto'] ) ? $notification['replyto'] : false;
[1410] Fix | Delete
$email['message'] = ! empty( $notification['message'] ) ? $notification['message'] : '{all_fields}';
[1411] Fix | Delete
$email['template'] = ! empty( $notification['template'] ) ? $notification['template'] : '';
[1412] Fix | Delete
[1413] Fix | Delete
if ( $is_carboncopy_enabled && ! empty( $notification['carboncopy'] ) ) {
[1414] Fix | Delete
$email['carboncopy'] = explode( ',', wpforms_process_smart_tags( $notification['carboncopy'], $form_data, $fields, $this->entry_id, 'notification-carboncopy' ) );
[1415] Fix | Delete
$email['carboncopy'] = array_filter( array_map( 'sanitize_email', $email['carboncopy'] ) );
[1416] Fix | Delete
}
[1417] Fix | Delete
[1418] Fix | Delete
/**
[1419] Fix | Delete
* Filter entry email notifications attributes.
[1420] Fix | Delete
*
[1421] Fix | Delete
* @since 1.0.0
[1422] Fix | Delete
*
[1423] Fix | Delete
* @param array $email Email attributes.
[1424] Fix | Delete
* @param array $fields List of fields.
[1425] Fix | Delete
* @param array $entry Form submission raw data.
[1426] Fix | Delete
* @param array $form_data Form data and settings.
[1427] Fix | Delete
* @param int $notification_id Notification ID.
[1428] Fix | Delete
*/
[1429] Fix | Delete
$email = apply_filters( 'wpforms_entry_email_atts', $email, $fields, $entry, $form_data, $notification_id ); // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
[1430] Fix | Delete
[1431] Fix | Delete
// Create new email.
[1432] Fix | Delete
$emails = ( new WPForms\Emails\Notifications() )->init( $email['template'] );
[1433] Fix | Delete
[1434] Fix | Delete
$emails->__set( 'form_data', $form_data );
[1435] Fix | Delete
$emails->__set( 'fields', $fields );
[1436] Fix | Delete
$emails->__set( 'notification_id', $notification_id );
[1437] Fix | Delete
$emails->__set( 'entry_id', $this->entry_id );
[1438] Fix | Delete
$emails->__set( 'from_name', $email['sender_name'] );
[1439] Fix | Delete
$emails->__set( 'from_address', $email['sender_address'] );
[1440] Fix | Delete
$emails->__set( 'reply_to', $email['replyto'] );
[1441] Fix | Delete
[1442] Fix | Delete
// Maybe include CC.
[1443] Fix | Delete
if ( $is_carboncopy_enabled && ! empty( $email['carboncopy'] ) ) {
[1444] Fix | Delete
$emails->__set( 'cc', $email['carboncopy'] );
[1445] Fix | Delete
}
[1446] Fix | Delete
[1447] Fix | Delete
/**
[1448] Fix | Delete
* Filter entry email notifications before sending.
[1449] Fix | Delete
*
[1450] Fix | Delete
* @since 1.0.0
[1451] Fix | Delete
*
[1452] Fix | Delete
* @param object $emails WPForms_WP_Emails instance.
[1453] Fix | Delete
*/
[1454] Fix | Delete
$emails = apply_filters( 'wpforms_entry_email_before_send', $emails );
[1455] Fix | Delete
[1456] Fix | Delete
// Go.
[1457] Fix | Delete
foreach ( $email['address'] as $address ) {
[1458] Fix | Delete
$emails->send( trim( $address ), $email['subject'], $email['message'] );
[1459] Fix | Delete
}
[1460] Fix | Delete
endforeach;
[1461] Fix | Delete
}
[1462] Fix | Delete
[1463] Fix | Delete
/**
[1464] Fix | Delete
* Save entry to database.
[1465] Fix | Delete
*
[1466] Fix | Delete
* @since 1.0.0
[1467] Fix | Delete
*
[1468] Fix | Delete
* @param array $fields List of form fields.
[1469] Fix | Delete
* @param array $entry User submitted data.
[1470] Fix | Delete
* @param int $form_id Form ID.
[1471] Fix | Delete
* @param array $form_data Prepared form settings.
[1472] Fix | Delete
*
[1473] Fix | Delete
* @return int
[1474] Fix | Delete
*/
[1475] Fix | Delete
public function entry_save( $fields, $entry, $form_id, $form_data = [] ) {
[1476] Fix | Delete
[1477] Fix | Delete
$fields = $this->remove_raw_data_before_save( $fields );
[1478] Fix | Delete
[1479] Fix | Delete
/**
[1480] Fix | Delete
* Fires on entry save.
[1481] Fix | Delete
*
[1482] Fix | Delete
* @since 1.0.0
[1483] Fix | Delete
*
[1484] Fix | Delete
* @param array $fields List of form fields.
[1485] Fix | Delete
* @param array $entry Form submission raw data.
[1486] Fix | Delete
* @param int $form_id Form ID.
[1487] Fix | Delete
* @param array $form_data Prepared form settings.
[1488] Fix | Delete
*/
[1489] Fix | Delete
do_action( 'wpforms_process_entry_save', $fields, $entry, $form_id, $form_data );
[1490] Fix | Delete
[1491] Fix | Delete
return $this->entry_id;
[1492] Fix | Delete
}
[1493] Fix | Delete
[1494] Fix | Delete
/**
[1495] Fix | Delete
* Remove raw data from fields before saving.
[1496] Fix | Delete
* This is needed to prevent raw password data from being saved to the database.
[1497] Fix | Delete
*
[1498] Fix | Delete
* @since 1.8.6
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function