' . sprintf(
+ /* translators: %s: Link to manage taxonomies section */
+ esc_html__( 'No taxonomies registered for display. Visit %s to get started.', 'custom-post-type-ui' ),
+ sprintf(
+ '%s',
+ esc_attr( admin_url( 'admin.php?page=cptui_manage_taxonomies' ) ),
+ esc_html__( 'Add/Edit Taxonomies', 'custom-post-type-ui' )
+ )
+ ) . '
';
+}
+add_action( 'cptui_no_taxonomies_listing', 'cptui_no_taxonomies_to_list' );
diff --git a/wp-content/plugins/custom-post-type-ui/inc/post-types.php b/wp-content/plugins/custom-post-type-ui/inc/post-types.php
new file mode 100644
index 0000000..22b4b5c
--- /dev/null
+++ b/wp-content/plugins/custom-post-type-ui/inc/post-types.php
@@ -0,0 +1,2658 @@
+ true ] );
+ $public = get_post_types(
+ [
+ '_builtin' => false,
+ 'public' => true,
+ ]
+ );
+ $private = get_post_types(
+ [
+ '_builtin' => false,
+ 'public' => false,
+ ]
+ );
+ $registered_post_types = array_merge( $core, $public, $private );
+
+ wp_localize_script(
+ 'cptui',
+ 'cptui_type_data',
+ [
+ 'confirm' => esc_html__( 'Are you sure you want to delete this? Deleting will NOT remove created content.', 'custom-post-type-ui' ),
+ 'existing_post_types' => $registered_post_types,
+ ]
+ );
+}
+add_action( 'admin_enqueue_scripts', 'cptui_post_type_enqueue_scripts' );
+
+/**
+ * Register our tabs for the Post Type screen.
+ *
+ * @since 1.3.0
+ *
+ * @internal
+ *
+ * @param array $tabs Array of tabs to display. Optional.
+ * @param string $current_page Current page being shown. Optional. Default empty string.
+ * @return array Amended array of tabs to show.
+ */
+function cptui_post_type_tabs( $tabs = [], $current_page = '' ) {
+
+ if ( 'post_types' === $current_page ) {
+ $post_types = cptui_get_post_type_data();
+ $classes = [ 'nav-tab' ];
+
+ $tabs['page_title'] = get_admin_page_title();
+ $tabs['tabs'] = [];
+ // Start out with our basic "Add new" tab.
+ $tabs['tabs']['add'] = [
+ 'text' => esc_html__( 'Add New Post Type', 'custom-post-type-ui' ),
+ 'classes' => $classes,
+ 'url' => cptui_admin_url( 'admin.php?page=cptui_manage_' . $current_page ),
+ 'aria-selected' => 'false',
+ ];
+
+ $action = cptui_get_current_action();
+ if ( empty( $action ) ) {
+ $tabs['tabs']['add']['classes'][] = 'nav-tab-active';
+ $tabs['tabs']['add']['aria-selected'] = 'true';
+ }
+
+ if ( ! empty( $post_types ) ) {
+
+ if ( ! empty( $action ) ) {
+ $classes[] = 'nav-tab-active';
+ }
+ $tabs['tabs']['edit'] = [
+ 'text' => esc_html__( 'Edit Post Types', 'custom-post-type-ui' ),
+ 'classes' => $classes,
+ 'url' => esc_url( add_query_arg( [ 'action' => 'edit' ], cptui_admin_url( 'admin.php?page=cptui_manage_' . $current_page ) ) ),
+ 'aria-selected' => ! empty( $action ) ? 'true' : 'false',
+ ];
+
+ $tabs['tabs']['view'] = [
+ 'text' => esc_html__( 'View Post Types', 'custom-post-type-ui' ),
+ 'classes' => [ 'nav-tab' ], // Prevent notices.
+ 'url' => esc_url( cptui_admin_url( 'admin.php?page=cptui_listings#post-types' ) ),
+ 'aria-selected' => 'false',
+ ];
+
+ $tabs['tabs']['export'] = [
+ 'text' => esc_html__( 'Import/Export Post Types', 'custom-post-type-ui' ),
+ 'classes' => [ 'nav-tab' ], // Prevent notices.
+ 'url' => esc_url( cptui_admin_url( 'admin.php?page=cptui_tools' ) ),
+ 'aria-selected' => 'false',
+ ];
+ }
+ }
+
+ return $tabs;
+}
+add_filter( 'cptui_get_tabs', 'cptui_post_type_tabs', 10, 2 );
+
+/**
+ * Create our settings page output.
+ *
+ * @since 1.0.0
+ *
+ * @internal
+ */
+function cptui_manage_post_types() {
+
+ $tab = ( ! empty( $_GET ) && ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] ) ? 'edit' : 'new'; // phpcs:ignore.
+ $tab_class = 'cptui-' . $tab;
+ $current = null;
+ ?>
+
+
+
+
+
+
+
+
';
+
+ /**
+ * Fires after the display of the site information.
+ * @since 1.3.0
+ */
+ do_action( 'cptui_after_site_info' );
+}
diff --git a/wp-content/plugins/custom-post-type-ui/inc/tools-sections/tools-get-code.php b/wp-content/plugins/custom-post-type-ui/inc/tools-sections/tools-get-code.php
new file mode 100644
index 0000000..d7fdd79
--- /dev/null
+++ b/wp-content/plugins/custom-post-type-ui/inc/tools-sections/tools-get-code.php
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+function () {
+
+}
+
+add_action( 'init', '' );
+ "' . $post_type['name'] . '",';
+ if ( ! empty( $post_type['rewrite_slug'] ) ) {
+ $rewrite_slug = ' "slug" => "' . $post_type['rewrite_slug'] . '",';
+ }
+
+ $withfront = disp_boolean( $post_type['rewrite_withfront'] );
+ if ( ! empty( $withfront ) ) {
+ $rewrite_withfront = ' "with_front" => ' . $withfront . ' ';
+ }
+
+ if ( ! empty( $post_type['rewrite_slug'] ) || ! empty( $post_type['rewrite_withfront'] ) ) {
+ $rewrite_start = '[';
+ $rewrite_end = ']';
+
+ $rewrite = $rewrite_start . $rewrite_slug . $rewrite_withfront . $rewrite_end;
+ }
+ } else {
+ $rewrite = disp_boolean( $post_type['rewrite'] );
+ }
+ $has_archive = get_disp_boolean( $post_type['has_archive'] );
+ if ( false !== $has_archive ) {
+ $has_archive = disp_boolean( $post_type['has_archive'] );
+ if ( ! empty( $post_type['has_archive_string'] ) ) {
+ $has_archive = '"' . $post_type['has_archive_string'] . '"';
+ }
+ } else {
+ $has_archive = disp_boolean( $post_type['has_archive'] );
+ }
+
+ $supports = '';
+ // Do a little bit of php work to get these into strings.
+ if ( ! empty( $post_type['supports'] ) && is_array( $post_type['supports'] ) ) {
+ $supports = '[ "' . implode( '", "', $post_type['supports'] ) . '" ]';
+ }
+
+ if ( in_array( 'none', $post_type['supports'], true ) ) {
+ $supports = 'false';
+ }
+
+ $taxonomies = '';
+ if ( ! empty( $post_type['taxonomies'] ) && is_array( $post_type['taxonomies'] ) ) {
+ $taxonomies = '[ "' . implode( '", "', $post_type['taxonomies'] ) . '" ]';
+ }
+
+ if ( in_array( $post_type['query_var'], [ 'true', 'false', '0', '1' ], true ) ) {
+ $post_type['query_var'] = disp_boolean( $post_type['query_var'] );
+ }
+ if ( ! empty( $post_type['query_var_slug'] ) ) {
+ $post_type['query_var'] = '"' . $post_type['query_var_slug'] . '"';
+ }
+
+ if ( empty( $post_type['show_in_rest'] ) ) {
+ $post_type['show_in_rest'] = 'false';
+ }
+ $rest_controller_class = ! empty( $post_type['rest_controller_class'] ) ? $post_type['rest_controller_class'] : 'WP_REST_Posts_Controller';
+ $rest_namespace = ! empty( $post_type['rest_namespace'] ) ? $post_type['rest_namespace'] : 'wp/v2';
+
+ $show_in_menu = get_disp_boolean( $post_type['show_in_menu'] );
+ if ( false !== $show_in_menu ) {
+ $show_in_menu = disp_boolean( $post_type['show_in_menu'] );
+ if ( ! empty( $post_type['show_in_menu_string'] ) ) {
+ $show_in_menu = '"' . $post_type['show_in_menu_string'] . '"';
+ }
+ } else {
+ $show_in_menu = disp_boolean( $post_type['show_in_menu'] );
+ }
+
+ $delete_with_user = 'false';
+ if ( isset( $post_type['delete_with_user'] ) ) {
+ $delete_with_user = disp_boolean( $post_type['delete_with_user'] );
+ }
+
+ $can_export = 'true';
+ if ( isset( $post_type['can_export'] ) ) {
+ $can_export = disp_boolean( $post_type['can_export'] );
+ }
+
+ $public = isset( $post_type['public'] ) ? disp_boolean( $post_type['public'] ) : 'true';
+ $show_in_nav_menus = ( ! empty( $post_type['show_in_nav_menus'] ) && false !== get_disp_boolean( $post_type['show_in_nav_menus'] ) ) ? 'true' : 'false';
+ if ( empty( $post_type['show_in_nav_menus'] ) ) {
+ $show_in_nav_menus = $public;
+ }
+
+ $capability_type = '"post"';
+ if ( ! empty( $post_type['capability_type'] ) ) {
+ $capability_type = '"' . $post_type['capability_type'] . '"';
+ if ( false !== strpos( $post_type['capability_type'], ',' ) ) {
+ $caps = array_map( 'trim', explode( ',', $post_type['capability_type'] ) );
+ if ( count( $caps ) > 2 ) {
+ $caps = array_slice( $caps, 0, 2 );
+ }
+ $capability_type = '[ "' . $caps[0] . '", "' . $caps[1] . '" ]';
+ }
+ }
+
+ $post_type['description'] = addslashes( $post_type['description'] );
+
+ $my_theme = wp_get_theme();
+ $textdomain = $my_theme->get( 'TextDomain' );
+ if ( empty( $textdomain ) ) {
+ $textdomain = 'custom-post-type-ui';
+ }
+ ?>
+
+ /**
+ * Post Type: .
+ */
+
+ $labels = [
+ "name" => esc_html__( "", "" ),
+ "singular_name" => esc_html__( "", "" ),
+ $label ) {
+ if ( ! empty( $label ) ) {
+ if ( 'parent' === $key && ! array_key_exists( 'parent_item_colon', $post_type['labels'] ) ) {
+ // Fix for incorrect label key. See #439.
+ echo "\t\t" . '"' . 'parent_item_colon' . '" => esc_html__( "' . esc_html( $label ) . '", "' . esc_html( $textdomain ) . '" ),' . "\n";
+ } else {
+ echo "\t\t" . '"' . esc_html( $key ) . '" => esc_html__( "' . esc_html( $label ) . '", "' . esc_html( $textdomain ) . '" ),' . "\n";
+ }
+ }
+ }
+?>
+ ];
+
+ $args = [
+ "label" => esc_html__( "", "" ),
+ "labels" => $labels,
+ "description" => "",
+ "public" => ,
+ "publicly_queryable" => ,
+ "show_ui" => ,
+ "show_in_rest" => ,
+ "rest_base" => "",
+ "rest_controller_class" => "",
+ "rest_namespace" => "",
+ "has_archive" => ,
+ "show_in_menu" => ,
+ "show_in_nav_menus" => ,
+ "delete_with_user" => ,
+ "exclude_from_search" => ,
+ "capability_type" => ,
+ "map_meta_cap" => ,
+ "hierarchical" => ,
+ "can_export" => ,
+ "rewrite" => ,
+ "query_var" => ,
+
+ "menu_position" => ,
+
+
+ "menu_icon" => "",
+
+
+ "register_meta_box_cb" => "",
+
+
+ "supports" => ,
+
+
+ "taxonomies" => ,
+
+
+ "yarpp_support" => ,
+
+
+ "show_in_graphql" => ,
+ "graphql_single_name" => "",
+ "graphql_plural_name" => "",
+
+ "show_in_graphql" => ,
+
+ ];
+
+ register_post_type( "", $args );
+
+function () {
+
+}
+add_action( 'init', '' );
+ \'' . $taxonomy['name'] . '\',';
+ if ( ! empty( $taxonomy['rewrite_slug'] ) ) {
+ $rewrite_slug = ' \'slug\' => \'' . $taxonomy['rewrite_slug'] . '\',';
+ }
+
+ $rewrite_withfront = '';
+ $withfront = disp_boolean( $taxonomy['rewrite_withfront'] );
+ if ( ! empty( $withfront ) ) {
+ $rewrite_withfront = ' \'with_front\' => ' . $withfront . ', ';
+ }
+
+ $hierarchical = ! empty( $taxonomy['rewrite_hierarchical'] ) ? disp_boolean( $taxonomy['rewrite_hierarchical'] ) : '';
+ $rewrite_hierarchcial = '';
+ if ( ! empty( $hierarchical ) ) {
+ $rewrite_hierarchcial = ' \'hierarchical\' => ' . $hierarchical . ', ';
+ }
+
+ if ( ! empty( $taxonomy['rewrite_slug'] ) || false !== disp_boolean( $taxonomy['rewrite_withfront'] ) ) {
+ $rewrite_start = '[';
+ $rewrite_end = ']';
+
+ $rewrite = $rewrite_start . $rewrite_slug . $rewrite_withfront . $rewrite_hierarchcial . $rewrite_end;
+ }
+ } else {
+ $rewrite = disp_boolean( $taxonomy['rewrite'] );
+ }
+ $public = isset( $taxonomy['public'] ) ? disp_boolean( $taxonomy['public'] ) : 'true';
+ $publicly_queryable = isset( $taxonomy['publicly_queryable'] ) ? disp_boolean( $taxonomy['publicly_queryable'] ) : disp_boolean( $taxonomy['public'] );
+ $show_in_quick_edit = isset( $taxonomy['show_in_quick_edit'] ) ? disp_boolean( $taxonomy['show_in_quick_edit'] ) : disp_boolean( $taxonomy['show_ui'] );
+ $show_tagcloud = isset( $taxonomy['show_tagcloud'] ) ? disp_boolean( $taxonomy['show_tagcloud'] ) : disp_boolean( $taxonomy['show_ui'] );
+
+ $show_in_menu = ( ! empty( $taxonomy['show_in_menu'] ) && false !== get_disp_boolean( $taxonomy['show_in_menu'] ) ) ? 'true' : 'false';
+ if ( empty( $taxonomy['show_in_menu'] ) ) {
+ $show_in_menu = disp_boolean( $taxonomy['show_ui'] );
+ }
+
+ $show_in_nav_menus = ( ! empty( $taxonomy['show_in_nav_menus'] ) && false !== get_disp_boolean( $taxonomy['show_in_nav_menus'] ) ) ? 'true' : 'false';
+ if ( empty( $taxonomy['show_in_nav_menus'] ) ) {
+ $show_in_nav_menus = $public;
+ }
+
+ $show_in_rest = ( ! empty( $taxonomy['show_in_rest'] ) && false !== get_disp_boolean( $taxonomy['show_in_rest'] ) ) ? 'true' : 'false';
+ $rest_base = ! empty( $taxonomy['rest_base'] ) ? $taxonomy['rest_base'] : $taxonomy['name'];
+ $rest_controller_class = ! empty( $taxonomy['rest_controller_class'] ) ? $taxonomy['rest_controller_class'] : 'WP_REST_Terms_Controller';
+ $rest_namespace = ! empty( $taxonomy['rest_namespace'] ) ? $taxonomy['rest_namespace'] : 'wp/v2';
+ $sort = ( ! empty( $taxonomy['sort'] ) && false !== get_disp_boolean( $taxonomy['sort'] ) ) ? 'true' : 'false';
+
+ if ( ! empty( $taxonomy['meta_box_cb'] ) ) {
+ $meta_box_cb = ( false !== get_disp_boolean( $taxonomy['meta_box_cb'] ) ) ? '"' . $taxonomy['meta_box_cb'] . '"' : 'false';
+ }
+
+ $default_term = '';
+ if ( ! empty( $taxonomy['default_term'] ) ) {
+ $term_parts = explode( ',', $taxonomy['default_term'] );
+ $default_term_start = '[';
+ $default_term_end = ']';
+ if ( ! empty( $term_parts[0] ) ) {
+ $default_term .= "'name' => '" . trim( $term_parts[0] ) . "'";
+ }
+ if ( ! empty( $term_parts[1] ) ) {
+ $default_term .= ", 'slug' => '" . trim( $term_parts[1] ) . "'";
+ }
+ if ( ! empty( $term_parts[2] ) ) {
+ $default_term .= ", 'description' => '" . trim( $term_parts[2] ) . "'";
+ }
+
+ $default_term = $default_term_start . $default_term . $default_term_end;
+ }
+
+ $my_theme = wp_get_theme();
+ $textdomain = $my_theme->get( 'TextDomain' );
+ if ( empty( $textdomain ) ) {
+ $textdomain = 'custom-post-type-ui';
+ }
+ ?>
+
+ /**
+ * Taxonomy: .
+ */
+
+ $labels = [
+ "name" => esc_html__( "", "" ),
+ "singular_name" => esc_html__( "", "" ),
+ $label ) {
+ if ( ! empty( $label ) ) {
+ echo "\t\t" . '"' . esc_html( $key ) . '" => esc_html__( "' . esc_html( $label ) . '", "' . esc_html( $textdomain ) . '" ),' . "\n";
+ }
+}
+?>
+ ];
+
+
+
+ $args = [
+ "label" => esc_html__( "", "" ),
+ "labels" => $labels,
+ "public" => ,
+ "publicly_queryable" => ,
+ "hierarchical" => ,
+ "show_ui" => ,
+ "show_in_menu" => ,
+ "show_in_nav_menus" => ,
+ "query_var" => ,
+ "rewrite" => ,
+ "show_admin_column" => ,
+ "show_in_rest" => ,
+ "show_tagcloud" => ,
+ "rest_base" => "",
+ "rest_controller_class" => "",
+ "rest_namespace" => "",
+ "show_in_quick_edit" => ,
+ "sort" => ,
+
+ "show_in_graphql" => ,
+ "graphql_single_name" => "",
+ "graphql_plural_name" => "",
+
+ "show_in_graphql" => ,
+
+
+ "meta_box_cb" => ,
+
+
+ "default_term" => ,
+
+ ];
+ register_taxonomy( "", , $args );
+ esc_html__( 'Post types', 'custom-post-type-ui' ),
+ 'classes' => $classes,
+ 'url' => cptui_admin_url( 'admin.php?page=cptui_' . $current_page ),
+ 'aria-selected' => 'false',
+ ];
+
+ $tabs['tabs']['taxonomies'] = [
+ 'text' => esc_html__( 'Taxonomies', 'custom-post-type-ui' ),
+ 'classes' => $classes,
+ 'url' => esc_url( add_query_arg( [ 'action' => 'taxonomies' ], cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
+ 'aria-selected' => 'false',
+ ];
+
+ $tabs['tabs']['get_code'] = [
+ 'text' => esc_html__( 'Get code', 'custom-post-type-ui' ),
+ 'classes' => $classes,
+ 'url' => esc_url( add_query_arg( [ 'action' => 'get_code' ], cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
+ 'aria-selected' => 'false',
+ ];
+
+ $tabs['tabs']['debuginfo'] = [
+ 'text' => esc_html__( 'Debug info', 'custom-post-type-ui' ),
+ 'classes' => $classes,
+ 'url' => esc_url( add_query_arg( [ 'action' => 'debuginfo' ], cptui_admin_url( 'admin.php?page=cptui_' . $current_page ) ) ),
+ 'aria-selected' => 'false',
+ ];
+
+ $active_class = 'nav-tab-active';
+ $action = cptui_get_current_action();
+ if ( ! empty( $action ) ) {
+ if ( 'taxonomies' === $action ) {
+ $tabs['tabs']['taxonomies']['classes'][] = $active_class;
+ $tabs['tabs']['taxonomies']['aria-selected'] = 'true';
+ } elseif ( 'get_code' === $action ) {
+ $tabs['tabs']['get_code']['classes'][] = $active_class;
+ $tabs['tabs']['get_code']['aria-selected'] = 'true';
+ } elseif ( 'debuginfo' === $action ) {
+ $tabs['tabs']['debuginfo']['classes'][] = $active_class;
+ $tabs['tabs']['debuginfo']['aria-selected'] = 'true';
+ }
+ } else {
+ $tabs['tabs']['post_types']['classes'][] = $active_class;
+ $tabs['tabs']['post_types']['aria-selected'] = 'true';
+ }
+
+ /**
+ * Filters the tabs being added for the tools area.
+ *
+ * @since 1.5.0
+ *
+ * @param array $tabs Array of tabs to show.
+ * @param string $action Current tab being shown.
+ * @param string $active_class Class to use to mark the tab active.
+ */
+ $tabs = apply_filters( 'cptui_tools_tabs', $tabs, $action, $active_class );
+ }
+
+ return $tabs;
+}
+add_filter( 'cptui_get_tabs', 'cptui_tools_tabs', 10, 2 );
+
+/**
+ * Create our settings page output.
+ *
+ * @since 1.0.0
+ *
+ * @internal
+ */
+function cptui_tools() {
+
+ $tab = 'post_types';
+ if ( ! empty( $_GET ) ) { // phpcs:ignore WordPress.Security.NonceVerification
+ if ( ! empty( $_GET['action'] ) && 'taxonomies' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
+ $tab = 'taxonomies';
+ } elseif ( ! empty( $_GET['action'] ) && 'get_code' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
+ $tab = 'get_code';
+ } elseif ( ! empty( $_GET['action'] ) && 'debuginfo' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
+ $tab = 'debuginfo';
+ }
+ }
+
+ echo '
';
+ /**
+ * Fires immediately after wrap div started on all of the cptui admin pages.
+ *
+ * @since 1.14.0
+ */
+ do_action( 'cptui_inside_wrap' );
+
+ /**
+ * Fires right inside the wrap div for the import/export pages.
+ *
+ * @since 1.3.0
+ *
+ * @deprecated 1.5.0
+ */
+ do_action_deprecated( 'cptui_inside_importexport_wrap', [], '1.5.0', 'cptui_inside_tools_wrap' );
+
+ /**
+ * Fires right inside the wrap div for the tools pages.
+ *
+ * @since 1.5.0
+ */
+ do_action( 'cptui_inside_tools_wrap' );
+
+ // Create our tabs.
+ cptui_settings_tab_menu( 'tools' );
+
+ /**
+ * Fires inside the markup for the import/export section.
+ *
+ * Allows for more modular control and adding more sections more easily.
+ *
+ * @since 1.2.0
+ *
+ * @deprecated 1.5.0
+ *
+ * @param string $tab Current tab being displayed.
+ */
+ do_action_deprecated( 'cptui_import_export_sections', [ $tab ], '1.5.0', 'cptui_tools_sections' );
+
+ /**
+ * Fires inside the markup for the tools section.
+ *
+ * Allows for more modular control and adding more sections more easily.
+ *
+ * @since 1.5.0
+ *
+ * @param string $tab Current tab being displayed.
+ */
+ do_action( 'cptui_tools_sections', $tab );
+
+ echo '
';
+}
+
+/**
+ * Import the posted JSON data from a separate export.
+ *
+ * @since 1.0.0
+ *
+ * @internal
+ *
+ * @param array $postdata $_POST data as json. Optional.
+ * @return mixed false on nothing to do, otherwise void.
+ */
+function cptui_import_types_taxes_settings( $postdata = [] ) {
+ if ( ! isset( $postdata['cptui_post_import'] ) && ! isset( $postdata['cptui_tax_import'] ) && ! array_key_exists( 'delete', $postdata ) ) {
+ return false;
+ }
+
+ $doing_wp_cli = ( defined( 'WP_CLI' ) && WP_CLI );
+ if ( ! $doing_wp_cli && ! check_admin_referer( 'cptui_typetaximport_nonce_action', 'cptui_typetaximport_nonce_field' ) ) {
+ return 'nonce_fail';
+ }
+
+ $status = 'import_fail';
+ $success = false;
+
+ /**
+ * Filters the post type data to import.
+ *
+ * Allows third parties to provide their own data dump and import instead of going through our UI.
+ *
+ * @since 1.2.0
+ *
+ * @param bool $value Default to no data.
+ */
+ $third_party_post_type_data = apply_filters( 'cptui_third_party_post_type_import', false );
+
+ /**
+ * Filters the taxonomy data to import.
+ *
+ * Allows third parties to provide their own data dump and import instead of going through our UI.
+ *
+ * @since 1.2.0
+ *
+ * @param bool $value Default to no data.
+ */
+ $third_party_taxonomy_data = apply_filters( 'cptui_third_party_taxonomy_import', false );
+
+ if ( false !== $third_party_post_type_data ) {
+ $postdata['cptui_post_import'] = $third_party_post_type_data;
+ }
+
+ if ( false !== $third_party_taxonomy_data ) {
+ $postdata['cptui_tax_import'] = $third_party_taxonomy_data;
+ }
+
+ if ( ! empty( $postdata['cptui_post_import'] ) || ( isset( $postdata['delete'] ) && 'type_true' === $postdata['delete'] ) ) {
+ $settings = null;
+ if ( ! empty( $postdata['cptui_post_import'] ) ) {
+ $settings = $postdata['cptui_post_import'];
+ }
+
+ // Add support to delete settings outright, without accessing database.
+ // Doing double check to protect.
+ if ( null === $settings && ( isset( $postdata['delete'] ) && 'type_true' === $postdata['delete'] ) ) {
+
+ /**
+ * Filters whether or not 3rd party options were deleted successfully within post type import.
+ *
+ * @since 1.3.0
+ *
+ * @param bool $value Whether or not someone else deleted successfully. Default false.
+ * @param array $postdata Post type data.
+ */
+ if ( false === ( $success = apply_filters( 'cptui_post_type_import_delete_save', false, $postdata ) ) ) { // phpcs:ignore.
+ $success = delete_option( 'cptui_post_types' );
+ }
+ }
+
+ if ( $settings ) {
+ if ( false !== cptui_get_post_type_data() ) {
+ /** This filter is documented in /inc/import-export.php */
+ if ( false === ( $success = apply_filters( 'cptui_post_type_import_delete_save', false, $postdata ) ) ) { // phpcs:ignore.
+ delete_option( 'cptui_post_types' );
+ }
+ }
+
+ /**
+ * Filters whether or not 3rd party options were updated successfully within the post type import.
+ *
+ * @since 1.3.0
+ *
+ * @param bool $value Whether or not someone else updated successfully. Default false.
+ * @param array $postdata Post type data.
+ */
+ if ( false === ( $success = apply_filters( 'cptui_post_type_import_update_save', false, $postdata ) ) ) { // phpcs:ignore.
+ $success = update_option( 'cptui_post_types', $settings );
+ }
+ }
+ // Used to help flush rewrite rules on init.
+ set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 );
+
+ if ( $success ) {
+ $status = 'import_success';
+ }
+ } elseif ( ! empty( $postdata['cptui_tax_import'] ) || ( isset( $postdata['delete'] ) && 'tax_true' === $postdata['delete'] ) ) {
+ $settings = null;
+
+ if ( ! empty( $postdata['cptui_tax_import'] ) ) {
+ $settings = $postdata['cptui_tax_import'];
+ }
+ // Add support to delete settings outright, without accessing database.
+ // Doing double check to protect.
+ if ( null === $settings && ( isset( $postdata['delete'] ) && 'tax_true' === $postdata['delete'] ) ) {
+
+ /**
+ * Filters whether or not 3rd party options were deleted successfully within taxonomy import.
+ *
+ * @since 1.3.0
+ *
+ * @param bool $value Whether or not someone else deleted successfully. Default false.
+ * @param array $postdata Taxonomy data
+ */
+ if ( false === ( $success = apply_filters( 'cptui_taxonomy_import_delete_save', false, $postdata ) ) ) { // phpcs:ignore.
+ $success = delete_option( 'cptui_taxonomies' );
+ }
+ }
+
+ if ( $settings ) {
+ if ( false !== cptui_get_taxonomy_data() ) {
+ /** This filter is documented in /inc/import-export.php */
+ if ( false === ( $success = apply_filters( 'cptui_taxonomy_import_delete_save', false, $postdata ) ) ) { // phpcs:ignore.
+ delete_option( 'cptui_taxonomies' );
+ }
+ }
+ /**
+ * Filters whether or not 3rd party options were updated successfully within the taxonomy import.
+ *
+ * @since 1.3.0
+ *
+ * @param bool $value Whether or not someone else updated successfully. Default false.
+ * @param array $postdata Taxonomy data.
+ */
+ if ( false === ( $success = apply_filters( 'cptui_taxonomy_import_update_save', false, $postdata ) ) ) { // phpcs:ignore.
+ $success = update_option( 'cptui_taxonomies', $settings );
+ }
+ }
+ // Used to help flush rewrite rules on init.
+ set_transient( 'cptui_flush_rewrite_rules', 'true', 5 * 60 );
+ if ( $success ) {
+ $status = 'import_success';
+ }
+ }
+
+ return $status;
+}
+
+/**
+ * Content for the Post Types/Taxonomies Tools tab.
+ *
+ * @since 1.2.0
+ *
+ * @internal
+ */
+function cptui_render_posttypes_taxonomies_section() {
+ ?>
+
+
+
+
+ %s: %s',
+ esc_html__( 'NOTE', 'custom-post-type-ui' ),
+ esc_html__( 'This will not export the associated posts or taxonomy terms, just the settings.', 'custom-post-type-ui' )
+ );
+ ?>
+
+
+ ' . esc_html__( 'About', 'custom-post-type-ui' ) . '',
+ '
' . esc_html__( 'Help', 'custom-post-type-ui' ) . '',
+ ),
+ $links
+ );
+}
+add_filter( 'plugin_action_links_' . plugin_basename( dirname( __DIR__ ) ) . '/custom-post-type-ui.php', 'cptui_edit_plugin_list_links' );
+
+/**
+ * Returns SVG icon for custom menu icon
+ *
+ * @since 1.2.0
+ *
+ * @return string
+ */
+function cptui_menu_icon() {
+ return 'dashicons-forms';
+}
+
+/**
+ * Return boolean status depending on passed in value.
+ *
+ * @since 0.5.0
+ *
+ * @param mixed $bool_text text to compare to typical boolean values.
+ * @return bool Which bool value the passed in value was.
+ */
+function get_disp_boolean( $bool_text ) {
+ $bool_text = (string) $bool_text;
+ if ( empty( $bool_text ) || '0' === $bool_text || 'false' === $bool_text ) {
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Return string versions of boolean values.
+ *
+ * @since 0.1.0
+ *
+ * @param string $bool_text String boolean value.
+ * @return string standardized boolean text.
+ */
+function disp_boolean( $bool_text ) {
+ $bool_text = (string) $bool_text;
+ if ( empty( $bool_text ) || '0' === $bool_text || 'false' === $bool_text ) {
+ return 'false';
+ }
+
+ return 'true';
+}
+
+/**
+ * Display footer links and plugin credits.
+ *
+ * @since 0.3.0
+ *
+ * @internal
+ *
+ * @param string $original Original footer content. Optional. Default empty string.
+ * @return string $value HTML for footer.
+ */
+function cptui_footer( $original = '' ) {
+
+ $screen = get_current_screen();
+
+ if ( ! is_object( $screen ) || 'cptui_main_menu' !== $screen->parent_base ) {
+ return $original;
+ }
+
+ return sprintf(
+ // translators: Placeholder will hold the name of the plugin, version of the plugin and a link to WebdevStudios.
+ esc_attr__( '%1$s version %2$s by %3$s', 'custom-post-type-ui' ),
+ esc_attr__( 'Custom Post Type UI', 'custom-post-type-ui' ),
+ CPTUI_VERSION,
+ '
WebDevStudios'
+ ) . ' - ' .
+ sprintf(
+ // translators: Placeholders are just for HTML markup that doesn't need translated.
+ '
%s',
+ esc_attr__( 'Support forums', 'custom-post-type-ui' )
+ ) . ' - ' .
+ sprintf(
+ // translators: Placeholders are just for HTML markup that doesn't need translated.
+ '
%s',
+ sprintf(
+ // translators: Placeholder will hold `
` tag for CPTUI.
+ esc_attr__( 'Review %s', 'custom-post-type-ui' ),
+ sprintf(
+ // translators: Placeholders are just for HTML markup that doesn't need translated.
+ '%s',
+ esc_attr__( 'Custom Post Type UI', 'custom-post-type-ui' ),
+ 'CPTUI'
+ )
+ )
+ ) . ' - ' .
+ esc_attr__( 'Follow on X:', 'custom-post-type-ui' ) .
+ sprintf(
+ // translators: Placeholders are just for HTML markup that doesn't need translated.
+ ' %s',
+ 'WebDevStudios'
+ );
+}
+add_filter( 'admin_footer_text', 'cptui_footer' );
+
+/**
+ * Conditionally flushes rewrite rules if we have reason to.
+ *
+ * @since 1.3.0
+ */
+function cptui_flush_rewrite_rules() {
+
+ if ( wp_doing_ajax() ) {
+ return;
+ }
+
+ /*
+ * Wise men say that you should not do flush_rewrite_rules on init or admin_init. Due to the nature of our plugin
+ * and how new post types or taxonomies can suddenly be introduced, we need to...potentially. For this,
+ * we rely on a short lived transient. Only 5 minutes life span. If it exists, we do a soft flush before
+ * deleting the transient to prevent subsequent flushes. The only times the transient gets created, is if
+ * post types or taxonomies are created, updated, deleted, or imported. Any other time and this condition
+ * should not be met.
+ */
+ $flush_it = get_transient( 'cptui_flush_rewrite_rules' );
+ if ( 'true' === $flush_it ) {
+ flush_rewrite_rules( false );
+ // So we only run this once.
+ delete_transient( 'cptui_flush_rewrite_rules' );
+ }
+}
+add_action( 'admin_init', 'cptui_flush_rewrite_rules' );
+
+/**
+ * Return the current action being done within CPTUI context.
+ *
+ * @since 1.3.0
+ *
+ * @return string Current action being done by CPTUI
+ */
+function cptui_get_current_action() {
+ $current_action = '';
+ if ( ! empty( $_GET ) && isset( $_GET['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
+ $current_action .= esc_textarea( wp_unslash( $_GET['action'] ) ); // phpcs:ignore
+ }
+
+ return $current_action;
+}
+
+/**
+ * Return an array of all post type slugs from Custom Post Type UI.
+ *
+ * @since 1.3.0
+ *
+ * @return array CPTUI post type slugs.
+ */
+function cptui_get_post_type_slugs() {
+ $post_types = get_option( 'cptui_post_types' );
+ if ( ! empty( $post_types ) ) {
+ return array_keys( $post_types );
+ }
+ return [];
+}
+
+/**
+ * Return an array of all taxonomy slugs from Custom Post Type UI.
+ *
+ * @since 1.3.0
+ *
+ * @return array CPTUI taxonomy slugs.
+ */
+function cptui_get_taxonomy_slugs() {
+ $taxonomies = get_option( 'cptui_taxonomies' );
+ if ( ! empty( $taxonomies ) ) {
+ return array_keys( $taxonomies );
+ }
+ return [];
+}
+
+/**
+ * Return the appropriate admin URL depending on our context.
+ *
+ * @since 1.3.0
+ *
+ * @param string $path URL path.
+ * @return string
+ */
+function cptui_admin_url( $path ) {
+ if ( is_multisite() && is_network_admin() ) {
+ return network_admin_url( $path );
+ }
+
+ return admin_url( $path );
+}
+
+/**
+ * Construct action tag for ` ';
+
+ /**
+ * Filters the custom admin notice for CPTUI.
+ *
+ * @deprecated
+ *
+ * @param string $value Complete HTML output for notice.
+ * @param string $action Action whose message is being generated.
+ * @param string $message The message to be displayed.
+ * @param string $messagewrapstart Beginning wrap HTML.
+ * @param string $messagewrapend Ending wrap HTML.
+ *
+ * @since 1.0.0
+ */
+ $notice = apply_filters_deprecated(
+ 'cptui_admin_notice',
+ [ $messagewrapstart . $message . $messagewrapend, '', $message, $messagewrapstart, $messagewrapend ],
+ '1.18.3',
+ '',
+ esc_html__( 'No filter replacement. Deprecated', 'custom-post-type-ui' )
+ );
+
+ $type = $success ? 'success' : 'error';
+ if ( ! empty( $success_override_type ) ) {
+ $type = $success_override_type;
+ }
+
+ wp_admin_notice(
+ $message,
+ [
+ 'id' => 'cptui-message',
+ 'type' => $type,
+ 'dismissible' => true,
+ ]
+ );
+}
+
+/**
+ * Grab post type or taxonomy slug from $_POST global, if available.
+ *
+ * @since 1.4.0
+ *
+ * @internal
+ *
+ * @return string
+ */
+function cptui_get_object_from_post_global() {
+ if ( isset( $_POST['cpt_custom_post_type']['name'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
+ $type_item = filter_input( INPUT_POST, 'cpt_custom_post_type', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
+ if ( $type_item ) {
+ return sanitize_text_field( $type_item['name'] );
+ }
+ }
+
+ if ( isset( $_POST['cpt_custom_tax']['name'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
+ $tax_item = filter_input( INPUT_POST, 'cpt_custom_tax', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
+ if ( $tax_item ) {
+ return sanitize_text_field( $tax_item['name'] );
+ }
+ }
+
+ return esc_html__( 'Object', 'custom-post-type-ui' );
+}
+
+/**
+ * Successful add callback.
+ *
+ * @since 1.4.0
+ */
+function cptui_add_success_admin_notice() {
+ cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
+ sprintf(
+ /* translators: Placeholders are just for HTML markup that doesn't need translated */
+ esc_html__( '%s has been successfully added', 'custom-post-type-ui' ),
+ cptui_get_object_from_post_global()
+ )
+ );
+}
+
+/**
+ * Fail to add callback.
+ *
+ * @since 1.4.0
+ */
+function cptui_add_fail_admin_notice() {
+ cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
+ sprintf(
+ /* translators: Placeholders are just for HTML markup that doesn't need translated */
+ esc_html__( '%s has failed to be added', 'custom-post-type-ui' ),
+ cptui_get_object_from_post_global()
+ ),
+ false
+ );
+}
+
+/**
+ * Successful update callback.
+ *
+ * @since 1.4.0
+ */
+function cptui_update_success_admin_notice() {
+ cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
+ sprintf(
+ /* translators: Placeholders are just for HTML markup that doesn't need translated */
+ esc_html__( '%s has been successfully updated', 'custom-post-type-ui' ),
+ cptui_get_object_from_post_global()
+ )
+ );
+}
+
+/**
+ * Fail to update callback.
+ *
+ * @since 1.4.0
+ */
+function cptui_update_fail_admin_notice() {
+ cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
+ sprintf(
+ /* translators: Placeholders are just for HTML markup that doesn't need translated */
+ esc_html__( '%s has failed to be updated', 'custom-post-type-ui' ),
+ cptui_get_object_from_post_global()
+ ),
+ false
+ );
+}
+
+/**
+ * Successful delete callback.
+ *
+ * @since 1.4.0
+ */
+function cptui_delete_success_admin_notice() {
+ cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
+ sprintf(
+ /* translators: Placeholders are just for HTML markup that doesn't need translated */
+ esc_html__( '%s has been successfully deleted', 'custom-post-type-ui' ),
+ cptui_get_object_from_post_global()
+ )
+ );
+}
+
+/**
+ * Fail to delete callback.
+ *
+ * @since 1.4.0
+ */
+function cptui_delete_fail_admin_notice() {
+ cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
+ sprintf(
+ /* translators: Placeholders are just for HTML markup that doesn't need translated */
+ esc_html__( '%s has failed to be deleted', 'custom-post-type-ui' ),
+ cptui_get_object_from_post_global()
+ ),
+ false
+ );
+}
+
+/**
+ * Success to import callback.
+ *
+ * @since 1.5.0
+ */
+function cptui_import_success_admin_notice() {
+ cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
+ esc_html__( 'Successfully imported data.', 'custom-post-type-ui' )
+ );
+}
+
+/**
+ * Failure to import callback.
+ *
+ * @since 1.5.0
+ */
+function cptui_import_fail_admin_notice() {
+ cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
+ esc_html__( 'Invalid data provided', 'custom-post-type-ui' ),
+ false
+ );
+}
+
+/**
+ * Failure to verify nonce, callback
+ *
+ * @since 1.7.4
+ */
+function cptui_nonce_fail_admin_notice() {
+ cptui_admin_notices_helper( // phpcs:ignore WordPress.Security.EscapeOutput
+ esc_html__( 'Nonce failed verification', 'custom-post-type-ui' ),
+ false
+ );
+}
+
+/**
+ * Returns error message for if trying to register existing post type.
+ *
+ * @since 1.4.0
+ *
+ * @return string
+ */
+function cptui_slug_matches_post_type() {
+ return sprintf(
+ /* translators: Placeholders are just for HTML markup that doesn't need translated */
+ esc_html__( 'Please choose a different post type name. %s is already registered.', 'custom-post-type-ui' ),
+ cptui_get_object_from_post_global()
+ );
+}
+
+/**
+ * Returns error message for if trying to register existing taxonomy.
+ *
+ * @since 1.4.0
+ *
+ * @return string
+ */
+function cptui_slug_matches_taxonomy() {
+ return sprintf(
+ /* translators: Placeholders are just for HTML markup that doesn't need translated */
+ esc_html__( 'Please choose a different taxonomy name. %s is already registered.', 'custom-post-type-ui' ),
+ cptui_get_object_from_post_global()
+ );
+}
+
+/**
+ * Returns error message for if not providing a post type to associate taxonomy to.
+ *
+ * @since 1.6.0
+ *
+ * @return string
+ */
+function cptui_empty_cpt_on_taxonomy() {
+ return esc_html__( 'Please provide a post type to attach to.', 'custom-post-type-ui' );
+}
+
+/**
+ * Returns error message for if trying to register post type with matching page slug.
+ *
+ * @since 1.4.0
+ *
+ * @return string
+ */
+function cptui_slug_matches_page() {
+ $slug = cptui_get_object_from_post_global();
+ $matched_slug = get_page_by_path(
+ cptui_get_object_from_post_global()
+ );
+ if ( $matched_slug instanceof WP_Post ) {
+ $slug = sprintf(
+ /* translators: Placeholders are just for HTML markup that doesn't need translated */
+ '