Advertisement
tzvij

Function file code publish button

Dec 16th, 2013
1,528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. //function to print publish button
  2. function show_publish_button(){
  3. Global $post;
  4. //only print fi admin
  5. if (current_user_can('manage_options')){
  6. echo '
  7.  
  8. <form action="" method="POST" name="front_end_publish"><input id="pid" type="hidden" name="pid" value="'.$post->ID.'" />
  9. <input id="FE_PUBLISH" type="hidden" name="FE_PUBLISH" value="FE_PUBLISH" />
  10. <input id="submit" type="submit" name="submit" value="Publish" /></form>';
  11. }
  12. }
  13.  
  14. //function to update post status
  15. function change_post_status($post_id,$status){
  16. $current_post = get_post( $post_id, 'ARRAY_A' );
  17. $current_post['post_status'] = $status;
  18. wp_update_post($current_post);
  19. }
  20.  
  21. if (isset($_POST['FE_PUBLISH']) && $_POST['FE_PUBLISH'] == 'FE_PUBLISH'){
  22. if (isset($_POST['pid']) && !empty($_POST['pid'])){
  23. change_post_status((int)$_POST['pid'],'publish');
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement