コード例 #1
0
 public function tearDown()
 {
     unregister_post_type('cpt');
     unregister_taxonomy('taxo');
     $this->set_permalink_structure('');
     parent::tearDown();
 }
コード例 #2
0
ファイル: Storage.php プロジェクト: wells5609/wp-app
 /**
  * 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);
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 /**
  * 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]);
 }
コード例 #5
0
function _unregister_taxonomy($taxonomy_name)
{
    unregister_taxonomy($taxonomy_name);
}
コード例 #6
0
ファイル: taxonomy.php プロジェクト: dd32/wordpress.develop
 /**
  * @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'));
 }
コード例 #7
0
ファイル: Taxonomy.php プロジェクト: aaemnnosttv/silk
 /**
  * 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;
 }
コード例 #8
0
 /**
  * @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);
 }
コード例 #9
0
ファイル: TaxonomyTest.php プロジェクト: aaemnnosttv/silk
 /**
  * @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();
 }