Custom Post Type UI - Version 1.2.0

Version Description

  • Added: Support for show_in_nav_menus parameter for post types.
  • Added: Support for taxonomy descriptions.
  • Added: Message on listings page if no post types or taxonomies are available.
  • Added: Note regarding 'public' parameter not being true by default for WordPress but is for CPTUI.
  • Added: Individual post type and taxonomy output for "Get Code" area.
  • Added: Fallback values for post type/taxonomy select input and get code area if no plural label provided.
  • Added: Support for custom query_var strings for post types.
  • Added: Support for show_in_rest and rest_base for post types and taxonomies for the upcoming WordPress REST API.
  • Added: Template hierarchy files to listings tables for user reference.
  • Added: Form labels in more areas to help with accessibility and usability.
  • Added: Fieldset method to Admin UI class for easily adding fieldset output.
  • Added: Debugging tab for use with CPTUI support.
  • Updated: Minimum version required. Now WordPress 4.2.
  • Updated: Heading tags match accessibility changes in WordPress 4.3.
  • Updated: Moved page title for some pages above tabs.
  • Updated: Textdomain now matches WordPress.org repo slug.
  • Updated: Added Visual Composer questions/answers to support section.
  • Updated: Added question/answer regarding spaces in post type slugs
  • Updated: Changed help icons to a Dashicon help icon.
  • Fixed: Support for YARPP plugin.
  • Fixed: Prevent potential issues with AJAX requests and our scripts/styles
Download this release

Release Info

Developer tw2113
Plugin Icon 128x128 Custom Post Type UI
Version 1.2.0
Comparing to
See all releases

Code changes from version 1.1.3 to 1.2.0

