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

Version Description

  • Added multiple select field type
Download this release

Release Info

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

Code changes from version 2.1.1 to 2.1.2

css/wck-cfc.css CHANGED
@@ -59,6 +59,8 @@
59
  #container_wck_cfc_fields .element_type_checkbox .row-labels,
60
  #container_wck_cfc_fields .element_type_select .row-options,
61
  #container_wck_cfc_fields .element_type_select .row-labels,
 
 
62
  #container_wck_cfc_fields .element_type_radio .row-options,
63
  #container_wck_cfc_fields .element_type_radio .row-labels,
64
  #container_wck_cfc_fields .element_type_upload .row-attach-upload-to-post,
59
  #container_wck_cfc_fields .element_type_checkbox .row-labels,
60
  #container_wck_cfc_fields .element_type_select .row-options,
61
  #container_wck_cfc_fields .element_type_select .row-labels,
62
+ #container_wck_cfc_fields .element_type_select-multiple .row-options,
63
+ #container_wck_cfc_fields .element_type_select-multiple .row-labels,
64
  #container_wck_cfc_fields .element_type_radio .row-options,
65
  #container_wck_cfc_fields .element_type_radio .row-labels,
66
  #container_wck_cfc_fields .element_type_upload .row-attach-upload-to-post,
js/wck-cfc.js CHANGED
@@ -2,7 +2,7 @@ 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
  }
