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

Version Description

  • Fixed an issue with fields that had their slug changed and didn't appear sometimes
  • Modifications to upload button so that it disappears when we already have something uploaded
  • Added 2 new currencies in the Currency Select field
  • Small modifications to the generate slug function
Download this release

Release Info

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

Code changes from version 2.0.5 to 2.0.6

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, 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.7
9
- Stable tag: 2.0.5
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -139,6 +139,12 @@ Creating a taxonomy generally automatically creates a special query variable usi
139
  10. Taxonomy listing
140
 
141
  == Changelog ==
 
 
 
 
 
 
142
  = 2.0.5 =
143
  * Changes to the unserialized fields: we can now handle fields from other sources
144
  * Improvements to javascript speed in the admin interface
5
  Tags: custom fields, custom field, wordpress custom fields, custom post type, custom post types, 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.7.1
9
+ Stable tag: 2.0.6
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.0.6 =
143
+ * Fixed an issue with fields that had their slug changed and didn't appear sometimes
144
+ * Modifications to upload button so that it disappears when we already have something uploaded
145
+ * Added 2 new currencies in the Currency Select field
146
+ * Small modifications to the generate slug function
147
+
148
  = 2.0.5 =
149
  * Changes to the unserialized fields: we can now handle fields from other sources
150
  * Improvements to javascript speed in the admin interface
wck-cfc.php CHANGED
@@ -1217,8 +1217,13 @@ function wck_serialized_update_from_unserialized( $replace, $object_id, $meta_ke
1217
  if( !empty( $cfc_fields ) ){
1218
  foreach ( $cfc_fields as $cfc_field ){
1219
 
 
 
 
 
 
1220
  /* check to see if we already have a meta name like this from the old structure to avoid conflicts */
1221
- $unserialized_key = Wordpress_Creation_Kit::wck_generate_unique_meta_name_for_unserialized_field( $object_id, Wordpress_Creation_Kit::wck_generate_slug( $cfc_field['field-title'] ), $cfc_args[0]['meta-name'] );
1222
 
1223
  /* I will limit this to maximum 100 repeater field entries */
1224
  for( $i=0; $i<1000;$i++ ){
@@ -1230,7 +1235,7 @@ function wck_serialized_update_from_unserialized( $replace, $object_id, $meta_ke
1230
 
1231
  if ( isset($meta_cache[$unserialized_key.$suffix]) ) {
1232
  $unserialized_value = maybe_unserialize( $meta_cache[$unserialized_key.$suffix][0] );
1233
- $replace_with[$i][Wordpress_Creation_Kit::wck_generate_slug( $cfc_field['field-title'] )] = $unserialized_value;
1234
  }
1235
  }
1236
  }
@@ -1239,8 +1244,9 @@ function wck_serialized_update_from_unserialized( $replace, $object_id, $meta_ke
1239
  if( !empty( $replace_with ) ){
1240
  $replace_with = array( array( $replace_with ) );
1241
 
1242
- if ( $single )
1243
  return $replace_with[0];
 
1244
  else
1245
  return $replace_with;
1246
  }
1217
  if( !empty( $cfc_fields ) ){
1218
  foreach ( $cfc_fields as $cfc_field ){
1219
 
1220
+ if( !empty( $cfc_field['field-slug'] ) )
1221
+ $slug = $cfc_field['field-slug'];
1222
+ else
1223
+ $slug = Wordpress_Creation_Kit::wck_generate_slug( $cfc_field['field-title'] );
1224
+
1225
  /* check to see if we already have a meta name like this from the old structure to avoid conflicts */
1226
+ $unserialized_key = Wordpress_Creation_Kit::wck_generate_unique_meta_name_for_unserialized_field( $object_id, $slug, $cfc_args[0]['meta-name'] );
1227
 
1228
  /* I will limit this to maximum 100 repeater field entries */
1229
  for( $i=0; $i<1000;$i++ ){
1235
 
1236
  if ( isset($meta_cache[$unserialized_key.$suffix]) ) {
1237
  $unserialized_value = maybe_unserialize( $meta_cache[$unserialized_key.$suffix][0] );
1238
+ $replace_with[$i][$slug] = $unserialized_value;
1239
  }
1240
  }
1241
  }
1244
  if( !empty( $replace_with ) ){
1245
  $replace_with = array( array( $replace_with ) );
1246
 
1247
+ if ( $single ) {
1248
  return $replace_with[0];
1249
+ }
1250
  else
1251
  return $replace_with;
1252
  }
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.0.5
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.0.6
7
  Author URI: http://www.cozmoslabs.com
8
 
9
  License: GPL2
wordpress-creation-kit-api/assets/currency/currency-select.php CHANGED
@@ -63,6 +63,7 @@ function wck_get_currencies() {
63
  'JMD' => __( 'Jamaica Dollar','wck' ),
64
  'JPY' => __( 'Japan Yen','wck' ),
65
  'JEP' => __( 'Jersey Pound','wck' ),
 
66
  'KZT' => __( 'Kazakhstan Tenge','wck' ),
67
  'KPW' => __( 'Korea (North) Won','wck' ),
68
  'KRW' => __( 'Korea (South) Won','wck' ),
@@ -72,6 +73,7 @@ function wck_get_currencies() {
72
  'LBP' => __( 'Lebanon Pound','wck' ),
73
  'LRD' => __( 'Liberia Dollar','wck' ),
74
  'LTL' => __( 'Lithuania Litas','wck' ),
 
75
  'MKD' => __( 'Macedonia Denar','wck' ),
76
  'MYR' => __( 'Malaysia Ringgit','wck' ),
77
  'MUR' => __( 'Mauritius Rupee','wck' ),
63
  'JMD' => __( 'Jamaica Dollar','wck' ),
64
  'JPY' => __( 'Japan Yen','wck' ),
65
  'JEP' => __( 'Jersey Pound','wck' ),
66
+ 'JOD' => __( 'Jordanian Dinar','wck' ),
67
  'KZT' => __( 'Kazakhstan Tenge','wck' ),
68
  'KPW' => __( 'Korea (North) Won','wck' ),
69
  'KRW' => __( 'Korea (South) Won','wck' ),
73
  'LBP' => __( 'Lebanon Pound','wck' ),
74
  'LRD' => __( 'Liberia Dollar','wck' ),
75
  'LTL' => __( 'Lithuania Litas','wck' ),
76
+ 'MOP' => __( 'Macau Pataca','wck' ),
77
  'MKD' => __( 'Macedonia Denar','wck' ),
78
  'MYR' => __( 'Malaysia Ringgit','wck' ),
79
  'MUR' => __( 'Mauritius Rupee','wck' ),
wordpress-creation-kit-api/fields/upload.js CHANGED
@@ -85,6 +85,7 @@ jQuery(document).ready(function(){
85
  }
86
 
87
  uploadButton.before( result );
 
88
 
89
  }
90
  /* turn into comma separated string */
@@ -123,9 +124,13 @@ jQuery(document).ready(function(){
123
  }
124
  newuploadAttachments = newuploadAttachments.join(',');
125
  upload_input.val(newuploadAttachments);
126
-
 
 
127
  /* remove the attachment details */
128
  jQuery(this).parent().parent('.upload-field-details').remove();
 
 
129
  });
130
  }
131
  });
85
  }
86
 
87
  uploadButton.before( result );
88
+ uploadButton.hide();
89
 
90
  }
91
  /* turn into comma separated string */
124
  }
125
  newuploadAttachments = newuploadAttachments.join(',');
126
  upload_input.val(newuploadAttachments);
127
+
128
+ jQuery( '.wck_upload_button', jQuery(this).closest( '.mb-right-column' ) ).css( 'display', 'inline-block' );
129
+
130
  /* remove the attachment details */
131
  jQuery(this).parent().parent('.upload-field-details').remove();
132
+
133
+
134
  });
135
  }
136
  });
wordpress-creation-kit-api/wck-fep/wck-fep.css CHANGED
@@ -455,6 +455,10 @@
455
  cursor: pointer;
456
  }
457
 
 
 
 
 
458
  .wck-edit, .wck-delete, .wck-number {
459
  text-align: center !important;
460
  width: 50px;
455
  cursor: pointer;
456
  }
457
 
458
+ .fep-container .upload-field-details + .wck_upload_button{
459
+ display:none;
460
+ }
461
+
462
  .wck-edit, .wck-delete, .wck-number {
463
  text-align: center !important;
464
  width: 50px;
wordpress-creation-kit-api/wck-fep/wck-fep.php CHANGED
@@ -370,8 +370,8 @@ class WCK_FrontEnd_Posting extends Wordpress_Creation_Kit{
370
  $value = self::wck_fep_get_edit_value( $post_id, $details );
371
  }
372
  else
373
- $value = apply_filters( 'wck_fep_default_value_'. $form_name . '_'. Wordpress_Creation_Kit::wck_generate_slug( $details['title'] ), '' );
374
-
375
  $form .= parent::wck_output_form_field( $form_name, $details, $value, 'fep', $post_id );
376
 
377
  }
@@ -393,8 +393,12 @@ class WCK_FrontEnd_Posting extends Wordpress_Creation_Kit{
393
  /* build edit values depending on the field */
394
  $value = self::wck_fep_get_edit_value( $post_id, $details, $box_args['meta_name'] );
395
  }
396
- else
397
- $value = '';
 
 
 
 
398
  $form .= '<div class="fep-single-element-wrap">';
399
  $form .= parent::wck_output_form_field( $box_args['meta_name'], $details, $value, 'fep', $post_id );
400
  $form .= '</div>';
@@ -490,7 +494,7 @@ class WCK_FrontEnd_Posting extends Wordpress_Creation_Kit{
490
  else{
491
  $meta_values = get_post_meta( $post_id, $meta_name, true );
492
  if( !empty( $meta_values ) )
493
- $value = $meta_values[0][Wordpress_Creation_Kit::wck_generate_slug( $details['title'] )];
494
  }
495
 
496
  return $value;
370
  $value = self::wck_fep_get_edit_value( $post_id, $details );
371
  }
372
  else
373
+ $value = apply_filters('wck_fep_default_value_' . $form_name . '_' . Wordpress_Creation_Kit::wck_generate_slug($details['title']), '');
374
+
375
  $form .= parent::wck_output_form_field( $form_name, $details, $value, 'fep', $post_id );
376
 
377
  }
393
  /* build edit values depending on the field */
394
  $value = self::wck_fep_get_edit_value( $post_id, $details, $box_args['meta_name'] );
395
  }
396
+ else {
397
+ if( isset( $details['default'] ) )
398
+ $value = $details['default'];
399
+ else
400
+ $value = '';
401
+ }
402
  $form .= '<div class="fep-single-element-wrap">';
403
  $form .= parent::wck_output_form_field( $box_args['meta_name'], $details, $value, 'fep', $post_id );
404
  $form .= '</div>';
494
  else{
495
  $meta_values = get_post_meta( $post_id, $meta_name, true );
496
  if( !empty( $meta_values ) )
497
+ $value = $meta_values[0][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )];
498
  }
499
 
500
  return $value;
wordpress-creation-kit-api/wordpress-creation-kit.css CHANGED
@@ -185,6 +185,9 @@ td.wck-number{
185
  color:#21759B;
186
  }
187
 
 
 
 
188
 
189
  /* Settings page. */
190
  .side .form-table th {
185
  color:#21759B;
186
  }
187
 
188
+ .upload-field-details + .wck_upload_button{
189
+ display:none;
190
+ }
191
 
192
  /* Settings page. */
193
  .side .form-table th {
wordpress-creation-kit-api/wordpress-creation-kit.js CHANGED
@@ -393,12 +393,13 @@ function wckGoToByScroll(id){
393
  }
394
 
395
  /* Remove uploaded file */
396
- jQuery(function(){
 
397
  jQuery(document).on('click', '.wck-remove-upload', function(e){
398
  jQuery(this).parent().parent().parent().children('.mb-field').val("");
399
  jQuery(this).parent().parent('.upload-field-details').html('<p><span class="file-name"></span><span class="file-type"></span></p>');
400
- });
401
- });
402
 
403
  /* Set width for listing "label" equal to the widest */
404
  jQuery( function(){
393
  }
394
 
395
  /* Remove uploaded file */
396
+ //this could be legacy code since before we added the upload.js so we might not need it
397
+ /*jQuery(function(){
398
  jQuery(document).on('click', '.wck-remove-upload', function(e){
399
  jQuery(this).parent().parent().parent().children('.mb-field').val("");
400
  jQuery(this).parent().parent('.upload-field-details').html('<p><span class="file-name"></span><span class="file-type"></span></p>');
401
+ });
402
+ });*/
403
 
404
  /* Set width for listing "label" equal to the widest */
405
  jQuery( function(){
wordpress-creation-kit-api/wordpress-creation-kit.php CHANGED
@@ -268,6 +268,10 @@ class Wordpress_Creation_Kit{
268
  else if( $context == 'fep' ){
269
  /* id prefix for frontend posting */
270
  $frontend_prefix = 'fep-';
 
 
 
 
271
  }
272
  else{
273
  if( isset( $details['default'] ) && !( $this->args['single'] == true && !is_null( $value ) ) ) {
@@ -385,6 +389,9 @@ class Wordpress_Creation_Kit{
385
  else if( !empty( $results[0] ) && !empty( $results[0][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )] ) )
386
  $value = $results[0][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )];
387
  }
 
 
 
388
 
389
  ?>
390
  <li class="row-<?php echo esc_attr( Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ) ) ?>">
@@ -494,7 +501,7 @@ class Wordpress_Creation_Kit{
494
  $results = get_post_meta($id, $meta, true);
495
  else if ( $this->args['context'] == 'option' )
496
  $results = get_option( $meta );
497
-
498
  $list = '';
499
  $list .= '<table id="container_'.esc_attr($meta).'" class="mb-table-container widefat';
500
 
@@ -538,12 +545,12 @@ class Wordpress_Creation_Kit{
538
  if( !empty( $fields ) ){
539
  foreach( $fields as $field ){
540
  $details = $field;
541
-
542
  if( isset( $results[$element_id][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )] ) )
543
  $value = $results[$element_id][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )];
544
  else
545
  $value = '';
546
-
547
  /* filter display value */
548
  /* keep this one for backwards compatibility */
549
  $value = apply_filters( "wck_displayed_value_{$meta}_element_{$j}", $value );
@@ -641,6 +648,8 @@ class Wordpress_Creation_Kit{
641
  }
642
  }
643
  }
 
 
644
  }
645
 
646
  /* function to generate output for upload field */
@@ -1613,6 +1622,8 @@ class Wordpress_Creation_Kit{
1613
  static function wck_generate_slug( $string, $details = array() ){
1614
  if( !empty( $details['slug'] ) )
1615
  $slug = $details['slug'];
 
 
1616
  else
1617
  $slug = rawurldecode( sanitize_title_with_dashes( remove_accents( $string ) ) );
1618
 
268
  else if( $context == 'fep' ){
269
  /* id prefix for frontend posting */
270
  $frontend_prefix = 'fep-';
271
+ /* we do this just for repeater fields, for single it should already be defined in fep */
272
+ if( !empty( $details['in_repeater'] ) && $details['in_repeater'] == true && isset( $details['default'] ) ){
273
+ $value = apply_filters( "wck_default_value_{$meta}_" . Wordpress_Creation_Kit::wck_generate_slug($details['title'], $details ), $details['default'] );
274
+ }
275
  }
276
  else{
277
  if( isset( $details['default'] ) && !( $this->args['single'] == true && !is_null( $value ) ) ) {
389
  else if( !empty( $results[0] ) && !empty( $results[0][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )] ) )
390
  $value = $results[0][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )];
391
  }
392
+ else{
393
+ $details['in_repeater'] = true;
394
+ }
395
 
396
  ?>
397
  <li class="row-<?php echo esc_attr( Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ) ) ?>">
501
  $results = get_post_meta($id, $meta, true);
502
  else if ( $this->args['context'] == 'option' )
503
  $results = get_option( $meta );
504
+
505
  $list = '';
506
  $list .= '<table id="container_'.esc_attr($meta).'" class="mb-table-container widefat';
507
 
545
  if( !empty( $fields ) ){
546
  foreach( $fields as $field ){
547
  $details = $field;
548
+
549
  if( isset( $results[$element_id][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )] ) )
550
  $value = $results[$element_id][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )];
551
  else
552
  $value = '';
553
+
554
  /* filter display value */
555
  /* keep this one for backwards compatibility */
556
  $value = apply_filters( "wck_displayed_value_{$meta}_element_{$j}", $value );
648
  }
649
  }
650
  }
651
+
652
+ return $value;
653
  }
654
 
655
  /* function to generate output for upload field */
1622
  static function wck_generate_slug( $string, $details = array() ){
1623
  if( !empty( $details['slug'] ) )
1624
  $slug = $details['slug'];
1625
+ elseif( !empty( $details['field-slug'] ) )
1626
+ $slug = $details['field-slug'];
1627
  else
1628
  $slug = rawurldecode( sanitize_title_with_dashes( remove_accents( $string ) ) );
1629