Last active
August 29, 2015 14:13
-
-
Save fjarrett/be5423e0899895558d75 to your computer and use it in GitHub Desktop.
Delete unwanted Stream Notification Rule post meta from other post types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wp_stream_scrub_notification_rule_post_meta() { | |
$post_types = get_post_types( array(), 'names' ); | |
unset( $post_types['stream_notification'] ); | |
$args = array( | |
'post_type' => $post_types, | |
'post_status' => 'any', | |
'meta_key' => 'triggers', | |
'posts_per_page' => -1, | |
'no_found_rows' => true, | |
); | |
$posts = get_posts( $args ); | |
if ( ! $posts ) { | |
return; | |
} | |
foreach ( $posts as $post ) { | |
delete_post_meta( $post->ID, 'triggers' ); | |
delete_post_meta( $post->ID, 'groups' ); | |
delete_post_meta( $post->ID, 'alerts' ); | |
} | |
} | |
add_action( 'init', 'wp_stream_scrub_notification_rule_post_meta', 11 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put this code in your theme's
functions.php
file to remove unwanted Stream Notification rule meta from your other post types, which was a bug reported here: xwp/stream#693Don't leave this in your functions file, because it will run on every page load. You should remove it after you've refreshed at least once.
Also, it might take a while to refresh the first time depending on the number of posts you have. If you have 10,000+ posts or something, it won't be a good idea to run this code.