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

Version Description

  • Added sortable taxonomy admin column support for Taxonomy Creator
  • Added show_in_quick_edit argument support for Taxonomy Creator
Download this release

Release Info

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

Code changes from version 2.0.3 to 2.0.4

Files changed (3) hide show
  1. readme.txt +5 -1
  2. wck-ctc.php +31 -3
  3. wck.php +1 -1
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.6.1
9
- Stable tag: 2.0.3
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -139,6 +139,10 @@ Creating a taxonomy generally automatically creates a special query variable usi
139
  10. Taxonomy listing
140
 
141
  == Changelog ==
 
 
 
 
142
  = 2.0.3 =
143
  * Fixed some issues with the unserialized fields conversion
144
  * Changed per batch variable from 100 to 30 to try to reduce timeouts on sites with a lot of entries
6
 
7
  Requires at least: 3.1
8
  Tested up to: 4.6.1
9
+ Stable tag: 2.0.4
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.0.4 =
143
+ * Added sortable taxonomy admin column support for Taxonomy Creator
144
+ * Added show_in_quick_edit argument support for Taxonomy Creator
145
+
146
  = 2.0.3 =
147
  * Fixed some issues with the unserialized fields conversion
148
  * Changed per batch variable from 100 to 30 to try to reduce timeouts on sites with a lot of entries
wck-ctc.php CHANGED
@@ -77,6 +77,8 @@ function wck_ctc_create_box(){
77
  array( 'type' => 'select', 'title' => __( 'Show UI', 'wck' ), 'slug' => 'show-ui', 'options' => array( 'false', 'true' ), 'default' => 'true', 'description' => __( 'Whether to generate a default UI for managing this post type.', 'wck' ) ),
78
  array( 'type' => 'select', 'title' => __( 'Show Tagcloud', 'wck' ), 'slug' => 'show-tagcloud', 'options' => array( 'false', 'true' ), 'default' => 'true', 'description' => __( 'Whether to allow the Tag Cloud widget to use this taxonomy.', 'wck' ) ),
79
  array( 'type' => 'select', 'title' => __( 'Show Admin Column', 'wck' ), 'slug' => 'show-admin-column', 'options' => array( 'false', 'true' ), 'default' => 'false', 'description' => __( 'Whether to allow automatic creation of taxonomy columns on associated post-types.', 'wck' ) ),
 
 
80
  array( 'type' => 'select', 'title' => __( 'Show in REST API', 'wck'), 'slug' => 'show-in-rest', 'options' => array( 'false', 'true'), 'default' => 'false', 'description' => __('Make this taxonomy available via WP REST API ', 'wck' ) )
81
  );
82
 
@@ -156,12 +158,38 @@ function wck_ctc_create_taxonomy(){
156
  $args['show_admin_column'] = $ct['show-admin-column'] == 'false' ? false : true;
157
  }
158
 
 
 
 
 
159
  if( !empty( $ct['attach-to'] ) )
160
  $object_type = explode( ', ', $ct['attach-to'] );
161
  else
162
  $object_type = '';
163
 
164
  register_taxonomy( $ct['taxonomy'], $object_type, apply_filters( 'wck_ctc_register_taxonomy_args', $args, $ct['taxonomy'] ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  }
166
  }
167
  }
@@ -231,7 +259,7 @@ function wck_ctc_form_wrapper_start(){
231
  echo '<li id="ctc-advanced-options-container" style="display:none;"><ul>';
232
  }
233
 
234
- add_action( "wck_after_add_form_wck_ctc_element_25", 'wck_ctc_form_wrapper_end' );
235
  function wck_ctc_form_wrapper_end(){
236
  echo '</ul></li>';
237
  }
@@ -258,7 +286,7 @@ function wck_ctc_update_form_wrapper_start( $form, $i ){
258
  return $form;
259
  }
260
 
