public function body_class($classes) { $style = jobify_theme_mod('jobify_listings', 'jobify_listings_display_area'); $classes[] = 'single-listing-style-' . $style; $categories = get_terms('job_listing_category'); if (get_option('job_manager_enable_categories') && !empty($categories)) { $classes[] = 'wp-job-manager-categories-enabled'; if (get_option('job_manager_enable_default_category_multiselect') && !is_page_template('page-templates/jobify.php')) { $classes[] = 'wp-job-manager-categories-multi-enabled'; } } $r_categories = get_terms('resume_category'); if (get_option('resume_manager_enable_categories') && !empty($r_categories)) { $classes[] = 'wp-resume-manager-categories-enabled'; if (get_option('resume_manager_enable_default_category_multiselect') && !is_page_template('page-templates/jobify.php')) { $classes[] = 'wp-resume-manager-categories-multi-enabled'; } } if (class_exists('Astoundify_Job_Manager_Contact_Listing')) { $classes[] = 'wp-job-manager-contact-listing'; } global $post; $apply = get_the_job_application_method(); if ($apply) { $classes[] = 'wp-job-manager-apply-' . $apply->type; } return $classes; }
<?php if ($apply = get_the_job_application_method()) { wp_enqueue_script('wp-job-manager-job-application'); ?> <div class="application"> <input class="application_button button__large" type="button" value="<?php _e('Hire Now!', 'babysitter'); ?> " /> <div class="application_details"> <?php switch ($apply->type) { case 'email': echo '<p>' . sprintf(__('To hire this person <strong>email your details to</strong> <a class="job_application_email" href="mailto:%1$s%2$s">%1$s</a>', 'babysitter'), $apply->email, '?subject=' . rawurlencode($apply->subject)) . '</p>'; echo '<p>' . __('Hire using webmail: ', 'babysitter'); echo '<a href="' . 'https://mail.google.com/mail/?view=cm&fs=1&to=' . $apply->email . '&su=' . urlencode($apply->subject) . '" target="_blank" class="job_application_email">Gmail</a> / '; echo '<a href="' . 'http://webmail.aol.com/Mail/ComposeMessage.aspx?to=' . $apply->email . '&subject=' . urlencode($apply->subject) . '" target="_blank" class="job_application_email">AOL</a> / '; echo '<a href="' . 'http://compose.mail.yahoo.com/?to=' . $apply->email . '&subject=' . urlencode($apply->subject) . '" target="_blank" class="job_application_email">Yahoo</a> / '; echo '<a href="' . 'http://mail.live.com/mail/EditMessageLight.aspx?n=&to=' . $apply->email . '&subject=' . urlencode($apply->subject) . '" target="_blank" class="job_application_email">Outlook</a>'; echo '</p>'; break; case 'url': echo '<p>' . sprintf(__('To hire this person please visit the following URL: <a href="%1$s">%1$s →</a>', 'babysitter'), $apply->url) . '</p>'; break; } ?> </div> </div> <?php
/** * 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; }
/** * Create a new job application * @param int $job_id * @param string $candidate_name * @param string $application_message * @param string $candidate_email * @param array $meta * @param bool $notification * @return int|bool success */ function create_job_application($job_id, $candidate_name, $candidate_email, $application_message, $meta = array(), $notification = true, $source = '') { $job = get_post($job_id); if (!$job || $job->post_type !== 'job_listing') { return false; } $application_data = array('post_title' => wp_kses_post($candidate_name), 'post_content' => wp_kses_post($application_message), 'post_status' => current(array_keys(get_job_application_statuses())), 'post_type' => 'job_application', 'comment_status' => 'closed', 'post_author' => $job->post_author, 'post_parent' => $job_id); $application_id = wp_insert_post($application_data); if ($application_id) { update_post_meta($application_id, '_job_applied_for', $job->post_title); update_post_meta($application_id, '_candidate_email', $candidate_email); update_post_meta($application_id, '_candidate_user_id', get_current_user_id()); update_post_meta($application_id, '_rating', 0); update_post_meta($application_id, '_application_source', $source); if ($meta) { foreach ($meta as $key => $value) { update_post_meta($application_id, $key, $value); } } if ($notification) { $method = get_the_job_application_method($job_id); if ("email" === $method->type) { $send_to = $method->raw_email; } elseif ($job->post_author) { $user = get_user_by('id', $job->post_author); $send_to = $user->user_email; } else { $send_to = ''; } if ($send_to) { $attachments = array(); if (!empty($meta['_attachment_file'])) { if (is_array($meta['_attachment_file'])) { foreach ($meta['_attachment_file'] as $file) { $attachments[] = $file; } } else { $attachments[] = $meta['_attachment_file']; } } $existing_shortcode_tags = $GLOBALS['shortcode_tags']; remove_all_shortcodes(); job_application_email_add_shortcodes(array('application_id' => $application_id, 'job_id' => $job_id, 'user_id' => get_current_user_id(), 'candidate_name' => $candidate_name, 'candidate_email' => $candidate_email, 'application_message' => $application_message, 'meta' => $meta)); $subject = do_shortcode(get_job_application_email_subject()); $message = do_shortcode(get_job_application_email_content()); $message = str_replace("\n\n\n\n", "\n\n", implode("\n", array_map('trim', explode("\n", $message)))); $is_html = $message != strip_tags($message); // Does this message contain formatting already? if ($is_html && !strstr($message, '<p') && !strstr($message, '<br')) { $message = nl2br($message); } $GLOBALS['shortcode_tags'] = $existing_shortcode_tags; $headers = array(); $headers[] = 'From: ' . $candidate_name . ' <' . $candidate_email . '>'; $headers[] = 'Reply-To: ' . $candidate_email; $headers[] = $is_html ? 'Content-Type: text/html' : 'Content-Type: text/plain'; $headers[] = 'charset=utf-8'; wp_mail(apply_filters('create_job_application_notification_recipient', $send_to, $job_id, $application_id), apply_filters('create_job_application_notification_subject', $subject, $job_id, $application_id), apply_filters('create_job_application_notification_message', $message), apply_filters('create_job_application_notification_headers', $headers, $job_id, $application_id), apply_filters('create_job_application_notification_attachments', $attachments, $job_id, $application_id)); } } return $application_id; } return false; }
/** * Show the application area */ public function output_job_apply($atts) { extract(shortcode_atts(array('id' => ''), $atts)); ob_start(); $args = array('post_type' => 'job_listing', 'post_status' => 'publish'); if (!$id) { return ''; } else { $args['p'] = absint($id); } $jobs = new WP_Query($args); if ($jobs->have_posts()) { ?> <?php while ($jobs->have_posts()) { $jobs->the_post(); ?> <div class="job-manager-application-wrapper"> <?php $apply = get_the_job_application_method(); do_action('job_manager_application_details_' . $apply->type, $apply); ?> </div> <?php } ?> <?php } wp_reset_postdata(); return ob_get_clean(); }
/** * Done Step */ public function done() { do_action('resume_manager_resume_submitted', $this->resume_id); get_job_manager_template('resume-submitted.php', array('resume' => get_post($this->resume_id), 'job_id' => $this->job_id), 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/'); if ($this->job_id && get_option('resume_manager_enable_application')) { if (get_post_type($this->job_id) !== 'job_listing') { return; } $method = get_the_job_application_method($this->job_id); if ("email" === $method->type || class_exists('WP_Job_Manager_Applications') && get_option('resume_manager_enable_application_for_url_method', 1)) { ?> <form method="post" class="apply_with_resume"> <p class="applying_for"><?php printf(__('Enter a message below to apply to "%s". This will accompany your online resume and be sent to the employer.', 'wp-job-manager-resumes'), '<a href="' . get_permalink($this->job_id) . '">' . get_the_title($this->job_id) . '</a>'); ?> </p> <p> <label><?php _e('Message', 'wp-job-manager-resumes'); ?> :</label> <textarea name="application_message" cols="20" rows="4" required><?php if (isset($_POST['application_message'])) { echo esc_textarea(stripslashes($_POST['application_message'])); } ?> </textarea> </p> <p> <input type="submit" name="resume_application_submit_button" value="<?php esc_attr_e('Send application', 'wp-job-manager-resumes'); ?> " /> <input type="hidden" name="resume_id" value="<?php echo esc_attr($this->resume_id); ?> " /> <input type="hidden" name="job_id" value="<?php echo esc_attr($this->job_id); ?> " /> <input type="hidden" name="step" value="<?php echo esc_attr($this->step); ?> " /> <input type="hidden" name="resume_manager_form" value="<?php echo $this->form_name; ?> " /> </p> </form> <?php } } }
/** * 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'); }
/** * Create a new job application * @param int $job_id * @param string $candidate_name * @param string $application_message * @param string $candidate_email * @param array $meta * @param bool $notification * @return int|bool success */ function create_job_application($job_id, $candidate_name, $candidate_email, $application_message, $meta = array(), $notification = true) { $job = get_post($job_id); if (!$job || $job->post_type !== 'job_listing') { return false; } $application_data = array('post_title' => wp_kses_post($candidate_name), 'post_content' => wp_kses_post($application_message), 'post_status' => current(array_keys(get_job_application_statuses())), 'post_type' => 'job_application', 'comment_status' => 'closed', 'post_author' => $job->post_author, 'post_parent' => $job_id); $application_id = wp_insert_post($application_data); if ($application_id) { update_post_meta($application_id, '_job_applied_for', $job->post_title); update_post_meta($application_id, '_candidate_email', $candidate_email); update_post_meta($application_id, '_candidate_user_id', get_current_user_id()); update_post_meta($application_id, '_rating', 0); if ($meta) { foreach ($meta as $key => $value) { update_post_meta($application_id, $key, $value); } } if ($notification) { $method = get_the_job_application_method($job_id); if ("email" === $method->type) { $send_to = $method->raw_email; } elseif ($job->post_author) { $user = get_user_by('id', $job->post_author); $send_to = $user->user_email; } else { $send_to = ''; } if ($send_to) { $dashboard_id = get_option('job_manager_job_dashboard_page_id'); $dashboard_link = ''; $attachments = array(); $message = array(); if ($dashboard_id) { $dashboard_link = add_query_arg(array('action' => 'show_applications', 'job_id' => $job_id), get_permalink($dashboard_id)); } if (!empty($meta['_attachment_file'])) { if (is_array($meta['_attachment_file'])) { foreach ($meta['_attachment_file'] as $file) { $attachments[] = $file; } } else { $attachments[] = $meta['_attachment_file']; } $message['before_message'] = "\n\n" . __('The candidate\'s CV/resume is attached to this email.', 'wp-job-manager-applications'); } else { $message['before_message'] = ''; } $message = apply_filters('create_job_application_notification_message', array('greeting' => __('Hello', 'wp-job-manager-applications'), 'position' => sprintf("\n\n" . __('A candidate (%s) has submitted their application for the position "%s".', 'wp-job-manager-applications'), wp_kses_post($candidate_name), get_the_title($job_id)), 'before_message' => $message['before_message'], 'start_message' => "\n\n-----------\n\n", 'message' => wp_kses_post($application_message), 'end_message' => "\n\n-----------\n\n", 'view_resume' => $dashboard_link ? sprintf(__('You can view this and any other applications here: %s.', 'wp-job-manager-applications'), $dashboard_link) : __('You can view the applications from your dashboard.', 'wp-job-manager-applications'), 'contact' => "\n" . sprintf(__('You can contact them directly at: %s.', 'wp-job-manager-applications'), $candidate_email)), $application_id); $headers = array(); $headers[] = 'From: ' . $candidate_email; $headers[] = 'Reply-To: ' . $candidate_email; $headers[] = 'Content-Type: text/plain'; $headers[] = 'charset=utf-8'; wp_mail(apply_filters('create_job_application_notification_recipient', $send_to, $job_id, $application_id), apply_filters('create_job_application_notification_subject', sprintf(__("New job application for %s", 'wp-job-manager-applications'), get_the_title($job_id)), $job_id, $application_id), implode('', $message), apply_filters('create_job_application_notification_headers', $headers, $job_id, $application_id), apply_filters('create_job_application_notification_attachments', $attachments, $job_id, $application_id)); } } return $application_id; } return false; }