function jobman_display_apply($jobid, $cat = NULL) { global $si_image_captcha; get_currentuserinfo(); $options = get_option('jobman_options'); $content = ''; $data = get_posts('post_type=jobman_app_form&numberposts=-1'); if (count($data) > 0) { $page = $data[0]; } else { $page = new stdClass(); $page->post_author = 1; $page->post_date = time(); $page->post_type = 'page'; $page->post_status = 'published'; } if (array_key_exists('jobman-apply', $_REQUEST)) { if (isset($si_image_captcha) && $options['plugins']['sicaptcha']) { $fake_comment = array('comment_type' => 'comment'); // No need to check return - will wp_die() if CAPTCHA failed $si_image_captcha->si_captcha_comment_post($fake_comment); } $err = jobman_store_application($jobid, $cat); switch ($err) { case -1: // No error, stored properly $msg = $options['text']['application_acceptance']; break; case -2: // Recent application form same job $msg = __('It seems you recently applied for this job. If you would like to add further information to your application, please contact us directly.', 'jobman'); break; default: if (is_array($err)) { $msg = __('There was an error uploading your application. Please contact us directly, and quote the information below:', 'jobman'); foreach ($err as $e) { $msg .= '<div class="jobman-error">' . esc_html($e->get_error_message()) . '</div>'; } } else { // Failed filter rules $msg = $options['fields'][$err]['error']; if (NULL == $msg || '' == $msg) { $msg = __("Thank you for your application. While your application doesn't fit our current requirements, please contact us directly to see if we have other positions available.", 'jobman'); } } break; } $page->post_title = __('Job Application', 'jobman'); $page->post_content .= "<div class='jobman-message'>{$msg}</div>"; return array($page); } if ($options['user_registration'] && ($options['loginform_apply'] || $options['user_registration_required'])) { $content .= jobman_display_login(); } if ($options['user_registration'] && $options['user_registration_required'] && !is_user_logged_in()) { // Skip the application form if the user hasn't registered yet, and we're enforcing registration. $pleaseregister = '<p>' . __('Before completing your application, please login using the form above, or register using the form below.', 'jobman') . '</p>'; $content .= apply_filters('jobman_pleaseregister_html', $pleaseregister); $reg = jobman_display_register(); $content .= $reg[0]->post_content; $page->post_content = $content; return array($page); } if ($jobid > 0) { $job = get_post($jobid); } else { $job = NULL; } $cat_arr = array(); if (NULL != $job) { $page->post_title = __('Job Application', 'jobman') . ': ' . $job->post_title; $foundjob = true; $jobid = $job->ID; $categories = wp_get_object_terms($job->ID, 'jobman_category'); if (count($categories) > 0) { foreach ($categories as $category) { $cat_arr[] = $category->slug; } } } else { $page->post_title = __('Job Application', 'jobman'); $foundjob = false; $jobid = -1; if (NULL != $cat) { $data = get_term_by('slug', $cat, 'jobman_category'); if (isset($data->slug)) { $cat_arr[] = $data->slug; } } } $content .= '<form action="" enctype="multipart/form-data" onsubmit="return jobman_apply_filter()" method="post">'; $content .= '<input type="hidden" name="jobman-apply" value="1" />'; $content .= '<input type="hidden" name="jobman-jobid" value="' . $jobid . '" />'; $content .= '<input type="hidden" name="jobman-categoryid" value="' . implode(',', $cat_arr) . '" />'; if (array_key_exists('jobman-joblist', $_REQUEST)) { $content .= '<input type="hidden" name="jobman-joblist" value="' . implode(',', $_REQUEST['jobman-joblist']) . '" />'; } if (empty($options['templates']['application_form'])) { $gencat = NULL; if (!empty($cat_arr)) { $gencat = $cat_arr[0]; } $content .= jobman_display_apply_generated($foundjob, $job, $gencat); } else { global $jobman_app_field_shortcodes, $jobman_app_shortcodes, $jobman_shortcode_job, $jobman_shortcode_categories; $jobman_shortcode_job = $job; $jobman_shortcode_categories = $cat_arr; jobman_add_app_field_shortcodes($jobman_app_field_shortcodes); jobman_add_app_shortcodes($jobman_app_shortcodes); $content .= do_shortcode($options['templates']['application_form']); jobman_remove_shortcodes(array_merge($jobman_app_field_shortcodes, $jobman_app_shortcodes)); } $content .= '</form>'; $content .= '<div id="jobman-map" style="width: 1px; height: 1px; display: none;"></div>'; $page->post_content = $content; return array($page); }
function jobman_display_job($job) { global $jobman_shortcode_job, $jobman_shortcodes, $jobman_field_shortcodes; $options = get_option('jobman_options'); $content = ''; if (is_string($job) || is_int($job)) { $job = get_post($job); } if ($options['user_registration'] && $options['loginform_job']) { $content .= jobman_display_login(); } if (NULL != $job) { $jobmeta = get_post_custom($job->ID); $jobdata = array(); foreach ($jobmeta as $key => $value) { if (is_array($value)) { $jobdata[$key] = $value[0]; } else { $jobdata[$key] = $value; } } } // Check that the job hasn't expired if (array_key_exists('displayenddate', $jobdata) && '' != $jobdata['displayenddate'] && strtotime($jobdata['displayenddate']) <= time()) { $job = NULL; } // Check that the job isn't in the future if (strtotime($job->post_date) > time()) { $job = NULL; } if (NULL == $job) { $page = get_post($options['main_page']); $page->post_type = 'jobman_job'; $page->post_title = __('This job doesn\'t exist', 'jobman'); $content .= '<p>' . sprintf(__('Perhaps you followed an out-of-date link? Please check out the <a href="%s">jobs we have currently available</a>.', 'jobman'), get_page_link($options['main_page'])) . '</p>'; $page->post_content = $content; return array($page); } $template = $options['templates']['job']; jobman_add_shortcodes($jobman_shortcodes); jobman_add_field_shortcodes($jobman_field_shortcodes); $jobman_shortcode_job = $job; $content .= do_shortcode($template); jobman_remove_shortcodes(array_merge($jobman_shortcodes, $jobman_field_shortcodes)); $page = $job; $page->post_title = $options['text']['job_title_prefix'] . $job->post_title; $page->post_content = $content; return array($page); }