本文整理汇总了PHP中delete_post_meta_by_key函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_post_meta_by_key函数的具体用法?PHP delete_post_meta_by_key怎么用?PHP delete_post_meta_by_key使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete_post_meta_by_key函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: affilboxUninstall
function affilboxUninstall()
{
if (!defined('WP_UNINSTALL_PLUGIN')) {
exit;
}
delete_option('affilboxOptions');
delete_post_meta_by_key('affilboxTrackingCode');
delete_post_meta_by_key('affilboxConversionCode');
}
示例2: deactivation
public function deactivation()
{
if (isset($_GET['deloption']) && $_GET['deloption']) {
delete_option('meta_keywords');
delete_option('meta_description');
delete_option('meta_manager_settings');
delete_post_meta_by_key('_keywords');
delete_post_meta_by_key('_description');
}
}
示例3: uninstall
static function uninstall()
{
global $wpdb;
$table_name = $wpdb->prefix . 'e4d';
do_action('e4d_before_table_drop', $table_name);
$wpdb->query("DROP TABLE IF EXISTS {$table_name}");
$htaccess_file = get_home_path() . '.htaccess';
$rules = array();
insert_with_markers($htaccess_file, 'e4d', $rules);
delete_post_meta_by_key('_e4d_require');
}
示例4: uninstall
/**
* Uninstall proccesses
*/
public static function uninstall()
{
$cf_posts = get_posts(array('post_type' => SCF_Config::NAME, 'posts_per_page' => -1, 'post_status' => 'any'));
foreach ($cf_posts as $post) {
wp_delete_post($post->ID, true);
}
delete_post_meta_by_key(SCF_Config::PREFIX . 'repeat-multiple-data');
// option の smart-cf-xxx を削除
global $wpdb;
$wpdb->query($wpdb->prepare("\n\t\t\t\tDELETE FROM {$wpdb->options}\n\t\t\t\t\tWHERE option_name LIKE %s\n\t\t\t\t", SCF_Config::PREFIX . '%'));
}
示例5: thim_export_front_page_displays_settings
/**
* Export meta data for front page displays settings
*/
function thim_export_front_page_displays_settings()
{
$page_for_posts = get_option('page_for_posts');
$page_on_front = get_option('page_on_front');
delete_post_meta_by_key('thim_page_for_posts');
delete_post_meta_by_key('thim_page_on_front');
if ($page_for_posts) {
update_post_meta($page_for_posts, 'thim_page_for_posts', 1);
}
if ($page_on_front) {
update_post_meta($page_on_front, 'thim_page_on_front', 1);
}
}
示例6: eshop_postmeta_upgrade
function eshop_postmeta_upgrade()
{
global $eshopoptions;
$new_options = array('_Sku' => 'sku', '_Product Description' => 'description', '_Shipping Rate' => 'shiprate', '_Featured Product' => 'featured', '_Stock Quantity' => 'qty', '_eshoposets' => 'optset');
//add on options and prices into the mix
$numoptions = $eshopoptions['options_num'];
if (!is_numeric($numoptions)) {
$numoptions = '3';
}
for ($i = 1; $i <= $numoptions; $i++) {
$new_options['_Option ' . $i] = array($i => 'option');
$new_options['_Price ' . $i] = array($i => 'price');
$new_options['_Download ' . $i] = array($i => 'download');
}
//go through every page and post
$args = array('post_type' => 'any', 'numberposts' => -1);
//add in transfer from prod download to _download here
$allposts = get_posts($args);
foreach ($allposts as $postinfo) {
//if(get_post_meta($postinfo->ID, '_eshop_product')!='')
// break;
foreach ($new_options as $oldfield => $newfield) {
$eshopvalue = get_post_meta($postinfo->ID, $oldfield, true);
if (is_array($newfield)) {
foreach ($newfield as $k => $v) {
$thenew_options['products'][$k][$v] = $eshopvalue;
}
} else {
$thenew_options[$newfield] = $eshopvalue;
}
if ($oldfield == '_Featured Product' && $eshopvalue == 'Yes') {
add_post_meta($postinfo->ID, '_eshop_featured', 'Yes');
}
}
if ($thenew_options['sku'] != '' && $thenew_options['description'] != '' && $thenew_options['products']['1']['option'] != '' && $thenew_options['products']['1']['price'] != '') {
add_post_meta($postinfo->ID, '_eshop_product', $thenew_options);
}
$stock = get_post_meta($postinfo->ID, '_Stock Available', true);
if (trim($stock) == 'Yes') {
add_post_meta($postinfo->ID, '_eshop_stock', '1');
}
}
//just make sure they are all gone
foreach ($new_options as $oldfield => $newfield) {
delete_post_meta_by_key($oldfield);
}
delete_post_meta_by_key('_Stock Available');
delete_post_meta_by_key('_eshop_prod_img');
/* post meta end */
}
示例7: _mgjp_mv_uninstall_local
/**
* Media Vault internal Uninstall function for a single
* blog install or for each blog site
* in network activation mode
*
* @since 0.8.5
*/
function _mgjp_mv_uninstall_local($blog_id = 0)
{
// Delete the default Media Vault placeholder image if it
// still exists
$ir['default'] = get_option('mgjp_mv_ir');
if ($ir['default'] && wp_attachment_is_image($ir['default'])) {
wp_delete_attachment($ir['default'], true);
}
// Delete all Media Vault local options from the local options table
delete_option('mgjp_mv_version');
delete_option('mgjp_mv_default_permission');
delete_option('mgjp_mv_options');
delete_option('mgjp_mv_ir');
// Delete all Media Vault attachment metadata from the local postmeta table
delete_post_meta_by_key('_mgjp_mv_permission');
delete_post_meta_by_key('mgjp_mv_meta');
}
示例8: helloPinsOnPluginUninstall
/**
* Uninstall function for cleaning up the database
*/
function helloPinsOnPluginUninstall()
{
if (!current_user_can('activate_plugins')) {
return;
}
check_admin_referer('bulk-plugins');
$postType = 'pinboard';
$options = 'hello_pins_settings';
$postMeta = array('_hello_pins', '_hello_pins_board', '_hello_pins_board_setting');
/**
* Delete Post Meta
*/
if (!empty($postMeta)) {
foreach ($postMeta as $k => $meta_key) {
delete_post_meta_by_key($meta_key);
}
}
/**
* Delete options field
*/
delete_option($options);
/**
* Delete posts
*/
$helloPinBoards = get_posts(array('post_type' => $postType, 'posts_per_page' => -1, 'post_status' => 'any'));
if (!empty($helloPinBoards)) {
foreach ($helloPinBoards as $kk => $board) {
wp_delete_post($board->ID, true);
}
}
$helloPinBoardsTrash = get_posts(array('post_type' => $postType, 'posts_per_page' => -1, 'post_status' => 'trash'));
if (!empty($helloPinBoardsTrash)) {
foreach ($helloPinBoardsTrash as $kk => $boardT) {
wp_delete_post($boardT->ID, true);
}
}
$helloPinBoardsDrafts = get_posts(array('post_type' => $postType, 'posts_per_page' => -1, 'post_status' => 'auto-draft'));
if (!empty($helloPinBoardsDrafts)) {
foreach ($helloPinBoardsDrafts as $kk => $boardD) {
wp_delete_post($boardD->ID, true);
}
}
}
示例9: ssb_uninstall
function ssb_uninstall()
{
delete_post_meta_by_key('ssb_post_sites');
//delete post meta from post
delete_option('ssb_share_version');
//delete option from database.
delete_option('ssb_share_filter_posttype');
//delete option from database.
delete_option('ssb_share_content_display');
//delete option from database.
delete_option('ssb_share_target_tab');
//delete option from database.
delete_option('ssb_share_content_themes');
//delete option from database.
delete_option('ssb_share_content_position');
//delete option from database.
delete_option('ssb_share_content_icon_margin');
//delete option from database.
}
示例10: remove_meta_tags
function remove_meta_tags()
{
header('Content-Type: application/json');
http_response_code(200);
$errors = array();
if ($_POST['type'] === 'post') {
delete_post_meta_by_key($_POST['key']);
delete_post_meta_by_key('_' . $_POST['key']);
} else {
if ($_POST['type'] === 'user') {
$users = get_users();
foreach ($users as $user) {
delete_user_meta($user->ID, $_POST['key']);
delete_user_meta($user->ID, '_' . $_POST['key']);
}
}
}
echo json_encode(array('status' => 'Finished'));
die;
}
示例11: timeline_pro_uninstall
function timeline_pro_uninstall()
{
$timeline_pro_delete = get_option('timeline_pro_delete');
if ($timeline_pro_delete == 'yes') {
delete_post_meta_by_key('timeline_pro_maincolor');
//delete post meta from post
delete_post_meta_by_key('timeline_pro_bgcolor');
//delete post meta from post
delete_post_meta_by_key('timeline_pro_posttype');
//delete post meta from post
delete_post_meta_by_key('timeline_pro_taxonomy');
//delete post meta from post
delete_post_meta_by_key('timeline_pro_taxonomy_category');
//delete post meta from post
delete_post_meta_by_key('timeline_pro_hide_thumb');
//delete post meta from post
delete_post_meta_by_key('timeline_pro_hide_share');
//delete post meta from post
delete_post_meta_by_key('timeline_pro_hide_zoom');
//delete post meta from post
delete_post_meta_by_key('timeline_pro_hide_comments');
//delete post meta from post
delete_post_meta_by_key('timeline_pro_content');
//delete post meta from post
delete_post_meta_by_key('timeline_pro_excrept_length');
//delete post meta from post
delete_post_meta_by_key('timeline_pro_excrept_readmore');
//delete post meta from post
delete_post_meta_by_key('timeline_pro_loadmore_text');
//delete post meta from post
delete_post_meta_by_key('timeline_pro_loading_text');
//delete post meta from post
//options
delete_option('timeline_pro_version');
//delete option from database.
delete_option('timeline_pro_delete');
//delete option from database.
}
}
示例12: save
/**
* Save post meta values
*
* Basic capability tests should already be applied by \Twitter\WordPress\Admin\Post\MetaBox::save before calling this method
*
* @since 1.0.0
*
* @param WP_Post $post WordPress post object
*
* @return void
*/
public static function save($post)
{
// test if post ID exists on object
if (!is_a($post, 'WP_Post')) {
return;
}
if (!isset($_POST[static::META_KEY])) {
return;
}
$fields = $_POST[static::META_KEY];
if (!is_array($fields)) {
return;
}
$fields = static::sanitizeFields($fields);
if (empty($fields)) {
delete_post_meta_by_key(static::META_KEY);
} else {
update_post_meta($post->ID, static::META_KEY, $fields);
}
}
示例13: test_delete_post_meta_by_key
function test_delete_post_meta_by_key()
{
// Add a unique post meta item
$this->assertInternalType('integer', add_post_meta($this->post_id, 'unique_delete_by_key', 'value', true));
$this->assertInternalType('integer', add_post_meta($this->post_id_2, 'unique_delete_by_key', 'value', true));
//Check they exist
$this->assertEquals('value', get_post_meta($this->post_id, 'unique_delete_by_key', true));
$this->assertEquals('value', get_post_meta($this->post_id_2, 'unique_delete_by_key', true));
//Delete one of them
$this->assertTrue(delete_post_meta_by_key('unique_delete_by_key'));
//Check the other still exists
$this->assertEquals('', get_post_meta($this->post_id_2, 'unique_delete_by_key', true));
$this->assertEquals('', get_post_meta($this->post_id_2, 'unique_delete_by_key', true));
}
示例14: clean_up
/**
* General clean-up of the saved meta values
* - Remove potentially lingering old meta keys
* - Remove all default and invalid values
*
* @static
* @return void
*/
public static function clean_up()
{
global $wpdb;
/**
* Clean up '_yoast_wpseo_meta-robots'
*
* Retrieve all '_yoast_wpseo_meta-robots' meta values and convert if no new values found
* @internal Query is pretty well optimized this way
*
* @todo [JRF => Yoast] find out all possible values which the old '_yoast_wpseo_meta-robots' could contain
* to convert the data correctly
*/
$query = $wpdb->prepare("\r\n\t\t\t\tSELECT `a`.*\r\n\t\t\t\tFROM {$wpdb->postmeta} AS a\r\n\t\t\t\tWHERE `a`.`meta_key` = %s\r\n\t\t\t\t\tAND NOT\tEXISTS (\r\n\t\t\t\t\t\tSELECT DISTINCT `post_id` , count( `meta_id` ) AS count\r\n\t\t\t\t\t\tFROM {$wpdb->postmeta} AS b\r\n\t\t\t\t\t\tWHERE `a`.`post_id` = `b`.`post_id`\r\n\t\t\t\t\t\t\tAND ( `meta_key` = %s\r\n\t\t\t\t\t\t\tOR `meta_key` = %s )\r\n\t\t\t\t\t\tGROUP BY `post_id`\r\n\t\t\t\t\t)\r\n\t\t\t\t;", self::$meta_prefix . 'meta-robots', self::$meta_prefix . 'meta-robots-noindex', self::$meta_prefix . 'meta-robots-nofollow');
$oldies = $wpdb->get_results($query);
if (is_array($oldies) && $oldies !== array()) {
foreach ($oldies as $old) {
$old_values = explode(',', $old->meta_value);
foreach ($old_values as $value) {
if ($value === 'noindex') {
update_post_meta($old->post_id, self::$meta_prefix . 'meta-robots-noindex', 1);
} elseif ($value === 'nofollow') {
update_post_meta($old->post_id, self::$meta_prefix . 'meta-robots-nofollow', 1);
}
}
}
}
unset($query, $oldies, $old, $old_values, $value);
// Delete old keys
delete_post_meta_by_key(self::$meta_prefix . 'meta-robots');
/**
* Remove all default values and (most) invalid option values
* Invalid option values for the multiselect (meta-robots-adv) field will be dealt with seperately
*
* @internal some of the defaults have changed in v1.5, but as the defaults will be removed and
* new defaults will now automatically be passed when no data found, this update is automatic
* (as long as we remove the old values which we do in the below routine)
*
* @internal unfortunately we can't use the normal delete_meta() with key/value combination as ''
* (empty string) values will be ignored and would result in all metas with that key being deleted,
* not just the empty fields.
* Still, the below implementation is largely based on the delete_meta() function
*/
$query = array();
foreach (self::$meta_fields as $subset => $field_group) {
foreach ($field_group as $key => $field_def) {
if ($field_def['type'] === 'snippetpreview' || !isset($field_def['default_value'])) {
continue;
}
if ($key === 'meta-robots-adv') {
$query[] = $wpdb->prepare("( meta_key = %s AND ( meta_value = 'none' OR meta_value = '-' ) )", self::$meta_prefix . $key);
} elseif (isset($field_def['options']) && is_array($field_def['options']) && $field_def['options'] !== array()) {
$valid = $field_def['options'];
// remove the default value from the valid options
unset($valid[$field_def['default_value']]);
$valid = array_keys($valid);
$query[] = $wpdb->prepare("( meta_key = %s AND meta_value NOT IN ( '" . implode("','", esc_sql($valid)) . "' ) )", self::$meta_prefix . $key);
unset($valid);
} elseif (is_string($field_def['default_value']) && $field_def['default_value'] !== '') {
$query[] = $wpdb->prepare('( meta_key = %s AND meta_value = %s )', self::$meta_prefix . $key, $field_def['default_value']);
} else {
$query[] = $wpdb->prepare("( meta_key = %s AND meta_value = '' )", self::$meta_prefix . $key);
}
}
}
unset($subset, $field_group, $key, $field_def, $where_or_or);
$query = "SELECT meta_id FROM {$wpdb->postmeta} WHERE " . implode(' OR ', $query) . ';';
$meta_ids = $wpdb->get_col($query);
if (is_array($meta_ids) && $meta_ids !== array()) {
// wp native action
do_action('delete_post_meta', $meta_ids, null, null, null);
$query = "DELETE FROM {$wpdb->postmeta} WHERE meta_id IN( " . implode(',', $meta_ids) . ' )';
$count = $wpdb->query($query);
if ($count) {
foreach ($meta_ids as $object_id) {
wp_cache_delete($object_id, 'post_meta');
}
// wp native action
do_action('deleted_post_meta', $meta_ids, null, null, null);
}
}
unset($query, $meta_ids, $count, $object_id);
/**
* Deal with the multiselect (meta-robots-adv) field
*
* Removes invalid option combinations, such as 'none,noarchive'
*
* Default values have already been removed, so we should have a small result set and
* (hopefully) even smaller set of invalid results.
*/
$query = $wpdb->prepare("SELECT meta_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = %s", self::$meta_prefix . 'meta-robots-adv');
$oldies = $wpdb->get_results($query);
if (is_array($oldies) && $oldies !== array()) {
//.........这里部分代码省略.........
示例15: delete_option
<?php
/**
* Tumblr Crosspostr uninstaller
*
* @package plugin
*/
// Don't execute any uninstall code unless WordPress core requests it.
if (!defined('WP_UNINSTALL_PLUGIN')) {
exit;
}
// Delete options.
delete_option('tumblr_crosspostr_settings');
delete_option('_tumblr_crosspostr_admin_notices');
delete_option('tumblr_crosspostr_access_token');
delete_option('tumblr_crosspostr_access_token_secret');
delete_post_meta_by_key('tumblr_crosspostr_crosspost');
/**
* TODO: Should we really delete this post meta?
* That'll wipe Tumblr post IDs and blog hostnames. :\
* We need these to be able to re-associate WordPress posts
* with the Tumblr posts that they were cross-posted to.
*/
// delete_post_meta_by_key('tumblr_post_id');
// delete_post_meta_by_key('tumblr_base_hostname');