Advertisement
Guest User

Untitled

a guest
Mar 27th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <?php
  2. /**
  3. * Plugin Name: Remove Preview
  4. * Description: The very first plugin that I have ever created.
  5. * Version: 1.0
  6. * Author: Owen Bick
  7. */
  8. /**
  9. * Remove the preview step. Code goes in theme functions.php or custom plugin.
  10. * @param array $steps
  11. * @return array
  12. */
  13. function custom_submit_job_steps( $steps ) {
  14. unset( $steps['preview'] );
  15. return $steps;
  16. }
  17. add_filter( 'submit_job_steps', 'custom_submit_job_steps' );
  18.  
  19. /**
  20. * Change button text (won't work until v1.16.2)
  21. */
  22. function change_preview_text() {
  23. return __( 'Submit Job' );
  24. }
  25. add_filter( 'submit_job_form_submit_button_text', 'change_preview_text' );
  26.  
  27. /**
  28. * Since we removed the preview step and it's handler, we need to manually publish jobs
  29. * @param int $job_id
  30. */
  31. function done_publish_job( $job_id ) {
  32. $job = get_post( $job_id );
  33.  
  34. if ( in_array( $job->post_status, array( 'preview', 'expired' ) ) ) {
  35. // Reset expirey
  36. delete_post_meta( $job->ID, '_job_expires' );
  37.  
  38. // Update job listing
  39. $update_job = array();
  40. $update_job['ID'] = $job->ID;
  41. $update_job['post_status'] = get_option( 'job_manager_submission_requires_approval' ) ? 'pending' : 'publish';
  42. $update_job['post_date'] = current_time( 'mysql' );
  43. $update_job['post_date_gmt'] = current_time( 'mysql', 1 );
  44. wp_update_post( $update_job );
  45. }
  46. }
  47. add_action( 'job_manager_job_submitted', 'done_publish_job' ); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement