function jobman_display_apply_generated($foundjob = false, $job = NULL, $cat = NULL) { global $current_user, $si_image_captcha, $wp_version; $options = get_option('jobman_options'); $content = ''; if (!empty($cat)) { $cat = get_term_by('slug', $cat, 'jobman_category'); } if ($foundjob) { $content .= '<p>' . __('Title', 'jobman') . ': <a href="' . get_page_link($job->ID) . '">' . $job->post_title . '</a></p>'; } if (!$foundjob) { if (!empty($options['app_job_select'])) { $content .= '<p><strong>' . __('Select the jobs you would like to apply for', 'jobman') . '</strong>: ' . jobman_generate_job_select($cat, $options['app_job_select']) . '</p>'; } if (!empty($options['app_cat_select'])) { $content .= '<p><strong>' . __('Select the categories that you are interested in', 'jobman') . '</strong>: ' . jobman_generate_cat_select($cat, $options['app_cat_select']) . '</p>'; } } $fields = $options['fields']; $start = true; $content .= '<p>' . __('Fields marked with an asterisk (*) must be filled out before submitting.', 'jobman') . '</p>'; if (count($fields) > 0) { uasort($fields, 'jobman_sort_fields'); $rowcount = 1; $totalrowcount = 1; $tablecount = 1; foreach ($fields as $id => $field) { if (array_key_exists('categories', $field) && count($field['categories']) > 0) { // If there are cats defined for this field, check that either the job has one of those categories, or we're submitting to that category if (empty($cat) || !in_array($cat->term_id, $field['categories'])) { continue; } } if ($start && 'heading' != $field['type']) { $content .= "<table class='job-apply-table table{$tablecount}'>"; $tablecount++; $rowcount = 1; } $data = trim(strip_tags($field['data'])); // Auto-populate logged in user email address if ($id == $options['application_email_from'] && '' == $data && is_user_logged_in()) { $data = $current_user->user_email; } if ('heading' != $field['type']) { $content .= "<tr class='row{$rowcount} totalrow{$totalrowcount} field{$id} "; $content .= $rowcount % 2 ? 'odd' : 'even'; $content .= "'>"; } $mandatory = ''; if ($field['mandatory']) { $mandatory = ' *'; } switch ($field['type']) { case 'text': case 'radio': case 'checkbox': case 'textarea': case 'date': case 'file': case 'select': case 'geoloc': if ('' != $field['label']) { $content .= "<th scope='row'>{$field['label']}{$mandatory}</th>"; } else { $content .= '<td class="th"></td>'; } $content .= '<td>' . jobman_app_field_input_html($id, $field, $data, $mandatory) . '</td></tr>'; break; case 'heading': if (!$start) { $content .= '</table>'; } $content .= "<h3>{$field['label']}</h3>"; $content .= "<table class='job-apply-table table{$tablecount}'>"; $tablecount++; $totalrowcount--; $rowcount = 0; break; case 'html': $content .= '<td colspan="2">' . jobman_app_field_input_html($id, $field, $data) . '</td></tr>'; break; case 'blank': $content .= '<td colspan="2"> </td></tr>'; break; } $start = false; $rowcount++; $totalrowcount++; } } $content .= '<tr><td colspan="2"> </td></tr>'; if (isset($si_image_captcha) && $options['plugins']['sicaptcha']) { // SI CAPTCHA echos directly to screen. We need to redirect that to our $content buffer. ob_start(); if ($wp_version[0] > 2) { $si_image_captcha->si_captcha_comment_form_wp3(); } else { $si_image_captcha->si_captcha_comment_form(); } $content .= '<tr><td colspan="2">' . ob_get_contents() . '</td></tr>'; ob_end_clean(); } $content .= '<tr><td colspan="2" class="submit"><input type="submit" name="submit" class="button-primary" value="' . __('Submit Your Application', 'jobman') . '" /></td></tr>'; $content .= '</table>'; return $content; }
function jobman_app_field_shortcode($atts, $content, $tag) { global $jobman_shortcode_app_field, $current_user; $options = get_option('jobman_options'); $matches = array(); preg_match('#^job_app_field(\\d+)(_label)?#', $tag, $matches); if (array_key_exists(2, $matches)) { return $options['fields'][$matches[1]]['label']; } preg_match('#^job_app_field(\\d+)(_mandatory)?#', $tag, $matches); if (array_key_exists(2, $matches)) { if ($options['fields'][$matches[1]]['mandatory']) { return 'mandatory'; } else { return NULL; } } preg_match('#^job_app_field(\\d+)#', $tag, $matches); if (!array_key_exists(1, $matches)) { return NULL; } $id = $matches[1]; $field = $options['fields'][$id]; $data = strip_tags($field['data']); // Auto-populate logged in user email address if ($id == $options['application_email_from'] && '' == $data && is_user_logged_in()) { $data = $current_user->user_email; } return jobman_app_field_input_html($id, $field, $data); }