Example #1
0
 /**
  * Unregisters the menu.
  *
  * @throws RuntimeException If the Post Type cannot be unregistered.
  *
  * @see https://core.trac.wordpress.org/ticket/14761 #14761 (unregister_post_type()) – WordPress Trac
  */
 public function unregister()
 {
     // Introduced since WordPress 4.5.
     if (!$this->supportsUnregistration() || is_wp_error(unregister_post_type($this->getName()))) {
         throw new RuntimeException('Cannot unregister the Post Type.');
     }
 }
 public function tearDown()
 {
     unregister_post_type('cpt');
     unregister_taxonomy('taxo');
     $this->set_permalink_structure('');
     parent::tearDown();
 }
 /**
  * Set up.
  */
 function setUp()
 {
     parent::setUp();
     $GLOBALS['wp_customize'] = null;
     // WPCS: Global override ok.
     $this->plugin = get_plugin_instance();
     unregister_post_type(Post_Type::SLUG);
 }
 /**
  * @ticket 34113
  */
 public function test_admin_bar_has_no_archives_link_for_cpt_not_shown_in_admin_bar()
 {
     register_post_type('foo-non-public', array('public' => true, 'has_archive' => true, 'show_in_admin_bar' => false));
     set_current_screen('edit-foo-non-public');
     $wp_admin_bar = $this->get_standard_admin_bar();
     $node = $wp_admin_bar->get_node('archive');
     set_current_screen('front');
     unregister_post_type('foo-non-public');
     $this->assertNull($node);
 }
/**
 * Removes the post type and its taxonomy associations.
 */
function _unregister_post_type($cpt_name)
{
    unregister_post_type($cpt_name);
}
Example #6
0
function candy_vc_grid_elements_menu_removal()
{
    remove_submenu_page('vc-general', 'edit.php?post_type=vc_grid_item');
    //unregister posttype custom function
    if (!function_exists('unregister_post_type')) {
        function unregister_post_type($post_type)
        {
            global $wp_post_types;
            if (isset($wp_post_types[$post_type])) {
                unset($wp_post_types[$post_type]);
                return true;
            }
            return false;
        }
    }
    unregister_post_type('vc_grid_item');
}
 function test_do_not_sync_non_existant_post_types()
 {
     $args = array('public' => true, 'label' => 'unregister post type');
     register_post_type('unregister_post_type', $args);
     $post_id = $this->factory->post->create(array('post_type' => 'unregister_post_type'));
     unregister_post_type('unregister_post_type');
     $this->sender->do_sync();
     $synced_post = $this->server_replica_storage->get_post($post_id);
     $this->assertEquals('jetpack_sync_non_registered_post_type', $synced_post->post_status);
     $this->assertEquals('', $synced_post->post_content_filtered);
     $this->assertEquals('', $synced_post->post_excerpt_filtered);
     // Also works for post type that was never registed
     $post_id = $this->factory->post->create(array('post_type' => 'does_not_exist'));
     $this->sender->do_sync();
     $synced_post = $this->server_replica_storage->get_post($post_id);
     $this->assertEquals('jetpack_sync_non_registered_post_type', $synced_post->post_status);
     $this->assertEquals('', $synced_post->post_content_filtered);
     $this->assertEquals('', $synced_post->post_excerpt_filtered);
 }
 /**
  * @ticket 14761
  */
 public function test_post_type_does_not_exist_after_unregister_post_type()
 {
     register_post_type('foo', array('public' => true));
     $this->assertTrue(unregister_post_type('foo'));
     $this->assertFalse(post_type_exists('foo'));
 }
 function unregister_vc_grid_element()
 {
     unregister_post_type('vc_grid_item');
 }
 /**
  * @ticket 36343
  */
 public function test_tax_query_operator_not_exists_combined()
 {
     register_post_type('wptests_cpt1');
     register_taxonomy('wptests_tax1', 'wptests_cpt1');
     register_taxonomy('wptests_tax2', 'wptests_cpt1');
     $t1 = self::factory()->term->create(array('taxonomy' => 'wptests_tax1'));
     $t2 = self::factory()->term->create(array('taxonomy' => 'wptests_tax1'));
     $t3 = self::factory()->term->create(array('taxonomy' => 'wptests_tax2'));
     $p1 = self::factory()->post->create(array('post_type' => 'wptests_cpt1'));
     $p2 = self::factory()->post->create(array('post_type' => 'wptests_cpt1'));
     $p3 = self::factory()->post->create(array('post_type' => 'wptests_cpt1'));
     $p4 = self::factory()->post->create(array('post_type' => 'wptests_cpt1'));
     wp_set_object_terms($p1, array($t1), 'wptests_tax1');
     wp_set_object_terms($p2, array($t2), 'wptests_tax1');
     wp_set_object_terms($p3, array($t3), 'wptests_tax2');
     $q = new WP_Query(array('post_type' => 'wptests_cpt1', 'fields' => 'ids', 'tax_query' => array('relation' => 'OR', array('taxonomy' => 'wptests_tax1', 'operator' => 'NOT EXISTS'), array('taxonomy' => 'wptests_tax1', 'field' => 'slug', 'terms' => get_term_field('slug', $t1)))));
     unregister_post_type('wptests_cpt1');
     unregister_taxonomy('wptests_tax1');
     unregister_taxonomy('wptests_tax2');
     $this->assertEqualSets(array($p1, $p3, $p4), $q->posts);
 }
function unregister_gallery_post_type()
{
    unregister_post_type('galleries', array());
}
Example #12
0
 /**
  * @test
  * @expectedException Silk\PostType\Exception\NonExistentPostTypeException
  */
 function it_blows_up_if_it_tries_to_unregister_a_nonexistent_type()
 {
     $type = PostType::make('non-existent')->register();
     unregister_post_type('non-existent');
     $type->unregister();
 }
Example #13
0
 /**
  * Unregister the post type.
  *
  * @throws NonExistentPostTypeException
  * @throws WP_ErrorException
  *
  * @return $this
  */
 public function unregister()
 {
     $id = $this->id();
     if (!static::exists($id)) {
         throw new NonExistentPostTypeException("No post type exists with name '{$id}'.");
     }
     if (is_wp_error($error = unregister_post_type($id))) {
         throw new WP_ErrorException($error);
     }
     return $this;
 }
Example #14
0
function remove_custom_posts()
{
    unregister_post_type('event');
    unregister_post_type('press');
}