/**
  * Handle the form when the preview page is submitted
  */
 public static function preview_handler()
 {
     if (!$_POST) {
         return;
     }
     if (version_compare(JOB_MANAGER_VERSION, '1.22.0', '<')) {
         // Edit = show submit form again
         if (!empty($_POST['edit_job'])) {
             WP_Job_Manager_Form_Submit_Job::previous_step();
         }
         // Continue to the next step
         if (!empty($_POST['continue'])) {
             $job = get_post(WP_Job_Manager_Form_Submit_Job::get_job_id());
             // Update job status to pending_payment
             if ($job->post_status == 'preview') {
                 $update_job = array();
                 $update_job['ID'] = $job->ID;
                 $update_job['post_status'] = 'pending_payment';
                 wp_update_post($update_job);
             }
             // If we're already chosen a package, apply its properties to the job here and add to cart
             if ('before' === get_option('job_manager_paid_listings_flow')) {
                 // Validate Selected Package
                 $validation = self::validate_package(self::$package_id, self::$is_user_package);
                 if (is_wp_error($validation)) {
                     WP_Job_Manager_Form_Submit_Job::add_error($validation->get_error_message());
                     WP_Job_Manager_Form_Submit_Job::previous_step();
                     WP_Job_Manager_Form_Submit_Job::previous_step();
                     return;
                 }
                 self::process_package(self::$package_id, self::$is_user_package, WP_Job_Manager_Form_Submit_Job::get_job_id());
                 WP_Job_Manager_Form_Submit_Job::next_step();
                 // Proceeed to the choose package step if the above did not redirect
             } else {
                 WP_Job_Manager_Form_Submit_Job::next_step();
             }
         }
     } else {
         $form = WP_Job_Manager_Form_Submit_Job::instance();
         // Edit = show submit form again
         if (!empty($_POST['edit_job'])) {
             $form->previous_step();
         }
         // Continue to the next step
         if (!empty($_POST['continue'])) {
             $job = get_post($form->get_job_id());
             // Update job status to pending_payment
             if ($job->post_status == 'preview') {
                 $update_job = array();
                 $update_job['ID'] = $job->ID;
                 $update_job['post_status'] = 'pending_payment';
                 wp_update_post($update_job);
             }
             // If we're already chosen a package, apply its properties to the job here and add to cart
             if ('before' === get_option('job_manager_paid_listings_flow')) {
                 // Validate Selected Package
                 $validation = self::validate_package(self::$package_id, self::$is_user_package);
                 if (is_wp_error($validation)) {
                     $form->add_error($validation->get_error_message());
                     $form->previous_step();
                     $form->previous_step();
                     return;
                 }
                 self::process_package(self::$package_id, self::$is_user_package, $form->get_job_id());
                 $form->next_step();
                 // Proceeed to the choose package step if the above did not redirect
             } else {
                 $form->next_step();
             }
         }
     }
 }
 /**
  * Main Instance
  */
 public static function instance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #3
0
 function wpjm()
 {
     if (!$this->wpjm) {
         $this->wpjm = WP_Job_Manager_Form_Submit_Job::instance();
     }
     return $this->wpjm;
 }
Example #4
0
/**
 * Preview View
 *
 * The default "Preview" view in WP Job Manager adds a little extra and doesn't
 * use the exact template file that displays what we need. Override it here.
 *
 * @since Jobify 1.6.0
 *
 * @return void
 */
function jobify_preview_handler()
{
    global $job_manager, $post;
    if (version_compare(JOB_MANAGER_VERSION, '1.22.0', '<')) {
        $job_id = WP_Job_Manager_Form_Submit_Job::get_job_id();
        $step = WP_Job_Manager_Form_Submit_Job::get_step();
        $form_name = WP_Job_Manager_Form_Submit_Job::$form_name;
    } else {
        $form = WP_Job_Manager_Form_Submit_Job::instance();
        $job_id = $form->get_job_id();
        $step = $form->get_step();
        $form_name = $form->form_name;
    }
    if ($job_id) {
        $post = get_post($job_id);
        setup_postdata($post);
        ?>
		<form method="post" id="job_preview">
			<div class="job_listing_preview_title">
				<input type="submit" name="continue" id="job_preview_submit_button" class="button" value="<?php 
        echo apply_filters('submit_job_step_preview_submit_text', __('Submit Listing &rarr;', 'jobify'));
        ?>
" />
				<input type="submit" name="edit_job" class="button" value="<?php 
        esc_attr_e('&larr; Edit listing', 'jobify');
        ?>
" />
				<input type="hidden" name="job_id" value="<?php 
        echo esc_attr($job_id);
        ?>
" />
				<input type="hidden" name="step" value="<?php 
        echo esc_attr($step);
        ?>
" />
				<input type="hidden" name="job_manager_form" value="<?php 
        echo $form_name;
        ?>
" />
			</div>
			<?php 
        get_job_manager_template_part('content-single', 'job');
        ?>
		</form>
		<?php 
        wp_reset_postdata();
    }
}
Example #5
0
/**
 * Output Preview Step for WP Job Manager Submit Form
 */
function listable_submit_form_preview()
{
    global $post, $job_preview;
    $instance = WP_Job_Manager_Form_Submit_Job::instance();
    if ($instance->get_job_id()) {
        $job_preview = true;
        $action = $instance->get_action();
        $post = get_post($instance->get_job_id());
        setup_postdata($post);
        $post->post_status = 'preview';
        ?>
		<form method="post" id="job_preview" action="<?php 
        echo esc_url($action);
        ?>
">
			<div class="job_listing_preview_title">
				<input type="submit" name="continue" id="job_preview_submit_button" class="button job-manager-button-submit-listing" value="<?php 
        echo apply_filters('submit_job_step_preview_submit_text', __('Submit Listing', 'listable'));
        ?>
"/>
				<input type="submit" name="edit_job" class="button job-manager-button-edit-listing" value="<?php 
        _e('Edit listing', 'wp-job-manager');
        ?>
"/>
				<input type="hidden" name="job_id" value="<?php 
        echo esc_attr($instance->get_job_id());
        ?>
"/>
				<input type="hidden" name="step" value="<?php 
        echo esc_attr($instance->get_step());
        ?>
"/>
				<input type="hidden" name="job_manager_form" value="<?php 
        echo $instance->form_name;
        ?>
"/>

				<h2>
					<?php 
        _e('Preview', 'listable');
        ?>
				</h2>
			</div>
			<?php 
        get_job_manager_template_part('content-single', 'job_listing-preview');
        ?>
		</form>
		<?php 
        wp_reset_postdata();
    }
}
 /**
  * Update or create a job listing from posted data
  *
  * @param  string $post_title
  * @param  string $post_content
  * @param  string $status
  */
 protected static function save_job($post_title, $post_content, $status = 'preview', $values = array())
 {
     $job_slug = array();
     // Prepend with company name
     if (!empty($values['company']['company_name'])) {
         $job_slug[] = $values['company']['company_name'];
     }
     // Prepend location
     if (!empty($values['job']['job_location'])) {
         $job_slug[] = $values['job']['job_location'];
     }
     // Prepend with job type
     if (!empty($values['job']['job_type'])) {
         $job_slug[] = $values['job']['job_type'];
     }
     $job_slug[] = $post_title;
     $job_data = apply_filters('submit_job_form_save_job_data', array('post_title' => $post_title, 'post_name' => sanitize_title(implode('-', $job_slug)), 'post_content' => $post_content, 'post_type' => 'job_listing', 'comment_status' => 'closed'), $post_title, $post_content, $status, $values);
     if ($status) {
         $job_data['post_status'] = $status;
     }
     if (self::$job_id) {
         $job_data['ID'] = self::$job_id;
         wp_update_post($job_data);
     } else {
         self::$job_id = wp_insert_post($job_data);
     }
 }
    function add_property_fields_to_submit($fields)
    {
        $property_fields = WP_Job_Manager_Form_Submit_Job::get_fields('property');
        if ($property_fields) {
            ?>
			<h2><?php 
            _e('Property Details', 'wp-job-manager');
            ?>
</h2>

	  		<?php 
            foreach ($property_fields as $key => $field) {
                ?>
				<fieldset class="fieldset-<?php 
                esc_attr_e($key);
                ?>
">
					<label for="<?php 
                esc_attr_e($key);
                ?>
"><?php 
                echo $field['label'] . apply_filters('submit_job_form_required_label', $field['required'] ? '' : ' <small>' . __('(optional)', 'wp-job-manager') . '</small>', $field);
                ?>
</label>
					<div class="field <?php 
                echo $field['required'] ? 'required-field' : '';
                ?>
">
						<?php 
                get_job_manager_template('form-fields/' . $field['type'] . '-field.php', array('key' => $key, 'field' => $field));
                ?>
					</div>
				</fieldset>
			<?php 
            }
        }
    }