Example #1
0
/**
 * Helper function to register the actual taxonomy.
 *
 * @param array $taxonomy Taxonomy array to register.
 *
 * @return null Result of register_taxonomy.
 */
function cptui_register_single_taxonomy($taxonomy = array())
{
    $labels = array('name' => $taxonomy['label'], 'singular_name' => $taxonomy['singular_label']);
    $preserved = cptui_get_preserved_keys('taxonomies');
    foreach ($taxonomy['labels'] as $key => $label) {
        if (!empty($label)) {
            $labels[$key] = $label;
        } elseif (empty($label) && in_array($key, $preserved)) {
            $labels[$key] = cptui_get_preserved_label('taxonomies', $key, $taxonomy['label'], $taxonomy['singular_label']);
        }
    }
    $rewrite = get_disp_boolean($taxonomy['rewrite']);
    if (false !== get_disp_boolean($taxonomy['rewrite'])) {
        $rewrite = array();
        $rewrite['slug'] = !empty($taxonomy['rewrite_slug']) ? $taxonomy['rewrite_slug'] : $taxonomy['name'];
        $rewrite['with_front'] = 'false' === disp_boolean($taxonomy['rewrite_withfront']) ? false : true;
        $rewrite['hierarchical'] = 'true' === disp_boolean($taxonomy['rewrite_hierarchical']) ? true : false;
    }
    if (in_array($taxonomy['query_var'], array('true', 'false', '0', '1'))) {
        $taxonomy['query_var'] = get_disp_boolean($taxonomy['query_var']);
    }
    if (true === $taxonomy['query_var'] && !empty($taxonomy['query_var_slug'])) {
        $taxonomy['query_var'] = $taxonomy['query_var_slug'];
    }
    $show_admin_column = !empty($taxonomy['show_admin_column']) && false !== get_disp_boolean($taxonomy['show_admin_column']) ? true : false;
    $args = array('labels' => $labels, 'label' => $taxonomy['label'], 'hierarchical' => get_disp_boolean($taxonomy['hierarchical']), 'show_ui' => get_disp_boolean($taxonomy['show_ui']), 'query_var' => $taxonomy['query_var'], 'rewrite' => $rewrite, 'show_admin_column' => $show_admin_column);
    $object_type = !empty($taxonomy['object_types']) ? $taxonomy['object_types'] : '';
    /**
     * Filters the arguments used for a taxonomy right before registering.
     *
     * @since 1.0.0
     *
     * @param array  $args Array of arguments to use for registering taxonomy.
     * @param string $value Taxonomy slug to be registered.
     */
    $args = apply_filters('cptui_pre_register_taxonomy', $args, $taxonomy['name']);
    return register_taxonomy($taxonomy['name'], $object_type, $args);
}
/**
 * Helper function to register the actual taxonomy.
 *
 * @since 1.0.0
 *
 * @internal
 *
 * @param array $taxonomy Taxonomy array to register.
 * @return null Result of register_taxonomy.
 */
function cptui_register_single_taxonomy($taxonomy = array())
{
    $labels = array('name' => $taxonomy['label'], 'singular_name' => $taxonomy['singular_label']);
    $description = '';
    if (!empty($taxonomy['description'])) {
        $description = $taxonomy['description'];
    }
    $preserved = cptui_get_preserved_keys('taxonomies');
    foreach ($taxonomy['labels'] as $key => $label) {
        if (!empty($label)) {
            $labels[$key] = $label;
        } elseif (empty($label) && in_array($key, $preserved)) {
            $labels[$key] = cptui_get_preserved_label('taxonomies', $key, $taxonomy['label'], $taxonomy['singular_label']);
        }
    }
    $rewrite = get_disp_boolean($taxonomy['rewrite']);
    if (false !== get_disp_boolean($taxonomy['rewrite'])) {
        $rewrite = array();
        $rewrite['slug'] = !empty($taxonomy['rewrite_slug']) ? $taxonomy['rewrite_slug'] : $taxonomy['name'];
        $rewrite['with_front'] = 'false' === disp_boolean($taxonomy['rewrite_withfront']) ? false : true;
        $rewrite['hierarchical'] = 'true' === disp_boolean($taxonomy['rewrite_hierarchical']) ? true : false;
    }
    if (in_array($taxonomy['query_var'], array('true', 'false', '0', '1'))) {
        $taxonomy['query_var'] = get_disp_boolean($taxonomy['query_var']);
    }
    if (true === $taxonomy['query_var'] && !empty($taxonomy['query_var_slug'])) {
        $taxonomy['query_var'] = $taxonomy['query_var_slug'];
    }
    $public = !empty($taxonomy['public']) && false === get_disp_boolean($taxonomy['public']) ? false : true;
    $show_admin_column = !empty($taxonomy['show_admin_column']) && false !== get_disp_boolean($taxonomy['show_admin_column']) ? true : false;
    $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 = get_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;
    $show_in_quick_edit = !empty($taxonomy['show_in_quick_edit']) && false !== get_disp_boolean($taxonomy['show_in_quick_edit']) ? true : false;
    $rest_base = null;
    if (!empty($taxonomy['rest_base'])) {
        $rest_base = $taxonomy['rest_base'];
    }
    $args = array('labels' => $labels, 'label' => $taxonomy['label'], 'description' => $description, 'public' => $public, 'hierarchical' => get_disp_boolean($taxonomy['hierarchical']), 'show_ui' => get_disp_boolean($taxonomy['show_ui']), 'show_in_menu' => $show_in_menu, 'show_in_nav_menus' => $show_in_nav_menus, 'query_var' => $taxonomy['query_var'], 'rewrite' => $rewrite, 'show_admin_column' => $show_admin_column, 'show_in_rest' => $show_in_rest, 'rest_base' => $rest_base, 'show_in_quick_edit' => $show_in_quick_edit);
    $object_type = !empty($taxonomy['object_types']) ? $taxonomy['object_types'] : '';
    /**
     * Filters the arguments used for a taxonomy right before registering.
     *
     * @since 1.0.0
     * @since 1.3.0 Added original passed in values array
     *
     * @param array  $args     Array of arguments to use for registering taxonomy.
     * @param string $value    Taxonomy slug to be registered.
     * @param array  $taxonomy Original passed in values for taxonomy.
     */
    $args = apply_filters('cptui_pre_register_taxonomy', $args, $taxonomy['name'], $taxonomy);
    return register_taxonomy($taxonomy['name'], $object_type, $args);
}
function cpt_create_custom_taxonomies()
{
    //register custom taxonomies
    $cpt_tax_types = get_option('cpt_custom_tax_types');
    //check if option value is an array before proceeding
    if (is_array($cpt_tax_types)) {
        foreach ($cpt_tax_types as $cpt_tax_type) {
            //set custom taxonomy values
            $cpt_label = !empty($cpt_tax_type["label"]) ? esc_html($cpt_tax_type["label"]) : esc_html($cpt_tax_type["name"]);
            $cpt_singular_label = !empty($cpt_tax_type["singular_label"]) ? esc_html($cpt_tax_type["singular_label"]) : esc_html($cpt_tax_type["name"]);
            $cpt_rewrite_slug = !empty($cpt_tax_type["rewrite_slug"]) ? esc_html($cpt_tax_type["rewrite_slug"]) : esc_html($cpt_tax_type["name"]);
            $cpt_tax_show_admin_column = !empty($cpt_tax_type["show_admin_column"]) ? esc_html($cpt_tax_type["show_admin_column"]) : false;
            $cpt_post_types = !empty($cpt_tax_type[1]) ? $cpt_tax_type[1] : $cpt_tax_type["cpt_name"];
            //set custom label values
            $cpt_labels['name'] = $cpt_label;
            $cpt_labels['singular_name'] = $cpt_tax_type["singular_label"];
            $cpt_labels['search_items'] = $cpt_tax_type[0]["search_items"] ? $cpt_tax_type[0]["search_items"] : 'Search ' . $cpt_label;
            $cpt_labels['popular_items'] = $cpt_tax_type[0]["popular_items"] ? $cpt_tax_type[0]["popular_items"] : 'Popular ' . $cpt_label;
            $cpt_labels['all_items'] = $cpt_tax_type[0]["all_items"] ? $cpt_tax_type[0]["all_items"] : 'All ' . $cpt_label;
            $cpt_labels['parent_item'] = $cpt_tax_type[0]["parent_item"] ? $cpt_tax_type[0]["parent_item"] : 'Parent ' . $cpt_singular_label;
            $cpt_labels['parent_item_colon'] = $cpt_tax_type[0]["parent_item_colon"] ? $cpt_tax_type[0]["parent_item_colon"] : 'Parent ' . $cpt_singular_label . ':';
            $cpt_labels['edit_item'] = $cpt_tax_type[0]["edit_item"] ? $cpt_tax_type[0]["edit_item"] : 'Edit ' . $cpt_singular_label;
            $cpt_labels['update_item'] = $cpt_tax_type[0]["update_item"] ? $cpt_tax_type[0]["update_item"] : 'Update ' . $cpt_singular_label;
            $cpt_labels['add_new_item'] = $cpt_tax_type[0]["add_new_item"] ? $cpt_tax_type[0]["add_new_item"] : 'Add New ' . $cpt_singular_label;
            $cpt_labels['new_item_name'] = $cpt_tax_type[0]["new_item_name"] ? $cpt_tax_type[0]["new_item_name"] : 'New ' . $cpt_singular_label . ' Name';
            $cpt_labels['separate_items_with_commas'] = $cpt_tax_type[0]["separate_items_with_commas"] ? $cpt_tax_type[0]["separate_items_with_commas"] : 'Separate ' . $cpt_label . ' with commas';
            $cpt_labels['add_or_remove_items'] = $cpt_tax_type[0]["add_or_remove_items"] ? $cpt_tax_type[0]["add_or_remove_items"] : 'Add or remove ' . $cpt_label;
            $cpt_labels['choose_from_most_used'] = $cpt_tax_type[0]["choose_from_most_used"] ? $cpt_tax_type[0]["choose_from_most_used"] : 'Choose from the most used ' . $cpt_label;
            //register our custom taxonomies
            register_taxonomy($cpt_tax_type["name"], $cpt_post_types, array('hierarchical' => get_disp_boolean($cpt_tax_type["hierarchical"]), 'label' => $cpt_label, 'show_ui' => get_disp_boolean($cpt_tax_type["show_ui"]), 'query_var' => get_disp_boolean($cpt_tax_type["query_var"]), 'rewrite' => array('slug' => $cpt_rewrite_slug), 'singular_label' => $cpt_singular_label, 'labels' => $cpt_labels, 'show_admin_column' => $cpt_tax_show_admin_column));
        }
    }
}
Example #4
0
/**
 * Create output for single post type to be ready for copy/paste from Get Code.
 *
 * @since 1.0.0
 *
 * @param array $post_type Post type data to output.
 *
 * @return string Copy/paste ready "php" code.
 */
function cptui_get_single_post_type_registery($post_type = array())
{
    /** This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
    $post_type['map_meta_cap'] = apply_filters('cptui_map_meta_cap', 'true', $post_type['name'], $post_type);
    $user_supports_params = apply_filters('cptui_user_supports_params', array(), $post_type['name'], $post_type);
    if (is_array($user_supports_params)) {
        $post_type['supports'] = array_merge($post_type['supports'], $user_supports_params);
    }
    $rewrite = get_disp_boolean($post_type['rewrite']);
    if (false !== $rewrite) {
        $rewrite = disp_boolean($post_type['rewrite']);
        $rewrite_slug = ' "slug" => "' . $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 = 'array(';
            $rewrite_end = ')';
            $rewrite = $rewrite_start . $rewrite_slug . $rewrite_withfront . $rewrite_end;
        }
    } else {
        $rewrite = disp_boolean($post_type['rewrite']);
    }
    $supports = '';
    # Do a little bit of php work to get these into strings.
    if (!empty($post_type['supports']) && is_array($post_type['supports'])) {
        $supports = 'array( "' . implode('", "', $post_type['supports']) . '" )';
    }
    if (in_array('none', $post_type['supports'])) {
        $supports = 'false';
    }
    $taxonomies = '';
    if (!empty($post_type['taxonomies']) && is_array($post_type['taxonomies'])) {
        $taxonomies = 'array( "' . implode('", "', $post_type['taxonomies']) . '" )';
    }
    if (in_array($post_type['query_var'], array('true', 'false', '0', '1'))) {
        $post_type['query_var'] = get_disp_boolean($post_type['query_var']);
    }
    $post_type['description'] = addslashes($post_type['description']);
    ?>
	$labels = array(
		"name" => "<?php 
    echo $post_type['label'];
    ?>
",
		"singular_name" => "<?php 
    echo $post_type['singular_label'];
    ?>
",
		<?php 
    foreach ($post_type['labels'] as $key => $label) {
        if (!empty($label)) {
            echo '"' . $key . '" => "' . $label . '",' . "\n\t\t";
        }
    }
    ?>
);

	$args = array(
		"labels" => $labels,
		"description" => "<?php 
    echo $post_type['description'];
    ?>
",
		"public" => <?php 
    echo disp_boolean($post_type['public']);
    ?>
,
		"show_ui" => <?php 
    echo disp_boolean($post_type['show_ui']);
    ?>
,
		"has_archive" => <?php 
    echo disp_boolean($post_type['has_archive']);
    ?>
,
		"show_in_menu" => <?php 
    echo disp_boolean($post_type['show_in_menu']);
    ?>
,
		"exclude_from_search" => <?php 
    echo disp_boolean($post_type['exclude_from_search']);
    ?>
,
		"capability_type" => "<?php 
    echo $post_type['capability_type'];
    ?>
",
		"map_meta_cap" => <?php 
    echo disp_boolean($post_type['map_meta_cap']);
    ?>
,
		"hierarchical" => <?php 
    echo disp_boolean($post_type['hierarchical']);
    ?>
,
		"rewrite" => <?php 
    echo $rewrite;
    ?>
,
		"query_var" => <?php 
    echo disp_boolean($post_type['query_var']);
    ?>
,
		<?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 
    }
    ?>
		<?php 
    if (!empty($supports)) {
        ?>
"supports" => <?php 
        echo $supports;
        ?>
,<?php 
    }
    ?>
		<?php 
    if (!empty($taxonomies)) {
        ?>
"taxonomies" => <?php 
        echo $taxonomies;
    }
    ?>
	);
	register_post_type( "<?php 
    echo $post_type['name'];
    ?>
", $args );
<?php 
}
Example #5
0
 public function test_get_disp_boolean()
 {
     $this->assertFalse(get_disp_boolean(0));
     $this->assertFalse(get_disp_boolean('0'));
     $this->assertFalse(get_disp_boolean(false));
     $this->assertFalse(get_disp_boolean('false'));
     $this->assertFalse(get_disp_boolean(''));
     $this->assertFalse(get_disp_boolean(null));
     $this->assertTrue(get_disp_boolean(1));
     $this->assertTrue(get_disp_boolean('1'));
     $this->assertTrue(get_disp_boolean(true));
     $this->assertTrue(get_disp_boolean('true'));
     $this->assertTrue(get_disp_boolean('abcd'));
     $this->assertTrue(get_disp_boolean(1235));
 }
function cpt_manage_cpt()
{
    global $CPT_URL;
    $MANAGE_URL = cpt_check_return('add');
    ?>
<div class="wrap">
<?php 
    //check for success/error messages
    if (isset($_GET['cpt_msg']) && $_GET['cpt_msg'] == 'del') {
        ?>
	<div id="message" class="updated">
		<?php 
        _e('Custom post type deleted successfully', 'cpt-plugin');
        ?>
	</div>
	<?php 
    }
    screen_icon('plugins');
    ?>
<h2><?php 
    _e('Manage Custom Post Types', 'cpt-plugin');
    ?>
</h2>
<p><?php 
    _e('Deleting custom post types will <strong>NOT</strong> delete any content into the database or added to those post types.  You can easily recreate your post types and the content will still exist.', 'cpt-plugin');
    ?>
</p>
<?php 
    $cpt_post_types = get_option('cpt_custom_post_types', array());
    if (is_array($cpt_post_types)) {
        ?>
		<table width="100%" class="widefat">
			<thead>
				<tr>
					<th><?php 
        _e('Action', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Name', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Label', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Public', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Show UI', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Hierarchical', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Rewrite', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Rewrite Slug', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Total Published', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Total Drafts', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Supports', 'cpt-plugin');
        ?>
</th>
				</tr>
			</thead>
			<tfoot>
				<tr>
					<th><?php 
        _e('Action', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Name', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Label', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Public', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Show UI', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Hierarchical', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Rewrite', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Rewrite Slug', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Total Published', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Total Drafts', 'cpt-plugin');
        ?>
</th>
					<th><?php 
        _e('Supports', 'cpt-plugin');
        ?>
</th>
				</tr>
			</tfoot>
		<?php 
        $thecounter = 0;
        $cpt_names = array();
        //Create urls for management
        foreach ($cpt_post_types as $cpt_post_type) {
            $del_url = cpt_check_return('cpt') . '&deltype=' . $thecounter . '&return=cpt';
            $del_url = function_exists('wp_nonce_url') ? wp_nonce_url($del_url, 'cpt_delete_post_type') : $del_url;
            $edit_url = $MANAGE_URL . '&edittype=' . $thecounter . '&return=cpt';
            $edit_url = function_exists('wp_nonce_url') ? wp_nonce_url($edit_url, 'cpt_edit_post_type') : $edit_url;
            $cpt_counts = wp_count_posts($cpt_post_type["name"]);
            $rewrite_slug = $cpt_post_type["rewrite_slug"] ? $cpt_post_type["rewrite_slug"] : $cpt_post_type["name"];
            ?>
			<tr>
				<td valign="top"><a href="<?php 
            echo $del_url;
            ?>
"><?php 
            _e('Delete', 'cpt-plugin');
            ?>
</a> / <a href="<?php 
            echo $edit_url;
            ?>
"><?php 
            _e('Edit', 'cpt-plugin');
            ?>
</a> / <a href="#" class="comment_button" id="<?php 
            echo $thecounter;
            ?>
"><?php 
            _e('Get Code', 'cpt-plugin');
            ?>
</a></td>
				<td valign="top"><?php 
            echo stripslashes($cpt_post_type["name"]);
            ?>
</td>
				<td valign="top"><?php 
            echo stripslashes($cpt_post_type["label"]);
            ?>
</td>
				<td valign="top"><?php 
            echo disp_boolean($cpt_post_type["public"]);
            ?>
</td>
				<td valign="top"><?php 
            echo disp_boolean($cpt_post_type["show_ui"]);
            ?>
</td>
				<td valign="top"><?php 
            echo disp_boolean($cpt_post_type["hierarchical"]);
            ?>
</td>
				<td valign="top"><?php 
            echo disp_boolean($cpt_post_type["rewrite"]);
            ?>
</td>
				<td valign="top"><?php 
            echo $rewrite_slug;
            ?>
</td>
				<td valign="top"><?php 
            echo $cpt_counts->publish;
            ?>
</td>
				<td valign="top"><?php 
            echo $cpt_counts->draft;
            ?>
</td>
				<td>
					<?php 
            if (is_array($cpt_post_type[0])) {
                foreach ($cpt_post_type[0] as $cpt_supports) {
                    echo $cpt_supports . '<br />';
                }
            }
            ?>
				</td>
			</tr>
			<tr>
				<td colspan="12">
					<div style="display:none;" id="slidepanel<?php 
            echo $thecounter;
            ?>
">
						<?php 
            // Begin the display for the "Get code" feature
            //display register_post_type code
            $custom_post_type = '';
            $cpt_support_array = '';
            $cpt_tax_array = '';
            $cpt_label = empty($cpt_post_type["label"]) ? esc_html($cpt_post_type["name"]) : esc_html($cpt_post_type["label"]);
            $cpt_singular = empty($cpt_post_type["singular_label"]) ? $cpt_label : esc_html($cpt_post_type["singular_label"]);
            $cpt_rewrite_slug = empty($cpt_post_type["rewrite_slug"]) ? esc_html($cpt_post_type["name"]) : esc_html($cpt_post_type["rewrite_slug"]);
            $cpt_rewrite_withfront = empty($cpt_post_type['rewrite_withfront']) ? get_disp_boolean($cpt_post_type['rewrite_withfront']) : 'true';
            //not reversed because false is empty, making the assignment go to true
            $cpt_menu_position = empty($cpt_post_type["menu_position"]) ? null : intval($cpt_post_type["menu_position"]);
            $cpt_menu_icon = !empty($cpt_post_type["menu_icon"]) ? esc_attr($cpt_post_type["menu_icon"]) : null;
            if (true == $cpt_post_type["show_ui"]) {
                $cpt_show_in_menu = $cpt_post_type["show_in_menu"] == 1 ? 1 : 0;
                $cpt_show_in_menu = $cpt_post_type["show_in_menu_string"] ? '\'' . $cpt_post_type["show_in_menu_string"] . '\'' : $cpt_show_in_menu;
            } else {
                $cpt_show_in_menu = 0;
            }
            //set custom label values
            $cpt_labels['name'] = $cpt_label;
            $cpt_labels['singular_name'] = $cpt_post_type["singular_label"];
            $cpt_labels['menu_name'] = $cpt_post_type[2]["menu_name"] ? $cpt_post_type[2]["menu_name"] : $cpt_label;
            $cpt_labels['add_new'] = $cpt_post_type[2]["add_new"] ? $cpt_post_type[2]["add_new"] : 'Add ' . $cpt_singular;
            $cpt_labels['add_new_item'] = $cpt_post_type[2]["add_new_item"] ? $cpt_post_type[2]["add_new_item"] : 'Add New ' . $cpt_singular;
            $cpt_labels['edit'] = $cpt_post_type[2]["edit"] ? $cpt_post_type[2]["edit"] : 'Edit';
            $cpt_labels['edit_item'] = $cpt_post_type[2]["edit_item"] ? $cpt_post_type[2]["edit_item"] : 'Edit ' . $cpt_singular;
            $cpt_labels['new_item'] = $cpt_post_type[2]["new_item"] ? $cpt_post_type[2]["new_item"] : 'New ' . $cpt_singular;
            $cpt_labels['view'] = $cpt_post_type[2]["view"] ? $cpt_post_type[2]["view"] : 'View ' . $cpt_singular;
            $cpt_labels['view_item'] = $cpt_post_type[2]["view_item"] ? $cpt_post_type[2]["view_item"] : 'View ' . $cpt_singular;
            $cpt_labels['search_items'] = $cpt_post_type[2]["search_items"] ? $cpt_post_type[2]["search_items"] : 'Search ' . $cpt_label;
            $cpt_labels['not_found'] = $cpt_post_type[2]["not_found"] ? $cpt_post_type[2]["not_found"] : 'No ' . $cpt_label . ' Found';
            $cpt_labels['not_found_in_trash'] = $cpt_post_type[2]["not_found_in_trash"] ? $cpt_post_type[2]["not_found_in_trash"] : 'No ' . $cpt_label . ' Found in Trash';
            $cpt_labels['parent'] = $cpt_post_type[2]["parent"] ? $cpt_post_type[2]["parent"] : 'Parent ' . $cpt_singular;
            if (false == (bool) $cpt_post_type["rewrite"]) {
                $rewrite = 'false';
            } else {
                if (!empty($cpt_post_type["rewrite_slug"])) {
                    $rewrite = "array('slug' => '" . $cpt_post_type["rewrite_slug"] . "', 'with_front' => " . $cpt_post_type['rewrite_withfront'] . "),\n";
                } else {
                    if (empty($cpt_post_type['rewrite_withfront'])) {
                        $cpt_post_type['rewrite_withfront'] = 1;
                    }
                    $rewrite = "array('slug' => '" . $cpt_post_type["name"] . "', 'with_front' => " . disp_boolean($cpt_post_type['rewrite_withfront']) . "),\n";
                }
            }
            if (is_array($cpt_post_type[0])) {
                $counter = 1;
                $count = count($cpt_post_type[0]);
                foreach ($cpt_post_type[0] as $cpt_supports) {
                    //build supports variable
                    $cpt_support_array .= '\'' . $cpt_supports . '\'';
                    if ($counter != $count) {
                        $cpt_support_array .= ',';
                    }
                    $counter++;
                }
            }
            if (is_array($cpt_post_type[1])) {
                $counter = 1;
                $count = count($cpt_post_type[1]);
                foreach ($cpt_post_type[1] as $cpt_taxes) {
                    //build taxonomies variable
                    $cpt_tax_array .= '\'' . $cpt_taxes . '\'';
                    if ($counter != $count) {
                        $cpt_tax_array .= ',';
                    }
                    $counter++;
                }
            }
            $custom_post_type = "add_action('init', 'cptui_register_my_cpt_" . $cpt_post_type["name"] . "');\n";
            $custom_post_type .= "function cptui_register_my_cpt_" . $cpt_post_type["name"] . "() {\n";
            $custom_post_type .= "register_post_type('" . $cpt_post_type["name"] . "', array(\n'label' => '" . $cpt_label . "',\n";
            $custom_post_type .= "'description' => '" . $cpt_post_type["description"] . "',\n";
            $custom_post_type .= "'public' => " . disp_boolean($cpt_post_type["public"]) . ",\n";
            $custom_post_type .= "'show_ui' => " . disp_boolean($cpt_post_type["show_ui"]) . ",\n";
            $custom_post_type .= "'show_in_menu' => " . disp_boolean($cpt_show_in_menu) . ",\n";
            $custom_post_type .= "'capability_type' => '" . $cpt_post_type["capability_type"] . "',\n";
            $custom_post_type .= "'map_meta_cap' => " . disp_boolean('1') . ",\n";
            $custom_post_type .= "'hierarchical' => " . disp_boolean($cpt_post_type["hierarchical"]) . ",\n";
            $custom_post_type .= "'rewrite' => " . $rewrite . "\n";
            $custom_post_type .= "'query_var' => " . disp_boolean($cpt_post_type["query_var"]) . ",\n";
            if (!empty($cpt_post_type["has_archive"])) {
                $custom_post_type .= "'has_archive' => " . disp_boolean($cpt_post_type["has_archive"]) . ",\n";
            }
            if (!empty($cpt_post_type["exclude_from_search"])) {
                $custom_post_type .= "'exclude_from_search' => " . disp_boolean($cpt_post_type["exclude_from_search"]) . ",\n";
            }
            if (!empty($cpt_menu_position)) {
                $custom_post_type .= "'menu_position' => " . $cpt_menu_position . ",\n";
            }
            if (!empty($cpt_post_type["menu_icon"])) {
                $custom_post_type .= "'menu_icon' => '" . $cpt_post_type["menu_icon"] . "',\n";
            }
            $custom_post_type .= "'supports' => array(" . $cpt_support_array . "),\n";
            if (!empty($cpt_tax_array)) {
                $custom_post_type .= "'taxonomies' => array(" . $cpt_tax_array . "),\n";
            }
            if (!empty($cpt_labels)) {
                $custom_post_type .= "'labels' => " . var_export($cpt_labels, true) . "\n";
            }
            $custom_post_type .= ") ); }";
            echo '<p>';
            _e('Place the below code in your themes functions.php file to manually create this custom post type.', 'cpt-plugin') . '<br>';
            _e('This is a <strong>BETA</strong> feature. Please <a href="https://github.com/WebDevStudios/custom-post-type-ui">report bugs</a>.', 'cpt-plugin') . '</p>';
            echo '<textarea rows="10" cols="100">' . $custom_post_type . '</textarea>';
            ?>
					</div>
				</td>
			</tr>
		<?php 
            $thecounter++;
            $cpt_names[] = strtolower($cpt_post_type["name"]);
        }
        $args = array('public' => true, '_builtin' => false);
        $output = 'objects';
        // or objects
        $post_types = get_post_types($args, $output);
        $cpt_first = false;
        if ($post_types) {
            ?>
</table>
				<h3><?php 
            _e('Additional Custom Post Types', 'cpt-plugin');
            ?>
</h3>
				<p><?php 
            _e('The custom post types below are registered in WordPress but were not created by the Custom Post Type UI Plugin.', 'cpt-plugin');
            ?>
</p>
					<?php 
            foreach ($post_types as $post_type) {
                if (!in_array(strtolower($post_type->name), $cpt_names)) {
                    if (isset($cpt_first) && !$cpt_first) {
                        ?>
								<table width="100%" class="widefat">
									<thead>
										<tr>
											<th><?php 
                        _e('Name', 'cpt-plugin');
                        ?>
</th>
											<th><?php 
                        _e('Label', 'cpt-plugin');
                        ?>
</th>
											<th><?php 
                        _e('Public', 'cpt-plugin');
                        ?>
</th>
											<th><?php 
                        _e('Show UI', 'cpt-plugin');
                        ?>
</th>
											<th><?php 
                        _e('Hierarchical', 'cpt-plugin');
                        ?>
</th>
											<th><?php 
                        _e('Rewrite', 'cpt-plugin');
                        ?>
</th>
											<th><?php 
                        _e('Rewrite Slug', 'cpt-plugin');
                        ?>
</th>
											<th><?php 
                        _e('Query Var', 'cpt-plugin');
                        ?>
</th>
										</tr>
									</thead>
									<tfoot>
										<tr>
											<th><?php 
                        _e('Name', 'cpt-plugin');
                        ?>
</th>
											<th><?php 
                        _e('Label', 'cpt-plugin');
                        ?>
</th>
											<th><?php 
                        _e('Public', 'cpt-plugin');
                        ?>
</th>
											<th><?php 
                        _e('Show UI', 'cpt-plugin');
                        ?>
</th>
											<th><?php 
                        _e('Hierarchical', 'cpt-plugin');
                        ?>
</th>
											<th><?php 
                        _e('Rewrite', 'cpt-plugin');
                        ?>
</th>
											<th><?php 
                        _e('Rewrite Slug', 'cpt-plugin');
                        ?>
</th>
											<th><?php 
                        _e('Query Var', 'cpt-plugin');
                        ?>
</th>
										</tr>
									</tfoot>
								<?php 
                        $cpt_first = true;
                    }
                    $rewrite_slug = isset($post_type->rewrite_slug) ? $post_type->rewrite_slug : $post_type->name;
                    ?>
							<tr>
								<td valign="top"><?php 
                    echo $post_type->name;
                    ?>
</td>
								<td valign="top"><?php 
                    echo $post_type->label;
                    ?>
</td>
								<td valign="top"><?php 
                    echo disp_boolean($post_type->public);
                    ?>
</td>
								<td valign="top"><?php 
                    echo disp_boolean($post_type->show_ui);
                    ?>
</td>
								<td valign="top"><?php 
                    echo disp_boolean($post_type->hierarchical);
                    ?>
</td>
								<td valign="top"><?php 
                    echo disp_boolean($post_type->rewrite);
                    ?>
</td>
								<td valign="top"><?php 
                    echo $rewrite_slug;
                    ?>
</td>
								<td valign="top"><?php 
                    echo disp_boolean($post_type->query_var);
                    ?>
</td>
							</tr>
							<?php 
                }
            }
        }
        if (isset($cpt_first) && !$cpt_first) {
            echo '<tr><td><strong>';
            _e('No additional post types found', 'cpt-plugin');
            echo '</strong></td></tr>';
        }
        ?>
		</table>

		</div><?php 
        //load footer
        cpt_footer();
    }
}
/**
 * Create output for single post type to be ready for copy/paste from Get Code.
 *
 * @since 1.0.0
 *
 * @param array $post_type Post type data to output.
 * @return string Copy/paste ready "php" code.
 */
function cptui_get_single_post_type_registery($post_type = array())
{
    /** This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
    $post_type['map_meta_cap'] = apply_filters('cptui_map_meta_cap', 'true', $post_type['name'], $post_type);
    /** This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
    $user_supports_params = apply_filters('cptui_user_supports_params', array(), $post_type['name'], $post_type);
    if (is_array($user_supports_params)) {
        $post_type['supports'] = array_merge($post_type['supports'], $user_supports_params);
    }
    $yarpp = false;
    // Prevent notices.
    if (!empty($post_type['custom_supports'])) {
        $custom = explode(',', $post_type['custom_supports']);
        foreach ($custom as $part) {
            // We'll handle YARPP separately.
            if (in_array($part, array('YARPP', 'yarpp'))) {
                $yarpp = true;
                continue;
            }
            $post_type['supports'][] = $part;
        }
    }
    $rewrite_withfront = '';
    $rewrite = get_disp_boolean($post_type['rewrite']);
    if (false !== $rewrite) {
        $rewrite = disp_boolean($post_type['rewrite']);
        $rewrite_slug = ' "slug" => "' . $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 = 'array(';
            $rewrite_end = ')';
            $rewrite = $rewrite_start . $rewrite_slug . $rewrite_withfront . $rewrite_end;
        }
    } else {
        $rewrite = disp_boolean($post_type['rewrite']);
    }
    $supports = '';
    // Do a little bit of php work to get these into strings.
    if (!empty($post_type['supports']) && is_array($post_type['supports'])) {
        $supports = 'array( "' . implode('", "', $post_type['supports']) . '" )';
    }
    if (in_array('none', $post_type['supports'])) {
        $supports = 'false';
    }
    $taxonomies = '';
    if (!empty($post_type['taxonomies']) && is_array($post_type['taxonomies'])) {
        $taxonomies = 'array( "' . implode('", "', $post_type['taxonomies']) . '" )';
    }
    if (in_array($post_type['query_var'], array('true', 'false', '0', '1'))) {
        $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';
    }
    $post_type['description'] = addslashes($post_type['description']);
    $my_theme = wp_get_theme();
    $textdomain = $my_theme->get('TextDomain');
    ?>
	$labels = array(
		"name" => __( '<?php 
    echo $post_type['label'];
    ?>
', '<?php 
    echo $textdomain;
    ?>
' ),
		"singular_name" => __( '<?php 
    echo $post_type['singular_label'];
    ?>
', '<?php 
    echo $textdomain;
    ?>
' ),
		<?php 
    foreach ($post_type['labels'] as $key => $label) {
        if (!empty($label)) {
            echo '"' . $key . '" => __( \'' . $label . '\', \'' . $textdomain . '\' ),' . "\n\t\t";
        }
    }
    ?>
);

	$args = array(
		"label" => __( '<?php 
    echo $post_type['label'];
    ?>
', '<?php 
    echo $textdomain;
    ?>
' ),
		"labels" => $labels,
		"description" => "<?php 
    echo $post_type['description'];
    ?>
",
		"public" => <?php 
    echo disp_boolean($post_type['public']);
    ?>
,
		"show_ui" => <?php 
    echo disp_boolean($post_type['show_ui']);
    ?>
,
		"show_in_rest" => <?php 
    echo disp_boolean($post_type['show_in_rest']);
    ?>
,
		"rest_base" => "<?php 
    echo $post_type['rest_base'];
    ?>
",
		"has_archive" => <?php 
    echo disp_boolean($post_type['has_archive']);
    ?>
,
		"show_in_menu" => <?php 
    echo disp_boolean($post_type['show_in_menu']);
    ?>
,
		"exclude_from_search" => <?php 
    echo disp_boolean($post_type['exclude_from_search']);
    ?>
,
		"capability_type" => "<?php 
    echo $post_type['capability_type'];
    ?>
",
		"map_meta_cap" => <?php 
    echo disp_boolean($post_type['map_meta_cap']);
    ?>
,
		"hierarchical" => <?php 
    echo disp_boolean($post_type['hierarchical']);
    ?>
,
		"rewrite" => <?php 
    echo $rewrite;
    ?>
,
		"query_var" => <?php 
    echo $post_type['query_var'];
    ?>
,
		<?php 
    if (!empty($post_type['menu_position'])) {
        ?>
"menu_position" => <?php 
        echo $post_type['menu_position'];
        ?>
,<?php 
    }
    if (!empty($post_type['menu_icon'])) {
        ?>
"menu_icon" => "<?php 
        echo $post_type['menu_icon'];
        ?>
",<?php 
    }
    ?>
		<?php 
    if (!empty($supports)) {
        echo "\n\t\t";
        ?>
"supports" => <?php 
        echo $supports;
        ?>
,<?php 
    }
    ?>
		<?php 
    if (!empty($taxonomies)) {
        echo "\n\t\t";
        ?>
"taxonomies" => <?php 
        echo $taxonomies;
        ?>
,<?php 
    }
    ?>
		<?php 
    if (true === $yarpp) {
        echo "\n\t\t";
        ?>
"yarpp_support" => <?php 
        echo disp_boolean($yarpp);
    }
    echo "\n";
    ?>
	);
	register_post_type( "<?php 
    echo $post_type['name'];
    ?>
", $args );
<?php 
}
/**
 * Create output for single post type to be ready for copy/paste from Get Code.
 *
 * @since 1.0.0
 *
 * @param array $post_type Post type data to output.
 *
 * @return string Copy/paste ready "php" code.
 */
function cptui_get_single_post_type_registery($post_type = array())
{
    /** This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
    $post_type['map_meta_cap'] = apply_filters('cptui_map_meta_cap', 'true', $post_type['name'], $post_type);
    $user_supports_params = apply_filters('cptui_user_supports_params', array(), $post_type['name'], $post_type);
    if (is_array($user_supports_params)) {
        $post_type['supports'] = array_merge($post_type['supports'], $user_supports_params);
    }
    $rewrite = get_disp_boolean($post_type['rewrite']);
    if (false !== $rewrite) {
        $rewrite = disp_boolean($post_type['rewrite']);
        $rewrite_slug = ' \'slug\' => \'' . $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 = 'array(';
            $rewrite_end = ')';
            $rewrite = $rewrite_start . $rewrite_slug . $rewrite_withfront . $rewrite_end;
        }
    } else {
        $rewrite = disp_boolean($post_type['rewrite']);
    }
    $supports = '';
    # Do a little bit of php work to get these into strings.
    if (!empty($post_type['supports']) && is_array($post_type['supports'])) {
        $supports = 'array( \'' . implode('\', \'', $post_type['supports']) . '\' )';
    }
    $taxonomies = '';
    if (!empty($post_type['taxonomies']) && is_array($post_type['taxonomies'])) {
        $taxonomies = 'array( \'' . implode('\', \'', $post_type['taxonomies']) . '\' )';
    }
    $post_type['description'] = addslashes($post_type['description']);
    ?>
	$labels = array(
		'name' => '<?php 
    echo $post_type['label'];
    ?>
',
		'singular_name' => '<?php 
    echo $post_type['singular_label'];
    ?>
',
		<?php 
    foreach ($post_type['labels'] as $key => $label) {
        if (!empty($label)) {
            echo "'{$key}' => '{$label}',\n\t\t";
        }
    }
    ?>
);

	$args = array(
		'labels' => $labels,
		'description' => '<?php 
    echo $post_type['description'];
    ?>
',
		'public' => <?php 
    echo $post_type['public'];
    ?>
,
		'show_ui' => <?php 
    echo $post_type['show_ui'];
    ?>
,
		'has_archive' => <?php 
    echo $post_type['has_archive'];
    ?>
,
		'show_in_menu' => <?php 
    echo $post_type['show_in_menu'];
    ?>
,
		'exclude_from_search' => <?php 
    echo $post_type['exclude_from_search'];
    ?>
,
		'capability_type' => '<?php 
    echo $post_type['capability_type'];
    ?>
',
		'map_meta_cap' => <?php 
    echo $post_type['map_meta_cap'];
    ?>
,
		'hierarchical' => <?php 
    echo $post_type['hierarchical'];
    ?>
,
		'rewrite' => <?php 
    echo $rewrite;
    ?>
,
		'query_var' => <?php 
    echo $post_type['query_var'];
    ?>
,
		<?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 
    }
    ?>
		<?php 
    if (!empty($supports)) {
        ?>
'supports' => <?php 
        echo $supports;
        ?>
,<?php 
    }
    ?>
		<?php 
    if (!empty($taxonomies)) {
        ?>
'taxonomies' => <?php 
        echo $taxonomies;
    }
    ?>
	);
	register_post_type( '<?php 
    echo $post_type['name'];
    ?>
', $args );
<?php 
}