-
-
Save Narga/ada6c02f8f1875a586c5 to your computer and use it in GitHub Desktop.
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 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'); |
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 clear_publicized_link() { | |
global $post; | |
if(!current_user_can('publish_posts') || !is_object($post)) { | |
return; | |
} | |
if(isset($_GET['post']) && get_post_meta($post->ID, '_wpas_done_all', true) == 1 && get_post_status($post->ID) !== 'publish') { | |
$notifyUrl = wp_nonce_url(admin_url("edit.php?post_type=product&action=clear_jetpack_published&post=".absint($_GET['post'])), 'clear_jetpack_published_'.$_GET['post']); ?> | |
<div id="jetpack-clear-action"><a class="submitjetpackclear jetpackclear" href="<?php echo esc_url($notifyUrl); ?>"><?php _e('Clear Jetpack Publicized status'); ?></a></div> | |
<?php | |
} | |
} | |
add_action('post_submitbox_start', 'clear_publicized_link'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment