PluginProbe ʕ •ᴥ•ʔ
Custom Post Type UI / 1.19.2
Custom Post Type UI v1.19.2
1.19.2 1.19.1 1.19.0 trunk 0.7.0.0 0.7.1.0 0.7.2.0 0.8.0.0 0.8.1 0.8.2 0.8.3 0.8.4 0.8.5 0.9.0 0.9.5 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.1.1 1.1.2 1.1.3 1.10.0 1.10.1 1.10.2 1.11.0 1.11.1 1.11.2 1.12.0 1.12.1 1.13.0 1.13.1 1.13.2 1.13.3 1.13.4 1.13.5 1.13.6 1.13.7 1.14.0 1.15.0 1.15.1 1.16.0 1.17.0 1.17.1 1.17.2 1.17.3 1.18.0 1.18.1 1.18.2 1.18.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.1 1.6.2 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.8.0 1.8.1 1.8.2 1.9.0 1.9.1 1.9.2
custom-post-type-ui / inc / tools.php
custom-post-type-ui / inc Last commit date
tools-sections 3 weeks ago about.php 3 weeks ago listings.php 3 weeks ago post-types.php 3 weeks ago support.php 3 weeks ago taxonomies.php 3 weeks ago tools.php 3 weeks ago utility.php 3 weeks ago wp-cli.php 3 weeks ago
tools.php
556 lines
1 <?php
2 /**
3 * Custom Post Type UI Tools.
4 *
5 * @package CPTUI
6 * @subpackage Tools
7 * @author WebDevStudios
8 * @since 1.0.0
9 * @license GPL-2.0+
10 */
11
12 // phpcs:disable WebDevStudios.All.RequireAuthor
13
14 // Exit if accessed directly.
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * Enqueue our Custom Post Type UI assets.
21 *
22 * @since 1.6.0
23 *
24 * @return void
25 */
26 function cptui_tools_assets( $hook ) {
27
28 if ( 'cpt-ui_page_cptui_tools' !== $hook ) {
29 return;
30 }
31
32 if ( wp_doing_ajax() ) {
33 return;
34 }
35
36 wp_enqueue_style( 'cptui-css' );
37 }
38 add_action( 'admin_enqueue_scripts', 'cptui_tools_assets' );
39
40 /**
41 * Register our tabs for the Tools screen.
42 *
43 * @since 1.3.0
44 * @since 1.5.0 Renamed to "Tools"
45 *
46 * @internal
47 *
48 * @param array $tabs Array of tabs to display. Optional.
49 * @param string $current_page Current page being shown. Optional. Default empty string.
50 * @return array Amended array of tabs to show.
51 */
52 function cptui_tools_tabs( $tabs = [], $current_page = '' ) {
53
54 if ( 'tools' === $current_page ) {
55 $classes = [ 'nav-tab' ];
56
57 $page_title = esc_html( get_admin_page_title() );
58 $tabs['page_title'] = '';
59 if ( empty( $_GET['action'] ) ) {
60 $tabs['page_title'] .= esc_html__( 'Post types', 'custom-post-type-ui' ) . ' - ' . $page_title;
61 }
62
63 if ( ! empty( $_GET['action'] ) && 'taxonomies' === sanitize_text_field( $_GET['action'] ) ) {
64 $tabs['page_title'] .= esc_html__( 'Taxonomies', 'custom-post-type-ui' ) . ' - ' . $page_title;
65 }
66
67 if ( ! empty( $_GET['action'] ) && 'get_code' === sanitize_text_field( $_GET['action'] ) ) {
68 $tabs['page_title'] .= esc_html__( 'Get code', 'custom-post-type-ui' ) . ' - ' . $page_title;
69 }
70
71 if ( ! empty( $_GET['action'] ) && 'debuginfo' === sanitize_text_field( $_GET['action'] ) ) {
72 $tabs['page_title'] .= esc_html__( 'Debug info', 'custom-post-type-ui' ) . ' - ' . $page_title;
73 }
74
75 $tabs['tabs'] = [];
76 $tabs['tabs']['post_types'] = [
77 'text' => esc_html__( 'Post types', 'custom-post-type-ui' ),
78 'classes' => $classes,
79 'url' => cptui_admin_url( 'admin.php?page=cptui_' . $current_page ),
80 'aria-selected' => 'false',
81 ];
82
83 $tabs['tabs']['taxonomies'] = [
84 'text' => esc_html__( 'Taxonomies', 'custom-post-type-ui' ),
85 'classes' => $classes,
86 'url' => esc_url( add_query_arg( [ 'action' => 'taxonomies' ], cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
87 'aria-selected' => 'false',
88 ];
89
90 $tabs['tabs']['get_code'] = [
91 'text' => esc_html__( 'Get code', 'custom-post-type-ui' ),
92 'classes' => $classes,
93 'url' => esc_url( add_query_arg( [ 'action' => 'get_code' ], cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
94 'aria-selected' => 'false',
95 ];
96
97 $tabs['tabs']['debuginfo'] = [
98 'text' => esc_html__( 'Debug info', 'custom-post-type-ui' ),
99 'classes' => $classes,
100 'url' => esc_url( add_query_arg( [ 'action' => 'debuginfo' ], cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
101 'aria-selected' => 'false',
102 ];
103
104 $active_class = 'nav-tab-active';
105 $action = cptui_get_current_action();
106 if ( ! empty( $action ) ) {
107 if ( 'taxonomies' === $action ) {
108 $tabs['tabs']['taxonomies']['classes'][] = $active_class;
109 $tabs['tabs']['taxonomies']['aria-selected'] = 'true';
110 } elseif ( 'get_code' === $action ) {
111 $tabs['tabs']['get_code']['classes'][] = $active_class;
112 $tabs['tabs']['get_code']['aria-selected'] = 'true';
113 } elseif ( 'debuginfo' === $action ) {
114 $tabs['tabs']['debuginfo']['classes'][] = $active_class;
115 $tabs['tabs']['debuginfo']['aria-selected'] = 'true';
116 }
117 } else {
118 $tabs['tabs']['post_types']['classes'][] = $active_class;
119 $tabs['tabs']['post_types']['aria-selected'] = 'true';
120 }
121
122 /**
123 * Filters the tabs being added for the tools area.
124 *
125 * @since 1.5.0
126 *
127 * @param array $tabs Array of tabs to show.
128 * @param string $action Current tab being shown.
129 * @param string $active_class Class to use to mark the tab active.
130 */
131 $tabs = apply_filters( 'cptui_tools_tabs', $tabs, $action, $active_class );
132 }
133
134 return $tabs;
135 }
136 add_filter( 'cptui_get_tabs', 'cptui_tools_tabs', 10, 2 );
137
138 /**
139 * Create our settings page output.
140 *
141 * @since 1.0.0
142 *
143 * @internal
144 */
145 function cptui_tools() {
146
147 $tab = 'post_types';
148 if ( ! empty( $_GET ) ) { // phpcs:ignore WordPress.Security.NonceVerification
149 if ( ! empty( $_GET['action'] ) && 'taxonomies' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
150 $tab = 'taxonomies';
151 } elseif ( ! empty( $_GET['action'] ) && 'get_code' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
152 $tab = 'get_code';
153 } elseif ( ! empty( $_GET['action'] ) && 'debuginfo' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
154 $tab = 'debuginfo';
155 }
156 }
157
158 echo '<div class="wrap">';
159 /**
160 * Fires immediately after wrap div started on all of the cptui admin pages.
161 *
162 * @since 1.14.0
163 */
164 do_action( 'cptui_inside_wrap' );
165
166 /**
167 * Fires right inside the wrap div for the import/export pages.
168 *
169 * @since 1.3.0
170 *
171 * @deprecated 1.5.0
172 */
173 do_action_deprecated( 'cptui_inside_importexport_wrap', [], '1.5.0', 'cptui_inside_tools_wrap' );
174
175 /**
176 * Fires right inside the wrap div for the tools pages.
177 *
178 * @since 1.5.0
179 */
180 do_action( 'cptui_inside_tools_wrap' );
181
182 // Create our tabs.
183 cptui_settings_tab_menu( 'tools' );
184
185 /**
186 * Fires inside the markup for the import/export section.
187 *
188 * Allows for more modular control and adding more sections more easily.
189 *
190 * @since 1.2.0
191 *
192 * @deprecated 1.5.0
193 *
194 * @param string $tab Current tab being displayed.
195 */
196 do_action_deprecated( 'cptui_import_export_sections', [ $tab ], '1.5.0', 'cptui_tools_sections' );
197
198 /**
199 * Fires inside the markup for the tools section.
200 *
201 * Allows for more modular control and adding more sections more easily.
202 *
203 * @since 1.5.0
204 *
205 * @param string $tab Current tab being displayed.
206 */
207 do_action( 'cptui_tools_sections', $tab );
208
209 echo '</div><!-- End .wrap -->';
210 }
211
212 /**
213 * Import the posted JSON data from a separate export.
214 *
215 * @since 1.0.0
216 *
217 * @internal
218 *
219 * @param array $postdata $_POST data as json. Optional.
220 * @return mixed false on nothing to do, otherwise void.
221 */
222 function cptui_import_types_taxes_settings( $postdata = [] ) {
223 if ( ! isset( $postdata['cptui_post_import'] ) && ! isset( $postdata['cptui_tax_import'] ) && ! array_key_exists( 'delete', $postdata ) ) {
224 return false;
225 }
226
227 $doing_wp_cli = ( defined( 'WP_CLI' ) && WP_CLI );
228 if ( ! $doing_wp_cli && ! check_admin_referer( 'cptui_typetaximport_nonce_action', 'cptui_typetaximport_nonce_field' ) ) {
229 return 'nonce_fail';
230 }
231
232 $status = 'import_fail';
233 $success = false;
234
235 /**
236 * Filters the post type data to import.
237 *
238 * Allows third parties to provide their own data dump and import instead of going through our UI.
239 *
240 * @since 1.2.0
241 *
242 * @param bool $value Default to no data.
243 */
244 $third_party_post_type_data = apply_filters( 'cptui_third_party_post_type_import', false );
245
246 /**
247 * Filters the taxonomy data to import.
248 *
249 * Allows third parties to provide their own data dump and import instead of going through our UI.
250 *
251 * @since 1.2.0
252 *
253 * @param bool $value Default to no data.
254 */
255 $third_party_taxonomy_data = apply_filters( 'cptui_third_party_taxonomy_import', false );
256
257 if ( false !== $third_party_post_type_data ) {
258 $postdata['cptui_post_import'] = $third_party_post_type_data;
259 }
260
261 if ( false !== $third_party_taxonomy_data ) {
262 $postdata['cptui_tax_import'] = $third_party_taxonomy_data;
263 }
264
265 if ( ! empty( $postdata['cptui_post_import'] ) || ( isset( $postdata['delete'] ) && 'type_true' === $postdata['delete'] ) ) {
266 $settings = null;
267 if ( ! empty( $postdata['cptui_post_import'] ) ) {
268 $settings = $postdata['cptui_post_import'];
269 }
270
271 // Add support to delete settings outright, without accessing database.
272 // Doing double check to protect.
273 if ( null === $settings && ( isset( $postdata['delete'] ) && 'type_true' === $postdata['delete'] ) ) {
274
275 /**
276 * Filters whether or not 3rd party options were deleted successfully within post type import.
277 *
278 * @since 1.3.0
279 *
280 * @param bool $value Whether or not someone else deleted successfully. Default false.
281 * @param array $postdata Post type data.
282 */
283 if ( false === ( $success = apply_filters( 'cptui_post_type_import_delete_save', false, $postdata ) ) ) { // phpcs:ignore.
284 $success = delete_option( 'cptui_post_types' );
285 }
286 }
287
288 if ( $settings ) {
289 if ( false !== cptui_get_post_type_data() ) {
290 /** This filter is documented in /inc/import-export.php */
291 if ( false === ( $success = apply_filters( 'cptui_post_type_import_delete_save', false, $postdata ) ) ) { // phpcs:ignore.
292 delete_option( 'cptui_post_types' );
293 }
294 }
295
296 /**
297 * Filters whether or not 3rd party options were updated successfully within the post type import.
298 *
299 * @since 1.3.0
300 *
301 * @param bool $value Whether or not someone else updated successfully. Default false.
302 * @param array $postdata Post type data.
303 */
304 if ( false === ( $success = apply_filters( 'cptui_post_type_import_update_save', false, $postdata ) ) ) { // phpcs:ignore.
305 $success = update_option( 'cptui_post_types', $settings );
306 }
307 }
308 // Used to help flush rewrite rules on init.
309 set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 );
310
311 if ( $success ) {
312 $status = 'import_success';
313 }
314 } elseif ( ! empty( $postdata['cptui_tax_import'] ) || ( isset( $postdata['delete'] ) && 'tax_true' === $postdata['delete'] ) ) {
315 $settings = null;
316
317 if ( ! empty( $postdata['cptui_tax_import'] ) ) {
318 $settings = $postdata['cptui_tax_import'];
319 }
320 // Add support to delete settings outright, without accessing database.
321 // Doing double check to protect.
322 if ( null === $settings && ( isset( $postdata['delete'] ) && 'tax_true' === $postdata['delete'] ) ) {
323
324 /**
325 * Filters whether or not 3rd party options were deleted successfully within taxonomy import.
326 *
327 * @since 1.3.0
328 *
329 * @param bool $value Whether or not someone else deleted successfully. Default false.
330 * @param array $postdata Taxonomy data
331 */
332 if ( false === ( $success = apply_filters( 'cptui_taxonomy_import_delete_save', false, $postdata ) ) ) { // phpcs:ignore.
333 $success = delete_option( 'cptui_taxonomies' );
334 }
335 }
336
337 if ( $settings ) {
338 if ( false !== cptui_get_taxonomy_data() ) {
339 /** This filter is documented in /inc/import-export.php */
340 if ( false === ( $success = apply_filters( 'cptui_taxonomy_import_delete_save', false, $postdata ) ) ) { // phpcs:ignore.
341 delete_option( 'cptui_taxonomies' );
342 }
343 }
344 /**
345 * Filters whether or not 3rd party options were updated successfully within the taxonomy import.
346 *
347 * @since 1.3.0
348 *
349 * @param bool $value Whether or not someone else updated successfully. Default false.
350 * @param array $postdata Taxonomy data.
351 */
352 if ( false === ( $success = apply_filters( 'cptui_taxonomy_import_update_save', false, $postdata ) ) ) { // phpcs:ignore.
353 $success = update_option( 'cptui_taxonomies', $settings );
354 }
355 }
356 // Used to help flush rewrite rules on init.
357 set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 );
358 if ( $success ) {
359 $status = 'import_success';
360 }
361 }
362
363 return $status;
364 }
365
366 /**
367 * Content for the Post Types/Taxonomies Tools tab.
368 *
369 * @since 1.2.0
370 *
371 * @internal
372 */
373 function cptui_render_posttypes_taxonomies_section() {
374 ?>
375
376 <p><?php esc_html_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>
377
378 <p>
379 <?php
380 printf(
381 '<strong>%s</strong>: %s',
382 esc_html__( 'NOTE', 'custom-post-type-ui' ),
383 esc_html__( 'This will not export the associated posts or taxonomy terms, just the settings.', 'custom-post-type-ui' )
384 );
385 ?>
386 </p>
387 <table class="form-table cptui-table">
388 <?php if ( ! empty( $_GET ) && empty( $_GET['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification ?>
389 <tr>
390 <td class="outer">
391 <h2><label for="cptui_post_import"><?php esc_html_e( 'Import Post Types', 'custom-post-type-ui' ); ?></label></h2>
392
393 <form method="post">
394 <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>
395
396 <p class="wp-ui-highlight">
397 <strong><?php esc_html_e( 'Note:', 'custom-post-type-ui' ); ?></strong> <?php esc_html_e( 'Importing will overwrite previous registered settings.', 'custom-post-type-ui' ); ?>
398 </p>
399
400 <p>
401 <strong><?php esc_html_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>
402 </p>
403
404 <p>
405 <input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Import', 'custom-post-type-ui' ); ?>" />
406 </p>
407 <?php wp_nonce_field( 'cptui_typetaximport_nonce_action', 'cptui_typetaximport_nonce_field' ); ?>
408 </form>
409 </td>
410 <td class="outer">
411 <h2><label for="cptui_post_export"><?php esc_html_e( 'Export Post Types settings', 'custom-post-type-ui' ); ?></label></h2>
412 <?php
413 $cptui_post_types = cptui_get_post_type_data();
414 if ( ! empty( $cptui_post_types ) ) {
415 foreach ( $cptui_post_types as $type => $values ) {
416 if ( ! empty( $values['description'] ) ) {
417 $cptui_post_types[ $type ]['description'] = wp_slash( html_entity_decode( $values['description'] ) );
418 }
419 }
420 $content = wp_json_encode( $cptui_post_types );
421 } else {
422 $content = esc_html__( 'No post types registered yet.', 'custom-post-type-ui' );
423 }
424 ?>
425 <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();" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true" class="cptui_post_import" id="cptui_post_export" name="cptui_post_export"><?php echo $content; // phpcs:ignore. ?></textarea>
426
427 <p>
428 <strong><?php esc_html_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>
429 </p>
430 </td>
431 </tr>
432 <?php } elseif ( ! empty( $_GET ) && 'taxonomies' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification ?>
433 <tr>
434 <td class="outer">
435 <h2><label for="cptui_tax_import"><?php esc_html_e( 'Import Taxonomies', 'custom-post-type-ui' ); ?></label></h2>
436
437 <form method="post">
438 <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>
439
440 <p class="wp-ui-highlight">
441 <strong><?php esc_html_e( 'Note:', 'custom-post-type-ui' ); ?></strong> <?php esc_html_e( 'Importing will overwrite previous registered settings.', 'custom-post-type-ui' ); ?>
442 </p>
443
444 <p>
445 <strong><?php esc_html_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>
446 </p>
447
448 <p>
449 <input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Import', 'custom-post-type-ui' ); ?>" />
450 </p>
451 <?php wp_nonce_field( 'cptui_typetaximport_nonce_action', 'cptui_typetaximport_nonce_field' ); ?>
452 </form>
453 </td>
454 <td class="outer">
455 <h2><label for="cptui_tax_export"><?php esc_html_e( 'Export Taxonomies settings', 'custom-post-type-ui' ); ?></label></h2>
456 <?php
457 $cptui_taxonomies = cptui_get_taxonomy_data();
458 if ( ! empty( $cptui_taxonomies ) ) {
459 foreach ( $cptui_taxonomies as $tax => $values ) {
460 if ( ! empty( $values['description'] ) ) {
461 $cptui_taxonomies[ $tax ]['description'] = wp_slash( html_entity_decode( $values['description'] ) );
462 }
463 }
464 $content = wp_json_encode( $cptui_taxonomies );
465 } else {
466 $content = esc_html__( 'No taxonomies registered yet.', 'custom-post-type-ui' );
467 }
468 ?>
469 <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()" onfocus="this.focus();this.select();" readonly="readonly" aria-readonly="true" class="cptui_tax_import" id="cptui_tax_export" name="cptui_tax_export"><?php echo $content; // phpcs:ignore WordPress.Security.EscapeOutput ?></textarea>
470
471 <p>
472 <strong><?php esc_html_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>
473 </p>
474 </td>
475 </tr>
476 <?php } ?>
477 </table>
478 <?php
479 }
480
481 /**
482 * Renders various tab sections for the Tools page, based on current tab.
483 *
484 * @since 1.2.0
485 *
486 * @internal
487 *
488 * @param string $tab Current tab to display.
489 */
490 function cptui_render_tools( $tab ) {
491 if ( 'post_types' === $tab || 'taxonomies' === $tab ) {
492 cptui_render_posttypes_taxonomies_section();
493 }
494
495 if ( 'get_code' === $tab ) {
496 cptui_render_getcode_section();
497 }
498
499 if ( 'debuginfo' === $tab ) {
500 cptui_render_debuginfo_section();
501 }
502 }
503 add_action( 'cptui_tools_sections', 'cptui_render_tools' );
504
505 /**
506 * Handle the import of transferred post types and taxonomies.
507 *
508 * @since 1.5.0
509 */
510 function cptui_do_import_types_taxes() {
511 // phpcs:ignore.
512 if ( ! empty( $_POST ) && // phpcs:ignore WordPress.Security.NonceVerification
513 ( ! empty( $_POST['cptui_post_import'] ) && isset( $_POST['cptui_post_import'] ) ) || // phpcs:ignore WordPress.Security.NonceVerification
514 ( ! empty( $_POST['cptui_tax_import'] ) && isset( $_POST['cptui_tax_import'] ) ) // phpcs:ignore WordPress.Security.NonceVerification
515 ) {
516 $data = [];
517 $decoded_post_data = null;
518 $decoded_tax_data = null;
519 if ( ! empty( $_POST['cptui_post_import'] ) ) { // phpcs:ignore.
520 $decoded_post_data = json_decode( stripslashes_deep( trim( $_POST['cptui_post_import'] ) ), true ); // phpcs:ignore.
521 }
522
523 if ( ! empty( $_POST['cptui_tax_import'] ) ) { // phpcs:ignore.
524 $decoded_tax_data = json_decode( stripslashes_deep( trim( $_POST['cptui_tax_import'] ) ), true ); // phpcs:ignore.
525 }
526
527 if (
528 empty( $decoded_post_data ) &&
529 empty( $decoded_tax_data ) &&
530 (
531 ! empty( $_POST['cptui_post_import'] ) && '{""}' !== stripslashes_deep( trim( $_POST['cptui_post_import'] ) ) // phpcs:ignore.
532 ) &&
533 (
534 ! empty( $_POST['cptui_tax_import'] ) && '{""}' !== stripslashes_deep( trim( $_POST['cptui_tax_import'] ) ) // phpcs:ignore.
535 )
536 ) {
537 return;
538 }
539 if ( null !== $decoded_post_data ) {
540 $data['cptui_post_import'] = $decoded_post_data;
541 }
542 if ( null !== $decoded_tax_data ) {
543 $data['cptui_tax_import'] = $decoded_tax_data;
544 }
545 if ( ! empty( $_POST['cptui_post_import'] ) && '{""}' === stripslashes_deep( trim( $_POST['cptui_post_import'] ) ) ) { // phpcs:ignore.
546 $data['delete'] = 'type_true';
547 }
548 if ( ! empty( $_POST['cptui_tax_import'] ) && '{""}' === stripslashes_deep( trim( $_POST['cptui_tax_import'] ) ) ) { // phpcs:ignore.
549 $data['delete'] = 'tax_true';
550 }
551 $success = cptui_import_types_taxes_settings( $data );
552 add_action( 'admin_notices', "cptui_{$success}_admin_notice" );
553 }
554 }
555 add_action( 'init', 'cptui_do_import_types_taxes', 8 );
556