<?php
+
/**
* Sets up the job post type and its taxonomies. Handles also the new fields in
* the metaboxes.
*/
public function __construct($path)
{
+// global $typenow;
$this->pluginDirName = $path;
add_action('init', array($this, 'addPostTypes'));
add_action('init', array($this, 'createJobTaxonomy'));
add_filter('post_updated_messages', array($this, 'jobsUpdatedMessages'));
add_filter('manage_edit-glm_jobs_columns',
- array($this, 'jobsEditColumns'));
+ array($this, 'jobsEditColumns'));
add_action('manage_posts_custom_column',
- array($this, 'jobsCustomColumns'));
+ array($this, 'jobsCustomColumns'));
add_action('admin_init', array($this, 'metaDates'));
add_action('save_post', array($this, 'saveEmpMeta'));
- add_filter('manage_edit-glm_jobs_sortable_columns', array($this, 'sortingColumns'));
-// add_action('restrict_manage_posts', array($this, 'jobFilterList'));
-// add_filter('parse_query', array($this, 'jobFilter'));
- add_filter('user_row_actions', array($this, 'remove_row_actions'));
+ add_filter('manage_edit-glm_jobs_sortable_columns',
+ array($this, 'sortingColumns'));
+ add_action('restrict_manage_posts',
+ array($this, 'taxonomy_filter_restrict_manage_posts'));
+ add_filter('parse_query', array($this, 'jobFilter'));
+// var_dump($typenow);
+// add_filter('user_row_actions', array($this, 'remove_row_actions'));
+ }
+
+ // Filter the request to just give posts for the given taxonomy, if applicable.
+ function taxonomy_filter_restrict_manage_posts()
+ {
+ global $typenow;
+// var_dump($typenow);
+ if ($typenow == GLM_EMP_POST_TYPE) {
+ $filters = get_object_taxonomies(GLM_EMP_POST_TYPE);
+
+ foreach ($filters as $tax_slug) {
+ $tax_obj = get_taxonomy($tax_slug);
+ wp_dropdown_categories(array(
+ 'show_option_all' => __('Show All ' . $tax_obj->label),
+ 'taxonomy' => $tax_slug,
+ 'name' => $tax_obj->name,
+ 'orderby' => 'name',
+ 'selected' => $_GET[$tax_slug],
+ 'hierarchical' => $tax_obj->hierarchical,
+ 'show_count' => true,
+ 'hide_empty' => true
+ ));
+ }
+ }
+
+
+
+ }
+
+ function taxonomy_filter_post_type_request($query)
+ {
+ global $pagenow, $typenow;
+//var_dump($typenow);
+ if ('edit.php' == $pagenow && $typenow == GLM_EMP_POST_TYPE) {
+ $filters = get_object_taxonomies(GLM_EMP_POST_TYPE);
+// var_dump($filters);
+ foreach ($filters as $tax_slug) {
+ $var = &$query->query_vars[$tax_slug];
+// var_dump($var);
+// var_dump($tax_slug);
+ if (isset($var)) {
+ $term = get_term_by('id', $var, $tax_slug);
+ var_dump($term);
+ $var['term'] = $term->slug;
+ var_dump($var['term']);
+ var_dump($term->slug);
+ }
+ }
+ }
}
public function remove_row_actions($actions, $post)
*/
public function jobFilter($query)
{
- if (isset($_REQUEST['post_type']) && $_REQUEST['post_type'] == GLM_EMP_POST_TYPE) {
- $qv =& $query->query_vars;
+ global $pagenow, $typenow;
+ if ('edit.php' == $pagenow && $typenow == GLM_EMP_POST_TYPE) {
+ $qv = & $query->query_vars;
if (isset($qv['post_type']) && $qv['post_type'] == GLM_EMP_POST_TYPE) {
+ //$qv['post_type'] = 'page';//GLM_EMP_POST_TYPE;
if (isset($qv[GLM_EMP_TAX_CATEGORIES]) && $qv[GLM_EMP_TAX_CATEGORIES] != 0) {
- $term = get_term_by('id',$qv[GLM_EMP_TAX_CATEGORIES],GLM_EMP_TAX_CATEGORIES);
+ $term = get_term_by('id', $qv[GLM_EMP_TAX_CATEGORIES], GLM_EMP_TAX_CATEGORIES);
$qv[GLM_EMP_TAX_CATEGORIES] = $term->slug;
-// if (isset($query->tax_query)) {
-// $tax_query =& $query->tax_query;
-// $queries =& $tax_query->queries;
-//// echo '<pre>'.print_r($queries, true).'</pre>';
-// foreach ($queries as $key => &$qs) {
-// if ($qs['taxonomy'] == GLM_EMP_TAX_CATEGORIES) {
-// $qs['terms'][$key] = $term->slug;
-// }
-// }
-// }
+ if (isset($query->tax_query)) {
+ $tax_query =& $query->tax_query;
+ $queries =& $tax_query->queries;
+// echo '<pre>'.print_r($queries, true).'</pre>';
+ foreach ($queries as $key => &$qs) {
+ if ($qs['taxonomy'] == GLM_EMP_TAX_CATEGORIES) {
+ $qs['terms'][$key] = $term->slug;
+ }
+ }
+ }
}
if (isset($qv[GLM_EMP_TAX_DEPARTMENTS]) && $qv[GLM_EMP_TAX_DEPARTMENTS] != 0) {
- $term = get_term_by('id',$qv[GLM_EMP_TAX_DEPARTMENTS],GLM_EMP_TAX_DEPARTMENTS);
+ $term = get_term_by('id', $qv[GLM_EMP_TAX_DEPARTMENTS], GLM_EMP_TAX_DEPARTMENTS);
$qv[GLM_EMP_TAX_DEPARTMENTS] = $term->slug;
}
if ($qv['post_type'] == GLM_EMP_POST_TYPE) {
// echo '<pre>'.print_r($qv, true).'</pre>';
-
}
// echo '<pre>'.print_r($query, true).'</pre>';
}
return $query;
}
-
}
/**
'taxonomy' => GLM_EMP_TAX_CATEGORIES,
'name' => GLM_EMP_TAX_CATEGORIES,
'orderby' => 'name',
- 'selected' => (isset($wp_query->query[GLM_EMP_TAX_CATEGORIES])? $wp_query->query[GLM_EMP_TAX_CATEGORIES]: ''),
+ 'selected' => (isset($wp_query->query[GLM_EMP_TAX_CATEGORIES])
+ ? $wp_query->query[GLM_EMP_TAX_CATEGORIES]
+ : ''),
'hierarchical' => true,
'depth' => 3,
'show_count' => true,
'taxonomy' => GLM_EMP_TAX_DEPARTMENTS,
'name' => GLM_EMP_TAX_DEPARTMENTS,
'orderby' => 'name',
- 'selected' => (isset($wp_query->query[GLM_EMP_TAX_DEPARTMENTS])? $wp_query->query[GLM_EMP_TAX_DEPARTMENTS]: ''),
+ 'selected' => (isset($wp_query->query[GLM_EMP_TAX_DEPARTMENTS])
+ ? $wp_query->query[GLM_EMP_TAX_DEPARTMENTS]
+ : ''),
'hierarchical' => true,
'depth' => 3,
'show_count' => true,
public function editJobMeta()
{
global $post;
- $custom = get_post_custom($post->ID);
+ $custom = get_post_custom($post->ID);
extract($custom);
$meta_sd = (isset($custom['glm_jobs_startdate']))
$clean_sd = date('D, M d, Y', $meta_sd);
$clean_ed = date('D, M d, Y', $meta_ed);
- $glm_jobs_status = (isset($glm_jobs_status[0]))
+ $glm_jobs_status = (isset($glm_jobs_status[0]))
? $glm_jobs_status[0]
: '';
$glm_jobs_pay_grade = (isset($glm_jobs_pay_grade[0]))
? $glm_jobs_pay_grade[0]
: '';
- $glm_jobs_shift = (isset($glm_jobs_shift[0]))
+ $glm_jobs_shift = (isset($glm_jobs_shift[0]))
? $glm_jobs_shift[0]
: '';
- $glm_jobs_contact = (isset($glm_jobs_contact[0]))
+ $glm_jobs_contact = (isset($glm_jobs_contact[0]))
? $glm_jobs_contact[0]
: '';
- $glm_jobs_email = (isset($glm_jobs_email[0]))
+ $glm_jobs_email = (isset($glm_jobs_email[0]))
? $glm_jobs_email[0]
: '';
- $glm_jobs_comments = (isset($glm_jobs_comments[0]))
+ $glm_jobs_comments = (isset($glm_jobs_comments[0]))
? $glm_jobs_comments[0]
: '';
- $glm_jobs_code = (isset($glm_jobs_code[0]))
+ $glm_jobs_code = (isset($glm_jobs_code[0]))
? $glm_jobs_code[0]
: '';
'menu_name' => 'Jobs'
);
$args = array(
- 'label' => __('Jobs'),
+// 'label' => __('Jobs'),
'labels' => $labels,
'description' => 'Stores Jobs and Job data',
'public' => true,
'supports' => array('title', 'editor'),
'has_archive' => true,
'menu_icon' => 'dashicons-businessman',
- 'capability_type' => 'page',
+ 'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => 'jobs'),
'taxonomies' => array(GLM_EMP_TAX_CATEGORIES, GLM_EMP_TAX_DEPARTMENTS),
- 'show_in_menu' => true
+ 'show_in_menu' => true,
+ 'show_ui' => true,
+ 'query_var' => true,
+ 'publicly_queryable' => true
);
register_post_type(GLM_EMP_POST_TYPE, $args);
+ register_taxonomy_for_object_type(GLM_EMP_TAX_CATEGORIES,
+ GLM_EMP_POST_TYPE);
+ register_taxonomy_for_object_type(GLM_EMP_TAX_DEPARTMENTS,
+ GLM_EMP_POST_TYPE);
}
/**
global $post, $post_ID;
$messages['post'] = array(
- 0 => '', // Unused. Messages start at index 1.
- 1 => sprintf( __('Job updated. <a href="%s">View item</a>'), esc_url( get_permalink($post_ID) ) ),
- 2 => __('Custom field updated.'),
- 3 => __('Custom field deleted.'),
- 4 => __('Job updated.'),
+ 0 => '', // Unused. Messages start at index 1.
+ 1 => sprintf(__('Job updated. <a href="%s">View item</a>'),
+ esc_url(get_permalink($post_ID))),
+ 2 => __('Custom field updated.'),
+ 3 => __('Custom field deleted.'),
+ 4 => __('Job updated.'),
/* translators: %s: date and time of the revision */
- 5 => isset($_GET['revision']) ? sprintf( __('Job restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
- 6 => sprintf( __('Job published. <a href="%s">View event</a>'), esc_url( get_permalink($post_ID) ) ),
- 7 => __('Job saved.'),
- 8 => sprintf( __('Job submitted. <a target="_blank" href="%s">Preview event</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
- 9 => sprintf( __('Job scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview job</a>'),
- // translators: Publish box date format, see http://php.net/date
- date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
- 10 => sprintf( __('Job draft updated. <a target="_blank" href="%s">Preview event</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
+ 5 => isset($_GET['revision'])
+ ? sprintf(__('Job restored to revision from %s'),
+ wp_post_revision_title((int) $_GET['revision'],
+ false))
+ : false,
+ 6 => sprintf(__('Job published. <a href="%s">View event</a>'),
+ esc_url(get_permalink($post_ID))),
+ 7 => __('Job saved.'),
+ 8 => sprintf(__('Job submitted. <a target="_blank" href="%s">Preview event</a>'),
+ esc_url(add_query_arg('preview', 'true',
+ get_permalink($post_ID)))),
+ 9 => sprintf(__('Job scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview job</a>'),
+ // translators: Publish box date format, see http://php.net/date
+ date_i18n(__('M j, Y @ G:i'),
+ strtotime($post->post_date)),
+ esc_url(get_permalink($post_ID))),
+ 10 => sprintf(__('Job draft updated. <a target="_blank" href="%s">Preview event</a>'),
+ esc_url(add_query_arg('preview', 'true',
+ get_permalink($post_ID)))),
);
return $messages;
}
);
register_taxonomy(
- GLM_EMP_TAX_CATEGORIES,
- null, //GLM_EMP_POST_TYPE,
+ GLM_EMP_TAX_CATEGORIES, GLM_EMP_POST_TYPE,
array(
- 'label' => __('Job Category'),
- 'labels' => $labels,
- 'hierarchical' => true,
- 'show_ui' => true,
- 'query_var' => GLM_EMP_TAX_CATEGORIES,
- 'rewrite' => array('slug' => GLM_EMP_TAX_CATEGORIES),
- 'show_admin_column' => true,
- '_builtin' => true
+ 'label' => __('Job Category'),
+ 'labels' => $labels,
+ 'hierarchical' => true,
+ 'show_ui' => true,
+ 'query_var' => GLM_EMP_TAX_CATEGORIES,
+ 'rewrite' => array('slug' => GLM_EMP_TAX_CATEGORIES),
+ 'show_admin_column' => true,
+ '_builtin' => true
));
- register_taxonomy_for_object_type(GLM_EMP_TAX_CATEGORIES, GLM_EMP_POST_TYPE);
+
$labels = array(
'name' => _x('Departments',
'taxonomy general name'),
);
register_taxonomy(
- GLM_EMP_TAX_DEPARTMENTS,
- null, //GLM_EMP_POST_TYPE,
+ GLM_EMP_TAX_DEPARTMENTS, GLM_EMP_POST_TYPE,
array(
- 'label' => __('Job Department'),
- 'labels' => $labels,
- 'hierarchical' => true,
- 'show_ui' => true,
- 'query_var' => GLM_EMP_TAX_DEPARTMENTS,
- 'rewrite' => array('slug' => GLM_EMP_TAX_DEPARTMENTS),
+ 'label' => __('Job Department'),
+ 'labels' => $labels,
+ 'hierarchical' => true,
+ 'show_ui' => true,
+ 'query_var' => GLM_EMP_TAX_DEPARTMENTS,
+ 'rewrite' => array('slug' => GLM_EMP_TAX_DEPARTMENTS),
));
- register_taxonomy_for_object_type(GLM_EMP_TAX_DEPARTMENTS, GLM_EMP_POST_TYPE);
}
/**