261
- add_filter( "wck_after_update_form_wck_ctc_element_25", 'wck_ctc_update_form_wrapper_end', 10, 2 );
262
  function wck_ctc_update_form_wrapper_end( $form, $i ){
263
  $form .= '</ul></li>';
264
  return $form;
@@ -287,7 +315,7 @@ function wck_ctc_display_adv_wrapper_start( $form, $i ){
287
  return $form;
288
  }
289
 
290
- add_filter( "wck_after_listed_wck_ctc_element_25", 'wck_ctc_display_adv_wrapper_end', 10, 2 );
291
  function wck_ctc_display_adv_wrapper_end( $form, $i ){
292
  $form .= '</ul></li>';
293
  return $form;
77
  array( 'type' => 'select', 'title' => __( 'Show UI', 'wck' ), 'slug' => 'show-ui', 'options' => array( 'false', 'true' ), 'default' => 'true', 'description' => __( 'Whether to generate a default UI for managing this post type.', 'wck' ) ),
78
  array( 'type' => 'select', 'title' => __( 'Show Tagcloud', 'wck' ), 'slug' => 'show-tagcloud', 'options' => array( 'false', 'true' ), 'default' => 'true', 'description' => __( 'Whether to allow the Tag Cloud widget to use this taxonomy.', 'wck' ) ),
79
  array( 'type' => 'select', 'title' => __( 'Show Admin Column', 'wck' ), 'slug' => 'show-admin-column', 'options' => array( 'false', 'true' ), 'default' => 'false', 'description' => __( 'Whether to allow automatic creation of taxonomy columns on associated post-types.', 'wck' ) ),
80
+ array( 'type' => 'select', 'title' => __( 'Sortable Admin Column', 'wck' ), 'slug' => 'sortable-admin-column', 'options' => array( 'false', 'true' ), 'default' => 'false', 'description' => __( 'Whether to make the columns sortable or not. WARNING: on a large number of posts the performance can be severely affected', 'wck' ) ),
81
+ array( 'type' => 'select', 'title' => __( 'Show in Quick Edit', 'wck' ), 'slug' => 'show-in-quick-edit', 'options' => array( 'false', 'true' ), 'default' => 'false', 'description' => __( 'Whether to show the taxonomy in the quick/bulk edit panel.', 'wck' ) ),
82
  array( 'type' => 'select', 'title' => __( 'Show in REST API', 'wck'), 'slug' => 'show-in-rest', 'options' => array( 'false', 'true'), 'default' => 'false', 'description' => __('Make this taxonomy available via WP REST API ', 'wck' ) )
83
  );
84
 
158
  $args['show_admin_column'] = $ct['show-admin-column'] == 'false' ? false : true;
159
  }
160
 
161
+ if( !empty( $ct['show-in-quick-edit'] ) ){
162
+ $args['show_in_quick_edit'] = $ct['show-in-quick-edit'] == 'false' ? false : true;
163
+ }
164
+
165
  if( !empty( $ct['attach-to'] ) )
166
  $object_type = explode( ', ', $ct['attach-to'] );
167
  else
168
  $object_type = '';
169
 
170
  register_taxonomy( $ct['taxonomy'], $object_type, apply_filters( 'wck_ctc_register_taxonomy_args', $args, $ct['taxonomy'] ) );
171
+
172
+ if( !empty( $object_type ) && !empty( $args['show_admin_column'] ) && $args['show_admin_column'] == true && !empty( $ct['sortable-admin-column'] ) && $ct['sortable-admin-column'] === 'true' ){
173
+ foreach( $object_type as $post_type ) {
174
+ add_filter("manage_edit-{$post_type}_sortable_columns", create_function('$columns', '$columns["taxonomy-' . $ct["taxonomy"] . '"] = "taxonomy-' . $ct["taxonomy"] . '";return $columns;'));
175
+ add_filter( 'posts_clauses', create_function( '$clauses, $wp_query', 'global $wpdb;
176
+ if ( is_admin() && isset( $wp_query->query[\'orderby\'] ) && \'taxonomy-'.$ct["taxonomy"].'\' == $wp_query->query[\'orderby\'] ) {
177
+
178
+ $clauses[\'join\'] .= <<<SQL
179
+ LEFT OUTER JOIN {$wpdb->term_relationships} ON {$wpdb->posts}.ID={$wpdb->term_relationships}.object_id
180
+ LEFT OUTER JOIN {$wpdb->term_taxonomy} USING (term_taxonomy_id)
181
+ LEFT OUTER JOIN {$wpdb->terms} USING (term_id)
182
+ SQL;
183
+
184
+ $clauses[\'where\'] .= " AND (taxonomy = \''.$ct["taxonomy"].'\' OR taxonomy IS NULL)";
185
+ $clauses[\'groupby\'] = "object_id";
186
+ $clauses[\'orderby\'] = "GROUP_CONCAT({$wpdb->terms}.name ORDER BY name ASC) ";
187
+ $clauses[\'orderby\'] .= ( \'ASC\' == strtoupper( $wp_query->get(\'order\') ) ) ? \'ASC\' : \'DESC\';
188
+ }
189
+
190
+ return $clauses;' ), 10, 2 );
191
+ }
192
+ }
193
  }
194
  }
195
  }
259
  echo '<li id="ctc-advanced-options-container" style="display:none;"><ul>';
260
  }
261
 
262
+ add_action( "wck_after_add_form_wck_ctc_element_27", 'wck_ctc_form_wrapper_end' );
263
  function wck_ctc_form_wrapper_end(){
264
  echo '</ul></li>';
265
  }
286
  return $form;
287
  }
288
 
289
+ add_filter( "wck_after_update_form_wck_ctc_element_27", 'wck_ctc_update_form_wrapper_end', 10, 2 );
290
  function wck_ctc_update_form_wrapper_end( $form, $i ){
291
  $form .= '</ul></li>';
292
  return $form;
315
  return $form;
316
  }
317
 
318
+ add_filter( "wck_after_listed_wck_ctc_element_27", 'wck_ctc_display_adv_wrapper_end', 10, 2 );
319
  function wck_ctc_display_adv_wrapper_end( $form, $i ){
320
  $form .= '</ul></li>';
321
  return $form;
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.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.0.4
7
  Author URI: http://www.cozmoslabs.com
8
 
9
  License: GPL2