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

Version Description

  • We now load the translation files from the theme first if they exist in the folder:local_wck_lang
  • Now in Custom Fields Creator the Options field for selects,radios and checkboxes is required so you can't create those field without any options
  • Single forms now keep their values when form throws alert required message so you don't have to input the values again
Download this release

Release Info

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

Code changes from version 1.2.3 to 1.2.4

readme.txt CHANGED
@@ -6,13 +6,15 @@ Tags: custom fields, custom field, wordpress custom fields, advanced custom fiel
6
 
7
  Requires at least: 3.1
8
  Tested up to: 4.4.2
9
- Stable tag: 1.2.3
10
 
11
  A must have tool for creating custom fields, custom post types and taxonomies, fast and without any programming knowledge.
12
 
13
 
14
  == Description ==
15
 
 
 
16
  **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.
17
 
18
  **WCK Custom Fields Creator** offers an UI for setting up custom meta boxes with custom fields for your posts, pages or custom post types. Uses standard custom fields to store data.
@@ -141,6 +143,11 @@ Creating a taxonomy generally automatically creates a special query variable usi
141
  10. Taxonomy listing
142
 
143
  == Changelog ==
 
 
 
 
 
144
  = 1.2.3 =
145
  * Minor security improvements
146
  * Added filter for the 'rewrite' argument in the Custom Taxonomy Creator: 'wck_ctc_register_taxonomy_rewrite_arg'
6
 
7
  Requires at least: 3.1
8
  Tested up to: 4.4.2
9
+ Stable tag: 1.2.4
10
 
11
  A must have tool for creating custom fields, custom post types and taxonomies, fast and without any programming knowledge.
12
 
13
 
14
  == Description ==
15
 
16
+ **Like this plugin?** Consider leaving a [5 star review](https://wordpress.org/support/view/plugin-reviews/wck-custom-fields-and-custom-post-types-creator?filter=5).
17
+
18
  **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.
19
 
20
  **WCK Custom Fields Creator** offers an UI for setting up custom meta boxes with custom fields for your posts, pages or custom post types. Uses standard custom fields to store data.
143
  10. Taxonomy listing
144
 
145
  == Changelog ==
146
+ = 1.2.4 =
147
+ * We now load the translation files from the theme first if they exist in the folder:local_wck_lang
148
+ * Now in Custom Fields Creator the Options field for selects,radios and checkboxes is required so you can't create those field without any options
149
+ * Single forms now keep their values when form throws alert required message so you don't have to input the values again
150
+
151
  = 1.2.3 =
152
  * Minor security improvements
153
  * Added filter for the 'rewrite' argument in the Custom Taxonomy Creator: 'wck_ctc_register_taxonomy_rewrite_arg'
wck-cfc.php CHANGED
@@ -649,4 +649,19 @@ function wck_cfc_filter_field_types( $field_types ){
649
 
650
  return $field_types;
651
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
652
  ?>
649
 
650
  return $field_types;
651
  }
652
+
653
+ /* Mark as required the 'Options' field for checkboxes, radios, selects .. */
654
+ add_filter( 'wck_before_test_required', 'wck_cfc_make_options_required', 10, 4 );
655
+ function wck_cfc_make_options_required( $meta_array, $meta, $values, $id ){
656
+ if( $meta == 'wck_cfc_fields' ){
657
+ if( $values['field-type'] == 'select' || $values['field-type'] == 'radio' || $values['field-type'] == 'checkbox' ){
658
+ foreach( $meta_array as $key => $field ){
659
+ if( $field['slug'] == 'options' ){
660
+ $meta_array[$key]['required'] = true;
661
+ }
662
+ }
663
+ }
664
+ }
665
+ return $meta_array;
666
+ }
667
  ?>
wck-template-api/wck-field-preprocess.php CHANGED
@@ -66,7 +66,7 @@ function wck_preprocess_the_field_checkbox( $field ){
66
 
67
  /**
68
  * Preprocess the upload field types.
69
- * We're returnig an array for images and an object for normal files
70
  *
71
  * @since 1.1.5
72
  *
@@ -75,7 +75,7 @@ function wck_preprocess_the_field_checkbox( $field ){
75
  */
76
  add_filter( 'wck_output_get_field_upload', 'wck_preprocess_field_upload', 10 );
77
  function wck_preprocess_field_upload( $field ){
78
-
79
  if ( $field == '' || !is_numeric( $field ) )
80
  return false;
81
 
@@ -85,7 +85,7 @@ function wck_preprocess_field_upload( $field ){
85
  if ( wp_attachment_is_image( $field ) ) {
86
 
87
  $attachment = get_post( $field );
88
-
89
  // create array to hold value data
90
  $src = wp_get_attachment_image_src( $attachment->ID, 'full' );
91
 
66
 
67
  /**
68
  * Preprocess the upload field types.
69
+ * We're returning an array for images and an object for normal files
70
  *
71
  * @since 1.1.5
72
  *
75
  */
76
  add_filter( 'wck_output_get_field_upload', 'wck_preprocess_field_upload', 10 );
77
  function wck_preprocess_field_upload( $field ){
78
+
79
  if ( $field == '' || !is_numeric( $field ) )
80
  return false;
81
 
85
  if ( wp_attachment_is_image( $field ) ) {
86
 
87
  $attachment = get_post( $field );
88
+
89
  // create array to hold value data
90
  $src = wp_get_attachment_image_src( $attachment->ID, 'full' );
91
 
wck-template-api/wck-template-api-class.php CHANGED
@@ -74,7 +74,7 @@ class WCK_Template_API{
74
 
75
  // use this filter to modify the return var in order to output text, arrays or objects
76
  $output = apply_filters('wck_output_get_field_' . $field_type, $post_meta[$key][$field_name] );
77
-
78
  return $output;
79
  }
80
  return '';
74
 
75
  // use this filter to modify the return var in order to output text, arrays or objects
76
  $output = apply_filters('wck_output_get_field_' . $field_type, $post_meta[$key][$field_name] );
77
+
78
  return $output;
79
  }
80
  return '';
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.3
7
  Author URI: http://www.cozmoslabs.com
8
 
9
  License: GPL2
@@ -27,7 +27,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
  define( 'WCK_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) );
28
 
29
  /* ready for localization */
30
- load_plugin_textdomain( 'wck', false, basename( dirname( __FILE__ ) ) . '/languages' );
 
 
 
 
 
31
 
32
 
33
  /* include Custom Fields Creator API */
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.4
7
  Author URI: http://www.cozmoslabs.com
8
 
9
  License: GPL2
27
  define( 'WCK_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) );
28
 
29
  /* ready for localization */
30
+ $current_theme = wp_get_theme();
31
+ if( !empty( $current_theme->stylesheet ) && file_exists( get_theme_root().'/'. $current_theme->stylesheet .'/local_wck_lang' ) )
32
+ load_plugin_textdomain( 'wck', false, basename( dirname( __FILE__ ) ).'/../../themes/'.$current_theme->stylesheet.'/local_wck_lang' );
33
+ else
34
+ load_plugin_textdomain( 'wck', false, basename( dirname( __FILE__ ) ) . '/languages' );
35
+
36
 
37
 
38
  /* include Custom Fields Creator API */
wordpress-creation-kit-api/wordpress-creation-kit.php CHANGED
@@ -361,7 +361,12 @@ class Wordpress_Creation_Kit{
361
  $value = '';
362
  if( $this->args['single'] == true ) {
363
  $value = null;
364
- if( !empty( $results[0] ) && !empty( $results[0][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )] ) )
 
 
 
 
 
365
  $value = $results[0][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )];
366
  }
367
 
@@ -720,7 +725,7 @@ class Wordpress_Creation_Kit{
720
 
721
  /* Helper function for required fields */
722
  function wck_test_required( $meta_array, $meta, $values, $id ){
723
- $fields = $meta_array;
724
  $required_fields = array();
725
  $required_fields_with_errors = array();
726
  $required_message = '';
@@ -1117,12 +1122,14 @@ class Wordpress_Creation_Kit{
1117
  if( !empty( $errors ) ){
1118
  /* if we have errors then add them in the global. We do this so we get all errors from all single metaboxes that might be on that page */
1119
  global $wck_single_forms_errors;
 
1120
  if( !empty( $errors['errorfields'] ) ){
1121
  foreach( $errors['errorfields'] as $key => $field_name ){
1122
  $errors['errorfields'][$key] = $this->args['meta_name']. '_' .$field_name;
1123
  }
1124
  }
1125
  $wck_single_forms_errors[] = $errors;
 
1126
  }
1127
  else {
1128
 
@@ -1154,6 +1161,7 @@ class Wordpress_Creation_Kit{
1154
  */
1155
  function wck_single_metabox_redirect_if_errors( $post_id, $post ){
1156
  global $wck_single_forms_errors;
 
1157
  if( !empty( $wck_single_forms_errors ) ) {
1158
  $error_messages = '';
1159
  $error_fields = '';
@@ -1161,7 +1169,7 @@ class Wordpress_Creation_Kit{
1161
  $error_messages .= $wck_single_forms_error['error'];
1162
  $error_fields .= implode( ',', $wck_single_forms_error['errorfields'] ).',';
1163
  }
1164
- wp_safe_redirect( add_query_arg( array( 'wckerrormessages' => base64_encode( urlencode( $error_messages ) ), 'wckerrorfields' => base64_encode( urlencode( $error_fields ) ) ), $_SERVER["HTTP_REFERER"] ) );
1165
  exit;
1166
  }
1167
  }
361
  $value = '';
362
  if( $this->args['single'] == true ) {
363
  $value = null;
364
+ /* see if we have any posted values */
365
+ if( !empty( $_GET['postedvalues'] ) ){
366
+ $posted_values = unserialize( urldecode( base64_decode( $_GET['postedvalues'] ) ) );
367
+ $value = $posted_values[$meta][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )];
368
+ }
369
+ else if( !empty( $results[0] ) && !empty( $results[0][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )] ) )
370
  $value = $results[0][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )];
371
  }
372
 
725
 
726
  /* Helper function for required fields */
727
  function wck_test_required( $meta_array, $meta, $values, $id ){
728
+ $fields = apply_filters( 'wck_before_test_required', $meta_array, $meta, $values, $id );
729
  $required_fields = array();
730
  $required_fields_with_errors = array();
731
  $required_message = '';
1122
  if( !empty( $errors ) ){
1123
  /* if we have errors then add them in the global. We do this so we get all errors from all single metaboxes that might be on that page */
1124
  global $wck_single_forms_errors;
1125
+ global $wck_single_forms_posted_values;
1126
  if( !empty( $errors['errorfields'] ) ){
1127
  foreach( $errors['errorfields'] as $key => $field_name ){
1128
  $errors['errorfields'][$key] = $this->args['meta_name']. '_' .$field_name;
1129
  }
1130
  }
1131
  $wck_single_forms_errors[] = $errors;
1132
+ $wck_single_forms_posted_values[$meta_name] = $meta_values;
1133
  }
1134
  else {
1135
 
1161
  */
1162
  function wck_single_metabox_redirect_if_errors( $post_id, $post ){
1163
  global $wck_single_forms_errors;
1164
+ global $wck_single_forms_posted_values;
1165
  if( !empty( $wck_single_forms_errors ) ) {
1166
  $error_messages = '';
1167
  $error_fields = '';
1169
  $error_messages .= $wck_single_forms_error['error'];
1170
  $error_fields .= implode( ',', $wck_single_forms_error['errorfields'] ).',';
1171
  }
1172
+ wp_safe_redirect( add_query_arg( array( 'wckerrormessages' => base64_encode( urlencode( $error_messages ) ), 'wckerrorfields' => base64_encode( urlencode( $error_fields ) ), 'postedvalues' => base64_encode( urlencode( serialize( $wck_single_forms_posted_values ) ) ) ), $_SERVER["HTTP_REFERER"] ) );
1173
  exit;
1174
  }
1175
  }