diff --git src/wp-includes/capabilities.php src/wp-includes/capabilities.php
index 7c570c4..d8f52fe 100644
--- src/wp-includes/capabilities.php
+++ src/wp-includes/capabilities.php
@@ -16,6 +16,8 @@
  *
  * @since 2.0.0
  *
+ * @global array $post_type_meta_caps Used to get post type meta capabilities.
+ *
  * @param string $cap       Capability name.
  * @param int    $user_id   User ID.
  * @param int    $object_id Optional. ID of the specific object to check against if `$cap` is a "meta" cap.
@@ -377,7 +379,7 @@ function map_meta_cap( $cap, $user_id ) {
 		break;
 	default:
 		// Handle meta capabilities for custom post types.
-		$post_type_meta_caps = _post_type_meta_capabilities();
+		global $post_type_meta_caps;
 		if ( isset( $post_type_meta_caps[ $cap ] ) ) {
 			$args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args );
 			return call_user_func_array( 'map_meta_cap', $args );
diff --git src/wp-includes/class-wp-rewrite.php src/wp-includes/class-wp-rewrite.php
index 035bbc3..467f823 100644
--- src/wp-includes/class-wp-rewrite.php
+++ src/wp-includes/class-wp-rewrite.php
@@ -842,6 +842,30 @@ class WP_Rewrite {
 	}
 
 	/**
+	 * Adds or updates existing rewrite tags (e.g. %postname%).
+	 *
+	 * If the tag already exists, replace the existing pattern and query for
+	 * that tag, otherwise add the new tag.
+	 *
+	 * @since 4.5.0
+	 * @access public
+	 *
+	 * @see WP_Rewrite::$rewritecode
+	 * @see WP_Rewrite::$rewritereplace
+	 * @see WP_Rewrite::$queryreplace
+	 *
+	 * @param string $tag Name of the rewrite tag.
+	 */
+	public function remove_rewrite_tag( $tag ) {
+		$position = array_search( $tag, $this->rewritecode );
+		if ( false !== $position && null !== $position ) {
+			unset( $this->rewritecode[ $position ] );
+			unset( $this->rewritereplace[ $position ] );
+			unset( $this->queryreplace[ $position ] );
+		}
+	}
+
+	/**
 	 * Generates rewrite rules from a permalink structure.
 	 *
 	 * The main WP_Rewrite function for building the rewrite rule list. The
diff --git src/wp-includes/post.php src/wp-includes/post.php
index 0fb1dfa..f906e01 100644
--- src/wp-includes/post.php
+++ src/wp-includes/post.php
@@ -1187,6 +1187,89 @@ function register_post_type( $post_type, $args = array() ) {
 }
 
 /**
+ * Unregister a post type.
+ *
+ * @since 4.5.0
+ *
+ * @global WP_Rewrite $wp_rewrite             WordPress rewrite component.
+ * @global WP         $wp                     Current WordPress environment instance.
+ * @global array      $_wp_post_type_features Used to remove post type features.
+ * @global array      $post_type_meta_caps    Used to remove meta capabilities.
+ * @global array      $wp_post_types          List of post types.
+ *
+ * @param string $post_type Post type key.
+ * @return bool True on success, false on failure.
+ */
+function unregister_post_type( $post_type ) {
+	$post_type_args = get_post_type_object( $post_type );
+
+	if ( ! $post_type_args ) {
+		return false;
+	}
+
+	// Do not allow unregistering internal post types.
+	if ( $post_type_args->_builtin ) {
+		return false;
+	}
+
+	global $wp, $wp_rewrite, $_wp_post_type_features, $post_type_meta_caps, $wp_post_types;
+
+	// Post type does not exist.
+	if ( ! isset( $wp_post_types[ $post_type ] ) ) {
+		return false;
+	}
+
+	// Remove query vars.
+	if ( false !== $post_type_args->query_var ) {
+		$wp->public_query_vars = array_diff( $wp->public_query_vars, array( $post_type_args->query_var ) );
+	}
+
+	// Remove any rewrite rules, permastructs, and rules.
+	if ( false !== $post_type_args->rewrite ) {
+		remove_rewrite_tag( "%$post_type%" );
+		foreach ( $wp_rewrite->extra_rules_top as $regex => $query ) {
+			if ( false !== strpos( $query, "index.php?post_type=$post_type" ) ) {
+				unset( $wp_rewrite->extra_rules_top[ $regex ] );
+			}
+		}
+
+		unset( $wp_rewrite->extra_permastructs[ $post_type ] );
+	}
+
+	// Remove registered custom meta capabilities.
+	foreach ( $post_type_args->cap as $cap ) {
+		unset( $post_type_meta_caps[ $cap ] );
+	}
+
+	// Remove all post type support.
+	unset( $_wp_post_type_features[ $post_type ] );
+
+	// Remove meta boxes.
+	remove_all_actions( 'add_meta_boxes_' . $post_type );
+
+	// Remove the post type from all taxonomies.
+	foreach ( get_object_taxonomies( $post_type ) as $taxonomy ) {
+		unregister_taxonomy_for_object_type( $taxonomy, $post_type );
+	}
+
+	// Remove the future post hook actions.
+	remove_all_actions( 'future_' . $post_type );
+
+	unset( $wp_post_types[ $post_type ] );
+
+	/**
+	 * Fires after a post type is unregistered.
+	 *
+	 * @since 4.5.0
+	 *
+	 * @param string $post_type Post type.
+	 */
+	do_action( 'unregistered_post_type', $post_type );
+
+	return true;
+}
+
+/**
  * Build an object with all post type capabilities out of a post type object
  *
  * Post type capabilities use the 'capability_type' argument as a base, if the
@@ -1293,17 +1376,17 @@ function get_post_type_capabilities( $args ) {
  * @since 3.1.0
  * @access private
  *
- * @staticvar array $meta_caps
+ * @global array $post_type_meta_caps Used to store meta capabilities.
  *
- * @param array|void $capabilities Post type meta capabilities.
+ * @param array $capabilities Post type meta capabilities.
  */
 function _post_type_meta_capabilities( $capabilities = null ) {
-	static $meta_caps = array();
-	if ( null === $capabilities )
-		return $meta_caps;
+	global $post_type_meta_caps;
+
 	foreach ( $capabilities as $core => $custom ) {
-		if ( in_array( $core, array( 'read_post', 'delete_post', 'edit_post' ) ) )
-			$meta_caps[ $custom ] = $core;
+		if ( in_array( $core, array( 'read_post', 'delete_post', 'edit_post' ) ) ) {
+			$post_type_meta_caps[ $custom ] = $core;
+		}
 	}
 }
 
diff --git src/wp-includes/rewrite.php src/wp-includes/rewrite.php
index 7f3b2ed..826ced2 100644
--- src/wp-includes/rewrite.php
+++ src/wp-includes/rewrite.php
@@ -173,6 +173,21 @@ function add_rewrite_tag( $tag, $regex, $query = '' ) {
 }
 
 /**
+ * Removes an existing rewrite tag (like %postname%).
+ *
+ * @since 4.5.0
+ *
+ * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
+ * @global WP         $wp         Current WordPress environment instance.
+ *
+ * @param string $tag Name of the rewrite tag.
+ */
+function remove_rewrite_tag( $tag ) {
+	global $wp_rewrite;
+	$wp_rewrite->remove_rewrite_tag( $tag );
+}
+
+/**
  * Add permalink structure.
  *
  * @since 3.0.0
diff --git tests/phpunit/includes/testcase.php tests/phpunit/includes/testcase.php
index a468deb..d9687d5 100644
--- tests/phpunit/includes/testcase.php
+++ tests/phpunit/includes/testcase.php
@@ -157,7 +157,7 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
 	 */
 	protected function reset_post_types() {
 		foreach ( get_post_types() as $pt ) {
-			_unregister_post_type( $pt );
+			unregister_post_type( $pt );
 		}
 		create_initial_post_types();
 	}
diff --git tests/phpunit/includes/utils.php tests/phpunit/includes/utils.php
index 0a6dfc1..7adb234 100644
--- tests/phpunit/includes/utils.php
+++ tests/phpunit/includes/utils.php
@@ -319,20 +319,6 @@ if ( !function_exists( 'str_getcsv' ) ) {
 	}
 }
 
-/**
- * Removes the post type and its taxonomy associations.
- */
-function _unregister_post_type( $cpt_name ) {
-	unset( $GLOBALS['wp_post_types'][ $cpt_name ] );
-	unset( $GLOBALS['_wp_post_type_features'][ $cpt_name ] );
-
-	foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy ) {
-		if ( false !== $key = array_search( $cpt_name, $taxonomy->object_type ) ) {
-			unset( $taxonomy->object_type[$key] );
-		}
-	}
-}
-
 function _unregister_taxonomy( $taxonomy_name ) {
 	unset( $GLOBALS['wp_taxonomies'][$taxonomy_name] );
 }
@@ -398,7 +384,7 @@ class wpdb_exposed_methods_for_testing extends wpdb {
  */
 function benchmark_pcre_backtracking( $pattern, $subject, $strategy ) {
 	$saved_config = ini_get( 'pcre.backtrack_limit' );
-	
+
 	// Attempt to prevent PHP crashes.  Adjust these lower when needed.
 	if ( version_compare( phpversion(), '5.4.8', '>' ) ) {
 		$limit = 1000000;
@@ -410,7 +396,7 @@ function benchmark_pcre_backtracking( $pattern, $subject, $strategy ) {
 	for( $i = 4; $i <= $limit; $i *= 2 ) {
 
 		ini_set( 'pcre.backtrack_limit', $i );
-		
+
 		switch( $strategy ) {
 		case 'split':
 			preg_split( $pattern, $subject );
diff --git tests/phpunit/tests/adminbar.php tests/phpunit/tests/adminbar.php
index a2f61f2..c79a8fb 100644
--- tests/phpunit/tests/adminbar.php
+++ tests/phpunit/tests/adminbar.php
@@ -48,7 +48,7 @@ class Tests_AdminBar extends WP_UnitTestCase {
 		$this->assertFalse( $nodes['new-content']->parent );
 		$this->assertEquals( 'new-content', $nodes['add-new-content']->parent );
 
-		_unregister_post_type( 'content' );
+		unregister_post_type( 'content' );
 	}
 
 	/**
diff --git tests/phpunit/tests/comment/query.php tests/phpunit/tests/comment/query.php
index 5d250ea..bf639cd 100644
--- tests/phpunit/tests/comment/query.php
+++ tests/phpunit/tests/comment/query.php
@@ -1469,8 +1469,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
 
 		$this->assertEqualSets( $c2, $found );
 
-		_unregister_post_type( 'post-type-1' );
-		_unregister_post_type( 'post-type-2' );
+		unregister_post_type( 'post-type-1' );
+		unregister_post_type( 'post-type-2' );
 	}
 
 	/**
@@ -1494,8 +1494,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
 
 		$this->assertEqualSets( $c2, $found );
 
-		_unregister_post_type( 'post-type-1' );
-		_unregister_post_type( 'post-type-2' );
+		unregister_post_type( 'post-type-1' );
+		unregister_post_type( 'post-type-2' );
 	}
 
 	/**
@@ -1521,8 +1521,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
 
 		$this->assertEqualSets( array_merge( $c1, $c3 ), $found );
 
-		_unregister_post_type( 'post-type-1' );
-		_unregister_post_type( 'post-type-2' );
+		unregister_post_type( 'post-type-1' );
+		unregister_post_type( 'post-type-2' );
 	}
 
 	public function test_post_name_single_value() {
diff --git tests/phpunit/tests/customize/nav-menu-item-setting.php tests/phpunit/tests/customize/nav-menu-item-setting.php
index 39ed42e..ec6add1 100644
--- tests/phpunit/tests/customize/nav-menu-item-setting.php
+++ tests/phpunit/tests/customize/nav-menu-item-setting.php
@@ -742,7 +742,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
 		$value_object = $setting->value_as_wp_post_nav_menu_item();
 		$this->assertFalse( $value_object->_invalid );
 
-		_unregister_post_type( 'poem' );
+		unregister_post_type( 'poem' );
 		$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
 		$value = $setting->value();
 		$this->assertTrue( $value['_invalid'] );
diff --git tests/phpunit/tests/post.php tests/phpunit/tests/post.php
index a1ec373..a9a90f3 100644
--- tests/phpunit/tests/post.php
+++ tests/phpunit/tests/post.php
@@ -816,7 +816,7 @@ class Tests_Post extends WP_UnitTestCase {
 		) );
 		$count = wp_count_posts( $post_type, 'readable' );
 		$this->assertEquals( 1, $count->publish );
-		_unregister_post_type( $post_type );
+		unregister_post_type( $post_type );
 		$this->assertEquals( new stdClass, wp_count_posts( $post_type, 'readable' ) );
 	}
 
@@ -1083,7 +1083,7 @@ class Tests_Post extends WP_UnitTestCase {
 
 		$this->assertEquals( 'open', $post->comment_status );
 		$this->assertEquals( 'open', $post->ping_status );
-		_unregister_post_type( $post_type );
+		unregister_post_type( $post_type );
 	}
 
 	/**
@@ -1103,7 +1103,7 @@ class Tests_Post extends WP_UnitTestCase {
 
 		$this->assertEquals( 'closed', $post->comment_status );
 		$this->assertEquals( 'closed', $post->ping_status );
-		_unregister_post_type( $post_type );
+		unregister_post_type( $post_type );
 	}
 
 	/**
diff --git tests/phpunit/tests/post/getPages.php tests/phpunit/tests/post/getPages.php
index 5391815..467dba2 100644
--- tests/phpunit/tests/post/getPages.php
+++ tests/phpunit/tests/post/getPages.php
@@ -356,7 +356,7 @@ class Tests_Post_getPages extends WP_UnitTestCase {
 		$this->assertContains( 'current_page_item', $output );
 		$this->assertEquals( 1, substr_count( $output, 'current_page_item' ) );
 
-		_unregister_post_type( $type );
+		unregister_post_type( $type );
 	}
 
 	function test_exclude_tree() {
diff --git tests/phpunit/tests/post/getPostsByAuthorSql.php tests/phpunit/tests/post/getPostsByAuthorSql.php
index 26de5b8..398e4c9 100644
--- tests/phpunit/tests/post/getPostsByAuthorSql.php
+++ tests/phpunit/tests/post/getPostsByAuthorSql.php
@@ -28,8 +28,8 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
 		$this->assertContains( "post_type = 'foo'", $maybe_string );
 		$this->assertContains( "post_type = 'bar'", $maybe_string );
 
-		_unregister_post_type( 'foo' );
-		_unregister_post_type( 'bar' );
+		unregister_post_type( 'foo' );
+		unregister_post_type( 'bar' );
 	}
 
 	public function test_full_true(){
@@ -143,9 +143,9 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
 		$this->assertNotContains( "post_type = 'bar' AND ( post_status = 'publish' OR post_status = 'private' )", $maybe_string );
 		$this->assertContains( "post_type = 'baz' AND ( post_status = 'publish' OR post_status = 'private' )", $maybe_string );
 
-		_unregister_post_type( 'foo' );
-		_unregister_post_type( 'bar' );
-		_unregister_post_type( 'baz' );
+		unregister_post_type( 'foo' );
+		unregister_post_type( 'bar' );
+		unregister_post_type( 'baz' );
 		wp_set_current_user( $current_user );
 	}
 }
diff --git tests/phpunit/tests/post/types.php tests/phpunit/tests/post/types.php
index 02d4590..0fbd532 100644
--- tests/phpunit/tests/post/types.php
+++ tests/phpunit/tests/post/types.php
@@ -16,7 +16,7 @@ class Tests_Post_Types extends WP_UnitTestCase {
 		$this->assertFalse( is_post_type_hierarchical( 'foo' ) );
 		$this->assertEquals( array(), get_object_taxonomies( 'foo' ) );
 
-		_unregister_post_type( 'foo' );
+		unregister_post_type( 'foo' );
 	}
 
 	/**
@@ -58,7 +58,7 @@ class Tests_Post_Types extends WP_UnitTestCase {
 		$this->assertFalse( is_object_in_taxonomy( 'bar', 'post_tag' ) );
 		$this->assertFalse( is_object_in_taxonomy( 'bar', 'post_tag' ) );
 
-		_unregister_post_type( 'bar' );
+		unregister_post_type( 'bar' );
 	}
 
 	function test_post_type_exists() {
@@ -81,12 +81,12 @@ class Tests_Post_Types extends WP_UnitTestCase {
 		register_post_type( 'foo', array( 'supports' => array() ) );
 		$this->assertTrue( post_type_supports( 'foo', 'editor' ) );
 		$this->assertTrue( post_type_supports( 'foo', 'title' ) );
-		_unregister_post_type( 'foo' );
+		unregister_post_type( 'foo' );
 
 		register_post_type( 'foo', array( 'supports' => false ) );
 		$this->assertFalse( post_type_supports( 'foo', 'editor' ) );
 		$this->assertFalse( post_type_supports( 'foo', 'title' ) );
-		_unregister_post_type( 'foo' );
+		unregister_post_type( 'foo' );
 	}
 
 	/**
@@ -99,7 +99,7 @@ class Tests_Post_Types extends WP_UnitTestCase {
 		register_post_type( 'foo', array( 'rewrite' => array( 'feeds' => false ) ) );
 		$this->assertFalse( $wp_rewrite->extra_permastructs['foo']['feed'] );
 		update_option( 'permalink_structure', $old_permastruct );
-		_unregister_post_type( 'foo' );
+		unregister_post_type( 'foo' );
 	}
 
 	/**
@@ -112,7 +112,7 @@ class Tests_Post_Types extends WP_UnitTestCase {
 		$this->assertObjectHasAttribute( 'featured_image', get_post_type_object( 'foo' )->labels );
 		$this->assertObjectHasAttribute( 'set_featured_image', get_post_type_object( 'foo' )->labels );
 
-		_unregister_post_type( 'foo' );
+		unregister_post_type( 'foo' );
 		remove_filter( 'post_type_labels_foo', array( $this, 'filter_post_type_labels' ) );
 	}
 
@@ -138,7 +138,7 @@ class Tests_Post_Types extends WP_UnitTestCase {
 		$this->assertNull( get_post_type_object( array( 'foo' ) ) );
 		$this->assertNull( get_post_type_object( new stdClass ) );
 
-		_unregister_post_type( 'foo' );
+		unregister_post_type( 'foo' );
 
 		$this->assertFalse( post_type_exists( 'foo' ) );
 	}
@@ -157,6 +157,182 @@ class Tests_Post_Types extends WP_UnitTestCase {
 
 		$this->assertEquals( $before, $after );
 
-		_unregister_post_type( 'foo' );
+		unregister_post_type( 'foo' );
+	}
+
+	/**
+	 * @ticket 14761
+	 */
+	public function test_unregister_post_type() {
+		register_post_type( 'foo' );
+		$this->assertTrue( unregister_post_type( 'foo' ) );
+	}
+
+	/**
+	 * @ticket 14761
+	 */
+	public function test_unregister_post_type_unknown_post_type() {
+		$this->assertFalse( unregister_post_type( 'foo' ) );
+	}
+
+	/**
+	 * @ticket 14761
+	 */
+	public function test_unregister_post_type_twice() {
+		register_post_type( 'foo' );
+		$this->assertTrue( unregister_post_type( 'foo' ) );
+		$this->assertFalse( unregister_post_type( 'foo' ) );
+	}
+
+	/**
+	 * @ticket 14761
+	 */
+	public function test_unregister_post_type_disallow_builtin_post_type() {
+		$this->assertFalse( unregister_post_type( 'post' ) );
+	}
+
+	/**
+	 * @ticket 14761
+	 */
+	public function test_unregister_post_type_removes_query_vars() {
+		global $wp;
+
+		register_post_type( 'foo', array(
+			'public'    => true,
+			'query_var' => 'bar',
+		) );
+
+		$this->assertInternalType( 'int', array_search( 'bar', $wp->public_query_vars ) );
+		$this->assertTrue( unregister_post_type( 'foo' ) );
+		$this->assertFalse( array_search( 'bar', $wp->public_query_vars ) );
+	}
+
+	/**
+	 * @ticket 14761
+	 */
+	public function test_unregister_post_type_removes_rewrite_rules() {
+		$this->set_permalink_structure( '/%postname%' );
+
+		global $wp_rewrite;
+
+		register_post_type( 'foo', array(
+			'public'    => true,
+			'query_var' => 'bar',
+		) );
+
+		$count_before = count( $wp_rewrite->rewritereplace );
+
+		$this->assertInternalType( 'int', array_search( '%foo%', $wp_rewrite->rewritecode ) );
+		$this->assertInternalType( 'int', array_search( 'bar=', $wp_rewrite->queryreplace ) );
+		$this->assertTrue( unregister_post_type( 'foo' ) );
+		$this->assertFalse( array_search( '%foo%', $wp_rewrite->rewritecode ) );
+		$this->assertFalse( array_search( 'bar=', $wp_rewrite->queryreplace ) );
+		$this->assertSame( --$count_before, count( $wp_rewrite->rewritereplace ) ); // Array was reduced by one value.
+	}
+
+	/**
+	 * @ticket 14761
+	 */
+	public function test_unregister_post_type_removes_custom_meta_capabilities() {
+		global $post_type_meta_caps;
+
+		register_post_type( 'foo', array(
+			'public' => true,
+			'capability_type' => 'bar',
+		) );
+
+		$post_type_args = get_post_type_object( 'foo' );
+		$this->assertTrue( unregister_post_type( 'foo' ) );
+
+		foreach ( $post_type_args->cap as $cap ) {
+			$this->assertFalse( isset( $post_type_meta_caps[ $cap ] ) );
+		}
+	}
+
+	/**
+	 * @ticket 14761
+	 */
+	public function test_unregister_post_type_removes_post_type_supports() {
+		global $_wp_post_type_features;
+
+		register_post_type( 'foo', array(
+			'public'   => true,
+			'supports' => array( 'editor', 'author', 'title' ),
+		) );
+
+		$this->assertSame( 3, count( $_wp_post_type_features['foo'] ) );
+		$this->assertTrue( unregister_post_type( 'foo' ) );
+		$this->assertFalse( isset( $_wp_post_type_features['foo'] ) );
+	}
+
+	/**
+	 * @ticket 14761
+	 */
+	public function test_unregister_post_type_removes_post_type_from_taxonomies() {
+		global $wp_taxonomies;
+
+		register_post_type( 'foo', array(
+			'public'   => true,
+			'taxonomies' => array( 'category', 'post_tag' ),
+		) );
+
+		$this->assertInternalType( 'int', array_search( 'foo', $wp_taxonomies['category']->object_type, true ) );
+		$this->assertInternalType( 'int', array_search( 'foo', $wp_taxonomies['post_tag']->object_type, true ) );
+		$this->assertTrue( unregister_post_type( 'foo' ) );
+		$this->assertFalse( array_search( 'foo', $wp_taxonomies['category']->object_type, true ) );
+		$this->assertFalse( array_search( 'foo', $wp_taxonomies['post_tag']->object_type, true ) );
+	}
+
+	/**
+	 * @ticket 14761
+	 */
+	public function test_unregister_post_type_removes_the_future_post_hooks() {
+		global $wp_filter;
+
+		register_post_type( 'foo', array(
+			'public' => true,
+		) );
+
+		add_action( 'future_foo', 'var_dump' );
+
+		$this->assertSame( 2, count( $wp_filter['future_foo'] ) );
+		$this->assertTrue( unregister_post_type( 'foo' ) );
+		$this->assertSame( array(), $wp_filter['future_foo'] );
+	}
+
+	/**
+	 * @ticket 14761
+	 */
+	public function test_unregister_post_type_removes_meta_boxes() {
+		global $wp_filter;
+
+		register_post_type( 'foo', array(
+			'public' => true,
+		) );
+
+		add_action( 'add_meta_boxes_foo', 'var_dump' );
+
+		$this->assertSame( 1, count( $wp_filter['add_meta_boxes_foo'] ) );
+		$this->assertTrue( unregister_post_type( 'foo' ) );
+		$this->assertSame( array(), $wp_filter['add_meta_boxes_foo'] );
+	}
+
+	/**
+	 * @ticket 14761
+	 */
+	public function test_unregister_post_type_removes_post_type_from_global() {
+		global $wp_post_types;
+
+		register_post_type( 'foo', array(
+			'public' => true,
+		) );
+
+		$this->assertInternalType( 'object', $wp_post_types['foo'] );
+		$this->assertInternalType( 'object', get_post_type_object( 'foo' ) );
+
+		$this->assertTrue( unregister_post_type( 'foo' ) );
+
+		$this->assertFalse( isset( $wp_post_types['foo'] ) );
+		$this->assertNull( get_post_type_object( 'foo' ) );
 	}
 }
diff --git tests/phpunit/tests/post/wpUniquePostSlug.php tests/phpunit/tests/post/wpUniquePostSlug.php
index 354997e..46caccc 100644
--- tests/phpunit/tests/post/wpUniquePostSlug.php
+++ tests/phpunit/tests/post/wpUniquePostSlug.php
@@ -61,8 +61,8 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
 		$this->assertEquals( 'some-other-slug', wp_unique_post_slug( 'some-other-slug', $one, 'publish', 'post-type-1', 0 ) );
 		$this->assertEquals( 'some-other-slug', wp_unique_post_slug( 'some-other-slug', $one, 'publish', 'post-type-2', 0 ) );
 
-		_unregister_post_type( 'post-type-1' );
-		_unregister_post_type( 'post-type-2' );
+		unregister_post_type( 'post-type-1' );
+		unregister_post_type( 'post-type-2' );
 	}
 
 	/**
@@ -85,7 +85,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
 
 		$this->assertEquals( 'some-slug-3', wp_unique_post_slug( 'some-slug', 0, 'publish', 'post-type-1', 0 ) );
 
-		_unregister_post_type( 'post-type-1' );
+		unregister_post_type( 'post-type-1' );
 	}
 
 	/**
@@ -123,7 +123,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
 		// 'image' can be a child of image-2
 		$this->assertEquals( 'image', wp_unique_post_slug( 'image', 0, 'publish', 'post-type-1', $two ) );
 
-		_unregister_post_type( 'post-type-1' );
+		unregister_post_type( 'post-type-1' );
 	}
 
 	/**
diff --git tests/phpunit/tests/query/search.php tests/phpunit/tests/query/search.php
index caf862c..5deb7f2 100644
--- tests/phpunit/tests/query/search.php
+++ tests/phpunit/tests/query/search.php
@@ -18,7 +18,7 @@ class Tests_Query_Search extends WP_UnitTestCase {
 	}
 
 	function tearDown() {
-		_unregister_post_type( $this->post_type );
+		unregister_post_type( $this->post_type );
 		unset( $this->q );
 
 		parent::tearDown();
diff --git tests/phpunit/tests/rewrite.php tests/phpunit/tests/rewrite.php
index 1f7426e..15956e5 100644
--- tests/phpunit/tests/rewrite.php
+++ tests/phpunit/tests/rewrite.php
@@ -131,7 +131,7 @@ class Tests_Rewrite extends WP_UnitTestCase {
 		$id = self::factory()->post->create( array( 'post_type' => $post_type ) );
 		$this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
 
-		_unregister_post_type( $post_type );
+		unregister_post_type( $post_type );
 	}
 
 	function test_url_to_postid_hierarchical() {
@@ -236,7 +236,7 @@ class Tests_Rewrite extends WP_UnitTestCase {
 
 		$this->go_to( $url );
 
-		_unregister_post_type( 'foo' );
+		unregister_post_type( 'foo' );
 
 		$this->assertEquals( array(), $GLOBALS['wp']->query_vars );
 	}
diff --git tests/phpunit/tests/taxonomy.php tests/phpunit/tests/taxonomy.php
index 2063bbe..ecb35fc 100644
--- tests/phpunit/tests/taxonomy.php
+++ tests/phpunit/tests/taxonomy.php
@@ -235,7 +235,7 @@ class Tests_Taxonomy extends WP_UnitTestCase {
 		$this->assertFalse( unregister_taxonomy_for_object_type( $tax, 'user' ) );
 
 		unset($GLOBALS['wp_taxonomies'][$tax]);
-		_unregister_post_type( $post_type );
+		unregister_post_type( $post_type );
 
 	}
 
@@ -408,7 +408,7 @@ class Tests_Taxonomy extends WP_UnitTestCase {
 		) );
 
 		$this->assertEqualSets( array( $p2, $p1 ), get_ancestors( $p3, 'wptests_pt' ) );
-		_unregister_post_type( 'wptests_pt' );
+		unregister_post_type( 'wptests_pt' );
 	}
 
 	/**
@@ -440,7 +440,7 @@ class Tests_Taxonomy extends WP_UnitTestCase {
 		$this->assertEqualSets( array( $p1 ), get_ancestors( $p2, 'wptests_conflict', 'post_type' ) );
 		$this->assertEqualSets( array( $t1 ), get_ancestors( $t2, 'wptests_conflict', 'taxonomy' ) );
 		$this->assertEqualSets( array( $t1 ), get_ancestors( $t2, 'wptests_conflict' ) );
-		_unregister_post_type( 'wptests_pt' );
+		unregister_post_type( 'wptests_pt' );
 	}
 
 	/**
diff --git tests/phpunit/tests/user/author.php tests/phpunit/tests/user/author.php
index 73ae3b6..f00af82 100644
--- tests/phpunit/tests/user/author.php
+++ tests/phpunit/tests/user/author.php
@@ -98,7 +98,7 @@ class Tests_User_Author_Template extends WP_UnitTestCase {
 
 		$this->assertEquals( 2, get_the_author_posts() );
 
-		_unregister_post_type( 'wptests_pt' );
+		unregister_post_type( 'wptests_pt' );
 	}
 
 	/**
diff --git tests/phpunit/tests/user/capabilities.php tests/phpunit/tests/user/capabilities.php
index 1316c17..183fed0 100644
--- tests/phpunit/tests/user/capabilities.php
+++ tests/phpunit/tests/user/capabilities.php
@@ -760,7 +760,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
 		$something = get_post_type_object( 'something' );
 		$this->assertEquals( 'draw_somethings', $something->cap->edit_posts );
 		$this->assertEquals( 'create_somethings', $something->cap->create_posts );
-		_unregister_post_type( 'something' );
+		unregister_post_type( 'something' );
 
 		// Test meta authorization callbacks
 		if ( function_exists( 'register_meta') ) {
@@ -845,7 +845,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
 		$this->assertTrue($author_2->has_cap( $cap->create_posts ));
 		$this->assertTrue($contributor->has_cap( $cap->create_posts ));
 
-		_unregister_post_type( 'foobar' );
+		unregister_post_type( 'foobar' );
 
 		// Primitive capability edit_foobars is not assigned to any users.
 		register_post_type( 'foobar', array( 'capability_type' => array( 'foobar', 'foobars' ) ) );
@@ -868,7 +868,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
 		$this->assertFalse($author_2->has_cap( $cap->create_posts ));
 		$this->assertFalse($contributor->has_cap( $cap->create_posts ));
 
-		_unregister_post_type( 'foobar' );
+		unregister_post_type( 'foobar' );
 
 		$cap = get_post_type_object( 'attachment' )->cap;
 		$this->assertEquals( 'upload_files', $cap->create_posts );
@@ -1116,7 +1116,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
 	function test_require_edit_others_posts_if_post_type_doesnt_exist() {
 		register_post_type( 'existed' );
 		$post_id = self::factory()->post->create( array( 'post_type' => 'existed' ) );
-		_unregister_post_type( 'existed' );
+		unregister_post_type( 'existed' );
 
 		$subscriber_id = self::$users['subscriber']->ID;
 		$editor_id = self::$users['editor']->ID;
@@ -1175,7 +1175,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
 		$this->assertFalse( user_can( $author->ID, 'edit_post', $author_post->ID ) );
 		$this->assertFalse( user_can( $contributor->ID, 'edit_post', $author_post->ID ) );
 
-		_unregister_post_type( 'page_capability' );
+		unregister_post_type( 'page_capability' );
 
 	}
 
diff --git tests/phpunit/tests/user/countUserPosts.php tests/phpunit/tests/user/countUserPosts.php
index bc91ceb..3ff92ef 100644
--- tests/phpunit/tests/user/countUserPosts.php
+++ tests/phpunit/tests/user/countUserPosts.php
@@ -27,7 +27,7 @@ class Tests_User_CountUserPosts extends WP_UnitTestCase {
 			'post_author' => 12345,
 			'post_type'   => 'wptests_pt',
 		) ) );
-		
+
 		self::$post_ids[] = $factory->post->create( array(
 			'post_author' => 12345,
 			'post_type'   => 'wptests_pt',
@@ -48,7 +48,7 @@ class Tests_User_CountUserPosts extends WP_UnitTestCase {
 	}
 
 	public function tearDown() {
-		_unregister_post_type( 'wptests_pt' );
+		unregister_post_type( 'wptests_pt' );
 		parent::tearDown();
 	}
 
diff --git tests/phpunit/tests/xmlrpc/wp/getPostType.php tests/phpunit/tests/xmlrpc/wp/getPostType.php
index a00dbda..450ed36 100644
--- tests/phpunit/tests/xmlrpc/wp/getPostType.php
+++ tests/phpunit/tests/xmlrpc/wp/getPostType.php
@@ -24,7 +24,7 @@ class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase {
 	}
 
 	function tearDown() {
-		_unregister_post_type( $this->cpt_name );
+		unregister_post_type( $this->cpt_name );
 
 		parent::tearDown();
 	}
diff --git tests/phpunit/tests/xmlrpc/wp/getPosts.php tests/phpunit/tests/xmlrpc/wp/getPosts.php
index 3d8dff4..bdd2dba 100644
--- tests/phpunit/tests/xmlrpc/wp/getPosts.php
+++ tests/phpunit/tests/xmlrpc/wp/getPosts.php
@@ -104,7 +104,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase {
 		$this->assertEquals( 1, count( $results3 ) );
 		$this->assertEquals( $post->ID, $results3[0]['post_id'] );
 
-		_unregister_post_type( $cpt_name );
+		unregister_post_type( $cpt_name );
 	}
 
 	function test_fields() {
@@ -152,4 +152,4 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase {
 		$this->assertEquals( 1, count( $results ) );
 	}
 
-}
\ No newline at end of file
+}
