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

Version Description

  • Select field can now display lables when outputting values
  • Minor security improvements
  • We no longer get .js errors when a Select field has no options
  • Added global filter for a form element output
  • Fixed typo in Meta Box Creator
Download this release

Release Info

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

Code changes from version 1.1.6 to 1.1.7

readme.txt CHANGED
@@ -3,9 +3,10 @@
3
  Contributors: reflectionmedia, madalin.ungureanu, sareiodata
4
  Donate link: http://www.cozmoslabs.com/wordpress-creation-kit/
5
  Tags: custom fields, custom field, wordpress custom fields, advanced custom fields, custom post type, custom post types, post types, cpt, post type, repeater fields, repeater, repeatable fields, meta box, metabox, taxonomy, taxonomies, custom taxonomy, custom taxonomies, custom, custom fields creator, post meta, meta, get_post_meta, post creator, cck, content types, types
 
6
  Requires at least: 3.1
7
- Tested up to: 4.1.1
8
- Stable tag: 1.1.6
9
 
10
  A must have tool for creating custom fields, custom post types and taxonomies, fast and without any programming knowledge.
11
 
@@ -140,8 +141,15 @@ Creating a taxonomy generally automatically creates a special query variable usi
140
  10. Taxonomy listing
141
 
142
  == Changelog ==
 
 
 
 
 
 
 
143
  = 1.1.6 =
144
- * We now run the Custom Post Type and Custom Taxonomy register function sooner on the init hook
145
  * Aligned "Help" wit "WCK" in contextual help red button
146
  * Fixed some issues with translations
147
 
3
  Contributors: reflectionmedia, madalin.ungureanu, sareiodata
4
  Donate link: http://www.cozmoslabs.com/wordpress-creation-kit/
5
  Tags: custom fields, custom field, wordpress custom fields, advanced custom fields, custom post type, custom post types, post types, cpt, post type, repeater fields, repeater, repeatable fields, meta box, metabox, taxonomy, taxonomies, custom taxonomy, custom taxonomies, custom, custom fields creator, post meta, meta, get_post_meta, post creator, cck, content types, types
6
+
7
  Requires at least: 3.1
8
+ Tested up to: 4.3.1
9
+ Stable tag: 1.1.7
10
 
11
  A must have tool for creating custom fields, custom post types and taxonomies, fast and without any programming knowledge.
12
 
141
  10. Taxonomy listing
142
 
143
  == Changelog ==
144
+ = 1.1.7 =
145
+ * Select field can now display lables when outputting values
146
+ * Minor security improvements
147
+ * We no longer get .js errors when a Select field has no options
148
+ * Added global filter for a form element output
149
+ * Fixed typo in Meta Box Creator
150
+
151
  = 1.1.6 =
152
+ * We now run the Custom Post Type and Custom Taxonomy register function sooner on the init hook
153
  * Aligned "Help" wit "WCK" in contextual help red button
154
  * Fixed some issues with translations
155
 
