This repository has been archived by the owner on Jul 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathwp-job-manager-custom-post-type.php
186 lines (164 loc) · 11.3 KB
/
wp-job-manager-custom-post-type.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
class Bullhorn_WP_Job_Manager_Custom_Post_Type {
public function __construct() {
add_action( 'init', array( __CLASS__, 'init' ) );
add_action( 'the_content', array( __CLASS__, 'add_json_ld_to_content' ) );
add_filter( 'manage_' . Bullhorn_2_WP::$post_type_application . '_posts_columns', array( 'Bullhorn_Custom_Post_Type', 'set_custom_edit_columns' ) );
add_action( 'manage_' . Bullhorn_2_WP::$post_type_application . '_posts_custom_column', array( 'Bullhorn_Custom_Post_Type', 'custom_column' ), 10, 2 );
add_filter( 'manage_edit-' . Bullhorn_2_WP::$post_type_application . '_sortable_columns', array( 'Bullhorn_Custom_Post_Type', 'sortable_column' ) );
add_action( 'init' , array( 'Bullhorn_Custom_Post_Type', 'sniff_post' ) );
add_action( 'pre_get_posts', array( 'Bullhorn_Custom_Post_Type', 'orderby' ) );
}
public static function init() {
$labels = array(
'name' => _x( 'Applications', 'Taxonomy General Name', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'singular_name' => _x( 'Application', 'Taxonomy Singular Name', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'add_new' => __( 'Add New', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'add_new_item' => __( 'Add New Application', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'edit_item' => __( 'Edit Application', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'new_item' => __( 'New Application', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'all_items' => __( 'All Applications', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'view_item' => __( 'View Application', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'search_items' => __( 'Search Applications', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'not_found' => __( 'No Applications found', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'not_found_in_trash' => __( 'No Applications found in Trash', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'parent_item_colon' => '',
'menu_name' => __( 'Application', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
);
$args = array(
'labels' => $labels,
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_menu' => 'edit.php?post_type=' . Bullhorn_2_WP::$post_type_job_listing,
'query_var' => true,
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'custom-fields' ),
);
register_post_type( Bullhorn_2_WP::$post_type_application, $args );
$labels = array(
'name' => _x( 'States', 'Taxonomy General Name', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'singular_name' => _x( 'State', 'Taxonomy Singular Name', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'menu_name' => __( 'States', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'all_items' => __( 'All States', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'parent_item' => __( 'Parent State', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'parent_item_colon' => __( 'Parent State:', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'new_item_name' => __( 'New State', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'add_new_item' => __( 'Add New State', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'edit_item' => __( 'Edit State', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'update_item' => __( 'Update State', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'separate_items_with_commas' => __( 'Separate states with commas', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'search_items' => __( 'Search states', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'add_or_remove_items' => __( 'Add or remove states', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'choose_from_most_used' => __( 'Choose from the most used states', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
);
register_taxonomy( Bullhorn_2_WP::$taxonomy_listing_state, Bullhorn_2_WP::$post_type_job_listing, $args );
if ( 'job_listing_category' !== Bullhorn_2_WP::$taxonomy_listing_category ) {
$labels = array(
'name' => _x( 'Categories', 'Taxonomy General Name', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'singular_name' => _x( 'Category', 'Taxonomy Singular Name', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'menu_name' => __( 'Categories', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'all_items' => __( 'All Categories', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'parent_item' => __( 'Parent Category', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'parent_item_colon' => __( 'Parent Category:', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'new_item_name' => __( 'New Category', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'add_new_item' => __( 'Add New Category', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'edit_item' => __( 'Edit Category', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'update_item' => __( 'Update Category', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'separate_items_with_commas' => __( 'Separate categories with commas', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'search_items' => __( 'Search categories', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'add_or_remove_items' => __( 'Add or remove categories', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'choose_from_most_used' => __( 'Choose from the most used categories', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
);
register_taxonomy( Bullhorn_2_WP::$taxonomy_listing_category, Bullhorn_2_WP::$post_type_job_listing, $args );
}
$labels = array(
'name' => _x( 'Skills', 'Taxonomy General Name', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'singular_name' => _x( 'Skill', 'Taxonomy Singular Name', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'menu_name' => __( 'Skills', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'all_items' => __( 'All Skills', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'parent_item' => __( 'Parent Skill', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'parent_item_colon' => __( 'Parent Skill:', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'new_item_name' => __( 'New Skill', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'add_new_item' => __( 'Add New Skill', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'edit_item' => __( 'Edit Skill', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'update_item' => __( 'Update Skill', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'separate_items_with_commas' => __( 'Separate skills with commas', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'search_items' => __( 'Search skills', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'add_or_remove_items' => __( 'Add or remove skills', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'choose_from_most_used' => __( 'Choose from the most used skills', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
);
register_taxonomy( Bullhorn_2_WP::$taxonomy_listing_skills, Bullhorn_2_WP::$post_type_job_listing, $args );
$labels = array(
'name' => _x( 'Certifications', 'Taxonomy General Name', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'singular_name' => _x( 'Certification', 'Taxonomy Singular Name', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'menu_name' => __( 'Certifications', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'all_items' => __( 'All Certifications', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'parent_item' => __( 'Parent Certification', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'parent_item_colon' => __( 'Parent Certification:', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'new_item_name' => __( 'New Certification', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'add_new_item' => __( 'Add New Certification', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'edit_item' => __( 'Edit Certification', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'update_item' => __( 'Update Certification', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'separate_items_with_commas' => __( 'Separate certifications with commas', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'search_items' => __( 'Search certifications', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'add_or_remove_items' => __( 'Add or remove certifications', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'choose_from_most_used' => __( 'Choose from the most used certifications', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
);
register_taxonomy( Bullhorn_2_WP::$taxonomy_listing_certifications, Bullhorn_2_WP::$post_type_job_listing, $args );
}
public static function add_json_ld_to_content( $content = null ) {
if ( get_post_type() === Bullhorn_2_WP::$post_type_job_listing ) {
if ( is_single() ) {
$bullhorn_json_ld = get_post_meta( get_the_ID(), 'bullhorn_json_ld', true );
$depth = apply_filters( 'bullhorn_json_ld_depth', 1024 );
$options = apply_filters( 'bullhorn_json_ld_options', JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES );
if ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) {
$options = $options | JSON_PRETTY_PRINT;
}
$bullhorn_json_ld = apply_filters( 'bullhorn_json_ld_full_array', $bullhorn_json_ld );
$content = PHP_EOL . sprintf( '<script type="application/ld+json">%s</script>', wp_json_encode( $bullhorn_json_ld, $options, $depth ) ) . PHP_EOL . $content;
}
}
return $content;
}
}