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

Version Description

  • All WCK meta keys are now protected so they do not appear in WordPress Custom Fields box which fixes some issues
  • We now can translate WCK labels with string translation in WPML (this includes Front end Posting labels)
  • Fixed a small css bug
Download this release

Release Info

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

Code changes from version 2.0.9 to 2.1.0

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.3
9
- Stable tag: 2.0.9
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -139,6 +139,11 @@ Creating a taxonomy generally automatically creates a special query variable usi
139
  10. Taxonomy listing
140
 
141
  == Changelog ==
 
 
 
 
 
142
  = 2.0.9 =
143
  * Security improvements
144
  * Small css change for labels in metaboxes
6
 
7
  Requires at least: 3.1
8
  Tested up to: 4.7.3
9
+ Stable tag: 2.1.0
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.0 =
143
+ * All WCK meta keys are now protected so they do not appear in WordPress Custom Fields box which fixes some issues
144
+ * We now can translate WCK labels with string translation in WPML (this includes Front end Posting labels)
145
+ * Fixed a small css bug
146
+
147
  = 2.0.9 =
148
  * Security improvements
149
  * Small css change for labels in metaboxes
wck-cfc.php CHANGED
@@ -181,7 +181,7 @@ function wck_cfc_create_box(){
181
  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 ),
182
  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 ),
183
  array( 'type' => 'text', 'title' => __( 'Map Height', 'wck' ), 'slug' => 'map-height', 'description' => __( 'The height of the map.', 'wck' ), 'default' => 350 ),
184
- array( 'type' => 'select', 'title' => __( 'Date Format', 'wck' ), 'slug' => 'date-format', 'description' => __( 'The format of the datepicker date', 'wck' ), 'options' => array( '%Default - dd-mm-yy%dd-mm-yy', '%Datepicker default - mm/dd/yy%mm/dd/yy', '%ISO 8601 - yy-mm-dd%yy-mm-dd', '%Short - d M, y%d M, y', '%Medium - d MM, y%d MM, y', '%Full - DD, d MM, yy%DD, d MM, yy', '%With text - \'day\' d \'of\' MM \'in the year\' yy%\'day\' d \'of\' MM \'in the year\' yy' ), 'default' => 'dd-mm-yy' ),
185
  ));
186
 
187
 
@@ -1039,7 +1039,7 @@ function wck_cfc_process_unserialized_batch() {
1039
  }
1040
 
1041
  ignore_user_abort( true );
1042
- @set_time_limit( 0 );
1043
 
1044
  /* set number of posts that are processed in a batch !IMPORTANT IT IS ALSO SET IN THE wck_unserialized_page_callback() FUNCTION */
1045
  $per_batch = 30;
@@ -1178,7 +1178,7 @@ function wck_cpt_save_meta_boxes_ids( $post_id ){
1178
  }
1179
  }
1180
  }
1181
-
1182
  update_option( 'wck_meta_boxes_ids', $wck_meta_boxes_ids );
1183
  }
1184
 
@@ -1253,4 +1253,23 @@ function wck_serialized_update_from_unserialized( $replace, $object_id, $meta_ke
1253
 
1254
  return $replace;
1255
  }
1256
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  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 ),
182
  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 ),
183
  array( 'type' => 'text', 'title' => __( 'Map Height', 'wck' ), 'slug' => 'map-height', 'description' => __( 'The height of the map.', 'wck' ), 'default' => 350 ),
184
+ array( 'type' => 'select', 'title' => __( 'Date Format', 'wck' ), 'slug' => 'date-format', 'description' => __( 'The format of the datepicker date', 'wck' ), 'options' => array( '%Default - dd-mm-yy%dd-mm-yy', '%Datepicker default - mm/dd/yy%mm/dd/yy', '%ISO 8601 (extended) - yy-mm-dd%yy-mm-dd', '%ISO 8601 (basic) - yymmdd%yymmdd', '%Short - d M, y%d M, y', '%Medium - d MM, y%d MM, y', '%Full - DD, d MM, yy%DD, d MM, yy', '%With text - \'day\' d \'of\' MM \'in the year\' yy%\'day\' d \'of\' MM \'in the year\' yy' ), 'default' => 'dd-mm-yy' ),
185
  ));
186
 
187
 
1039
  }
1040
 
1041
  ignore_user_abort( true );
1042
+ @set_time_limit( 0 );
1043
 
1044
  /* set number of posts that are processed in a batch !IMPORTANT IT IS ALSO SET IN THE wck_unserialized_page_callback() FUNCTION */
