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

Version Description

  • Improved speed on sites with a lot of Custom Fields Metaboxes defined
  • Fixed some php notices
Download this release

Release Info

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

Code changes from version 2.1.3 to 2.1.4

readme.txt CHANGED
@@ -1,12 +1,10 @@
1
  === Custom Post Types and Custom Fields creator - WCK ===
2
-
3
  Contributors: cozmoslabs, reflectionmedia, madalin.ungureanu, sareiodata, adispiac
4
  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.8.2
9
- Stable tag: 2.1.3
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -139,6 +137,10 @@ Creating a taxonomy generally automatically creates a special query variable usi
139
  10. Taxonomy listing
140
 
141
  == Changelog ==
 
 
 
 
142
  = 2.1.3 =
143
  * Added filter 'wck_extra_field_attributes' which with you can add extra attributes to fields
144
  * Fixed the start page css
1
  === Custom Post Types and Custom Fields creator - WCK ===
 
2
  Contributors: cozmoslabs, reflectionmedia, madalin.ungureanu, sareiodata, adispiac
3
  Donate link: http://www.cozmoslabs.com/wordpress-creation-kit/
4
  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
 
5
  Requires at least: 3.1
6
+ Tested up to: 4.9.0
7
+ Stable tag: 2.1.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
137
  10. Taxonomy listing
138
 
139
  == Changelog ==
140
+ = 2.1.4 =
141
+ * Improved speed on sites with a lot of Custom Fields Metaboxes defined
142
+ * Fixed some php notices
143
+
144
  = 2.1.3 =
145
  * Added filter 'wck_extra_field_attributes' which with you can add extra attributes to fields
146
  * Fixed the start page css
