Skip to content

Instantly share code, notes, and snippets.

@cfxd
Last active February 21, 2021 18:33
Show Gist options
  • Save cfxd/c0d949e0e63aa4edf460 to your computer and use it in GitHub Desktop.
Save cfxd/c0d949e0e63aa4edf460 to your computer and use it in GitHub Desktop.
Clear Jetpack's Publicized data to re-Publicize posts. See http://cfxdesign.com/how-to-re-publicize-posts-with-jetpack/
<?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');
@humbertorames
Copy link

thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment