Skip to content

Commit

Permalink
Merge pull request #2 from Automattic/master
Browse files Browse the repository at this point in the history
Get latest
  • Loading branch information
turtlepod authored Mar 27, 2017
2 parents 8f71c19 + 6951d06 commit b2e9967
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
14 changes: 14 additions & 0 deletions includes/abstracts/abstract-wp-job-manager-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ public function __wakeup() {
* Process function. all processing code if needed - can also change view if step is complete
*/
public function process() {

// reset cookie
if (
isset( $_GET[ 'new' ] ) &&
isset( $_COOKIE[ 'wp-job-manager-submitting-job-id' ] ) &&
isset( $_COOKIE[ 'wp-job-manager-submitting-job-key' ] ) &&
get_post_meta( $_COOKIE[ 'wp-job-manager-submitting-job-id' ], '_submitting_key', true ) == $_COOKIE['wp-job-manager-submitting-job-key']
) {
delete_post_meta( $_COOKIE[ 'wp-job-manager-submitting-job-id' ], '_submitting_key' );
setcookie( 'wp-job-manager-submitting-job-id', '', time() - 3600, COOKIEPATH, COOKIE_DOMAIN, false );
setcookie( 'wp-job-manager-submitting-job-key', '', time() - 3600, COOKIEPATH, COOKIE_DOMAIN, false );
wp_redirect( remove_query_arg( array( 'new', 'key' ), $_SERVER[ 'REQUEST_URI' ] ) );
}

$step_key = $this->get_step_key( $this->step );

if ( $step_key && is_callable( $this->steps[ $step_key ]['handler'] ) ) {
Expand Down
5 changes: 4 additions & 1 deletion includes/forms/class-wp-job-manager-form-submit-job.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ public function __construct() {
}

// Allow resuming from cookie.
if ( ! $this->job_id && ! empty( $_COOKIE['wp-job-manager-submitting-job-id'] ) && ! empty( $_COOKIE['wp-job-manager-submitting-job-key'] ) ) {
$this->resume_edit = false;
if ( ! isset( $_GET[ 'new' ] ) && ( 'before' === get_option( 'job_manager_paid_listings_flow' ) || ! $this->job_id ) && ! empty( $_COOKIE['wp-job-manager-submitting-job-id'] ) && ! empty( $_COOKIE['wp-job-manager-submitting-job-key'] ) ) {
$job_id = absint( $_COOKIE['wp-job-manager-submitting-job-id'] );
$job_status = get_post_status( $job_id );

if ( ( 'preview' === $job_status || 'pending_payment' === $job_status ) && get_post_meta( $job_id, '_submitting_key', true ) === $_COOKIE['wp-job-manager-submitting-job-key'] ) {
$this->job_id = $job_id;
$this->resume_edit = get_post_meta( $job_id, '_submitting_key', true );
}
}

Expand Down Expand Up @@ -412,6 +414,7 @@ public function submit() {
get_job_manager_template( 'job-submit.php', array(
'form' => $this->form_name,
'job_id' => $this->get_job_id(),
'resume_edit' => $this->resume_edit,
'action' => $this->get_action(),
'job_fields' => $this->get_fields( 'job' ),
'company_fields' => $this->get_fields( 'company' ),
Expand Down
6 changes: 6 additions & 0 deletions templates/job-submit.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
?>
<form action="<?php echo esc_url( $action ); ?>" method="post" id="submit-job-form" class="job-manager-form" enctype="multipart/form-data">

<?php
if ( isset( $resume_edit ) && $resume_edit ) {
printf( '<p><strong>' . __( "You are editing an existing job. %s" ) . '</strong></p>', '<a href="?new=1&key=' . $resume_edit . '">' . __( 'Create A New Job' ) . '</a>' );
}
?>

<?php do_action( 'submit_job_form_start' ); ?>

<?php if ( apply_filters( 'submit_job_form_show_signin', true ) ) : ?>
Expand Down
1 change: 1 addition & 0 deletions wp-job-manager-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -919,3 +919,4 @@ function job_manager_duplicate_listing( $post_id ) {

return $new_post_id;
}

4 changes: 2 additions & 2 deletions wp-job-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ public function frontend_scripts() {
}
}

function job_manager_add_post_types( $types, $id ) {
function job_manager_add_post_types( $types ) {
$types[] = 'job_listing';
return $types;
}
add_filter( 'post_types_to_delete_with_user', 'job_manager_add_post_types', 10, 2 );
add_filter( 'post_types_to_delete_with_user', 'job_manager_add_post_types', 10 );

$GLOBALS['job_manager'] = new WP_Job_Manager();

0 comments on commit b2e9967

Please sign in to comment.