本文整理汇总了PHP中wp_set_post_terms函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_set_post_terms函数的具体用法?PHP wp_set_post_terms怎么用?PHP wp_set_post_terms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_set_post_terms函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: create_feedback
public function create_feedback($params)
{
global $un_settings;
if (isset($params['title']) && $params['title']) {
$title = $params['title'];
}
$content = $params['description'];
if (empty($params['title'])) {
$title = substr($content, 0, 150) . (strlen($content) < 150 ? '' : "…");
}
$id = wp_insert_post(array('post_type' => FEEDBACK, 'post_title' => wp_kses(apply_filters('un_feedback_title', $title, $params), wp_kses_allowed_html()), 'post_content' => wp_kses(apply_filters('un_feedback_content', $content, $params), wp_kses_allowed_html()), 'post_status' => un_get_option(UN_PUBLISH_DIRECTLY) ? 'publish' : 'pending', 'post_author' => 0));
$email = isset($params['email']) ? trim($params['email']) : '';
if ($email) {
add_post_meta($id, '_email', $email);
}
if (is_user_logged_in()) {
add_post_meta($id, '_author', get_current_user_id());
}
if (isset($params['name']) && trim($params['name'])) {
add_post_meta($id, '_name', wp_kses(trim($params['name']), wp_kses_allowed_html()));
}
wp_set_post_terms($id, $params['type'], FEEDBACK_TYPE);
do_action('un_feedback_created', $id, $params);
$this->send_admin_message($id, $params);
}
开发者ID:congtrieu112,项目名称:anime,代码行数:25,代码来源:model.php
示例2: create
/**
* Create or edit a a project
*
* @param null|int $project_id
* @return int
*/
function create($project_id = 0, $posted = array())
{
$is_update = $project_id ? true : false;
$data = array('post_title' => $posted['project_name'], 'post_content' => $posted['project_description'], 'post_type' => 'project', 'post_status' => 'publish');
if ($is_update) {
$data['ID'] = $project_id;
$project_id = wp_update_post($data);
} else {
$project_id = wp_insert_post($data);
}
if ($project_id) {
$this->insert_project_user_role($posted, $project_id);
wp_set_post_terms($project_id, $posted['project_cat'], 'project_category', false);
if ($is_update) {
do_action('cpm_project_update', $project_id, $data);
} else {
update_post_meta($project_id, '_project_archive', 'no');
update_post_meta($project_id, '_project_active', 'yes');
$settings = $this->settings_user_permission();
update_post_meta($project_id, '_settings', $settings);
do_action('cpm_project_new', $project_id, $data);
}
}
return $project_id;
}
开发者ID:javalidigital,项目名称:multipla,代码行数:31,代码来源:project.php
示例3: save_new_episode
public function save_new_episode($item, $show_slug)
{
$item_date = $item->get_date('Y-m-d H:i:s');
$enclosure = $item->get_enclosure();
$post = array('post_title' => $item->get_title(), 'post_date' => $item_date, 'post_content' => $item->get_description(), 'post_status' => 'publish', 'post_type' => Dipo_Podcast_Post_Type::POST_TYPE, 'tags_input' => $enclosure->get_keywords());
$post_id = wp_insert_post($post);
if (!empty($show_slug)) {
$term_id = term_exists($show_slug, 'podcast_show');
wp_set_post_terms($post_id, $term_id, 'podcast_show');
}
// save episodes data as metadata for post
$subtitle = htmlspecialchars($this->get_subtitle($item));
update_post_meta($post_id, '_dipo_subtitle', $subtitle);
$summary = htmlspecialchars($this->get_summary($item));
update_post_meta($post_id, '_dipo_summary', $summary);
$explicit = htmlspecialchars(strtolower($this->get_explicit($item)));
$possible_values = array('yes', 'no', 'clean');
if (in_array($explicit, $possible_values)) {
update_post_meta($post_id, '_dipo_explicit', $explicit);
}
$medialink = esc_url_raw($enclosure->get_link());
$type = htmlspecialchars($enclosure->get_type());
$duration = htmlspecialchars($enclosure->get_duration('hh:mm:ss'));
$length = htmlspecialchars($enclosure->get_length());
$mediafile = array('id' => 1, 'medialink' => $medialink, 'mediatype' => $type, 'duration' => $duration, 'filesize' => $length);
update_post_meta($post_id, '_dipo_mediafile1', $mediafile);
update_post_meta($post_id, '_dipo_max_mediafile_number', '1');
$this->created_episodes++;
return $post_id;
}
开发者ID:ICFMovement,项目名称:dicentis,代码行数:30,代码来源:class-dipo-feed-import.php
示例4: error_log
public static function error_log($post_title, $error, $tags = array())
{
$post_content = (is_string($error) ? $error : print_r($error, true)) . "\n\n";
$backtrace = debug_backtrace();
// remove calls to this function and template tags that call it
foreach ($backtrace as $i => $call) {
if ('voce_error_log' === $call['function'] || 'error_log' === $call['function']) {
unset($backtrace[$i]);
}
}
$post_content .= "<hr>\n";
foreach ($backtrace as $call) {
if (isset($call['file']) && isset($call['line'])) {
$post_content .= sprintf("%s - (%s:%d)\n", $call['function'], $call['file'], $call['line']);
} else {
$post_content .= $call['function'] . "\n";
break;
// stop when we get to the function containing the voce_error_log() call
}
}
$postarr = compact('post_title', 'post_content');
$postarr = array_merge($postarr, array('post_type' => self::POST_TYPE, 'post_status' => 'publish', 'post_tag' => $tags));
$log_id = wp_insert_post($postarr);
wp_set_post_terms($log_id, $tags, self::TAXONOMY);
}
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:25,代码来源:voce-error-logging.php
示例5: scoper_force_custom_taxonomy_filters
function scoper_force_custom_taxonomy_filters($post_id, $post)
{
$post_type_obj = get_post_type_object($post->post_type);
foreach ($post_type_obj->taxonomies as $taxonomy) {
// if terms were selected, WP core already applied the filter and there is no need to apply default terms
if (in_array($taxonomy, array('category', 'post_tag')) || did_action("pre_post_{$taxonomy}")) {
continue;
}
// don't filter term selection for non-hierarchical taxonomies
if (empty($GLOBALS['wp_taxonomies'][$taxonomy]->hierarchical)) {
continue;
}
if ($taxonomy_obj = get_taxonomy($taxonomy)) {
if (!empty($_POST['tax_input'][$taxonomy]) && is_array($_POST['tax_input'][$taxonomy]) && (reset($_POST['tax_input'][$taxonomy]) || count($_POST['tax_input'][$taxonomy]) > 1)) {
// complication because (as of 3.0) WP always includes a zero-valued first array element
$tags = $_POST['tax_input'][$taxonomy];
} elseif ('auto-draft' != $post->post_status) {
$tags = (array) get_option("default_{$taxonomy}");
} else {
$tags = array();
}
if ($tags) {
if (!empty($_POST['tax_input']) && is_array($_POST['tax_input'][$taxonomy])) {
// array = hierarchical, string = non-hierarchical.
$tags = array_filter($tags);
}
if (current_user_can($taxonomy_obj->cap->assign_terms)) {
$tags = apply_filters("pre_post_{$taxonomy}", $tags);
$tags = apply_filters("{$taxonomy}_pre", $tags);
wp_set_post_terms($post_id, $tags, $taxonomy);
}
}
}
}
}
开发者ID:btj,项目名称:cscircles-wp-content,代码行数:35,代码来源:filters-admin-save_rs.php
示例6: postStoreProcess
public function postStoreProcess($table, $newTags = array(), $replace = true)
{
return false;
if (!empty($table->newTags) && empty($newTags)) {
$newTags = $table->newTags;
}
// If existing row, check to see if tags have changed.
$newTable = clone $table;
$newTable->reset();
$key = $newTable->getKeyName();
$typeAlias = $this->typeAlias;
$result = false;
if ($this->tagsChanged || !empty($newTags) && $newTags[0] != '') {
$taxonomy_obj = get_taxonomy($typeAlias);
if (is_array($newTags)) {
// array = hierarchical, string = non-hierarchical.
$newTags = array_filter($newTags);
}
if (current_user_can($taxonomy_obj->cap->assign_terms)) {
$result = wp_set_post_terms($table->id, $newTags, $typeAlias);
if (is_array($result) && count($result) > 0) {
$result = true;
} elseif (is_object($result)) {
$result = false;
}
}
}
return $result;
}
开发者ID:vanie3,项目名称:appland,代码行数:29,代码来源:tags.php
示例7: post_add_tax
function post_add_tax($value, $object, $field_name)
{
//var_dump( $value );
foreach ($value as $term => $tax) {
wp_set_post_terms($object->ID, array(intval($term)), $tax, true);
}
}
开发者ID:KodkodGates,项目名称:angularjs-for-wordpress,代码行数:7,代码来源:plugin.php
示例8: save
public static function save($post_id)
{
if (isset($_POST['_unit'])) {
update_post_meta($post_id, '_unit', sanitize_text_field($_POST['_unit']));
}
if (isset($_POST['_unit_base'])) {
update_post_meta($post_id, '_unit_base', $_POST['_unit_base'] === '' ? '' : wc_format_decimal($_POST['_unit_base']));
}
if (isset($_POST['_unit_price_regular'])) {
update_post_meta($post_id, '_unit_price_regular', $_POST['_unit_price_regular'] === '' ? '' : wc_format_decimal($_POST['_unit_price_regular']));
update_post_meta($post_id, '_unit_price', $_POST['_unit_price_regular'] === '' ? '' : wc_format_decimal($_POST['_unit_price_regular']));
}
if (isset($_POST['_unit_price_sale'])) {
update_post_meta($post_id, '_unit_price_sale', '');
// Update Sale Price only if is on sale (Cron?!)
if (get_post_meta($post_id, '_price', true) != $_POST['_regular_price'] && $_POST['_unit_price_sale'] !== '') {
update_post_meta($post_id, '_unit_price_sale', $_POST['_unit_price_sale'] === '' ? '' : wc_format_decimal($_POST['_unit_price_sale']));
update_post_meta($post_id, '_unit_price', $_POST['_unit_price_sale'] === '' ? '' : wc_format_decimal($_POST['_unit_price_sale']));
}
}
if (isset($_POST['_mini_desc'])) {
update_post_meta($post_id, '_mini_desc', esc_html($_POST['_mini_desc']));
}
if (isset($_POST['delivery_time']) && !is_numeric($_POST['delivery_time'])) {
wp_set_post_terms($post_id, sanitize_text_field($_POST['delivery_time']), 'product_delivery_time');
} else {
wp_set_object_terms($post_id, absint($_POST['delivery_time']), 'product_delivery_time');
}
}
开发者ID:radscheit,项目名称:unicorn,代码行数:29,代码来源:class-wc-gzd-meta-box-product-data.php
示例9: add_post_to_cat
function add_post_to_cat()
{
// Get the Post ID
if (isset($_POST['post_id']) && !empty($_POST['post_id'])) {
$post_id = esc_html($_POST['post_id']);
} else {
echo json_encode(array('success' => false, 'reason' => 'No Post ID.'));
exit;
}
// Get the Category
if (isset($_POST['cat_id']) && !empty($_POST['cat_id'])) {
$cat_id = esc_html($_POST['cat_id']);
} else {
echo json_encode(array('success' => false, 'reason' => 'No Cat ID.'));
exit;
}
// Check if Post is already in this category
if (has_term($cat_id, 'bookmark-category', $post_id)) {
echo json_encode(array('success' => true, 'reason' => 'duplicate'));
exit;
}
// Add Post to Bookmark Category
$did_add_cat = wp_set_post_terms($post_id, $cat_id, 'bookmark-category', true);
if ($did_add_cat) {
echo json_encode(array('success' => true, 'reason' => 'inserted'));
} else {
echo json_encode(array('success' => false, 'reason' => "Couldn't add cat."));
}
exit;
}
开发者ID:ryan-frankel,项目名称:nerdmash,代码行数:30,代码来源:ajax-add-cat-to-post.php
示例10: post
public function post()
{
if (isset($_POST['review_id'])) {
update_post_meta($_POST['review_id'], 'color', $_POST['color']);
update_post_meta($_POST['review_id'], 'espuma', $_POST['espuma']);
update_post_meta($_POST['review_id'], 'alcohol', $_POST['alcohol']);
update_post_meta($_POST['review_id'], 'cuerpo', $_POST['cuerpo']);
update_post_meta($_POST['review_id'], 'final', $_POST['final']);
update_post_meta($_POST['review_id'], 'amargor', $_POST['amargor']);
update_post_meta($_POST['review_id'], 'rating', $_POST['rating']);
$cerveza_id = get_post_meta($_POST['review_id'], 'cerveza_id', true);
$flavors = $_POST['tax_input']['flavor_of_beer'];
$aromas = $_POST['tax_input']['aroma_of_beer'];
wp_set_post_terms($_POST['review_id'], $flavors, 'flavor_of_beer');
wp_set_post_terms($_POST['review_id'], $aromas, 'aroma_of_beer');
global $wpdb;
$sql = 'SELECT * FROM nwm_loc_hielera ';
$sql .= 'WHERE beer=' . $cerveza_id . ' ';
$sql .= 'AND user=' . get_current_user_id();
if ($wpdb->get_row($sql) == null) {
$newCoolerRow = array('user' => get_current_user_id(), 'beer' => $cerveza_id, 'review' => 1, 'rate' => 1, 'forlater' => 0, 'favorite' => 0, 'status' => 'Review');
$wpdb->insert('nwm_loc_hielera', $newCoolerRow);
} else {
$updateCoolerRow = array('status' => 'Review', 'review' => 1);
$wpdb->update('nwm_loc_hielera', $updateCoolerRow, array('user' => get_current_user_id(), 'beer' => $cerveza_id));
}
$wpdb->insert('nwm_loc_hielera', array('user' => get_current_user_id(), 'beer' => $cerveza_id));
$wpdb->update('nwm_loc_hielera', array('status' => 'Reviewed', 'review' => 1, 'rate' => 1), array('user' => get_current_user_id(), 'beer' => $cerveza_id));
}
}
开发者ID:mauricioabisay,项目名称:nwm-loc,代码行数:30,代码来源:class-plugin-name-public.php
示例11: handle_question_editing
function handle_question_editing()
{
global $wpdb;
if (!wp_verify_nonce($_POST['_wpnonce'], 'qa_edit')) {
wp_die(__('Are you sure you want to do that?', QA_TEXTDOMAIN));
}
$question_id = (int) $_POST['question_id'];
if (!$question_id && !current_user_can('publish_questions')) {
wp_die(__('You are not allowed to post questions', QA_TEXTDOMAIN));
}
$question = array('post_title' => trim($_POST['question_title']), 'post_content' => trim($_POST['question_content']));
if (empty($question['post_title']) || empty($question['post_content'])) {
wp_die(__('Questions must have both a title and a body.', QA_TEXTDOMAIN));
}
// Check for duplicates
if (!$question_id) {
$dup_id = $wpdb->get_var($wpdb->prepare("\n\t\t\t\tSELECT ID\n\t\t\t\tFROM {$wpdb->posts}\n\t\t\t\tWHERE post_type = 'question'\n\t\t\t\tAND post_status = 'publish'\n\t\t\t\tAND (post_title = %s OR post_content = %s)\n\t\t\t\tLIMIT 1\n\t\t\t", $question['post_title'], $question['post_content']));
if ($dup_id) {
wp_die(sprintf(__('It seems that question was <a href="%s">already asked</a>.', QA_TEXTDOMAIN), qa_get_url('single', $dup_id)));
}
}
$question_id = $this->_insert_post($question_id, $question, array('post_type' => 'question', 'comment_status' => 'open'));
wp_set_post_terms($question_id, $_POST['question_tags'], 'question_tag');
return qa_get_url('single', $question_id);
}
开发者ID:rgrp,项目名称:wordpress-qa,代码行数:25,代码来源:edit.php
示例12: wdm_modified_bid_place
function wdm_modified_bid_place($args)
{
global $wpdb;
$wpdb->show_errors();
$wpdb->insert($wpdb->prefix . 'wdm_bidders', array('name' => $args['orig_name'], 'email' => $args['orig_email'], 'auction_id' => $args['auc_id'], 'bid' => $args['orig_bid'], 'date' => date("Y-m-d H:i:s", time())), array('%s', '%s', '%d', '%f', '%s'));
update_post_meta($args['auc_id'], 'wdm_previous_bid_value', $args['mod_bid']);
//store bid value of the most recent bidder
$place_bid = $wpdb->insert($wpdb->prefix . 'wdm_bidders', array('name' => $args['mod_name'], 'email' => $args['mod_email'], 'auction_id' => $args['auc_id'], 'bid' => $args['mod_bid'], 'date' => date("Y-m-d H:i:s", time())), array('%s', '%s', '%d', '%f', '%s'));
if ($place_bid) {
$c_code = substr(get_option('wdm_currency'), -3);
$char = $args['site_char'];
$ret_url = $args['auc_url'];
$adm_email = get_option("wdm_auction_email");
if ($args['email_type'] === 'winner') {
update_post_meta($args['auc_id'], 'wdm_listing_ends', date("Y-m-d H:i:s", time()));
$check_term = term_exists('expired', 'auction-status');
wp_set_post_terms($args['auc_id'], $check_term["term_id"], 'auction-status');
update_post_meta($args['auc_id'], 'email_sent_imd', 'sent_imd');
$args['stat'] = "Won";
} else {
$args['stat'] = "Placed";
}
$args['adm_email'] = $adm_email;
$args['ret_url'] = $ret_url;
$args['type'] = 'proxy';
echo json_encode($args);
}
}
开发者ID:tvolmari,项目名称:hammydowns,代码行数:28,代码来源:ua-proxy-bidding.php
示例13: cjtheme_insert_question
function cjtheme_insert_question()
{
global $wpdb;
$errors = null;
parse_str($_POST['data'], $postdata);
if ($postdata['question'] == '') {
$errors[] = __('Please enter some content to ask.', 'cjtheme');
}
if ($postdata['category'] == '') {
$errors[] = __('You must select a category for this question.', 'cjtheme');
}
if (!is_null($errors)) {
$return['errors'] = cjtheme_show_message('error', implode('<br>', $errors));
} else {
// $post_title = cjtheme_trim_text($postdata['question'], '60');
$post_title = $postdata['question'];
$question_data = array('post_title' => $post_title, 'post_name' => sanitize_title($post_title), 'post_content' => esc_textarea($postdata['question']), 'post_type' => 'questions', 'post_status' => 'publish');
$post_id = wp_insert_post($question_data);
wp_set_post_terms($post_id, $postdata['category'], 'qna_type');
//$return['success'] = $postdata['current_url'].'#question-'.$post_id;
$return['success'] = get_permalink($post_id);
}
echo json_encode($return);
die;
}
开发者ID:praveen-thayikkattil,项目名称:cartoq-theme,代码行数:25,代码来源:ajax-qna.php
示例14: set_terms
/**
* Wrapper for terms setting to post.
*
* @param array $terms List of terms to set.
* @param string $taxonomy Name of taxonomy to set terms to.
* @param bool $append When true post may have multiple same instances.
*
* @return bool Success.
*/
public function set_terms(array $terms, $taxonomy, $append = false)
{
$result = wp_set_post_terms($this->_post_id, $terms, $taxonomy, $append);
if (is_wp_error($result)) {
return false;
}
return $result;
}
开发者ID:washingtonstateuniversity,项目名称:WSUWP2-CAHNRS-Plugin-Collection,代码行数:17,代码来源:taxonomy.php
示例15: copy_tags_from_old_to_new
function copy_tags_from_old_to_new($old_id, $new_id)
{
$old_terms = wp_get_post_terms($old_id, 'post_tag');
$old_term_ids = array_map(function ($term) {
return $term->term_id;
}, $old_terms);
wp_set_post_terms($new_id, $old_term_ids, 'post_tag', true);
}
开发者ID:nathanielks,项目名称:wp-podcast-post-type,代码行数:8,代码来源:functions.php
示例16: wpdr_update_type
function wpdr_update_type($postID)
{
$wpdr = Document_Revisions::$instance;
if (!$wpdr->verify_post_type($postID)) {
return;
}
wp_set_post_terms($postID, array($wpdr->get_extension($postID)), 'filetype', false);
}
开发者ID:nyxerus,项目名称:WP-Document-Revisions-Code-Cookbook,代码行数:8,代码来源:filetype-taxonomy.php
示例17: toggle_case
function toggle_case()
{
global $post;
if (isset($_POST['closeCase'])) {
$tag = get_term_by('id', $_POST['result_select'], 'results');
wp_set_post_terms($post->ID, $tag->slug, 'results');
} elseif (isset($_POST['openCase'])) {
wp_delete_object_term_relationships($post->ID, 'results');
}
}
开发者ID:aopletaev,项目名称:casepress,代码行数:10,代码来源:comments_action.php
示例18: chef_gift_registry_add_action_callback
function chef_gift_registry_add_action_callback()
{
if (!wp_verify_nonce($_POST['_wpnonce'], 'add_to_wishlist') || !absint($_POST['u'])) {
_e('Adding the item to your wishlist failed.', 'ignitewoo-wishlists-pro');
die;
}
$taxonomy_id = absint($_POST['wishlist_num']);
if (!$taxonomy_id) {
_e('There was an error adding the wishlist. Please try again shortly.', 'ignitewoo-wishlists-pro');
die;
}
$wishlist_type = get_term($taxonomy_id, 'c_wishlists_cat', OBJECT);
if (!$wishlist_type) {
_e('There was an error adding the wishlist. Please try again shortly.', 'ignitewoo-wishlists-pro');
die;
}
if ('' == trim(strip_tags($_POST['wishlist_title']))) {
_e('You must specify a Wishlist title.', 'ignitewoo-wishlists-pro');
die;
}
$user = absint($_POST['u']);
// We have 3 predefined types: public, private, and shared.
// Parse to find which string is in the slug so we can define the list.
// Do this just in case an admin modifies the taxonomies.
if (strpos($wishlist_type->slug, 'wishlist_public') !== false) {
$wishlist_type = 'public';
} else {
if (strpos($wishlist_type->slug, 'wishlist_private') !== false) {
$wishlist_type = 'private';
} else {
if (strpos($wishlist_type->slug, 'wishlist_shared') !== false) {
$wishlist_type = 'shared';
} else {
$wishlist_type = 'public';
}
}
}
$wishlist_title = $_POST['wishlist_title'];
$args = array('post_type' => 'custom_wishlists', 'post_title' => strip_tags($wishlist_title), 'post_content' => '', 'post_status' => 'publish', 'post_author' => $user);
$post_id = wp_insert_post($args);
if ($post_id) {
wp_set_post_terms($post_id, array($taxonomy_id), 'c_wishlists_cat');
update_post_meta($post_id, 'wishlist_type', $wishlist_type);
$event_type = isset($_POST['event-type']) ? $_POST['event-type'] : "";
$event_date = isset($_POST['event-date']) ? $_POST['event-date'] : "";
$co_registrant_name = isset($_POST['co-registrant-name']) ? $_POST['co-registrant-name'] : "";
$co_registrant_email = isset($_POST['co-registrant-email']) ? $_POST['co-registrant-email'] : "";
save_additional_wishlists_info($post_id, $user, $event_type, $event_date, $co_registrant_name, $co_registrant_email);
include CHEF_GIFT_REGISTRY_PLUGIN_DIR . '/wishlist-add-action-success-result.tpl.php';
die;
} else {
_e('There was an error adding the wishlist. Please try again shortly.', 'ignitewoo-wishlists-pro');
die;
}
}
开发者ID:TakenCdosG,项目名称:chefs,代码行数:55,代码来源:shortcodes.php
示例19: wpmp_add_product
function wpmp_add_product()
{
if (isset($_POST['__product_wpmp']) && wp_verify_nonce($_POST['__product_wpmp'], 'wpmp-product') && $_POST['task'] == '') {
//echo "here";exit;
if ($_POST['post_type'] == "wpmarketplace") {
global $current_user, $wpdb;
get_currentuserinfo();
$settings = get_option('_wpmp_settings');
$pstatus = $settings['fstatus'] ? $settings['fstatus'] : "draft";
$my_post = array('post_title' => $_POST['product']['post_title'], 'post_content' => $_POST['product']['post_content'], 'post_excerpt' => $_POST['product']['post_excerpt'], 'post_status' => $pstatus, 'post_author' => $current_user->ID, 'post_type' => "wpmarketplace");
if ($_POST['id']) {
//update post
$my_post['ID'] = $_REQUEST['id'];
wp_update_post($my_post);
$postid = $_REQUEST['id'];
} else {
//insert post
$postid = wp_insert_post($my_post);
}
update_post_meta($postid, "wpmp_list_opts", $_POST['wpmp_list']);
//set the product type
wp_set_post_terms($postid, $_POST['product_type'], "ptype");
foreach ($_POST['wpmp_list'] as $k => $v) {
update_post_meta($postid, $k, $v);
}
if ($_POST['wpmp_list']['fimage']) {
$wp_filetype = wp_check_filetype(basename($_POST['wpmp_list']['fimage']), null);
$attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($_POST['wpmp_list']['fimage'])), 'post_content' => '', 'guid' => $_POST['wpmp_list']['fimage'], 'post_status' => 'inherit');
$attach_id = wp_insert_attachment($attachment, $_POST['wpmp_list']['fimage'], $postid);
// you must first include the image.php file
// for the function wp_generate_attachment_metadata() to work
require_once ABSPATH . 'wp-admin/includes/image.php';
$attach_data = wp_generate_attachment_metadata($attach_id, $_POST['wpmp_list']['fimage']);
wp_update_attachment_metadata($attach_id, $attach_data);
set_post_thumbnail($postid, $attach_id);
}
//send admin email
if ($pstatus == "draft") {
//get user emai
global $current_user;
get_currentuserinfo();
mail($current_user->user_email, "New Product Added", "Your product is successfully added and is waiting to admin review. You will be notified if your product is accepetd or rejected.");
//now send notification to site admin about newly added product
$admin_email = get_bloginfo('admin_email');
mail($admin_email, "Product Review", "New Product is added by user " . $current_user->user_login . ". Please review this product to add your store.");
//add a new post meta to identify only drafted post
if (!update_post_meta($postid, '_z_user_review', '1')) {
add_post_meta($postid, '_z_user_review', '1', true);
}
}
}
header("Location: " . $_SERVER['HTTP_REFERER']);
die;
}
}
开发者ID:tvolmari,项目名称:hammydowns,代码行数:55,代码来源:functions.php
示例20: save
/**
* Save meta box data
*/
public static function save($post_id, $post)
{
update_post_meta($post_id, 'sp_minutes', sp_array_value($_POST, 'sp_minutes', get_option('sportspress_event_minutes', 90)));
$venues = array_filter(sp_array_value(sp_array_value($_POST, 'tax_input', array()), 'sp_venue', array()));
if (empty($venues)) {
$teams = sp_array_value($_POST, 'sp_team', array());
$team = reset($teams);
$venue = sp_get_the_term_id($team, 'sp_venue');
wp_set_post_terms($post_id, $venue, 'sp_venue');
}
}
开发者ID:ArnaudGuillou,项目名称:SiteESBVolley,代码行数:14,代码来源:class-sp-meta-box-event-details.php
注:本文中的wp_set_post_terms函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论