/** * custom_columns function. * * @access public * @param mixed $column * @return void */ public function custom_columns($column) { global $post; switch ($column) { case "application_status": echo '<span class="status">' . $post->post_status . '</a>'; break; case "candidate": echo '<a href="' . admin_url('post.php?post=' . $post->ID . '&action=edit') . '" class="tips candidate_name" data-tip="' . sprintf(__('Application ID: %d', 'wp-job-manager-applications'), $post->ID) . '">' . $post->post_title . '</a>'; if ($email = get_post_meta($post->ID, '_candidate_email', true)) { echo '<br/><a href="mailto:' . esc_attr($email) . '">' . esc_attr($email) . '</a>'; echo get_avatar($email, 42); } echo '<div class="hidden" id="inline_' . $post->ID . '"><div class="post_title">' . $post->post_title . '</div></div>'; break; case 'job': $job = get_post($post->post_parent); if ($job && $job->post_type === 'job_listing') { echo '<a href="' . get_permalink($job->ID) . '">' . $job->post_title . '</a>'; } elseif ($job = get_post_meta($post->ID, '_job_applied_for', true)) { echo esc_html($job); } else { echo '<span class="na">–</span>'; } break; case 'attachment': if ($attachments = get_job_application_attachments($post->ID)) { foreach ($attachments as $attachment) { echo '<a href="' . esc_url($attachment) . '">' . get_job_application_attachment_name($attachment, 20) . '</a></br>'; } } else { echo '<span class="na">–</span>'; } break; case 'online_resume': if (($resume_id = get_job_application_resume_id($post->ID)) && function_exists('get_resume_share_link') && ($share_link = get_resume_share_link($resume_id))) { echo '<a href="' . esc_attr($share_link) . '" target="_blank" class="job-application-resume">' . get_the_title($resume_id) . '</a>'; } else { echo '<span class="na">–</span>'; } break; case 'application_rating': echo '<span class="job-application-rating"><span style="width: ' . get_job_application_rating($post->ID) / 5 * 100 . '%;"></span></span>'; break; case 'application_notes': printf(_n('%d note', '%d notes', $post->comment_count, 'wp-job-manager-applications'), $post->comment_count); break; case "job_application_posted": echo '<strong>' . date_i18n(__('M j, Y', 'wp-job-manager-applications'), strtotime($post->post_date)) . '</strong><span>'; echo (empty($post->post_author) ? __('by a guest', 'wp-job-manager-applications') : sprintf(__('by %s', 'wp-job-manager-applications'), '<a href="' . get_edit_user_link($post->post_author) . '">' . get_the_author() . '</a>')) . '</span>'; break; case "job_application_actions": echo '<div class="actions">'; $admin_actions = array(); if ($post->post_status !== 'trash') { $admin_actions['view'] = array('action' => 'view', 'name' => __('View', 'wp-job-manager-applications'), 'url' => get_edit_post_link($post->ID)); $admin_actions['delete'] = array('action' => 'delete', 'name' => __('Delete', 'wp-job-manager-applications'), 'url' => get_delete_post_link($post->ID)); } $admin_actions = apply_filters('job_manager_job_applications_admin_actions', $admin_actions, $post); foreach ($admin_actions as $action) { printf('<a class="icon-%s button tips" href="%s" data-tip="%s">%s</a>', esc_attr($action['action']), esc_url($action['url']), esc_attr($action['name']), esc_attr($action['name'])); } echo '</div>'; break; } }
/** * Sent the application email */ public static function send_application($job_id, $resume_id, $application_message) { $user = wp_get_current_user(); $resume_link = get_resume_share_link($resume_id); $candidate_name = get_the_title($resume_id); $candidate_email = get_post_meta($resume_id, '_candidate_email', true); $method = get_the_job_application_method($job_id); $sent = false; $attachments = array(); $resume = get_post($resume_id); $file_paths = get_resume_files($resume); foreach ($file_paths as $file_path) { $attachments[] = str_replace(array(site_url('/', 'http'), site_url('/', 'https')), ABSPATH, get_post_meta($resume_id, '_resume_file', true)); } if (empty($candidate_email)) { $candidate_email = $user->user_email; } $message = apply_filters('apply_with_resume_email_message', array('greeting' => __('Hello', 'wp-job-manager-resumes'), 'position' => sprintf("\n\n" . __('A candidate has applied online for the position "%s".', 'wp-job-manager-resumes'), get_the_title($job_id)), 'start_message' => "\n\n-----------\n\n", 'message' => $application_message, 'end_message' => "\n\n-----------\n\n", 'view_resume' => sprintf(__('You can view their online resume here: %s.', 'wp-job-manager-resumes'), $resume_link), 'contact' => "\n" . sprintf(__('Or you can contact them directly at: %s.', 'wp-job-manager-resumes'), $candidate_email)), get_current_user_id(), $job_id, $resume_id, $application_message); if (!empty($method->raw_email)) { $headers = array(); $headers[] = 'From: ' . $candidate_name . ' <' . $candidate_email . '>'; $headers[] = 'Reply-To: ' . $candidate_email; $sent = wp_mail(apply_filters('apply_with_resume_email_recipient', $method->raw_email, $job_id, $resume_id), apply_filters('apply_with_resume_email_subject', $method->subject, $job_id, $resume_id), implode('', $message), apply_filters('apply_with_resume_email_headers', $headers, $job_id, $resume_id), apply_filters('apply_with_resume_email_attachments', array_filter($attachments), $job_id, $resume_id)); } do_action('applied_with_resume', get_current_user_id(), $job_id, $resume_id, $application_message, $sent); if ("email" !== $method->type && class_exists('WP_Job_Manager_Applications') && get_option('resume_manager_enable_application_for_url_method', 1)) { $sent = true; } return $sent; }
/** * Add shortcodes for email content * @param array $data */ function job_application_email_add_shortcodes($data) { extract($data); $job_title = strip_tags(get_the_title($job_id)); $dashboard_id = get_option('job_manager_job_dashboard_page_id'); $job_dashboard_url = $dashboard_id ? htmlspecialchars_decode(add_query_arg(array('action' => 'show_applications', 'job_id' => $job_id), get_permalink($dashboard_id))) : ''; $meta_data = array(); $company_name = get_the_company_name($job_id); $application_id = $data['application_id']; $user_id = $data['user_id']; add_shortcode('from_name', function ($atts, $content = '') use($candidate_name) { return job_application_email_shortcode_handler($atts, $content, $candidate_name); }); add_shortcode('from_email', function ($atts, $content = '') use($candidate_email) { return job_application_email_shortcode_handler($atts, $content, $candidate_email); }); add_shortcode('message', function ($atts, $content = '') use($application_message) { return job_application_email_shortcode_handler($atts, $content, $application_message); }); add_shortcode('job_id', function ($atts, $content = '') use($job_id) { return job_application_email_shortcode_handler($atts, $content, $job_id); }); add_shortcode('job_title', function ($atts, $content = '') use($job_title) { return job_application_email_shortcode_handler($atts, $content, $job_title); }); add_shortcode('job_dashboard_url', function ($atts, $content = '') use($job_dashboard_url) { return job_application_email_shortcode_handler($atts, $content, $job_dashboard_url); }); add_shortcode('company_name', function ($atts, $content = '') use($company_name) { return job_application_email_shortcode_handler($atts, $content, $company_name); }); add_shortcode('application_id', function ($atts, $content = '') use($application_id) { return job_application_email_shortcode_handler($atts, $content, $application_id); }); add_shortcode('user_id', function ($atts, $content = '') use($user_id) { return job_application_email_shortcode_handler($atts, $content, $user_id); }); add_shortcode('job_post_meta', function ($atts, $content = '') use($job_id) { $atts = shortcode_atts(array('key' => ''), $atts); $value = get_post_meta($job_id, sanitize_text_field($atts['key']), true); return job_application_email_shortcode_handler($atts, $content, $value); }); foreach (get_job_application_form_fields() as $key => $field) { if (in_array('message', $field['rules']) || in_array('from_name', $field['rules']) || in_array('from_email', $field['rules']) || in_array('attachment', $field['rules'])) { continue; } $value = isset($meta[$field['label']]) ? $meta[$field['label']] : ''; if ($field['type'] === 'resumes' && function_exists('get_resume_share_link') && $value) { $value = get_resume_share_link($value); } $meta_data[$field['label']] = $value; add_shortcode($key, function ($atts, $content = '') use($value) { return job_application_email_shortcode_handler($atts, $content, $value); }); } $meta_data = array_filter($meta_data); $meta_data_strings = array(); foreach ($meta_data as $label => $value) { $meta_data_strings[] = $label . ': ' . $value; } $meta_data_strings = implode("\n", $meta_data_strings); add_shortcode('meta_data', function ($atts, $content = '') use($meta_data_strings) { return job_application_email_shortcode_handler($atts, $content, $meta_data_strings); }); do_action('job_application_email_add_shortcodes', $data); }
/** * Handle applications via Resume Manager's Form * @param int $user_id * @param int $job_id * @param int $resume_id * @param string $application_message */ public function handle_applied_with_resume($user_id, $job_id, $resume_id, $application_message, $sent_email = true) { if (!$job_id) { return; } $user = get_user_by('id', $user_id); $resume_link = get_resume_share_link($resume_id); $candidate_name = get_post_meta($resume_id, '_candidate_name', true); $candidate_email = get_post_meta($resume_id, '_candidate_email', true); if (empty($candidate_email)) { $candidate_email = $user->user_email; } $application_meta = array(); $application_meta['_resume_id'] = $resume_id; $get_meta = array('_candidate_title' => __('Title', 'wp-job-manager-applications'), '_candidate_location' => __('Location', 'wp-job-manager-applications')); foreach ($get_meta as $key => $label) { if ($value = get_post_meta($resume_id, $key, true)) { $application_meta[$label] = $value; } } create_job_application($job_id, $candidate_name, $candidate_email, $application_message, $application_meta, !$sent_email, 'resume-manager'); }
<?php echo get_job_application_avatar($application->ID); ?> <h3> <?php if (($resume_id = get_job_application_resume_id($application->ID)) && 'publish' === get_post_status($resume_id) && function_exists('get_resume_share_link') && ($share_link = get_resume_share_link($resume_id))) { ?> <a href="<?php echo esc_attr($share_link); ?> "><?php echo $application->post_title; ?> </a> <?php } else { ?> <?php echo $application->post_title; ?> <?php } ?> </h3> <span class="job-application-rating"><span style="width: <?php echo get_job_application_rating($application->ID) / 5 * 100; ?> %;"></span></span>
/** * Sent the application email */ public static function send_application($job_id, $resume_id, $application_message) { $user = wp_get_current_user(); $resume_link = get_resume_share_link($resume_id); $candidate_email = get_post_meta($resume_id, '_candidate_email', true); $method = get_the_job_application_method($job_id); $sent = false; if (empty($candidate_email)) { $candidate_email = $user->user_email; } $message = apply_filters('apply_with_resume_email_message', array('greeting' => __('Hello', 'wp-job-manager-resumes'), 'position' => sprintf("\n\n" . __('A candidate has applied online for the position "%s".', 'wp-job-manager-resumes'), get_the_title($job_id)), 'start_message' => "\n\n-----------\n\n", 'message' => $application_message, 'end_message' => "\n\n-----------\n\n", 'view_resume' => sprintf(__('You can view their online resume here: %s.', 'wp-job-manager-resumes'), $resume_link), 'contact' => "\n" . sprintf(__('Or you can contact them directly at: %s.', 'wp-job-manager-resumes'), $candidate_email)), get_current_user_id(), $job_id, $resume_id, $application_message); if (!empty($method->raw_email)) { add_filter('wp_mail_from', array(__CLASS__, 'get_from_address')); add_filter('wp_mail_from_name', array(__CLASS__, 'get_from_name')); $sent = wp_mail($method->raw_email, $method->subject, implode('', $message)); remove_filter('wp_mail_from', array(__CLASS__, 'get_from_address')); remove_filter('wp_mail_from_name', array(__CLASS__, 'get_from_name')); } do_action('applied_with_resume', get_current_user_id(), $job_id, $resume_id, $application_message, $sent); return $sent || class_exists('WP_Job_Manager_Applications'); }