wck-cfc.php CHANGED
@@ -231,6 +231,13 @@ function wck_cfc_after_refresh_list(){
231
  add_action( 'admin_init', 'wck_cfc_create_boxes' );
232
 
233
  function wck_cfc_create_boxes_args(){
 
 
 
 
 
 
 
234
  $args = array(
235
  'post_type' => 'wck-meta-box',
236
  'numberposts' => -1
@@ -238,8 +245,6 @@ function wck_cfc_create_boxes_args(){
238
 
239
  $all_meta_boxes = get_posts( $args );
240
 
241
- $all_box_args = array();
242
-
243
  if( !empty( $all_meta_boxes ) ){
244
  foreach( $all_meta_boxes as $meta_box ){
245
  $wck_cfc_args = get_post_meta( $meta_box->ID, 'wck_cfc_args', true );
@@ -385,6 +390,7 @@ function wck_cfc_create_boxes_args(){
385
  }
386
  }
387
  }
 
388
  return $all_box_args;
389
  }
390
 
@@ -865,13 +871,13 @@ function wck_cfc_make_options_required( $meta_array, $meta, $values, $id ) {
865
  }
866
 
867
  foreach( $meta_array as $key => $field ) {
868
- if( $field['type'] == 'phone' ) {
869
  $meta_array[$key]['required'] ? $meta_array[$key]['was_required'] = true : $meta_array[$key]['was_required'] = false;
870
  $meta_array[$key]['required'] = true;
871
  add_filter( "wck_required_test_{$meta}_" . Wordpress_Creation_Kit::wck_generate_slug( $field['title'], $field ), 'wck_phone_field_error', 10, 6 );
872
  }
873
 
874
- if( $field['type'] == 'number' ) {
875
  $meta_array[$key]['required'] ? $meta_array[$key]['was_required'] = true : $meta_array[$key]['was_required'] = false;
876
  $meta_array[$key]['required'] = true;
877
  add_filter( "wck_required_test_{$meta}_" . Wordpress_Creation_Kit::wck_generate_slug( $field['title'], $field ), 'wck_number_field_error', 10, 6 );
@@ -975,12 +981,12 @@ function wck_number_field_error( $bool, $value, $id, $field, $meta, $fields ) {
975
  return true;
976
  }
977
 
978
- if( ( ! empty( $field_array['min-number-value'] ) || $field_array['min-number-value'] == '0' ) && ( ! empty( $value ) || $value == '0' ) && $value < $field_array['min-number-value'] ) {
979
  add_filter( "wck_required_message_{$meta}_{$field_slug}", create_function( '$message, $value, $required_field', '$number_min = '. $field_array['min-number-value'] .'; $message = apply_filters( "wck_number_error_message", "$required_field" . __( " field value must be greater than or equal to ", "wck" ) . "$number_min \n" ); return $message;' ), 10, 3 );
980
  return true;
981
  }
982
 
983
- if( ( ! empty( $field_array['max-number-value'] ) || $field_array['max-number-value'] == '0' ) && ( ! empty( $value ) || $value == '0' ) && $value > $field_array['max-number-value'] ) {
984
  add_filter( "wck_required_message_{$meta}_{$field_slug}", create_function( '$message, $value, $required_field', '$number_max = '. $field_array['max-number-value'] .'; $message = apply_filters( "wck_number_error_message", "$required_field" . __( " field value must be less than or equal to ", "wck" ) . "$number_max \n" ); return $message;' ), 10, 3 );
985
  return true;
986
  }
231
  add_action( 'admin_init', 'wck_cfc_create_boxes' );
232
 
233
  function wck_cfc_create_boxes_args(){
234
+ $all_box_args = wp_cache_get( 'wck_all_box_args', 'wck' );
235
+
236
+ if ( $all_box_args !== false )
237
+ return $all_box_args;
238
+
239
+ $all_box_args = array();
240
+
241
  $args = array(
242
  'post_type' => 'wck-meta-box',
243
  'numberposts' => -1
245
 
246
  $all_meta_boxes = get_posts( $args );
247
 
 
 
248
  if( !empty( $all_meta_boxes ) ){
249
  foreach( $all_meta_boxes as $meta_box ){
250
  $wck_cfc_args = get_post_meta( $meta_box->ID, 'wck_cfc_args', true );
390
  }
391
  }
392
  }
393
+ wp_cache_set( 'wck_all_box_args', $all_box_args, 'wck');
394
  return $all_box_args;
395
  }
396
 
871
  }
872
 
873
  foreach( $meta_array as $key => $field ) {
874
+ if( isset( $field['type'] ) && $field['type'] == 'phone' ) {
875
  $meta_array[$key]['required'] ? $meta_array[$key]['was_required'] = true : $meta_array[$key]['was_required'] = false;
876
  $meta_array[$key]['required'] = true;
877
  add_filter( "wck_required_test_{$meta}_" . Wordpress_Creation_Kit::wck_generate_slug( $field['title'], $field ), 'wck_phone_field_error', 10, 6 );
878
  }
879
 
880
+ if( isset( $field['type'] ) && $field['type'] == 'number' ) {
881
  $meta_array[$key]['required'] ? $meta_array[$key]['was_required'] = true : $meta_array[$key]['was_required'] = false;
882
  $meta_array[$key]['required'] = true;
883
  add_filter( "wck_required_test_{$meta}_" . Wordpress_Creation_Kit::wck_generate_slug( $field['title'], $field ), 'wck_number_field_error', 10, 6 );
981
  return true;
982
  }
983
 
984
+ if( ( ! empty( $field_array['min-number-value'] ) || (isset($field_array['min-number-value']) && $field_array['min-number-value'] == '0' )) && ( ! empty( $value ) || $value == '0' ) && $value < $field_array['min-number-value'] ) {
985
  add_filter( "wck_required_message_{$meta}_{$field_slug}", create_function( '$message, $value, $required_field', '$number_min = '. $field_array['min-number-value'] .'; $message = apply_filters( "wck_number_error_message", "$required_field" . __( " field value must be greater than or equal to ", "wck" ) . "$number_min \n" ); return $message;' ), 10, 3 );
986
  return true;
987
  }
988
 
989
+ if( ( ! empty( $field_array['max-number-value'] ) || (isset($field_array['max-number-value']) && $field_array['max-number-value'] == '0' )) && ( ! empty( $value ) || $value == '0' ) && $value > $field_array['max-number-value'] ) {
990
  add_filter( "wck_required_message_{$meta}_{$field_slug}", create_function( '$message, $value, $required_field', '$number_max = '. $field_array['max-number-value'] .'; $message = apply_filters( "wck_number_error_message", "$required_field" . __( " field value must be less than or equal to ", "wck" ) . "$number_max \n" ); return $message;' ), 10, 3 );
991
  return true;
992
  }
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.3
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.4
7
  Author URI: http://www.cozmoslabs.com
8
 
9
  License: GPL2
wordpress-creation-kit-api/wck-fep/wck-fep.php CHANGED
@@ -498,7 +498,7 @@ class WCK_FrontEnd_Posting extends Wordpress_Creation_Kit{
498
  }
499
  else{
500
  $meta_values = get_post_meta( $post_id, $meta_name, true );
501
- if( !empty( $meta_values ) )
502
  $value = $meta_values[0][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )];
503
  }
504
 
498
  }
499
  else{
500
  $meta_values = get_post_meta( $post_id, $meta_name, true );
501
+ if( isset( $meta_values[0][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )] ) )
502
  $value = $meta_values[0][Wordpress_Creation_Kit::wck_generate_slug( $details['title'], $details )];
503
  }
504