wck-cfc.php CHANGED
@@ -118,7 +118,7 @@ function wck_cfc_create_box(){
118
 
119
  /* set up the fields array */
120
  $cfc_box_args_fields = array(
121
- array( 'type' => 'text', 'title' => __( 'Metaaaa name', 'wck' ), 'slug' => 'meta-name', 'description' => __( 'The name of the meta field. It is the name by which you will query the data in the frontend. Must be unique, only lowercase letters, no spaces and no special characters.', 'wck' ), 'required' => true ),
122
  array( 'type' => 'select', 'title' => __( 'Post Type', 'wck' ), 'slug' => 'post-type', 'options' => $post_type_names, 'default-option' => true, 'description' => __( 'What post type the meta box should be attached to', 'wck' ), 'required' => true ),
123
  array( 'type' => 'select', 'title' => __( 'Repeater', 'wck' ), 'slug' => 'repeater', 'options' => array( 'false', 'true' ), 'default' => 'false', 'description' => __( 'Whether the box supports just one entry or if it is a repeater field. By default it is a single field.', 'wck' ) ),
124
  array( 'type' => 'select', 'title' => __( 'Sortable', 'wck' ), 'slug' => 'sortable', 'options' => array( 'true', 'false' ), 'default' => 'false', 'description' => __( 'Whether the entries are sortable or not. This is valid for repeater fields.', 'wck' ) ),
118
 
119
  /* set up the fields array */
120
  $cfc_box_args_fields = array(
121
+ array( 'type' => 'text', 'title' => __( 'Meta name', 'wck' ), 'slug' => 'meta-name', 'description' => __( 'The name of the meta field. It is the name by which you will query the data in the frontend. Must be unique, only lowercase letters, no spaces and no special characters.', 'wck' ), 'required' => true ),
122
  array( 'type' => 'select', 'title' => __( 'Post Type', 'wck' ), 'slug' => 'post-type', 'options' => $post_type_names, 'default-option' => true, 'description' => __( 'What post type the meta box should be attached to', 'wck' ), 'required' => true ),
123
  array( 'type' => 'select', 'title' => __( 'Repeater', 'wck' ), 'slug' => 'repeater', 'options' => array( 'false', 'true' ), 'default' => 'false', 'description' => __( 'Whether the box supports just one entry or if it is a repeater field. By default it is a single field.', 'wck' ) ),
124
  array( 'type' => 'select', 'title' => __( 'Sortable', 'wck' ), 'slug' => 'sortable', 'options' => array( 'true', 'false' ), 'default' => 'false', 'description' => __( 'Whether the entries are sortable or not. This is valid for repeater fields.', 'wck' ) ),
wck-template-api/wck-template-api-class.php CHANGED
@@ -98,7 +98,10 @@ class WCK_Template_API{
98
 
99
  foreach( $all_cfc as $post_id ) {
100
  $queried_meta_name = WCK_Template_API::get_meta('wck_cfc_args', $post_id );
101
- $queried_meta_name = $queried_meta_name[0]['meta-name'];
 
 
 
102
 
103
  if ( $meta_name == $queried_meta_name ) {
104
  $available_fields = WCK_Template_API::get_meta( 'wck_cfc_fields', $post_id );
98
 
99
  foreach( $all_cfc as $post_id ) {
100
  $queried_meta_name = WCK_Template_API::get_meta('wck_cfc_args', $post_id );
101
+ if( isset( $queried_meta_name[0]['meta-name'] ) )
102
+ $queried_meta_name = $queried_meta_name[0]['meta-name'];
103
+ else
104
+ $queried_meta_name = '';
105
 
106
  if ( $meta_name == $queried_meta_name ) {
107
  $available_fields = WCK_Template_API::get_meta( 'wck_cfc_fields', $post_id );
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.1.6
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: 1.1.7
7
  Author URI: http://www.cozmoslabs.com
8
 
9
  License: GPL2
wordpress-creation-kit-api/wck-fep/wck-fep.php CHANGED
@@ -714,7 +714,7 @@ class WCK_FEP_Dashboard{
714
  'author' => $user_id,
715
  'post_type' => $post_type->name
716
  );
717
- $posts = get_posts( $args );
718
 
719
  if( !empty( $posts ) )
720
  $dashboard .= '<li><a href="#fep-'. $post_type->name .'">'. __( 'My ', 'wck' ) .$post_type->label.'</a></li>';
@@ -733,7 +733,7 @@ class WCK_FEP_Dashboard{
733
  'author' => $user_id,
734
  'post_type' => $post_type->name
735
  );
736
- $posts = get_posts( $args );
737
  if( !empty( $posts ) ){
738
  $dashboard .= '<div id="fep-'. $post_type->name .'">';
739
  $dashboard .= '<h3 class="fep-'. $post_type->name .'">'. __( 'My ', 'wck' ) . $post_type->label .'</h3>';
714
  'author' => $user_id,
715
  'post_type' => $post_type->name
716
  );
717
+ $posts = get_posts( apply_filters( 'wck_fep_dashbord_get_posts_args', $args ) );
718
 
719
  if( !empty( $posts ) )
720
  $dashboard .= '<li><a href="#fep-'. $post_type->name .'">'. __( 'My ', 'wck' ) .$post_type->label.'</a></li>';
733
  'author' => $user_id,
734
  'post_type' => $post_type->name
735
  );
736
+ $posts = get_posts( apply_filters( 'wck_fep_dashbord_get_posts_args', $args ) );
737
  if( !empty( $posts ) ){
738
  $dashboard .= '<div id="fep-'. $post_type->name .'">';
739
  $dashboard .= '<h3 class="fep-'. $post_type->name .'">'. __( 'My ', 'wck' ) . $post_type->label .'</h3>';
wordpress-creation-kit-api/wordpress-creation-kit.js CHANGED
@@ -47,9 +47,12 @@ function addMeta(value, id, nonce){
47
  values[key.toString()] += ', ' + jQuery(this).val().toString();
48
  }
49
  }
50
-
51
- else
52
- values[key.toString()] = jQuery(this).val().toString();
 
 
 
53
  });
54
 
55
  meta = value;
@@ -304,9 +307,12 @@ function updateMeta(value, id, element_id, nonce){
304
  values[key.toString()] += ', ' + jQuery(this).val().toString();
305
  }
306
  }
307
-
308
- else
309
- values[key.toString()] = jQuery(this).val().toString();
 
 
 
310
 
311
  });
312
 
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
54
+ values[key.toString()] = '';
55
+ }
56
  });
