-
-
Save kish2011/fce8f924d7b2563018111c51e73ddc95 to your computer and use it in GitHub Desktop.
Remove preview step for job and resume (WP Job Manager)
This file contains hidden or 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
/** | |
* Remove the preview step for Job | |
* @param array $steps | |
* @return array | |
*/ | |
if ( !function_exists( 'handyman_custom_submit_job_steps' ) ) { | |
function handyman_custom_submit_job_steps( $steps ) { | |
unset( $steps['preview'] ); | |
return $steps; | |
} | |
add_filter( 'submit_job_steps', 'handyman_custom_submit_job_steps' ); | |
} | |
/** | |
* Change button text | |
*/ | |
if ( !function_exists( 'handyman_change_preview_text' ) ) { | |
function handyman_change_preview_text() { | |
return esc_html__( 'Submit Job', 'handyman' ); | |
} | |
add_filter( 'submit_job_form_submit_button_text', 'handyman_change_preview_text' ); | |
} | |
/** | |
* Since we removed the preview step and it's handler, we need to manually publish jobs | |
* @param int $job_id | |
*/ | |
if ( !function_exists( 'handyman_done_publish_job' ) ) { | |
function handyman_done_publish_job( $job_id ) { | |
$job = get_post( $job_id ); | |
if ( in_array( $job->post_status, array( 'preview', 'expired' ) ) ) { | |
// Reset expirey | |
delete_post_meta( $job->ID, '_job_expires' ); | |
// Update job listing | |
$update_job = array(); | |
$update_job['ID'] = $job->ID; | |
$update_job['post_status'] = get_option( 'job_manager_submission_requires_approval' ) ? 'pending' : 'publish'; | |
$update_job['post_date'] = current_time( 'mysql' ); | |
$update_job['post_date_gmt'] = current_time( 'mysql', 1 ); | |
wp_update_post( $update_job ); | |
} | |
} | |
add_action( 'job_manager_job_submitted', 'handyman_done_publish_job' ); | |
} | |
/** | |
* Remove the preview step for Resumes | |
* @param array $steps | |
* @return array | |
*/ | |
if ( !function_exists( 'handyman_wpjm_remove_resume_preview_step' ) ) { | |
function handyman_wpjm_remove_resume_preview_step( $steps ) { | |
unset( $steps['preview'] ); | |
return $steps; | |
} | |
add_filter( 'submit_resume_steps', 'handyman_wpjm_remove_resume_preview_step' ); | |
} | |
/** | |
* Change button text (won't work until v1.16.2) | |
*/ | |
if ( !function_exists( 'handyman_wpjm_change_resume_button_text' ) ) { | |
function handyman_wpjm_change_resume_button_text() { | |
return esc_html__( 'Submit Resume', 'handyman' ); | |
} | |
add_filter( 'submit_resume_form_submit_button_text', 'handyman_wpjm_change_resume_button_text' ); | |
} | |
/** | |
* Since we removed the preview step and it's handler, we need to manually publish resumes | |
* @param int $resume_id | |
*/ | |
if ( !function_exists( 'handyman_wpjm_manually_publish_resume' ) ) { | |
function handyman_wpjm_manually_publish_resume( $resume_id ) { | |
$resume = get_post( $resume_id ); | |
if ( in_array( $resume->post_status, array( 'preview', 'expired' ) ) ) { | |
// Reset expirey | |
delete_post_meta( $resume->ID, '_resume_expires' ); | |
// Update resume listing | |
$update_resume = array(); | |
$update_resume['ID'] = $resume->ID; | |
$update_resume['post_status'] = apply_filters( 'submit_resume_post_status', get_option( 'resume_manager_submission_requires_approval' ) ? 'pending' : 'publish', $resume ); | |
wp_update_post( $update_resume ); | |
} | |
} | |
add_action( 'resume_manager_resume_submitted', 'handyman_wpjm_manually_publish_resume' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment