Custom Post Types and Custom Fields creator – WCK - Version 1.2.9

Version Description

  • Added Lables field in Custom Fields Creator next to Options for checkboxes, selects and radios
Download this release

Release Info

Developer madalin.ungureanu
Plugin Icon 128x128 Custom Post Types and Custom Fields creator – WCK
Version 1.2.9
Comparing to
See all releases

Code changes from version 1.2.8 to 1.2.9

css/wck-cfc.css CHANGED
@@ -1,15 +1,32 @@
1
- #wck_cfc_fields .row-options, #wck_cfc_fields .row-phone-format, #wck_cfc_fields .row-html-content, #wck_cfc_fields .row-attach-upload-to-post, #wck_cfc_fields .row-cpt, #wck_cfc_fields .row-number-of-rows, #wck_cfc_fields .row-readonly, #wck_cfc_fields .row-default-text{
 
 
 
 
 
 
 
 
 
 
 
 
2
  display:none;
3
  }
4
 
5
  #container_wck_cfc_fields .row-options,
6
- #container_wck_cfc_fields .row-attach-upload-to-post,
 
7
  #container_wck_cfc_fields .row-cpt,
8
  #container_wck_cfc_fields .row-number-of-rows,
9
- #container_wck_cfc_fields .row-readonly,
10
- #container_wck_cfc_fields .row-default-text,
11
  #container_wck_cfc_fields .row-html-content,
12
- #container_wck_cfc_fields .row-phone-format{
 
 
 
 
 
 
13
  display:none;
14
  }
15
 
@@ -28,12 +45,19 @@
28
  #container_wck_cfc_fields .element_type_phone .row-phone-format,
29
  #container_wck_cfc_fields .element_type_cpt-select .row-cpt,
30
  #container_wck_cfc_fields .element_type_checkbox .row-options,
 
31
  #container_wck_cfc_fields .element_type_select .row-options,
 
32
  #container_wck_cfc_fields .element_type_radio .row-options,
 
33
  #container_wck_cfc_fields .element_type_upload .row-attach-upload-to-post,
34
  #container_wck_cfc_fields .element_type_textarea .row-number-of-rows,
35
  #container_wck_cfc_fields .element_type_textarea .row-readonly,
36
- #container_wck_cfc_fields .element_type_textarea .row-default-text{
 
 
 
 
37
  display:block;
38
  }
39
 
1
+ #wck_cfc_fields .row-options,
2
+ #wck_cfc_fields .row-labels,
3
+ #wck_cfc_fields .row-phone-format,
4
+ #wck_cfc_fields .row-attach-upload-to-post,
5
+ #wck_cfc_fields .row-cpt,
6
+ #wck_cfc_fields .row-number-of-rows,
7
+ #wck_cfc_fields .row-readonly,
8
+ #wck_cfc_fields .row-html-content,
9
+ #wck_cfc_fields .row-default-text,
10
+ #wck_cfc_fields .row-map-default-latitude,
11
+ #wck_cfc_fields .row-map-default-longitude,
12
+ #wck_cfc_fields .row-map-default-zoom,
13
+ #wck_cfc_fields .row-map-height {
14
  display:none;
15
  }
16
 
17
  #container_wck_cfc_fields .row-options,
18
+ #container_wck_cfc_fields .row-labels,
19
+ #container_wck_cfc_fields .row-attach-upload-to-post,
20
  #container_wck_cfc_fields .row-cpt,
21
  #container_wck_cfc_fields .row-number-of-rows,
 
 
22
  #container_wck_cfc_fields .row-html-content,
23
+ #container_wck_cfc_fields .row-default-text,
24
+ #container_wck_cfc_fields .row-phone-format,
25
+ #container_wck_cfc_fields .row-readonly,
26
+ #container_wck_cfc_fields .row-map-default-latitude,
27
+ #container_wck_cfc_fields .row-map-default-longitude,
28
+ #container_wck_cfc_fields .row-map-default-zoom,
29
+ #container_wck_cfc_fields .row-map-height {
30
  display:none;
31
  }
32
 
45
  #container_wck_cfc_fields .element_type_phone .row-phone-format,
46
  #container_wck_cfc_fields .element_type_cpt-select .row-cpt,
47
  #container_wck_cfc_fields .element_type_checkbox .row-options,
48
+ #container_wck_cfc_fields .element_type_checkbox .row-labels,
49
  #container_wck_cfc_fields .element_type_select .row-options,
50
+ #container_wck_cfc_fields .element_type_select .row-labels,
51
  #container_wck_cfc_fields .element_type_radio .row-options,
52
+ #container_wck_cfc_fields .element_type_radio .row-labels,
53
  #container_wck_cfc_fields .element_type_upload .row-attach-upload-to-post,
54
  #container_wck_cfc_fields .element_type_textarea .row-number-of-rows,
55
  #container_wck_cfc_fields .element_type_textarea .row-readonly,
56
+ #container_wck_cfc_fields .element_type_textarea .row-default-text,
57
+ #container_wck_cfc_fields .element_type_map .row-map-default-latitude,
58
+ #container_wck_cfc_fields .element_type_map .row-map-default-longitude,
59
+ #container_wck_cfc_fields .element_type_map .row-map-default-zoom,
60
+ #container_wck_cfc_fields .element_type_map .row-map-height {
61
  display:block;
62
  }
63
 