1045
  $per_batch = 30;
1178
  }
1179
  }
1180
  }
1181
+
1182
  update_option( 'wck_meta_boxes_ids', $wck_meta_boxes_ids );
1183
  }
1184
 
1253
 
1254
  return $replace;
1255
  }
1256
+
1257
+ /* make wck meta names protected so they are not saved by custom fields */
1258
+ add_filter( 'is_protected_meta', 'wck_cfc_protect_meta_keys', 10, 3 );
1259
+ function wck_cfc_protect_meta_keys( $protected, $meta_key, $meta_type ){
1260
+ global $wck_objects, $post;
1261
+ if( !empty( $wck_objects ) ){
1262
+ foreach( $wck_objects as $wck_object ){
1263
+ if( !empty( $wck_object['meta_array'] ) ){
1264
+ foreach ( $wck_object['meta_array'] as $field ){
1265
+ $field_meta_key = Wordpress_Creation_Kit::wck_generate_slug( $field['title'], $field );
1266
+ /* take care of suffixes with pregmatch and we could also have the group name as a prefix to be unique */
1267
+ if ( $meta_key == $field_meta_key || preg_match( '/'.$field_meta_key.'_\d+\z/', $meta_key ) || $meta_key == $wck_object['meta_name'].'_'.$field_meta_key || preg_match( '/'.$wck_object['meta_name'].'_'.$field_meta_key.'_\d+\z/', $meta_key ) )
1268
+ return true;
1269
+ }
1270
+ }
1271
+ }
1272
+ }
1273
+ return $protected;
1274
+ }
1275
+ ?>
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.9
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.0
7
  Author URI: http://www.cozmoslabs.com
8
 
9
  License: GPL2
wordpress-creation-kit-api/wck-fep/wck-fep.php CHANGED
@@ -433,7 +433,12 @@ class WCK_FrontEnd_Posting extends Wordpress_Creation_Kit{
433
  $submit_text = apply_filters( 'wck_fep_form_button_update', __( 'Update Post', 'wck' ), $form_name );
434
  else
435
  $submit_text = apply_filters( 'wck_fep_form_button_add', __( 'Add Post', 'wck' ), $form_name );
436
-
 
 
 
 
 
437
  $form .= '<input type="submit" id="submit_'.$form_name.'" value="'. $submit_text .'" onclick="wckFepAddPost(\''. $form_name .'\', '. $post_id .', \''. $action .'\', \''. $nonce .'\');return false;"/>';
438
 
439
  $form .= '</form>';
@@ -552,6 +557,14 @@ class WCK_FrontEnd_Posting extends Wordpress_Creation_Kit{
552
  if( !empty( $single_cfcs ) ){
553
  foreach( $single_cfcs as $meta_name => $single_values ){
554
  update_post_meta( $post_ID, $meta_name, array( $single_values ) );
 
 
 
 
 
 
 
 
555
 
556
  /* if unserialize_fields is true add for each entry separate post meta for every element of the form */
557
  if( $this->single_cfcs[$meta_name.'_unserialize_fields'] ){
@@ -695,9 +708,16 @@ class WCK_FrontEnd_Posting extends Wordpress_Creation_Kit{
695
  do_action( 'wck_fep_update_post', $wck_fep_new_post, get_current_user_id() );
696
 
697
  if( $action_type == '' )
698
- echo apply_filters( 'wck_fep_post_added_message', __( 'Post Added', 'wck' ), $meta );
699
  else if( $action_type == 'edit' )
700
- echo apply_filters( 'wck_fep_post_updated_message', __( 'Post Updated', 'wck' ), $meta );
 
 
 
 
 
 
 
701
 
702
  die();
703
  }
433
  $submit_text = apply_filters( 'wck_fep_form_button_update', __( 'Update Post', 'wck' ), $form_name );
434
  else
435
  $submit_text = apply_filters( 'wck_fep_form_button_add', __( 'Add Post', 'wck' ), $form_name );
436
+
437
+ if (function_exists('icl_register_string') && function_exists('icl_translate') ) {
438
+ icl_register_string( 'plugin wck', 'wck_label_translation_'.Wordpress_Creation_Kit::wck_generate_slug( $submit_text ), $submit_text );
439
+ $submit_text = icl_translate( 'plugin wck', 'wck_label_translation_'.Wordpress_Creation_Kit::wck_generate_slug( $submit_text ), $submit_text );
440
+ }
441
+
442
  $form .= '<input type="submit" id="submit_'.$form_name.'" value="'. $submit_text .'" onclick="wckFepAddPost(\''. $form_name .'\', '. $post_id .', \''. $action .'\', \''. $nonce .'\');return false;"/>';
443
 
444
  $form .= '</form>';
557
  if( !empty( $single_cfcs ) ){
558
  foreach( $single_cfcs as $meta_name => $single_values ){
559
  update_post_meta( $post_ID, $meta_name, array( $single_values ) );
560
+
561
+ if (!empty($single_values)) {
562
+ foreach ($single_values as $name => $value) {
563
+ /* check to see if we already have a meta name like this from the old structure to avoid conflicts */
564
+ $name = Wordpress_Creation_Kit::wck_generate_unique_meta_name_for_unserialized_field( $post_ID, $name, $meta_name );
565
+ update_post_meta($post_ID, $name, $value);
566
+ }
567
+ }
568
 
569
  /* if unserialize_fields is true add for each entry separate post meta for every element of the form */
570
  if( $this->single_cfcs[$meta_name.'_unserialize_fields'] ){
708
  do_action( 'wck_fep_update_post', $wck_fep_new_post, get_current_user_id() );
709
 
710
  if( $action_type == '' )
711
+ $message = apply_filters( 'wck_fep_post_added_message', __( 'Post Added', 'wck' ), $meta );
712
  else if( $action_type == 'edit' )
713
+ $message = apply_filters( 'wck_fep_post_updated_message', __( 'Post Updated', 'wck' ), $meta );
714
+
715
+ if (function_exists('icl_register_string') && function_exists('icl_translate') ) {
716
+ icl_register_string( 'plugin wck', 'wck_label_translation_'.Wordpress_Creation_Kit::wck_generate_slug( $message ), $message );
717
+ $message = icl_translate( 'plugin wck', 'wck_label_translation_'.Wordpress_Creation_Kit::wck_generate_slug( $message ), $message );
718
+ }
719
+
720
+ echo $message;
721
 
722
  die();
723
  }
wordpress-creation-kit-api/wordpress-creation-kit.css CHANGED
@@ -25,6 +25,10 @@
25
  min-width:100px;
26
  }
27
 
 
 
 
 
28
  .field-label.error{
29
  color:#ff0000;
30
  }
25
  min-width:100px;
26
  }
27
 
28
+ #container_post_detail strong{
29
+ min-width:70px;
30
+ }
31
+
32
  .field-label.error{
33
  color:#ff0000;
34
  }
wordpress-creation-kit-api/wordpress-creation-kit.php CHANGED
@@ -287,7 +287,12 @@ class Wordpress_Creation_Kit{
287
  $single_prefix = '';
288
 
289
  if( $details['type'] !== 'heading' && $details['type'] !== 'html' ) {
290
- $element .= '<label for="'. $single_prefix . esc_attr( Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ) ) .'" class="field-label">'. apply_filters( "wck_label_{$meta}_". Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ), ucfirst($details['title']) ) .':';
 
 
 
 
 
291
  if( !empty( $details['required'] ) && $details['required'] )
292
  $element .= '<span class="required">*</span>';
293
  $element .= '</label>';
@@ -1592,7 +1597,7 @@ class Wordpress_Creation_Kit{
1592
  }
1593
 
1594
 
1595
- function wck_get_meta_boxes( $screen = null ){
1596
  global $wp_meta_boxes, $wck_objects;
1597
 
1598
  if ( empty( $screen ) )
287
  $single_prefix = '';
288
 
289
  if( $details['type'] !== 'heading' && $details['type'] !== 'html' ) {
290
+ $details['title'] = apply_filters( "wck_label_{$meta}_". Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ), $details['title'] );
291
+ if (function_exists('icl_register_string') && function_exists('icl_translate') ) {
292
+ icl_register_string( 'plugin wck', 'wck_label_translation_'.Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ), $details['title'] );
293
+ $details['title'] = icl_translate( 'plugin wck', 'wck_label_translation_'.Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ), $details['title'] );
294
+ }
295
+ $element .= '<label for="'. $single_prefix . esc_attr( Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details ) ) .'" class="field-label">'. ucfirst( $details['title'] ) .':';
296
  if( !empty( $details['required'] ) && $details['required'] )
297
  $element .= '<span class="required">*</span>';
298
  $element .= '</label>';
1597
  }
1598
 
1599
 
1600
+ static function wck_get_meta_boxes( $screen = null ){
1601
  global $wp_meta_boxes, $wck_objects;
1602
 
1603
  if ( empty( $screen ) )