本文整理汇总了PHP中wp_update_category函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_update_category函数的具体用法?PHP wp_update_category怎么用?PHP wp_update_category使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_update_category函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pp_update_project
function pp_update_project($project_data)
{
if (!($project_category_id = pp_get_category_id('projects'))) {
return false;
// This shouldn't happen from the edit screen.
}
if (isset($project_data['project_parent']) && (!$project_data['project_parent'] || -1 == $project_data['project_parent'])) {
$project_data['project_parent'] = $project_category_id;
}
$category_data = array('cat_ID' => $project_data['project_ID'], 'cat_name' => $project_data['project_name'], 'category_description' => $project_data['project_description'], 'category_nicename' => $project_data['project_nicename'], 'category_parent' => $project_data['project_parent']);
if (!($category_id = wp_update_category($category_data, false))) {
return false;
}
$project_meta = array();
$project_meta['logo'] = $project_data['project_logo'];
$project_meta['website'] = $project_data['project_website'];
$project_meta['blog'] = $project_data['project_blog'];
$project_meta['svn'] = $project_data['project_svn'];
$project_meta['trac'] = $project_data['project_trac'];
$project_meta['intertrac'] = $project_data['project_intertrac'];
$project_meta['activity'] = $project_data['project_activity'];
$project_meta['overheard'] = $project_data['project_overheard'];
if ($project_meta['activity']) {
$project_meta['activity'] = str_replace("\r", '', $project_meta['activity']);
$project_meta['activity'] = explode("\n", $project_meta['activity']);
array_walk($project_meta['activity'], create_function('&$a', '$a = trim($a);'));
$project_meta['activity'] = array_filter($project_meta['activity']);
}
if ($project_meta['overheard']) {
$project_meta['overheard'] = str_replace("\r", '', $project_meta['overheard']);
$project_meta['overheard'] = explode("\n", $project_meta['overheard']);
array_walk($project_meta['overheard'], create_function('&$a', '$a = trim($a);'));
$project_meta['overheard'] = array_filter($project_meta['overheard']);
}
if ($current_project_meta = get_option('pp_project_meta_' . $category_id)) {
$project_meta = array_merge($current_project_meta, $project_meta);
}
update_option('pp_project_meta_' . $category_id, $project_meta);
return $category_id;
}
示例2: _e
_e('Edit category');
?>
»" /></p>
</form>
<p><a href="categories.php"><?php
_e('« Return to category list');
?>
</a></p>
</div>
<?php
break;
case 'editedcat':
if (!current_user_can('manage_categories')) {
die(__('Cheatin’ uh?'));
}
wp_update_category($_POST);
header('Location: categories.php?message=3');
break;
default:
require_once 'admin-header.php';
$messages[1] = __('Category added.');
$messages[2] = __('Category deleted.');
$messages[3] = __('Category updated.');
?>
<?php
if (isset($_GET['message'])) {
?>
<div id="message" class="updated fade"><p><?php
echo $messages[$_GET['message']];
?>
示例3: get_category_to_edit
$category = get_category_to_edit($cat_ID);
include 'edit-category-form.php';
break;
case 'editedcat':
$cat_ID = (int) $_POST['cat_ID'];
check_admin_referer('update-category_' . $cat_ID);
if (!current_user_can('manage_categories')) {
wp_die(__('Cheatin’ uh?'));
}
$location = 'categories.php';
if ($referer = wp_get_original_referer()) {
if (false !== strpos($referer, 'categories.php')) {
$location = $referer;
}
}
if (wp_update_category($_POST)) {
$location = add_query_arg('message', 3, $location);
} else {
$location = add_query_arg('message', 5, $location);
}
wp_redirect($location);
exit;
break;
default:
if (isset($_GET['_wp_http_referer']) && !empty($_GET['_wp_http_referer'])) {
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
exit;
}
wp_enqueue_script('admin-categories');
if (current_user_can('manage_categories')) {
wp_enqueue_script('inline-edit-tax');
示例4: die
}
if (!isset($_POST['tax_ID']) || !($id = (int) $_POST['tax_ID'])) {
die(-1);
}
switch ($_POST['tax_type']) {
case 'cat':
$data = array();
$data['cat_ID'] = $id;
$data['cat_name'] = $_POST['name'];
$data['category_nicename'] = $_POST['slug'];
if (isset($_POST['parent']) && (int) $_POST['parent'] > 0) {
$data['category_parent'] = $_POST['parent'];
}
$cat = get_category($id, ARRAY_A);
$data['category_description'] = $cat['category_description'];
$updated = wp_update_category($data);
if ($updated && !is_wp_error($updated)) {
echo _cat_row($updated, 0);
} else {
die(__('Category not updated.'));
}
break;
case 'link-cat':
$updated = wp_update_term($id, 'link_category', $_POST);
if ($updated && !is_wp_error($updated)) {
echo link_cat_row($updated['term_id']);
} else {
die(__('Category not updated.'));
}
break;
case 'tag':
示例5: 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 {
//.........这里部分代码省略.........
示例6: setBlogOptions
/**
* Set options for a new blog created when a new
* campaign is created.
*
* @param int $blogId
* @return null
*/
protected function setBlogOptions($blogId)
{
// allow search engine robots to index the campaign site
update_blog_option($blogId, 'blog_public', 1);
// set defaut campaign theme
update_blog_option($blogId, 'current_theme', 'Blog 01');
update_blog_option($blogId, 'stylesheet', 'blog-01');
update_blog_option($blogId, 'template', 'blog-01');
// set upload limit
$capabilities = Capability::getByPlanId($this->plan_id);
update_blog_option($blogId, 'blog_upload_space', $capabilities->upload_limit->value);
// enable contact page
update_blog_option($blogId, 'projeto_contact_enabled', 'on');
// enable "mobilize" menu entry option
if ($capabilities->mobilize->value) {
update_blog_option($blogId, 'mobilize', array('general' => array('menuItem' => true)));
}
// rename category "sem-categoria" to "noticias"
wp_update_category(array('cat_ID' => 1, 'cat_name' => 'Notícias', 'category_nicename' => 'noticias'));
}
示例7: setBlogOptions
/**
* Set options for a new blog created when a new
* campaign is created.
*
* @param int $blogId
* @return null
*/
protected function setBlogOptions($blogId)
{
// allow search engine robots to index the campaign site
update_blog_option($blogId, 'blog_public', 1);
// allow change of blog model
$model = get_user_meta(get_current_user_id(), 'blogmodel', true);
if (empty($model)) {
// set defaut campaign theme
update_blog_option($blogId, 'current_theme', 'Blog 01');
update_blog_option($blogId, 'stylesheet', 'blog-01');
update_blog_option($blogId, 'template', 'blog-01');
} elseif (file_exists(WPMU_PLUGIN_DIR . "/campaign_base/models/" . basename($model) . ".php")) {
include WPMU_PLUGIN_DIR . "/campaign_base/models/" . basename($model) . ".php";
}
// set upload limit
$capabilities = Capability::getByPlanId($this->plan_id);
update_blog_option($blogId, 'blog_upload_space', $capabilities->upload_limit->value);
// enable contact page
update_blog_option($blogId, 'projeto_contact_enabled', 'on');
// enable "mobilize" menu entry option
if ($capabilities->mobilize->value) {
update_blog_option($blogId, 'mobilize', array('general' => array('menuItem' => true)));
}
// rename category "sem-categoria" to "noticias"
wp_update_category(array('cat_ID' => 1, 'cat_name' => 'Notícias', 'category_nicename' => 'noticias'));
}