本文整理汇总了PHP中wp_delete_object_term_relationships函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_delete_object_term_relationships函数的具体用法?PHP wp_delete_object_term_relationships怎么用?PHP wp_delete_object_term_relationships使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_delete_object_term_relationships函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wp_delete_link
function wp_delete_link($link_id)
{
global $wpdb;
do_action('delete_link', $link_id);
wp_delete_object_term_relationships($link_id, 'link_category');
$wpdb->query("DELETE FROM {$wpdb->links} WHERE link_id = '{$link_id}'");
do_action('deleted_link', $link_id);
return true;
}
示例2: wp_delete_link
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $link_id
* @return unknown
*/
function wp_delete_link($link_id)
{
global $wpdb;
do_action('delete_link', $link_id);
wp_delete_object_term_relationships($link_id, 'link_category');
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->links} WHERE link_id = %d", $link_id));
do_action('deleted_link', $link_id);
clean_bookmark_cache($link_id);
return true;
}
示例3: wp_delete_link
/**
* Delete link specified from database
*
* @since 2.0.0
*
* @param int $link_id ID of the link to delete
* @return bool True
*/
function wp_delete_link($link_id)
{
global $wpdb;
do_action('delete_link', $link_id);
wp_delete_object_term_relationships($link_id, 'link_category');
$wpdb->delete($wpdb->links, array('link_id' => $link_id));
do_action('deleted_link', $link_id);
clean_bookmark_cache($link_id);
return true;
}
示例4: 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');
}
}
示例5: test_delete_object_term_relationships
public function test_delete_object_term_relationships()
{
$anther_term = wp_insert_term('mouse', $this->taxonomy);
wp_set_post_terms($this->post_id, array($anther_term['term_id']), $this->taxonomy, false);
$anther_term_2 = wp_insert_term('cat', $this->taxonomy);
wp_set_post_terms($this->post_id, array($anther_term_2['term_id']), $this->taxonomy, true);
wp_delete_object_term_relationships($this->post_id, array($this->taxonomy));
$this->client->do_sync();
$object_terms = get_the_terms($this->post_id, $this->taxonomy);
$server_object_terms = $this->server_replica_storage->get_the_terms($this->post_id, $this->taxonomy);
$this->assertEquals($object_terms, $server_object_terms);
}
示例6: delete_series_post_relationship
function delete_series_post_relationship($postid)
{
$id = (int) $postid;
$series = get_the_series($id);
if (!empty($series)) {
//let's not waste any cycles
foreach ($series as $ser) {
wp_reset_series_order_meta_cache($id, $ser->term_id);
}
return wp_delete_object_term_relationships($id, array('series'));
}
return;
}
示例7: save
/**
* Save meta box data
*/
public static function save($post_id, $post)
{
global $wpdb;
update_post_meta($post_id, '_on_market', isset($_POST['_on_market']) ? $_POST['_on_market'] : '');
update_post_meta($post_id, '_featured', isset($_POST['_featured']) ? $_POST['_featured'] : '');
if (!empty($_POST['_availability'])) {
wp_set_post_terms($post_id, $_POST['_availability'], 'availability');
} else {
// Setting to blank
wp_delete_object_term_relationships($post_id, 'availability');
}
wp_delete_object_term_relationships($post_id, 'marketing_flag');
if (!empty($_POST['_marketing_flags'])) {
wp_set_post_terms($post_id, $_POST['_marketing_flags'], 'marketing_flag');
}
do_action('propertyhive_save_property_marketing', $post_id);
}
示例8: test_array_of_taxonomies
public function test_array_of_taxonomies()
{
register_taxonomy('wptests_tax1', 'post');
register_taxonomy('wptests_tax2', 'post');
register_taxonomy('wptests_tax3', 'post');
$t1 = $this->factory->term->create(array('taxonomy' => 'wptests_tax1'));
$t2 = $this->factory->term->create(array('taxonomy' => 'wptests_tax2'));
$t3 = $this->factory->term->create(array('taxonomy' => 'wptests_tax3'));
$object_id = 567;
wp_set_object_terms($object_id, array($t1), 'wptests_tax1');
wp_set_object_terms($object_id, array($t2), 'wptests_tax2');
wp_set_object_terms($object_id, array($t3), 'wptests_tax3');
// Confirm the setup.
$terms = wp_get_object_terms($object_id, array('wptests_tax1', 'wptests_tax2', 'wptests_tax3'), array('fields' => 'ids'));
$this->assertEqualSets(array($t1, $t2, $t3), $terms);
// wp_delete_object_term_relationships() doesn't have a return value.
wp_delete_object_term_relationships($object_id, array('wptests_tax1', 'wptests_tax3'));
$terms = wp_get_object_terms($object_id, array('wptests_tax1', 'wptests_tax2', 'wptests_tax3'), array('fields' => 'ids'));
$this->assertEqualSets(array($t2), $terms);
}
示例9: toggle_case_result
function toggle_case_result($comment_ID)
{
$comment = get_comment($comment_ID);
$post = get_post($comment->comment_post_ID);
//Check case single
if ('cases' != $post->post_type) {
return;
}
if (isset($_POST['close_case_comment_cp'])) {
if (isset($_POST['case_result_select'])) {
$result = $_POST['case_result_select'];
}
$tag = get_term_by('id', $result, 'results');
$answer = wp_set_object_terms($post->ID, $tag->term_id, 'results');
return;
} elseif (isset($_POST['case_reset_result_cp'])) {
wp_delete_object_term_relationships($post->ID, 'results');
return;
}
}
示例10: deleteAll
function deleteAll($product_id = 0)
{
global $wpdb;
if ($product_id > 0) {
if ($attributes = $wpdb->get_results("SELECT attribute_name FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies")) {
foreach ($attributes as $attribute) {
wp_delete_object_term_relationships($product_id, 'pa_' . $attribute->attribute_name);
}
}
$transient_name = 'wc_product_children_ids_' . $product_id;
delete_transient($transient_name);
}
$ids = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type='product_variation' " . ($product_id > 0 ? "AND post_parent='" . (int) $product_id . "'" : ""), 'ARRAY_A');
if (!empty($ids)) {
foreach ($ids as $id) {
$x = (int) $id['ID'];
$wpdb->query("DELETE FROM " . $wpdb->posts . " WHERE ID='" . $x . "'");
$wpdb->query("DELETE FROM " . $wpdb->postmeta . " WHERE post_id='" . $x . "'");
}
}
}
示例11: wp_set_terms_for_user
/**
* Save taxonomy terms for a specific user
*
* @since 0.1.0
*
* @param int $user_id
* @param string $taxonomy
* @param array $terms
* @param boolean $bulk
*
* @return boolean
*/
function wp_set_terms_for_user($user_id, $taxonomy, $terms = array(), $bulk = false)
{
// Get the taxonomy
$tax = get_taxonomy($taxonomy);
// Make sure the current user can edit the user and assign terms before proceeding.
if (!current_user_can('edit_user', $user_id) && current_user_can($tax->cap->assign_terms)) {
return false;
}
if (empty($terms) && empty($bulk)) {
$terms = isset($_POST[$taxonomy]) ? $_POST[$taxonomy] : null;
}
// Delete all user terms
if (is_null($terms) || empty($terms)) {
wp_delete_object_term_relationships($user_id, $taxonomy);
// Set the terms
} else {
$_terms = array_map('sanitize_key', $terms);
// Sets the terms for the user
wp_set_object_terms($user_id, $_terms, $taxonomy, false);
}
// Clean the cache
clean_object_term_cache($user_id, $taxonomy);
}
示例12: delete_term_language
public function delete_term_language($term_id)
{
wp_delete_object_term_relationships($term_id, 'term_language');
}
示例13: save
/**
* Validate and save the meta box fields.
*
* @since 3.0.0
*
* @param int $post_id
* @param \WP_Post $post
*
* @return void
*/
public static function save($post_id, $post)
{
/* ====================== *
* Calendar type and view *
* ====================== */
// Unlink existing terms for feed type and calendar type.
wp_delete_object_term_relationships($post_id, array('calendar_feed', 'calendar_type'));
// Set the feed type as term.
$feed_type = isset($_POST['_feed_type']) ? sanitize_title(stripslashes($_POST['_feed_type'])) : apply_filters('simcal_default_feed_type', 'google');
wp_set_object_terms($post_id, $feed_type, 'calendar_feed');
// Set the calendar type as a term.
$calendar_type = isset($_POST['_calendar_type']) ? sanitize_title(stripslashes($_POST['_calendar_type'])) : apply_filters('simcal_default_calendar_type', 'default-calendar');
wp_set_object_terms($post_id, $calendar_type, 'calendar_type');
// Set the calendar type view as post meta.
$calendar_view = isset($_POST['_calendar_view']) ? $_POST['_calendar_view'] : '';
if ($calendar_view && is_array($calendar_view)) {
$views = array_map('sanitize_title', $calendar_view);
update_post_meta($post_id, '_calendar_view', $views);
}
/* ===================== *
* Events settings panel *
* ===================== */
// Calendar opening.
$calendar_begins = isset($_POST['_calendar_begins']) ? sanitize_key($_POST['_calendar_begins']) : 'this_month';
update_post_meta($post_id, '_calendar_begins', $calendar_begins);
$calendar_begins_nth = isset($_POST['_calendar_begins_nth']) ? absint($_POST['_calendar_begins_nth']) : 2;
update_post_meta($post_id, '_calendar_begins_nth', $calendar_begins_nth);
$calendar_begins_custom_date = isset($_POST['_calendar_begins_custom_date']) ? sanitize_title($_POST['_calendar_begins_custom_date']) : '';
update_post_meta($post_id, '_calendar_begins_custom_date', $calendar_begins_custom_date);
// Feed earliest events date.
$earliest_events = isset($_POST['_feed_earliest_event_date']) ? sanitize_key($_POST['_feed_earliest_event_date']) : '';
update_post_meta($post_id, '_feed_earliest_event_date', $earliest_events);
$earliest_events_range = isset($_POST['_feed_earliest_event_date_range']) ? max(absint($_POST['_feed_earliest_event_date_range']), 1) : 1;
update_post_meta($post_id, '_feed_earliest_event_date_range', $earliest_events_range);
// Feed latest events date.
$latest_events = isset($_POST['_feed_latest_event_date']) ? sanitize_key($_POST['_feed_latest_event_date']) : '';
update_post_meta($post_id, '_feed_latest_event_date', $latest_events);
$latest_events_range = isset($_POST['_feed_latest_event_date_range']) ? max(absint($_POST['_feed_latest_event_date_range']), 1) : 1;
update_post_meta($post_id, '_feed_latest_event_date_range', $latest_events_range);
/* ======================= *
* Calendar settings panel *
* ======================= */
// Static calendar.
$static = isset($_POST['_calendar_is_static']) ? 'yes' : 'no';
update_post_meta($post_id, '_calendar_is_static', $static);
// No events message.
$message = isset($_POST['_no_events_message']) ? wp_kses_post($_POST['_no_events_message']) : '';
update_post_meta($post_id, '_no_events_message', $message);
/* ======================= *
* Advanced settings panel *
* ======================= */
// Timezone.
$feed_timezone_setting = isset($_POST['_feed_timezone_setting']) ? sanitize_key($_POST['_feed_timezone_setting']) : 'use_calendar';
update_post_meta($post_id, '_feed_timezone_setting', $feed_timezone_setting);
$default_timezone = simcal_get_wp_timezone();
$feed_timezone = $default_timezone ? $default_timezone : 'UTC';
$feed_timezone = isset($_POST['_feed_timezone']) ? sanitize_text_field($_POST['_feed_timezone']) : $feed_timezone;
update_post_meta($post_id, '_feed_timezone', $feed_timezone);
// Date format.
$date_format_setting = isset($_POST['_calendar_date_format_setting']) ? sanitize_key($_POST['_calendar_date_format_setting']) : 'use_site';
update_post_meta($post_id, '_calendar_date_format_setting', $date_format_setting);
$date_format = isset($_POST['_calendar_date_format']) ? sanitize_text_field(trim($_POST['_calendar_date_format'])) : get_option('date_format');
update_post_meta($post_id, '_calendar_date_format', $date_format);
$date_format_php = isset($_POST['_calendar_date_format_php']) ? sanitize_text_field(trim($_POST['_calendar_date_format_php'])) : get_option('date_format');
update_post_meta($post_id, '_calendar_date_format_php', $date_format_php);
// Time format.
$time_format_setting = isset($_POST['_calendar_time_format_setting']) ? sanitize_key($_POST['_calendar_time_format_setting']) : 'use_site';
update_post_meta($post_id, '_calendar_time_format_setting', $time_format_setting);
$time_format = isset($_POST['_calendar_time_format']) ? sanitize_text_field(trim($_POST['_calendar_time_format'])) : get_option('time_format');
update_post_meta($post_id, '_calendar_time_format', $time_format);
$time_format_php = isset($_POST['_calendar_time_format_php']) ? sanitize_text_field(trim($_POST['_calendar_time_format_php'])) : get_option('time_format');
update_post_meta($post_id, '_calendar_time_format_php', $time_format_php);
// Date-time separator.
$datetime_separator = isset($_POST['_calendar_datetime_separator']) ? sanitize_text_field($_POST['_calendar_datetime_separator']) : ' ';
update_post_meta($post_id, '_calendar_datetime_separator', $datetime_separator);
// Week start.
$week_start_setting = isset($_POST['_calendar_week_starts_on_setting']) ? sanitize_key($_POST['_calendar_week_starts_on_setting']) : 'use_site';
update_post_meta($post_id, '_calendar_week_starts_on_setting', $week_start_setting);
$week_start = isset($_POST['_calendar_week_starts_on']) ? intval($_POST['_calendar_week_starts_on']) : get_option('start_of_week');
update_post_meta($post_id, '_calendar_week_starts_on', $week_start);
// Cache interval.
$cache = 7200;
if (isset($_POST['_feed_cache_user_amount']) && isset($_POST['_feed_cache_user_unit'])) {
$amount = is_numeric($_POST['_feed_cache_user_amount']) ? absint($_POST['_feed_cache_user_amount']) : 1;
$unit = is_numeric($_POST['_feed_cache_user_unit']) ? absint($_POST['_feed_cache_user_unit']) : 3600;
update_post_meta($post_id, '_feed_cache_user_amount', $amount);
update_post_meta($post_id, '_feed_cache_user_unit', $unit);
$cache = $amount * $unit;
}
update_post_meta($post_id, '_feed_cache', $cache);
//.........这里部分代码省略.........
示例14: load_tools_page
/**
* Hooks the dynamic load-* action called when
* this tools page loads.
*
* @return void
**/
public function load_tools_page()
{
if (!($action = isset($_GET['btgt_action']) ? sanitize_text_field($_GET['btgt_action']) : false)) {
return;
}
$obj_id = isset($_GET['obj_id']) ? absint($_GET['obj_id']) : false;
$wp_nonce = isset($_GET['_wpnonce']) ? sanitize_text_field($_GET['_wpnonce']) : false;
if (!$wp_nonce || !wp_verify_nonce($wp_nonce, "btgt_{$action}_{$obj_id}")) {
$this->set_admin_error('Sorry, went wrong. Please try again.');
return;
}
switch ($action) {
case 'delete_from_groups':
if (!current_user_can('manage_options')) {
$this->set_admin_error("You are not allowed to delete term relation ships for {$obj_id}.");
return;
}
wp_delete_object_term_relationships($obj_id, 'post_translation');
$this->set_admin_notice("Deleted term relationships for {$obj_id}");
break;
case 'delete_post':
if (!current_user_can('delete_post', $obj_id)) {
$this->set_admin_error('You are not allowed to move this post to the trash.');
return;
}
wp_delete_object_term_relationships($obj_id, 'post_translation');
wp_delete_post($obj_id, true);
break;
case 'trash_post':
if (!current_user_can('delete_post', $obj_id)) {
$this->set_admin_error('You are not allowed to move this post to the trash.');
return;
}
wp_delete_object_term_relationships($obj_id, 'post_translation');
wp_trash_post($obj_id);
break;
}
$args = array('page' => 'btgt', 'lang' => bbl_get_default_lang_code());
$args = array_map('rawurlencode', $args);
$url = add_query_arg($args, admin_url('tools.php'));
$url .= '#' . rawurlencode($_GET['anchor']);
wp_safe_redirect($url);
}
示例15: wepn_save_user_city_group_category
/**
* Saves the term selected on the edit user/profile page in the admin. This function is triggered when the page
* is updated. We just grab the posted data and use wp_set_object_terms() to save it.
*
* @param int $user_id The ID of the user to save the terms for.
*/
public function wepn_save_user_city_group_category($user_id)
{
if (!WEPN_Helper::check_user_role('vendor', $user_id)) {
return;
}
global $wpdb;
$company_name = esc_attr($_POST['company_name']);
$company_id = get_user_meta($user_id, 'company', true);
if ($company_id && is_numeric($company_id)) {
wp_update_post(array('ID' => $company_id, 'post_title' => $company_name, 'post_author' => $user_id, 'post_type' => 'vendor', 'post_status' => 'publish'));
} else {
$company_id = $wpdb->get_var("SELECT ID FROM wp_posts WHERE post_title = '" . $company_name . "'");
if (!empty($company_name) && !$company_id) {
$company_id = wp_insert_post(array('post_title' => $company_name, 'post_author' => $user_id, 'post_type' => 'vendor', 'post_status' => 'publish'));
update_user_meta($user_id, 'company', $company_id);
}
}
// Update Post Meta
update_post_meta($company_id, 'vendor', $user_id);
//Only administrator can change this section
if (current_user_can('manage_options')) {
$city = $_POST['city'];
$group = $_POST['group'];
$category = $_POST['category'];
$group_slug = sanitize_title($group);
$category_slug = sanitize_title($category);
$other_categories = (array) (!empty($_POST['categories']) ? $_POST['categories'] : array());
// Remove existing post and term relatinships
$old_tax = get_post_meta($company_id, 'city', true);
wp_delete_object_term_relationships($company_id, $old_tax);
if (!in_array($category, $other_categories)) {
$other_categories = array_merge($other_categories, array($category));
}
if (count($other_categories) > 0) {
$terms = array();
foreach ($other_categories as $term_title) {
if (empty($term_title)) {
continue;
}
$term_slug = sanitize_title($term_title);
if (!($term = term_exists($term_title, $city))) {
$term = wp_insert_term($term_title, $city, array('slug' => $term_slug));
}
if (!is_wp_error($term)) {
$terms[] = $term['term_id'];
}
}
wp_set_post_terms($company_id, $terms, $city, false);
}
// Update custom permalink
update_post_meta($company_id, 'custom_permalink', $city . '/' . $group_slug . '/' . $category_slug . '/' . sanitize_title($company_name));
update_post_meta($company_id, 'region', $group_slug);
update_post_meta($company_id, 'city', $city);
update_post_meta($company_id, 'category', $category_slug);
// Update user meta
update_user_meta($user_id, 'city', $city);
update_user_meta($user_id, 'group', $group_slug);
update_user_meta($user_id, 'category', $category_slug);
}
}