@@ -96,7 +96,7 @@ jQuery(function(){
96
 
97
  jQuery(document).on( 'change', '#container_wck_cfc_fields #field-type', function () {
98
  value = jQuery(this).val();
99
- if( value == 'select' || value == 'checkbox' || value == 'radio' ){
100
  jQuery(this).parent().parent().parent().children(".row-options").show();
101
  jQuery(this).parent().parent().parent().children(".row-labels").show();
102
  }
2
  jQuery(document).on( 'change', '#wck_cfc_fields #field-type', function () {
3
  value = jQuery(this).val();
4
 
5
+ if( value == 'select' || value == 'select multiple' || value == 'checkbox' || value == 'radio' ){
6
  jQuery( '#wck_cfc_fields .row-options' ).show();
7
  jQuery( '#wck_cfc_fields .row-labels' ).show();
8
  }
96
 
97
  jQuery(document).on( 'change', '#container_wck_cfc_fields #field-type', function () {
98
  value = jQuery(this).val();
99
+ if( value == 'select' || value == 'select multiple' || value == 'checkbox' || value == 'radio' ){
100
  jQuery(this).parent().parent().parent().children(".row-options").show();
101
  jQuery(this).parent().parent().parent().children(".row-labels").show();
102
  }
readme.txt CHANGED
@@ -6,7 +6,7 @@ Tags: custom fields, custom field, wordpress custom fields, custom post type, cu
6
 
7
  Requires at least: 3.1
8
  Tested up to: 4.7.4
9
- Stable tag: 2.1.1
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -139,6 +139,9 @@ Creating a taxonomy generally automatically creates a special query variable usi
139
  10. Taxonomy listing
140
 
141
  == Changelog ==
 
 
 
142
  = 2.1.1 =
143
  * Added seamless display mode option to Custom Fields Creator boxes
144
 
6
 
7
  Requires at least: 3.1
8
  Tested up to: 4.7.4
9
+ Stable tag: 2.1.2
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
139
  10. Taxonomy listing
140
 
141
  == Changelog ==
142
+ = 2.1.2 =
143
+ * Added multiple select field type
144
+
145
  = 2.1.1 =
146
  * Added seamless display mode option to Custom Fields Creator boxes
147
 
wck-cfc.php CHANGED
@@ -153,7 +153,7 @@ function wck_cfc_create_box(){
153
 
154
  /* set up field types */
155
 
156
- $field_types = array( 'heading', 'text', 'number', 'textarea', 'select', 'checkbox', 'radio', 'phone', 'upload', 'wysiwyg editor', 'datepicker', 'timepicker', 'colorpicker', 'country select', 'user select', 'cpt select', 'currency select', 'html', 'map' );
157
 
158
  $field_types = apply_filters( 'wck_field_types', $field_types );
159
 
@@ -827,7 +827,7 @@ add_filter( 'wck_field_types', 'wck_cfc_filter_field_types' );
827
  function wck_cfc_filter_field_types( $field_types ){
828
  $wck_premium_update = WCK_PLUGIN_DIR.'/update/';
829
  if ( !file_exists ($wck_premium_update . 'update-checker.php'))
830
- $field_types = array( 'text', 'textarea', 'select', 'checkbox', 'radio', 'upload', 'wysiwyg editor', 'heading', 'colorpicker', 'currency select', 'phone', 'timepicker', 'html', 'number' );
831
 
832
  return $field_types;
833
  }
@@ -836,7 +836,7 @@ function wck_cfc_filter_field_types( $field_types ){
836
  add_filter( 'wck_before_test_required', 'wck_cfc_make_options_required', 10, 4 );
837
  function wck_cfc_make_options_required( $meta_array, $meta, $values, $id ) {
838
  if( $meta == 'wck_cfc_fields' ) {
839
- if( $values['field-type'] == 'select' || $values['field-type'] == 'radio' || $values['field-type'] == 'checkbox' ) {
840
  foreach( $meta_array as $key => $field ) {
841
  if( $field['slug'] == 'options' ) {
842
  $meta_array[$key]['required'] = true;
153
 
154
  /* set up field types */
155
 
156
+ $field_types = array( 'heading', 'text', 'number', 'textarea', 'select', 'select multiple', 'checkbox', 'radio', 'phone', 'upload', 'wysiwyg editor', 'datepicker', 'timepicker', 'colorpicker', 'country select', 'user select', 'cpt select', 'currency select', 'html', 'map' );
157
 
158
  $field_types = apply_filters( 'wck_field_types', $field_types );
159
 
827
  function wck_cfc_filter_field_types( $field_types ){
828
  $wck_premium_update = WCK_PLUGIN_DIR.'/update/';
829
  if ( !file_exists ($wck_premium_update . 'update-checker.php'))
830
+ $field_types = array( 'text', 'textarea', 'select', 'select multiple', 'checkbox', 'radio', 'upload', 'wysiwyg editor', 'heading', 'colorpicker', 'currency select', 'phone', 'timepicker', 'html', 'number' );
831
 
832
  return $field_types;
833
  }
836
  add_filter( 'wck_before_test_required', 'wck_cfc_make_options_required', 10, 4 );
837
  function wck_cfc_make_options_required( $meta_array, $meta, $values, $id ) {
838
  if( $meta == 'wck_cfc_fields' ) {
839
+ if( $values['field-type'] == 'select' || $values['field-type'] == 'select multiple' || $values['field-type'] == 'radio' || $values['field-type'] == 'checkbox' ) {
840
  foreach( $meta_array as $key => $field ) {
841
  if( $field['slug'] == 'options' ) {
842
  $meta_array[$key]['required'] = true;
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: 2.1.1
7
  Author URI: http://www.cozmoslabs.com
8
 
9
  License: GPL2
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: 2.1.2
7
  Author URI: http://www.cozmoslabs.com
8
 
9
  License: GPL2
wordpress-creation-kit-api/fields/select multiple.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $element .= '<select multiple name="'. $single_prefix . esc_attr( Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ) );
8
+ if( $this->args['single'] && $this->args['context'] != 'option' ) {
9
+ $element .= '[]';
10
+ }
11
+ $element .= '" id="';
12
+ if( !empty( $frontend_prefix ) )
13
+ $element .= $frontend_prefix;
14
+ $element .= esc_attr( Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ) ) .'" class="mb-select-multiple mb-field" >';
15
+
16
+ if( !empty( $details['default-option'] ) && $details['default-option'] )
17
+ $element .= '<option value="">'. __('...Choose', 'wck') .'</option>';
18
+
19
+ $field_name = Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details );
20
+
21
+ $options = '';
22
+ if( !empty( $details['options'] ) ){
23
+ $i = 0;
24
+ foreach( $details['options'] as $option ){
25
+ $found = false;
26
+
27
+ if( !is_array( $value ) )
28
+ $values = explode( ', ', $value );
29
+ else
30
+ $values = $value;
31
+
32
+ if( strpos( $option, '%' ) === false ){
33
+ $label = $option;
34
+ $value_attr = $option;
35
+ if ( in_array( $option, $values ) )
36
+ $found = true;
37
+ }
38
+ else{
39
+ $option_parts = explode( '%', $option );
40
+ if( !empty( $option_parts ) ){
41
+ if( empty( $option_parts[0] ) && count( $option_parts ) == 3 ){
42
+ $label = $option_parts[1];
43
+ $value_attr = $option_parts[2];
44
+ if ( in_array( $option_parts[2], $values ) )
45
+ $found = true;
46
+ }
47
+ }
48
+ }
49
+
50
+ $optionOutput = '<option value="'. esc_attr( $value_attr ) .'" '. selected( $found, true, false ) .' >'. esc_html( $label ) .'</option>';
51
+ $options .= apply_filters( "wck_select_{$meta}_{$field_name}_option_{$i}", $optionOutput, $i);
52
+ $i++;
53
+ }
54
+ }
55
+
56
+ $element .= apply_filters( "wck_select_{$meta}_{$field_name}_options", $options );
57
+ $element .= '</select>';
58
+ ?>
wordpress-creation-kit-api/wck-fep/wck-fep.js CHANGED
@@ -69,8 +69,9 @@ function wckGetTargetedValues( target ){
69
  else
70
  values[key.toString()] += ', ' + jQuery(this).val().toString();
71
  }
 
 
72
  }
73
-
74
  else
75
  values[key.toString()] = jQuery(this).val().toString();
76
 
69
  else
70
  values[key.toString()] += ', ' + jQuery(this).val().toString();
71
  }
72
+ }else if( jQuery(this).hasClass('mb-select-multiple') ){
73
+ values[key.toString()] = jQuery(this).val().toString().replace(',', ', ');
74
  }
 
75
  else
76
  values[key.toString()] = jQuery(this).val().toString();
77
 
wordpress-creation-kit-api/wordpress-creation-kit.js CHANGED
@@ -32,7 +32,7 @@ function addMeta(value, id, nonce){
32
  var values = {};
33
 
34
  jQuery('#'+value+' .mb-field').each(function(){
35
-
36
  var key = jQuery(this).attr('name');
37
 
38
  if(jQuery(this).attr('type') == 'checkbox' || jQuery(this).attr('type') == 'radio' ) {
@@ -57,8 +57,13 @@ function addMeta(value, id, nonce){
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
@@ -320,6 +325,12 @@ function updateMeta(value, id, element_id, nonce){
320
  else
321
  values[key.toString()].push( '' );
322
  }
 
 
 
 
 
 
323
  else {
324
  if( jQuery(this).val() != null )
325
  values[key.toString()] = jQuery(this).val().toString();
32
  var values = {};
33
 
34
  jQuery('#'+value+' .mb-field').each(function(){
35
+
36
  var key = jQuery(this).attr('name');
37
 
38
  if(jQuery(this).attr('type') == 'checkbox' || jQuery(this).attr('type') == 'radio' ) {
57
  else
58
  values[key.toString()].push( '' );
59
 
60
+ }else if( jQuery(this).hasClass('mb-select-multiple') ) {
61
+ if( jQuery(this).val() != null )
62
+ values[key.toString()] = jQuery(this).val().toString().replace(',', ', ');
63
+ else
64
+ values[key.toString()] = '';
65
+ }
66
+ else {
67
  if( jQuery(this).val() != null )
68
  values[key.toString()] = jQuery(this).val().toString();
69
  else
325
  else
326
  values[key.toString()].push( '' );
327
  }
328
+ else if( jQuery(this).hasClass('mb-select-multiple') ) {
329
+ if( jQuery(this).val() != null )
330
+ values[key.toString()] = jQuery(this).val().toString().replace(',', ', ');
331
+ else
332
+ values[key.toString()] = '';
333
+ }
334
  else {
335
  if( jQuery(this).val() != null )
336
  values[key.toString()] = jQuery(this).val().toString();