Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //function to print publish button
- function show_publish_button(){
- Global $post;
- //only print fi admin
- if (current_user_can('manage_options')){
- echo '
- <form action="" method="POST" name="front_end_publish"><input id="pid" type="hidden" name="pid" value="'.$post->ID.'" />
- <input id="FE_PUBLISH" type="hidden" name="FE_PUBLISH" value="FE_PUBLISH" />
- <input id="submit" type="submit" name="submit" value="Publish" /></form>';
- }
- }
- //function to update post status
- function change_post_status($post_id,$status){
- $current_post = get_post( $post_id, 'ARRAY_A' );
- $current_post['post_status'] = $status;
- wp_update_post($current_post);
- }
- if (isset($_POST['FE_PUBLISH']) && $_POST['FE_PUBLISH'] == 'FE_PUBLISH'){
- if (isset($_POST['pid']) && !empty($_POST['pid'])){
- change_post_status((int)$_POST['pid'],'publish');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement