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


PHP wp_update_term函数代码示例

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


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

示例1: 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

示例2: set

 public function set($key, $value, $override = false)
 {
     if ($key !== "name" && $key !== "taxonomy") {
         $data = array($key => $value);
         wp_update_term($this->id["term_id"], $this->taxonomy, $data);
     }
 }
开发者ID:oligoform,项目名称:mesh,代码行数:7,代码来源:mesh-term.php

示例3: initialize_container

 /**
  * initialize_container - Initialiaze the PAIR containers if the associated
  * option is checked
  *
  * @param  {type} $option    the checkbox to evaluate
  * @param  {type} $oldValue  the oldvalue (should be false)
  * @param  {type} $_newValue the new checkbox value (should be true)
  * @return {type}            description
  */
 function initialize_container($force = false)
 {
     if (isset($_GET['settings-updated']) || $force) {
         $ldp_container_init = get_option('ldp_container_init', false);
         if ($ldp_container_init || $force) {
             //TODO: Initialize the PAIR containers
             $pair_terms = array('initiative' => array('label' => __('Initiative', 'wpldp'), 'rdftype' => 'pair:initiative'), 'organization' => array('label' => __('Organization', 'wpldp'), 'rdftype' => 'foaf:organization'), 'group' => array('label' => __('Group', 'wpldp'), 'rdftype' => 'foaf:group'), 'document' => array('label' => __('Document', 'wpldp'), 'rdftype' => 'foaf:document'), 'goodorservice' => array('label' => __('Good or Service', 'wpldp'), 'rdftype' => 'goodRelation:goodOrService'), 'artwork' => array('label' => __('Artwork', 'wpldp'), 'rdftype' => 'schema:artwork'), 'event' => array('label' => __('Event', 'wpldp'), 'rdftype' => 'schema:event'), 'place' => array('label' => __('Place', 'wpldp'), 'rdftype' => 'schema:place'), 'theme' => array('label' => __('Theme', 'wpldp'), 'rdftype' => 'pair:theme'), 'thesis' => array('label' => __('Thesis', 'wpldp'), 'rdftype' => 'pair:thesis'), 'person' => array('label' => __('Person', 'wpldp'), 'rdftype' => 'pair:person'));
             foreach ($pair_terms as $term => $properties) {
                 // Loop on the models files (or hardcoded array) and push them each as taxonomy term in the database
                 $model = file_get_contents(__DIR__ . '/models/' . $term . '.json');
                 $term_id = null;
                 if (!term_exists($term, 'ldp_container')) {
                     $new_term = wp_insert_term($properties['label'], 'ldp_container', array('slug' => $term, 'description' => sprintf(__('The %1$s object model', 'wpldp'), $term)));
                     $term_id = $new_term['term_id'];
                 } else {
                     $existing_term = get_term_by('slug', $term, 'ldp_container');
                     $updated_term = wp_update_term($existing_term->term_id, 'ldp_container', array('slug' => $term, 'description' => sprintf(__('The %1$s object model', 'wpldp'), $term)));
                     $term_id = $existing_term->term_id;
                 }
                 if (!empty($term_id)) {
                     $term_meta = get_option("ldp_container_{$term_id}");
                     if (!is_array($term_meta)) {
                         $term_meta = array();
                     }
                     $term_meta['ldp_rdf_type'] = $properties['rdftype'];
                     $term_meta['ldp_model'] = stripslashes_deep($model);
                     update_option("ldp_container_{$term_id}", $term_meta);
                 }
             }
         }
     }
 }
开发者ID:assemblee-virtuelle,项目名称:wpldp,代码行数:41,代码来源:wpldp-settings.php

示例4: wp_insert_category

function wp_insert_category($catarr)
{
    global $wpdb;
    extract($catarr, EXTR_SKIP);
    if (trim($cat_name) == '') {
        return 0;
    }
    $cat_ID = (int) $cat_ID;
    // Are we updating or creating?
    if (!empty($cat_ID)) {
        $update = true;
    } else {
        $update = false;
    }
    $name = $cat_name;
    $description = $category_description;
    $slug = $category_nicename;
    $parent = $category_parent;
    $parent = (int) $parent;
    if (empty($parent) || !category_exists($parent) || $cat_ID && cat_is_ancestor_of($cat_ID, $parent)) {
        $parent = 0;
    }
    $args = compact('name', 'slug', 'parent', 'description');
    if ($update) {
        $cat_ID = wp_update_term($cat_ID, 'category', $args);
    } else {
        $cat_ID = wp_insert_term($cat_name, 'category', $args);
    }
    if (is_wp_error($cat_ID)) {
        return 0;
    }
    return $cat_ID['term_id'];
}
开发者ID:helmonaut,项目名称:owb-mirror,代码行数:33,代码来源:taxonomy.php

示例5: handle

	/**
	 * Handle tab logic
	 */
	public function handle()
	{
		// Actions
		add_action('admin_enqueue_scripts', array(&$this, 'action_admin_enqueue_scripts'));
		
		// Taxonomies
		$taxonomies = get_taxonomies(array(
			'hierarchical' => true
		), 'objects');
		$taxonomy_current = (isset($_GET['taxonomy'])  && isset($taxonomies[$_GET['taxonomy']])) ? $taxonomies[$_GET['taxonomy']] : current($taxonomies);
		
		// Terms hierarchy
		if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST) && wp_verify_nonce($_POST['jwbp-terms-reorganize-nonce'], 'jwbp-terms-reorganize')) {
			$terms_parents = $_POST['jwbp-term-parent'];
			
			foreach ($terms_parents as $index => $term_parent) {
				wp_update_term($index, $taxonomy_current->name, array(
					'parent' => $term_parent
				));
			}
			
			// Remove hierarchy from cache
			delete_option($taxonomy_current->name . '_children');
			
			// Add message to notify user of completion
			$this->add_message(sprintf(__('%s hierarchy successfully updated.', 'bulkpress'), $taxonomy_current->labels->singular_name));
		}
	}
开发者ID:erudith,项目名称:fullpower,代码行数:31,代码来源:class.ReorganizeTerms.php

示例6: groundup_activation

 function groundup_activation()
 {
     // Check to see if activation has already been run
     if (!get_option('groundup_activated') == 'activated') {
         add_option('groundup_activated', 'activated');
         // Remove default site description
         if (get_bloginfo('description') == 'Just another WordPress site') {
             update_option('blogdescription', '');
         }
         // Allow shortcodes in widgets
         add_filter('widget_text', 'shortcode_unautop');
         add_filter('widget_text', 'do_shortcode', 11);
         // Change Uploads folder to /media
         update_option('uploads_use_yearmonth_folders', 0);
         update_option('upload_path', 'media');
         update_option('upload_url_path', get_home_url() . '/media');
         // Pretty Permalinks
         update_option('category_base', '/site/');
         update_option('permalink_structure', '/%category%/%postname%/');
         // change start of week to Sunday
         update_option('start_of_week', 0);
         // Change default 'Uncategorized' to 'General'
         $category = get_term_by('id', '1', 'category');
         if ($category->name == 'Uncategorized') {
             $category->name = 'General';
             $category->slug = strtolower(str_replace('_', ' ', 'general'));
         }
         wp_update_term($category->term_id, 'category', array('slug' => $category->slug, 'name' => $category->name));
         // Disable Smilies
         update_option('use_smilies', 0);
         // Set default comment status to closed
         update_option('default_comment_status', 'closed');
         update_option('default_ping_status', 'closed');
         // Set Timezone
         $timezone = "America/New_York";
         //$timezone = "America/Chicago";
         //$timezone = "America/Denver";
         //$timezone = "America/Los_Angeles";
         update_option('timezone_string', $timezone);
         // Clean up widget settings that weren't set at installation to prevent unecessary queries
         add_option('widget_pages', array('_multiwidget' => 1));
         add_option('widget_calendar', array('_multiwidget' => 1));
         add_option('widget_tag_cloud', array('_multiwidget' => 1));
         add_option('widget_nav_menu', array('_multiwidget' => 1));
         // Update default media sizes - additional sizes are added through groundup_init
         update_option('thumbnail_size_w', 330);
         update_option('thumbnail_size_h', 330);
         update_option('thumbnail_crop', true);
         update_option('medium_size_w', 600);
         update_option('medium_size_h', 400);
         update_option('large_size_w', 1200);
         update_option('large_size_h', 800);
         update_option('embed_size_w', 1200);
         update_option('embed_size_h', 800);
         // Add default menus
         groundup_register_nav_menus(array('Primary', 'Secondary', 'Mobile', 'Footer'));
         groundup_create_nav_menus(array('Primary', 'Secondary', 'Mobile', 'Footer'));
     }
 }
开发者ID:abacusadvertising,项目名称:groundup,代码行数:59,代码来源:setup.php

示例7: kws_rt_taxonomy_save

function kws_rt_taxonomy_save()
{
    global $tag_ID;
    $a = array('description');
    foreach ($a as $v) {
        wp_update_term($tag_ID, $v, $_POST[$v]);
    }
}
开发者ID:JackBrit,项目名称:Team-London-Bridge,代码行数:8,代码来源:rich-text-tags.php

示例8: update_object

 function update_object($term, $fields)
 {
     $fields = array_merge(array('taxonomy' => $this->taxonomy), $fields);
     if (is_object($term)) {
         $taxonomy = $term->taxonomy;
     }
     $term_id_pair = wp_update_term($term, $taxonomy, $fields);
     return $term_id_pair['term_id'];
 }
开发者ID:artofwp,项目名称:wp-testing,代码行数:9,代码来源:WP_UnitTest_Factory_For_Term.php

示例9: test_update_term_is_synced

 public function test_update_term_is_synced()
 {
     $args = array('name' => 'Non Catégorisé', 'slug' => 'non-categorise');
     wp_update_term($this->term_object['term_id'], $this->taxonomy, $args);
     $this->client->do_sync();
     $terms = $this->get_terms();
     $server_terms = $this->server_replica_storage->get_terms($this->taxonomy);
     $this->assertEquals($terms, $server_terms);
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:9,代码来源:test_class.jetpack-sync-terms.php

示例10: ubik_quick_terms_description_save

function ubik_quick_terms_description_save($term_id)
{
    $tax = get_taxonomy($_REQUEST['taxonomy']);
    if (current_filter() === 'edited_' . $tax->name && current_user_can($tax->cap->edit_terms)) {
        $description = filter_input(INPUT_POST, 'description', FILTER_SANITIZE_STRING);
        remove_action(current_filter(), __FUNCTION__);
        // Removing action to avoid recursion
        wp_update_term($term_id, $tax->name, array('description' => $description));
    }
}
开发者ID:synapticism,项目名称:ubik-quick-terms,代码行数:10,代码来源:ubik-quick-terms-core.php

示例11: wl_core_install_entity_type_data

/**
 * Install known types in WordPress.
 */
function wl_core_install_entity_type_data()
{
    // Ensure the custom type and the taxonomy are registered.
    wl_entity_type_register();
    wl_entity_type_taxonomy_register();
    // Set the taxonomy data.
    // Note: parent types must be defined before child types.
    // TODO: Manage both generic and custom fields as fields.
    $terms = array('thing' => array('label' => 'Thing', 'description' => 'A generic thing (something that doesn\'t fit in the previous definitions.', 'css' => 'wl-thing', 'uri' => 'http://schema.org/Thing', 'same_as' => array('*'), 'custom_fields' => array(WL_CUSTOM_FIELD_SAME_AS => array('predicate' => 'http://schema.org/sameAs', 'type' => WL_DATA_TYPE_URI, 'export_type' => 'http://schema.org/Thing', 'constraints' => '', 'input_field' => 'sameas')), 'microdata_template' => '', 'templates' => array('subtitle' => '{{id}}')), 'creative-work' => array('label' => 'CreativeWork', 'description' => 'A creative work (or a Music Album).', 'parents' => array('thing'), 'css' => 'wl-creative-work', 'uri' => 'http://schema.org/CreativeWork', 'same_as' => array('http://schema.org/MusicAlbum', 'http://schema.org/Product'), 'custom_fields' => array(), 'microdata_template' => '', 'templates' => array('subtitle' => '{{id}}')), 'event' => array('label' => 'Event', 'description' => 'An event.', 'parents' => array('thing'), 'css' => 'wl-event', 'uri' => 'http://schema.org/Event', 'same_as' => array('http://dbpedia.org/ontology/Event'), 'custom_fields' => array(WL_CUSTOM_FIELD_CAL_DATE_START => array('predicate' => 'http://schema.org/startDate', 'type' => WL_DATA_TYPE_DATE, 'export_type' => 'xsd:date', 'constraints' => ''), WL_CUSTOM_FIELD_CAL_DATE_END => array('predicate' => 'http://schema.org/endDate', 'type' => WL_DATA_TYPE_DATE, 'export_type' => 'xsd:date', 'constraints' => ''), WL_CUSTOM_FIELD_LOCATION => array('predicate' => 'http://schema.org/location', 'type' => WL_DATA_TYPE_URI, 'export_type' => 'http://schema.org/PostalAddress', 'constraints' => array('uri_type' => 'Place'))), 'microdata_template' => '{{startDate}}
                                {{endDate}}
                                {{location}}', 'templates' => array('subtitle' => '{{id}}')), 'organization' => array('label' => 'Organization', 'description' => 'An organization, including a government or a newspaper.', 'parents' => array('thing'), 'css' => 'wl-organization', 'uri' => 'http://schema.org/Organization', 'same_as' => array('http://rdf.freebase.com/ns/organization.organization', 'http://rdf.freebase.com/ns/government.government', 'http://schema.org/Newspaper'), 'custom_fields' => array(WL_CUSTOM_FIELD_FOUNDER => array('predicate' => 'http://schema.org/founder', 'type' => WL_DATA_TYPE_URI, 'export_type' => 'http://schema.org/Person', 'constraints' => array('uri_type' => 'Person'))), 'microdata_template' => '{{founder}}', 'templates' => array('subtitle' => '{{id}}')), 'person' => array('label' => 'Person', 'description' => 'A person (or a music artist).', 'parents' => array('thing'), 'css' => 'wl-person', 'uri' => 'http://schema.org/Person', 'same_as' => array('http://rdf.freebase.com/ns/people.person', 'http://rdf.freebase.com/ns/music.artist', 'http://dbpedia.org/class/yago/LivingPeople'), 'custom_fields' => array(), 'microdata_template' => '', 'templates' => array('subtitle' => '{{id}}')), 'place' => array('label' => 'Place', 'description' => 'A place.', 'parents' => array('thing'), 'css' => 'wl-place', 'uri' => 'http://schema.org/Place', 'same_as' => array('http://rdf.freebase.com/ns/location.location', 'http://www.opengis.net/gml/_Feature'), 'custom_fields' => array(WL_CUSTOM_FIELD_GEO_LATITUDE => array('predicate' => 'http://schema.org/latitude', 'type' => WL_DATA_TYPE_DOUBLE, 'export_type' => 'xsd:double', 'constraints' => '', 'input_field' => 'coordinates'), WL_CUSTOM_FIELD_GEO_LONGITUDE => array('predicate' => 'http://schema.org/longitude', 'type' => WL_DATA_TYPE_DOUBLE, 'export_type' => 'xsd:double', 'constraints' => '', 'input_field' => 'coordinates'), WL_CUSTOM_FIELD_ADDRESS => array('predicate' => 'http://schema.org/address', 'type' => WL_DATA_TYPE_STRING, 'export_type' => 'http://schema.org/PostalAddress', 'constraints' => '')), 'microdata_template' => '<span itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">
                                    {{latitude}}
                                    {{longitude}}
                                </span>
                                {{address}}', 'templates' => array('subtitle' => '{{id}}')), 'localbusiness' => array('label' => 'LocalBusiness', 'description' => 'A local business.', 'parents' => array('place', 'organization'), 'css' => 'wl-local-business', 'uri' => 'http://schema.org/LocalBusiness', 'same_as' => array('http://rdf.freebase.com/ns/business/business_location', 'https://schema.org/Store'), 'custom_fields' => array(), 'microdata_template' => '', 'templates' => array('subtitle' => '{{id}}')));
    foreach ($terms as $slug => $term) {
        // Create the term if it does not exist, then get its ID
        $term_id = term_exists($term['label']);
        if ($term_id == 0 || is_null($term_id)) {
            $result = wp_insert_term($term['label'], WL_ENTITY_TYPE_TAXONOMY_NAME);
        } else {
            $result = get_term($term_id, WL_ENTITY_TYPE_TAXONOMY_NAME, ARRAY_A);
        }
        // Check for errors.
        if (is_wp_error($result)) {
            wl_write_log('wl_install_entity_type_data [ ' . $result->get_error_message() . ' ]');
            continue;
        }
        // Check if 'parent' corresponds to an actual term and get its ID.
        if (!isset($term['parents'])) {
            $term['parents'] = array();
        }
        $parent_ids = array();
        foreach ($term['parents'] as $parent_slug) {
            $parent_id = get_term_by('slug', $parent_slug, WL_ENTITY_TYPE_TAXONOMY_NAME);
            $parent_ids[] = intval($parent_id->term_id);
            // Note: int casting is suggested by Codex: http://codex.wordpress.org/Function_Reference/get_term_by
        }
        // Define a parent in the WP taxonomy style (not important for WL)
        if (empty($parent_ids)) {
            // No parent
            $parent_id = 0;
        } else {
            // Get first parent
            $parent_id = $parent_ids[0];
        }
        // Update term with description, slug and parent
        wp_update_term($result['term_id'], WL_ENTITY_TYPE_TAXONOMY_NAME, array('description' => $term['description'], 'slug' => $slug, 'parent' => $parent_id));
        // Inherit custom fields and microdata template from parent.
        $term = wl_entity_type_taxonomy_type_inheritage($term, $parent_ids);
        // Add custom metadata to the term.
        wl_entity_type_taxonomy_update_term($result['term_id'], $term['css'], $term['uri'], $term['same_as'], $term['custom_fields'], $term['templates'], $term['microdata_template']);
    }
}
开发者ID:efueger,项目名称:wordlift-plugin,代码行数:57,代码来源:wordlift_core_install.php

示例12: updateMenuName

 /**
  * Update the menu name if option is updated
  * @since 1.1.5
  */
 public function updateMenuName($option, $old_value, $value)
 {
     if ($option == 'nestedpages_menu') {
         $menu = get_term_by('id', $old_value, 'nav_menu');
         if ($menu) {
             delete_option('nestedpages_menu');
             // Delete the option to prevent infinite loop
             update_option('nestedpages_menu', $old_value);
             wp_update_term($menu->term_id, 'nav_menu', array('name' => $value, 'slug' => sanitize_title($value)));
         }
     }
 }
开发者ID:erkmen,项目名称:wpstartersetup,代码行数:16,代码来源:class-np-settings.php

示例13: move_folder

 function move_folder($folderId, $inFolderId)
 {
     global $wplr;
     $termId = $wplr->get_meta("mediafolder_term_id", $folderId);
     $parentTermId = $wplr->get_meta("mediafolder_term_id", $inFolderId);
     $result = wp_update_term($termId, 'wpmf-category', array('parent' => $parentTermId));
     if (is_wp_error($result)) {
         error_log("Issue while moving the folder.");
         error_log($result->get_error_message());
         return;
     }
 }
开发者ID:jordymeow,项目名称:wplr-media-folder,代码行数:12,代码来源:wplr-media-folder.php

示例14: test_category_name_change

 /**
  * @ticket 22526
  */
 function test_category_name_change()
 {
     $term = self::factory()->category->create_and_get(array('name' => 'Foo'));
     $post_id = self::factory()->post->create();
     wp_set_post_categories($post_id, $term->term_id);
     $post = get_post($post_id);
     $cats1 = get_the_category($post->ID);
     $this->assertEquals($term->name, reset($cats1)->name);
     wp_update_term($term->term_id, 'category', array('name' => 'Bar'));
     $cats2 = get_the_category($post->ID);
     $this->assertNotEquals($term->name, reset($cats2)->name);
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:15,代码来源:cache.php

示例15: update_category

 /**
  * Update to-do list category
  * @static
  * @return int
  */
 public static function update_category()
 {
     $category_id = absint($_POST['cleverness_todo_cat_id']);
     $term = wp_update_term($category_id, 'todocategories', array('name' => $_POST['cleverness_todo_cat_name']));
     if (!is_wp_error($term)) {
         $options = get_option('CTDL_categories');
         $options["category_{$category_id}"] = absint($_POST['cleverness_todo_cat_visibility']);
         update_option('CTDL_categories', $options);
         return $term['term_id'];
     } else {
         return 0;
     }
 }
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:18,代码来源:cleverness-to-do-list-categories.class.php


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