|
3 | 3 | * Gravity Wiz // Gravity Forms // Draft Resume Change Notice |
4 | 4 | * https://gravitywiz.com/ |
5 | 5 | * |
6 | | - * Use this snippet to display a notice when the user resumes a draft from a different location, browser or device. |
| 6 | + * Use this snippet to display a notice when the user resumes draft from a different location, browser or device. |
7 | 7 | */ |
8 | 8 | add_filter( 'gform_get_form_filter', function( $form_markup, $form ) { |
9 | 9 |
|
|
14 | 14 |
|
15 | 15 | global $wpdb; |
16 | 16 | $table = GFFormsModel::get_draft_submissions_table_name(); |
| 17 | + |
| 18 | + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
17 | 19 | $draft = $wpdb->get_row( |
18 | 20 | $wpdb->prepare( |
19 | 21 | "SELECT form_id, ip, submission FROM {$table} WHERE uuid = %s", |
|
32 | 34 | $submission_data = json_decode( $draft->submission, true ); |
33 | 35 | $submission_data = is_array( $submission_data ) ? $submission_data : array(); |
34 | 36 |
|
35 | | - $stored_user_agent = $submission_data['partial_entry']['user_agent'] ?? ''; |
| 37 | + $stored_user_agent = $submission_data['partial_entry']['user_agent'] ?? ''; |
36 | 38 | $current_user_agent = $_SERVER['HTTP_USER_AGENT'] ?? ''; |
37 | 39 |
|
38 | | - $stored_ip = $draft->ip ?? ''; |
39 | | - $current_ip = GFFormsModel::get_ip(); |
| 40 | + $stored_ip = $draft->ip ?? ''; |
| 41 | + $current_ip = GFFormsModel::get_ip(); |
40 | 42 |
|
41 | 43 | $ip_changed = ( $stored_ip && $current_ip && $stored_ip !== $current_ip ); |
42 | 44 | $browser_changed = ( $stored_user_agent && $current_user_agent && $stored_user_agent !== $current_user_agent ); |
|
45 | 47 | return $form_markup; |
46 | 48 | } |
47 | 49 |
|
48 | | - // Configure Messages |
49 | | - $ip_changed_message = "🌍 Your location has changed since last editing this draft"; |
50 | | - $browser_changed_message = "💻 Your browser or device has changed since last editing this draft"; |
51 | | - $both_changed_message = "🔒 Your location and device have both changed since last editing this draft"; |
| 50 | + // Configure Messages |
| 51 | + $ip_changed_message = '🌍 Your location has changed since last editing this draft'; |
| 52 | + $browser_changed_message = '💻 Your browser or device has changed since last editing this draft'; |
| 53 | + $both_changed_message = '🔒 Your location AND device have both changed since last editing this draft'; |
52 | 54 |
|
53 | 55 | $message = $both_changed_message; |
54 | 56 | if ( $ip_changed && ! $browser_changed ) { |
|
0 commit comments