Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Job CPT tweaks #43

Merged
merged 3 commits into from Apr 25, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions archive-job_posting.php
@@ -0,0 +1,18 @@
<?php
/**
* Archive: job_posting
* @package WordPress
*/

get_header(); ?>

<div id="wrap">
<div id="content" role="main">
<h1 class="entry-title">Jobs</h1>
<?php get_template_part( 'loop', 'job_listings' ); ?>

</div><!-- #content -->
</div><!-- #wrap -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>
68 changes: 51 additions & 17 deletions includes/cpt_job_board.php
@@ -1,6 +1,35 @@
<?php
/* Job Posting Custom Post Type */

function job_posting_search($job_type_selected='',$term='') {
do_action('job_posting_search',$job_type_selected,$term);
}

add_action('job_posting_search','job_posting_search_form',5,3);

function job_posting_search_form($job_type_selected='',$term='Wildlife Biologist') { ?>
<div class="job_posting-search-form">
<label>
<h4>Search Job Postings</h4>
</label>
<form role="search" class="searchform" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
<?php
/*echo '<div class="tax-options">';
$args = array('order'=>'ASC','hide_empty'=>true);
echo get_terms_dropdown($job_type_selected, $args);
echo '</div>';
*/
?>
<input type="text" class="s" name="searchjobpostings" id="s" placeholder="<?php echo $term; ?>" onfocus="if(this.value==this.defaultValue)this.value='<?php echo $term; ?>';" onblur="if(this.value=='<?php echo $term; ?>')this.value=this.defaultValue;"/>
<input class="job_posting-submit" type="submit" name="submit" value="Search" />
<input type="hidden" name="post_type" value="job_posting" />
</form>
</div>
<?php
}