js/wck-cfc.js CHANGED
@@ -1,12 +1,14 @@
1
  jQuery(function(){
2
  jQuery(document).on( 'change', '#wck_cfc_fields #field-type', function () {
3
  value = jQuery(this).val();
4
-
5
  if( value == 'select' || value == 'checkbox' || value == 'radio' ){
6
  jQuery( '#wck_cfc_fields .row-options' ).show();
 
7
  }
8
  else{
9
  jQuery( '#wck_cfc_fields .row-options' ).hide();
 
10
  }
11
 
12
  if( value == 'upload' ){
@@ -60,15 +62,31 @@ jQuery(function(){
60
  jQuery( '#wck_cfc_fields .row-html-content' ).hide();
61
  }
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  });
64
 
65
  jQuery(document).on( 'change', '#container_wck_cfc_fields #field-type', function () {
66
  value = jQuery(this).val();
67
  if( value == 'select' || value == 'checkbox' || value == 'radio' ){
68
  jQuery(this).parent().parent().parent().children(".row-options").show();
 
69
  }
70
  else{
71
  jQuery(this).parent().parent().parent().children(".row-options").hide();
 
72
  }
73
 
74
  if( value == 'upload' ){
@@ -122,5 +140,19 @@ jQuery(function(){
122
  jQuery( this ).parent().parent().parent().children( ".row-html-content" ).hide();
123
  }
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  });
126
  });
1
  jQuery(function(){
2
  jQuery(document).on( 'change', '#wck_cfc_fields #field-type', function () {
3
  value = jQuery(this).val();
4
+
5
  if( value == 'select' || value == 'checkbox' || value == 'radio' ){
6
  jQuery( '#wck_cfc_fields .row-options' ).show();
7
+ jQuery( '#wck_cfc_fields .row-labels' ).show();
8
  }
9
  else{
10
  jQuery( '#wck_cfc_fields .row-options' ).hide();
11
+ jQuery( '#wck_cfc_fields .row-labels' ).hide();
12
  }
13
 
14
  if( value == 'upload' ){
62
  jQuery( '#wck_cfc_fields .row-html-content' ).hide();
63
  }
64
 
65
+ if( value == 'map' ) {
66
+ jQuery( '#wck_cfc_fields .row-map-default-latitude' ).show();
67
+ jQuery( '#wck_cfc_fields .row-map-default-longitude' ).show();
68
+ jQuery( '#wck_cfc_fields .row-map-default-zoom' ).show();
69
+ jQuery( '#wck_cfc_fields .row-map-height' ).show();
70
+ jQuery( '#wck_cfc_fields .row-default-value' ).hide();
71
+ } else {
72
+ jQuery( '#wck_cfc_fields .row-map-default-latitude' ).hide();
73
+ jQuery( '#wck_cfc_fields .row-map-default-longitude' ).hide();
74
+ jQuery( '#wck_cfc_fields .row-map-default-zoom' ).hide();
75
+ jQuery( '#wck_cfc_fields .row-map-height' ).hide();
76
+ jQuery( '#wck_cfc_fields .row-default-value' ).show();
77
+ }
78
+
79
  });
80
 
81
  jQuery(document).on( 'change', '#container_wck_cfc_fields #field-type', function () {
82
  value = jQuery(this).val();
83
  if( value == 'select' || value == 'checkbox' || value == 'radio' ){
84
  jQuery(this).parent().parent().parent().children(".row-options").show();
85
+ jQuery(this).parent().parent().parent().children(".row-labels").show();
86
  }
87
  else{
88
  jQuery(this).parent().parent().parent().children(".row-options").hide();
89
+ jQuery(this).parent().parent().parent().children(".row-labels").hide();
90
  }
91
 
92
  if( value == 'upload' ){
140
  jQuery( this ).parent().parent().parent().children( ".row-html-content" ).hide();
141
  }
142
 
143
+ if( value == 'map' ) {
144
+ jQuery( this ).parent().parent().parent().children( '.row-map-default-latitude' ).show();
145
+ jQuery( this ).parent().parent().parent().children( '.row-map-default-longitude' ).show();
146
+ jQuery( this ).parent().parent().parent().children( '.row-map-default-zoom' ).show();
147
+ jQuery( this ).parent().parent().parent().children( '.row-map-height' ).show();
148
+ jQuery( this ).parent().parent().parent().children( '.row-default-value' ).hide();
149
+ } else {
150
+ jQuery( this ).parent().parent().parent().children( '.row-map-default-latitude' ).hide();
151
+ jQuery( this ).parent().parent().parent().children( '.row-map-default-longitude' ).hide();
152
+ jQuery( this ).parent().parent().parent().children( '.row-map-default-zoom' ).hide();
153
+ jQuery( this ).parent().parent().parent().children( '.row-map-height' ).hide();
154
+ jQuery( this ).parent().parent().parent().children( '.row-default-value' ).show();
155
+ }
156
+
157
  });
158
  });
readme.txt CHANGED
@@ -5,8 +5,8 @@ Donate link: http://www.cozmoslabs.com/wordpress-creation-kit/
5
  Tags: custom fields, custom field, wordpress custom fields, custom post type, custom post types, repeater fields, meta box, metabox, custom taxonomy, custom fields creator, post meta
6
 
7
  Requires at least: 3.1
8
- Tested up to: 4.5.2
9
- Stable tag: 1.2.8
10
 
11
  A must have tool for creating custom fields, custom post types and taxonomies, fast and without any programming knowledge.
12
 
@@ -143,6 +143,9 @@ Creating a taxonomy generally automatically creates a special query variable usi
143
  10. Taxonomy listing
144
 
145
  == Changelog ==
 
 
 
146
  = 1.2.8 =
147
  * Added Phone field type
148
  * Added HTML field type
5
  Tags: custom fields, custom field, wordpress custom fields, custom post type, custom post types, repeater fields, meta box, metabox, custom taxonomy, custom fields creator, post meta
6
 
7
  Requires at least: 3.1
8
+ Tested up to: 4.5.3
9
+ Stable tag: 1.2.9
10
 
11
  A must have tool for creating custom fields, custom post types and taxonomies, fast and without any programming knowledge.
12
 
143
  10. Taxonomy listing
144
 
145
  == Changelog ==
146
+ = 1.2.9 =
147
+ * Added Lables field in Custom Fields Creator next to Options for checkboxes, selects and radios
148
+
149
  = 1.2.8 =
150
  * Added Phone field type
151
  * Added HTML field type
wck-cfc.php CHANGED
@@ -149,7 +149,9 @@ function wck_cfc_create_box(){
149
  new Wordpress_Creation_Kit( $args );
150
 
151
  /* set up field types */
152
- $field_types = array( 'heading', 'text', 'textarea', 'select', 'checkbox', 'radio', 'phone', 'upload', 'wysiwyg editor', 'datepicker', 'timepicker', 'colorpicker', 'country select', 'user select', 'cpt select', 'currency select', 'html' );
 
 
153
  $field_types = apply_filters( 'wck_field_types', $field_types );
154
 
155
  /* setup post types */
@@ -165,12 +167,17 @@ function wck_cfc_create_box(){
165
  array( 'type' => 'text', 'title' => __( 'Default Value', 'wck' ), 'slug' => 'default-value', 'description' => __( 'Default value of the field. For Checkboxes if there are multiple values separate them with a ",". For an Upload field input an attachment id.', 'wck' ) ),
166
  array( 'type' => 'textarea', 'title' => __( 'Default Text', 'wck' ), 'slug' => 'default-text', 'description' => __( 'Default text of the textarea.', 'wck' ) ),
167
  array( 'type' => 'textarea', 'title' => __( 'HTML Content', 'wck' ), 'slug' => 'html-content', 'description' => __( 'Add your HTML (or text) content.', 'wck' ) ),
168
- array( 'type' => 'text', 'title' => __( 'Options', 'wck' ), 'slug' => 'options', 'description' => __( 'Options for field types "select", "checkbox" and "radio". For multiple options separate them with a ",". You can use the following structure if you want the label to be different from the value: %LabelOne%valueone,%LabelTwo%valuetwo,%LabelThree%valuethree', 'wck' ) ),
 
169
  array( 'type' => 'text', 'title' => __( 'Phone Format', 'wck' ), 'slug' => 'phone-format', 'default' => '(###) ###-####', 'description' => __( "You can use: # for numbers, parentheses ( ), - sign, + sign, dot . and spaces.", 'wck' ) .'<br>'. __( "Eg. (###) ###-####", 'wck' ) .'<br>'. __( "Empty field won't check for correct phone number.", 'wck' ) ),
170
  array( 'type' => 'checkbox', 'title' => __( 'Attach upload to post', 'wck' ), 'slug' => 'attach-upload-to-post', 'description' => __( 'Uploads will be attached to the post if this is checked', 'wck' ), 'options' => array( 'yes' ), 'default' => 'yes' ),
171
  array( 'type' => 'text', 'title' => __( 'Number of rows', 'wck' ), 'slug' => 'number-of-rows', 'description' => __( 'Number of rows for the textarea', 'wck' ), 'default' => '5' ),
172
  array( 'type' => 'select', 'title' => __( 'Readonly', 'wck' ), 'slug' => 'readonly', 'options' => array( 'false', 'true' ), 'default' => 'false', 'description' => __( 'Whether the textarea is readonly or not', 'wck' ) ),
173
- ) );
 
 
 
 
174
 
175
 
176
  /* set up the box arguments */
@@ -258,11 +265,17 @@ function wck_cfc_create_boxes_args(){
258
  if( isset( $wck_cfc_field['default-text'] ) && !empty( $wck_cfc_field['default-text'] ) )
259
  $fields_inner_array['default'] = $wck_cfc_field['default-text'];
260
  if( !empty( $wck_cfc_field['options'] ) ){
261
- $fields_inner_array['options'] = explode( ',', $wck_cfc_field['options'] );
 
 
 
 
262
 
263
  if( !empty( $fields_inner_array['options'] ) ){
264
  foreach( $fields_inner_array['options'] as $key => $value ){
265
  $fields_inner_array['options'][$key] = trim( $value );
 
 
266
  }
267
  }
268
 
@@ -289,9 +302,23 @@ function wck_cfc_create_boxes_args(){
289
  }
290
  }
291
 
292
- if( $wck_cfc_field['field-type'] === 'html' && isset( $wck_cfc_field['html-content'] ) ) {
293
- $fields_inner_array['html-content'] = $wck_cfc_field['html-content'];
294
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
 
296
  $fields_array[] = $fields_inner_array;
297
  }
149
  new Wordpress_Creation_Kit( $args );
150
 
151
  /* set up field types */
152
+
153
+ $field_types = array( 'heading', 'text', 'textarea', 'select', 'checkbox', 'radio', 'phone', 'upload', 'wysiwyg editor', 'datepicker', 'timepicker', 'colorpicker', 'country select', 'user select', 'cpt select', 'currency select', 'html', 'map' );
154
+
155
  $field_types = apply_filters( 'wck_field_types', $field_types );
156
 
157
  /* setup post types */
167
  array( 'type' => 'text', 'title' => __( 'Default Value', 'wck' ), 'slug' => 'default-value', 'description' => __( 'Default value of the field. For Checkboxes if there are multiple values separate them with a ",". For an Upload field input an attachment id.', 'wck' ) ),
168
  array( 'type' => 'textarea', 'title' => __( 'Default Text', 'wck' ), 'slug' => 'default-text', 'description' => __( 'Default text of the textarea.', 'wck' ) ),
169
  array( 'type' => 'textarea', 'title' => __( 'HTML Content', 'wck' ), 'slug' => 'html-content', 'description' => __( 'Add your HTML (or text) content.', 'wck' ) ),
170
+ array( 'type' => 'text', 'title' => __( 'Options', 'wck' ), 'slug' => 'options', 'description' => __( 'Options for field types "select", "checkbox" and "radio". For multiple options separate them with a ",".', 'wck' ) ),
171
+ array( 'type' => 'text', 'title' => __( 'Labels', 'wck' ), 'slug' => 'labels', 'description' => __( 'Labels for field types "select", "checkbox" and "radio". For multiple options separate them with a ",".', 'wck' ) ),
172
  array( 'type' => 'text', 'title' => __( 'Phone Format', 'wck' ), 'slug' => 'phone-format', 'default' => '(###) ###-####', 'description' => __( "You can use: # for numbers, parentheses ( ), - sign, + sign, dot . and spaces.", 'wck' ) .'<br>'. __( "Eg. (###) ###-####", 'wck' ) .'<br>'. __( "Empty field won't check for correct phone number.", 'wck' ) ),
173
  array( 'type' => 'checkbox', 'title' => __( 'Attach upload to post', 'wck' ), 'slug' => 'attach-upload-to-post', 'description' => __( 'Uploads will be attached to the post if this is checked', 'wck' ), 'options' => array( 'yes' ), 'default' => 'yes' ),
174
  array( 'type' => 'text', 'title' => __( 'Number of rows', 'wck' ), 'slug' => 'number-of-rows', 'description' => __( 'Number of rows for the textarea', 'wck' ), 'default' => '5' ),
175
  array( 'type' => 'select', 'title' => __( 'Readonly', 'wck' ), 'slug' => 'readonly', 'options' => array( 'false', 'true' ), 'default' => 'false', 'description' => __( 'Whether the textarea is readonly or not', 'wck' ) ),
176
+ array( 'type' => 'text', 'title' => __( 'Default Latitude', 'wck' ), 'slug' => 'map-default-latitude', 'description' => __( 'The latitude at which the map should be displayed when no pins are attached.', 'wck' ), 'default' => 0 ),
177
+ array( 'type' => 'text', 'title' => __( 'Default Longitude', 'wck' ), 'slug' => 'map-default-longitude', 'description' => __( 'The longitude at which the map should be displayed when no pins are attached.', 'wck' ), 'default' => 0 ),
178
+ array( 'type' => 'text', 'title' => __( 'Default Zoom', 'wck' ), 'slug' => 'map-default-zoom', 'description' => __( 'Add a number from 0 to 19. The higher the number the higher the zoom.', 'wck' ), 'default' => 15 ),
179
+ array( 'type' => 'text', 'title' => __( 'Map Height', 'wck' ), 'slug' => 'map-height', 'description' => __( 'The height of the map.', 'wck' ), 'default' => 350 )
180
+ ));
181
 
182
 
183
  /* set up the box arguments */
265
  if( isset( $wck_cfc_field['default-text'] ) && !empty( $wck_cfc_field['default-text'] ) )
266
  $fields_inner_array['default'] = $wck_cfc_field['default-text'];
267
  if( !empty( $wck_cfc_field['options'] ) ){
268
+ $fields_inner_array['options'] = array_map( 'trim', explode( ',', $wck_cfc_field['options'] ) );
269
+
270
+ if( !empty( $wck_cfc_field['labels'] ) ){
271
+ $labels = array_map( 'trim', explode( ',', $wck_cfc_field['labels'] ) );
272
+ }
273
 
274
  if( !empty( $fields_inner_array['options'] ) ){
275
  foreach( $fields_inner_array['options'] as $key => $value ){
276
  $fields_inner_array['options'][$key] = trim( $value );
277
+ if( strpos( $value, '%' ) === false && !empty( $labels[$key] ) )
278
+ $fields_inner_array['options'][$key] = '%'.$labels[$key].'%'.$value;
279
  }
280
  }
281
 
302
  }
303
  }
304
 
305
+
306
+ if( $wck_cfc_field['field-type'] === 'html' && isset( $wck_cfc_field['html-content'] ) ) {
307
+ $fields_inner_array['html-content'] = $wck_cfc_field['html-content'];
308
+ }
309
+
310
+
311
+ if( isset( $wck_cfc_field['map-default-latitude'] ) )
312
+ $fields_inner_array['map_default_latitude'] = trim( $wck_cfc_field['map-default-latitude'] );
313
+
314
+ if( isset( $wck_cfc_field['map-default-longitude'] ) )
315
+ $fields_inner_array['map_default_longitude'] = trim( $wck_cfc_field['map-default-longitude'] );
316
+
317
+ if( !empty( $wck_cfc_field['map-default-zoom'] ) )
318
+ $fields_inner_array['map_default_zoom'] = trim( $wck_cfc_field['map-default-zoom'] );
319
+
320
+ if( !empty( $wck_cfc_field['map-height'] ) )
321
+ $fields_inner_array['map_height'] = trim( $wck_cfc_field['map-height'] );
322
 
323
  $fields_array[] = $fields_inner_array;
324
  }
wck-sas.php CHANGED
@@ -79,6 +79,35 @@ function wck_sas_create_box(){
79
 
80
  /* create the box */
81
  new Wordpress_Creation_Kit( $args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  }
83
  }
84
 
79
 
80
  /* create the box */
81
  new Wordpress_Creation_Kit( $args );
82
+
83
+
84
+ /* set up the extra settings array */
85
+ $sas_extra_options = array();
86
+
87
+ if( file_exists( dirname( __FILE__ ) . '/wordpress-creation-kit-api/fields/map.php' ) )
88
+ $sas_extra_options[] = array( 'type' => 'text', 'title' => __( 'Google Maps API', 'wck' ), 'description' => __( 'Enter your Google Maps API key ( <a href="https://console.developers.google.com/flows/enableapi?apiid=maps_backend" target="_blank">Get your API key</a> )', 'wck' ), 'required' => false );
89
+
90
+ /* if there are extra options add the box */
91
+ if( !empty( $sas_extra_options ) ) {
92
+
93
+ /* set up the box arguments */
94
+ $args = array(
95
+ 'metabox_id' => 'wck_extra_options',
96
+ 'metabox_title' => __( 'Extra Settings', 'wck' ),
97
+ 'post_type' => 'sas-page',
98
+ 'meta_name' => 'wck_extra_options',
99
+ 'meta_array' => $sas_extra_options,
100
+ 'context' => 'option',
101
+ 'single' => true,
102
+ 'sortable' => false
103
+ );
104
+
105
+ /* create the box */
106
+ if (file_exists ($wck_premium_update . 'update-checker.php'))
107
+ new Wordpress_Creation_Kit( $args );
108
+
109
+ }
110
+
111
  }
