示例#1
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();
    }
}
示例#2
0
" />

	<div class="resume_contact_details">
		<h2 class="modal-title"><?php 
_e('Contact', 'jobify');
?>
</h2>

		<div class="resume-contact-content">
			<?php 
$email = get_post_meta($post->ID, '_candidate_email', true);
$subject = sprintf(__('Contact via the resume for "%s" on %s', 'resume_manager'), $post->post_title, home_url());
if (class_exists('Astoundify_Job_Manager_Apply_GF', false)) {
    echo do_shortcode('[gravityform id="' . get_option('job_manager_gravity_form_resumes') . '" title="false" ajax="true"]');
} else {
    echo '<p>' . sprintf(__('To apply for this job <strong>email your details to</strong> <a class="job_application_email" href="mailto:%1$s%2$s">%1$s</a>', 'jobify'), $email, '?subject=' . rawurlencode($subject)) . '</p>';
}
?>

			<?php 
if (!resume_manager_user_can_view_contact_details($post->ID)) {
    ?>
				<?php 
    get_job_manager_template_part('access-denied', 'contact-details', 'resume_manager', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
    ?>
			<?php 
}
?>
		</div>
	</div>
</div>
    /**
     * Get resumes via ajax
     */
    public function get_resumes()
    {
        global $wpdb;
        ob_start();
        $search_location = sanitize_text_field(stripslashes($_POST['search_location']));
        $search_keywords = sanitize_text_field(stripslashes($_POST['search_keywords']));
        $search_categories = isset($_POST['search_categories']) ? $_POST['search_categories'] : '';
        if (is_array($search_categories)) {
            $search_categories = array_map('sanitize_text_field', array_map('stripslashes', $search_categories));
        } else {
            $search_categories = array(sanitize_text_field(stripslashes($search_categories)), 0);
        }
        $search_categories = array_filter($search_categories);
        $args = array('search_location' => $search_location, 'search_keywords' => $search_keywords, 'search_categories' => $search_categories, 'orderby' => sanitize_text_field($_POST['orderby']), 'order' => sanitize_text_field($_POST['order']), 'offset' => (absint($_POST['page']) - 1) * absint($_POST['per_page']), 'posts_per_page' => absint($_POST['per_page']));
        if (isset($_POST['featured']) && ($_POST['featured'] === 'true' || $_POST['featured'] === 'false')) {
            $args['featured'] = $_POST['featured'] === 'true' ? true : false;
        }
        $resumes = get_resumes(apply_filters('resume_manager_get_resumes_args', $args));
        $result = array();
        $result['found_resumes'] = false;
        if ($resumes->have_posts()) {
            $result['found_resumes'] = true;
            ?>

			<?php 
            while ($resumes->have_posts()) {
                $resumes->the_post();
                ?>

				<?php 
                get_job_manager_template_part('content', 'resume', 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
                ?>

			<?php 
            }
            ?>

		<?php 
        } else {
            ?>

			<li class="no_resumes_found"><?php 
            _e('No resumes found matching your selection.', 'wp-job-manager-resumes');
            ?>
</li>

		<?php 
        }
        $result['html'] = ob_get_clean();
        // Generate 'showing' text
        if ($search_keywords || $search_location || $search_categories || apply_filters('resume_manager_get_resumes_custom_filter', false)) {
            $showing_categories = array();
            if ($search_categories) {
                foreach ($search_categories as $category) {
                    if (!is_numeric($category)) {
                        $category_object = get_term_by('slug', $category, 'resume_category');
                    }
                    if (is_numeric($category) || is_wp_error($category_object) || !$category_object) {
                        $category_object = get_term_by('id', $category, 'resume_category');
                    }
                    if (!is_wp_error($category_object)) {
                        $showing_categories[] = $category_object->name;
                    }
                }
            }
            if ($search_keywords) {
                $showing_resumes = sprintf(__('Showing &ldquo;%s&rdquo; %sresumes', 'wp-job-manager-resumes'), $search_keywords, implode(', ', $showing_categories));
            } else {
                $showing_resumes = sprintf(__('Showing all %sresumes', 'wp-job-manager-resumes'), implode(', ', $showing_categories) . ' ');
            }
            $showing_location = $search_location ? sprintf(' ' . __('located in &ldquo;%s&rdquo;', 'wp-job-manager-resumes'), $search_location) : '';
            $result['showing'] = apply_filters('resume_manager_get_resumes_custom_filter_text', $showing_resumes . $showing_location);
        } else {
            $result['showing'] = '';
        }
        // Generate RSS link
        $result['showing_links'] = resume_manager_get_filtered_links(array('search_location' => $search_location, 'search_categories' => $search_categories, 'search_keywords' => $search_keywords));
        // Generate pagination
        if (isset($_POST['show_pagination']) && $_POST['show_pagination'] === 'true') {
            $result['pagination'] = get_job_listing_pagination($resumes->max_num_pages, absint($_POST['page']));
        }
        $result['max_num_pages'] = $resumes->max_num_pages;
        echo '<!--WPJM-->';
        echo json_encode($result);
        echo '<!--WPJM_END-->';
        die;
    }
    /**
     * View results
     */
    public function view_results($alert_id)
    {
        $alert = get_post($alert_id);
        $jobs = WP_Job_Manager_Alerts_Notifier::get_matching_jobs($alert, true);
        echo wpautop(sprintf(__('Jobs matching your "%s" alert:', 'wp-job-manager-alerts'), $alert->post_title));
        if ($jobs->have_posts()) {
            ?>

			<ul class="job_listings">

				<?php 
            while ($jobs->have_posts()) {
                $jobs->the_post();
                ?>

					<?php 
                get_job_manager_template_part('content', 'job_listing');
                ?>

				<?php 
            }
            ?>

			</ul>

		<?php 
        } else {
            echo wpautop(__('No jobs found', 'wp-job-manager-alerts'));
        }
        wp_reset_postdata();
    }
    /**
     * Get listings via ajax
     */
    public function get_listings()
    {
        global $wp_post_types;
        $result = array();
        $search_location = sanitize_text_field(stripslashes($_REQUEST['search_location']));
        $search_keywords = sanitize_text_field(stripslashes($_REQUEST['search_keywords']));
        $search_categories = isset($_REQUEST['search_categories']) ? $_REQUEST['search_categories'] : '';
        $filter_job_types = isset($_REQUEST['filter_job_type']) ? array_filter(array_map('sanitize_title', (array) $_REQUEST['filter_job_type'])) : null;
        $types = get_job_listing_types();
        $post_type_label = $wp_post_types['job_listing']->labels->name;
        $orderby = sanitize_text_field($_REQUEST['orderby']);
        if (is_array($search_categories)) {
            $search_categories = array_filter(array_map('sanitize_text_field', array_map('stripslashes', $search_categories)));
        } else {
            $search_categories = array_filter(array(sanitize_text_field(stripslashes($search_categories))));
        }
        $args = array('search_location' => $search_location, 'search_keywords' => $search_keywords, 'search_categories' => $search_categories, 'job_types' => is_null($filter_job_types) || sizeof($types) === sizeof($filter_job_types) ? '' : $filter_job_types + array(0), 'orderby' => $orderby, 'order' => sanitize_text_field($_REQUEST['order']), 'offset' => (absint($_REQUEST['page']) - 1) * absint($_REQUEST['per_page']), 'posts_per_page' => absint($_REQUEST['per_page']));
        if (isset($_REQUEST['filled']) && ($_REQUEST['filled'] === 'true' || $_REQUEST['filled'] === 'false')) {
            $args['filled'] = $_REQUEST['filled'] === 'true' ? true : false;
        }
        if (isset($_REQUEST['featured']) && ($_REQUEST['featured'] === 'true' || $_REQUEST['featured'] === 'false')) {
            $args['featured'] = $_REQUEST['featured'] === 'true' ? true : false;
            $args['orderby'] = 'featured' === $orderby ? 'date' : $orderby;
        }
        ob_start();
        $jobs = get_job_listings(apply_filters('job_manager_get_listings_args', $args));
        $result['found_jobs'] = false;
        if ($jobs->have_posts()) {
            $result['found_jobs'] = true;
            ?>

			<?php 
            while ($jobs->have_posts()) {
                $jobs->the_post();
                ?>

				<?php 
                get_job_manager_template_part('content', 'job_listing');
                ?>

			<?php 
            }
            ?>

		<?php 
        } else {
            ?>

			<?php 
            get_job_manager_template_part('content', 'no-jobs-found');
            ?>

		<?php 
        }
        $result['html'] = ob_get_clean();
        $result['showing'] = array();
        // Generate 'showing' text
        $showing_types = array();
        $unmatched = false;
        foreach ($types as $type) {
            if (is_array($filter_job_types) && in_array($type->slug, $filter_job_types)) {
                $showing_types[] = $type->name;
            } else {
                $unmatched = true;
            }
        }
        if (sizeof($showing_types) == 1) {
            $result['showing'][] = implode(', ', $showing_types);
        } elseif ($unmatched && $showing_types) {
            $last_type = array_pop($showing_types);
            $result['showing'][] = implode(', ', $showing_types) . " &amp; {$last_type}";
        }
        if ($search_categories) {
            $showing_categories = array();
            foreach ($search_categories as $category) {
                $category_object = get_term_by(is_numeric($category) ? 'id' : 'slug', $category, 'job_listing_category');
                if (!is_wp_error($category_object)) {
                    $showing_categories[] = $category_object->name;
                }
            }
            $result['showing'][] = implode(', ', $showing_categories);
        }
        if ($search_keywords) {
            $result['showing'][] = '&ldquo;' . $search_keywords . '&rdquo;';
        }
        $result['showing'][] = $post_type_label;
        if ($search_location) {
            $result['showing'][] = sprintf(__('located in &ldquo;%s&rdquo;', 'wp-job-manager'), $search_location);
        }
        if (1 === sizeof($result['showing'])) {
            $result['showing_all'] = true;
        }
        $result['showing'] = apply_filters('job_manager_get_listings_custom_filter_text', sprintf(__('Showing all %s', 'wp-job-manager'), implode(' ', $result['showing'])));
        // Generate RSS link
        $result['showing_links'] = job_manager_get_filtered_links(array('filter_job_types' => $filter_job_types, 'search_location' => $search_location, 'search_categories' => $search_categories, 'search_keywords' => $search_keywords));
        // Generate pagination
        if (isset($_REQUEST['show_pagination']) && $_REQUEST['show_pagination'] === 'true') {
            $result['pagination'] = get_job_listing_pagination($jobs->max_num_pages, absint($_REQUEST['page']));
        }
        $result['max_num_pages'] = $jobs->max_num_pages;
        wp_send_json(apply_filters('job_manager_get_listings_result', $result, $jobs));
    }
    /**
     * Preview Step
     */
    public function preview()
    {
        global $post, $job_preview;
        if ($this->job_id) {
            $job_preview = true;
            $action = $this->get_action();
            $post = get_post($this->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" value="<?php 
            echo apply_filters('submit_job_step_preview_submit_text', __('Submit Listing', 'wp-job-manager'));
            ?>
" />
					<input type="submit" name="edit_job" class="button" value="<?php 
            _e('Edit listing', 'wp-job-manager');
            ?>
" />
					<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="job_manager_form" value="<?php 
            echo $this->form_name;
            ?>
" />
					<h2>
						<?php 
            _e('Preview', 'wp-job-manager');
            ?>
					</h2>
				</div>
				<div class="job_listing_preview single_job_listing">
					<h1><?php 
            the_title();
            ?>
</h1>
					<?php 
            get_job_manager_template_part('content-single', 'job_listing');
            ?>
				</div>
			</form>
			<?php 
            wp_reset_postdata();
        }
    }
	<div id="primary" class="content-area">
		<div id="content" class="site-content full" role="main">
			<div class="entry-content">

				<?php 
if (have_posts()) {
    ?>
				<div class="resume_listings">
					<ul class="resumes">
						<?php 
    while (have_posts()) {
        the_post();
        ?>
							<?php 
        get_job_manager_template_part('content', 'resume', 'resume_manager', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
        ?>
						<?php 
    }
    ?>
					</ul>
				</div>
				<?php 
} else {
    ?>
					<?php 
    get_template_part('content', 'none');
    ?>
				<?php 
}
?>
示例#8
0
						<?php 
            }
            ?>
					</div>

				<?php 
        }
        ?>

				<div>
					<?php 
        $job_manager = $GLOBALS['job_manager'];
        remove_filter('the_content', array($job_manager->post_types, 'job_content'));
        ob_start();
        do_action('job_content_start');
        get_job_manager_template_part('content-single', 'job_listing');
        do_action('job_content_end');
        $content = ob_get_clean();
        add_filter('the_content', array($job_manager->post_types, 'job_content'));
        echo apply_filters('job_manager_single_job_content', $content, $post);
        wp_link_pages(array('before' => '<div class="page-links">' . esc_html__('Pages:', 'listable'), 'after' => '</div>'));
        ?>
				</div><!-- .entry-content -->

				<footer class="entry-footer">
					<?php 
        listable_entry_footer();
        ?>
				</footer><!-- .entry-footer -->

			<?php 
    /**
     * output_resumes function.
     *
     * @access public
     * @param mixed $args
     * @return void
     */
    public function output_resumes($atts)
    {
        global $resume_manager;
        ob_start();
        if (!resume_manager_user_can_browse_resumes()) {
            get_job_manager_template_part('access-denied', 'browse-resumes', 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
            return ob_get_clean();
        }
        extract($atts = shortcode_atts(apply_filters('resume_manager_output_resumes_defaults', array('per_page' => get_option('resume_manager_per_page'), 'order' => 'DESC', 'orderby' => 'featured', 'show_filters' => true, 'show_categories' => get_option('resume_manager_enable_categories'), 'categories' => '', 'featured' => null, 'show_category_multiselect' => get_option('resume_manager_enable_default_category_multiselect', false), 'selected_category' => '', 'show_pagination' => false, 'show_more' => true)), $atts));
        $categories = array_filter(array_map('trim', explode(',', $categories)));
        $keywords = '';
        $location = '';
        // String and bool handling
        $show_filters = $this->string_to_bool($show_filters);
        $show_categories = $this->string_to_bool($show_categories);
        $show_category_multiselect = $this->string_to_bool($show_category_multiselect);
        $show_more = $this->string_to_bool($show_more);
        $show_pagination = $this->string_to_bool($show_pagination);
        if (!is_null($featured)) {
            $featured = is_bool($featured) && $featured || in_array($featured, array('1', 'true', 'yes')) ? true : false;
        }
        if (!empty($_GET['search_keywords'])) {
            $keywords = sanitize_text_field($_GET['search_keywords']);
        }
        if (!empty($_GET['search_location'])) {
            $location = sanitize_text_field($_GET['search_location']);
        }
        if (!empty($_GET['search_category'])) {
            $selected_category = sanitize_text_field($_GET['search_category']);
        }
        if ($show_filters) {
            get_job_manager_template('resume-filters.php', array('per_page' => $per_page, 'orderby' => $orderby, 'order' => $order, 'show_categories' => $show_categories, 'categories' => $categories, 'selected_category' => $selected_category, 'atts' => $atts, 'location' => $location, 'keywords' => $keywords, 'show_category_multiselect' => $show_category_multiselect), 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
            get_job_manager_template('resumes-start.php', array(), 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
            get_job_manager_template('resumes-end.php', array(), 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
            if (!$show_pagination && $show_more) {
                echo '<a class="load_more_resumes" href="#" style="display:none;"><strong>' . __('Load more resumes', 'wp-job-manager-resumes') . '</strong></a>';
            }
        } else {
            $resumes = get_resumes(apply_filters('resume_manager_output_resumes_args', array('search_categories' => $categories, 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => $per_page, 'featured' => $featured)));
            if ($resumes->have_posts()) {
                ?>

				<?php 
                get_job_manager_template('resumes-start.php', array(), 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
                ?>

				<?php 
                while ($resumes->have_posts()) {
                    $resumes->the_post();
                    ?>
					<?php 
                    get_job_manager_template_part('content', 'resume', 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
                    ?>
				<?php 
                }
                ?>

				<?php 
                get_job_manager_template('resumes-end.php', array(), 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
                ?>

				<?php 
                if ($resumes->found_posts > $per_page && $show_more) {
                    ?>

					<?php 
                    wp_enqueue_script('wp-resume-manager-ajax-filters');
                    ?>

					<?php 
                    if ($show_pagination) {
                        ?>
						<?php 
                        echo get_job_listing_pagination($resumes->max_num_pages);
                        ?>
					<?php 
                    } else {
                        ?>
						<a class="load_more_resumes" href="#"><strong><?php 
                        _e('Load more resumes', 'wp-job-manager-resumes');
                        ?>
</strong></a>
					<?php 
                    }
                    ?>

				<?php 
                }
                ?>

			<?php 
            }
            wp_reset_postdata();
        }
        $data_attributes_string = '';
        $data_attributes = array('location' => $location, 'keywords' => $keywords, 'show_filters' => $show_filters ? 'true' : 'false', 'show_pagination' => $show_pagination ? 'true' : 'false', 'per_page' => $per_page, 'orderby' => $orderby, 'order' => $order, 'categories' => implode(',', $categories));
        if (!is_null($featured)) {
            $data_attributes['featured'] = $featured ? 'true' : 'false';
        }
        foreach ($data_attributes as $key => $value) {
            $data_attributes_string .= 'data-' . esc_attr($key) . '="' . esc_attr($value) . '" ';
        }
        return '<div class="resumes" ' . $data_attributes_string . '>' . ob_get_clean() . '</div>';
    }
    /**
     * Preview Step
     */
    public function preview()
    {
        global $post, $resume_preview;
        wp_enqueue_script('wp-resume-manager-resume-submission');
        if ($this->resume_id) {
            $resume_preview = true;
            $post = get_post($this->resume_id);
            setup_postdata($post);
            ?>
			<form method="post" id="resume_preview">
				<div class="resume_preview_title">
					<input type="submit" name="continue" id="resume_preview_submit_button" class="button" value="<?php 
            echo apply_filters('submit_resume_step_preview_submit_text', __('Submit Resume &rarr;', 'wp-job-manager-resumes'));
            ?>
" />
					<input type="submit" name="edit_resume" class="button" value="<?php 
            _e('&larr; Edit resume', '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;
            ?>
" />
					<h2>
						<?php 
            _e('Preview', 'wp-job-manager-resumes');
            ?>
					</h2>
				</div>
				<div class="resume_preview single-resume">
					<h1><?php 
            the_title();
            ?>
</h1>
					<?php 
            get_job_manager_template_part('content-single', 'resume', 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
            ?>
				</div>
			</form>
			<?php 
            wp_reset_postdata();
        }
    }
				</dl>
			<?php 
        }
        ?>
		</div>

		<?php 
    }
    ?>

		<?php 
    locate_template(array('sidebar-single-resume.php'), true, false);
    ?>

		<?php 
    do_action('single_resume_end');
    ?>

	<?php 
} else {
    ?>

		<?php 
    get_job_manager_template_part('access-denied', 'single-resume', 'resume_manager', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
    ?>

	<?php 
}
?>

</div>
    /**
     * widget function.
     *
     * @see WP_Widget
     * @access public
     * @param array $args
     * @param array $instance
     * @return void
     */
    function widget($args, $instance)
    {
        global $job_manager;
        if ($this->get_cached_widget($args)) {
            return;
        }
        ob_start();
        extract($args);
        $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
        $number = absint($instance['number']);
        $query_args = array('post_type' => 'job_listing', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $number, 'orderby' => 'date', 'order' => 'DESC');
        if (get_option('job_manager_hide_filled_positions') == 1) {
            $query_args['meta_query'] = array(array('key' => '_filled', 'value' => '1', 'compare' => '!='));
        }
        $jobs = new WP_Query($query_args);
        if ($jobs->have_posts()) {
            ?>

			<?php 
            echo $before_widget;
            ?>

			<?php 
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            ?>

			<ul class="job_listings">

				<?php 
            while ($jobs->have_posts()) {
                $jobs->the_post();
                ?>

					<?php 
                get_job_manager_template_part('content-widget', 'job_listing');
                ?>

				<?php 
            }
            ?>

			</ul>

			<?php 
            echo $after_widget;
            ?>

		<?php 
        }
        wp_reset_postdata();
        $content = ob_get_clean();
        echo $content;
        $this->cache_widget($args, $content);
    }
    /**
     * widget function.
     *
     * @see WP_Widget
     * @access public
     * @param array $args
     * @param array $instance
     */
    public function widget($args, $instance)
    {
        if (!resume_manager_user_can_browse_resumes()) {
            return;
        }
        if ($this->get_cached_widget($args)) {
            return;
        }
        ob_start();
        extract($args);
        $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
        $number = absint($instance['number']);
        $resumes = get_resumes(array('posts_per_page' => $number, 'orderby' => 'date', 'order' => 'DESC', 'featured' => true));
        if ($resumes->have_posts()) {
            ?>

			<?php 
            echo $before_widget;
            ?>

			<?php 
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            ?>

			<ul class="resumes">

				<?php 
            while ($resumes->have_posts()) {
                $resumes->the_post();
                ?>

					<?php 
                get_job_manager_template_part('content-widget', 'resume', 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
                ?>

				<?php 
            }
            ?>

			</ul>

			<?php 
            echo $after_widget;
            ?>

		<?php 
        } else {
            ?>

			<?php 
            get_job_manager_template_part('content-widget', 'no-resumes-found', 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
            ?>

		<?php 
        }
        wp_reset_postdata();
        $content = ob_get_clean();
        echo $content;
        $this->cache_widget($args, $content);
    }
 /**
  * Add extra content before/after the post for single job listings.
  */
 public function job_content($content)
 {
     global $post;
     if (!is_singular('job_listing') || !in_the_loop() || 'job_listing' !== $post->post_type) {
         return $content;
     }
     ob_start();
     $this->job_content_filter(false);
     do_action('job_content_start');
     get_job_manager_template_part('content-single', 'job_listing');
     do_action('job_content_end');
     $this->job_content_filter(true);
     // Put back original content
     $content = str_replace('{{{post_content}}}', apply_filters('the_job_description', $content), ob_get_clean());
     return apply_filters('job_manager_single_job_content', $content, $post);
 }
 /**
  * Add extra content when showing resumes
  */
 public function resume_content($content)
 {
     global $post;
     if (!is_singular('resume') || !in_the_loop()) {
         return $content;
     }
     remove_filter('the_content', array($this, 'resume_content'));
     if ($post->post_type == 'resume') {
         ob_start();
         get_job_manager_template_part('content-single', 'resume', 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
         $content = ob_get_clean();
     }
     add_filter('the_content', array($this, 'resume_content'));
     return $content;
 }
 /**
  * Add extra content before/after the post for single job listings.
  */
 public function job_content($content)
 {
     global $post;
     if (!is_singular('job_listing') || !in_the_loop() || 'job_listing' !== $post->post_type) {
         return $content;
     }
     ob_start();
     $this->job_content_filter(false);
     do_action('job_content_start');
     get_job_manager_template_part('content-single', 'job_listing');
     do_action('job_content_end');
     $this->job_content_filter(true);
     return apply_filters('job_manager_single_job_content', ob_get_clean(), $post);
 }
 /**
  * Add extra content when showing job content
  */
 public function job_content($content)
 {
     global $post, $job_manager;
     if (!is_singular('job_listing')) {
         return $content;
     }
     remove_filter('the_content', array($this, 'job_content'));
     if ($post->post_type == 'job_listing') {
         ob_start();
         get_job_manager_template_part('content-single', 'job_listing');
         $content = ob_get_clean();
     }
     add_filter('the_content', array($this, 'job_content'));
     return $content;
 }
示例#18
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();
    }
}
    /**
     * Job Summary shortcode
     *
     * @access public
     * @param array $args
     * @return string
     */
    public function output_job_summary($atts)
    {
        extract(shortcode_atts(array('id' => '', 'width' => '250px', 'align' => 'left', 'featured' => null), $atts));
        ob_start();
        $args = array('post_type' => 'job_listing', 'post_status' => 'publish');
        if (!$id) {
            $args['posts_per_page'] = 1;
            $args['orderby'] = 'rand';
            if (!is_null($featured)) {
                $args['meta_query'] = array(array('key' => '_featured', 'value' => '1', 'compare' => $featured ? '=' : '!='));
            }
        } 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_summary_shortcode align<?php 
                echo $align;
                ?>
" style="width: <?php 
                echo $width ? $width : auto;
                ?>
">

					<?php 
                get_job_manager_template_part('content-summary', 'job_listing');
                ?>

				</div>

			<?php 
            }
            ?>

		<?php 
        }
        wp_reset_postdata();
        return ob_get_clean();
    }
    /**
     * widget function.
     *
     * @see WP_Widget
     * @access public
     * @param array $args
     * @param array $instance
     * @return void
     */
    public function widget($args, $instance)
    {
        if ($this->get_cached_widget($args)) {
            return;
        }
        ob_start();
        extract($args);
        $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
        $number = absint($instance['number']);
        $jobs = get_job_listings(array('posts_per_page' => $number, 'orderby' => 'date', 'order' => 'DESC', 'featured' => true));
        if ($jobs->have_posts()) {
            ?>

			<?php 
            echo $before_widget;
            ?>

			<?php 
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            ?>

			<ul class="job_listings">

				<?php 
            while ($jobs->have_posts()) {
                $jobs->the_post();
                ?>

					<?php 
                get_job_manager_template_part('content-widget', 'job_listing');
                ?>

				<?php 
            }
            ?>

			</ul>

			<?php 
            echo $after_widget;
            ?>

		<?php 
        } else {
            ?>

			<?php 
            get_job_manager_template_part('content-widget', 'no-jobs-found');
            ?>

		<?php 
        }
        wp_reset_postdata();
        $content = ob_get_clean();
        echo $content;
        $this->cache_widget($args, $content);
    }
    /**
     * Job Summary shortcode
     *
     * @access public
     * @param array $args
     * @return string
     */
    public function output_job_summary($atts)
    {
        global $job_manager;
        extract(shortcode_atts(array('id' => '', 'width' => '250px', 'align' => 'left'), $atts));
        if (!$id) {
            return;
        }
        ob_start();
        $args = array('post_type' => 'job_listing', 'post_status' => 'publish', 'p' => $id);
        $jobs = new WP_Query($args);
        if ($jobs->have_posts()) {
            ?>

			<?php 
            while ($jobs->have_posts()) {
                $jobs->the_post();
                ?>

				<div class="job_summary_shortcode align<?php 
                echo $align;
                ?>
" style="width: <?php 
                echo $width ? $width : auto;
                ?>
">

					<?php 
                get_job_manager_template_part('content-summary', 'job_listing');
                ?>

				</div>

			<?php 
            }
            ?>

		<?php 
        }
        wp_reset_postdata();
        return ob_get_clean();
    }
    /**
     * Get listings via ajax
     */
    public function get_listings()
    {
        global $job_manager, $wpdb;
        $result = array();
        $search_location = sanitize_text_field(stripslashes($_POST['search_location']));
        $search_keywords = sanitize_text_field(stripslashes($_POST['search_keywords']));
        $search_categories = isset($_POST['search_categories']) ? $_POST['search_categories'] : '';
        $filter_job_types = isset($_POST['filter_job_type']) ? array_filter(array_map('sanitize_title', (array) $_POST['filter_job_type'])) : null;
        if (is_array($search_categories)) {
            $search_categories = array_filter(array_map('sanitize_text_field', array_map('stripslashes', $search_categories)));
        } else {
            $search_categories = array_filter(array(sanitize_text_field(stripslashes($search_categories))));
        }
        $args = array('search_location' => $search_location, 'search_keywords' => $search_keywords, 'search_categories' => $search_categories, 'job_types' => is_null($filter_job_types) ? '' : $filter_job_types + array(0), 'orderby' => sanitize_text_field($_POST['orderby']), 'order' => sanitize_text_field($_POST['order']), 'offset' => (absint($_POST['page']) - 1) * absint($_POST['per_page']), 'posts_per_page' => absint($_POST['per_page']), 'show_featured_only' => isset($_POST['show_featured_only']) ? absint($_POST['show_featured_only']) : 0);
        $jobs = get_job_listings(apply_filters('job_manager_get_listings_args', $args));
        $result['found_jobs'] = false;
        ob_start();
        if ($jobs->have_posts()) {
            $result['found_jobs'] = true;
            ?>

			<?php 
            while ($jobs->have_posts()) {
                $jobs->the_post();
                ?>

				<?php 
                get_job_manager_template_part('content', 'job_listing');
                ?>

			<?php 
            }
            ?>

		<?php 
        } else {
            ?>

			<?php 
            get_job_manager_template_part('content', 'no-jobs-found');
            ?>

		<?php 
        }
        $result['html'] = ob_get_clean();
        // Generate 'showing' text
        $types = get_job_listing_types();
        if (sizeof($filter_job_types) > 0 && (sizeof($filter_job_types) !== sizeof($types) || $search_keywords || $search_location || $search_categories || apply_filters('job_manager_get_listings_custom_filter', false))) {
            $showing_types = array();
            $unmatched = false;
            foreach ($types as $type) {
                if (in_array($type->slug, $filter_job_types)) {
                    $showing_types[] = $type->name;
                } else {
                    $unmatched = true;
                }
            }
            if (!$unmatched) {
                $showing_types = '';
            } elseif (sizeof($showing_types) == 1) {
                $showing_types = implode(', ', $showing_types) . ' ';
            } else {
                $last = array_pop($showing_types);
                $showing_types = implode(', ', $showing_types);
                $showing_types .= " &amp; {$last} ";
            }
            $showing_categories = array();
            if ($search_categories) {
                foreach ($search_categories as $category) {
                    if (!is_numeric($category)) {
                        $category_object = get_term_by('slug', $category, 'job_listing_category');
                    }
                    if (is_numeric($category) || is_wp_error($category_object) || !$category_object) {
                        $category_object = get_term_by('id', $category, 'job_listing_category');
                    }
                    if (!is_wp_error($category_object)) {
                        $showing_categories[] = $category_object->name;
                    }
                }
            }
            if ($search_keywords) {
                $showing_jobs = sprintf(__('Showing %s&ldquo;%s&rdquo; %sjobs', 'wp-job-manager'), $showing_types, $search_keywords, implode(', ', $showing_categories));
            } else {
                $showing_jobs = sprintf(__('Showing all %s%sjobs', 'wp-job-manager'), $showing_types, implode(', ', $showing_categories) . ' ');
            }
            $showing_location = $search_location ? sprintf(' ' . __('located in &ldquo;%s&rdquo;', 'wp-job-manager'), $search_location) : '';
            $result['showing'] = apply_filters('job_manager_get_listings_custom_filter_text', $showing_jobs . $showing_location);
        } else {
            $result['showing'] = '';
        }
        // Generate RSS link
        $result['showing_links'] = job_manager_get_filtered_links(array('filter_job_types' => $filter_job_types, 'search_location' => $search_location, 'search_categories' => $search_categories, 'search_keywords' => $search_keywords));
        $result['max_num_pages'] = $jobs->max_num_pages;
        echo '<!--WPJM-->';
        echo json_encode(apply_filters('job_manager_get_listings_result', $result));
        echo '<!--WPJM_END-->';
        die;
    }
 /**
  * Add extra content when showing job content
  */
 public function job_content($content)
 {
     global $post;
     if (!is_singular('job_listing') || !in_the_loop()) {
         return $content;
     }
     remove_filter('the_content', array($this, 'job_content'));
     if ('job_listing' === $post->post_type) {
         ob_start();
         do_action('job_content_start');
         get_job_manager_template_part('content-single', 'job_listing');
         do_action('job_content_end');
         $content = ob_get_clean();
     }
     add_filter('the_content', array($this, 'job_content'));
     return apply_filters('job_manager_single_job_content', $content, $post);
 }
    /**
     * Jobs by tag shortcode
     *
     * @return string
     */
    public function jobs_by_tag($atts)
    {
        global $job_manager;
        ob_start();
        extract(shortcode_atts(array('per_page' => '-1', 'orderby' => 'date', 'order' => 'desc', 'tag' => '', 'tags' => ''), $atts));
        $tags = array_filter(array_map('sanitize_title', explode(',', $tags)));
        if ($tag) {
            $tags[] = sanitize_title($tag);
        }
        if (!$tags) {
            return;
        }
        $args = array('post_type' => 'job_listing', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $per_page, 'orderby' => $orderby, 'order' => $order);
        $args['tax_query'] = array(array('taxonomy' => 'job_listing_tag', 'field' => 'slug', 'terms' => $tags));
        if (get_option('job_manager_hide_filled_positions') == 1) {
            $args['meta_query'] = array(array('key' => '_filled', 'value' => '1', 'compare' => '!='));
        }
        $jobs = new WP_Query(apply_filters('job_manager_output_jobs_args', $args));
        if ($jobs->have_posts()) {
            ?>

			<ul class="job_listings">

				<?php 
            while ($jobs->have_posts()) {
                $jobs->the_post();
                ?>

					<?php 
                get_job_manager_template_part('content', 'job_listing');
                ?>

				<?php 
            }
            ?>

			</ul>

		<?php 
        } else {
            echo '<p>' . sprintf(__('No jobs found tagged with %s.', 'wp-job-manager-tags'), implode(', ', $tags)) . '</p>';
        }
        wp_reset_postdata();
        return '<div class="job_listings">' . ob_get_clean() . '</div>';
    }
    /**
     * Preview Step
     */
    public static function preview()
    {
        global $job_manager, $post;
        if (self::$job_id) {
            $post = get_post(self::$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;', 'wp-job-manager'));
            ?>
" />
					<input type="submit" name="edit_job" class="button" value="<?php 
            _e('&larr; Edit listing', 'wp-job-manager');
            ?>
" />
					<input type="hidden" name="job_id" value="<?php 
            echo esc_attr(self::$job_id);
            ?>
" />
					<input type="hidden" name="step" value="<?php 
            echo esc_attr(self::$step);
            ?>
" />
					<input type="hidden" name="job_manager_form" value="<?php 
            echo self::$form_name;
            ?>
" />
					<h2>
						<?php 
            _e('Preview', 'wp-job-manager');
            ?>
					</h2>
				</div>
				<div class="job_listing_preview single_job_listing">
					<h1><?php 
            the_title();
            ?>
</h1>
					<?php 
            get_job_manager_template_part('content-single', 'job_listing');
            ?>
				</div>
			</form>
			<?php 
            wp_reset_postdata();
        }
    }