Custom Contact Forms - Version 6.0.3

Version Description

  • Make Google library URL protocol agnostic
Download this release

Release Info

Developer tlovett1
Plugin Icon 128x128 Custom Contact Forms
Version 6.0.3
Comparing to
See all releases

Code changes from version 6.0.2 to 6.0.3

classes/class-ccf-api.php CHANGED
@@ -321,6 +321,7 @@ class CCF_API extends WP_JSON_Posts {
321
  public function create_form( $data ) {
322
  unset( $data['ID'] );
323
 
 
324
  if ( isset( $data['author'] ) ) {
325
  unset( $data['author'] );
326
  }
@@ -576,6 +577,7 @@ class CCF_API extends WP_JSON_Posts {
576
  return new WP_Error( 'json_invalid_ccf_form', esc_html__( 'Invalid form.', 'custom-contact-forms' ), array( 'status' => 404 ) );
577
  }
578
 
 
579
  if ( isset( $data['author'] ) ) {
580
  unset( $data['author'] );
581
  }
321
  public function create_form( $data ) {
322
  unset( $data['ID'] );
323
 
324
+ // @todo: remove hack. Needed for broken API
325
  if ( isset( $data['author'] ) ) {
326
  unset( $data['author'] );
327
  }
577
  return new WP_Error( 'json_invalid_ccf_form', esc_html__( 'Invalid form.', 'custom-contact-forms' ), array( 'status' => 404 ) );
578
  }
579
 
580
+ // @todo: remove hack. Needed for broken API
581
  if ( isset( $data['author'] ) ) {
582
  unset( $data['author'] );
583
  }
classes/class-ccf-form-renderer.php CHANGED
@@ -42,7 +42,7 @@ class CCF_Form_Renderer {
42
  $js_path = '/build/css/form.min.js';
43
  }
44
 
45
- wp_enqueue_style('ccf-jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
46
  wp_enqueue_style( 'ccf-form', plugins_url( $css_form_path, dirname( __FILE__ ) ) );
47
 
48
  wp_enqueue_script( 'ccf-form', plugins_url( $js_path, dirname( __FILE__ ) ), array( 'jquery-ui-datepicker', 'underscore' ), '1.1', true );
42
  $js_path = '/build/css/form.min.js';
43
  }
44
 
45
+ wp_enqueue_style('ccf-jquery-ui', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
46
  wp_enqueue_style( 'ccf-form', plugins_url( $css_form_path, dirname( __FILE__ ) ) );
47
 
48
  wp_enqueue_script( 'ccf-form', plugins_url( $js_path, dirname( __FILE__ ) ), array( 'jquery-ui-datepicker', 'underscore' ), '1.1', true );
classes/class-ccf-upgrader.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CCF_Upgrader {
4
+
5
+ public function setup() {
6
+ add_action( 'admin_init', array( $this, 'start_upgrade' ), 100 );
7
+ }
8
+
9
+ public function start_upgrade() {
10
+ global $wpdb;
11
+
12
+ if ( ! empty( $upgraded ) ) {
13
+ return false;
14
+ }
15
+
16
+ $forms = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}customcontactforms_forms" );
17
+
18
+ $upgraded_forms = get_option( 'ccf_upgraded_forms' );
19
+
20
+ if ( empty( $upgraded_forms ) ) {
21
+ $upgraded_forms = array();
22
+ }
23
+
24
+ $type_mapping = array(
25
+ 'Dropdown' => 'dropdown',
26
+ 'Textarea' => 'paragraph_text',
27
+ 'Text' => 'single_line_text',
28
+ 'Checkbox' => 'checkboxes',
29
+ 'Radio' => 'radio',
30
+ 'fixedEmail' => 'email',
31
+ 'fixedWebsite' => 'website',
32
+ 'datePicker' => 'date',
33
+ );
34
+
35
+ foreach ( $forms as $form ) {
36
+ $form_id = wp_insert_post( array(
37
+ 'post_type' => 'ccf_form',
38
+ 'post_title' => $form->form_title,
39
+ 'author' => 1,
40
+ 'post_status' => 'publish',
41
+ ) );
42
+
43
+ if ( is_wp_error( $form_id ) ) {
44
+ continue;
45
+ }
46
+
47
+ update_post_meta( $form_id, 'ccf_old_mapped_id', (int) $form->ID );
48
+
49
+ $success_message = $form->form_success_message;
50
+ $notification_email = $form->form_email;
51
+ $submit_button_text = $form->submit_button_text;
52
+
53
+ update_post_meta( $form_id, 'ccf_form_buttonText', sanitize_text_field( $submit_button_text ) );
54
+ update_post_meta( $form_id, 'ccf_form_email_notification_addresses', sanitize_text_field( $notification_email ) );
55
+ update_post_meta( $form_id, 'ccf_form_completion_message', sanitize_text_field( $success_message ) );
56
+ update_post_meta( $form_id, 'ccf_form_send_email_notifications', ( ! empty( $notification_email ) ) ? true : false );
57
+
58
+ /**
59
+ * Move fields over
60
+ */
61
+
62
+ $fields = unserialize( $form->form_fields );
63
+
64
+ if ( ! empty( $fields ) ) {
65
+ $form_fields = array();
66
+
67
+ foreach( $fields as $field_id ) {
68
+ $field = $wpdb->get_row( sprintf( "SELECT * FROM {$wpdb->prefix}customcontactforms_fields WHERE ID='%d'", (int) $field_id ) );
69
+
70
+ $type = $field->field_type;
71
+
72
+ if ( ! empty( $type_mapping[$type] ) ) {
73
+ $type = $type_mapping[$type];
74
+ } else {
75
+ continue;
76
+ }
77
+
78
+ $field_id = wp_insert_post( array(
79
+ 'post_type' => 'ccf_form',
80
+ 'post_title' => $form->form_title,
81
+ 'post_parent' => $form_id,
82
+ 'post_status' => 'publish',
83
+ ) );
84
+
85
+ if ( ! is_wp_error( $field_id ) ) {
86
+ $form_fields[] = $field_id;
87
+
88
+ $slug = $field->field_slug;
89
+ $label = $field->field_label;
90
+ $required = $field->field_required;
91
+
92
+ update_post_meta( $field_id, 'ccf_field_slug', sanitize_text_field( $slug ) );
93
+ update_post_meta( $field_id, 'ccf_field_label', sanitize_text_field( $label ) );
94
+ update_post_meta( $field_id, 'ccf_field_required', (bool) $required );
95
+ update_post_meta( $field_id, 'ccf_field_type', sanitize_text_field( $type ) );
96
+
97
+ if ( ( 'dropdown' === $type || 'radio' === $type || 'checkboxes' === $type ) && ! empty( $field->field_options ) ) {
98
+
99
+ $choices = unserialize( $field->field_options );
100
+
101
+ foreach ( $choices as $choice_id ) {
102
+ $choice = $wpdb->get_row( sprintf( "SELECT * FROM {$wpdb->prefix}customcontactforms_field_options WHERE ID='%d'", (int) $choice_id ) );
103
+ }
104
+ }
105
+ }
106
+ }
107
+
108
+ update_post_meta( $form_id, 'ccf_attached_fields', $form_fields );
109
+ }
110
+
111
+ /**
112
+ * Move submissions over
113
+ */
114
+
115
+ $submissions = $wpdb->get_results( sprintf( "SELECT * FROM {$wpdb->prefix}customcontactforms_user_data WHERE data_formid = '%d'" , (int) $form->ID ) );
116
+
117
+ foreach ( $submissions as $submission ) {
118
+ $submission_id = wp_insert_post( array(
119
+ 'post_type' => 'ccf_submission',
120
+ 'post_title' => $form->form_title,
121
+ 'post_parent' => $form_id,
122
+ 'post_status' => 'publish',
123
+ 'post_date' => date( 'Y-m-d H:m:s', $submission->data_time ),
124
+ ) );
125
+
126
+ if ( ! is_wp_error( $submission_id ) ) {
127
+ update_post_meta( $submission_id, 'ccf_submission_data', unserialize( $submission->data_value ) );
128
+ }
129
+ }
130
+
131
+ $upgraded_forms[] = (int) $form->ID;
132
+ //update_option( 'ccf_upgraded_forms', $upgraded_forms );
133
+ }
134
+ }
135
+
136
+
137
+ /**
138
+ * Return singleton instance of class
139
+ *
140
+ * @since 6.0
141
+ * @return object
142
+ */
143
+ public static function factory() {
144
+ static $instance;
145
+
146
+ if ( ! $instance ) {
147
+ $instance = new self();
148
+ $instance->setup();
149
+ }
150
+
151
+ return $instance;
152
+ }
153
+ }
custom-contact-forms.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://www.taylorlovett.com
5
  * Description: Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
6
  * Author: Taylor Lovett
7
- * Version: 6.0.2
8
  * Author URI: http://www.taylorlovett.com
9
  */
10
 
4
  * Plugin URI: http://www.taylorlovett.com
5
  * Description: Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
6
  * Author: Taylor Lovett
7
+ * Version: 6.0.3
8
  * Author URI: http://www.taylorlovett.com
9
  */
10
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.taylorlovett.com
4
  Tags: contact form, web form, custom contact form, custom forms, captcha form, contact fields, form mailers, forms
5
  Requires at least: 3.9
6
  Tested up to: 4.1
7
- Stable tag: 6.0.2
8
 
9
  Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
10
 
@@ -34,6 +34,9 @@ For questions, feature requests, and support concerning the Custom Contact Forms
34
 
35
  = Changelog ==
36
 
 
 
 
37
  = 6.0.2 =
38
  * Create forms, fields, choices, and submissions under the proper user.
39
 
4
  Tags: contact form, web form, custom contact form, custom forms, captcha form, contact fields, form mailers, forms
5
  Requires at least: 3.9
6
  Tested up to: 4.1
7
+ Stable tag: 6.0.3
8
 
9
  Build beautiful custom forms the WordPress way. View live previews of your forms while you build them.
10
 
34
 
35
  = Changelog ==
36
 
37
+ = 6.0.3 =
38
+ * Make Google library URL protocol agnostic
39
+
40
  = 6.0.2 =
41
  * Create forms, fields, choices, and submissions under the proper user.
42
 
vendor/wp-api/wp-api/lib/class-wp-json-posts.php CHANGED
@@ -837,8 +837,6 @@ class WP_JSON_Posts {
837
  $post['post_name'] = $data['name'];
838
  }
839
 
840
- var_dump( $data['author']);
841
-
842
  // Author
843
  if ( ! empty( $data['author'] ) ) {
844
  // Allow passing an author object
@@ -851,8 +849,6 @@ class WP_JSON_Posts {
851
  $data['author'] = (int) $data['author'];
852
  }
853
 
854
- var_dump( $data['author']);
855
-
856
  // Only check edit others' posts if we are another user
857
  if ( $data['author'] !== get_current_user_id() ) {
858
  if ( ! json_check_post_permission( $post, 'edit_others_posts' ) ) {
837
  $post['post_name'] = $data['name'];
838
  }
839
 
 
 
840
  // Author
841
  if ( ! empty( $data['author'] ) ) {
842
  // Allow passing an author object
849
  $data['author'] = (int) $data['author'];
850
  }
851
 
 
 
852
  // Only check edit others' posts if we are another user
853
  if ( $data['author'] !== get_current_user_id() ) {
854
  if ( ! json_check_post_permission( $post, 'edit_others_posts' ) ) {