当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_delete_category函数代码示例

本文整理汇总了PHP中wp_delete_category函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_delete_category函数的具体用法?PHP wp_delete_category怎么用?PHP wp_delete_category使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_delete_category函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wpTearDownAfterClass

 /**
  * Destroy the user we created and related posts.
  */
 public static function wpTearDownAfterClass()
 {
     // Delete our user
     self::delete_user(self::$user_id);
     // Delete all of our posts
     foreach (self::$posts as $post) {
         wp_delete_post($post, true);
     }
     // Delete our taxonomy
     wp_delete_category(self::$category->term_id);
 }
开发者ID:pbearne,项目名称:contrib2core,代码行数:14,代码来源:rss2.php

示例2: delete_categories

 function delete_categories($id)
 {
     $args = array('hide_empty' => 0, 'child_of' => $id);
     $child_categories = get_categories($args);
     if (!empty($child_categories)) {
         foreach ($child_categories as $child_category) {
             self::delete_categories($child_category->term_id);
         }
     }
     wp_delete_category($id);
 }
开发者ID:pgogy,项目名称:WordPress-MOLIE,代码行数:11,代码来源:molie-course-delete.php

示例3: testDeleteCategory

 function testDeleteCategory()
 {
     update_option('default_category', 1);
     add_category(1, (object) array('slug' => 'test'));
     add_category(2, (object) array('slug' => 'test-2'));
     $this->assertFalse(wp_delete_category(1));
     $this->assertTrue(wp_delete_category(2));
     $result = get_category(1);
     $this->assertTrue(isset($result->term_id));
     $result = get_category(2);
     $this->assertFalse(isset($result->term_id));
 }
开发者ID:rgeyer,项目名称:mockpress,代码行数:12,代码来源:MockPressTest.php

示例4: test_orphan_category

	/**
	 * @ticket 19205
	 */
	function test_orphan_category() {
		$cat_id1 = $this->factory->category->create();

		wp_delete_category( $cat_id1 );

		$cat_id2 = $this->factory->category->create( array( 'parent' => $cat_id1 ) );
		$this->assertWPError( $cat_id2 );
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:11,代码来源:term.php

示例5: _wp_ajax_delete_comment_response

     if ($r) {
         // Decide if we need to send back '1' or a more complicated response including page links and comment counts
         _wp_ajax_delete_comment_response($comment->comment_ID);
     }
     die('0');
     break;
 case 'delete-cat':
     check_ajax_referer("delete-category_{$id}");
     if (!current_user_can('manage_categories')) {
         die('-1');
     }
     $cat = get_category($id);
     if (!$cat || is_wp_error($cat)) {
         die('1');
     }
     if (wp_delete_category($id)) {
         die('1');
     } else {
         die('0');
     }
     break;
 case 'delete-tag':
     $tag_id = (int) $_POST['tag_ID'];
     check_ajax_referer("delete-tag_{$tag_id}");
     if (!current_user_can('manage_categories')) {
         die('-1');
     }
     $taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
     $tag = get_term($tag_id, $taxonomy);
     if (!$tag || is_wp_error($tag)) {
         die('1');
开发者ID:nagyist,项目名称:laura-wordpress,代码行数:31,代码来源:admin-ajax.php

示例6: cpm_action_build_storyline_schema

function cpm_action_build_storyline_schema()
{
    global $cpm_config;
    update_option('comicpress-enable-storyline-support', isset($_POST['enable-storyline-support']) ? 1 : 0);
    update_option('comicpress-storyline-show-top-category', isset($_POST['show-top-category']) ? 1 : 0);
    if (isset($_POST['enable-storyline-support'])) {
        $cpm_config->is_cpm_modifying_categories = true;
        $categories_to_create = array();
        $categories_to_rename = array();
        $category_ids_to_clean = array();
        extract(cpm_get_all_comic_categories());
        $comic_posts = cpm_query_posts();
        $comic_posts_by_category_id = array();
        foreach ($comic_posts as $post) {
            foreach (wp_get_post_categories($post->ID) as $category) {
                if (!isset($comic_posts_by_category_id[$category])) {
                    $comic_posts_by_category_id[$category] = array();
                }
                $comic_posts_by_category_id[$category][] = $post->ID;
            }
        }
        foreach ($_POST as $field => $value) {
            $value = stripslashes($value);
            $parts = explode("/", $field);
            if ($parts[0] == "0" && count($parts) > 1) {
                $category_id = end($parts);
                $category = get_category($category_id);
                if (!empty($category)) {
                    $category = (array) $category;
                    if ($category['cat_name'] != $value) {
                        $cpm_config->messages[] = sprintf(__('Category <strong>%1$s</strong> renamed to <strong>%2$s</strong>.', 'comicpress-manager'), $category['cat_name'], $value);
                        $category['cat_name'] = $value;
                        wp_update_category($category);
                        $category_ids_to_clean[] = $category_id;
                    }
                } else {
                    $categories_to_create[$field] = $value;
                }
                if (($index = array_search($field, $category_tree)) !== false) {
                    array_splice($category_tree, $index, 1);
                }
            }
        }
        if (isset($_POST['original-categories'])) {
            foreach (explode(",", $_POST['original-categories']) as $node) {
                if (!isset($_POST[$node])) {
                    $category_id = end(explode("/", $node));
                    $category = get_category($category_id);
                    $original_cat_name = $category->cat_name;
                    // ensure that we're not deleting a ComicPress category
                    $ok = true;
                    foreach (array('comiccat', 'blogcat') as $type) {
                        if ($category_id == $cpm_config->properties[$type]) {
                            $ok = false;
                        }
                    }
                    // ensure that the category truly is a child of the comic category
                    if ($ok) {
                        $category = get_category($category_id);
                        $ok = false;
                        if (!is_wp_error($category)) {
                            while ($category->parent != 0 && $category->parent != $cpm_config->properties['comiccat']) {
                                $category = get_category($category->parent);
                            }
                            if ($category->parent == $cpm_config->properties['comiccat']) {
                                $ok = true;
                            }
                        }
                    }
                    if ($ok) {
                        wp_delete_category($category_id);
                        $category_ids_to_clean[] = $category_id;
                        $cpm_config->messages[] = sprintf(__('Category <strong>%s</strong> deleted.', 'comicpress-manager'), $original_cat_name);
                    }
                }
            }
        }
        uksort($categories_to_create, 'cpm_sort_category_keys_by_length');
        $changed_field_ids = array();
        $removed_field_ids = array();
        $target_category_ids = array();
        foreach ($categories_to_create as $field => $value) {
            $original_field = $field;
            foreach ($changed_field_ids as $changed_field => $new_field) {
                if (strpos($field, $changed_field) === 0 && strlen($field) > strlen($changed_field)) {
                    $field = str_replace($changed_field, $new_field, $field);
                    break;
                }
            }
            $parts = explode("/", $field);
            $target_id = array_pop($parts);
            $parent_id = array_pop($parts);
            if (!category_exists($value)) {
                $category_id = wp_create_category($value, $parent_id);
                $category_ids_to_clean[] = $category_id;
                array_push($parts, $parent_id);
                array_push($parts, $category_id);
                $changed_field_ids[$original_field] = implode("/", $parts);
                $cpm_config->messages[] = sprintf(__('Category <strong>%s</strong> created.', 'comicpress-manager'), $value);
            } else {
//.........这里部分代码省略.........
开发者ID:johnbintz,项目名称:comicpress-manager-1.4,代码行数:101,代码来源:comicpress_build-storyline-schema.php

示例7: wp_deleteCategory

 /**
  * Remove category.
  *
  * @since 2.5.0
  *
  * @param array $args Method parameters.
  * @return mixed See {@link wp_delete_category()} for return info.
  */
 function wp_deleteCategory($args)
 {
     $this->escape($args);
     $blog_id = (int) $args[0];
     $username = $args[1];
     $password = $args[2];
     $category_id = (int) $args[3];
     if (!$this->login_pass_ok($username, $password)) {
         return $this->error;
     }
     do_action('xmlrpc_call', 'wp.deleteCategory');
     set_current_user(0, $username);
     if (!current_user_can("manage_categories")) {
         return new IXR_Error(401, __("Sorry, you do not have the right to delete a category."));
     }
     return wp_delete_category($category_id);
 }
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:25,代码来源:xmlrpc.php

示例8: remove_category

 private function remove_category($params)
 {
     $inserted_install = get_theme_mod('exclusive_install_posts', '');
     if (isset($inserted_install[$params['spec_id']])) {
         $sucsses = wp_delete_category($inserted_install[$params['spec_id']]);
         if ($sucsses) {
             unset($inserted_install[$params['spec_id']]);
             set_theme_mod('exclusive_install_posts', $inserted_install);
             return 1;
         } else {
             if (get_category($inserted_install[$params['spec_id']])) {
                 return '<div class="error_text">Error Remove</div>';
             } else {
                 unset($inserted_install[$params['spec_id']]);
                 set_theme_mod('exclusive_install_posts', $inserted_install);
                 return '<div class="notification_text">Not Found</div>';
             }
         }
     } else {
         return '<div class="notification_text">Not Found</div>';
     }
 }
开发者ID:ssxenon01,项目名称:exclusive,代码行数:22,代码来源:install_sampl_date.php

示例9: wpmu_create_blog

} else {
    $id = wpmu_create_blog($hostname, "/" . $site['slug'], $site['name'], 1, $options, 1);
}
$wpdb->show_errors();
if (!is_wp_error($id)) {
    //doing a normal flush rules will not work, just delete the rewrites
    switch_to_blog($id);
    // we delete the rewrites because flushing them does not work if the originally
    // loaded blog is the main one, deleteing them will force a propper flush on that site's first page.
    delete_option('rewrite_rules');
    // Delete the first post
    wp_delete_post(1, true);
    // Delete the about page
    wp_delete_post(2, true);
    //Configure categories
    wp_delete_category(1);
    $inserted_cats = array();
    foreach ($categories as $cat) {
        $cat_id = wp_insert_category($cat);
        $inserted_cats[$cat_id] = $cat;
    }
    // Create the Section Menu
    $menu_id = wp_create_nav_menu('Main', array('slug' => 'main'));
    // Assign it to the sections theme location
    $theme = get_current_theme();
    $mods = get_option('mods_' . $theme);
    $mods['nav_menu_locations']['sections'] = $menu_id;
    update_option('mods_' . $theme, $mods);
    // Create the menu items
    foreach ($inserted_cats as $cat_id => $cat) {
        if (in_array($cat['cat_name'], $section_nav)) {
开发者ID:newsapps,项目名称:wordpress-deploy,代码行数:31,代码来源:na-createblog.php

示例10: remove

 static function remove()
 {
     $td_stacks_demo_categories_id = get_option('td_demo_categories_id');
     if (is_array($td_stacks_demo_categories_id)) {
         foreach ($td_stacks_demo_categories_id as $td_stacks_demo_category_id) {
             wp_delete_category($td_stacks_demo_category_id);
         }
     }
 }
开发者ID:Che234,项目名称:andreatelo,代码行数:9,代码来源:td_demo_util.php

示例11: test_multi_facet_and

 /**
  * Test to see if a two facets can be selected with the AND operator.
  * Should yield zero results.
  * @group 37
  */
 function test_multi_facet_and()
 {
     $this->__change_option('s4wp_default_operator', 'AND');
     $this->__change_option('s4wp_facet_on_custom_fields', array('my_field'));
     $this->__change_option('s4wp_index_custom_fields', array('my_field'));
     $cat_id_one = wp_create_category('new_cat');
     $cat_id_two = wp_create_category('smelly_cat');
     $p_id = $this->__create_test_post();
     update_post_meta($p_id, 'my_field', 'my_value');
     wp_set_object_terms($p_id, $cat_id_one, 'category', true);
     $p_id_two = $this->__create_test_post();
     wp_set_object_terms($p_id_two, $cat_id_two, 'category', true);
     SolrPower_Sync::get_instance()->load_all_posts(0, 'post', 100, false);
     $query = $this->__facet_query(array('facet' => array('my_field_str' => array('my_value'), 'categories' => array('smelly_cat^^'))));
     // This should return zero results because the result cannot contain both the custom field and the category.
     $this->assertEquals(0, $query->post_count);
     $this->assertEquals(0, $query->found_posts);
     wp_delete_category($cat_id_one);
     wp_delete_category($cat_id_two);
 }
开发者ID:allan23,项目名称:solr-for-wordpress-on-pantheon,代码行数:25,代码来源:test-solr.php

示例12: test_wp_insert_delete_category

	function test_wp_insert_delete_category() {
		$term = rand_str();
		$this->assertNull( category_exists( $term ) );

		$initial_count = wp_count_terms( 'category' );

		$t = wp_insert_category( array( 'cat_name' => $term ) );
		$this->assertTrue( is_numeric($t) );
		$this->assertFalse( is_wp_error($t) );
		$this->assertTrue( $t > 0 );
		$this->assertEquals( $initial_count + 1, wp_count_terms( 'category' ) );

		// make sure the term exists
		$this->assertTrue( term_exists($term) > 0 );
		$this->assertTrue( term_exists($t) > 0 );

		// now delete it
		$this->assertTrue( wp_delete_category($t) );
		$this->assertNull( term_exists($term) );
		$this->assertNull( term_exists($t) );
		$this->assertEquals( $initial_count, wp_count_terms('category') );
	}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:22,代码来源:term.php

示例13: pp_delete_project

function pp_delete_project($project_id)
{
    if (true !== wp_delete_category($project_id)) {
        return false;
    }
    delete_option('pp_project_meta_' . $project_id);
    return true;
}
开发者ID:rmccue,项目名称:wordpress-unit-tests,代码行数:8,代码来源:functions-admin.php

示例14: the_theme_setup

function the_theme_setup()
{
    require_once ABSPATH . 'wp-config.php';
    require_once ABSPATH . 'wp-includes/wp-db.php';
    require_once ABSPATH . 'wp-admin/includes/taxonomy.php';
    include_once ABSPATH . 'wp-admin/includes/plugin.php';
    // damn twenty twelve name had a space and is capitalized
    // i would use wp_current_theme, but twenty twelve screwed me
    $theme_name = get_option('template');
    // First we check to see if our default theme settings have been applied.
    $the_theme_status = get_option("theme_setup_status_{$theme_name}");
    if ($the_theme_status !== '1') {
        // value set to see if we include in the menu
        $categories = array('News' => 'true', 'Featured Media' => 'false', 'Gallery' => 'true', 'Spotlight' => 'false', 'Video' => 'false');
        // make an array for list of category ids
        $created_categories = array();
        foreach ($categories as $key => $value) {
            // this returns the cat id
            $term_id = term_exists($key, 'category');
            if ($term_id !== 0 && $term_id !== null) {
                // just get the id
                $created_categories[$key] = $term_id;
            } else {
                // cat doesnt exist so we make it
                $created_categories[$key] = wp_create_category($key);
            }
        }
        // Category 2
        update_option('default_category', $created_categories['News']);
        // delete the default category
        wp_delete_category(1);
        $pages = array('Bio', 'Contact', 'Tour');
        // ids of the
        $page_ids = array();
        foreach ($pages as $page) {
            // create new pages
            $post = array('comment_status' => 'closed', 'ping_status' => 'closed', 'post_content' => $page . ' page content goes here. Edit to make this go away', 'post_name' => $page, 'post_status' => 'publish', 'post_title' => $page, 'post_type' => 'page');
            // check to see if page doesnt already exist so we don't keep adding junk.
            //worked fine in local, but sandbox was acting up.
            $page_check = get_page_by_title($page);
            if (is_null($page_check)) {
                $page_ids[$page] = wp_insert_post($post);
            } else {
                $page_ids[$page] = $page_check->ID;
            }
        }
        // create main menu
        if (!is_nav_menu('main')) {
            $main_menu_slug = 'main-menu';
            $menu_title = 'main';
            // just create one menu
            //register_nav_menu( $main_menu_slug, $menu_title );
            if (!is_nav_menu($menu_title)) {
                $menu_id = wp_create_nav_menu($menu_title);
                $item = array('menu-item-type' => 'custom', 'menu-item-url' => site_url(), 'menu-item-title' => 'Home', 'menu-item-status' => 'publish');
                wp_update_nav_menu_item($menu_id, 0, $item);
                foreach ($pages as $page) {
                    $item = array('menu-item-object-id' => $page_ids[$page], 'menu-item-object' => 'page', 'menu-item-type' => 'post_type', 'menu-item-title' => $page, 'menu-item-status' => 'publish', 'menu-item-parent-id' => $menu_id);
                    wp_update_nav_menu_item($menu_id, 0, $item);
                }
                foreach ($categories as $key => $value) {
                    // do we include it in the menu?
                    if ($value == 'true') {
                        $item = array('menu-item-object-id' => $created_categories[$key], 'menu-item-object' => 'category', 'menu-item-type' => 'taxonomy', 'menu-item-title' => $key, 'menu-item-status' => 'publish', 'menu-item-parent-id' => $menu_id);
                        wp_update_nav_menu_item($menu_id, 0, $item);
                    }
                }
                $mods = get_option("theme_mods_{$theme_name}");
                //update mods with menu id at theme location
                $menu_locations = get_nav_menu_locations();
                foreach ($menu_locations as $menu_location => $description) {
                    $mods['nav_menu_locations'][$menu_location] = $menu_id;
                }
                update_option("theme_mods_{$theme_name}", $mods);
            }
        }
    } elseif ($the_theme_status === '1' and isset($_GET['activated'])) {
        $msg = '
		<div class="updated">
			<p>The ' . get_option('current_theme') . ' theme was successfully re-activated.</p>
		</div>';
        add_action('admin_notices', $c = create_function('', 'echo "' . addcslashes($msg, '"') . '";'));
    }
    update_option("theme_setup_status_{$theme_name}", '1');
}
开发者ID:aamirs332,项目名称:wordpress-demos,代码行数:85,代码来源:custom-menus.php

示例15: themify_undo_import_sample_content

/**
 * Undo demo setup and reverts back to state before importing the sample contents.
 * Does not remove post/pages that have been modified by the user.
 *
 * @since 1.7.6
 */
function themify_undo_import_sample_content()
{
    do_action('themify_before_demo_erase');
    themify_import_sample_content_setup();
    $import = new Themify_Import();
    $data = $import->parse(themify_get_sample_content_file());
    foreach ($data['categories'] as $cat) {
        $term_id = term_exists($cat['category_nicename'], 'category');
        if ($term_id) {
            if (is_array($term_id)) {
                $term_id = $term_id['term_id'];
            }
            if (isset($cat['term_id'])) {
                wp_delete_category($term_id);
            }
        }
    }
    foreach ($data['tags'] as $tag) {
        $term_id = term_exists($tag['tag_slug'], 'post_tag');
        if ($term_id) {
            if (is_array($term_id)) {
                $term_id = $term_id['term_id'];
            }
            if (isset($tag['term_id'])) {
                wp_delete_term($term_id, 'post_tag');
            }
        }
    }
    foreach ($data['terms'] as $term) {
        $term_id = term_exists($term['slug'], $term['term_taxonomy']);
        if ($term_id) {
            if (is_array($term_id)) {
                $term_id = $term_id['term_id'];
            }
            if (isset($term['term_id'])) {
                wp_delete_term($term_id, $term['term_taxonomy']);
            }
        }
    }
    foreach ($data['posts'] as $post) {
        $post_exists = post_exists($post['post_title'], '', $post['post_date']);
        if ($post_exists && get_post_type($post_exists) == $post['post_type']) {
            /* check if the post has not been modified since it was created */
            if ($post['post_date'] == get_post_field('post_modified', $post_exists)) {
                wp_delete_post($post_exists, true);
                // true: bypass trash
            }
        }
    }
    do_action('themify_after_demo_erase');
}
开发者ID:tchataigner,项目名称:palette,代码行数:57,代码来源:themify-utils.php


注:本文中的wp_delete_category函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。