Version Description
- We now allow Custom Post Types and Custom Taxonomies to be available via REST API by adding 'show_in_rest' attribute
Download this release
Release Info
Developer | madalin.ungureanu |
Plugin | Custom Post Types and Custom Fields creator – WCK |
Version | 1.1.8 |
Comparing to | |
See all releases |
Code changes from version 1.1.7 to 1.1.8
- readme.txt +5 -2
- wck-cptc.php +178 -176
- wck-ctc.php +146 -144
- wck.php +1 -1
- wordpress-creation-kit-api/wordpress-creation-kit.php +1 -1
readme.txt
CHANGED
@@ -5,8 +5,8 @@ Donate link: http://www.cozmoslabs.com/wordpress-creation-kit/
|
|
5 |
Tags: custom fields, custom field, wordpress custom fields, advanced custom fields, custom post type, custom post types, post types, cpt, post type, repeater fields, repeater, repeatable fields, meta box, metabox, taxonomy, taxonomies, custom taxonomy, custom taxonomies, custom, custom fields creator, post meta, meta, get_post_meta, post creator, cck, content types, types
|
6 |
|
7 |
Requires at least: 3.1
|
8 |
-
Tested up to: 4.
|
9 |
-
Stable tag: 1.1.
|
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,9 @@ Creating a taxonomy generally automatically creates a special query variable usi
|
|
141 |
10. Taxonomy listing
|
142 |
|
143 |
== Changelog ==
|
|
|
|
|
|
|
144 |
= 1.1.7 =
|
145 |
* Select field can now display lables when outputting values
|
146 |
* Minor security improvements
|
5 |
Tags: custom fields, custom field, wordpress custom fields, advanced custom fields, custom post type, custom post types, post types, cpt, post type, repeater fields, repeater, repeatable fields, meta box, metabox, taxonomy, taxonomies, custom taxonomy, custom taxonomies, custom, custom fields creator, post meta, meta, get_post_meta, post creator, cck, content types, types
|
6 |
|
7 |
Requires at least: 3.1
|
8 |
+
Tested up to: 4.4.1
|
9 |
+
Stable tag: 1.1.8
|
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.8 =
|
145 |
+
* We now allow Custom Post Types and Custom Taxonomies to be available via REST API by adding 'show_in_rest' attribute
|
146 |
+
|
147 |
= 1.1.7 =
|
148 |
* Select field can now display lables when outputting values
|
149 |
* Minor security improvements
|
wck-cptc.php
CHANGED
@@ -2,256 +2,258 @@
|
|
2 |
/* Creates Custom Post Types for WordPress */
|
3 |
|
4 |
|
5 |
-
$args = array(
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
$cptc_page = new WCK_Page_Creator( $args );
|
16 |
|
17 |
|
18 |
/* Add Scripts */
|
19 |
add_action('admin_enqueue_scripts', 'wck_cptc_print_scripts' );
|
20 |
-
function wck_cptc_print_scripts($hook){
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
}
|
26 |
|
27 |
/* create the meta box only for admins ( 'capability' => 'edit_theme_options' ) */
|
28 |
add_action( 'init', 'wck_cptc_create_box', 11 );
|
29 |
function wck_cptc_create_box(){
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
96 |
}
|
97 |
|
98 |
/* hook to create custom post types */
|
99 |
add_action( 'init', 'wck_cptc_create_cpts', 8 );
|
100 |
|
101 |
function wck_cptc_create_cpts(){
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
|
|
160 |
}
|
161 |
|
162 |
/* Flush rewrite rules */
|
163 |
add_action('init', 'cptc_flush_rules', 20);
|
164 |
function cptc_flush_rules(){
|
165 |
-
|
166 |
-
|
167 |
}
|
168 |
|
169 |
/* advanced labels container for add form */
|
170 |
add_action( "wck_before_add_form_wck_cptc_element_7", 'wck_cptc_form_label_wrapper_start' );
|
171 |
function wck_cptc_form_label_wrapper_start(){
|
172 |
-
|
173 |
-
|
174 |
}
|
175 |
|
176 |
add_action( "wck_after_add_form_wck_cptc_element_17", 'wck_cptc_form_label_wrapper_end' );
|
177 |
function wck_cptc_form_label_wrapper_end(){
|
178 |
-
|
179 |
}
|
180 |
|
181 |
/* advanced options container for add form */
|
182 |
add_action( "wck_before_add_form_wck_cptc_element_18", 'wck_cptc_form_wrapper_start' );
|
183 |
function wck_cptc_form_wrapper_start(){
|
184 |
-
|
185 |
-
|
186 |
}
|
187 |
|
188 |
-
add_action( "
|
189 |
function wck_cptc_form_wrapper_end(){
|
190 |
-
|
191 |
}
|
192 |
|
193 |
/* advanced label options container for update form */
|
194 |
add_filter( "wck_before_update_form_wck_cptc_element_7", 'wck_cptc_update_form_label_wrapper_start', 10, 2 );
|
195 |
function wck_cptc_update_form_label_wrapper_start( $form, $i ){
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
}
|
200 |
|
201 |
add_filter( "wck_after_update_form_wck_cptc_element_17", 'wck_cptc_update_form_label_wrapper_end', 10, 2 );
|
202 |
function wck_cptc_update_form_label_wrapper_end( $form, $i ){
|
203 |
-
|
204 |
-
|
205 |
}
|
206 |
|
207 |
/* advanced options container for update form */
|
208 |
add_filter( "wck_before_update_form_wck_cptc_element_18", 'wck_cptc_update_form_wrapper_start', 10, 2 );
|
209 |
function wck_cptc_update_form_wrapper_start( $form, $i ){
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
}
|
214 |
|
215 |
-
add_filter( "
|
216 |
function wck_cptc_update_form_wrapper_end( $form, $i ){
|
217 |
-
|
218 |
-
|
219 |
}
|
220 |
|
221 |
|
222 |
/* advanced label options container for display */
|
223 |
add_filter( "wck_before_listed_wck_cptc_element_7", 'wck_cptc_display_label_wrapper_start', 10, 2 );
|
224 |
function wck_cptc_display_label_wrapper_start( $form, $i ){
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
}
|
229 |
|
230 |
add_filter( "wck_after_listed_wck_cptc_element_17", 'wck_cptc_display_label_wrapper_end', 10, 2 );
|
231 |
function wck_cptc_display_label_wrapper_end( $form, $i ){
|
232 |
-
|
233 |
-
|
234 |
}
|
235 |
|
236 |
/* advanced options container for display */
|
237 |
add_filter( "wck_before_listed_wck_cptc_element_18", 'wck_cptc_display_adv_wrapper_start', 10, 2 );
|
238 |
function wck_cptc_display_adv_wrapper_start( $form, $i ){
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
}
|
243 |
|
244 |
-
add_filter( "
|
245 |
function wck_cptc_display_adv_wrapper_end( $form, $i ){
|
246 |
-
|
247 |
-
|
248 |
}
|
249 |
|
250 |
/* add refresh to page */
|
251 |
add_action("wck_refresh_list_wck_cptc", "wck_cptc_after_refresh_list");
|
252 |
add_action("wck_refresh_entry_wck_cptc", "wck_cptc_after_refresh_list");
|
253 |
function wck_cptc_after_refresh_list(){
|
254 |
-
|
255 |
}
|
256 |
|
257 |
/* Add side metaboxes */
|
@@ -275,7 +277,7 @@ if( !file_exists( dirname(__FILE__).'/wck-stp.php' ) ) {
|
|
275 |
/* Contextual Help */
|
276 |
add_action('load-wck_page_cptc-page', 'wck_cptc_help');
|
277 |
|
278 |
-
function wck_cptc_help () {
|
279 |
$screen = get_current_screen();
|
280 |
|
281 |
/*
|
@@ -291,14 +293,14 @@ function wck_cptc_help () {
|
|
291 |
'title' => __('Overview', 'wck' ),
|
292 |
'content' => '<p>' . __( 'WCK Custom Post Type Creator allows you to easily create custom post types for Wordpress without any programming knowledge.<br />Most of the common options for creating a post type are displayed by default while the advanced options and label are just one click away.', 'wck' ) . '</p>',
|
293 |
) );
|
294 |
-
|
295 |
-
|
296 |
'id' => 'wck_cptc_labels',
|
297 |
'title' => __( 'Labels', 'wck' ),
|
298 |
'content' => '<p>' . __( 'For simplicity you are required to introduce only the Singular Label and Plural Label from wchich the rest of the labels will be formed.<br />For a more detailed control of the labels you just have to click the "Show Advanced Label Options" link and all the availabel labels will be displayed.', 'wck' ) . '</p>',
|
299 |
) );
|
300 |
-
|
301 |
-
|
302 |
'id' => 'wck_cptc_advanced',
|
303 |
'title' => __('Advanced Options', 'wck' ),
|
304 |
'content' => '<p>' . __( 'The Advanced Options are set to the most common defaults for custom post types. To display them click the "Show Advanced Options" link.', 'wck' ) . '</p>',
|
2 |
/* Creates Custom Post Types for WordPress */
|
3 |
|
4 |
|
5 |
+
$args = array(
|
6 |
+
'page_title' => __( 'WCK Post Type Creator', 'wck' ),
|
7 |
+
'menu_title' => __( 'Post Type Creator', 'wck' ),
|
8 |
+
'capability' => 'edit_theme_options',
|
9 |
+
'menu_slug' => 'cptc-page',
|
10 |
+
'page_type' => 'submenu_page',
|
11 |
+
'parent_slug' => 'wck-page',
|
12 |
+
'priority' => 8,
|
13 |
+
'page_icon' => plugins_url('/images/wck-32x32.png', __FILE__)
|
14 |
+
);
|
15 |
$cptc_page = new WCK_Page_Creator( $args );
|
16 |
|
17 |
|
18 |
/* Add Scripts */
|
19 |
add_action('admin_enqueue_scripts', 'wck_cptc_print_scripts' );
|
20 |
+
function wck_cptc_print_scripts($hook){
|
21 |
+
if( 'wck_page_cptc-page' == $hook ){
|
22 |
+
wp_register_style('wck-cptc-css', plugins_url('/css/wck-cptc.css', __FILE__));
|
23 |
+
wp_enqueue_style('wck-cptc-css');
|
24 |
+
}
|
25 |
}
|
26 |
|
27 |
/* create the meta box only for admins ( 'capability' => 'edit_theme_options' ) */
|
28 |
add_action( 'init', 'wck_cptc_create_box', 11 );
|
29 |
function wck_cptc_create_box(){
|
30 |
+
|
31 |
+
if( is_admin() && current_user_can( 'edit_theme_options' ) ){
|
32 |
+
/* get registered taxonomies */
|
33 |
+
$args = array(
|
34 |
+
'public' => true
|
35 |
+
);
|
36 |
+
$output = 'objects';
|
37 |
+
$taxonomies = get_taxonomies($args,$output);
|
38 |
+
$taxonomie_names = array();
|
39 |
+
|
40 |
+
if( !empty( $taxonomies ) ){
|
41 |
+
foreach ($taxonomies as $taxonomie ) {
|
42 |
+
if ( $taxonomie->name != 'nav_menu' && $taxonomie->name != 'post_format')
|
43 |
+
$taxonomie_names[] = $taxonomie->name;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
/* set up the fields array */
|
48 |
+
$cpt_creation_fields = array(
|
49 |
+
array( 'type' => 'text', 'title' => __( 'Post type', 'wck' ), 'slug' => 'post-type', 'description' => __( '(max. 20 characters, can not contain capital letters, hyphens, or spaces)', 'wck' ), 'required' => true ),
|
50 |
+
array( 'type' => 'textarea', 'title' => __( 'Description', 'wck' ), 'slug' => 'description', 'description' => __( 'A short descriptive summary of what the post type is.', 'wck' ) ),
|
51 |
+
array( 'type' => 'text', 'title' => __( 'Singular Label', 'wck' ), 'slug' => 'singular-label', 'required' => true, 'description' => __( 'ex. Book', 'wck' ) ),
|
52 |
+
array( 'type' => 'text', 'title' => __( 'Plural Label', 'wck' ), 'slug' => 'plural-label', 'required' => true, 'description' => __( 'ex. Books', 'wck' ) ),
|
53 |
+
array( 'type' => 'select', 'title' => __( 'Hierarchical', 'wck' ), 'slug' => 'hierarchical', 'options' => array( 'false', 'true' ), 'default' => 'false', 'description' => __( 'Whether the post type is hierarchical. Allows Parent to be specified.', 'wck' ) ),
|
54 |
+
array( 'type' => 'select', 'title' => __( 'Has Archive', 'wck' ), 'slug' => 'has-archive', 'options' => array( 'false', 'true' ), 'default' => 'false', 'description' => __( 'Enables post type archives. Will use string as archive slug. Will generate the proper rewrite rules if rewrite is enabled.', 'wck' ) ),
|
55 |
+
array( 'type' => 'checkbox', 'title' => __( 'Supports', 'wck' ), 'slug' => 'supports', 'options' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'post-formats' ), 'default' =>'title, editor' ),
|
56 |
+
|
57 |
+
|
58 |
+
array( 'type' => 'text', 'title' => __( 'Add New', 'wck' ), 'slug' => 'add-new', 'description' => __( 'ex. Add New', 'wck' ) ),
|
59 |
+
array( 'type' => 'text', 'title' => __( 'Add New Item', 'wck' ), 'slug' => 'add-new-item', 'description' => __( 'ex. Add New Book', 'wck' ) ),
|
60 |
+
array( 'type' => 'text', 'title' => __( 'Edit Item', 'wck' ), 'slug' => 'edit-item', 'description' => __( 'ex. Edit Book', 'wck' ) ),
|
61 |
+
array( 'type' => 'text', 'title' => __( 'New Item', 'wck' ), 'slug' => 'new-item', 'description' => __( 'ex. New Book', 'wck' ) ),
|
62 |
+
array( 'type' => 'text', 'title' => __( 'All Items', 'wck' ), 'slug' => 'all-items', 'description' => __( 'ex. All Books', 'wck' ) ),
|
63 |
+
array( 'type' => 'text', 'title' => __( 'View Items', 'wck' ), 'slug' => 'view-items', 'description' => __( 'ex. View Books', 'wck' ) ),
|
64 |
+
array( 'type' => 'text', 'title' => __( 'Search Items', 'wck' ), 'slug' => 'search-items', 'description' => __( 'ex. Search Books', 'wck' ) ),
|
65 |
+
array( 'type' => 'text', 'title' => __( 'Not Found', 'wck' ), 'slug' => 'not-found', 'description' => __( 'ex. No Books Found', 'wck' ) ),
|
66 |
+
array( 'type' => 'text', 'title' => __( 'Not Found In Trash', 'wck' ), 'slug' => 'not-found-in-trash', 'description' => __( 'ex. No Books found in Trash', 'wck' ) ),
|
67 |
+
array( 'type' => 'text', 'title' => __( 'Parent Item Colon', 'wck' ), 'slug' => 'parent-item-colon', 'description' => __( 'the parent text. This string isn\'t used on non-hierarchical types. In hierarchical ones the default is Parent Page ', 'wck' ) ),
|
68 |
+
array( 'type' => 'text', 'title' => __( 'Menu Name', 'wck' ), 'slug' => 'menu-name' ),
|
69 |
+
|
70 |
+
array( 'type' => 'select', 'title' => __( 'Public', 'wck' ), 'slug' => 'public', 'options' => array( 'false', 'true' ), 'default' => 'true', 'description' => __( 'Meta argument used to define default values for publicly_queriable, show_ui, show_in_nav_menus and exclude_from_search', 'wck' ) ),
|
71 |
+
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' ) ),
|
72 |
+
array( 'type' => 'select', 'title' => __( 'Show In Nav Menus', 'wck' ), 'slug' => 'show-in-nav-menus', 'options' => array( 'false', 'true' ), 'default' => 'true', 'description' => __( 'Whether post_type is available for selection in navigation menus.', 'wck' ) ),
|
73 |
+
array( 'type' => 'text', 'title' => __( 'Show In Menu', 'wck' ), 'slug' => 'show-in-menu', 'default' => 'true', 'description' => __( 'Whether to show the post type in the admin menu. show_ui must be true. "false" - do not display in the admin menu, "true" - display as a top level menu, "some string" - If an existing top level page such as "tools.php" or "edit.php?post_type=page", the post type will be placed as a sub menu of that.', 'wck' ) ),
|
74 |
+
array( 'type' => 'text', 'title' => __( 'Menu Position', 'wck' ), 'slug' => 'menu-position', 'description' => __( 'The position in the menu order the post type should appear.', 'wck' ) ),
|
75 |
+
array( 'type' => 'text', 'title' => __( 'Menu Icon', 'wck' ), 'slug' => 'menu-icon', 'description' => __( 'The url to the icon to be used for this menu.', 'wck' ) ),
|
76 |
+
array( 'type' => 'text', 'title' => __( 'Capability Type', 'wck' ), 'slug' => 'capability-type', 'description' => __( 'The string to use to build the read, edit, and delete capabilities.', 'wck' ), 'default' => 'post' ),
|
77 |
+
array( 'type' => 'checkbox', 'title' => __( 'Taxonomies', 'wck' ), 'slug' => 'taxonomies', 'options' => $taxonomie_names ),
|
78 |
+
array( 'type' => 'select', 'title' => __( 'Rewrite', 'wck' ), 'slug' => 'rewrite', 'options' => array( 'false', 'true' ), 'default' => 'true', 'description' => __( 'Rewrite permalinks.', 'wck' ) ),
|
79 |
+
array( 'type' => 'text', 'title' => __( 'Rewrite Slug', 'wck' ), 'slug' => 'rewrite-slug', 'description' => __( 'Defaults to post type name.', 'wck' ) ),
|
80 |
+
array( 'type' => 'select', 'title' => __( 'Show in REST API', 'wck'), 'slug' => 'show-in-rest', 'options' => array( 'false', 'true'), 'default' => 'false', 'description' => __('Make this post type available via WP REST API ', 'wck' ) )
|
81 |
+
);
|
82 |
+
|
83 |
+
/* set up the box arguments */
|
84 |
+
$args = array(
|
85 |
+
'metabox_id' => 'option_page',
|
86 |
+
'metabox_title' => __( 'Custom Post Type Creation', 'wck' ),
|
87 |
+
'post_type' => 'cptc-page',
|
88 |
+
'meta_name' => 'wck_cptc',
|
89 |
+
'meta_array' => $cpt_creation_fields,
|
90 |
+
'context' => 'option',
|
91 |
+
'sortable' => false
|
92 |
+
);
|
93 |
+
|
94 |
+
/* create the box */
|
95 |
+
new Wordpress_Creation_Kit( $args );
|
96 |
+
}
|
97 |
}
|
98 |
|
99 |
/* hook to create custom post types */
|
100 |
add_action( 'init', 'wck_cptc_create_cpts', 8 );
|
101 |
|
102 |
function wck_cptc_create_cpts(){
|
103 |
+
$cpts = get_option('wck_cptc');
|
104 |
+
if( !empty( $cpts ) ){
|
105 |
+
foreach( $cpts as $cpt ){
|
106 |
+
|
107 |
+
$labels = array(
|
108 |
+
'name' => _x( $cpt['plural-label'], 'post type general name'),
|
109 |
+
'singular_name' => _x( $cpt['singular-label'], 'post type singular name'),
|
110 |
+
'add_new' => _x( $cpt['add-new'] ? $cpt['add-new'] : 'Add New', strtolower( $cpt['singular-label'] ) ),
|
111 |
+
'add_new_item' => __( $cpt['add-new-item'] ? $cpt['add-new-item'] : "Add New ".$cpt['singular-label']),
|
112 |
+
'edit_item' => __( $cpt['edit-item'] ? $cpt['edit-item'] : "Edit ".$cpt['singular-label'], 'wck' ) ,
|
113 |
+
'new_item' => __( $cpt['new-item'] ? $cpt['new-item'] : "New ".$cpt['singular-label'], 'wck' ),
|
114 |
+
'all_items' => __( $cpt['all-items'] ? $cpt['all-items'] : "All ".$cpt['plural-label'] , 'wck'),
|
115 |
+
'view_item' => __( !empty( $cpt['view-item'] ) ? $cpt['view-item'] : "View ".$cpt['singular-label'] , 'wck'),
|
116 |
+
'search_items' => __( $cpt['search-items'] ? $cpt['search-items'] : "Search ".$cpt['plural-label'], 'wck' ),
|
117 |
+
'not_found' => __( $cpt['not-found'] ? $cpt['not-found'] : "No ". strtolower( $cpt['plural-label'] ) ." found", 'wck' ),
|
118 |
+
'not_found_in_trash' => __( $cpt['not-found-in-trash'] ? $cpt['not-found-in-trash'] : "No ". strtolower( $cpt['plural-label'] ) ." found in Trash", 'wck' ),
|
119 |
+
'parent_item_colon' => __( !empty( $cpt['parent-item-colon'] ) ? $cpt['parent-item-colon'] : "Parent Page", 'wck' ),
|
120 |
+
'menu_name' => $cpt['menu-name'] ? $cpt['menu-name'] : $cpt['plural-label']
|
121 |
+
);
|
122 |
+
$args = array(
|
123 |
+
'labels' => $labels,
|
124 |
+
'public' => $cpt['public'] == 'false' ? false : true,
|
125 |
+
'description' => $cpt['description'],
|
126 |
+
'show_ui' => $cpt['show-ui'] == 'false' ? false : true,
|
127 |
+
'show_in_nav_menus' => !empty( $cpt['show-in-nav-menus'] ) && $cpt['show-in-nav-menus'] == 'false' ? false : true,
|
128 |
+
'has_archive' => $cpt['has-archive'] == 'false' ? false : true,
|
129 |
+
'hierarchical' => $cpt['hierarchical'] == 'false' ? false : true,
|
130 |
+
'supports' => explode( ', ', $cpt['supports'] ) ,
|
131 |
+
'show_in_rest' => !empty($cpt['show-in-rest']) ? $cpt['show-in-rest'] : false,
|
132 |
+
);
|
133 |
+
|
134 |
+
if( !empty( $cpt['show-in-menu'] ) ){
|
135 |
+
$args['show_in_menu'] = $cpt['show-in-menu'] == 'true' ? true : $cpt['show-in-menu'];
|
136 |
+
}
|
137 |
+
|
138 |
+
if( !empty( $cpt['menu-position'] ) )
|
139 |
+
$args['menu_position'] = intval( $cpt['menu-position'] );
|
140 |
+
|
141 |
+
if( has_filter( "wck_cptc_capabilities_{$cpt['post-type']}" ) )
|
142 |
+
$args['capabilities'] = apply_filters( "wck_cptc_capabilities_{$cpt['post-type']}", $cpt['capability-type'] );
|
143 |
+
else
|
144 |
+
$args['capability_type'] = $cpt['capability-type'];
|
145 |
+
|
146 |
+
if( !empty( $cpt['taxonomies'] ) )
|
147 |
+
$args['taxonomies'] = explode( ', ', $cpt['taxonomies'] );
|
148 |
+
|
149 |
+
if( !empty( $cpt['menu-icon'] ) )
|
150 |
+
$args['menu_icon'] = $cpt['menu-icon'];
|
151 |
+
|
152 |
+
if( $cpt['rewrite'] == 'false' )
|
153 |
+
$args['rewrite'] = $cpt['rewrite'] == 'false' ? false : true;
|
154 |
+
else{
|
155 |
+
if( !empty( $cpt['rewrite-slug'] ) )
|
156 |
+
$args['rewrite'] = array('slug' => $cpt['rewrite-slug']);
|
157 |
+
}
|
158 |
+
|
159 |
+
register_post_type( $cpt['post-type'], apply_filters( 'wck_cptc_register_post_type_args', $args, $cpt['post-type'] ) );
|
160 |
+
}
|
161 |
+
}
|
162 |
}
|
163 |
|
164 |
/* Flush rewrite rules */
|
165 |
add_action('init', 'cptc_flush_rules', 20);
|
166 |
function cptc_flush_rules(){
|
167 |
+
if( isset( $_GET['page'] ) && $_GET['page'] == 'cptc-page' && isset( $_GET['updated'] ) && $_GET['updated'] == 'true' )
|
168 |
+
flush_rewrite_rules( false );
|
169 |
}
|
170 |
|
171 |
/* advanced labels container for add form */
|
172 |
add_action( "wck_before_add_form_wck_cptc_element_7", 'wck_cptc_form_label_wrapper_start' );
|
173 |
function wck_cptc_form_label_wrapper_start(){
|
174 |
+
echo '<li><a href="javascript:void(0)" onclick="jQuery(\'#cptc-advanced-label-options-container\').toggle(); if( jQuery(this).text() == \''. __( 'Show Advanced Label Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Hide Advanced Label Options', 'wck' ) .'\'); else if( jQuery(this).text() == \''. __( 'Hide Advanced Label Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Show Advanced Label Options', 'wck' ) .'\');">'. __('Show Advanced Label Options', 'wck' ) .'</a></li>';
|
175 |
+
echo '<li id="cptc-advanced-label-options-container" style="display:none;"><ul>';
|
176 |
}
|
177 |
|
178 |
add_action( "wck_after_add_form_wck_cptc_element_17", 'wck_cptc_form_label_wrapper_end' );
|
179 |
function wck_cptc_form_label_wrapper_end(){
|
180 |
+
echo '</ul></li>';
|
181 |
}
|
182 |
|
183 |
/* advanced options container for add form */
|
184 |
add_action( "wck_before_add_form_wck_cptc_element_18", 'wck_cptc_form_wrapper_start' );
|
185 |
function wck_cptc_form_wrapper_start(){
|
186 |
+
echo '<li><a href="javascript:void(0)" onclick="jQuery(\'#cptc-advanced-options-container\').toggle(); if( jQuery(this).text() == \''. __('Show Advanced Options', 'wck' ) .'\' ) jQuery(this).text(\'Hide Advanced Options\'); else if( jQuery(this).text() == \''. __('Hide Advanced Options', 'wck' ) .'\' ) jQuery(this).text(\''. __('Show Advanced Options', 'wck' ) .'\');">'. __('Show Advanced Options', 'wck' ) .'</a></li>';
|
187 |
+
echo '<li id="cptc-advanced-options-container" style="display:none;"><ul>';
|
188 |
}
|
189 |
|
190 |
+
add_action( "wck_after_add_form_wck_cptc_element_28", 'wck_cptc_form_wrapper_end' );
|
191 |
function wck_cptc_form_wrapper_end(){
|
192 |
+
echo '</ul></li>';
|
193 |
}
|
194 |
|
195 |
/* advanced label options container for update form */
|
196 |
add_filter( "wck_before_update_form_wck_cptc_element_7", 'wck_cptc_update_form_label_wrapper_start', 10, 2 );
|
197 |
function wck_cptc_update_form_label_wrapper_start( $form, $i ){
|
198 |
+
$form .= '<li><a href="javascript:void(0)" onclick="jQuery(\'#cptc-advanced-label-options-update-container-'.$i.'\').toggle(); if( jQuery(this).text() == \''. __( 'Show Advanced Label Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Hide Advanced Label Options', 'wck' ) .'\'); else if( jQuery(this).text() == \''. __( 'Hide Advanced Label Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Show Advanced Label Options', 'wck' ) .'\');">'. __( 'Show Advanced Label Options', 'wck' ) .'</a></li>';
|
199 |
+
$form .= '<li id="cptc-advanced-label-options-update-container-'.$i.'" style="display:none;"><ul>';
|
200 |
+
return $form;
|
201 |
}
|
202 |
|
203 |
add_filter( "wck_after_update_form_wck_cptc_element_17", 'wck_cptc_update_form_label_wrapper_end', 10, 2 );
|
204 |
function wck_cptc_update_form_label_wrapper_end( $form, $i ){
|
205 |
+
$form .= '</ul></li>';
|
206 |
+
return $form;
|
207 |
}
|
208 |
|
209 |
/* advanced options container for update form */
|
210 |
add_filter( "wck_before_update_form_wck_cptc_element_18", 'wck_cptc_update_form_wrapper_start', 10, 2 );
|
211 |
function wck_cptc_update_form_wrapper_start( $form, $i ){
|
212 |
+
$form .= '<li><a href="javascript:void(0)" onclick="jQuery(\'#cptc-advanced-options-update-container-'.$i.'\').toggle(); if( jQuery(this).text() == \''. __( 'Show Advanced Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Hide Advanced Options', 'wck' ) .'\'); else if( jQuery(this).text() == \''. __( 'Hide Advanced Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Show Advanced Options', 'wck' ) .'\');">'. __( 'Show Advanced Options', 'wck' ) .'</a></li>';
|
213 |
+
$form .= '<li id="cptc-advanced-options-update-container-'.$i.'" style="display:none;"><ul>';
|
214 |
+
return $form;
|
215 |
}
|
216 |
|
217 |
+
add_filter( "wck_after_update_form_wck_cptc_element_28", 'wck_cptc_update_form_wrapper_end', 10, 2 );
|
218 |
function wck_cptc_update_form_wrapper_end( $form, $i ){
|
219 |
+
$form .= '</ul></li>';
|
220 |
+
return $form;
|
221 |
}
|
222 |
|
223 |
|
224 |
/* advanced label options container for display */
|
225 |
add_filter( "wck_before_listed_wck_cptc_element_7", 'wck_cptc_display_label_wrapper_start', 10, 2 );
|
226 |
function wck_cptc_display_label_wrapper_start( $form, $i ){
|
227 |
+
$form .= '<li><a href="javascript:void(0)" onclick="jQuery(\'#cptc-advanced-label-options-display-container-'.$i.'\').toggle(); if( jQuery(this).text() == \''. __( 'Show Advanced Labels', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Hide Advanced Labels', 'wck' ) .'\'); else if( jQuery(this).text() == \''. __( 'Hide Advanced Labels', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Show Advanced Labels', 'wck' ) .'\');">'. __( 'Show Advanced Labels', 'wck' ) .'</a></li>';
|
228 |
+
$form .= '<li id="cptc-advanced-label-options-display-container-'.$i.'" style="display:none;"><ul>';
|
229 |
+
return $form;
|
230 |
}
|
231 |
|
232 |
add_filter( "wck_after_listed_wck_cptc_element_17", 'wck_cptc_display_label_wrapper_end', 10, 2 );
|
233 |
function wck_cptc_display_label_wrapper_end( $form, $i ){
|
234 |
+
$form .= '</ul></li>';
|
235 |
+
return $form;
|
236 |
}
|
237 |
|
238 |
/* advanced options container for display */
|
239 |
add_filter( "wck_before_listed_wck_cptc_element_18", 'wck_cptc_display_adv_wrapper_start', 10, 2 );
|
240 |
function wck_cptc_display_adv_wrapper_start( $form, $i ){
|
241 |
+
$form .= '<li><a href="javascript:void(0)" onclick="jQuery(\'#cptc-advanced-options-display-container-'.$i.'\').toggle(); if( jQuery(this).text() == \''. __( 'Show Advanced Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Hide Advanced Options', 'wck' ) .'\'); else if( jQuery(this).text() == \''. __( 'Hide Advanced Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Show Advanced Options', 'wck' ) .'\');">'. __( 'Show Advanced Options', 'wck' ) .'</a></li>';
|
242 |
+
$form .= '<li id="cptc-advanced-options-display-container-'.$i.'" style="display:none;"><ul>';
|
243 |
+
return $form;
|
244 |
}
|
245 |
|
246 |
+
add_filter( "wck_after_listed_wck_cptc_element_28", 'wck_cptc_display_adv_wrapper_end', 10, 2 );
|
247 |
function wck_cptc_display_adv_wrapper_end( $form, $i ){
|
248 |
+
$form .= '</ul></li>';
|
249 |
+
return $form;
|
250 |
}
|
251 |
|
252 |
/* add refresh to page */
|
253 |
add_action("wck_refresh_list_wck_cptc", "wck_cptc_after_refresh_list");
|
254 |
add_action("wck_refresh_entry_wck_cptc", "wck_cptc_after_refresh_list");
|
255 |
function wck_cptc_after_refresh_list(){
|
256 |
+
echo '<script type="text/javascript">window.location="'. get_admin_url() . 'admin.php?page=cptc-page&updated=true' .'";</script>';
|
257 |
}
|
258 |
|
259 |
/* Add side metaboxes */
|
277 |
/* Contextual Help */
|
278 |
add_action('load-wck_page_cptc-page', 'wck_cptc_help');
|
279 |
|
280 |
+
function wck_cptc_help () {
|
281 |
$screen = get_current_screen();
|
282 |
|
283 |
/*
|
293 |
'title' => __('Overview', 'wck' ),
|
294 |
'content' => '<p>' . __( 'WCK Custom Post Type Creator allows you to easily create custom post types for Wordpress without any programming knowledge.<br />Most of the common options for creating a post type are displayed by default while the advanced options and label are just one click away.', 'wck' ) . '</p>',
|
295 |
) );
|
296 |
+
|
297 |
+
$screen->add_help_tab( array(
|
298 |
'id' => 'wck_cptc_labels',
|
299 |
'title' => __( 'Labels', 'wck' ),
|
300 |
'content' => '<p>' . __( 'For simplicity you are required to introduce only the Singular Label and Plural Label from wchich the rest of the labels will be formed.<br />For a more detailed control of the labels you just have to click the "Show Advanced Label Options" link and all the availabel labels will be displayed.', 'wck' ) . '</p>',
|
301 |
) );
|
302 |
+
|
303 |
+
$screen->add_help_tab( array(
|
304 |
'id' => 'wck_cptc_advanced',
|
305 |
'title' => __('Advanced Options', 'wck' ),
|
306 |
'content' => '<p>' . __( 'The Advanced Options are set to the most common defaults for custom post types. To display them click the "Show Advanced Options" link.', 'wck' ) . '</p>',
|
wck-ctc.php
CHANGED
@@ -2,218 +2,220 @@
|
|
2 |
/* Creates Custom Taxonomies for WordPress */
|
3 |
|
4 |
/* Create the CTC Page only for admins ( 'capability' => 'edit_theme_options' ) */
|
5 |
-
$args = array(
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
new WCK_Page_Creator( $args );
|
16 |
|
17 |
/* create the meta box only for admins ( 'capability' => 'edit_theme_options' ) */
|
18 |
add_action( 'init', 'wck_ctc_create_box', 11 );
|
19 |
function wck_ctc_create_box(){
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
75 |
}
|
76 |
|
77 |
add_action( 'init', 'wck_ctc_create_taxonomy', 8 );
|
78 |
|
79 |
function wck_ctc_create_taxonomy(){
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
122 |
}
|
123 |
|
124 |
/* Flush rewrite rules */
|
125 |
add_action('init', 'ctc_flush_rules', 20);
|
126 |
function ctc_flush_rules(){
|
127 |
-
|
128 |
-
|
129 |
}
|
130 |
|
131 |
/* add refresh to page */
|
132 |
add_action("wck_refresh_list_wck_ctc", "wck_ctc_after_refresh_list");
|
133 |
add_action("wck_refresh_entry_wck_ctc", "wck_ctc_after_refresh_list");
|
134 |
function wck_ctc_after_refresh_list(){
|
135 |
-
|
136 |
}
|
137 |
|
138 |
/* advanced labels container for add form */
|
139 |
add_action( "wck_before_add_form_wck_ctc_element_5", 'wck_ctc_form_label_wrapper_start' );
|
140 |
function wck_ctc_form_label_wrapper_start(){
|
141 |
-
|
142 |
-
|
143 |
}
|
144 |
|
145 |
add_action( "wck_after_add_form_wck_ctc_element_17", 'wck_ctc_form_label_wrapper_end' );
|
146 |
function wck_ctc_form_label_wrapper_end(){
|
147 |
-
|
148 |
}
|
149 |
|
150 |
/* advanced options container for add form */
|
151 |
add_action( "wck_before_add_form_wck_ctc_element_18", 'wck_ctc_form_wrapper_start' );
|
152 |
function wck_ctc_form_wrapper_start(){
|
153 |
-
|
154 |
-
|
155 |
}
|
156 |
|
157 |
-
add_action( "
|
158 |
function wck_ctc_form_wrapper_end(){
|
159 |
-
|
160 |
}
|
161 |
|
162 |
/* advanced label options container for update form */
|
163 |
add_filter( "wck_before_update_form_wck_ctc_element_5", 'wck_ctc_update_form_label_wrapper_start', 10, 2 );
|
164 |
function wck_ctc_update_form_label_wrapper_start( $form, $i ){
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
}
|
169 |
|
170 |
add_filter( "wck_after_update_form_wck_ctc_element_17", 'wck_ctc_update_form_label_wrapper_end', 10, 2 );
|
171 |
function wck_ctc_update_form_label_wrapper_end( $form, $i ){
|
172 |
-
|
173 |
-
|
174 |
}
|
175 |
|
176 |
/* advanced options container for update form */
|
177 |
add_filter( "wck_before_update_form_wck_ctc_element_18", 'wck_ctc_update_form_wrapper_start', 10, 2 );
|
178 |
function wck_ctc_update_form_wrapper_start( $form, $i ){
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
}
|
183 |
|
184 |
-
add_filter( "
|
185 |
function wck_ctc_update_form_wrapper_end( $form, $i ){
|
186 |
-
|
187 |
-
|
188 |
}
|
189 |
|
190 |
|
191 |
/* advanced label options container for display */
|
192 |
add_filter( "wck_before_listed_wck_ctc_element_5", 'wck_ctc_display_label_wrapper_start', 10, 2 );
|
193 |
function wck_ctc_display_label_wrapper_start( $form, $i ){
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
}
|
198 |
|
199 |
add_filter( "wck_after_listed_wck_ctc_element_17", 'wck_ctc_display_label_wrapper_end', 10, 2 );
|
200 |
function wck_ctc_display_label_wrapper_end( $form, $i ){
|
201 |
-
|
202 |
-
|
203 |
}
|
204 |
|
205 |
/* advanced options container for display */
|
206 |
add_filter( "wck_before_listed_wck_ctc_element_18", 'wck_ctc_display_adv_wrapper_start', 10, 2 );
|
207 |
function wck_ctc_display_adv_wrapper_start( $form, $i ){
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
}
|
212 |
|
213 |
-
add_filter( "
|
214 |
function wck_ctc_display_adv_wrapper_end( $form, $i ){
|
215 |
-
|
216 |
-
|
217 |
}
|
218 |
|
219 |
/* Add side metaboxes */
|
@@ -236,7 +238,7 @@ if( !file_exists( dirname(__FILE__).'/wck-stp.php' ) ) {
|
|
236 |
/* Contextual Help */
|
237 |
add_action('load-wck_page_ctc-page', 'wck_ctc_help');
|
238 |
|
239 |
-
function wck_ctc_help () {
|
240 |
$screen = get_current_screen();
|
241 |
|
242 |
/*
|
@@ -252,14 +254,14 @@ function wck_ctc_help () {
|
|
252 |
'title' => __( 'Overview', 'wck' ),
|
253 |
'content' => '<p>' . __( 'WCK Custom Taxonomy Creator allows you to easily create custom taxonomy for Wordpress without any programming knowledge.<br />Most of the common options for creating a taxonomy are displayed by default while the advanced and label options are just one click away.', 'wck' ) . '</p>',
|
254 |
) );
|
255 |
-
|
256 |
-
|
257 |
'id' => 'wck_ctc_labels',
|
258 |
'title' => __( 'Labels', 'wck' ),
|
259 |
'content' => '<p>' . __( 'For simplicity you are required to introduce only the Singular Label and Plural Label from wchich the rest of the labels will be formed.<br />For a more detailed control of the labels you just have to click the "Show Advanced Label Options" link and all the availabel labels will be displayed', 'wck' ) . '</p>',
|
260 |
) );
|
261 |
-
|
262 |
-
|
263 |
'id' => 'wck_ctc_advanced',
|
264 |
'title' => __( 'Advanced Options', 'wck' ),
|
265 |
'content' => '<p>' . __( 'The Advanced Options are set to the most common defaults for taxonomies. To display them click the "Show Advanced Options" link.', 'wck' ) . '</p>',
|
2 |
/* Creates Custom Taxonomies for WordPress */
|
3 |
|
4 |
/* Create the CTC Page only for admins ( 'capability' => 'edit_theme_options' ) */
|
5 |
+
$args = array(
|
6 |
+
'page_title' => __( 'WCK Taxonomy Creator', 'wck' ),
|
7 |
+
'menu_title' => __( 'Taxonomy Creator', 'wck' ),
|
8 |
+
'capability' => 'edit_theme_options',
|
9 |
+
'menu_slug' => 'ctc-page',
|
10 |
+
'page_type' => 'submenu_page',
|
11 |
+
'parent_slug' => 'wck-page',
|
12 |
+
'priority' => 9,
|
13 |
+
'page_icon' => plugins_url('/images/wck-32x32.png', __FILE__)
|
14 |
+
);
|
15 |
new WCK_Page_Creator( $args );
|
16 |
|
17 |
/* create the meta box only for admins ( 'capability' => 'edit_theme_options' ) */
|
18 |
add_action( 'init', 'wck_ctc_create_box', 11 );
|
19 |
function wck_ctc_create_box(){
|
20 |
+
|
21 |
+
if( is_admin() && current_user_can( 'edit_theme_options' ) ){
|
22 |
+
$args = array(
|
23 |
+
'public' => true
|
24 |
+
);
|
25 |
+
$output = 'objects'; // or objects
|
26 |
+
$post_types = get_post_types($args,$output);
|
27 |
+
$post_type_names = array();
|
28 |
+
if( !empty( $post_types ) ){
|
29 |
+
foreach ( $post_types as $post_type ) {
|
30 |
+
if ( $post_type->name != 'attachment' && $post_type->name != 'wck-meta-box' && $post_type->name != 'wck-frontend-posting' && $post_type->name != 'wck-option-page' && $post_type->name != 'wck-option-field' && $post_type->name != 'wck-swift-template' )
|
31 |
+
$post_type_names[] = $post_type->name;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
$ct_creation_fields = array(
|
37 |
+
array( 'type' => 'text', 'title' => __( 'Taxonomy', 'wck' ), 'slug' => 'taxonomy', 'description' => __( '(The name of the taxonomy. Name must not contain capital letters or spaces.)', 'wck' ), 'required' => true ),
|
38 |
+
array( 'type' => 'text', 'title' => __( 'Singular Label', 'wck' ), 'slug' => 'singular-label', 'required' => true, 'description' => __( 'ex. Writer', 'wck' ) ),
|
39 |
+
array( 'type' => 'text', 'title' => __( 'Plural Label', 'wck' ), 'slug' => 'plural-label', 'required' => true, 'description' => __( 'ex. Writers', 'wck' ) ),
|
40 |
+
array( 'type' => 'checkbox', 'title' => __( 'Attach to', 'wck' ), 'slug' => 'attach-to', 'options' => $post_type_names ),
|
41 |
+
array( 'type' => 'select', 'title' => __( 'Hierarchical', 'wck' ), 'slug' => 'hierarchical', 'options' => array( 'false', 'true' ), 'default' => 'false', 'description' => __( 'Is this taxonomy hierarchical (have descendants) like categories or not hierarchical like tags.', 'wck' ) ),
|
42 |
+
|
43 |
+
array( 'type' => 'text', 'title' => __( 'Search Items', 'wck' ), 'slug' => 'search-items', 'description' => __( 'ex. Search Writers', 'wck' ) ),
|
44 |
+
array( 'type' => 'text', 'title' => __( 'Popular Items', 'wck' ), 'slug' => 'popular-items', 'description' => __( 'ex. Popular Writers', 'wck' ) ),
|
45 |
+
array( 'type' => 'text', 'title' => __( 'All Items', 'wck' ), 'slug' => 'all-items', 'description' => __( 'ex. All Writers', 'wck' ) ),
|
46 |
+
array( 'type' => 'text', 'title' => __( 'Parent Item', 'wck' ), 'slug' => 'parent-item', 'description' => __( 'ex. Parent Genre', 'wck' ) ),
|
47 |
+
array( 'type' => 'text', 'title' => __( 'Parent Item Colon', 'wck' ), 'slug' => 'parent-item-colon', 'description' => __( 'ex. Parent Genre:', 'wck' ) ),
|
48 |
+
array( 'type' => 'text', 'title' => __( 'Edit Item', 'wck' ), 'slug' => 'edit-item', 'description' => __( 'ex. Edit Writer', 'wck' ) ),
|
49 |
+
array( 'type' => 'text', 'title' => __( 'Update Item', 'wck' ), 'slug' => 'update-item', 'description' => __( 'ex. Update Writer', 'wck' ) ),
|
50 |
+
array( 'type' => 'text', 'title' => __( 'Add New Item', 'wck' ), 'slug' => 'add-new-item', 'description' => __( 'ex. Add New Writer', 'wck' ) ),
|
51 |
+
array( 'type' => 'text', 'title' => __( 'New Item Name', 'wck' ), 'slug' => 'new-item-name', 'description' => __( 'ex. New Writer Name', 'wck' ) ),
|
52 |
+
array( 'type' => 'text', 'title' => __( 'Separate Items With Commas', 'wck' ), 'slug' => 'separate-items-with-commas', 'description' => __( 'ex. Separate writers with commas', 'wck' ) ),
|
53 |
+
array( 'type' => 'text', 'title' => __( 'Add Or Remove Items', 'wck' ), 'slug' => 'add-or-remove-items', 'description' => __( 'ex. Add or remove writers', 'wck' ) ),
|
54 |
+
array( 'type' => 'text', 'title' => __( 'Choose From Most Used', 'wck' ), 'slug' => 'choose-from-most-used', 'description' => __( 'ex. Choose from the most used writers', 'wck' ) ),
|
55 |
+
array( 'type' => 'text', 'title' => __( 'Menu Name', 'wck' ), 'slug' => 'menu-name' ),
|
56 |
+
|
57 |
+
array( 'type' => 'select', 'title' => __( 'Public', 'wck' ), 'slug' => 'public', 'options' => array( 'false', 'true' ), 'default' => 'true', 'description' => __( 'Meta argument used to define default values for publicly_queriable, show_ui, show_in_nav_menus and exclude_from_search', 'wck' ) ),
|
58 |
+
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' ) ),
|
59 |
+
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' ) ),
|
60 |
+
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' ) ),
|
61 |
+
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' ) )
|
62 |
+
);
|
63 |
+
|
64 |
+
$args = array(
|
65 |
+
'metabox_id' => 'ctc_creation_box',
|
66 |
+
'metabox_title' => __( 'Custom Taxonomy Creation', 'wck' ),
|
67 |
+
'post_type' => 'ctc-page',
|
68 |
+
'meta_name' => 'wck_ctc',
|
69 |
+
'meta_array' => $ct_creation_fields,
|
70 |
+
'context' => 'option'
|
71 |
+
);
|
72 |
+
|
73 |
+
|
74 |
+
new Wordpress_Creation_Kit( $args );
|
75 |
+
}
|
76 |
}
|
77 |
|
78 |
add_action( 'init', 'wck_ctc_create_taxonomy', 8 );
|
79 |
|
80 |
function wck_ctc_create_taxonomy(){
|
81 |
+
$cts = get_option('wck_ctc');
|
82 |
+
if( !empty( $cts ) ){
|
83 |
+
foreach( $cts as $ct ){
|
84 |
+
|
85 |
+
$labels = array(
|
86 |
+
'name' => _x( $ct['plural-label'], 'taxonomy general name' ),
|
87 |
+
'singular_name' => _x( $ct['singular-label'], 'taxonomy singular name'),
|
88 |
+
'search_items' => __( $ct['search-items'] ? $ct['search-items'] : 'Search '.$ct['plural-label'], 'wck' ),
|
89 |
+
'popular_items' => __( $ct['popular-items'] ? $ct['popular-items'] : "Popular ".$ct['plural-label'], 'wck' ),
|
90 |
+
'all_items' => __( $ct['all-items'] ? $ct['all-items'] : "All ".$ct['plural-label'], 'wck' ) ,
|
91 |
+
'parent_item' => __( $ct['parent-item'] ? $ct['parent-item'] : "Parent ".$ct['singular-label'], 'wck' ),
|
92 |
+
'parent_item_colon' => __( $ct['parent-item-colon'] ? $ct['parent-item-colon'] : "Parent ".$ct['singular-label'].':', 'wck' ),
|
93 |
+
'edit_item' => __( $ct['edit-item'] ? $ct['edit-item'] : "Edit ".$ct['singular-label'], 'wck' ),
|
94 |
+
'update_item' => __( $ct['update-item'] ? $ct['update-item'] : "Update ".$ct['singular-label'], 'wck' ),
|
95 |
+
'add_new_item' => __( $ct['add-new-item'] ? $ct['add-new-item'] : "Add New ". $ct['singular-label'], 'wck' ),
|
96 |
+
'new_item_name' => __( $ct['new-item-name'] ? $ct['new-item-name'] : "New ". $ct['singular-label']. ' Name', 'wck' ),
|
97 |
+
'separate_items_with_commas' => __( $ct['separate-items-with-commas'] ? $ct['separate-items-with-commas'] : "Separate ". strtolower( $ct['plural-label'] ). ' with commas', 'wck' ),
|
98 |
+
'add_or_remove_items' => __( $ct['add-or-remove-items'] ? $ct['add-or-remove-items'] : "Add or remove " .strtolower( $ct['plural-label'] ), 'wck' ),
|
99 |
+
'choose_from_most_used' => __( $ct['choose-from-most-used'] ? $ct['choose-from-most-used'] : "Choose from the most used " .strtolower( $ct['plural-label'] ), 'wck' ),
|
100 |
+
'menu_name' => $ct['menu-name'] ? $ct['menu-name'] : $ct['plural-label']
|
101 |
+
);
|
102 |
+
|
103 |
+
$args = array(
|
104 |
+
'labels' => $labels,
|
105 |
+
'public' => $ct['public'] == 'false' ? false : true,
|
106 |
+
'show_ui' => $ct['show-ui'] == 'false' ? false : true,
|
107 |
+
'hierarchical' => $ct['hierarchical'] == 'false' ? false : true,
|
108 |
+
'show_tagcloud' => $ct['show-tagcloud'] == 'false' ? false : true,
|
109 |
+
'show_in_rest' => !empty($ct['show-in-rest']) ? $ct['show-in-rest'] : false,
|
110 |
+
);
|
111 |
+
|
112 |
+
if( !empty( $ct['show-admin-column'] ) ){
|
113 |
+
$args['show_admin_column'] = $ct['show-admin-column'] == 'false' ? false : true;
|
114 |
+
}
|
115 |
+
|
116 |
+
if( !empty( $ct['attach-to'] ) )
|
117 |
+
$object_type = explode( ', ', $ct['attach-to'] );
|
118 |
+
else
|
119 |
+
$object_type = '';
|
120 |
+
|
121 |
+
register_taxonomy( $ct['taxonomy'], $object_type, apply_filters( 'wck_ctc_register_taxonomy_args', $args, $ct['taxonomy'] ) );
|
122 |
+
}
|
123 |
+
}
|
124 |
}
|
125 |
|
126 |
/* Flush rewrite rules */
|
127 |
add_action('init', 'ctc_flush_rules', 20);
|
128 |
function ctc_flush_rules(){
|
129 |
+
if( isset( $_GET['page'] ) && $_GET['page'] == 'ctc-page' && isset( $_GET['updated'] ) && $_GET['updated'] == 'true' )
|
130 |
+
flush_rewrite_rules( false );
|
131 |
}
|
132 |
|
133 |
/* add refresh to page */
|
134 |
add_action("wck_refresh_list_wck_ctc", "wck_ctc_after_refresh_list");
|
135 |
add_action("wck_refresh_entry_wck_ctc", "wck_ctc_after_refresh_list");
|
136 |
function wck_ctc_after_refresh_list(){
|
137 |
+
echo '<script type="text/javascript">window.location="'. get_admin_url() . 'admin.php?page=ctc-page&updated=true' .'";</script>';
|
138 |
}
|
139 |
|
140 |
/* advanced labels container for add form */
|
141 |
add_action( "wck_before_add_form_wck_ctc_element_5", 'wck_ctc_form_label_wrapper_start' );
|
142 |
function wck_ctc_form_label_wrapper_start(){
|
143 |
+
echo '<li><a href="javascript:void(0)" onclick="jQuery(\'#ctc-advanced-label-options-container\').toggle(); if( jQuery(this).text() == \''. __( 'Show Advanced Label Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Hide Advanced Label Options', 'wck' ) .'\'); else if( jQuery(this).text() == \''. __( 'Hide Advanced Label Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Show Advanced Label Options', 'wck' ) .'\');">'. __( 'Show Advanced Label Options', 'wck' ) .'</a></li>';
|
144 |
+
echo '<li id="ctc-advanced-label-options-container" style="display:none;"><ul>';
|
145 |
}
|
146 |
|
147 |
add_action( "wck_after_add_form_wck_ctc_element_17", 'wck_ctc_form_label_wrapper_end' );
|
148 |
function wck_ctc_form_label_wrapper_end(){
|
149 |
+
echo '</ul></li>';
|
150 |
}
|
151 |
|
152 |
/* advanced options container for add form */
|
153 |
add_action( "wck_before_add_form_wck_ctc_element_18", 'wck_ctc_form_wrapper_start' );
|
154 |
function wck_ctc_form_wrapper_start(){
|
155 |
+
echo '<li><a href="javascript:void(0)" onclick="jQuery(\'#ctc-advanced-options-container\').toggle(); if( jQuery(this).text() == \''. __( 'Show Advanced Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Hide Advanced Options', 'wck' ) .'\'); else if( jQuery(this).text() == \''. __( 'Hide Advanced Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Show Advanced Options', 'wck' ) .'\');">'. __( 'Show Advanced Options', 'wck' ) .'</a></li>';
|
156 |
+
echo '<li id="ctc-advanced-options-container" style="display:none;"><ul>';
|
157 |
}
|
158 |
|
159 |
+
add_action( "wck_after_add_form_wck_ctc_element_22", 'wck_ctc_form_wrapper_end' );
|
160 |
function wck_ctc_form_wrapper_end(){
|
161 |
+
echo '</ul></li>';
|
162 |
}
|
163 |
|
164 |
/* advanced label options container for update form */
|
165 |
add_filter( "wck_before_update_form_wck_ctc_element_5", 'wck_ctc_update_form_label_wrapper_start', 10, 2 );
|
166 |
function wck_ctc_update_form_label_wrapper_start( $form, $i ){
|
167 |
+
$form .= '<li><a href="javascript:void(0)" onclick="jQuery(\'#ctc-advanced-label-options-update-container-'.$i.'\').toggle(); if( jQuery(this).text() == \''. __( 'Show Advanced Label Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Hide Advanced Label Options', 'wck' ) .'\'); else if( jQuery(this).text() == \''. __( 'Hide Advanced Label Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Show Advanced Label Options', 'wck' ) .'\');">'. __( 'Show Advanced Label Options', 'wck' ) .'</a></li>';
|
168 |
+
$form .= '<li id="ctc-advanced-label-options-update-container-'.$i.'" style="display:none;"><ul>';
|
169 |
+
return $form;
|
170 |
}
|
171 |
|
172 |
add_filter( "wck_after_update_form_wck_ctc_element_17", 'wck_ctc_update_form_label_wrapper_end', 10, 2 );
|
173 |
function wck_ctc_update_form_label_wrapper_end( $form, $i ){
|
174 |
+
$form .= '</ul></li>';
|
175 |
+
return $form;
|
176 |
}
|
177 |
|
178 |
/* advanced options container for update form */
|
179 |
add_filter( "wck_before_update_form_wck_ctc_element_18", 'wck_ctc_update_form_wrapper_start', 10, 2 );
|
180 |
function wck_ctc_update_form_wrapper_start( $form, $i ){
|
181 |
+
$form .= '<li><a href="javascript:void(0)" onclick="jQuery(\'#ctc-advanced-options-update-container-'.$i.'\').toggle(); if( jQuery(this).text() == \''. __( 'Show Advanced Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Hide Advanced Options', 'wck' ) .'\'); else if( jQuery(this).text() == \''. __( 'Hide Advanced Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Show Advanced Options', 'wck' ) .'\');">'. __( 'Show Advanced Options', 'wck' ) .'</a></li>';
|
182 |
+
$form .= '<li id="ctc-advanced-options-update-container-'.$i.'" style="display:none;"><ul>';
|
183 |
+
return $form;
|
184 |
}
|
185 |
|
186 |
+
add_filter( "wck_after_update_form_wck_ctc_element_22", 'wck_ctc_update_form_wrapper_end', 10, 2 );
|
187 |
function wck_ctc_update_form_wrapper_end( $form, $i ){
|
188 |
+
$form .= '</ul></li>';
|
189 |
+
return $form;
|
190 |
}
|
191 |
|
192 |
|
193 |
/* advanced label options container for display */
|
194 |
add_filter( "wck_before_listed_wck_ctc_element_5", 'wck_ctc_display_label_wrapper_start', 10, 2 );
|
195 |
function wck_ctc_display_label_wrapper_start( $form, $i ){
|
196 |
+
$form .= '<li><a href="javascript:void(0)" onclick="jQuery(\'#ctc-advanced-label-options-display-container-'.$i.'\').toggle(); if( jQuery(this).text() == \''. __( 'Show Advanced Labels', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Hide Advanced Labels', 'wck' ) .'\'); else if( jQuery(this).text() == \''. __( 'Hide Advanced Labels', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Show Advanced Labels', 'wck' ) .'\');">'. __( 'Show Advanced Labels', 'wck' ) .'</a></li>';
|
197 |
+
$form .= '<li id="ctc-advanced-label-options-display-container-'.$i.'" style="display:none;"><ul>';
|
198 |
+
return $form;
|
199 |
}
|
200 |
|
201 |
add_filter( "wck_after_listed_wck_ctc_element_17", 'wck_ctc_display_label_wrapper_end', 10, 2 );
|
202 |
function wck_ctc_display_label_wrapper_end( $form, $i ){
|
203 |
+
$form .= '</ul></li>';
|
204 |
+
return $form;
|
205 |
}
|
206 |
|
207 |
/* advanced options container for display */
|
208 |
add_filter( "wck_before_listed_wck_ctc_element_18", 'wck_ctc_display_adv_wrapper_start', 10, 2 );
|
209 |
function wck_ctc_display_adv_wrapper_start( $form, $i ){
|
210 |
+
$form .= '<li><a href="javascript:void(0)" onclick="jQuery(\'#ctc-advanced-options-display-container-'.$i.'\').toggle(); if( jQuery(this).text() == \''. __( 'Show Advanced Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Hide Advanced Options', 'wck' ) .'\'); else if( jQuery(this).text() == \''. __( 'Hide Advanced Options', 'wck' ) .'\' ) jQuery(this).text(\''. __( 'Show Advanced Options', 'wck' ) .'\');">'. __( 'Show Advanced Options', 'wck' ) .'</a></li>';
|
211 |
+
$form .= '<li id="ctc-advanced-options-display-container-'.$i.'" style="display:none;"><ul>';
|
212 |
+
return $form;
|
213 |
}
|
214 |
|
215 |
+
add_filter( "wck_after_listed_wck_ctc_element_22", 'wck_ctc_display_adv_wrapper_end', 10, 2 );
|
216 |
function wck_ctc_display_adv_wrapper_end( $form, $i ){
|
217 |
+
$form .= '</ul></li>';
|
218 |
+
return $form;
|
219 |
}
|
220 |
|
221 |
/* Add side metaboxes */
|
238 |
/* Contextual Help */
|
239 |
add_action('load-wck_page_ctc-page', 'wck_ctc_help');
|
240 |
|
241 |
+
function wck_ctc_help () {
|
242 |
$screen = get_current_screen();
|
243 |
|
244 |
/*
|
254 |
'title' => __( 'Overview', 'wck' ),
|
255 |
'content' => '<p>' . __( 'WCK Custom Taxonomy Creator allows you to easily create custom taxonomy for Wordpress without any programming knowledge.<br />Most of the common options for creating a taxonomy are displayed by default while the advanced and label options are just one click away.', 'wck' ) . '</p>',
|
256 |
) );
|
257 |
+
|
258 |
+
$screen->add_help_tab( array(
|
259 |
'id' => 'wck_ctc_labels',
|
260 |
'title' => __( 'Labels', 'wck' ),
|
261 |
'content' => '<p>' . __( 'For simplicity you are required to introduce only the Singular Label and Plural Label from wchich the rest of the labels will be formed.<br />For a more detailed control of the labels you just have to click the "Show Advanced Label Options" link and all the availabel labels will be displayed', 'wck' ) . '</p>',
|
262 |
) );
|
263 |
+
|
264 |
+
$screen->add_help_tab( array(
|
265 |
'id' => 'wck_ctc_advanced',
|
266 |
'title' => __( 'Advanced Options', 'wck' ),
|
267 |
'content' => '<p>' . __( 'The Advanced Options are set to the most common defaults for taxonomies. To display them click the "Show Advanced Options" link.', 'wck' ) . '</p>',
|
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.1.
|
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: 1.1.8
|
7 |
Author URI: http://www.cozmoslabs.com
|
8 |
|
9 |
License: GPL2
|
wordpress-creation-kit-api/wordpress-creation-kit.php
CHANGED
@@ -1503,7 +1503,7 @@ class WCK_Page_Creator{
|
|
1503 |
* Do action 'add_meta_boxes'. This hook isn't executed by default on a admin page so we have to add it.
|
1504 |
*/
|
1505 |
function wck_settings_page_add_meta_boxes() {
|
1506 |
-
do_action( 'add_meta_boxes', $this->hookname );
|
1507 |
}
|
1508 |
|
1509 |
/**
|
1503 |
* Do action 'add_meta_boxes'. This hook isn't executed by default on a admin page so we have to add it.
|
1504 |
*/
|
1505 |
function wck_settings_page_add_meta_boxes() {
|
1506 |
+
do_action( 'add_meta_boxes', $this->hookname, 0 );
|
1507 |
}
|
1508 |
|
1509 |
/**
|