classes/class.cptui_admin_ui.php CHANGED
@@ -11,7 +11,7 @@ class cptui_admin_ui {
11
  /**
12
  * Return an opening <tr> tag.
13
  *
14
- * @since 1.0
15
  *
16
  * @return string $value Opening <tr> tag with attributes.
17
  */
@@ -22,7 +22,7 @@ class cptui_admin_ui {
22
  /**
23
  * Return a closing </tr> tag.
24
  *
25
- * @since 1.0
26
  *
27
  * @return string $value Closing </tr> tag.
28
  */
@@ -33,7 +33,7 @@ class cptui_admin_ui {
33
  /**
34
  * Return an opening <th> tag.
35
  *
36
- * @since 1.0
37
  *
38
  * @return string $value Opening <th> tag with attributes.
39
  */
@@ -44,7 +44,7 @@ class cptui_admin_ui {
44
  /**
45
  * Return a closing </th> tag.
46
  *
47
- * @since 1.0
48
  *
49
  * @return string $value Closing </th> tag.
50
  */
@@ -55,7 +55,7 @@ class cptui_admin_ui {
55
  /**
56
  * Return an opening <td> tag.
57
  *
58
- * @since 1.0
59
  *
60
  * @return string $value Opening <td> tag.
61
  */
@@ -66,7 +66,7 @@ class cptui_admin_ui {
66
  /**
67
  * Return a closing </td> tag.
68
  *
69
- * @since 1.0
70
  *
71
  * @return string $value Closing </td> tag.
72
  */
@@ -74,13 +74,34 @@ class cptui_admin_ui {
74
  return '</td>';
75
  }
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  /**
78
  * Return string wrapped in a <p> tag.
79
  *
80
- * @since 1.0
81
  *
82
  * @param string $text Content to wrap in a <p> tag.
83
- *
84
  * @return string $value Content wrapped in a <p> tag.
85
  */
86
  public function get_p( $text = '' ) {
@@ -90,11 +111,10 @@ class cptui_admin_ui {
90
  /**
91
  * Return a form <label> with for attribute.
92
  *
93
- * @since 1.0
94
  *
95
  * @param string $label_for Form input to associate <label> with.
96
  * @param string $label_text Text to display in the <label> tag.
97
- *
98
  * @return string $value <label> tag with filled out parts.
99
  */
100
  public function get_label( $label_for = '', $label_text = '' ) {
@@ -104,7 +124,7 @@ class cptui_admin_ui {
104
  /**
105
  * Return a <span> to indicate required status, with class attribute.
106
  *
107
- * @since 1.0
108
  *
109
  * @return string span tag.
110
  */
@@ -115,21 +135,21 @@ class cptui_admin_ui {
115
  /**
116
  * Return an <a> tag with title attribute holding help text.
117
  *
118
- * @since 1.0
119
  *
120
  * @param string $help_text Text to use in the title attribute.
121
- *
122
  * @return string <a> tag with filled out parts.
123
  */
124
  public function get_help( $help_text = '' ) {
125
- return '<a href="#" title="' . esc_attr( $help_text ) . '" class="cptui-help wp-ui-highlight">?</a>';
126
  }
127
 
128
  /**
129
  * Return a maxlength HTML attribute with a specified length.
130
  *
131
- * @param string $length How many characters the max length should be set to.
132
  *
 
133
  * @return string $value Maxlength HTML attribute.
134
  */
135
  public function get_maxlength( $length = '' ) {
@@ -139,8 +159,9 @@ class cptui_admin_ui {
139
  /**
140
  * Return a onblur HTML attribute for a specified value.
141
  *
142
- * @param string $text Text to place in the onblur attribute.
143
  *
 
144
  * @return string $value Onblur HTML attribute.
145
  */
146
  public function get_onblur( $text = '' ) {
@@ -150,10 +171,9 @@ class cptui_admin_ui {
150
  /**
151
  * Return a populated <select> input.
152
  *
153
- * @since 1.0
154
  *
155
  * @param array $args Arguments to use with the <select> input.
156
- *
157
  * @return string $value Complete <select> input with options and selected attribute.
158
  */
159
  public function get_select_input( $args = array() ) {
@@ -219,10 +239,9 @@ class cptui_admin_ui {
219
  /**
220
  * Return a text input.
221
  *
222
- * @since 1.0
223
  *
224
  * @param array $args Arguments to use with the text input.
225
- *
226
  * @return string Complete text <input> with proper attributes.
227
  */
228
  public function get_text_input( $args = array() ) {
@@ -278,10 +297,9 @@ class cptui_admin_ui {
278
  /**
279
  * Return a <textarea> input.
280
  *
281
- * @since 1.0
282
  *
283
  * @param array $args Arguments to use with the textarea input.
284
- *
285
  * @return string $value Complete <textarea> input with proper attributes.
286
  */
287
  public function get_textarea_input( $args = array() ) {
@@ -321,10 +339,9 @@ class cptui_admin_ui {
321
  /**
322
  * Return a checkbox <input>.
323
  *
324
- * @since 1.0
325
  *
326
  * @param array $args Arguments to use with the checkbox input.
327
- *
328
  * @return string $value Complete checkbox <input> with proper attributes.
329
  */
330
  public function get_check_input( $args = array() ) {
@@ -369,10 +386,9 @@ class cptui_admin_ui {
369
  /**
370
  * Return some array_merged default arguments for all input types.
371
  *
372
- * @since 1.0
373
  *
374
  * @param array $additions Arguments array to merge with our defaults.
375
- *
376
  * @return array $value Merged arrays for our default parameters.
377
  */
378
  public function get_default_input_parameters( $additions = array() ) {
11
  /**
12
  * Return an opening <tr> tag.
13
  *
14
+ * @since 1.0.0
15
  *
16
  * @return string $value Opening <tr> tag with attributes.
17
  */
22
  /**
23
  * Return a closing </tr> tag.
24
  *
25
+ * @since 1.0.0
26
  *
27
  * @return string $value Closing </tr> tag.
28
  */
33
  /**
34
  * Return an opening <th> tag.
35
  *
36
+ * @since 1.0.0
37
  *
38
  * @return string $value Opening <th> tag with attributes.
39
  */
44
  /**
45
  * Return a closing </th> tag.
46
  *
47
+ * @since 1.0.0
48
  *
49
  * @return string $value Closing </th> tag.
50
  */
55
  /**
56
  * Return an opening <td> tag.
57
  *
58
+ * @since 1.0.0
59
  *
60
  * @return string $value Opening <td> tag.
61
  */
66
  /**
67
  * Return a closing </td> tag.
68
  *
69
+ * @since 1.0.0
70
  *
71
  * @return string $value Closing </td> tag.
72
  */
74
  return '</td>';
75
  }
76
 
77
+ /**
78
+ * Return an opening <fieldset> tag.
79
+ *
80
+ * @since 1.2.0
81
+ *
82
+ * @return string $value Opening <fieldset> tag.
83
+ */
84
+ public function get_fieldset_start() {
85
+ return '<fieldset>';
86
+ }
87
+
88
+ /**
89
+ * Return an closing <fieldset> tag.
90
+ *
91
+ * @since 1.2.0
92
+ *
93
+ * @return string $value Closing <fieldset> tag.
94
+ */
95
+ public function get_fieldset_end() {
96
+ return '</fieldset>';
97
+ }
98
+
99
  /**
100
  * Return string wrapped in a <p> tag.
101
  *
102
+ * @since 1.0.0
103
  *
104
  * @param string $text Content to wrap in a <p> tag.
 
105
  * @return string $value Content wrapped in a <p> tag.
106
  */
107
  public function get_p( $text = '' ) {
111
  /**
112
  * Return a form <label> with for attribute.
113
  *
114
+ * @since 1.0.0
115
  *
116
  * @param string $label_for Form input to associate <label> with.
117
  * @param string $label_text Text to display in the <label> tag.
 
118
  * @return string $value <label> tag with filled out parts.
119
  */
120
  public function get_label( $label_for = '', $label_text = '' ) {
124
  /**
125
  * Return a <span> to indicate required status, with class attribute.
126
  *
127
+ * @since 1.0.0
128
  *
129
  * @return string span tag.
130
  */
135
  /**
136
  * Return an <a> tag with title attribute holding help text.
137
  *
138
+ * @since 1.0.0
139
  *
140
  * @param string $help_text Text to use in the title attribute.
 
141
  * @return string <a> tag with filled out parts.
142
  */
143
  public function get_help( $help_text = '' ) {
144
+ return '<a href="#" class="cptui-help dashicons-before dashicons-editor-help" title="' . esc_attr( $help_text ) . '"></a>';
145
  }
146
 
147
  /**
148
  * Return a maxlength HTML attribute with a specified length.
149
  *
150
+ * @since 1.0.0
151
  *
152
+ * @param string $length How many characters the max length should be set to.
153
  * @return string $value Maxlength HTML attribute.
154
  */
155
  public function get_maxlength( $length = '' ) {
159
  /**
160
  * Return a onblur HTML attribute for a specified value.
161
  *
162
+ * @since 1.0.0
163
  *
164
+ * @param string $text Text to place in the onblur attribute.
165
  * @return string $value Onblur HTML attribute.
166
  */
167
  public function get_onblur( $text = '' ) {
171
  /**
172
  * Return a populated <select> input.
173
  *
174
+ * @since 1.0.0
175
  *
176
  * @param array $args Arguments to use with the <select> input.
 
177
  * @return string $value Complete <select> input with options and selected attribute.
178
  */
179
  public function get_select_input( $args = array() ) {
239
  /**
240
  * Return a text input.
241
  *
242
+ * @since 1.0.0
243
  *
244
  * @param array $args Arguments to use with the text input.
 
245
  * @return string Complete text <input> with proper attributes.
246
  */
247
  public function get_text_input( $args = array() ) {
297
  /**
298
  * Return a <textarea> input.
299
  *
300
+ * @since 1.0.0
301
  *
302
  * @param array $args Arguments to use with the textarea input.
 
303
  * @return string $value Complete <textarea> input with proper attributes.
304
  */
305
  public function get_textarea_input( $args = array() ) {
339
  /**
340
  * Return a checkbox <input>.
341
  *
342
+ * @since 1.0.0
343
  *
344
  * @param array $args Arguments to use with the checkbox input.
 
345
  * @return string $value Complete checkbox <input> with proper attributes.
346
  */
347
  public function get_check_input( $args = array() ) {
386
  /**
387
  * Return some array_merged default arguments for all input types.
388
  *
389
+ * @since 1.0.0
390
  *
391
  * @param array $additions Arguments array to merge with our defaults.
 
392
  * @return array $value Merged arrays for our default parameters.
393
  */
394
  public function get_default_input_parameters( $additions = array() ) {
classes/class.cptui_debug_info.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CPTUI_Debug_Info {
4
+
5
+ public function tab_site_info() {
6
+ ?>
7
+ <p><?php _e( 'If you have sought support for Custom Post Type UI on the forums, you may be requested to send the information below to the plugin developer. Simply insert the email they provided in the input field at the bottom and click the "Send debug info" button. Only the data below will be sent to them.', 'custom-post-type-ui' ); ?></p>
8
+ <label for="cptui_audit_textarea">
9
+ <textarea readonly="readonly" id="cptui-audit-textarea" name="cptui_audit_textarea" rows="20" cols="100">
10
+ <?php echo $this->system_status(); ?>
11
+ </textarea></label>
12
+ <?php
13
+ }
14
+
15
+ private function system_status() {
16
+ if ( ! current_user_can( 'manage_options' ) ) {
17
+ return '';
18
+ }
19
+
20
+ global $wpdb;
21
+
22
+ if ( get_bloginfo( 'version' ) < '3.4' ) {
23
+ $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
24
+ $theme = $theme_data['Name'] . ' ' . $theme_data['Version'];
25
+ } else {
26
+ $theme_data = wp_get_theme();
27
+ $theme = $theme_data->Name . ' ' . $theme_data->Version;
28
+ }
29
+
30
+ ob_start();
31
+ ?>
32
+
33
+ ### Begin Custom Post Type UI Debug Info ###
34
+
35
+ Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
36
+
37
+ SITE_URL: <?php echo site_url() . "\n"; ?>
38
+ HOME_URL: <?php echo home_url() . "\n"; ?>
39
+
40
+ WordPress Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
41
+ Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
42
+ Active Theme: <?php echo $theme . "\n"; ?>
43
+
44
+ Registered Post Types: <?php echo implode( ', ', get_post_types( '', 'names' ) ) . "\n"; ?>
45
+
46
+ PHP Version: <?php echo PHP_VERSION . "\n"; ?>
47
+ MySQL Version: <?php echo $wpdb->db_version() . "\n"; ?>
48
+ Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
49
+
50
+ Show On Front: <?php echo get_option( 'show_on_front' ) . "\n" ?>
51
+ Page On Front: <?php $id = get_option( 'page_on_front' );
52
+ echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
53
+ Page For Posts: <?php $id = get_option( 'page_for_posts' );
54
+ echo get_the_title( $id ) . ' (#' . $id . ')' . "\n" ?>
55
+
56
+ WordPress Memory Limit: <?php echo ( $this->num_convt( WP_MEMORY_LIMIT ) / ( 1024 ) ) . "MB"; ?><?php echo "\n"; ?>
57
+
58
+ <?php
59
+ $plugins = get_plugins();
60
+ $pg_count = count( $plugins );
61
+ echo 'TOTAL PLUGINS: ' . $pg_count . "\n\n";
62
+ // MU plugins
63
+ $mu_plugins = get_mu_plugins();
64
+
65
+ if ( $mu_plugins ) :
66
+ $mu_count = count( $mu_plugins );
67
+
68
+ echo 'MU PLUGINS: (' . $mu_count . ')' . "\n\n";
69
+
70
+ foreach ( $mu_plugins as $mu_path => $mu_plugin ) {
71
+
72
+ echo $mu_plugin['Name'] . ': ' . $mu_plugin['Version'] . "\n";
73
+ }
74
+ endif;
75
+ // standard plugins - active
76
+ echo "\n";
77
+
78
+ $active = get_option( 'active_plugins', array() );
79
+ $ac_count = count( $active );
80
+ $ic_count = $pg_count - $ac_count;
81
+
82
+ echo 'ACTIVE PLUGINS: (' . $ac_count . ')' . "\n\n";
83
+
84
+ foreach ( $plugins as $plugin_path => $plugin ) {
85
+ // If the plugin isn't active, don't show it.
86
+ if ( ! in_array( $plugin_path, $active ) ) {
87
+ continue;
88
+ }
89
+
90
+ echo $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
91
+ }
92
+ // standard plugins - inactive
93
+ echo "\n";
94
+ echo 'INACTIVE PLUGINS: (' . $ic_count . ')' . "\n\n";
95
+
96
+ foreach ( $plugins as $plugin_path => $plugin ) {
97
+ // If the plugin isn't active, show it here.
98
+ if ( in_array( $plugin_path, $active ) ) {
99
+ continue;
100
+ }
101
+
102
+ echo $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
103
+ }
104
+
105
+ // if multisite, grab network as well
106
+ if ( is_multisite() ) :
107
+
108
+ $net_plugins = wp_get_active_network_plugins();
109
+ $net_active = get_site_option( 'active_sitewide_plugins', array() );
110
+
111
+ echo "\n";
112
+ echo 'NETWORK ACTIVE PLUGINS: (' . count( $net_plugins ) . ')' . "\n\n";
113
+
114
+ foreach ( $net_plugins as $plugin_path ) {
115
+ $plugin_base = plugin_basename( $plugin_path );
116
+
117
+ // If the plugin isn't active, don't show it.
118
+ if ( ! array_key_exists( $plugin_base, $net_active ) ) {
119
+ continue;
120
+ }
121
+
122
+ $plugin = get_plugin_data( $plugin_path );
123
+
124
+ echo $plugin['Name'] . ' :' . $plugin['Version'] . "\n";
125
+ }
126
+
127
+ endif;
128
+
129
+ echo "\n";
130
+ $cptui_post_types = get_option( 'cptui_post_types', array() );
131
+ echo 'Post Types: ' . "\n";
132
+ echo esc_html( json_encode( $cptui_post_types ) ) . "\n";
133
+
134
+ echo "\n\n";
135
+
136
+ $cptui_taxonomies = get_option( 'cptui_taxonomies', array() );
137
+ echo 'Taxonomies: ' . "\n";
138
+ echo esc_html( json_encode( $cptui_taxonomies ) ) . "\n";
139
+ echo "\n";
140
+ ?>
141
+ ### End Debug Info ###
142
+ <?php
143
+
144
+ return ob_get_clean();
145
+ }
146
+
147
+ /**
148
+ * helper function for number conversions
149
+ * @access public
150
+ *
151
+ * @param mixed $v
152
+ * @return int
153
+ */
154
+ public function num_convt( $v ) {
155
+ $l = substr( $v, - 1 );
156
+ $ret = substr( $v, 0, - 1 );
157
+
158
+ switch ( strtoupper( $l ) ) {
159
+ case 'P': // fall-through
160
+ case 'T': // fall-through
161
+ case 'G': // fall-through
162
+ case 'M': // fall-through
163
+ case 'K': // fall-through
164
+ $ret *= 1024;
165
+ break;
166
+ default:
167
+ break;
168
+ }
169
+
170
+ return $ret;
171
+ }
172
+
173
+ public function send_email( $args ) {
174
+
175
+ if ( ! isset( $args['email'] ) || ! is_email( $args['email'] ) ) {
176
+ return false;
177
+ }
178
+
179
+ stripslashes_deep( $args );
180
+
181
+ $args['email'] = sanitize_email( $args['email'] );
182
+
183
+ $message = $this->system_status();
184
+
185
+ $subject = sprintf(
186
+ __( 'CPTUI debug information for %s'),
187
+ home_url( '/' )
188
+ );
189
+
190
+ wp_mail( $args['email'], $subject, $message );
191
+ }
192
+ }
193
+
css/cptui.css CHANGED
@@ -1,12 +1,3 @@
1
- .cptui-help {
2
- border-radius: 50%;
3
- display: inline-block;
4
- height: 15px;
5
- margin-left: 2px;
6
- text-align: center;
7
- width: 15px;
8
- }
9
- .cptui-help:hover { font-weight: bold; }
10
  .required { color: rgb(255,0,0); }
11
  .cptui-table #excerpt { height: 16px; margin-right: 4px; width: auto; }
12
  .cptui-table td.outter { vertical-align: top; width: 50%; }
@@ -108,3 +99,21 @@
108
  .js #cptui_select_taxonomy input[type='submit'] {
109
  display: none;
110
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  .required { color: rgb(255,0,0); }
2
  .cptui-table #excerpt { height: 16px; margin-right: 4px; width: auto; }
3
  .cptui-table td.outter { vertical-align: top; width: 50%; }
99
  .js #cptui_select_taxonomy input[type='submit'] {
100
  display: none;
101
  }
102
+ .cptui-help {
103
+ color: #424242;
104
+ margin-left: 4px;
105
+ opacity: 0.5;
106
+ text-decoration: none;
107
+ width: 16px;
108
+ }
109
+ fieldset .cptui-help {
110
+ position: relative;
111
+ top: 4px;
112
+ }
113
+ .cptui-help:hover {
114
+ color: #0074a2;
115
+ opacity: 1;
116
+ }
117
+ .cptui-help:focus {
118
+ box-shadow: none;
119
+ }
custom-post-type-ui.php CHANGED
@@ -4,9 +4,9 @@ Plugin Name: Custom Post Type UI
4
  Plugin URI: https://github.com/WebDevStudios/custom-post-type-ui/
5
  Description: Admin panel for creating custom post types and custom taxonomies in WordPress
6
  Author: WebDevStudios
7
- Version: 1.1.3
8
  Author URI: http://webdevstudios.com/
9
- Text Domain: cpt-plugin
10
  Domain Path: /languages
11
  License: GPLv2
12
  */
@@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) {
16
  exit;
17
  }
18
 
19
- define( 'CPT_VERSION', '1.1.3' );
20
  define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );
21
 
22
  /**
@@ -26,6 +26,7 @@ define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );
26
  */
27
  function cptui_load_ui_class() {
28
  require_once( plugin_dir_path( __FILE__ ) . 'classes/class.cptui_admin_ui.php' );
 
29
  }
30
  add_action( 'init', 'cptui_load_ui_class' );
31
 
@@ -45,7 +46,7 @@ register_deactivation_hook( __FILE__, 'cptui_deactivation' );
45
  * @since 0.8.0
46
  */
47
  function cptui_load_textdomain() {
48
- load_plugin_textdomain( 'cpt-plugin', false, basename( dirname( __FILE__ ) ) . '/languages' );
49
  }
50
  add_action( 'init', 'cptui_load_textdomain' );
51
 
@@ -57,16 +58,16 @@ add_action( 'init', 'cptui_load_textdomain' );
57
  * @since 0.1.0
58
  */
59
  function cptui_plugin_menu() {
60
- add_menu_page( __( 'Custom Post Types', 'cpt-plugin' ), __( 'CPT UI', 'cpt-plugin' ), 'manage_options', 'cptui_main_menu', 'cptui_settings' );
61
- add_submenu_page( 'cptui_main_menu', __( 'Add/Edit Post Types', 'cpt-plugin' ), __( 'Add/Edit Post Types', 'cpt-plugin' ), 'manage_options', 'cptui_manage_post_types', 'cptui_manage_post_types' );
62
- add_submenu_page( 'cptui_main_menu', __( 'Add/Edit Taxonomies', 'cpt-plugin' ), __( 'Add/Edit Taxonomies', 'cpt-plugin' ), 'manage_options', 'cptui_manage_taxonomies', 'cptui_manage_taxonomies' );
63
- add_submenu_page( 'cptui_main_menu', __( 'Registered Types and Taxes', 'cpt-plugin' ), __( 'Registered Types/Taxes', 'cpt-plugin' ), 'manage_options', 'cptui_listings', 'cptui_listings' );
64
- add_submenu_page( 'cptui_main_menu', __( 'Import/Export', 'cpt-plugin' ), __( 'Import/Export', 'cpt-plugin' ), 'manage_options', 'cptui_importexport', 'cptui_importexport' );
65
- add_submenu_page( 'cptui_main_menu', __( 'Help/Support', 'cpt-plugin' ), __( 'Help/Support', 'cpt-plugin' ), 'manage_options', 'cptui_support', 'cptui_support' );
66
 
67
  # Remove the default one so we can add our customized version.
68
  remove_submenu_page('cptui_main_menu', 'cptui_main_menu');
69
- add_submenu_page( 'cptui_main_menu', __( 'About CPT UI', 'cpt-plugin' ), __( 'About CPT UI', 'cpt-plugin' ), 'manage_options', 'cptui_main_menu', 'cptui_settings' );
70
  }
71
  add_action( 'admin_menu', 'cptui_plugin_menu' );
72
 
@@ -85,6 +86,10 @@ function cptui_create_submenus() {
85
  add_action( 'init', 'cptui_create_submenus' );
86
 
87
  function cptui_add_styles() {
 
 
 
 
88
  wp_enqueue_style( 'cptui-css', plugins_url( 'css/cptui.css', __FILE__ ) );
89
  }
90
  add_action( 'admin_enqueue_scripts', 'cptui_add_styles' );
@@ -143,9 +148,15 @@ function cptui_register_single_post_type( $post_type = array() ) {
143
  $post_type['supports'] = array_merge( $post_type['supports'], $user_supports_params );
144
  }
145
 
 
146
  if ( ! empty( $post_type['custom_supports'] ) ) {
147
  $custom = explode( ',', $post_type['custom_supports'] );
148
  foreach( $custom as $part ) {
 
 
 
 
 
149
  $post_type['supports'][] = $part;
150
  }
151
  }
@@ -192,26 +203,46 @@ function cptui_register_single_post_type( $post_type = array() ) {
192
  if ( in_array( $post_type['query_var'], array( 'true', 'false', '0', '1' ) ) ) {
193
  $post_type['query_var'] = get_disp_boolean( $post_type['query_var'] );
194
  }
 
 
 
195
 
196
  $menu_position = null;
197
  if ( !empty( $post_type['menu_position'] ) ) {
198
  $menu_position = (int) $post_type['menu_position'];
199
  }
200
 
 
201
  if ( ! empty( $post_type['exclude_from_search'] ) ) {
202
  $exclude_from_search = get_disp_boolean( $post_type['exclude_from_search'] );
203
  } else {
204
- $public = get_disp_boolean( $post_type['public'] );
205
  $exclude_from_search = ( false === $public ) ? true : false;
206
  }
207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  $args = array(
209
  'labels' => $labels,
210
  'description' => $post_type['description'],
211
  'public' => get_disp_boolean( $post_type['public'] ),
212
  'show_ui' => get_disp_boolean( $post_type['show_ui'] ),
 
213
  'has_archive' => $has_archive,
214
  'show_in_menu' => $show_in_menu,
 
 
215
  'exclude_from_search' => $exclude_from_search,
216
  'capability_type' => $post_type['capability_type'],
217
  'map_meta_cap' => $post_type['map_meta_cap'],
@@ -224,6 +255,10 @@ function cptui_register_single_post_type( $post_type = array() ) {
224
  'taxonomies' => $post_type['taxonomies']
225
  );
226
 
 
 
 
 
227
  /**
228
  * Filters the arguments used for a post type right before registering.
229
  *
@@ -294,14 +329,22 @@ function cptui_register_single_taxonomy( $taxonomy = array() ) {
294
 
295
  $show_admin_column = ( !empty( $taxonomy['show_admin_column'] ) && false !== get_disp_boolean( $taxonomy['show_admin_column'] ) ) ? true : false;
296
 
 
 
 
 
 
297
  $args = array(
298
  'labels' => $labels,
299
  'label' => $taxonomy['label'],
 
300
  'hierarchical' => get_disp_boolean( $taxonomy['hierarchical'] ),
301
  'show_ui' => get_disp_boolean( $taxonomy['show_ui'] ),
302
  'query_var' => $taxonomy['query_var'],
303
  'rewrite' => $rewrite,
304
- 'show_admin_column' => $show_admin_column
 
 
305
  );
306
 
307
  $object_type = ( !empty( $taxonomy['object_types'] ) ) ? $taxonomy['object_types'] : '';
@@ -336,57 +379,74 @@ function cptui_settings() { ?>
336
  * @since 1.0.0
337
  */
338
  do_action( 'cptui_main_page_start' ); ?>
339
- <h1><?php _e( 'Custom Post Type UI', 'cpt-plugin' ); ?> <?php echo CPT_VERSION; ?></h1>
340
 
341
  <div class="about-text cptui-about-text">
342
- <?php _e( 'Thank you for choosing Custom Post Type UI. We hope that your experience with our plugin provides efficiency and speed in creating post types and taxonomies, to better organize your content, without having to touch code.', 'cpt-plugin' ); ?>
343
  </div>
344
-
345
  <div class="changelog about-integrations">
346
  <div class="cptui-feature feature-section col three-col">
 
347
  <div>
348
- <h4><?php _e( 'Post type migration', 'cpt-plugin' ); ?></h4>
349
- <p><?php _e( 'In the past, if you changed your post type slug, you would lose immediate access to the posts in the post type and need to recover another way. We have now added support for migrating all posts within the old post type to the new post type you renamed it to.', 'cpt-plugin' ); ?></p>
350
  </div>
351
  <div>
352
- <h4><?php _e( 'UI Refinement', 'cpt-plugin' ); ?></h4>
353
- <p><?php _e( 'After receiving feedback regarding the 1.0.x changes, we have further simplified the UI to reduce the amount of clicking necessary to manage your post types and taxonomies.', 'cpt-plugin' ); ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
  </div>
355
  <div class="last-feature">
356
- <h4><?php _e( 'Registered Post Type and Taxonomy Listings', 'cpt-plugin' ); ?></h4>
357
- <p><?php _e( 'We are bringing back the listing of all CPTUI-registered post types and taxonomies for easier quick view of what you have going.', 'cpt-plugin' ); ?></p>
358
  </div>
359
  </div>
360
  </div>
361
 
362
- <h2><?php _e( 'Help Support This Plugin!', 'cpt-plugin' ); ?></h2>
363
  <table border="0">
364
  <tr>
365
  <td class="one-third valign">
366
- <h3><?php _e( 'Professional WordPress<br />Third Edition', 'cpt-plugin' ); ?></h3>
367
  <a href="http://bit.ly/prowp3" target="_blank">
368
- <img src="<?php echo plugins_url( '/images/professional-wordpress-thirdedition.jpg', __FILE__ ); ?>" width="200">
369
  </a>
370
  <br />
371
- <p><?php _e( 'The leading book on WordPress design and development! Brand new third edition!', 'cpt-plugin' ); ?></p>
372
  </td>
373
  <td class="one-third valign">
374
- <h3><?php _e( 'Professional WordPress<br />Plugin Development', 'cpt-plugin' ); ?></h3>
375
  <a href="http://amzn.to/plugindevbook" target="_blank">
376
- <img src="<?php echo plugins_url( '/images/professional-wordpress-plugin-development.png', __FILE__ ); ?>" width="200">
377
  </a>
378
  <br />
379
- <p><?php _e( 'Highest rated WordPress development book on Amazon!', 'cpt-plugin' ); ?></p>
380
  </td>
381
  <td class="one-third valign">
382
- <h3><?php _e( 'PayPal Donation', 'cpt-plugin' ); ?></h3>
383
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
384
  <input type="hidden" name="cmd" value="_s-xclick">
385
  <input type="hidden" name="hosted_button_id" value="YJEDXPHE49Q3U">
386
- <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" name="submit" alt="<?php esc_attr_e( 'PayPal - The safer, easier way to pay online!', 'cpt-plugin' ); ?>">
387
  <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
388
  </form>
389
- <p><?php _e( 'Please donate to the development of Custom Post Type UI:', 'cpt-plugin' ); ?></p>
390
  </td>
391
  </tr>
392
  </table>
@@ -412,10 +472,10 @@ function cptui_footer( $original = '' ) {
412
  }
413
 
414
  return sprintf(
415
- __( '%s version %s by %s', 'cpt-plugin' ),
416
  sprintf(
417
  '<a target="_blank" href="http://wordpress.org/support/plugin/custom-post-type-ui">%s</a>',
418
- __( 'Custom Post Type UI', 'cpt-plugin' )
419
  ),
420
  CPT_VERSION,
421
  '<a href="http://webdevstudios.com" target="_blank">WebDevStudios</a>'
@@ -423,10 +483,10 @@ function cptui_footer( $original = '' ) {
423
  ' - '.
424
  sprintf(
425
  '<a href="https://github.com/WebDevStudios/custom-post-type-ui/issues" target="_blank">%s</a>',
426
- __( 'Please Report Bugs', 'cpt-plugin' )
427
  ).
428
  ' '.
429
- __( 'Follow on Twitter:', 'cpt-plugin' ).
430
  sprintf(
431
  ' %s &middot; %s &middot; %s',
432
  '<a href="http://twitter.com/tw2113" target="_blank">Michael</a>',
@@ -484,17 +544,17 @@ function disp_boolean( $booText ) {
484
  function cptui_settings_tab_menu( $page = 'post_types' ) {
485
 
486
  # initiate our arrays with default classes
487
- $tab1 = $tab2 = $tab3 = array( 'nav-tab' );
488
  $has = false;
489
 
490
  if ( 'importexport' == $page ) :
491
- $title = __( 'Import/Export', 'cpt-plugin' );
492
  elseif ( 'taxonomies' == $page ) :
493
- $title = __( 'Manage Taxonomies', 'cpt-plugin' );
494
  $taxes = get_option( 'cptui_taxonomies' );
495
  $has = ( !empty( $taxes ) ) ? true : false;
496
  else :
497
- $title = __( 'Manage Post Types', 'cpt-plugin' );
498
  $types = get_option( 'cptui_post_types' );
499
  $has = ( !empty( $types ) ) ? true : false;
500
  endif;
@@ -504,39 +564,42 @@ function cptui_settings_tab_menu( $page = 'post_types' ) {
504
  $tab2[] = 'nav-tab-active';
505
  } elseif ( 'get_code' == $_GET['action'] ) {
506
  $tab3[] = 'nav-tab-active';
 
 
507
  }
508
  } else {
509
  $tab1[] = 'nav-tab-active';
510
  }
511
 
512
  # implode our arrays for class attributes
513
- $tab1 = implode( ' ', $tab1 ); $tab2 = implode( ' ', $tab2 ); $tab3 = implode( ' ', $tab3 );
514
 
515
  ?>
 
516
  <h2 class="nav-tab-wrapper">
517
- <?php echo $title;
518
-
519
  # Import/Export area is getting different tabs, so we need to separate out.
520
  if ( 'importexport' != $page ) {
521
  if ( 'post_types' == $page ) {
522
  ?>
523
- <a class="<?php echo $tab1; ?>" href="<?php echo admin_url( 'admin.php?page=cptui_manage_' . $page ); ?>"><?php _e( 'Add New Post Type', 'cpt-plugin' ); ?></a>
524
  <?php
525
  if ( $has ) { ?>
526
- <a class="<?php echo $tab2; ?>" href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit' ), admin_url( 'admin.php?page=cptui_manage_' . $page ) ) ); ?>"><?php _e( 'Edit Post Types', 'cpt-plugin' ); ?></a>
527
  <?php }
528
  } elseif ( 'taxonomies' == $page ) {
529
  ?>
530
- <a class="<?php echo $tab1; ?>" href="<?php echo admin_url( 'admin.php?page=cptui_manage_' . $page ); ?>"><?php _e( 'Add New Taxonomy', 'cpt-plugin' ); ?></a>
531
  <?php
532
  if ( $has ) { ?>
533
- <a class="<?php echo $tab2; ?>" href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit' ), admin_url( 'admin.php?page=cptui_manage_' . $page ) ) ); ?>"><?php _e( 'Edit Taxonomies', 'cpt-plugin' ); ?></a>
534
  <?php }
535
  }
536
  } else { ?>
537
- <a class="<?php echo $tab1; ?>" href="<?php echo admin_url( 'admin.php?page=cptui_' . $page ); ?>"><?php _e( 'Post Types', 'cpt-plugin' ); ?></a>
538
- <a class="<?php echo $tab2; ?>" href="<?php echo esc_url( add_query_arg( array( 'action' => 'taxonomies' ), admin_url( 'admin.php?page=cptui_' . $page ) ) ); ?>"><?php _e( 'Taxonomies', 'cpt-plugin' ); ?></a>
539
- <a class="<?php echo $tab3; ?>" href="<?php echo esc_url( add_query_arg( array( 'action' => 'get_code' ), admin_url( 'admin.php?page=cptui_' . $page ) ) ); ?>"><?php _e( 'Get Code', 'cpt-plugin' ); ?></a>
 
540
  <?php
541
  }
542
 
@@ -619,7 +682,7 @@ function cptui_edit_plugin_list_links( $links ) {
619
 
620
  # Add our custom links to the returned array value.
621
  return array_merge( array(
622
- '<a href="' . admin_url( 'admin.php?page=cptui_main_menu' ) . '">' . __( 'Settings', 'cpt-plugin' ) . '</a>', '<a href="' . admin_url( 'admin.php?page=cptui_support' ) . '">' . __( 'Help', 'cpt-plugin' ) . '</a>'
623
  ), $links );
624
  }
625
  add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'cptui_edit_plugin_list_links' );
@@ -648,27 +711,27 @@ function cptui_admin_notices( $action = '', $object_type = '', $success = true ,
648
 
649
  if ( 'add' == $action ) {
650
  if ( $success ) {
651
- $message .= sprintf( __( '%s has been successfully added', 'cpt-plugin' ), $object_type );
652
  } else {
653
- $message .= sprintf( __( '%s has failed to be added', 'cpt-plugin' ), $object_type );
654
  }
655
  } elseif ( 'update' == $action ) {
656
  if ( $success ) {
657
- $message .= sprintf( __( '%s has been successfully updated', 'cpt-plugin' ), $object_type );
658
  } else {
659
- $message .= sprintf( __( '%s has failed to be updated', 'cpt-plugin' ), $object_type );
660
  }
661
  } elseif ( 'delete' == $action ) {
662
  if ( $success ) {
663
- $message .= sprintf( __( '%s has been successfully deleted', 'cpt-plugin' ), $object_type );
664
  } else {
665
- $message .= sprintf( __( '%s has failed to be deleted', 'cpt-plugin' ), $object_type );
666
  }
667
  } elseif ( 'import' == $action ) {
668
  if ( $success ) {
669
- $message .= sprintf( __( '%s has been successfully imported', 'cpt-plugin' ), $object_type );
670
  } else {
671
- $message .= sprintf( __( '%s has failed to be imported', 'cpt-plugin' ), $object_type );
672
  }
673
  } elseif ( 'error' == $action ) {
674
  if ( !empty( $custom ) ) {
@@ -751,30 +814,41 @@ function cptui_get_preserved_label( $type = '', $key = '', $plural = '', $singul
751
 
752
  $preserved_labels = array(
753
  'post_types' => array(
754
- 'add_new_item' => sprintf( __( 'Add new %s', 'cpt-plugin' ), $singular ),
755
- 'edit_item' => sprintf( __( 'Edit %s', 'cpt-plugin' ), $singular ),
756
- 'new_item' => sprintf( __( 'New %s', 'cpt-plugin' ), $singular ),
757
- 'view_item' => sprintf( __( 'View %s', 'cpt-plugin' ), $singular ),
758
- 'all_items' => sprintf( __( 'All %s', 'cpt-plugin' ), $plural ),
759
- 'search_items' => sprintf( __( 'Search %s', 'cpt-plugin' ), $plural ),
760
- 'not_found' => sprintf( __( 'No %s found.', 'cpt-plugin' ), $plural ),
761
- 'not_found_in_trash' => sprintf( __( 'No %s found in trash.', 'cpt-plugin' ), $plural )
762
  ),
763
  'taxonomies' => array(
764
- 'search_items' => sprintf( __( 'Search %s', 'cpt-plugin' ), $plural ),
765
- 'popular_items' => sprintf( __( 'Popular %s', 'cpt-plugin' ), $plural ),
766
- 'all_items' => sprintf( __( 'All %s', 'cpt-plugin' ), $plural ),
767
- 'parent_item' => sprintf( __( 'Parent %s', 'cpt-plugin' ), $singular ),
768
- 'parent_item_colon' => sprintf( __( 'Parent %s:', 'cpt-plugin' ), $singular ),
769
- 'edit_item' => sprintf( __( 'Edit %s', 'cpt-plugin' ), $singular ),
770
- 'update_item' => sprintf( __( 'Update %s', 'cpt-plugin' ), $singular ),
771
- 'add_new_item' => sprintf( __( 'Add new %s', 'cpt-plugin' ), $singular ),
772
- 'new_item_name' => sprintf( __( 'New %s name', 'cpt-plugin' ), $singular ),
773
- 'separate_items_with_commas' => sprintf( __( 'Separate %s with commas', 'cpt-plugin' ), $plural ),
774
- 'add_or_remove_items' => sprintf( __( 'Add or remove %s', 'cpt-plugin' ), $plural ),
775
- 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'cpt-plugin' ), $plural )
776
  )
777
  );
778
 
779
  return $preserved_labels[ $type ][ $key ];
780
  }
 
 
 
 
 
 
 
 
 
 
 
4
  Plugin URI: https://github.com/WebDevStudios/custom-post-type-ui/
5
  Description: Admin panel for creating custom post types and custom taxonomies in WordPress
6
  Author: WebDevStudios
7
+ Version: 1.2.0
8
  Author URI: http://webdevstudios.com/
9
+ Text Domain: custom-post-type-ui
10
  Domain Path: /languages
11
  License: GPLv2
12
  */
16
  exit;
17
  }
18
 
19
+ define( 'CPT_VERSION', '1.2.0' );
20
  define( 'CPTUI_WP_VERSION', get_bloginfo( 'version' ) );
21
 
22
  /**
26
  */
27
  function cptui_load_ui_class() {
28
  require_once( plugin_dir_path( __FILE__ ) . 'classes/class.cptui_admin_ui.php' );
29
+ require_once( plugin_dir_path( __FILE__ ) . 'classes/class.cptui_debug_info.php' );
30
  }
31
  add_action( 'init', 'cptui_load_ui_class' );
32
 
46
  * @since 0.8.0
47
  */
48
  function cptui_load_textdomain() {
49
+ load_plugin_textdomain( 'custom-post-type-ui', false, basename( dirname( __FILE__ ) ) . '/languages' );
50
  }
51
  add_action( 'init', 'cptui_load_textdomain' );
52
 
58
  * @since 0.1.0
59
  */
60
  function cptui_plugin_menu() {
61
+ add_menu_page( __( 'Custom Post Types', 'custom-post-type-ui' ), __( 'CPT UI', 'custom-post-type-ui' ), 'manage_options', 'cptui_main_menu', 'cptui_settings', cptui_menu_icon() );
62
+ add_submenu_page( 'cptui_main_menu', __( 'Add/Edit Post Types', 'custom-post-type-ui' ), __( 'Add/Edit Post Types', 'custom-post-type-ui' ), 'manage_options', 'cptui_manage_post_types', 'cptui_manage_post_types' );
63
+ add_submenu_page( 'cptui_main_menu', __( 'Add/Edit Taxonomies', 'custom-post-type-ui' ), __( 'Add/Edit Taxonomies', 'custom-post-type-ui' ), 'manage_options', 'cptui_manage_taxonomies', 'cptui_manage_taxonomies' );
64
+ add_submenu_page( 'cptui_main_menu', __( 'Registered Types and Taxes', 'custom-post-type-ui' ), __( 'Registered Types/Taxes', 'custom-post-type-ui' ), 'manage_options', 'cptui_listings', 'cptui_listings' );
65
+ add_submenu_page( 'cptui_main_menu', __( 'Import/Export', 'custom-post-type-ui' ), __( 'Import/Export', 'custom-post-type-ui' ), 'manage_options', 'cptui_importexport', 'cptui_importexport' );
66
+ add_submenu_page( 'cptui_main_menu', __( 'Help/Support', 'custom-post-type-ui' ), __( 'Help/Support', 'custom-post-type-ui' ), 'manage_options', 'cptui_support', 'cptui_support' );
67
 
68
  # Remove the default one so we can add our customized version.
69
  remove_submenu_page('cptui_main_menu', 'cptui_main_menu');
70
+ add_submenu_page( 'cptui_main_menu', __( 'About CPT UI', 'custom-post-type-ui' ), __( 'About CPT UI', 'custom-post-type-ui' ), 'manage_options', 'cptui_main_menu', 'cptui_settings' );
71
  }
72
  add_action( 'admin_menu', 'cptui_plugin_menu' );
73
 
86
  add_action( 'init', 'cptui_create_submenus' );
87
 
88
  function cptui_add_styles() {
89
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
90
+ return;
91
+ }
92
+
93
  wp_enqueue_style( 'cptui-css', plugins_url( 'css/cptui.css', __FILE__ ) );
94
  }
95
  add_action( 'admin_enqueue_scripts', 'cptui_add_styles' );
148
  $post_type['supports'] = array_merge( $post_type['supports'], $user_supports_params );
149
  }
150
 
151
+ $yarpp = false; # Prevent notices.
152
  if ( ! empty( $post_type['custom_supports'] ) ) {
153
  $custom = explode( ',', $post_type['custom_supports'] );
154
  foreach( $custom as $part ) {
155
+ # We'll handle YARPP separately.
156
+ if ( in_array( $part, array( 'YARPP', 'yarpp' ) ) ) {
157
+ $yarpp = true;
158
+ continue;
159
+ }
160
  $post_type['supports'][] = $part;
161
  }
162
  }
203
  if ( in_array( $post_type['query_var'], array( 'true', 'false', '0', '1' ) ) ) {
204
  $post_type['query_var'] = get_disp_boolean( $post_type['query_var'] );
205
  }
206
+ if ( ! empty( $post_type['query_var_slug'] ) ) {
207
+ $post_type['query_var'] = $post_type['query_var_slug'];
208
+ }
209
 
210
  $menu_position = null;
211
  if ( !empty( $post_type['menu_position'] ) ) {
212
  $menu_position = (int) $post_type['menu_position'];
213
  }
214
 
215
+ $public = get_disp_boolean( $post_type['public'] );
216
  if ( ! empty( $post_type['exclude_from_search'] ) ) {
217
  $exclude_from_search = get_disp_boolean( $post_type['exclude_from_search'] );
218
  } else {
 
219
  $exclude_from_search = ( false === $public ) ? true : false;
220
  }
221
 
222
+ if ( empty( $post_type['show_in_nav_menus'] ) ) {
223
+ // Defaults to value of public.
224
+ $post_type['show_in_nav_menus'] = $public;
225
+ }
226
+
227
+ if ( empty( $post_type['show_in_rest'] ) ) {
228
+ $post_type['show_in_rest'] = false;
229
+ }
230
+
231
+ $rest_base = null;
232
+ if ( ! empty( $post_type['rest_base'] ) ) {
233
+ $rest_base = $post_type['rest_base'];
234
+ }
235
+
236
  $args = array(
237
  'labels' => $labels,
238
  'description' => $post_type['description'],
239
  'public' => get_disp_boolean( $post_type['public'] ),
240
  'show_ui' => get_disp_boolean( $post_type['show_ui'] ),
241
+ 'show_in_nav_menus' => get_disp_boolean( $post_type['show_in_nav_menus'] ),
242
  'has_archive' => $has_archive,
243
  'show_in_menu' => $show_in_menu,
244
+ 'show_in_rest' => get_disp_boolean( $post_type['show_in_rest'] ),
245
+ 'rest_base' => $rest_base,
246
  'exclude_from_search' => $exclude_from_search,
247
  'capability_type' => $post_type['capability_type'],
248
  'map_meta_cap' => $post_type['map_meta_cap'],
255
  'taxonomies' => $post_type['taxonomies']
256
  );
257
 
258
+ if ( true === $yarpp ) {
259
+ $args['yarpp_support'] = $yarpp;
260
+ }
261
+
262
  /**
263
  * Filters the arguments used for a post type right before registering.
264
  *
329
 
330
  $show_admin_column = ( !empty( $taxonomy['show_admin_column'] ) && false !== get_disp_boolean( $taxonomy['show_admin_column'] ) ) ? true : false;
331
 
332
+ $rest_base = null;
333
+ if ( ! empty( $taxonomy['rest_base'] ) ) {
334
+ $rest_base = $taxonomy['rest_base'];
335
+ }
336
+
337
  $args = array(
338
  'labels' => $labels,
339
  'label' => $taxonomy['label'],
340
+ 'description' => $taxonomy['description'],
341
  'hierarchical' => get_disp_boolean( $taxonomy['hierarchical'] ),
342
  'show_ui' => get_disp_boolean( $taxonomy['show_ui'] ),
343
  'query_var' => $taxonomy['query_var'],
344
  'rewrite' => $rewrite,
345
+ 'show_admin_column' => $show_admin_column,
346
+ 'show_in_rest' => get_disp_boolean( $taxonomy['show_in_rest'] ),
347
+ 'rest_base' => $rest_base,
348
  );
349
 
350
  $object_type = ( !empty( $taxonomy['object_types'] ) ) ? $taxonomy['object_types'] : '';
379
  * @since 1.0.0
380
  */
381
  do_action( 'cptui_main_page_start' ); ?>
382
+ <h1><?php _e( 'Custom Post Type UI', 'custom-post-type-ui' ); ?> <?php echo CPT_VERSION; ?></h1>
383
 
384
  <div class="about-text cptui-about-text">
385
+ <?php _e( 'Thank you for choosing Custom Post Type UI. We hope that your experience with our plugin provides efficiency and speed in creating post types and taxonomies, to better organize your content, without having to touch code.', 'custom-post-type-ui' ); ?>
386
  </div>
387
+ <h2><?php printf( __( 'What\'s new in version %s', 'custom-post-type-ui' ), CPT_VERSION ); ?></h2>
388
  <div class="changelog about-integrations">
389
  <div class="cptui-feature feature-section col three-col">
390
+
391
  <div>
392
+ <h2><?php _e( 'Updated internationalization', 'custom-post-type-ui' ); ?></h2>
393
+ <p><?php _e( 'Our textdomain now matches the plugin slug from our WordPress.org repository to help aid in translating Custom Post Type UI', 'custom-post-type-ui' ); ?></p>
394
  </div>
395
  <div>
396
+ <h2><?php _e( 'Debugging information', 'custom-post-type-ui' ); ?></h2>
397
+ <p><?php _e( 'We have added a new "Debug Info" tab to the Import/Export area to aid in debugging issues with Custom Post Type UI.', 'custom-post-type-ui' ); ?></p>
398
+ </div>
399
+ <div>
400
+ <h2><?php _e( 'Improved accessibility', 'custom-post-type-ui' ); ?></h2>
401
+ <p><?php _e( 'A lot of work was done in the areas of accessibility to help aid users who need it. If you have feedback on where it could be further improved, let us know.', 'custom-post-type-ui' ); ?></p>
402
+ </div>
403
+ <div>
404
+ <h2><?php _e( 'WP REST API support', 'custom-post-type-ui' ); ?></h2>
405
+ <p><?php _e( 'We now have support for the required fields for the WP REST API. Now you can add your Custom Post Type UI post types and taxonomies to the available REST API lists.', 'custom-post-type-ui' ); ?></p>
406
+ </div>
407
+ <div>
408
+ <h2><?php _e( 'More parameter support', 'custom-post-type-ui' ); ?></h2>
409
+ <p><?php _e( 'We have added more parameters for greater customization of your post type and taxonomy settings.', 'custom-post-type-ui' ); ?></p>
410
+ </div>
411
+ <div>
412
+ <h2><?php _e( 'New individual "Get Code" sections', 'custom-post-type-ui' ); ?></h2>
413
+ <p><?php _e( 'The "Get Code" area now has support for copy/paste of individual post types and taxonomies.', 'custom-post-type-ui' ); ?></p>
414
  </div>
415
  <div class="last-feature">
416
+ <h2><?php _e( 'Template hierarchy reference', 'custom-post-type-ui' ); ?></h2>
417
+ <p><?php _e( 'To help aid your development with post types and taxonomies, we have added a quick reference list of common template files you can use in your theme. They will be listed on the "Registered Types/Taxes" screen.', 'custom-post-type-ui' ); ?></p>
418
  </div>
419
  </div>
420
  </div>
421
 
422
+ <h1><?php _e( 'Help Support This Plugin!', 'custom-post-type-ui' ); ?></h1>
423
  <table border="0">
424
  <tr>
425
  <td class="one-third valign">
426
+ <h2><?php _e( 'Professional WordPress<br />Third Edition', 'custom-post-type-ui' ); ?></h2>
427
  <a href="http://bit.ly/prowp3" target="_blank">
428
+ <img src="<?php echo plugins_url( '/images/professional-wordpress-thirdedition.jpg', __FILE__ ); ?>" width="200" alt="<?php esc_attr_e( 'Professional WordPress Design and Development book cover.', 'custom-post-type-ui' ); ?>">
429
  </a>
430
  <br />
431
+ <p><?php _e( 'The leading book on WordPress design and development! Brand new third edition!', 'custom-post-type-ui' ); ?></p>
432
  </td>
433
  <td class="one-third valign">
434
+ <h2><?php _e( 'Professional WordPress<br />Plugin Development', 'custom-post-type-ui' ); ?></h2>
435
  <a href="http://amzn.to/plugindevbook" target="_blank">
436
+ <img src="<?php echo plugins_url( '/images/professional-wordpress-plugin-development.png', __FILE__ ); ?>" width="200" alt="<?php esc_attr_e( 'Professional WordPress Pluing Development book cover.', 'custom-post-type-ui' ); ?>">
437
  </a>
438
  <br />
439
+ <p><?php _e( 'Highest rated WordPress development book on Amazon!', 'custom-post-type-ui' ); ?></p>
440
  </td>
441
  <td class="one-third valign">
442
+ <h2><?php _e( 'PayPal Donation', 'custom-post-type-ui' ); ?></h2>
443
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
444
  <input type="hidden" name="cmd" value="_s-xclick">
445
  <input type="hidden" name="hosted_button_id" value="YJEDXPHE49Q3U">
446
+ <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" name="submit" alt="<?php esc_attr_e( 'PayPal - The safer, easier way to pay online!', 'custom-post-type-ui' ); ?>">
447
  <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
448
  </form>
449
+ <p><?php _e( 'Please donate to the development of Custom Post Type UI:', 'custom-post-type-ui' ); ?></p>
450
  </td>
451
  </tr>
452
  </table>
472
  }
473
 
474
  return sprintf(
475
+ __( '%s version %s by %s', 'custom-post-type-ui' ),
476
  sprintf(
477
  '<a target="_blank" href="http://wordpress.org/support/plugin/custom-post-type-ui">%s</a>',
478
+ __( 'Custom Post Type UI', 'custom-post-type-ui' )
479
  ),
480
  CPT_VERSION,
481
  '<a href="http://webdevstudios.com" target="_blank">WebDevStudios</a>'
483
  ' - '.
484
  sprintf(
485
  '<a href="https://github.com/WebDevStudios/custom-post-type-ui/issues" target="_blank">%s</a>',
486
+ __( 'Please Report Bugs', 'custom-post-type-ui' )
487
  ).
488
  ' '.
489
+ __( 'Follow on Twitter:', 'custom-post-type-ui' ).
490
  sprintf(
491
  ' %s &middot; %s &middot; %s',
492
  '<a href="http://twitter.com/tw2113" target="_blank">Michael</a>',
544
  function cptui_settings_tab_menu( $page = 'post_types' ) {
545
 
546
  # initiate our arrays with default classes
547
+ $tab1 = $tab2 = $tab3 = $tab4 = array( 'nav-tab' );
548
  $has = false;
549
 
550
  if ( 'importexport' == $page ) :
551
+ $title = __( 'Import/Export', 'custom-post-type-ui' );
552
  elseif ( 'taxonomies' == $page ) :
553
+ $title = __( 'Manage Taxonomies', 'custom-post-type-ui' );
554
  $taxes = get_option( 'cptui_taxonomies' );
555
  $has = ( !empty( $taxes ) ) ? true : false;
556
  else :
557
+ $title = __( 'Manage Post Types', 'custom-post-type-ui' );
558
  $types = get_option( 'cptui_post_types' );
559
  $has = ( !empty( $types ) ) ? true : false;
560
  endif;
564
  $tab2[] = 'nav-tab-active';
565
  } elseif ( 'get_code' == $_GET['action'] ) {
566
  $tab3[] = 'nav-tab-active';
567
+ } elseif ( 'debuginfo' == $_GET['action'] ) {
568
+ $tab4[] = 'nav-tab-active';
569
  }
570
  } else {
571
  $tab1[] = 'nav-tab-active';
572
  }
573
 
574
  # implode our arrays for class attributes
575
+ $tab1 = implode( ' ', $tab1 ); $tab2 = implode( ' ', $tab2 ); $tab3 = implode( ' ', $tab3 ); $tab4 = implode( ' ', $tab4 );
576
 
577
  ?>
578
+ <h1><?php echo $title; ?></h1>
579
  <h2 class="nav-tab-wrapper">
580
+ <?php
 
581
  # Import/Export area is getting different tabs, so we need to separate out.
582
  if ( 'importexport' != $page ) {
583
  if ( 'post_types' == $page ) {
584
  ?>
585
+ <a class="<?php echo $tab1; ?>" href="<?php echo admin_url( 'admin.php?page=cptui_manage_' . $page ); ?>"><?php _e( 'Add New Post Type', 'custom-post-type-ui' ); ?></a>
586
  <?php
587
  if ( $has ) { ?>
588
+ <a class="<?php echo $tab2; ?>" href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit' ), admin_url( 'admin.php?page=cptui_manage_' . $page ) ) ); ?>"><?php _e( 'Edit Post Types', 'custom-post-type-ui' ); ?></a>
589
  <?php }
590
  } elseif ( 'taxonomies' == $page ) {
591
  ?>
592
+ <a class="<?php echo $tab1; ?>" href="<?php echo admin_url( 'admin.php?page=cptui_manage_' . $page ); ?>"><?php _e( 'Add New Taxonomy', 'custom-post-type-ui' ); ?></a>
593
  <?php
594
  if ( $has ) { ?>
595
+ <a class="<?php echo $tab2; ?>" href="<?php echo esc_url( add_query_arg( array( 'action' => 'edit' ), admin_url( 'admin.php?page=cptui_manage_' . $page ) ) ); ?>"><?php _e( 'Edit Taxonomies', 'custom-post-type-ui' ); ?></a>
596
  <?php }
597
  }
598
  } else { ?>
599
+ <a class="<?php echo $tab1; ?>" href="<?php echo admin_url( 'admin.php?page=cptui_' . $page ); ?>"><?php _e( 'Post Types', 'custom-post-type-ui' ); ?></a>
600
+ <a class="<?php echo $tab2; ?>" href="<?php echo esc_url( add_query_arg( array( 'action' => 'taxonomies' ), admin_url( 'admin.php?page=cptui_' . $page ) ) ); ?>"><?php _e( 'Taxonomies', 'custom-post-type-ui' ); ?></a>
601
+ <a class="<?php echo $tab3; ?>" href="<?php echo esc_url( add_query_arg( array( 'action' => 'get_code' ), admin_url( 'admin.php?page=cptui_' . $page ) ) ); ?>"><?php _e( 'Get Code', 'custom-post-type-ui' ); ?></a>
602
+ <a class="<?php echo $tab4; ?>" href="<?php echo esc_url( add_query_arg( array( 'action' => 'debuginfo' ), admin_url( 'admin.php?page=cptui_' . $page ) ) ); ?>"><?php _e( 'Debug Info', 'custom-post-type-ui' ); ?></a>
603
  <?php
604
  }
605
 
682
 
683
  # Add our custom links to the returned array value.
684
  return array_merge( array(
685
+ '<a href="' . admin_url( 'admin.php?page=cptui_main_menu' ) . '">' . __( 'Settings', 'custom-post-type-ui' ) . '</a>', '<a href="' . admin_url( 'admin.php?page=cptui_support' ) . '">' . __( 'Help', 'custom-post-type-ui' ) . '</a>'
686
  ), $links );
687
  }
688
  add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'cptui_edit_plugin_list_links' );
711
 
712
  if ( 'add' == $action ) {
713
  if ( $success ) {
714
+ $message .= sprintf( __( '%s has been successfully added', 'custom-post-type-ui' ), $object_type );
715
  } else {
716
+ $message .= sprintf( __( '%s has failed to be added', 'custom-post-type-ui' ), $object_type );
717
  }
718
  } elseif ( 'update' == $action ) {
719
  if ( $success ) {
720
+ $message .= sprintf( __( '%s has been successfully updated', 'custom-post-type-ui' ), $object_type );
721
  } else {
722
+ $message .= sprintf( __( '%s has failed to be updated', 'custom-post-type-ui' ), $object_type );
723
  }
724
  } elseif ( 'delete' == $action ) {
725
  if ( $success ) {
726
+ $message .= sprintf( __( '%s has been successfully deleted', 'custom-post-type-ui' ), $object_type );
727
  } else {
728
+ $message .= sprintf( __( '%s has failed to be deleted', 'custom-post-type-ui' ), $object_type );
729
  }
730
  } elseif ( 'import' == $action ) {
731
  if ( $success ) {
732
+ $message .= sprintf( __( '%s has been successfully imported', 'custom-post-type-ui' ), $object_type );
733
  } else {
734
+ $message .= sprintf( __( '%s has failed to be imported', 'custom-post-type-ui' ), $object_type );
735
  }
736
  } elseif ( 'error' == $action ) {
737
  if ( !empty( $custom ) ) {
814
 
815
  $preserved_labels = array(
816
  'post_types' => array(
817
+ 'add_new_item' => sprintf( __( 'Add new %s', 'custom-post-type-ui' ), $singular ),
818
+ 'edit_item' => sprintf( __( 'Edit %s', 'custom-post-type-ui' ), $singular ),
819
+ 'new_item' => sprintf( __( 'New %s', 'custom-post-type-ui' ), $singular ),
820
+ 'view_item' => sprintf( __( 'View %s', 'custom-post-type-ui' ), $singular ),
821
+ 'all_items' => sprintf( __( 'All %s', 'custom-post-type-ui' ), $plural ),
822
+ 'search_items' => sprintf( __( 'Search %s', 'custom-post-type-ui' ), $plural ),
823
+ 'not_found' => sprintf( __( 'No %s found.', 'custom-post-type-ui' ), $plural ),
824
+ 'not_found_in_trash' => sprintf( __( 'No %s found in trash.', 'custom-post-type-ui' ), $plural )
825
  ),
826
  'taxonomies' => array(
827
+ 'search_items' => sprintf( __( 'Search %s', 'custom-post-type-ui' ), $plural ),
828
+ 'popular_items' => sprintf( __( 'Popular %s', 'custom-post-type-ui' ), $plural ),
829
+ 'all_items' => sprintf( __( 'All %s', 'custom-post-type-ui' ), $plural ),
830
+ 'parent_item' => sprintf( __( 'Parent %s', 'custom-post-type-ui' ), $singular ),
831
+ 'parent_item_colon' => sprintf( __( 'Parent %s:', 'custom-post-type-ui' ), $singular ),
832
+ 'edit_item' => sprintf( __( 'Edit %s', 'custom-post-type-ui' ), $singular ),
833
+ 'update_item' => sprintf( __( 'Update %s', 'custom-post-type-ui' ), $singular ),
834
+ 'add_new_item' => sprintf( __( 'Add new %s', 'custom-post-type-ui' ), $singular ),
835
+ 'new_item_name' => sprintf( __( 'New %s name', 'custom-post-type-ui' ), $singular ),
836
+ 'separate_items_with_commas' => sprintf( __( 'Separate %s with commas', 'custom-post-type-ui' ), $plural ),
837
+ 'add_or_remove_items' => sprintf( __( 'Add or remove %s', 'custom-post-type-ui' ), $plural ),
838
+ 'choose_from_most_used' => sprintf( __( 'Choose from the most used %s', 'custom-post-type-ui' ), $plural )
839
  )
840
  );
841
 
842
  return $preserved_labels[ $type ][ $key ];
843
  }
844
+
845
+ /**
846
+ * Returns SVG icon for custom menu icon
847
+ *
848
+ * @since 1.2.0
849
+ *
850
+ * @return string
851
+ */
852
+ function cptui_menu_icon() {
853
+ return 'data:image/svg+xml;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABC9pVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMDE0IDc5LjE1Njc5NywgMjAxNC8wOC8yMC0wOTo1MzowMiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wUmlnaHRzPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvcmlnaHRzLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1wUmlnaHRzOk1hcmtlZD0iVHJ1ZSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo5NkE3NTc5MUJCOTIxMUU0QUVENDlFMUYwOEMyRDgwQyIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo5NkE3NTc5MEJCOTIxMUU0QUVENDlFMUYwOEMyRDgwQyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxNCAoV2luZG93cykiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmRpZDo5NjMzOTU2ODgyMjhFMDExOTg5Q0MwQTFBRDAyQjVDMiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo5NjMzOTU2ODgyMjhFMDExOTg5Q0MwQTFBRDAyQjVDMiIvPiA8ZGM6cmlnaHRzPiA8cmRmOkFsdD4gPHJkZjpsaSB4bWw6bGFuZz0ieC1kZWZhdWx0Ij5DcmVhdGl2ZSBDb21tb25zIEF0dHJpYnV0aW9uIE5vbi1Db21tZXJjaWFsIE5vIERlcml2YXRpdmVzPC9yZGY6bGk+IDwvcmRmOkFsdD4gPC9kYzpyaWdodHM+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+hXhu9wAAAjdJREFUeNrcWYFtwjAQBNQB0g3oBukEDRPUnYCwQRmhE8AGhgnKBh0h2YBuQDZIbclI6GXH7/c7cfrSCxEcuHv+7x3/su/7xZxttZi5/XsChfJP5Y3ynskFKwNdAw4Xym89r9UDv0dy1wd1z2/s4F0ERGbgC+WN8iuGQJFZ2tzB303ANbCIa1O4XLZTfiLeq3H8KC8frr3BRU/g/dbzpRflZ+Wd8ta8pjAbeG2VT4VGL0JE2kArXClUeCJ/GqEvuSL/aGtKJz5nAv5oUtdKYCifuwzAa+Bf8OIS7EZdW9PnCQoWBnADox+SQhjwtQcEFby2vQ18iAr5lEOadboJlkxqczcZspWgEJBgLYYEFnwDZZObgHSsHyKBBY/6N2MISEL0sODRjZNK4IAEocGuzT1lAHiJ7dxYGV0CtZEJe0JrJBMl2xQCN+YdK0rvHSYoD/WXhNHfB4DXmfBNrQGZ4KlNBuxYaxcwThUKsYYCPpZAiCT69H5NAR9LgIuEoILnIBBL4hCQOlajyGjMrhLq/WvIGVzKs9FQ/dbrP3I73A0hoY9bfnM8ncaQOHI2Q64awNZEaN6PVgOYf4It78cacEASG668HyOFUlhUClUTg69iU6hYZGpYAtuJcb5jZ2Q5nE5DL4eGLrCIG89+Zqz5QPUQ+aGhSwsJ6JHqYUZj4j0koJlecy5a0GdeVpaLu5lEX+PsVo48380A/MWmQqkn9RzPz2LoZM7WwGrTB8oJI94a9TtB5fsTYABOp6Z0XZr87gAAAABJRU5ErkJggg==';
854
+ }
inc/import_export.php CHANGED
@@ -20,6 +20,8 @@ function cptui_importexport() {
20
  $tab = 'taxonomies';
21
  } elseif ( !empty( $_GET['action'] ) && 'get_code' == $_GET['action'] ) {
22
  $tab = 'get_code';
 
 
23
  } else {
24
  $tab = 'post_types';
25
  }
@@ -37,82 +39,7 @@ function cptui_importexport() {
37
  # Create our tabs.
38
  cptui_settings_tab_menu( $page = 'importexport' );
39
 
40
- if ( isset( $tab ) && ( 'post_types' == $tab || 'taxonomies' == $tab ) ) {
41
- ?>
42
- <p><?php _e( 'If you are wanting to migrate registered post types or taxonomies from this site to another, that will also use Custom Post Type UI, use the import and export functionality. If you are moving away from Custom Post Type UI, use the information in the "Get Code" tab.', 'cpt-plugin' ); ?></p>
43
-
44
- <p><?php printf( '<strong>%s</strong>: %s',
45
- __( 'NOTE', 'cpt-plugin' ),
46
- __( 'This will not export the associated posts, just the settings.', 'cpt-plugin' )
47
- ); ?>
48
- </p>
49
- <table class="form-table cptui-table">
50
- <?php if ( !empty( $_GET ) && empty( $_GET['action'] ) ) { ?>
51
- <tr>
52
- <td class="outter">
53
- <h3><?php _e( 'Import Post Types', 'cpt-plugin' ); ?></h3>
54
- <form method="post">
55
- <textarea class="cptui_post_import" placeholder="<?php esc_attr_e( 'Paste content here.', 'cpt-plugin' ); ?>" name="cptui_post_import"></textarea>
56
- <p class="wp-ui-highlight"><strong><?php _e( 'Note:', 'cpt-plugin' ); ?></strong> <?php _e( 'Importing will overwrite previous registered settings.', 'cpt-plugin' ); ?></p>
57
- <p><strong><?php _e( 'To import post types from a different WordPress site, paste the exported content from that site and click the "Import" button.', 'cpt-plugin' ); ?></strong></p>
58
- <p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Import', 'cpt-plugin' ); ?>"/></p>
59
- </form>
60
- </td>
61
- <td class="outter">
62
- <h3><?php _e( 'Export Post Types', 'cpt-plugin' ); ?></h3>
63
- <?php
64
- $cptui_post_types = get_option( 'cptui_post_types', array() );
65
- if ( !empty( $cptui_post_types ) ) {
66
- $content = esc_html( json_encode( $cptui_post_types ) );
67
- } else {
68
- $content = __( 'No post types registered yet.', 'cpt-plugin' );
69
- }
70
- ?>
71
- <textarea title="<?php esc_attr_e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'cpt-plugin' ); ?>" onclick="this.focus();this.select()" readonly="readonly" class="cptui_post_import"><?php echo $content; ?></textarea>
72
- <p><strong><?php _e( 'Use the content above to import current post types into a different WordPress site. You can also use this to simply back up your post type settings.', 'cpt-plugin' ); ?></strong></p>
73
- </td>
74
- </tr>
75
- <?php } elseif ( !empty( $_GET ) && 'taxonomies' == $_GET['action'] ) { ?>
76
- <tr>
77
- <td class="outter">
78
- <h3><?php _e( 'Import Taxonomies', 'cpt-plugin' ); ?></h3>
79
- <form method="post">
80
- <textarea class="cptui_tax_import" placeholder="<?php esc_attr_e( 'Paste content here.', 'cpt-plugin' ); ?>" name="cptui_tax_import"></textarea>
81
- <p class="wp-ui-highlight"><strong><?php _e( 'Note:', 'cpt-plugin' ); ?></strong> <?php _e( 'Importing will overwrite previous registered settings.', 'cpt-plugin' ); ?></p>
82
- <p><strong><?php _e( 'To import taxonomies from a different WordPress site, paste the exported content from that site and click the "Import" button.', 'cpt-plugin' ); ?></strong></p>
83
- <p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Import', 'cpt-plugin' ); ?>"/></p>
84
- </form>
85
- </td>
86
- <td class="outter">
87
- <h3><?php _e( 'Export Taxonomies', 'cpt-plugin' ); ?></h3>
88
- <?php
89
- $cptui_taxonomies = get_option( 'cptui_taxonomies', array() );
90
- if ( !empty( $cptui_taxonomies ) ) {
91
- $content = esc_html( json_encode( $cptui_taxonomies ) );
92
- } else {
93
- $content = __( 'No taxonomies registered yet.', 'cpt-plugin' );
94
- }
95
- ?>
96
- <textarea title="<?php esc_attr_e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'cpt-plugin' ); ?>" onclick="this.focus();this.select()" readonly="readonly" class="cptui_tax_import"><?php echo $content; ?></textarea>
97
- <p><strong><?php _e( 'Use the content above to import current taxonomies into a different WordPress site. You can also use this to simply back up your taxonomy settings.', 'cpt-plugin' ); ?></strong></p>
98
- </td>
99
- </tr>
100
- <?php } ?>
101
- </table>
102
-
103
- <?php
104
- } else { ?>
105
- <h2><?php _e( 'Get Post Type and Taxonomy Code', 'cpt-plugin' ); ?></h2>
106
-
107
- <h3><?php _e( 'All CPT UI Post Types', 'cpt-plugin' ); ?></h3>
108
- <label for="cptui_post_type_get_code"><?php _e( 'Copy/paste the code below into your functions.php file.', 'cpt-plugin' ); ?></label>
109
- <textarea name="cptui_post_type_get_code" id="cptui_post_type_get_code" class="cptui_post_type_get_code" onclick="this.focus();this.select()" readonly="readonly"><?php cptui_get_post_type_code(); ?></textarea>
110
-
111
- <h3><?php _e( 'All CPT UI Taxonomies', 'cpt-plugin' ); ?></h3>
112
- <label for="cptui_tax_get_code"><?php _e( 'Copy/paste the code below into your functions.php file.', 'cpt-plugin' ); ?></label>
113
- <textarea name="cptui_tax_get_code" id="cptui_tax_get_code" class="cptui_tax_get_code" onclick="this.focus();this.select()" readonly="readonly"><?php cptui_get_taxonomy_code(); ?></textarea>
114
- <?php
115
- }
116
 
117
  echo '</div><!-- End .wrap -->';
118
  }
@@ -121,25 +48,33 @@ function cptui_importexport() {
121
  * Display our copy-able code for registered taxonomies.
122
  *
123
  * @since 1.0.0
 
 
 
 
 
124
  *
125
  * @return string Taxonomy registration text for use elsewhere.
126
  */
127
- function cptui_get_taxonomy_code() {
128
-
129
- $cptui_taxonomies = get_option( 'cptui_taxonomies' );
130
  if ( !empty( $cptui_taxonomies ) ) {
 
 
 
 
 
131
  ?>
132
- add_action( 'init', 'cptui_register_my_taxes' );
133
- function cptui_register_my_taxes() {
134
  <?php
135
  foreach( $cptui_taxonomies as $tax ) {
136
  echo cptui_get_single_taxonomy_registery( $tax ) . "\n";
137
  } ?>
138
- // End cptui_register_my_taxes
139
  }
140
  <?php
141
  } else {
142
- _e( 'No taxonomies to display at this time', 'cpt-plugin' );
143
  }
144
  }
145
 
@@ -168,6 +103,7 @@ function cptui_get_single_taxonomy_registery( $taxonomy = array() ) {
168
  $rewrite_slug = ' \'slug\' => \'' . $taxonomy['rewrite_slug'] . '\',';
169
  }
170
 
 
171
  $withfront = disp_boolean( $taxonomy['rewrite_withfront'] );
172
  if ( !empty( $withfront ) ) {
173
  $rewrite_withfront = ' \'with_front\' => ' . $withfront . ' ';
@@ -218,27 +154,34 @@ function cptui_get_single_taxonomy_registery( $taxonomy = array() ) {
218
  * Display our copy-able code for registered post types.
219
  *
220
  * @since 1.0.0
 
 
 
 
 
221
  *
222
  * @return string Post type registration text for use elsewhere.
223
  */
224
- function cptui_get_post_type_code() {
225
-
226
- $cptui_post_types = get_option( 'cptui_post_types' );
227
-
228
  # Whitespace very much matters here, thus why it's all flush against the left side
229
  if ( !empty( $cptui_post_types ) ) {
 
 
 
 
 
230
  ?>
231
- add_action( 'init', 'cptui_register_my_cpts' );
232
- function cptui_register_my_cpts() {
233
  <?php #space before this line reflects in textarea
234
  foreach( $cptui_post_types as $type ) {
235
  echo cptui_get_single_post_type_registery( $type ) . "\n";
236
  } ?>
237
- // End of cptui_register_my_cpts()
238
  }
239
  <?php
240
  } else {
241
- _e( 'No post types to display at this time', 'cpt-plugin' );
242
  }
243
  }
244
 
@@ -256,11 +199,26 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
256
  /** This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
257
  $post_type['map_meta_cap'] = apply_filters( 'cptui_map_meta_cap', 'true', $post_type['name'], $post_type );
258
 
 
259
  $user_supports_params = apply_filters( 'cptui_user_supports_params', array(), $post_type['name'], $post_type );
260
  if ( is_array( $user_supports_params ) ) {
261
  $post_type['supports'] = array_merge( $post_type['supports'], $user_supports_params );
262
  }
263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  $rewrite = get_disp_boolean( $post_type['rewrite' ] );
265
  if ( false !== $rewrite ) {
266
  $rewrite = disp_boolean( $post_type['rewrite'] );
@@ -302,7 +260,14 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
302
  }
303
 
304
  if ( in_array( $post_type['query_var'], array( 'true', 'false', '0', '1' ) ) ) {
305
- $post_type['query_var'] = get_disp_boolean( $post_type['query_var'] );
 
 
 
 
 
 
 
306
  }
307
 
308
  $post_type['description'] = addslashes( $post_type['description'] );
@@ -321,6 +286,7 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
321
  "description" => "<?php echo $post_type['description']; ?>",
322
  "public" => <?php echo disp_boolean( $post_type['public'] ); ?>,
323
  "show_ui" => <?php echo disp_boolean( $post_type['show_ui'] ); ?>,
 
324
  "has_archive" => <?php echo disp_boolean( $post_type['has_archive'] ); ?>,
325
  "show_in_menu" => <?php echo disp_boolean( $post_type['show_in_menu'] ); ?>,
326
  "exclude_from_search" => <?php echo disp_boolean( $post_type['exclude_from_search'] ); ?>,
@@ -328,10 +294,11 @@ function cptui_get_single_post_type_registery( $post_type = array() ) {
328
  "map_meta_cap" => <?php echo disp_boolean( $post_type['map_meta_cap'] ); ?>,
329
  "hierarchical" => <?php echo disp_boolean( $post_type['hierarchical'] ); ?>,
330
  "rewrite" => <?php echo $rewrite; ?>,
331
- "query_var" => <?php echo disp_boolean( $post_type['query_var'] ); ?>,
332
  <?php if ( !empty( $post_type['menu_position'] ) ) { ?>"menu_position" => <?php echo $post_type['menu_position']; ?>,<?php } ?><?php if ( !empty( $post_type['menu_icon'] ) ) { ?>"menu_icon" => "<?php echo $post_type['menu_icon']; ?>",<?php } ?>
333
  <?php if ( !empty( $supports ) ) { echo "\n\t\t" ?>"supports" => <?php echo $supports; ?>,<?php } ?>
334
- <?php if ( !empty( $taxonomies ) ) { echo "\n\t\t" ?>"taxonomies" => <?php echo $taxonomies; ?><?php } echo "\n"?>
 
335
  );
336
  register_post_type( "<?php echo $post_type['name']; ?>", $args );
337
  <?php
@@ -353,9 +320,47 @@ function cptui_import_types_taxes_settings( $postdata = array() ) {
353
 
354
  $success = false;
355
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  if ( !empty( $postdata['cptui_post_import'] ) ) {
357
- $data = stripslashes_deep( trim( $postdata['cptui_post_import'] ) );
358
- $settings = json_decode( $data, true );
 
 
 
 
 
 
 
 
359
 
360
  if ( $settings ) {
361
  if ( false !== get_option( 'cptui_post_types' ) ) {
@@ -364,11 +369,19 @@ function cptui_import_types_taxes_settings( $postdata = array() ) {
364
 
365
  $success = update_option( 'cptui_post_types', $settings );
366
  }
367
- return cptui_admin_notices( 'import', __( 'Post types', 'cpt-plugin' ), $success );
368
 
369
  } elseif ( !empty( $postdata['cptui_tax_import'] ) ) {
370
- $data = stripslashes_deep( trim( $postdata['cptui_tax_import'] ) );
371
- $settings = json_decode( $data, true );
 
 
 
 
 
 
 
 
372
 
373
  if ( $settings ) {
374
  if ( false !== get_option( 'cptui_taxonomies' ) ) {
@@ -377,10 +390,181 @@ function cptui_import_types_taxes_settings( $postdata = array() ) {
377
 
378
  $success = update_option( 'cptui_taxonomies', $settings );
379
  }
380
- return cptui_admin_notices( 'import', __( 'Taxonomies', 'cpt-plugin' ), $success );
381
  }
382
 
383
  flush_rewrite_rules();
384
 
385
  return $success;
386
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  $tab = 'taxonomies';
21
  } elseif ( !empty( $_GET['action'] ) && 'get_code' == $_GET['action'] ) {
22
  $tab = 'get_code';
23
+ } elseif ( !empty( $_GET['action'] ) && 'debuginfo' == $_GET['action'] ) {
24
+ $tab = 'debuginfo';
25
  } else {
26
  $tab = 'post_types';
27
  }
39
  # Create our tabs.
40
  cptui_settings_tab_menu( $page = 'importexport' );
41
 
42
+ do_action( 'cptui_import_export_sections', $tab );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  echo '</div><!-- End .wrap -->';
45
  }
48
  * Display our copy-able code for registered taxonomies.
49
  *
50
  * @since 1.0.0
51
+ * @since 1.2.0 Added $cptui_taxonomies parameter.
52
+ * @since 1.2.0 Added $single parameter.
53
+ *
54
+ * @param array $cptui_taxonomies Array of taxonomies to render.
55
+ * @param bool $single Whether or not we are rendering a single taxonomy.
56
  *
57
  * @return string Taxonomy registration text for use elsewhere.
58
  */
59
+ function cptui_get_taxonomy_code( $cptui_taxonomies = array(), $single = false ) {
 
 
60
  if ( !empty( $cptui_taxonomies ) ) {
61
+ $callback = 'cptui_register_my_taxes';
62
+ if ( $single ) {
63
+ $key = key( $cptui_taxonomies );
64
+ $callback = 'cptui_register_my_taxes_' . str_replace('-', '_', $cptui_taxonomies[ $key ]['name'] );
65
+ }
66
  ?>
67
+ add_action( 'init', '<?php echo $callback; ?>' );
68
+ function <?php echo $callback; ?>() {
69
  <?php
70
  foreach( $cptui_taxonomies as $tax ) {
71
  echo cptui_get_single_taxonomy_registery( $tax ) . "\n";
72
  } ?>
73
+ // End <?php echo $callback; ?>()
74
  }
75
  <?php
76
  } else {
77
+ _e( 'No taxonomies to display at this time', 'custom-post-type-ui' );
78
  }
79
  }
80
 
103
  $rewrite_slug = ' \'slug\' => \'' . $taxonomy['rewrite_slug'] . '\',';
104
  }
105
 
106
+ $rewrite_withfront = '';
107
  $withfront = disp_boolean( $taxonomy['rewrite_withfront'] );
108
  if ( !empty( $withfront ) ) {
109
  $rewrite_withfront = ' \'with_front\' => ' . $withfront . ' ';
154
  * Display our copy-able code for registered post types.
155
  *
156
  * @since 1.0.0
157
+ * @since 1.2.0 Added $cptui_post_types parameter.
158
+ * @since 1.2.0 Added $single parameter.
159
+ *
160
+ * @param array $cptui_post_types Array of post types to render.
161
+ * @param bool $single Whether or not we are rendering a single post type.
162
  *
163
  * @return string Post type registration text for use elsewhere.
164
  */
165
+ function cptui_get_post_type_code( $cptui_post_types = array(), $single = false ) {
 
 
 
166
  # Whitespace very much matters here, thus why it's all flush against the left side
167
  if ( !empty( $cptui_post_types ) ) {
168
+ $callback = 'cptui_register_my_cpts';
169
+ if ( $single ) {
170
+ $key = key( $cptui_post_types );
171
+ $callback = 'cptui_register_my_cpts_' . str_replace( '-', '_', $cptui_post_types[ $key ]['name'] );
172
+ }
173
  ?>
174
+ add_action( 'init', '<?php echo $callback; ?>' );
175
+ function <?php echo $callback; ?>() {
176
  <?php #space before this line reflects in textarea
177
  foreach( $cptui_post_types as $type ) {
178
  echo cptui_get_single_post_type_registery( $type ) . "\n";
179
  } ?>
180
+ // End of <?php echo $callback; ?>()
181
  }
182
  <?php
183
  } else {
184
+ _e( 'No post types to display at this time', 'custom-post-type-ui' );
185
  }
186
  }
187
 
199
  /** This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
200
  $post_type['map_meta_cap'] = apply_filters( 'cptui_map_meta_cap', 'true', $post_type['name'], $post_type );
201
 
202
+ /** This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
203
  $user_supports_params = apply_filters( 'cptui_user_supports_params', array(), $post_type['name'], $post_type );
204
  if ( is_array( $user_supports_params ) ) {
205
  $post_type['supports'] = array_merge( $post_type['supports'], $user_supports_params );
206
  }
207
 
208
+ $yarpp = false; # Prevent notices.
209
+ if ( ! empty( $post_type['custom_supports'] ) ) {
210
+ $custom = explode( ',', $post_type['custom_supports'] );
211
+ foreach ( $custom as $part ) {
212
+ # We'll handle YARPP separately.
213
+ if ( in_array( $part, array( 'YARPP', 'yarpp' ) ) ) {
214
+ $yarpp = true;
215
+ continue;
216
+ }
217
+ $post_type['supports'][] = $part;
218
+ }
219
+ }
220
+
221
+ $rewrite_withfront = '';
222
  $rewrite = get_disp_boolean( $post_type['rewrite' ] );
223
  if ( false !== $rewrite ) {
224
  $rewrite = disp_boolean( $post_type['rewrite'] );
260
  }
261
 
262
  if ( in_array( $post_type['query_var'], array( 'true', 'false', '0', '1' ) ) ) {
263
+ $post_type['query_var'] = disp_boolean( $post_type['query_var'] );
264
+ }
265
+ if ( !empty( $post_type['query_var_slug'] ) ) {
266
+ $post_type['query_var'] = '"' . $post_type['query_var_slug'] . '"';
267
+ }
268
+
269
+ if ( empty( $post_type['show_in_rest'] ) ) {
270
+ $post_type['show_in_rest'] = 'false';
271
  }
272
 
273
  $post_type['description'] = addslashes( $post_type['description'] );
286
  "description" => "<?php echo $post_type['description']; ?>",
287
  "public" => <?php echo disp_boolean( $post_type['public'] ); ?>,
288
  "show_ui" => <?php echo disp_boolean( $post_type['show_ui'] ); ?>,
289
+ "show_in_rest" => <?php echo disp_boolean( $post_type['show_in_rest'] ); ?>,
290
  "has_archive" => <?php echo disp_boolean( $post_type['has_archive'] ); ?>,
291
  "show_in_menu" => <?php echo disp_boolean( $post_type['show_in_menu'] ); ?>,
292
  "exclude_from_search" => <?php echo disp_boolean( $post_type['exclude_from_search'] ); ?>,
294
  "map_meta_cap" => <?php echo disp_boolean( $post_type['map_meta_cap'] ); ?>,
295
  "hierarchical" => <?php echo disp_boolean( $post_type['hierarchical'] ); ?>,
296
  "rewrite" => <?php echo $rewrite; ?>,
297
+ "query_var" => <?php echo $post_type['query_var']; ?>,
298
  <?php if ( !empty( $post_type['menu_position'] ) ) { ?>"menu_position" => <?php echo $post_type['menu_position']; ?>,<?php } ?><?php if ( !empty( $post_type['menu_icon'] ) ) { ?>"menu_icon" => "<?php echo $post_type['menu_icon']; ?>",<?php } ?>
299
  <?php if ( !empty( $supports ) ) { echo "\n\t\t" ?>"supports" => <?php echo $supports; ?>,<?php } ?>
300
+ <?php if ( !empty( $taxonomies ) ) { echo "\n\t\t" ?>"taxonomies" => <?php echo $taxonomies; ?>,<?php } ?>
301
+ <?php if ( true === $yarpp ) { echo "\n\t\t" ?>"yarpp_support" => <?php echo disp_boolean( $yarpp ); ?><?php } echo "\n";?>
302
  );
303
  register_post_type( "<?php echo $post_type['name']; ?>", $args );
304
  <?php
320
 
321
  $success = false;
322
 
323
+ /**
324
+ * Filters the post type data to import.
325
+ *
326
+ * Allows third parties to provide their own data dump and import instead of going through our UI.
327
+ *
328
+ * @since 1.2.0
329
+ *
330
+ * @param bool $value Default to no data.
331
+ */
332
+ $third_party_post_type_data = apply_filters( 'cptui_third_party_post_type_import', false );
333
+
334
+ /**
335
+ * Filters the taxonomy data to import.
336
+ *
337
+ * Allows third parties to provide their own data dump and import instead of going through our UI.
338
+ *
339
+ * @since 1.2.0
340
+ *
341
+ * @param bool $value Default to no data.
342
+ */
343
+ $third_party_taxonomy_data = apply_filters( 'cptui_third_party_taxonomy_import', false );
344
+
345
+ if ( false !== $third_party_post_type_data ) {
346
+ $postdata['cptui_post_import'] = $third_party_post_type_data;
347
+ }
348
+
349
+ if ( false !== $third_party_taxonomy_data ) {
350
+ $postdata['cptui_tax_import'] = $third_party_taxonomy_data;
351
+ }
352
+
353
  if ( !empty( $postdata['cptui_post_import'] ) ) {
354
+ $cpt_data = stripslashes_deep( trim( $postdata['cptui_post_import'] ) );
355
+ $settings = json_decode( $cpt_data, true );
356
+
357
+ # Add support to delete settings outright, without accessing database.
358
+ # Doing double check to protect.
359
+ if ( is_null( $settings ) && '{""}' === $cpt_data ) {
360
+ delete_option( 'cptui_post_types' );
361
+ # We're technically successful in a sense. Importing nothing.
362
+ $success = true;
363
+ }
364
 
365
  if ( $settings ) {
366
  if ( false !== get_option( 'cptui_post_types' ) ) {
369
 
370
  $success = update_option( 'cptui_post_types', $settings );
371
  }
372
+ return cptui_admin_notices( 'import', __( 'Post types', 'custom-post-type-ui' ), $success );
373
 
374
  } elseif ( !empty( $postdata['cptui_tax_import'] ) ) {
375
+ $tax_data = stripslashes_deep( trim( $postdata['cptui_tax_import'] ) );
376
+ $settings = json_decode( $tax_data, true );
377
+
378
+ # Add support to delete settings outright, without accessing database.
379
+ # Doing double check to protect.
380
+ if ( is_null( $settings ) && '{""}' === $tax_data ) {
381
+ delete_option( 'cptui_taxonomies' );
382
+ # We're technically successful in a sense. Importing nothing.
383
+ $success = true;
384
+ }
385
 
386
  if ( $settings ) {
387
  if ( false !== get_option( 'cptui_taxonomies' ) ) {
390
 
391
  $success = update_option( 'cptui_taxonomies', $settings );
392
  }
393
+ return cptui_admin_notices( 'import', __( 'Taxonomies', 'custom-post-type-ui' ), $success );
394
  }
395
 
396
  flush_rewrite_rules();
397
 
398
  return $success;
399
  }
400
+
401
+ function cptui_render_posttypes_taxonomies_section() {
402
+ ?>
403
+
404
+ <p><?php _e( 'If you are wanting to migrate registered post types or taxonomies from this site to another, that will also use Custom Post Type UI, use the import and export functionality. If you are moving away from Custom Post Type UI, use the information in the "Get Code" tab.', 'custom-post-type-ui' ); ?></p>
405
+
406
+ <p><?php printf( '<strong>%s</strong>: %s',
407
+ __( 'NOTE', 'custom-post-type-ui' ),
408
+ __( 'This will not export the associated posts or taxonomy terms, just the settings.', 'custom-post-type-ui' )
409
+ ); ?>
410
+ </p>
411
+ <table class="form-table cptui-table">
412
+ <?php if ( ! empty( $_GET ) && empty( $_GET['action'] ) ) { ?>
413
+ <tr>
414
+ <td class="outter">
415
+ <label for="cptui_post_import"><h2><?php _e( 'Import Post Types', 'custom-post-type-ui' ); ?></h2>
416
+ </label>
417
+
418
+ <form method="post">
419
+ <textarea class="cptui_post_import" placeholder="<?php esc_attr_e( 'Paste content here.', 'custom-post-type-ui' ); ?>" id="cptui_post_import" name="cptui_post_import"></textarea>
420
+
421
+ <p class="wp-ui-highlight">
422
+ <strong><?php _e( 'Note:', 'custom-post-type-ui' ); ?></strong> <?php _e( 'Importing will overwrite previous registered settings.', 'custom-post-type-ui' ); ?>
423
+ </p>
424
+
425
+ <p>
426
+ <strong><?php _e( 'To import post types from a different WordPress site, paste the exported content from that site and click the "Import" button.', 'custom-post-type-ui' ); ?></strong>
427
+ </p>
428
+
429
+ <p>
430
+ <input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Import', 'custom-post-type-ui' ); ?>" />
431
+ </p>
432
+ </form>
433
+ </td>
434
+ <td class="outter">
435
+ <label for="cptui_post_export"><h2><?php _e( 'Export Post Types', 'custom-post-type-ui' ); ?></h2>
436
+ </label>
437
+ <?php
438
+ $cptui_post_types = get_option( 'cptui_post_types', array() );
439
+ if ( ! empty( $cptui_post_types ) ) {
440
+ $content = esc_html( json_encode( $cptui_post_types ) );
441
+ } else {
442
+ $content = __( 'No post types registered yet.', 'custom-post-type-ui' );
443
+ }
444
+ ?>
445
+ <textarea title="<?php esc_attr_e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'custom-post-type-ui' ); ?>" onclick="this.focus();this.select()" readonly="readonly" class="cptui_post_import" id="cptui_post_export" name="cptui_post_export"><?php echo $content; ?></textarea>
446
+
447
+ <p>
448
+ <strong><?php _e( 'Use the content above to import current post types into a different WordPress site. You can also use this to simply back up your post type settings.', 'custom-post-type-ui' ); ?></strong>
449
+ </p>
450
+ </td>
451
+ </tr>
452
+ <?php } elseif ( ! empty( $_GET ) && 'taxonomies' == $_GET['action'] ) { ?>
453
+ <tr>
454
+ <td class="outter">
455
+ <label for="cptui_tax_import"><h2><?php _e( 'Import Taxonomies', 'custom-post-type-ui' ); ?></h2>
456
+ </label>
457
+
458
+ <form method="post">
459
+ <textarea class="cptui_tax_import" placeholder="<?php esc_attr_e( 'Paste content here.', 'custom-post-type-ui' ); ?>" id="cptui_tax_import" name="cptui_tax_import"></textarea>
460
+
461
+ <p class="wp-ui-highlight">
462
+ <strong><?php _e( 'Note:', 'custom-post-type-ui' ); ?></strong> <?php _e( 'Importing will overwrite previous registered settings.', 'custom-post-type-ui' ); ?>
463
+ </p>
464
+
465
+ <p>
466
+ <strong><?php _e( 'To import taxonomies from a different WordPress site, paste the exported content from that site and click the "Import" button.', 'custom-post-type-ui' ); ?></strong>
467
+ </p>
468
+
469
+ <p>
470
+ <input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Import', 'custom-post-type-ui' ); ?>" />
471
+ </p>
472
+ </form>
473
+ </td>
474
+ <td class="outter">
475
+ <label for="cptui_tax_export"><h2><?php _e( 'Export Taxonomies', 'custom-post-type-ui' ); ?></h2>
476
+ </label>
477
+ <?php
478
+ $cptui_taxonomies = get_option( 'cptui_taxonomies', array() );
479
+ if ( ! empty( $cptui_taxonomies ) ) {
480
+ $content = esc_html( json_encode( $cptui_taxonomies ) );
481
+ } else {
482
+ $content = __( 'No taxonomies registered yet.', 'custom-post-type-ui' );
483
+ }
484
+ ?>
485
+ <textarea title="<?php esc_attr_e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'custom-post-type-ui' ); ?>" onclick="this.focus();this.select()" readonly="readonly" class="cptui_tax_import" id="cptui_tax_export" name="cptui_tax_export"><?php echo $content; ?></textarea>
486
+
487
+ <p>
488
+ <strong><?php _e( 'Use the content above to import current taxonomies into a different WordPress site. You can also use this to simply back up your taxonomy settings.', 'custom-post-type-ui' ); ?></strong>
489
+ </p>
490
+ </td>
491
+ </tr>
492
+ <?php } ?>
493
+ </table>
494
+ <?php
495
+ }
496
+
497
+ function cptui_render_getcode_section() {
498
+ ?>
499
+ <h1><?php _e( 'Get Post Type and Taxonomy Code', 'custom-post-type-ui' ); ?></h1>
500
+
501
+ <h2><?php _e( 'All CPT UI Post Types', 'custom-post-type-ui' ); ?></h2>
502
+
503
+ <?php $cptui_post_types = get_option( 'cptui_post_types' ); ?>
504
+ <label for="cptui_post_type_get_code"><?php _e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label>
505
+ <textarea name="cptui_post_type_get_code" id="cptui_post_type_get_code" class="cptui_post_type_get_code" onclick="this.focus();this.select()" readonly="readonly"><?php cptui_get_post_type_code( $cptui_post_types ); ?></textarea>
506
+
507
+ <?php
508
+ if ( !empty( $cptui_post_types ) ) {
509
+ foreach ( $cptui_post_types as $post_type ) { ?>
510
+ <h2><?php
511
+ $type = ( !empty( $post_type['label'] ) ) ? $post_type['label'] : $post_type['name'];
512
+ printf( __( '%s Post Type', 'custom-post-type-ui' ), $type ); ?></h2>
513
+ <label for="cptui_post_type_get_code_<?php echo $post_type['name']; ?>"><?php _e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label>
514
+ <textarea name="cptui_post_type_get_code_<?php echo $post_type['name']; ?>" id="cptui_post_type_get_code_<?php echo $post_type['name']; ?>" class="cptui_post_type_get_code" onclick="this.focus();this.select()" readonly="readonly"><?php cptui_get_post_type_code( array( $post_type ), true ); ?></textarea>
515
+ <?php }
516
+ } ?>
517
+
518
+ <h2><?php _e( 'All CPT UI Taxonomies', 'custom-post-type-ui' ); ?></h2>
519
+
520
+ <?php $cptui_taxonomies = get_option( 'cptui_taxonomies' ); ?>
521
+ <label for="cptui_tax_get_code"><?php _e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label>
522
+ <textarea name="cptui_tax_get_code" id="cptui_tax_get_code" class="cptui_tax_get_code" onclick="this.focus();this.select()" readonly="readonly"><?php cptui_get_taxonomy_code( $cptui_taxonomies ); ?></textarea>
523
+
524
+ <?php
525
+ if ( ! empty( $cptui_taxonomies ) ) {
526
+ foreach ( $cptui_taxonomies as $taxonomy ) { ?>
527
+ <h2><?php
528
+ $tax = ( ! empty( $taxonomy['label'] ) ) ? $taxonomy['label'] : $taxonomy['name'];
529
+ printf( __( '%s Taxonomy', 'custom-post-type-ui' ), $tax ); ?></h2>
530
+ <label for="cptui_tax_get_code_<?php echo $taxonomy['name']; ?>"><?php _e( 'Copy/paste the code below into your functions.php file.', 'custom-post-type-ui' ); ?></label>
531
+ <textarea name="cptui_tax_get_code_<?php echo $taxonomy['name']; ?>" id="cptui_tax_get_code_<?php echo $taxonomy['name']; ?>" class="cptui_tax_get_code" onclick="this.focus();this.select()" readonly="readonly"><?php cptui_get_taxonomy_code( array( $taxonomy ), true ); ?></textarea>
532
+ <?php }
533
+ } ?>
534
+ <?php
535
+ }
536
+
537
+ function cptui_render_debuginfo_section() {
538
+ $debuginfo = new CPTUI_Debug_Info();
539
+
540
+ echo '<form id="cptui_debug_info" method="post">';
541
+ $debuginfo->tab_site_info();
542
+
543
+ if ( ! empty( $_POST ) && isset( $_POST['cptui_debug_info_email'] ) ) {
544
+ $email_args = array();
545
+ $email_args['email'] = sanitize_text_field( $_POST['cptui_debug_info_email'] );
546
+ $debuginfo->send_email( $email_args );
547
+ }
548
+
549
+ echo '<p><label for="cptui_debug_info_email">' . __( 'Please provide an email address to send debug information to: ', 'custom-post-type-ui' ) . '</label><input type="email" id="cptui_debug_info_email" name="cptui_debug_info_email" value="" /></p>';
550
+
551
+ echo '<p><input type="submit" class="button-primary" name="cptui_send_debug_email" value="' . esc_attr( apply_filters( 'cptui_post_type_debug_email', __( 'Send debug info', 'custom-post-type-ui' ) ) ) . '" /></p>';
552
+ echo '</form>';
553
+ }
554
+
555
+ function cptui_render_importexportsections( $tab ) {
556
+ if ( isset( $tab ) ) {
557
+ if ( 'post_types' == $tab || 'taxonomies' == $tab ) {
558
+ cptui_render_posttypes_taxonomies_section();
559
+ }
560
+
561
+ if ( 'get_code' == $tab ) {
562
+ cptui_render_getcode_section();
563
+ }
564
+
565
+ if ( 'debuginfo' == $tab ) {
566
+ cptui_render_debuginfo_section();
567
+ }
568
+ }
569
+ }
570
+ add_action( 'cptui_import_export_sections', 'cptui_render_importexportsections' );
inc/listings.php CHANGED
@@ -7,18 +7,25 @@ function cptui_listings() {
7
  ?>
8
  <div class="wrap">
9
 
10
- <h1><?php _e( 'Post Types and Taxonomies registered by Custom Post Type UI.', 'cpt-plugin' ); ?></h1>
11
  <?php
12
  $post_types = get_option( 'cptui_post_types' );
13
-
14
  if ( !empty( $post_types ) ) {
15
-
16
- echo '<h2>' . __( 'Post Types', 'cpt-plugin' ) . '</h2>';
17
  ?>
18
- <p><?php printf( __( 'Total count: %d', 'cpt-plugin' ), count( $post_types ) ); ?></p>
19
 
20
  <?php
21
 
 
 
 
 
 
 
 
 
 
22
  /**
23
  * Fires before the listing of registered post type data.
24
  *
@@ -28,11 +35,9 @@ function cptui_listings() {
28
  ?>
29
  <table class="wp-list-table widefat">
30
  <tr>
31
- <th><?php _e( 'Post Type', 'cpt-plugin' ); ?></th>
32
- <th><?php _e( 'Settings', 'cpt-plugin' ); ?></th>
33
- <th><?php _e( 'Supports', 'cpt-plugin' ); ?></th>
34
- <th><?php _e( 'Taxonomies', 'cpt-plugin' ); ?></th>
35
- <th><?php _e( 'Labels', 'cpt-plugin' ); ?></th>
36
  </tr>
37
  <?php
38
  $counter = 1;
@@ -43,6 +48,7 @@ function cptui_listings() {
43
  $strings = array();
44
  $supports = array();
45
  $taxonomies = array();
 
46
  foreach( $post_type_settings as $settings_key => $settings_value ) {
47
  if ( 'labels' == $settings_key ) {
48
  continue;
@@ -68,11 +74,11 @@ function cptui_listings() {
68
  }
69
  ?>
70
  <tr class="<?php echo $rowclass; ?>">
71
- <td><a href="<?php echo admin_url( 'admin.php?page=cptui_manage_post_types&action=edit&cptui_post_type=' . $post_type ); ?>"><?php echo $post_type; ?></a><br/><hr/>
72
- <a href="<?php echo admin_url( 'admin.php?page=cptui_manage_post_types&action=edit&cptui_post_type=' . $post_type ); ?>"><?php _e( 'Edit', 'cpt-plugin' ); ?></a>
73
  <?php if ( $archive ) { ?>
74
  |
75
- <a href="<?php echo get_post_type_archive_link( $post_type ); ?>"><?php _e( 'View frontend archive', 'cpt-plugin' ); ?></a>
76
  <?php } ?>
77
  </td>
78
  <td>
@@ -105,10 +111,30 @@ function cptui_listings() {
105
  echo $key . ': ' . $value . '<br/>';
106
  }
107
  } else {
108
- _e( 'No custom labels to display', 'cpt-plugin' );
109
  }
110
  ?>
111
  </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  </tr>
113
 
114
  <?php
@@ -116,118 +142,153 @@ function cptui_listings() {
116
  }
117
  ?>
118
  <tr>
119
- <th><?php _e( 'Post Type', 'cpt-plugin' ); ?></th>
120
- <th><?php _e( 'Settings', 'cpt-plugin' ); ?></th>
121
- <th><?php _e( 'Supports', 'cpt-plugin' ); ?></th>
122
- <th><?php _e( 'Taxonomies', 'cpt-plugin' ); ?></th>
123
- <th><?php _e( 'Labels', 'cpt-plugin' ); ?></th>
124
  </tr>
125
  </table>
126
- <?php
 
 
 
 
 
 
 
127
  }
128
 
129
- $taxonomies = get_option( 'cptui_taxonomies' );
130
- if ( !empty( $taxonomies ) ) {
 
 
 
131
 
132
- echo '<h2>' . __( 'Taxonomies', 'cpt-plugin' ) . '</h2>';
133
- ?>
134
- <p><?php printf( __( 'Total count: %d', 'cpt-plugin' ), count( $taxonomies ) ); ?></p>
135
 
136
- <?php
 
 
 
 
 
 
137
 
138
- /**
139
- * Fires before the listing of registered taxonomy data.
140
- *
141
- * @since 1.1.0
142
- */
143
- do_action( 'cptui_before_taxonomy_listing' );
144
- ?>
145
- <table class="wp-list-table widefat">
146
- <tr>
147
- <th><?php _e( 'Taxonomy', 'cpt-plugin' ); ?></th>
148
- <th><?php _e( 'Settings', 'cpt-plugin' ); ?></th>
149
- <th><?php _e( 'Post Types', 'cpt-plugin' ); ?></th>
150
- <th><?php _e( 'Labels', 'cpt-plugin' ); ?></th>
151
- </tr>
152
- <?php
153
- $counter = 1;
154
- foreach ( $taxonomies as $taxonomy => $taxonomy_settings ) {
155
 
156
- $rowclass = ( $counter % 2 == 0 ) ? '' : 'alternate';
157
 
158
- $strings = array();
159
- $object_types = array();
160
- foreach( $taxonomy_settings as $settings_key => $settings_value ) {
161
- if ( 'labels' == $settings_key ) {
162
- continue;
163
- }
164
 
165
- if ( is_string( $settings_value ) ) {
166
- $strings[ $settings_key ] = $settings_value;
167
- } else {
168
- if ( 'object_types' === $settings_key ) {
169
- $object_types[ $settings_key ] = $settings_value;
170
 
171
- # In case they are not associated from the post type settings
172
- if ( empty( $object_types['taxonomies'] ) ) {
173
- $types = get_taxonomy( $taxonomy );
174
- $object_types['types'] = $types->object_type;
 
175
  }
176
  }
177
  }
178
- }
179
- ?>
180
- <tr class="<?php echo $rowclass; ?>">
181
- <td><a href="<?php echo admin_url( 'admin.php?page=cptui_manage_taxonomies&action=edit&cptui_taxonomy=' . $taxonomy ); ?>"><?php echo $taxonomy; ?></a><br/><hr/>
182
- <a href="<?php echo admin_url( 'admin.php?page=cptui_manage_taxonomies&action=edit&cptui_taxonomy=' . $taxonomy ); ?>"><?php _e( 'Edit', 'cpt-plugin' ); ?></a>
183
- </td>
184
- <td>
185
- <?php foreach ( $strings as $key => $value ) {
186
- printf( '<strong>%s:</strong> ', $key );
187
- if ( in_array( $value, array( '1', '0' ) ) ) {
188
- echo disp_boolean( $value );