57
 
58
  meta = value;
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();
313
+ else
314
+ values[key.toString()] = '';
315
+ }
316
 
317
  });
318
 
wordpress-creation-kit-api/wordpress-creation-kit.php CHANGED
@@ -306,9 +306,10 @@ class Wordpress_Creation_Kit{
306
  }
307
 
308
  $element .= '</div><!-- .mb-right-column -->';
309
-
 
310
  $element = apply_filters( "wck_output_form_field_{$meta}_" . Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ), $element );
311
-
312
  return $element;
313
 
314
  }
@@ -532,7 +533,9 @@ class Wordpress_Creation_Kit{
532
  $display_value = self::wck_get_entry_field_cpt_select( $value ) . '</pre>';
533
  } elseif ( $details['type'] == 'checkbox' && is_array( $value ) ){
534
  $display_value = implode( ', ', $value );
535
- } else {
 
 
536
  $display_value = '<pre>'.htmlspecialchars( $value ) . '</pre>';
537
  }
538
 
@@ -577,6 +580,29 @@ class Wordpress_Creation_Kit{
577
  return $list;
578
  }
579
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
580
  /* function to generate output for upload field */
581
  function wck_get_entry_field_upload($id){
582
  if( !empty ( $id ) && is_numeric( $id ) ){
@@ -1071,7 +1097,7 @@ class Wordpress_Creation_Kit{
1071
  foreach ($this->args['meta_array'] as $meta_field){
1072
  /* in the $_POST the names for the fields are prefixed with the meta_name for the single metaboxes in case there are multiple metaboxes that contain fields wit hthe same name */
1073
  $single_field_name = $this->args['meta_name'] .'_'. Wordpress_Creation_Kit::wck_generate_slug( $meta_field['title'], $meta_field );
1074
- if (!empty($_POST[$single_field_name])) {
1075
  /* checkbox needs to be stored as string not array */
1076
  if( $meta_field['type'] == 'checkbox' )
1077
  $_POST[$single_field_name] = implode( ', ', $_POST[$single_field_name] );
@@ -1132,7 +1158,7 @@ class Wordpress_Creation_Kit{
1132
  $error_messages .= $wck_single_forms_error['error'];
1133
  $error_fields .= implode( ',', $wck_single_forms_error['errorfields'] ).',';
1134
  }
1135
- wp_redirect( add_query_arg( array( 'wckerrormessages' => base64_encode( urlencode( $error_messages ) ), 'wckerrorfields' => base64_encode( urlencode( $error_fields ) ) ), $_SERVER["HTTP_REFERER"] ) );
1136
  exit;
1137
  }
1138
  }
@@ -1156,7 +1182,7 @@ class Wordpress_Creation_Kit{
1156
  echo '<script type="text/javascript">';
1157
  $field_names = explode( ',', urldecode( base64_decode( $_GET['wckerrorfields'] ) ) );
1158
  foreach( $field_names as $field_name ){
1159
- echo "jQuery( '.field-label[for=\"". $field_name ."\"]' ).addClass('error');";
1160
 
1161
  }
1162
  echo '</script>';
@@ -1164,7 +1190,7 @@ class Wordpress_Creation_Kit{
1164
 
1165
  /* alert the error messages */
1166
  if( isset( $_GET['wckerrormessages'] ) ){
1167
- echo '<script type="text/javascript">alert("'. urldecode( str_replace( '%0A', '\n', base64_decode( $_GET['wckerrormessages'] ) ) ) .'")</script>';
1168
  }
1169
  }
1170
 
306
  }
307
 
308
  $element .= '</div><!-- .mb-right-column -->';
309
+
310
+ $element = apply_filters( "wck_output_form_field", $element, $meta, $details);
311
  $element = apply_filters( "wck_output_form_field_{$meta}_" . Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ), $element );
312
+
313
  return $element;
314
 
315
  }
533
  $display_value = self::wck_get_entry_field_cpt_select( $value ) . '</pre>';
534
  } elseif ( $details['type'] == 'checkbox' && is_array( $value ) ){
535
  $display_value = implode( ', ', $value );
536
+ } elseif ( $details['type'] == 'select' ){
537
+ $display_value = '<pre>' . __(self::wck_get_entry_field_select( $value, $details ), 'profilebuilder') . '</pre>';
538
+ }else {
539
  $display_value = '<pre>'.htmlspecialchars( $value ) . '</pre>';
540
  }
