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

Version Description

  • Added filter for the arguments passed to the register_post_type() funtion when creating a Custom Post Type. ( "wck_cptc_register_post_type_args" )
  • Fixed the missing datepicker css 404 error.
  • Removed notices
  • Fixed "Attach upload to post" option for the upload field.
Download this release

Release Info

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

Code changes from version 1.0.9 to 1.1.0

readme.txt CHANGED
@@ -6,7 +6,7 @@ Tags: custom fields, custom field, wordpress custom fields, advanced custom fiel
6
 
7
  Requires at least: 3.1
8
  Tested up to: 3.9.0
9
- Stable tag: 1.0.9
10
 
11
  A must have tool for creating custom fields, custom post types and taxonomies, fast and without any programming knowledge.
12
 
@@ -141,6 +141,12 @@ Creating a taxonomy generally automatically creates a special query variable usi
141
  10. Taxonomy listing
142
 
143
  == Changelog ==
 
 
 
 
 
 
144
  = 1.0.9 =
145
  * Replaced wysiwyg editor from tinymce to ckeditor to fix compatibility issues with WordPress 3.9
146
 
6
 
7
  Requires at least: 3.1
8
  Tested up to: 3.9.0
9
+ Stable tag: 1.1.0
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.0 =
145
+ * Added filter for the arguments passed to the register_post_type() funtion when creating a Custom Post Type. ( "wck_cptc_register_post_type_args" )
146
+ * Fixed the missing datepicker css 404 error.
147
+ * Removed notices
148
+ * Fixed "Attach upload to post" option for the upload field.
149
+
150
  = 1.0.9 =
151
  * Replaced wysiwyg editor from tinymce to ckeditor to fix compatibility issues with WordPress 3.9
152
 
wck-cptc.php CHANGED
@@ -153,10 +153,9 @@ function wck_cptc_create_cpts(){
153
  else{
154
  if( !empty( $cpt['rewrite-slug'] ) )
155
  $args['rewrite'] = array('slug' => $cpt['rewrite-slug']);
156
- }
157
 
158
-
159
- register_post_type( $cpt['post-type'], $args );
160
  }
161
  }
162
  }
153
  else{
154
  if( !empty( $cpt['rewrite-slug'] ) )
155
  $args['rewrite'] = array('slug' => $cpt['rewrite-slug']);
156
+ }
157
 
158
+ register_post_type( $cpt['post-type'], apply_filters( 'wck_cptc_register_post_type_args', $args, $cpt['post-type'] ) );
 
159
  }
160
  }
161
  }
wck.php CHANGED
@@ -3,13 +3,13 @@
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: Reflection Media, Madalin Ungureanu, sareiodata
6
- Version: 1.0.9
7
  Author URI: http://www.reflectionmedia.ro
8
 
9
  License: GPL2
10
 
11
  == Copyright ==
12
- Copyright 2011 Reflection Media (wwww.reflectionmedia.ro)
13
 
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License as published by
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: Reflection Media, Madalin Ungureanu, sareiodata
6
+ Version: 1.1.0
7
  Author URI: http://www.reflectionmedia.ro
8
 
9
  License: GPL2
10
 
11
  == Copyright ==
12
+ Copyright 2014 Cozmoslabs (wwww.cozmoslabs.com)
13
 
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License as published by
wordpress-creation-kit-api/assets/js/ckeditor/config.js CHANGED
@@ -35,4 +35,7 @@ CKEDITOR.editorConfig = function( config ) {
35
 
36
  // Make dialogs simpler.
37
  config.removeDialogTabs = 'image:advanced;link:advanced';
 
 
 
38
  };
35
 
36
  // Make dialogs simpler.
37
  config.removeDialogTabs = 'image:advanced;link:advanced';
38
+
39
+ /* set default language */
40
+ config.language = "en";
41
  };
