Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813

Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
pum_cleanup_post_meta_keys( int $post_id, array $keys_to_delete = array() )

Clean up postmeta by removing all keys from the given post_id.


Description Description


Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813

Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813

Parameters Parameters

$post_id

(Required)

$keys_to_delete

(Optional)

Default value: array()


Top ↑

Source Source

File: includes/functions/utils/upgrades.php

function pum_cleanup_post_meta_keys( $post_id = 0, $keys_to_delete = array() ) {
	/**
	 * Clean up automatically.
	 */
	if ( ! empty( $keys_to_delete ) ) {
		global $wpdb;

		$keys_to_delete = array_map( 'esc_sql', (array) $keys_to_delete );
		$meta_keys = implode( "','", $keys_to_delete );

		$query = $wpdb->prepare( "DELETE FROM `$wpdb->postmeta` WHERE `post_id` = %d AND `meta_key` IN ('{$meta_keys}')", $post_id );

		$wpdb->query( $query );

		wp_cache_delete( $post_id, 'post_meta' );
	}

}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.