add_action( 'init', 'create_job_posting_post_type' );
function create_job_posting_post_type() {
register_post_type( 'job_posting',
Expand Down Expand Up @@ -31,10 +60,10 @@ function create_job_posting_post_type() {
);
}

// hook into the init action and call create_tests_taxonomies() when it fires
// hook into the init action and call create_job_taxonomies() when it fires
add_action( 'init', 'create_job_taxonomies', 0 );

// create three taxonomies, species and lab sections for the post type "tests"
// create three taxonomies, species and lab sections for the post type "job_posting"
function create_job_taxonomies() {

// Add new taxonomy, make it hierarchical (like categories)
Expand Down Expand Up @@ -70,21 +99,26 @@ function job_posting_meta_init() {
}

function job_posting_details_meta() {
global $post;
$custom = get_post_custom($post->ID);

$job_number = $custom["job_number"][0];
$agency = $custom["agency"][0];
$location = $custom["location"][0];
$salary = $custom["salary"][0];
$apply_date = $custom["apply_date"][0];
$description = $custom["description"][0];
$qualifications=$custom["qualifications"][0];
$contact_name = $custom["contact_name"][0];
$contact_email= $custom["contact_email"][0];
$contact_phone= $custom["contact_phone"][0];

include(MY_THEME_FOLDER . '/includes/meta_boxes/jobs_meta_html.php');
global $post;
$custom = get_post_custom($post->ID);

// Still Support the legacy _my_meta fields
$my_meta = get_post_meta($post->ID,'_my_meta',TRUE);

$job_number = ($my_meta['job_number']<>''? $my_meta['job_number'] : $custom["job_number"][0]);
$agency = ($my_meta['agency']<>'' ? $my_meta['agency'] : $custom["agency"][0]);
$location = ($my_meta['location']<>'' ? $my_meta['location'] : $custom["location"][0]);
$type = ($my_meta['type'] <>'' ? $my_meta['type'] : $custom["classification"][0]);
$salary = ($my_meta['salary']<>'' ? $my_meta['salary'] : $custom["salary"][0]);
$apply_date = ($my_meta['apply-date'] <> '' ? $my_meta['apply-date'] : $custom["apply_date"][0]);
$start_date = ($my_meta['start-date'] <> '' ? $my_meta['start-date'] : $custom["start_date"][0]);
$description = ($my_meta['description'] <> '' ? $my_meta['description'] : $custom["description"][0]);
$qualifications = ($my_meta['qualifications'] <> '' ? $my_meta['qualifications'] : $custom["qualifications"][0]);
$contact_name = ($my_meta['contact-name'] <> '' ? $my_meta['contact-name'] : $custom["contact_name"][0]);
$contact_phone = ($my_meta['contact-phone'] <> '' ? $my_meta['contact-phone'] : $custom["contact_phone"][0]);
$contact_email = ($my_meta['contact-email'] <> '' ? $my_meta['contact-email'] : $custom["contact_email"][0]);

include(MY_THEME_FOLDER . '/includes/meta_boxes/jobs_meta_html.php');
}


Expand Down
5 changes: 4 additions & 1 deletion includes/meta_boxes/jobs_meta_html.php
Expand Up @@ -12,7 +12,10 @@
<input type="text" class="admin-form-input" id="salary" name="salary" value="<?php if(!empty($salary)) echo $salary; ?>" placeholder="$50,000" size="25" /></p>

<p><label class="admin-form-label" for="apply_date">Last Date to Apply</label>
<input type="text" class="admin-form-input" id="apply-date" name="apply_date" value="<?php if(!empty($apply_date)) echo $apply_date; ?>" placeholder="October 3, 2012" size="25" /></p>
<input type="text" class="admin-form-input" id="apply-date" name="apply_date" value="<?php if(!empty($apply_date)) echo $apply_date; ?>" placeholder="October 3, 2013" size="25" /></p>

<p><label class="admin-form-label" for="start_date">Start Date</label>
<input type="text" class="admin-form-input" id="start-date" name="start_date" value="<?php if(!empty($start_date)) echo $start_date; ?>" placeholder="October 15, 2013" size="25" /></p>

<p><label class="admin-form-label" for="description">Job Description</label>
<textarea class="admin-form-input" id="description" name="description" cols="65" rows="8"><?php if(!empty($description)) echo $description; ?></textarea></p>
Expand Down
23 changes: 23 additions & 0 deletions includes/shortcodes.php
Expand Up @@ -267,4 +267,27 @@ function myLoop($atts, $content = null) {
}
add_shortcode("loop", "myLoop");



/**
* The Job Postings shortcode. [job_postings]
*
* Shows the entries in the job_postings custom post type. Just points to the archive page.
**
*/
function job_postings_shortcode() {
global $post;

$paged = 1;
if ( get_query_var('paged') ) $paged = get_query_var('paged');
if ( get_query_var('page') ) $paged = get_query_var('page');

query_posts( '&post_type=job_posting&paged=' . $paged );
//include(MY_THEME_FOLDER . '/archive-job_posting.php');
get_template_part( 'loop', 'job_listings' );

}
add_shortcode('job_postings', 'job_postings_shortcode');


?>
90 changes: 90 additions & 0 deletions loop-job_listings.php
@@ -0,0 +1,90 @@
<?php
/**
* The loop that displays posts.
*
* The loop displays the posts and the post content. See
* http://codex.wordpress.org/The_Loop to understand it and
* http://codex.wordpress.org/Template_Tags to understand
* the tags used in it.
*
* This can be overridden in child themes with loop.php or
* loop-template.php, where 'template' is the loop context
* requested by a template. For example, loop-index.php would
* be used if it exists and we ask for the loop with:
* <code>get_template_part( 'loop', 'index' );</code>
*
* Used in archive.php
*
* @package WordPress
* @subpackage agriflex
* @since agriflex 1.0
*/
?>


<div class="job-search-form">
<label>
<h4>Search Job Board Database</h4>
</label>
<form role="search" class="searchform" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
<input type="text" class="s" name="s" id="s" placeholder="Wildlife Biologist" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/><br />
<input type="hidden" name="post_type" value="job_posting" />
</form>
</div>

<?php
//might need to beef up the search later
//job_posting_search($_GET['job_type'],$_GET['searchjobpostings']);
?>

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$my_query = new WP_Query('post_type=job_posting&post_status=publish&posts_per_page=30&paged='. $paged);
?>
<?php /* If there are no tests to display, let the user know */ ?>
<?php if ( ! $my_query -> have_posts() ) : ?>
<div id="post-0" class="post error404 not-found">
<h1 class="entry-title"><?php _e( 'Not Found', 'agriflex' ); ?></h1>
<div class="entry-content">
<p><?php _e( 'Apologies, but no jobs were found that match your search criteria.', 'agriflex' ); ?></p>
</div><!-- .entry-content -->
</div><!-- #post-0 -->
<?php endif; ?>


<ul class="job-listing-ul">
<?php
while ($my_query->have_posts()) : $my_query->the_post();
global $post;
$my_meta = get_post_meta($post->ID,'_my_meta',TRUE);

$custom = get_post_custom($post->ID);

//echo '<hr />my_meta:<pre>'.print_r($my_meta['agency']).'</pre>';
//echo 'agency: '.$my_meta['agency'];
//echo '<hr />custom:<pre>'.print_r($custom).'</pre>';

$job_number = ($my_meta['job_number']<>'' ? $my_meta['job_number'] : $custom["job_number"][0]);
$agency = ($my_meta['agency']<>'' ? $my_meta['agency'] : $custom["agency"][0]);
$location = ($my_meta['location']<>'' ? $my_meta['location'] : $custom["location"][0]);
$type = ($my_meta['type'] <>'' ? $my_meta['type'] : $custom["classification"][0]);

?>
<li class="job-listing-item">
<a class="job-listing-link" href="<?php the_permalink(); ?>">
<div class="role">
<h2 class="job-title" title="<?php the_title(); ?>"><?php the_title(); ?></h2>
<h3 class="job-agency"><?php echo $agency; ?></h3>
<p class="job-location location"><?php echo $location; ?></p>
<p class="job-type type"><?php echo $type; ?></p>
</div>
</a>
</li>

<?php endwhile;?>
</ul>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('Previous entries') ?></div>
<div class="alignright"><?php previous_posts_link('Next entries') ?></div>
</div>
<?php wp_reset_query(); ?>
61 changes: 0 additions & 61 deletions page-job-posting-archive.php

This file was deleted.

13 changes: 12 additions & 1 deletion single-job_posting.php
Expand Up @@ -45,7 +45,7 @@
$contact_name = ($my_meta['contact-name'] <> '' ? $my_meta['contact-name'] : $custom["contact_name"][0]);
$contact_phone = ($my_meta['contact-phone'] <> '' ? $my_meta['contact-phone'] : $custom["contact_phone"][0]);
$contact_email = ($my_meta['contact-email'] <> '' ? $my_meta['contact-email'] : $custom["contact_email"][0]);

$job_categories = get_the_terms( $post->ID, 'job_category');
?>
<div class="job-posting-details">
<dl class="job-posting-dl">
Expand All @@ -57,6 +57,17 @@
<dt class="job-posting-dt">Location</dt>
<dd class="job-posting-dd"><?php echo $location;?></dd>
<?php } ?>
<?php
if ( $job_categories && ! is_wp_error( $job_categories ) ) {
$job_category_names = array();
foreach ( $job_categories as $term ) {
$job_category_names[] = $term->name;
}
$the_job_category = join( ", ", $job_category_names );
?>
<dt class="job-posting-dt">Job Category</dt>
<dd class="job-posting-dd"><?php echo $the_job_category;?></dd>
<?php } ?>

<?php if ($salary) { ?>
<dt class="job-posting-dt">Salary</dt>
Expand Down