112
  }
113
 
wck.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WCK - Custom Fields and Custom Post Types Creator
4
  Description: WordPress Creation Kit consists of three tools that can help you create and maintain custom post types, custom taxonomies and most importantly, custom fields and metaboxes for your posts, pages or CPT's.
5
  Author: Cozmoslabs, Madalin Ungureanu, Cristian Antohe
6
- Version: 1.2.8
7
  Author URI: http://www.cozmoslabs.com
8
 
9
  License: GPL2
@@ -118,7 +118,12 @@ if( file_exists( dirname(__FILE__).'/wck-stp.php' ) && ( !isset( $wck_stp ) || $
118
  /* Include Free to Pro menu items */
119
  if( !file_exists( dirname(__FILE__).'/wck-fep.php' ) && !file_exists( dirname(__FILE__).'/wck-stp.php' ) && !file_exists( dirname(__FILE__).'/update/update-checker.php' ) && ( !isset( $wck_free_to_pro ) || $wck_free_to_pro == 'enabled' )){
120
  require_once('wck-free-to-pro.php');
121
- }
 
 
 
 
 
122
 
123
  /* deactivation hook */
124
  register_deactivation_hook( __FILE__, 'wck_deactivate_function' );
3
  Plugin Name: WCK - Custom Fields and Custom Post Types Creator
4
  Description: WordPress Creation Kit consists of three tools that can help you create and maintain custom post types, custom taxonomies and most importantly, custom fields and metaboxes for your posts, pages or CPT's.
5
  Author: Cozmoslabs, Madalin Ungureanu, Cristian Antohe
6
+ Version: 1.2.9
7
  Author URI: http://www.cozmoslabs.com
8
 
9
  License: GPL2
118
  /* Include Free to Pro menu items */
119
  if( !file_exists( dirname(__FILE__).'/wck-fep.php' ) && !file_exists( dirname(__FILE__).'/wck-stp.php' ) && !file_exists( dirname(__FILE__).'/update/update-checker.php' ) && ( !isset( $wck_free_to_pro ) || $wck_free_to_pro == 'enabled' )){
120
  require_once('wck-free-to-pro.php');
121
+ }
122
+
123
+ /* Include Map Helper Field */
124
+ if( ( ( !isset( $wck_cfc ) || $wck_cfc == 'enabled' ) || ( !isset( $wck_opc ) || $wck_opc == 'enabled' ) ) && file_exists( dirname( __FILE__ ) . '/wordpress-creation-kit-api/assets/map/map.php' ) )
125
+ require_once( 'wordpress-creation-kit-api/assets/map/map.php' );
126
+
127
 
128
  /* deactivation hook */
129
  register_deactivation_hook( __FILE__, 'wck_deactivate_function' );
wordpress-creation-kit-api/assets/map/map.css ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*--------------------------------------------------------------
2
+ Map Field
3
+ --------------------------------------------------------------*/
4
+ input[type=text].wck-map-search-box {
5
+ position: absolute;
6
+ top: 9px !important;
7
+ height: 35px;
8
+ width: 30%;
9
+ min-width: 250px;
10
+ background: #fff;
11
+ border: 0;
12
+ border-radius: 1px;
13
+ padding: 0 10px;
14
+ box-shadow: 0 1px 1px 0 #c1c1c1;
15
+ font-family: 'Roboto', sans-serif;
16
+ font-size: 12px;
17
+ }
wordpress-creation-kit-api/assets/map/map.js ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // The Map Class
2
+ function WCK_Map( $jq_obj ) {
3
+
4
+ // Save the current instance
5
+ var _this = this;
6
+
7
+ this.jq_obj = $jq_obj;
8
+ this.default_lat = this.jq_obj.data('default-lat') || 0;
9
+ this.default_lng = this.jq_obj.data('default-lng') || 0;
10
+ this.default_zoom = this.jq_obj.data('default-zoom') || 0;
11
+ this.editable = this.jq_obj.data('editable');
12
+
13
+ this.map = null;
14
+ this.markers = [];
15
+ this.saved_positions = [];
16
+
17
+
18
+ /*
19
+ * Renders the map with all elements
20
+ *
21
+ */
22
+ this.render_map = function() {
23
+
24
+ // Set default center of the map
25
+ var center = { lat: this.default_lat, lng: this.default_lng };
26
+
27
+ // Default center of the map
28
+ var args = {
29
+ zoom : this.default_zoom,
30
+ center : new google.maps.LatLng( center ),
31
+ mapTypeId : google.maps.MapTypeId.ROADMAP
32
+ };
33
+
34
+ // Init the map
35
+ this.map = new google.maps.Map( this.jq_obj[0], args );
36
+
37
+ // Get saved positions from the db
38
+ this.saved_positions = this.get_saved_positions();
39
+
40
+
41
+ // Add saved markers
42
+ if( this.saved_positions.length > 0 ) {
43
+
44
+ for( x in this.saved_positions )
45
+ this.add_marker( this.saved_positions[x] );
46
+
47
+ this.center_map();
48
+
49
+ }
50
+
51
+
52
+ // Add search box
53
+ if( jQuery( '#' + this.jq_obj.attr('id') + '-search-box').length > 0 )
54
+ this.render_search_box();
55
+
56
+ // Bind map click to add marker and remove marker
57
+ if( this.editable ) {
58
+ this.map.addListener( 'click', function(event) {
59
+ _this.add_marker( { lat: event.latLng.lat(), lng: event.latLng.lng() } );
60
+ });
61
+ }
62
+
63
+ };
64
+
65
+
66
+ /*
67
+ * Attaches a search box to the map to search for places
68
+ *
69
+ */
70
+ this.render_search_box = function(){
71
+
72
+ var input = document.getElementById( this.jq_obj.attr('id') + '-search-box' );
73
+ var searchBox = new google.maps.places.SearchBox(input);
74
+ this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
75
+
76
+ searchBox.addListener( 'places_changed', function() {
77
+
78
+ var places = searchBox.getPlaces();
79
+
80
+ if( places.length == 0 )
81
+ return;
82
+
83
+ // Place markers for all locations found
84
+ places.forEach( function(place) {
85
+ _this.add_marker( { lat : place.geometry.location.lat(), lng : place.geometry.location.lng() } )
86
+ });
87
+
88
+ // Center map after new markers have been placed
89
+ _this.center_map();
90
+
91
+ });
92
+
93
+ };
94
+
95
+
96
+ /*
97
+ * Centers a map in correlation with the markers
98
+ *
99
+ */
100
+ this.center_map = function() {
101
+
102
+ var bounds = new google.maps.LatLngBounds();
103
+
104
+ for( x in this.markers ) {
105
+ var latlng = new google.maps.LatLng( this.markers[x].position.lat(), this.markers[x].position.lng() );
106
+ bounds.extend( latlng );
107
+ }
108
+
109
+ if( this.markers.length == 1 ) {
110
+
111
+ this.map.setCenter( bounds.getCenter() );
112
+ this.map.setZoom( this.jq_obj.data('default-zoom') );
113
+
114
+ } else {
115
+
116
+ this.map.fitBounds( bounds );
117
+
118
+ }
119
+
120
+ };
121
+
122
+
123
+ /*
124
+ * Adds a new marker to the map and also adds it in the hidden fields
125
+ * if it does not exist
126
+ *
127
+ */
128
+ this.add_marker = function( position ) {
129
+
130
+ // Add marker to the map
131
+ var marker = new google.maps.Marker({
132
+ position : new google.maps.LatLng( position ),
133
+ map : this.map
134
+ });
135
+
136
+ // Cache marker
137
+ if( this.markers.indexOf( marker ) == -1 )
138
+ this.markers.push( marker );
139
+
140
+ // Add hidden marker field
141
+ if( this.saved_positions.indexOf( position ) == -1 ) {
142
+ this.jq_obj.parent().append( '<input name="' + this.jq_obj.attr('id') + ( this.jq_obj.data('repeater') == 1 ? '' : '[]' ) + '" type="hidden" class="wck-map-marker mb-field" value="' + position.lat + ',' + position.lng + '" />' );
143
+ }
144
+
145
+ if( this.jq_obj.parents('.mb-list-entry-fields').length > 0 ) {
146
+ var infoWindow = new google.maps.InfoWindow({
147
+ content : '<a class="wck-map-remove-marker" data-marker="' + _this.markers.indexOf( marker ) + '" href="#">Remove Marker</a>'
148
+ });
149
+
150
+ marker.addListener( 'click', function(){
151
+ infoWindow.open( _this.map, marker );
152
+
153
+ // Bind remove marker
154
+ jQuery('.wck-map-remove-marker').click( function(e) {
155
+ e.preventDefault();
156
+ _this.remove_marker( jQuery(this).data('marker') );
157
+ });
158
+
159
+ });
160
+ }
161
+
162
+ };
163
+
164
+
165
+ /*
166
+ * Removes a marker from the map and also the hidden field associated with the marker
167
+ *
168
+ */
169
+ this.remove_marker = function( index ) {
170
+
171
+ var marker = this.markers[index];
172
+
173
+ // Remove hidden marker field
174
+ this.jq_obj.parent().find( 'input[value="' + marker.position.lat() + ',' + marker.position.lng() + '"]' ).remove();
175
+
176
+ // Remove marker from map
177
+ marker.setMap(null);
178
+
179
+ };
180
+
181
+
182
+ /*
183
+ * Returns the markers for a given map
184
+ * Markers are represented by hidden field that are under the map
185
+ *
186
+ */
187
+ this.get_saved_positions = function() {
188
+
189
+ var markers = [];
190
+
191
+ this.jq_obj.siblings('.wck-map-marker').each( function() {
192
+
193
+ var val = jQuery(this).val();
194
+
195
+ if( val != '' && val != undefined ) {
196
+ val = val.split(',');
197
+ markers.push( { lat : parseFloat( val[0] ), lng : parseFloat( val[1] ) } );
198
+ }
199
+
200
+ });
201
+
202
+ return markers;
203
+
204
+ }
205
+
206
+ }
207
+
208
+
209
+ /*
210
+ * Initialise all maps
211
+ */
212
+ jQuery( function($) {
213
+
214
+ var $maps = $('.wck-map-container');
215
+
216
+
217
+ /*
218
+ * Render each map
219
+ *
220
+ */
221
+
222
+ $maps.each( function() {
223
+
224
+ var map = new WCK_Map( $(this) );
225
+ map.render_map();
226
+
227
+ });
228
+
229
+ });
wordpress-creation-kit-api/assets/map/map.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Adds individual meta-data for the Map field when adding / updating a meta-box information
5
+ *
6
+ */
7
+ function wck_map_field_add_meta( $meta, $id, $values, $element_id = '' ) {
8
+
9
+
10
+ if( !empty( $id ) ) {
11
+ $meta_context = 'meta';
12
+ $meta_context_cpt = 'wck-meta-box';
13
+
14
+ $meta_values = get_post_meta($id, $meta, true);
15
+ } else {
16
+ $meta_context = 'option';
17
+ $meta_context_cpt = 'wck-option-field';
18
+
19
+ $meta_values = get_option( $meta );
20
+ }
21
+
22
+
23
+ $field_sets = get_posts( array( 'post_type' => $meta_context_cpt, 'numberposts' => -1 ) );
24
+
25
+ if( empty( $field_sets ) )
26
+ return;
27
+
28
+
29
+ foreach( $field_sets as $field_set ) {
30
+
31
+ $args = get_post_meta( $field_set->ID, 'wck_' . ( !empty( $id ) ? 'cfc' : 'opc_field' ) . '_args', true );
32
+
33
+ if( $args[0][ $meta_context . '-name' ] !== $meta )
34
+ continue;
35
+
36
+ // calculate element id
37
+ $element_id = ( $element_id != '' ? ( (int)$element_id + 1 ) : ( $args[0]['repeater'] == 'false' ? 1 : count( $meta_values ) + 1 ) );
38
+
39
+ $fields = get_post_meta( $field_set->ID, 'wck_' . ( !empty( $id ) ? 'cfc' : 'opc' ) . '_fields', true );
40
+
41
+ if( empty( $fields ) )
42
+ continue;
43
+
44
+ foreach( $fields as $field ) {
45
+
46
+ if( $field['field-type'] !== 'map' )
47
+ continue;
48
+
49
+ if( !empty( $values[ Wordpress_Creation_Kit::wck_generate_slug( $field['field-title'], $field ) ] ) ) {
50
+
51
+ wck_map_field_delete_metadata( $id, $meta, $field, $element_id );
52
+ wck_map_field_update_metadata( $id, $meta, $field, $element_id, $values[ Wordpress_Creation_Kit::wck_generate_slug( $field['field-title'], $field ) ] );
53
+
54
+ }
55
+
56
+ }
57
+
58
+ }
59
+
60
+ }
61
+ add_action( 'wck_before_add_meta', 'wck_map_field_add_meta', 10, 4 );
62
+ add_action( 'wck_before_update_meta', 'wck_map_field_add_meta', 10, 4 );
63
+
64
+
65
+ /*
66
+ * Add all markers for a map field as individual post_meta or options
67
+ *
68
+ */
69
+ function wck_map_field_update_metadata( $id = '', $meta, $field, $element_id, $map_markers = array() ) {
70
+
71
+ if( !empty( $map_markers ) ) {
72
+ foreach( $map_markers as $key => $map_marker ) {
73
+
74
+ $meta_name = $meta . '_' . Wordpress_Creation_Kit::wck_generate_slug( $field['field-title'], $field ) . '_' . $element_id . '_' . $key;
75
+
76
+ if( !empty( $id ) )
77
+ update_post_meta( $id, $meta_name, $map_marker );
78
+ else
79
+ update_option( $meta_name, $map_marker );
80
+ }
81
+ }
82
+
83
+ }
84
+
85
+
86
+ /*
87
+ * Removes all markers for a map field from the post_meta or options
88
+ *
89
+ */
90
+ function wck_map_field_delete_metadata( $id = '', $meta, $field, $element_id ) {
91
+
92
+ global $wpdb;
93
+
94
+ $meta_name = $meta . '_' . Wordpress_Creation_Kit::wck_generate_slug( $field['field-title'], $field ) . '_' . $element_id;
95
+
96
+ if( !empty( $id ) ) {
97
+
98
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key LIKE %s", $id, '%' . $meta_name . '%' ) );
99
+
100
+ wp_cache_delete( $id, 'post_meta' );
101
+
102
+ } else {
103
+
104
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", '%' . $meta_name . '%' ) );
105
+
106
+ // Needed in order to save data if other changes are made
107
+ wp_cache_flush();
108
+
109
+ }
110
+
111
+ }
112
+
113
+
114
+ /*
115
+ * Returns the HTML for a map given the field
116
+ *
117
+ */
118
+ function wck_get_map_output( $field, $args ) {
119
+
120
+ $defaults = array(
121
+ 'markers' => array(),
122
+ 'editable' => true,
123
+ 'show_search' => true,
124
+ 'extra_attr' => '',
125
+ 'wrapper' => ''
126
+ );
127
+
128
+ $args = wp_parse_args( $args, $defaults );
129
+
130
+ $return = '';
131
+
132
+ // Search box
133
+ // The style:left=-99999px is set to hide the input from the viewport. It will be rewritten when the map gets initialised
134
+ if( $args['show_search'] )
135
+ $return .= '<input style="left: -99999px" type="text" id="' . Wordpress_Creation_Kit::wck_generate_slug( $field['title'], $field ) . '-search-box" class="wppb-map-search-box" placeholder="' . __( 'Search Location', 'profile-builder' ) . '" />';
136
+
137
+ // Map container
138
+ $return .= '<div id="' . Wordpress_Creation_Kit::wck_generate_slug( $field['title'], $field ) . '" class="wck-map-container" style="height: ' . $field['map_height'] . 'px;" data-editable="' . ( $args['editable'] ? 1 : 0 ) . '" data-default-zoom="' . ( !empty( $field['map_default_zoom'] ) ? (int)$field['map_default_zoom'] : 16 ) . '" data-default-lat="' . $field['map_default_latitude'] . '" data-default-lng="' . $field['map_default_longitude'] . '" ' . $args['extra_attr'] . '></div>';
139
+
140
+ if( !empty( $args['markers'] ) ) {
141
+ foreach( $args['markers'] as $marker )
142
+ $return .= '<input name="' . ( $args['editable'] ? Wordpress_Creation_Kit::wck_generate_slug( $field['title'], $field ) : '' ) . '" type="hidden" class="wck-map-marker" value="' . $marker . '" />';
143
+ }
144
+
145
+ if( !empty( $args['wrapper'] ) )
146
+ $return = '<' . $args['wrapper'] . '>' . $return . '</' . $args['wrapper'] . '>';
147
+
148
+ return $return;
149
+
150
+ }
wordpress-creation-kit-api/fields/checkbox.php CHANGED
@@ -4,7 +4,7 @@
4
  * @param string $value Contains input value;
5
  * @param string $context Context where the function is used. Depending on it some actions are preformed.;
6
  * @return string $element input element html string. */
7
-
8
  if( !empty( $details['options'] ) ){
9
  $element .= '<div class="wck-checkboxes">';
10
  foreach( $details['options'] as $option ){
4
  * @param string $value Contains input value;
5
  * @param string $context Context where the function is used. Depending on it some actions are preformed.;
6
  * @return string $element input element html string. */
7
+
8
  if( !empty( $details['options'] ) ){
9
  $element .= '<div class="wck-checkboxes">';
10
  foreach( $details['options'] as $option ){
wordpress-creation-kit-api/fields/map.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @param string $meta Meta name.
3
+ * @param array $details Contains the details for the field.
4
+ * @param string $value Contains input value;
5
+ * @param string $context Context where the function is used. Depending on it some actions are preformed.;
6
+ * @return string $element input element html string. */
7
+
8
+ $wck_extra_options = get_option( 'wck_extra_options' );
9
+
10
+ if( !empty( $wck_extra_options[0]['google-maps-api'] ) ) {
11
+
12
+ $element .= '<div id="' . $single_prefix . esc_attr( Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ) ) . '" class="wck-map-container" style="height: ' . $details['map_height'] . 'px;" data-repeater="' . ( $this->args['single'] && $this->args['context'] != 'option' ? '0' : '1' ) . '" data-default-lat="' . $details['map_default_latitude'] . '" data-default-lng="' . $details['map_default_longitude'] . '" data-default-zoom="' . $details['map_default_zoom'] . '" data-editable="1"></div>';
13
+
14
+ $element .= '<input style="left: -99999px" type="text" id="' . $single_prefix . esc_attr( Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ) ) . '-search-box" class="wck-map-search-box" placeholder="' . __( 'Search Location', 'wck' ) . '" />';
15
+
16
+ if( !empty( $value ) && is_array( $value ) ) {
17
+ foreach( $value as $key => $marker ) {
18
+ $element .= '<input name="' . $single_prefix . esc_attr( Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ) );
19
+
20
+ // If the field is not a repeater we save it directly as an array
21
+ if( $this->args['single'] && $this->args['context'] != 'option' ) {
22
+ $element .= '[]';
23
+ }
24
+
25
+ $element .= '" type="hidden" class="wck-map-marker mb-field" value="' . $marker . '" />';
26
+ }
27
+ }
28
+
29
+ // Initialise map
30
+ $element .= '<script type="text/javascript">
31
+ jQuery( function( $ ) {
32
+ var $maps = jQuery(".wck-map-container");
33
+
34
+
35
+ /*
36
+ * Render each map
37
+ *
38
+ */
39
+
40
+ $maps.each( function() {
41
+
42
+ var map = new WCK_Map( jQuery(this) );
43
+ map.render_map();
44
+
45
+ });
46
+ });
47
+ </script>';
48
+
49
+ } else {
50
+
51
+ $element .= '<div class="wck-notification friendly-warning">' . sprintf( __( 'In order for the map field to work it will need a Google Maps API key. Please insert your API key <a href="%s">here</a>.', 'wck' ), admin_url( 'admin.php?page=sas-page#wck_extra_options' ) ) . '</div>';
52
+
53
+ }
wordpress-creation-kit-api/wck-fep/wck-fep.php CHANGED
@@ -74,7 +74,7 @@ class WCK_FrontEnd_Posting extends Wordpress_Creation_Kit{
74
  *
75
  * @since 1.0.0
76
  */
77
- static function wck_fep_register_script(){
78
  //datepicker
79
  wp_enqueue_script('jquery-ui-datepicker');
80
  wp_enqueue_style('jquery-style', plugins_url( '', dirname(__FILE__) ).'/assets/datepicker/datepicker.css');
@@ -88,6 +88,15 @@ class WCK_FrontEnd_Posting extends Wordpress_Creation_Kit{
88
  //phone
89
  wp_enqueue_script( 'wck-jquery-inputmask', plugins_url( '', dirname(__FILE__) ).'/assets/phone/jquery.inputmask.bundle.min.js', array( 'jquery' ), false, 1 );
90
 
 
 
 
 
 
 
 
 
 
91
  /* FEP script */
92
  wp_register_script( 'wck-fep', plugins_url('wck-fep.js', __FILE__ ), array('jquery'), '1.0', true );
93
  wp_register_style( 'wck-fep-css', plugins_url('wck-fep.css', __FILE__ ) );
74
  *
75
  * @since 1.0.0
76
  */
77
+ static function wck_fep_register_script(){
78
  //datepicker
79
  wp_enqueue_script('jquery-ui-datepicker');
80
  wp_enqueue_style('jquery-style', plugins_url( '', dirname(__FILE__) ).'/assets/datepicker/datepicker.css');
88
  //phone
89
  wp_enqueue_script( 'wck-jquery-inputmask', plugins_url( '', dirname(__FILE__) ).'/assets/phone/jquery.inputmask.bundle.min.js', array( 'jquery' ), false, 1 );
90
 
91
+ // map
92
+ $options = get_option( 'wck_extra_options' );
93
+
94
+ if( !empty( $options[0]['google-maps-api'] ) ) {
95
+ wp_enqueue_script( 'wck-google-maps-api-script', 'https://maps.googleapis.com/maps/api/js?key=' . $options[0]['google-maps-api'] . '&libraries=places', array('jquery') );
96
+ wp_enqueue_script( 'wck-google-maps-script', plugin_dir_url( __FILE__ ) . '../assets/map/map.js', array('jquery') );
97
+ wp_enqueue_style( 'wck-google-maps-style', plugin_dir_url( __FILE__ ) . '../assets/map/map.css' );
98
+ }
99
+
100
  /* FEP script */
101
  wp_register_script( 'wck-fep', plugins_url('wck-fep.js', __FILE__ ), array('jquery'), '1.0', true );
102
  wp_register_style( 'wck-fep-css', plugins_url('wck-fep.css', __FILE__ ) );
wordpress-creation-kit-api/wordpress-creation-kit.css CHANGED
@@ -246,4 +246,16 @@ td.wck-number{
246
  left:4px;
247
  line-height: 21px;
248
  padding-left: 18px;
 
 
 
 
 
 
 
 
 
 
 
 
249
  }
246
  left:4px;
247
  line-height: 21px;
248
  padding-left: 18px;
249
+ }
250
+
251
+ .wck-notification {
252
+ padding: 0.5em 1em;
253
+ border: 1px solid;
254
+ border-radius: 2px;
255
+ }
256
+
257
+ .wck-notification.friendly-warning {
258
+ background: rgba(230,126,34, 0.2);
259
+ color: #d35400;
260
+ border-color: #f39c12;
261
  }
wordpress-creation-kit-api/wordpress-creation-kit.js CHANGED
@@ -46,8 +46,19 @@ function addMeta(value, id, nonce){
46
  else
47
  values[key.toString()] += ', ' + jQuery(this).val().toString();
48
  }
49
- }
50
- else {
 
 
 
 
 
 
 
 
 
 
 
51
  if( jQuery(this).val() != null )
52
  values[key.toString()] = jQuery(this).val().toString();
53
  else
@@ -61,7 +72,7 @@ function addMeta(value, id, nonce){
61
  metaDetails = value.split("-wcknested-");
62
  meta = metaDetails[0];
63
  }
64
-
65
  jQuery.post( wckAjaxurl , { action:"wck_add_meta"+meta, meta:value, id:id, values:values, _ajax_nonce:nonce}, function(response) {
66
 
67
  jQuery( '#'+value+' .field-label').removeClass('error');
@@ -305,8 +316,19 @@ function updateMeta(value, id, element_id, nonce){
305
  values[key.toString()] += jQuery(this).val().toString();
306
  else
307
  values[key.toString()] += ', ' + jQuery(this).val().toString();
308
- }
309
- }
 
 
 
 
 
 
 
 
 
 
 
310
  else {
311
  if( jQuery(this).val() != null )
312
  values[key.toString()] = jQuery(this).val().toString();
@@ -315,8 +337,7 @@ function updateMeta(value, id, element_id, nonce){
315
  }
316
 
317
  });
318
-
319
-
320
  meta = value;
321
 
322
  if( value.indexOf("-wcknested-") != -1 ){
46
  else
47
  values[key.toString()] += ', ' + jQuery(this).val().toString();
48
  }
49
+
50
+ } else if( jQuery(this).hasClass('wck-map-marker') ) {
51
+
52
+ if( !Array.isArray( values[key.toString()] ) )
53
+ values[key.toString()] = [];
54
+
55
+ if( jQuery(this).val() != null )
56
+ values[key.toString()].push( jQuery(this).val().toString() );
57
+ else
58
+ values[key.toString()].push( '' );
59
+
60
+ } else {
61
+
62
  if( jQuery(this).val() != null )
63
  values[key.toString()] = jQuery(this).val().toString();
64
  else
72
  metaDetails = value.split("-wcknested-");
73
  meta = metaDetails[0];
74
  }
75
+
76
  jQuery.post( wckAjaxurl , { action:"wck_add_meta"+meta, meta:value, id:id, values:values, _ajax_nonce:nonce}, function(response) {
77
 
78
  jQuery( '#'+value+' .field-label').removeClass('error');
316
  values[key.toString()] += jQuery(this).val().toString();
317
  else
318
  values[key.toString()] += ', ' + jQuery(this).val().toString();
319
+ }
320
+
321
+ // The map markers need to be passed as array
322
+ } else if( jQuery(this).hasClass('wck-map-marker') ) {
323
+
324
+ if( !Array.isArray( values[key.toString()] ) )
325
+ values[key.toString()] = [];
326
+
327
+ if( jQuery(this).val() != null )
328
+ values[key.toString()].push( jQuery(this).val().toString() );
329
+ else
330
+ values[key.toString()].push( '' );
331
+ }
332
  else {
333
  if( jQuery(this).val() != null )
334
  values[key.toString()] = jQuery(this).val().toString();
337
  }
338
 
339
  });
340
+
 
341
  meta = value;
342
 
343
  if( value.indexOf("-wcknested-") != -1 ){
wordpress-creation-kit-api/wordpress-creation-kit.php CHANGED
@@ -554,6 +554,8 @@ class Wordpress_Creation_Kit{
554
  $display_value = implode( ', ', $value );
555
  } elseif ( $details['type'] == 'select' ){
556
  $display_value = '<pre>' . __(self::wck_get_entry_field_select( $value, $details ), 'profilebuilder') . '</pre>';
 
 
557
  }else {
558
  $display_value = '<pre>'.htmlspecialchars( $value ) . '</pre>';
559
  }
@@ -740,6 +742,17 @@ class Wordpress_Creation_Kit{
740
  if ( file_exists( WCK_PLUGIN_DIR. '/wordpress-creation-kit-api/fields/phone.php' ) ){
741
  wp_enqueue_script( 'wck-jquery-inputmask', plugins_url( '/assets/phone/jquery.inputmask.bundle.min.js', __FILE__ ), array( 'jquery' ), false, 1 );
742
  }
 
 
 
 
 
 
 
 
 
 
 
743
 
744
  /* media upload */
745
  wp_enqueue_media();
@@ -765,10 +778,10 @@ class Wordpress_Creation_Kit{
765
  }
766
  }
767
 
768
- if( !empty( $values ) ){
769
- foreach( $values as $key => $value ){
770
- if( array_key_exists( $key, $required_fields ) && apply_filters( "wck_required_test_{$meta}_{$key}", empty( $value ), $value, $id, $key, $meta, $fields ) ){
771
- $required_message .= apply_filters( "wck_required_message_{$meta}_{$key}", __( "Please enter a value for the required field ", "wck" ) . "$required_fields[$key] \n", $value, $required_fields[$key] );
772
  $required_fields_with_errors[] = $key;
773
  }
774
  }
554
  $display_value = implode( ', ', $value );
555
  } elseif ( $details['type'] == 'select' ){
556
  $display_value = '<pre>' . __(self::wck_get_entry_field_select( $value, $details ), 'profilebuilder') . '</pre>';
557
+ } elseif ( $details['type'] == 'map' ){
558
+ $display_value = '<pre>' . ( !empty( $value ) ? count( $value ) : 0 ) . ' ' . __( 'Map Markers', 'wck' ) . '</pre>';
559
  }else {
560
  $display_value = '<pre>'.htmlspecialchars( $value ) . '</pre>';
561
  }
742
  if ( file_exists( WCK_PLUGIN_DIR. '/wordpress-creation-kit-api/fields/phone.php' ) ){
743
  wp_enqueue_script( 'wck-jquery-inputmask', plugins_url( '/assets/phone/jquery.inputmask.bundle.min.js', __FILE__ ), array( 'jquery' ), false, 1 );
744
  }
745
+
746
+ //map
747
+ if ( file_exists( WCK_PLUGIN_DIR. '/wordpress-creation-kit-api/fields/map.php' ) ){
748
+ $options = get_option( 'wck_extra_options' );
749
+
750
+ if( !empty( $options[0]['google-maps-api'] ) ) {
751
+ wp_enqueue_script('wck-google-maps-api-script', 'https://maps.googleapis.com/maps/api/js?key=' . $options[0]['google-maps-api'] . '&libraries=places', array('jquery'));
752
+ wp_enqueue_script('wck-google-maps-script', plugin_dir_url(__FILE__) . '/assets/map/map.js', array('jquery'), false, 1);
753
+ wp_enqueue_style('wck-google-maps-style', plugin_dir_url(__FILE__) . '/assets/map/map.css');
754
+ }
755
+ }
756
 
757
  /* media upload */
758
  wp_enqueue_media();
778
  }
779
  }
780
 
781
+ if( !empty( $values ) ){
782
+ foreach( $required_fields as $key => $title ){
783
+ if( !array_key_exists( $key, $values ) || ( array_key_exists( $key, $values ) && apply_filters( "wck_required_test_{$meta}_{$key}", empty( $values[$key] ), $values[$key], $id, $key, $meta, $fields ) ) ) {
784
+ $required_message .= apply_filters( "wck_required_message_{$meta}_{$key}", __( "Please enter a value for the required field ", "wck" ) . "$required_fields[$key] \n", ( isset($values[$key]) ? $values[$key] : '' ), $required_fields[$key] );
785
  $required_fields_with_errors[] = $key;
786
  }
787
  }