本文整理汇总了PHP中wp_insert_term函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_insert_term函数的具体用法?PHP wp_insert_term怎么用?PHP wp_insert_term使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_insert_term函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: check_recipe_taxonomies
/**
* Check if we have recipe taxonomies
*/
public function check_recipe_taxonomies()
{
$taxonomies = $this->get();
if (count($taxonomies) == 0) {
$taxonomies = $this->add_taxonomy_to_array($taxonomies, 'ingredient', __('Ingredients', 'wp-ultimate-recipe'), __('Ingredient', 'wp-ultimate-recipe'));
$taxonomies = $this->add_taxonomy_to_array($taxonomies, 'course', __('Courses', 'wp-ultimate-recipe'), __('Course', 'wp-ultimate-recipe'));
$taxonomies = $this->add_taxonomy_to_array($taxonomies, 'cuisine', __('Cuisines', 'wp-ultimate-recipe'), __('Cuisine', 'wp-ultimate-recipe'));
$this->update($taxonomies);
update_option('wpurp_flush', '1');
wp_insert_term(__('Breakfast', 'wp-ultimate-recipe'), 'course');
wp_insert_term(__('Appetizer', 'wp-ultimate-recipe'), 'course');
wp_insert_term(__('Soup', 'wp-ultimate-recipe'), 'course');
wp_insert_term(__('Main Course', 'wp-ultimate-recipe'), 'course');
wp_insert_term(__('Side Dish', 'wp-ultimate-recipe'), 'course');
wp_insert_term(__('Salad', 'wp-ultimate-recipe'), 'course');
wp_insert_term(__('Dessert', 'wp-ultimate-recipe'), 'course');
wp_insert_term(__('Snack', 'wp-ultimate-recipe'), 'course');
wp_insert_term(__('Drinks', 'wp-ultimate-recipe'), 'course');
wp_insert_term(__('French', 'wp-ultimate-recipe'), 'cuisine');
wp_insert_term(__('Italian', 'wp-ultimate-recipe'), 'cuisine');
wp_insert_term(__('Mediterranean', 'wp-ultimate-recipe'), 'cuisine');
wp_insert_term(__('Indian', 'wp-ultimate-recipe'), 'cuisine');
wp_insert_term(__('Chinese', 'wp-ultimate-recipe'), 'cuisine');
wp_insert_term(__('Japanese', 'wp-ultimate-recipe'), 'cuisine');
wp_insert_term(__('American', 'wp-ultimate-recipe'), 'cuisine');
wp_insert_term(__('Mexican', 'wp-ultimate-recipe'), 'cuisine');
}
}
开发者ID:mehshan,项目名称:wp-ultimate-recipe,代码行数:31,代码来源:taxonomies.php
示例2: add_source_default
public static function add_source_default()
{
global $wpdb;
if (empty(self::$source_list)) {
return false;
}
foreach (self::$source_list as $source) {
if (isset($source['name'])) {
$term = get_term_by('name', $source['name'], 'dln_source_cat');
if (empty($term)) {
$term = wp_insert_term(esc_sql($source['name']), 'dln_source_cat');
}
if (!empty($term->term_id) && isset($source['link'])) {
$links = $source['link'];
if (is_array($links)) {
foreach ($links as $i => $link) {
$sql = $wpdb->prepare("SELECT id from {$wpdb->dln_news_source} WHERE link = %s", esc_sql($link));
$exists = $wpdb->get_row($sql);
if (empty($exists)) {
$result = $wpdb->insert($wpdb->dln_news_source, array('term_id' => esc_sql($term->term_id), 'link' => esc_sql($link), 'source_type' => esc_sql($source['source_type']), 'tags' => esc_sql($source['tags']), 'type' => esc_sql($source['type'])));
}
if (is_wp_error($result)) {
var_dump($result);
}
}
}
}
}
}
exit;
}
开发者ID:httvncoder,项目名称:151722441,代码行数:31,代码来源:helper-source.php
示例3: _mla_ajax_add_flat_term
/**
* Add flat taxonomy term from "checklist" meta box on the Media Manager Modal Window
*
* Adapted from the WordPress post_categories_meta_box() in /wp-admin/includes/meta-boxes.php.
*
* @since 2.20
*
* @param string The taxonomy name, from $_POST['action']
*
* @return void Sends JSON response with updated HTML for the checklist
*/
private static function _mla_ajax_add_flat_term($key)
{
$taxonomy = get_taxonomy($key);
check_ajax_referer($_POST['action'], '_ajax_nonce-add-' . $key, true);
if (!current_user_can($taxonomy->cap->edit_terms)) {
wp_die(-1);
}
$new_names = explode(',', $_POST['new' . $key]);
$new_terms_markup = '';
foreach ($new_names as $name) {
if ('' === sanitize_title($name)) {
continue;
}
if (!($id = term_exists($name, $key))) {
$id = wp_insert_term($name, $key);
}
if (is_wp_error($id)) {
continue;
}
if (is_array($id)) {
$id = absint($id['term_id']);
} else {
continue;
}
$term = get_term($id, $key);
$name = $term->name;
$new_terms_markup .= "<li id='{$key}-{$id}'><label class='selectit'><input value='{$name}' type='checkbox' name='tax_input[{$key}][]' id='in-{$key}-{$id}' checked='checked' />{$name}</label></li>\n";
}
// foreach new_name
$input_new_parent_name = "new{$key}_parent";
$supplemental = "<input type='hidden' name='{$input_new_parent_name}' id='{$input_new_parent_name}' value='-1' />";
$add = array('what' => $key, 'id' => $id, 'data' => $new_terms_markup, 'position' => -1, 'supplemental' => array('newcat_parent' => $supplemental));
$x = new WP_Ajax_Response($add);
$x->send();
}
开发者ID:jonpetersen,项目名称:PHTC,代码行数:46,代码来源:class-mla-ajax.php
示例4: add_label
public function add_label()
{
$data = stripslashes_deep($_POST);
$post_id = !empty($data['post_id']) ? $data['post_id'] : false;
$post_ids = !empty($data['post_ids']) ? array_map('intval', $data['post_ids']) : array();
if ($post_id) {
$post_ids[] = $post_id;
}
$term = !empty($data['term']) ? $data['term'] : false;
if (!$term) {
$this->_out(new Upfront_JsonResponse_Error("No term"));
}
$res = wp_insert_term($term, 'media_label');
if (is_wp_error($res)) {
$this->_out(new Upfront_JsonResponse_Error("Something went wrong"));
}
if ($post_ids) {
$result = array();
foreach ($post_ids as $post_id) {
$label_objs = wp_get_object_terms($post_id, 'media_label');
$labels = array();
foreach ($label_objs as $label) {
$labels[] = (int) $label->term_id;
}
$labels[] = (int) $res['term_id'];
$result[$post_id] = wp_set_object_terms($post_id, $labels, 'media_label');
}
$this->_out(new Upfront_JsonResponse_Success($result));
} else {
$this->_out(new Upfront_JsonResponse_Success($res));
}
}
开发者ID:sedici,项目名称:wpmu-istec,代码行数:32,代码来源:class_upfront_media_server.php
示例5: dwqa_posttype_init
function dwqa_posttype_init()
{
global $dwqa_options;
extract(dwqa_get_rewrite_slugs());
/* Question Posttype Registration */
$question_labels = array('name' => __('Question', 'dwqa'), 'singular_name' => __('Question', 'dwqa'), 'add_new' => __('Add New', 'theme'), 'add_new_item' => __('Add New Question', 'dwqa'), 'edit_item' => __('Edit Question'), 'new_item' => __('New Question', 'dwqa'), 'all_items' => __('All Questions', 'dwqa'), 'view_item' => __('View Question', 'dwqa'), 'search_items' => __('Search Question', 'dwqa'), 'not_found' => __('No questions found', 'dwqa'), 'not_found_in_trash' => __('No questions found in Trash', 'dwqa'), 'parent_item_colon' => '', 'menu_name' => __('DW Q&A', 'dwqa'));
$question_args = array('labels' => $question_labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array('slug' => $question_rewrite, 'with_front' => false), 'has_archive' => true, 'hierarchical' => true, 'menu_icon' => '', 'supports' => array('title', 'editor', 'comments', 'author', 'page-attributes'));
register_post_type('dwqa-question', $question_args);
/* Question Posttype Registration */
$answer_labels = array('name' => __('Answer', 'dwqa'), 'singular_name' => __('Answer', 'dwqa'), 'add_new' => __('Add New', 'dwqa'), 'add_new_item' => __('Add new answer', 'dwqa'), 'edit_item' => __('Edit answer', 'dwqa'), 'new_item' => __('New Answer', 'dwqa'), 'all_items' => __('All Answers', 'dwqa'), 'view_item' => __('View Answer', 'dwqa'), 'search_items' => __('Search Answer', 'dwqa'), 'not_found' => __('No Answers found', 'dwqa'), 'not_found_in_trash' => __('No Answers found in Trash', 'dwqa'), 'parent_item_colon' => '', 'menu_name' => __('Answer', 'dwqa'));
$answer = array('labels' => $answer_labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => 'edit.php?post_type=dwqa-question', 'query_var' => true, 'rewrite' => true, 'has_archive' => false, 'hierarchical' => true, 'menu_icon' => '', 'supports' => array('title', 'editor', 'comments', 'custom-fields', 'author', 'page-attributes'));
register_post_type('dwqa-answer', $answer);
// Question Taxonomies ( Tag, Category register for Question Posttype)
// Question Categories
$question_category_labels = array('name' => _x('Categories', 'taxonomy general name'), 'singular_name' => _x('Category', 'taxonomy singular name'), 'search_items' => __('Search Categories', 'dwqa'), 'all_items' => __('All Categories', 'dwqa'), 'parent_item' => __('Parent Category', 'dwqa'), 'parent_item_colon' => __('Parent Category:', 'dwqa'), 'edit_item' => __('Edit Category', 'dwqa'), 'update_item' => __('Update Category', 'dwqa'), 'add_new_item' => __('Add New Category', 'dwqa'), 'new_item_name' => __('New Category Name', 'dwqa'), 'menu_name' => __('Question Categories', 'dwqa'));
register_taxonomy('dwqa-question_category', array('dwqa-question'), array('hierarchical' => true, 'labels' => $question_category_labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => $question_category_rewrite, 'with_front' => false)));
// Question Tags
$question_tag_labels = array('name' => _x('Tags', 'taxonomy general name'), 'singular_name' => _x('Tag', 'taxonomy singular name'), 'search_items' => __('Search Tags', 'dwqa'), 'popular_items' => __('Popular Tags', 'dwqa'), 'all_items' => __('All Tags', 'dwqa'), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __('Edit Tag', 'dwqa'), 'update_item' => __('Update Tag', 'dwqa'), 'add_new_item' => __('Add New Tag', 'dwqa'), 'new_item_name' => __('New Tag Name', 'dwqa'), 'separate_items_with_commas' => __('Separate tags with commas', 'dwqa'), 'add_or_remove_items' => __('Add or remove tags', 'dwqa'), 'choose_from_most_used' => __('Choose from the most used tags', 'dwqa'), 'menu_name' => __('Question Tags', 'dwqa'));
register_taxonomy('dwqa-question_tag', array('dwqa-question'), array('hierarchical' => false, 'labels' => $question_tag_labels, 'show_ui' => true, 'update_count_callback' => '_update_post_term_count', 'query_var' => true, 'rewrite' => array('slug' => $question_tag_rewrite, 'with_front' => false)));
// Create default category for dwqa question type when dwqa plugin is actived
$cats = get_categories(array('type' => 'dwqa-question', 'hide_empty' => 0, 'taxonomy' => 'dwqa-question_category'));
if (empty($cats)) {
wp_insert_term('Questions', 'dwqa-question_category');
}
// update term rewrite rule
dwqa_update_term_rewrite_rules();
}
开发者ID:douglaswebdesigns,项目名称:ask-bio-expert,代码行数:27,代码来源:dw-question-answer.php
示例6: processTaxonomy
private function processTaxonomy(&$taxonomy)
{
$currentTerms = get_terms($taxonomy->slug, array('hide_empty' => false));
$done = false;
while (!$done) {
$deferred = 0;
foreach ($taxonomy->terms as &$term) {
if (!$term->done) {
$parentId = $this->parentId($term->term->parent, $taxonomy);
if ($parentId || $term->term->parent == 0) {
$existingTermId = $this->findExistingTerm($term, $currentTerms);
$args = array('description' => $term->term->description, 'parent' => $parentId, 'slug' => $term->term->slug, 'term_group' => $term->term->term_group, 'name' => $term->term->name);
if ($existingTermId > 0) {
$ret = wp_update_term($existingTermId, $taxonomy->slug, $args);
$term->id = $existingTermId;
} else {
$id = wp_insert_term($term->term->name, $taxonomy->slug, $args);
$term->id = $id['term_id'];
}
$term->done = true;
} else {
++$deferred;
}
}
if ($deferred == 0) {
$done = true;
}
}
}
}
开发者ID:eriktorsner,项目名称:wp-bootstrap-ui,代码行数:30,代码来源:Pushtaxonomies.php
示例7: woocommerce_osc_run_cats
function woocommerce_osc_run_cats($parent = 0, $parent_term_id = 0)
{
global $wpdb, $oscdb, $import_cat_counter;
$categories = $oscdb->get_results("SELECT c.*, cd.* FROM categories c, categories_description cd WHERE c.categories_id=cd.categories_id AND cd.language_id=1 AND c.parent_id='" . (int) $parent . "'", ARRAY_A);
if (!empty($categories)) {
foreach ($categories as $category) {
if (!is_wp_error($category)) {
$term = term_exists($category['categories_name'], 'product_cat', (int) $parent_term_id);
// array is returned if taxonomy is given
if ((int) $term['term_id'] == 0) {
$term = wp_insert_term($category['categories_name'], 'product_cat', array('parent' => $parent_term_id));
delete_option('product_cat_children');
// clear the cache
$attach_id = 0;
if ($category['categories_image'] != '') {
$url = rtrim($_POST['store_url'], '/') . '/images/' . urlencode($category['categories_image']);
$attach_id = woocommerce_osc_import_image($url);
}
add_woocommerce_term_meta($term['term_id'], 'order', $category['sort_order']);
add_woocommerce_term_meta($term['term_id'], 'display_type', '');
add_woocommerce_term_meta($term['term_id'], 'thumbnail_id', (int) $attach_id);
add_woocommerce_term_meta($term['term_id'], 'osc_id', $category['categories_id']);
woocommerce_osc_run_cats($category['categories_id'], $term['term_id']);
$import_cat_counter++;
} else {
woocommerce_osc_run_cats($category['categories_id'], $term['term_id']);
}
}
}
}
}
开发者ID:Korri,项目名称:woocommerce-etsy-importer,代码行数:31,代码来源:woocommerce-etsy-importer.php
示例8: un_do_db_upgrade
function un_do_db_upgrade()
{
global $un_default_options, $wp_roles, $wpdb;
$icons = array('idea' => 'icon-lightbulb', 'question' => 'icon-question-sign', 'problem' => 'icon-exclamation-sign', 'praise' => 'icon-heart');
$plural = array('idea' => __('Ideas', 'usernoise'), 'question' => __('Questions', 'usernoise'), 'problem' => __('Problems', 'usernoise'), 'praise' => __('Praises', 'usernoise'));
$index = 0;
$wpdb->un_termmeta = $wpdb->prefix . "un_termmeta";
if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->un_termmeta}'") != $wpdb->un_termmeta) {
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
$sql = "CREATE TABLE `{$wpdb->un_termmeta}` (\n\t\t\t`meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t`un_term_id` bigint(20) unsigned NOT NULL DEFAULT '0',\n\t\t\t`meta_key` varchar(255) DEFAULT NULL,\n\t\t\t`meta_value` longtext,\n\t\t\tPRIMARY KEY (`meta_id`),\n\t\t\tKEY `un_term_id` (`un_term_id`),\n\t\t\tKEY `meta_key` (`meta_key`)\n\t\t);";
dbDelta($sql);
}
foreach (array('idea' => __('Idea', 'usernoise'), 'question' => __('Question', 'usernoise'), 'problem' => __('Problem', 'usernoise'), 'praise' => __('Praise', 'usernoise')) as $type => $value) {
if (null == ($term = get_term_by('slug', $type, 'feedback_type', ARRAY_A))) {
$term = wp_insert_term($value, FEEDBACK_TYPE, array('slug' => $type));
}
if (null == un_get_term_meta($term['term_id'], 'icon')) {
un_add_term_meta($term['term_id'], 'icon', $icons[$type], true);
un_add_term_meta($term['term_id'], 'plural', $plural[$type], true);
un_add_term_meta($term['term_id'], 'position', $index, true);
}
$index++;
}
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
foreach (un_get_capable_roles() as $role) {
foreach (un_get_feedback_capabilities() as $cap) {
$wp_roles->add_cap($role, $cap);
}
}
update_option('un_db_revision', '2');
}
开发者ID:congtrieu112,项目名称:anime,代码行数:33,代码来源:db-upgrade.php
示例9: podcasting_install
/**
* Post installation procedures
*/
function podcasting_install()
{
# Setup the default taxonomy
wp_insert_term('Default Format', 'podcast_format');
# Add Podcasting options to the database
add_option('pod_title', get_option('blogname'), "The podcast's title");
add_option('pod_tagline', get_option('blogdescription'), "The podcast's tagline");
add_option('pod_disabled_enclose', false);
add_option('pod_itunes_summary', '', 'iTunes summary');
add_option('pod_itunes_author', '', 'iTunes author');
add_option('pod_itunes_image', '', 'iTunes image');
add_option('pod_itunes_cat1', '', 'iTunes category 1');
add_option('pod_itunes_cat2', '', 'iTunes category 2');
add_option('pod_itunes_cat3', '', 'iTunes category 3');
add_option('pod_itunes_keywords', '', 'iTunes keywords');
add_option('pod_itunes_explicit', '', 'iTunes explicit');
add_option('pod_itunes_new-feed-url', '', 'iTunes new feed url');
add_option('pod_itunes_ownername', '', 'iTunes owner name');
add_option('pod_itunes_owneremail', '', 'iTunes owner email');
add_option('pod_formats', '', 'Explict settings for podcast formats');
add_option('pod_player_flashvars', '', 'Podcasting player flashvars');
add_option('pod_audio_width', '290', 'Podcasting player width');
add_option('pod_player_use_video', 'no');
add_option('pod_player_location', '', '');
add_option('pod_player_text_above', '', '');
add_option('pod_player_text_before', '', '');
add_option('pod_player_text_below', '', '');
add_option('pod_player_text_link', '', '');
add_option('pod_player_width', '400', 'Podcast player width');
add_option('pod_player_height', '300', 'Podcast player height');
add_option('pod_video_flashvars', '', 'Podcasting video flashvars');
add_option('pod_accept_fail', 'no', 'Accept enclosure failure');
}
开发者ID:howardlei82,项目名称:IGSM-Website,代码行数:36,代码来源:podcasting.php
示例10: dt_geodir_default_taxonomies
function dt_geodir_default_taxonomies($post_type, $categories, $folder_name)
{
global $wpdb, $dummy_image_path;
$cat_count = count($categories);
for ($i = 0; $i < $cat_count; $i++) {
$parent_catid = 0;
if (is_array($categories[$i])) {
$cat_name_arr = $categories[$i];
$count_cat_name_arr = count($cat_name_arr);
for ($j = 0; $j < $count_cat_name_arr; $j++) {
$catname = $cat_name_arr[$j];
if (!term_exists($catname, $post_type . 'category')) {
$last_catid = wp_insert_term($catname, $post_type . 'category', $args = array('parent' => $parent_catid));
if ($j == 0) {
$parent_catid = $last_catid;
}
dt_geodir_insert_taxonomy($post_type, $catname, $folder_name, $last_catid);
}
}
} else {
$catname = $categories[$i];
if (!term_exists($catname, $post_type . 'category')) {
$last_catid = wp_insert_term($catname, $post_type . 'category');
dt_geodir_insert_taxonomy($post_type, $catname, $folder_name, $last_catid);
}
}
}
}
开发者ID:mistergiri,项目名称:directory-starter,代码行数:28,代码来源:dummy.php
示例11: categorize
private function categorize($post_id, $categories_str)
{
$categories_arr = explode(',', $categories_str);
foreach ($categories_arr as $category) {
$categories_par = explode('>', $category);
if (!isset($categories_par[0], $categories_par[1])) {
$this->err($category, $post_id);
}
$categories_par[0] = trim($categories_par[0]);
$categories_par[1] = trim($categories_par[1]);
$parent_term = term_exists($categories_par[0], 'venture_categories');
if (!$parent_term) {
$parent_term = wp_insert_term($categories_par[0], 'venture_categories');
}
$parent_term_id = intval($parent_term['term_id']);
$term = term_exists($categories_par[1], 'venture_categories', $parent_term_id);
if (!$term) {
$term = wp_insert_term($categories_par[1], 'venture_categories', array('parent' => $parent_term_id));
}
if (is_wp_error($term)) {
$this->err($category, $post_id);
}
$term_id = intval($term['term_id']);
wp_set_object_terms($post_id, $parent_term_id, 'venture_categories', true);
wp_set_object_terms($post_id, $term_id, 'venture_categories', true);
}
}
开发者ID:johnleesw,项目名称:mustardseedwp,代码行数:27,代码来源:Class_Import_Page.php
示例12: vtprd_add_dummy_rule_category
public function vtprd_add_dummy_rule_category()
{
$category_list = get_terms('vtprd_rule_category', 'hide_empty=0&parent=0');
if (count($category_list) == 0) {
wp_insert_term(__('Pricing Deals Category', 'vtprd'), 'vtprd_rule_category', "parent=0");
}
}
开发者ID:tleonard2,项目名称:durablegbFeb,代码行数:7,代码来源:vtprd-backbone.php
示例13: vtwpr_add_dummy_rule_category
public function vtwpr_add_dummy_rule_category()
{
$category_list = get_terms('vtwpr_rule_category', 'hide_empty=0&parent=0');
if (count($category_list) == 0) {
wp_insert_term(__('Wholesale Pricing Category', 'vtwpr'), 'vtwpr_rule_category', "parent=0");
}
}
开发者ID:sawan34,项目名称:tanzi,代码行数:7,代码来源:vtwpr-backbone.php
示例14: vtmin_add_dummy_rule_category
public function vtmin_add_dummy_rule_category()
{
$category_list = get_terms('vtmin_rule_category', 'hide_empty=0&parent=0');
if (count($category_list) == 0) {
wp_insert_term(__('Minimum Purchase Category', 'vtmin'), 'vtmin_rule_category', "parent=0");
}
}
开发者ID:kevinotsuka,项目名称:coffeecircle,代码行数:7,代码来源:vtmin-backbone.php
示例15: set_up_0_4_0_test_posts
function set_up_0_4_0_test_posts()
{
update_option('wp_gistpen_version', '0.3.1');
register_post_type('gistpens', array());
register_taxonomy('language', array('gistpens'));
foreach (Language::$supported as $lang => $slug) {
$result = wp_insert_term($lang, 'language', array('slug' => $slug));
if (is_wp_error($result)) {
throw new Exception("Failed to insert term.");
}
}
$terms = get_terms('language', 'hide_empty=0');
foreach ($terms as $term) {
$languages[] = $term->slug;
}
$num_posts = count($languages);
$this->gistpens = $this->factory->post->create_many($num_posts, array('post_type' => 'gistpens', 'post_status' => 'publish'), array('post_title' => new WP_UnitTest_Generator_Sequence('Post title %s'), 'post_name' => new WP_UnitTest_Generator_Sequence('Post title %s'), 'post_content' => new WP_UnitTest_Generator_Sequence('Post content %s')));
foreach ($this->gistpens as $gistpen_id) {
// Pick a random language
$num_posts = $num_posts - 1;
$lang_num = rand(0, $num_posts);
// Get the language's id
$lang_slug = $languages[$lang_num];
// Remove the language and reindex the languages array
unset($languages[$lang_num]);
$languages = array_values($languages);
// Give the post a description
update_post_meta($gistpen_id, '_wpgp_gistpen_description', 'This is a description of the Gistpen.');
// Give the post the language
wp_set_object_terms($gistpen_id, $lang_slug, 'language', false);
// Create and set up the user
$user_id = $this->factory->user->create(array('role' => 'administrator'));
wp_set_current_user($user_id);
}
}
开发者ID:petermac-,项目名称:WP-Gistpen,代码行数:35,代码来源:test-migration.php
示例16: avia_temp_products
function avia_temp_products()
{
if (post_type_exists('product')) {
return false;
}
$product_base = $base_slug = $category_base = "";
register_taxonomy('product_cat', array('product'), array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Categories', 'woothemes'), 'labels' => array('name' => __('Categories', 'woothemes'), 'singular_name' => __('Product Category', 'woothemes'), 'search_items' => __('Search Product Categories', 'woothemes'), 'all_items' => __('All Product Categories', 'woothemes'), 'parent_item' => __('Parent Product Category', 'woothemes'), 'parent_item_colon' => __('Parent Product Category:', 'woothemes'), 'edit_item' => __('Edit Product Category', 'woothemes'), 'update_item' => __('Update Product Category', 'woothemes'), 'add_new_item' => __('Add New Product Category', 'woothemes'), 'new_item_name' => __('New Product Category Name', 'woothemes')), 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => $category_base . _x('product-category', 'slug', 'woothemes'), 'with_front' => false)));
register_taxonomy('product_tag', array('product'), array('hierarchical' => false, 'label' => __('Tags', 'woothemes'), 'labels' => array('name' => __('Tags', 'woothemes'), 'singular_name' => __('Product Tag', 'woothemes'), 'search_items' => __('Search Product Tags', 'woothemes'), 'all_items' => __('All Product Tags', 'woothemes'), 'parent_item' => __('Parent Product Tag', 'woothemes'), 'parent_item_colon' => __('Parent Product Tag:', 'woothemes'), 'edit_item' => __('Edit Product Tag', 'woothemes'), 'update_item' => __('Update Product Tag', 'woothemes'), 'add_new_item' => __('Add New Product Tag', 'woothemes'), 'new_item_name' => __('New Product Tag Name', 'woothemes')), 'show_ui' => true, 'query_var' => true, 'rewrite' => array('slug' => $category_base . _x('product-tag', 'slug', 'woothemes'), 'with_front' => false)));
register_post_type("product", array('labels' => array('name' => __('Products', 'woothemes'), 'singular_name' => __('Product', 'woothemes'), 'add_new' => __('Add Product', 'woothemes'), 'add_new_item' => __('Add New Product', 'woothemes'), 'edit' => __('Edit', 'woothemes'), 'edit_item' => __('Edit Product', 'woothemes'), 'new_item' => __('New Product', 'woothemes'), 'view' => __('View Product', 'woothemes'), 'view_item' => __('View Product', 'woothemes'), 'search_items' => __('Search Products', 'woothemes'), 'not_found' => __('No Products found', 'woothemes'), 'not_found_in_trash' => __('No Products found in trash', 'woothemes'), 'parent' => __('Parent Product', 'woothemes')), 'description' => __('This is where you can add new products to your store.', 'woothemes'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'publicly_queryable' => true, 'exclude_from_search' => false, 'hierarchical' => true, 'rewrite' => array('slug' => $product_base, 'with_front' => false), 'query_var' => true, 'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'comments'), 'has_archive' => $base_slug, 'show_in_nav_menus' => false));
register_post_type("product_variation", array('labels' => array('name' => __('Variations', 'woothemes'), 'singular_name' => __('Variation', 'woothemes'), 'add_new' => __('Add Variation', 'woothemes'), 'add_new_item' => __('Add New Variation', 'woothemes'), 'edit' => __('Edit', 'woothemes'), 'edit_item' => __('Edit Variation', 'woothemes'), 'new_item' => __('New Variation', 'woothemes'), 'view' => __('View Variation', 'woothemes'), 'view_item' => __('View Variation', 'woothemes'), 'search_items' => __('Search Variations', 'woothemes'), 'not_found' => __('No Variations found', 'woothemes'), 'not_found_in_trash' => __('No Variations found in trash', 'woothemes'), 'parent' => __('Parent Variation', 'woothemes')), 'public' => true, 'show_ui' => false, 'capability_type' => 'post', 'publicly_queryable' => true, 'exclude_from_search' => true, 'hierarchical' => true, 'rewrite' => false, 'query_var' => true, 'supports' => array('title', 'editor', 'custom-fields', 'page-attributes', 'thumbnail'), 'show_in_nav_menus' => false));
register_taxonomy('product_type', array('product'), array('hierarchical' => false, 'show_ui' => false, 'query_var' => true, 'show_in_nav_menus' => false));
register_post_type("shop_order", array('labels' => array('name' => __('Orders', 'woothemes'), 'singular_name' => __('Order', 'woothemes'), 'add_new' => __('Add Order', 'woothemes'), 'add_new_item' => __('Add New Order', 'woothemes'), 'edit' => __('Edit', 'woothemes'), 'edit_item' => __('Edit Order', 'woothemes'), 'new_item' => __('New Order', 'woothemes'), 'view' => __('View Order', 'woothemes'), 'view_item' => __('View Order', 'woothemes'), 'search_items' => __('Search Orders', 'woothemes'), 'not_found' => __('No Orders found', 'woothemes'), 'not_found_in_trash' => __('No Orders found in trash', 'woothemes'), 'parent' => __('Parent Orders', 'woothemes')), 'description' => __('This is where store orders are stored.', 'woothemes'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'publicly_queryable' => false, 'exclude_from_search' => true, 'show_in_menu' => 'woocommerce', 'hierarchical' => false, 'show_in_nav_menus' => false, 'rewrite' => false, 'query_var' => true, 'supports' => array('title', 'comments', 'custom-fields'), 'has_archive' => false));
register_taxonomy('shop_order_status', array('shop_order'), array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'labels' => array('name' => __('Order statuses', 'woothemes'), 'singular_name' => __('Order status', 'woothemes'), 'search_items' => __('Search Order statuses', 'woothemes'), 'all_items' => __('All Order statuses', 'woothemes'), 'parent_item' => __('Parent Order status', 'woothemes'), 'parent_item_colon' => __('Parent Order status:', 'woothemes'), 'edit_item' => __('Edit Order status', 'woothemes'), 'update_item' => __('Update Order status', 'woothemes'), 'add_new_item' => __('Add New Order status', 'woothemes'), 'new_item_name' => __('New Order status Name', 'woothemes')), 'show_ui' => false, 'show_in_nav_menus' => false, 'query_var' => true, 'rewrite' => false));
register_post_type("shop_coupon", array('labels' => array('name' => __('Coupons', 'woothemes'), 'singular_name' => __('Coupon', 'woothemes'), 'add_new' => __('Add Coupon', 'woothemes'), 'add_new_item' => __('Add New Coupon', 'woothemes'), 'edit' => __('Edit', 'woothemes'), 'edit_item' => __('Edit Coupon', 'woothemes'), 'new_item' => __('New Coupon', 'woothemes'), 'view' => __('View Coupons', 'woothemes'), 'view_item' => __('View Coupon', 'woothemes'), 'search_items' => __('Search Coupons', 'woothemes'), 'not_found' => __('No Coupons found', 'woothemes'), 'not_found_in_trash' => __('No Coupons found in trash', 'woothemes'), 'parent' => __('Parent Coupon', 'woothemes')), 'description' => __('This is where you can add new coupons that customers can use in your store.', 'woothemes'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'publicly_queryable' => true, 'exclude_from_search' => true, 'show_in_menu' => 'woocommerce', 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'supports' => array('title'), 'show_in_nav_menus' => false));
if (!taxonomy_exists('product_type')) {
register_taxonomy('product_type', array('post'));
register_taxonomy('shop_order_status', array('post'));
}
$product_types = array('simple', 'grouped', 'variable', 'downloadable', 'virtual');
foreach ($product_types as $type) {
if (!get_term_by('slug', sanitize_title($type), 'product_type')) {
wp_insert_term($type, 'product_type');
}
}
$order_status = array('pending', 'failed', 'on-hold', 'processing', 'completed', 'refunded', 'cancelled');
foreach ($order_status as $status) {
if (!get_term_by('slug', sanitize_title($status), 'shop_order_status')) {
wp_insert_term($status, 'shop_order_status');
}
}
}
开发者ID:eddiewilson,项目名称:new-ke,代码行数:31,代码来源:admin-import.php
示例17: createCategoryTaxonomy
public function createCategoryTaxonomy()
{
$labels = array('name' => "Category", 'singular_name' => "Category", 'update_item' => "Update Category", 'add_new_item' => "Add a new Category", 'new_item_name' => "New Category Name");
register_taxonomy(self::TAXONOMY, array(self::DIRECTOR_POST_TYPE), array('hierarchical' => true, 'labels' => $labels, 'query_var' => self::TAXONOMY, 'rewrite' => array('slug' => self::TAXONOMY_URL)));
wp_insert_term("Board", self::TAXONOMY, array("description" => "this is for board entries", "slug" => "board"));
wp_insert_term("Media", self::TAXONOMY, array("description" => "this is for media releases", "slug" => "media"));
}
开发者ID:javierdlahoz,项目名称:dcbia-wp,代码行数:7,代码来源:DirectorHelper.php
示例18: create_term_type_coat
function create_term_type_coat()
{
// T-shirt
wp_insert_term('t-shirt', 'type', array('description' => 'Just t-shirt', 'slug' => 't-shirt'));
// Pull
wp_insert_term('pull', 'type', array('description' => 'Just pull', 'slug' => 'pull'));
}
开发者ID:stowback,项目名称:coat_recipe,代码行数:7,代码来源:coat.php
示例19: maybe_install
/**
* Set installed option and default settings / terms
*
* @since 1.0
*/
private function maybe_install()
{
global $woocommerce;
$installed_version = get_option('wc_pre_orders_version');
// install
if (!$installed_version) {
// add 'pre-order' shop order status term
$woocommerce->init_taxonomy();
if (!get_term_by('slug', 'pre-ordered', 'shop_order_status')) {
wp_insert_term('pre-ordered', 'shop_order_status');
}
// install default settings
foreach ($this->get_settings() as $setting) {
if (isset($setting['default'])) {
update_option($setting['id'], $setting['default']);
}
}
}
// upgrade - installed version lower than plugin version?
if (-1 === version_compare($installed_version, WC_Pre_Orders::VERSION)) {
$this->upgrade($installed_version);
// new version number
update_option('wc_pre_orders_version', WC_Pre_Orders::VERSION);
}
}
开发者ID:shahadat014,项目名称:geleyi,代码行数:30,代码来源:class-wc-pre-orders-admin.php
示例20: new_term
function new_term($path, $blog_id, $taxonomy)
{
$args = $this->query_args();
$input = $this->input();
if (!is_array($input) || !$input || !strlen($input['name'])) {
return new WP_Error('invalid_input', 'Unknown data passed', 400);
}
$tax = get_taxonomy($taxonomy);
if (!current_user_can($tax->cap->manage_terms)) {
return new WP_Error('unauthorized', 'User cannot edit taxonomy', 403);
}
if (!isset($input['parent']) || !is_taxonomy_hierarchical($taxonomy)) {
$input['parent'] = 0;
}
if ($term = get_term_by('name', $input['name'], $taxonomy)) {
// get_term_by is not case-sensitive, but a name with different casing is allowed
// also, the exact same name is allowed as long as the parents are different
if ($input['name'] === $term->name && $input['parent'] === $term->parent) {
return new WP_Error('duplicate', 'A taxonomy with that name already exists', 409);
}
}
$data = wp_insert_term(addslashes($input['name']), $taxonomy, array('description' => addslashes($input['description']), 'parent' => $input['parent']));
if (is_wp_error($data)) {
return $data;
}
$term = get_term_by('id', $data['term_id'], $taxonomy);
$return = $this->get_taxonomy($term->slug, $taxonomy, $args['context']);
if (!$return || is_wp_error($return)) {
return $return;
}
/** This action is documented in json-endpoints/class.wpcom-json-api-site-settings-endpoint.php */
do_action('wpcom_json_api_objects', 'terms');
return $return;
}
开发者ID:kanei,项目名称:vantuch.cz, |
请发表评论