wordpress-creation-kit-api/fields/upload.js CHANGED
@@ -4,16 +4,25 @@ jQuery(document).ready(function(){
4
 
5
  // Uploading files
6
  var wp_media_post_id = wp.media.model.settings.post.id; // Store the old id
7
- var set_to_post_id = wckUpload.postID; // Set this
8
 
9
  jQuery('.wck_upload_button').live('click', function( event ){
10
  event.preventDefault();
11
-
 
 
 
12
  var file_frame;
13
  var uploadInputId = jQuery( this ).data( 'upload_input' );
14
  var uploadInFront = jQuery( this ).data( 'upload_in_backend' );
 
15
  var uploadButton = jQuery( this );
16
 
 
 
 
 
 
17
  /* set default tab to upload file */
18
  wp.media.controller.Library.prototype.defaults.contentUserSetting = false;
19
  if( uploadInFront != true )
@@ -56,8 +65,7 @@ jQuery(document).ready(function(){
56
  for( var i=0;i < attachments.length; i++ ){
57
  // Do something with attachment.id and/or attachment.url here
58
  attids.push( attachments[i].id );
59
- result = '<div class="upload-field-details" id="'+ uploadInputId +'_info_container" data-attachment_id="'+ attachments[i].id +'">';
60
- console.log(attachments);
61
  if( attachments[i].sizes != undefined ){
62
  if( attachments[i].sizes.thumbnail != undefined )
63
  thumb = attachments[i].sizes.thumbnail;
4
 
5
  // Uploading files
6
  var wp_media_post_id = wp.media.model.settings.post.id; // Store the old id
7
+
8
 
9
  jQuery('.wck_upload_button').live('click', function( event ){
10
  event.preventDefault();
11
+
12
+ var set_to_post_id = jQuery( this ).data( 'post_id' ); // Set this
13
+
14
+
15
  var file_frame;
16
  var uploadInputId = jQuery( this ).data( 'upload_input' );
17
  var uploadInFront = jQuery( this ).data( 'upload_in_backend' );
18
+ var attachToPost = jQuery( this ).data( 'attach_to_post' );
19
  var uploadButton = jQuery( this );
20
 
21
+ /* remove set_to_post_id value if we do not want to attach to post */
22
+ if( attachToPost != true ){
23
+ set_to_post_id = '';
24
+ }
25
+
26
  /* set default tab to upload file */
27
  wp.media.controller.Library.prototype.defaults.contentUserSetting = false;
28
  if( uploadInFront != true )
65
  for( var i=0;i < attachments.length; i++ ){
66
  // Do something with attachment.id and/or attachment.url here
67
  attids.push( attachments[i].id );
68
+ result = '<div class="upload-field-details" id="'+ uploadInputId +'_info_container" data-attachment_id="'+ attachments[i].id +'">';
 
69
  if( attachments[i].sizes != undefined ){
70
  if( attachments[i].sizes.thumbnail != undefined )
71
  thumb = attachments[i].sizes.thumbnail;
wordpress-creation-kit-api/fields/upload.php CHANGED
@@ -5,7 +5,6 @@
5
  * @param string $context Context where the function is used. Depending on it some actions are preformed.;
6
  * @return string $element input element html string. */
7
 
8
-
9
  /* define id's for input and info div */
10
  $upload_input_id = str_replace( '-', '_', Wordpress_Creation_Kit::wck_generate_slug( $meta . $details['title'] ) );
11
  $upload_info_div_id = str_replace( '-', '_', Wordpress_Creation_Kit::wck_generate_slug( $meta .'_info_container_'. $details['title'] ) );
@@ -42,11 +41,21 @@ if( !empty ( $value ) ){
42
  $element.= '<a href="#" class="button wck_upload_button" id="upload_'. esc_attr(Wordpress_Creation_Kit::wck_generate_slug( $details['title'] ) ) .'_button" data-uploader_title="'. $details['title'] .'" data-uploader_button_text="Select Files" data-upload_input="'.esc_attr( $upload_input_id ).'" ';
43
  if( is_user_logged_in() )
44
  $element.= 'data-uploader_logged_in="true"';
 
 
 
 
 
 
 
 
 
 
45
 
46
- if( $details['multiple_upload'] == 'true' )
47
- $element.= ' data-multiple_upload="true"';
48
- else
49
- $element.= ' data-multiple_upload="false"';
50
 
51
  if( $context != 'fep' )
52
  $element.= ' data-upload_in_backend="true"';
5
  * @param string $context Context where the function is used. Depending on it some actions are preformed.;
6
  * @return string $element input element html string. */
7
 
 
8
  /* define id's for input and info div */
9
  $upload_input_id = str_replace( '-', '_', Wordpress_Creation_Kit::wck_generate_slug( $meta . $details['title'] ) );
10
  $upload_info_div_id = str_replace( '-', '_', Wordpress_Creation_Kit::wck_generate_slug( $meta .'_info_container_'. $details['title'] ) );
41
  $element.= '<a href="#" class="button wck_upload_button" id="upload_'. esc_attr(Wordpress_Creation_Kit::wck_generate_slug( $details['title'] ) ) .'_button" data-uploader_title="'. $details['title'] .'" data-uploader_button_text="Select Files" data-upload_input="'.esc_attr( $upload_input_id ).'" ';
42
  if( is_user_logged_in() )
43
  $element.= 'data-uploader_logged_in="true"';
44
+
45
+ if( !empty( $post_id ) )
46
+ $element.= ' data-post_id="'. $post_id .'"';
47
+
48
+ if( !empty( $details['multiple_upload'] ) ){
49
+ if( $details['multiple_upload'] == 'true' )
50
+ $element.= ' data-multiple_upload="true"';
51
+ else
52
+ $element.= ' data-multiple_upload="false"';
53
+ }
54
 
55
+ if( !empty( $details['attach_to_post'] ) ){
56
+ if( $details['attach_to_post'] == true )
57
+ $element.= ' data-attach_to_post="true"';
58
+ }
59
 
60
  if( $context != 'fep' )
61
  $element.= ' data-upload_in_backend="true"';
wordpress-creation-kit-api/wordpress-creation-kit.js CHANGED
@@ -185,7 +185,7 @@ function mb_sortable_elements() {
185
  jQuery( ".mb-table-container tbody" ).not( jQuery( ".mb-table-container.single tbody, .mb-table-container.not-sortable tbody" ) ).sortable({
186
  update: function(event, ui){
187
 
188
- var value = jQuery(this).parent().prev().attr('id');
189
  var id = jQuery(this).parent().attr('post');
190
 
191
  var result = jQuery(this).sortable('toArray');
185
  jQuery( ".mb-table-container tbody" ).not( jQuery( ".mb-table-container.single tbody, .mb-table-container.not-sortable tbody" ) ).sortable({
186
  update: function(event, ui){
187
 
188
+ var value = jQuery(this).parent().siblings('.wck-add-form').attr('id');
189
  var id = jQuery(this).parent().attr('post');
190
 
191
  var result = jQuery(this).sortable('toArray');
wordpress-creation-kit-api/wordpress-creation-kit.php CHANGED
@@ -91,13 +91,21 @@ class Wordpress_Creation_Kit{
91
 
92
  // Set up the AJAX hooks
93
  add_action("wp_ajax_wck_add_meta".$this->args['meta_name'], array( &$this, 'wck_add_meta') );
 
94
  add_action("wp_ajax_wck_update_meta".$this->args['meta_name'], array( &$this, 'wck_update_meta') );
 
95
  add_action("wp_ajax_wck_show_update".$this->args['meta_name'], array( &$this, 'wck_show_update_form') );
 
96
  add_action("wp_ajax_wck_refresh_list".$this->args['meta_name'], array( &$this, 'wck_refresh_list') );
 
97
  add_action("wp_ajax_wck_refresh_entry".$this->args['meta_name'], array( &$this, 'wck_refresh_entry') );
 
98
  add_action("wp_ajax_wck_add_form".$this->args['meta_name'], array( &$this, 'wck_add_form') );
 
99
  add_action("wp_ajax_wck_remove_meta".$this->args['meta_name'], array( &$this, 'wck_remove_meta') );
 
100
  add_action("wp_ajax_wck_reorder_meta".$this->args['meta_name'], array( &$this, 'wck_reorder_meta') );
 
101
 
102
  add_action('add_meta_boxes', array( &$this, 'wck_add_metabox') );
103
 
@@ -288,7 +296,7 @@ class Wordpress_Creation_Kit{
288
  $post_id = '';
289
 
290
  ?>
291
- <div id="<?php echo $meta ?>" style="padding:10px 0;" <?php if( $this->args['single'] ) echo 'class="single"' ?>>
292
  <ul class="mb-list-entry-fields">
293
  <?php
294
  $element_id = 0;
@@ -450,8 +458,10 @@ class Wordpress_Creation_Kit{
450
  else
451
  $value = '';
452
 
453
- /* filter display value */
 
454
  $value = apply_filters( "wck_displayed_value_{$meta}_element_{$j}", $value );
 
455
 
456
  /* display it differently based on field type*/
457
  if( $details['type'] == 'upload' ){
@@ -596,18 +606,15 @@ class Wordpress_Creation_Kit{
596
  wp_enqueue_script( 'wck-ckeditor' );
597
 
598
  //datepicker
599
- wp_enqueue_script('jquery-ui-datepicker');
600
- wp_enqueue_style( 'jquery-style', plugins_url( '/assets/datepicker/datepicker.css', __FILE__ ) );
 
 
601
 
602
  /* media upload */
603
  wp_enqueue_media();
604
  wp_enqueue_script('wck-upload-field', plugins_url('/fields/upload.js', __FILE__), array('jquery') );
605
- if( !$wck_printed_scripts ){
606
- /* send parameters to the upload script */
607
- $post_id = !empty( $_GET['post'] ) ? $_GET['post'] : '';
608
- $parameters_array = array( 'postID' => $post_id );
609
- wp_localize_script( 'wck-upload-field', 'wckUpload', $parameters_array );
610
- }
611
  /* eache metabox prints the scripts which is fine for wp_enque but not for wp_localize_script so this marks when they were executed at least once */
612
  $wck_printed_scripts = true;
613
  }
91
 
92
  // Set up the AJAX hooks
93
  add_action("wp_ajax_wck_add_meta".$this->args['meta_name'], array( &$this, 'wck_add_meta') );
94
+ add_action("wp_ajax_nopriv_wck_add_meta".$this->args['meta_name'], array( &$this, 'wck_add_meta') );
95
  add_action("wp_ajax_wck_update_meta".$this->args['meta_name'], array( &$this, 'wck_update_meta') );
96
+ add_action("wp_ajax_nopriv_wck_update_meta".$this->args['meta_name'], array( &$this, 'wck_update_meta') );
97
  add_action("wp_ajax_wck_show_update".$this->args['meta_name'], array( &$this, 'wck_show_update_form') );
98
+ add_action("wp_ajax_nopriv_wck_show_update".$this->args['meta_name'], array( &$this, 'wck_show_update_form') );
99
  add_action("wp_ajax_wck_refresh_list".$this->args['meta_name'], array( &$this, 'wck_refresh_list') );
100
+ add_action("wp_ajax_nopriv_wck_refresh_list".$this->args['meta_name'], array( &$this, 'wck_refresh_list') );
101
  add_action("wp_ajax_wck_refresh_entry".$this->args['meta_name'], array( &$this, 'wck_refresh_entry') );
102
+ add_action("wp_ajax_nopriv_wck_refresh_entry".$this->args['meta_name'], array( &$this, 'wck_refresh_entry') );
103
  add_action("wp_ajax_wck_add_form".$this->args['meta_name'], array( &$this, 'wck_add_form') );
104
+ add_action("wp_ajax_nopriv_wck_add_form".$this->args['meta_name'], array( &$this, 'wck_add_form') );
105
  add_action("wp_ajax_wck_remove_meta".$this->args['meta_name'], array( &$this, 'wck_remove_meta') );
106
+ add_action("wp_ajax_nopriv_wck_remove_meta".$this->args['meta_name'], array( &$this, 'wck_remove_meta') );
107
  add_action("wp_ajax_wck_reorder_meta".$this->args['meta_name'], array( &$this, 'wck_reorder_meta') );
108
+ add_action("wp_ajax_nopriv_wck_reorder_meta".$this->args['meta_name'], array( &$this, 'wck_reorder_meta') );
109
 
110
  add_action('add_meta_boxes', array( &$this, 'wck_add_metabox') );
111
 
296
  $post_id = '';
297
 
298
  ?>
299
+ <div id="<?php echo $meta ?>" style="padding:10px 0;" class="wck-add-form<?php if( $this->args['single'] ) echo ' single' ?>">
300
  <ul class="mb-list-entry-fields">
301
  <?php
302
  $element_id = 0;
458
  else
459
  $value = '';
460
 
461
+ /* filter display value */
462
+ /* keep this one for backwards compatibility */
463
  $value = apply_filters( "wck_displayed_value_{$meta}_element_{$j}", $value );
464
+ $value = apply_filters( "wck_displayed_value_{$meta}_".Wordpress_Creation_Kit::wck_generate_slug( $details['title'] ), $value );
465
 
466
  /* display it differently based on field type*/
467
  if( $details['type'] == 'upload' ){
606
  wp_enqueue_script( 'wck-ckeditor' );
607
 
608
  //datepicker
609
+ if ( file_exists( WCK_PLUGIN_DIR. '/wordpress-creation-kit-api/fields/datepicker.php' ) ){
610
+ wp_enqueue_script('jquery-ui-datepicker');
611
+ wp_enqueue_style( 'jquery-style', plugins_url( '/assets/datepicker/datepicker.css', __FILE__ ) );
612
+ }
613
 
614
  /* media upload */
615
  wp_enqueue_media();
616
  wp_enqueue_script('wck-upload-field', plugins_url('/fields/upload.js', __FILE__), array('jquery') );
617
+
 
 
 
 
 
618
  /* eache metabox prints the scripts which is fine for wp_enque but not for wp_localize_script so this marks when they were executed at least once */
619
  $wck_printed_scripts = true;
620
  }