541
 
580
  return $list;
581
  }
582
 
583
+ /* function to generate the output for the select field */
584
+ function wck_get_entry_field_select( $value, $field_details ){
585
+ if ( (!is_array( $field_details ) && !isset( $field_details['options']) ) || empty( $value )){
586
+ return $value;
587
+ }
588
+
589
+ foreach( $field_details['options'] as $option ){
590
+ if ( strpos( $option, $value ) !== false ){
591
+ if( strpos( $option, '%' ) === false ){
592
+ return $value;
593
+ } else {
594
+ $option_parts = explode( '%', $option );
595
+ if( !empty( $option_parts ) ){
596
+ if( empty( $option_parts[0] ) && count( $option_parts ) == 3 ){
597
+ $label = $option_parts[1];
598
+ return $label;
599
+ }
600
+ }
601
+ }
602
+ }
603
+ }
604
+ }
605
+
606
  /* function to generate output for upload field */
607
  function wck_get_entry_field_upload($id){
608
  if( !empty ( $id ) && is_numeric( $id ) ){
1097
  foreach ($this->args['meta_array'] as $meta_field){
1098
  /* in the $_POST the names for the fields are prefixed with the meta_name for the single metaboxes in case there are multiple metaboxes that contain fields wit hthe same name */
1099
  $single_field_name = $this->args['meta_name'] .'_'. Wordpress_Creation_Kit::wck_generate_slug( $meta_field['title'], $meta_field );
1100
+ if (isset($_POST[$single_field_name])) {
1101
  /* checkbox needs to be stored as string not array */
1102
  if( $meta_field['type'] == 'checkbox' )
1103
  $_POST[$single_field_name] = implode( ', ', $_POST[$single_field_name] );
1158
  $error_messages .= $wck_single_forms_error['error'];
1159
  $error_fields .= implode( ',', $wck_single_forms_error['errorfields'] ).',';
1160
  }
1161
+ wp_safe_redirect( add_query_arg( array( 'wckerrormessages' => base64_encode( urlencode( $error_messages ) ), 'wckerrorfields' => base64_encode( urlencode( $error_fields ) ) ), $_SERVER["HTTP_REFERER"] ) );
1162
  exit;
1163
  }
1164
  }
1182
  echo '<script type="text/javascript">';
1183
  $field_names = explode( ',', urldecode( base64_decode( $_GET['wckerrorfields'] ) ) );
1184
  foreach( $field_names as $field_name ){
1185
+ echo "jQuery( '.field-label[for=\"". esc_js( $field_name ) ."\"]' ).addClass('error');";
1186
 
1187
  }
1188
  echo '</script>';
1190
 
1191
  /* alert the error messages */
1192
  if( isset( $_GET['wckerrormessages'] ) ){
1193
+ echo '<script type="text/javascript">alert("'. str_replace( '%0A', '\n', esc_js( urldecode( base64_decode( $_GET['wckerrormessages'] ) ) ) ) .'")</script>';
1194
  }
1195
  }
1196