public function tearDown() { unregister_post_type('cpt'); unregister_taxonomy('taxo'); $this->set_permalink_structure(''); parent::tearDown(); }
/** * Deletes a record from storage. * * @param \WordPress\Data\ModelInterface $model */ public function delete(ModelInterface $model) { if (!$model->name) { throw new \RuntimeException("Taxonomy must have 'name' field"); } $result = unregister_taxonomy($model->name); return !is_wp_error($result); }
public function test_register() { if (function_exists('unregister_taxonomy')) { unregister_taxonomy('attachment_tag'); } else { global $wp_taxonomies; unset($wp_taxonomies['attachment_tag']); } $tag = new Attachment_Tag(); $tag->register(); $tax = get_taxonomy('attachment_tag'); $this->assertObjectHasAttribute('name', $tax); }
/** * Unregisters the taxonomy. * * @since 1.0.0 * @access public */ public function unregister() { $slug = $this->get_slug(); if (function_exists('unregister_taxonomy')) { unregister_taxonomy($slug); return; } global $wp_taxonomies; $taxonomy_args = get_taxonomy($this->slug); if (!$taxonomy_args || $taxonomy_args->_builtin) { return; } remove_filter('wp_ajax_add-' . $this->slug, '_wp_ajax_add_hierarchical_term'); unset($wp_taxonomies[$this->slug]); }
function _unregister_taxonomy($taxonomy_name) { unregister_taxonomy($taxonomy_name); }
/** * @ticket 35227 */ public function test_taxonomy_does_not_exist_after_unregister_taxonomy() { register_taxonomy('foo', 'post'); $this->assertTrue(taxonomy_exists('foo')); unregister_taxonomy('foo'); $this->assertFalse(taxonomy_exists('foo')); }
/** * Unregister the taxonomy. * * @throws NonExistentTaxonomyException * @throws WP_ErrorException * * @return $this */ public function unregister() { if (!$this->exists($this->id())) { throw new NonExistentTaxonomyException(); } if (is_wp_error($error = unregister_taxonomy($this->id()))) { throw new WP_ErrorException($error); } return $this; }
/** * @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); }
/** * @test * @expectedException Silk\Taxonomy\Exception\NonExistentTaxonomyException */ public function it_blows_up_if_trying_to_unregister_a_nonexistent_taxonomy() { register_taxonomy('temp', []); $taxonomy = new Taxonomy(get_taxonomy('temp')); unregister_taxonomy('temp'); $taxonomy->unregister(); }