Skip to content

Instantly share code, notes, and snippets.

@Narga
Forked from cfxd/clear_jetpack_published.php
Last active August 29, 2015 14:07
Show Gist options
  • Save Narga/ada6c02f8f1875a586c5 to your computer and use it in GitHub Desktop.
Save Narga/ada6c02f8f1875a586c5 to your computer and use it in GitHub Desktop.
<?php
function clear_jetpack_published() {
if(empty($_REQUEST['post'])) {
wp_die(__('Invalid post ID or action'));
}
global $wpdb;
$id = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : '';
check_admin_referer('clear_jetpack_published_'.$id);
$all_post_meta = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$id");
if(count($all_post_meta) != 0) {
foreach ($all_post_meta as $post_meta) {
$meta_key = $post_meta->meta_key;
if(strpos($meta_key, '_wpas_done_all') !== false || strpos($meta_key, '_wpas_mess') !== false || strpos($meta_key, '_wpas_skip_') !== false) {
delete_post_meta($id, $meta_key);
}
}
}
wp_redirect(admin_url('post.php?action=edit&post='.$id));
exit;
}
add_action('admin_action_clear_jetpack_published', 'clear_jetpack_published');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment