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-addon.php
253 lines (213 loc) · 9.67 KB
/
wp-job-manager-addon.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<?php
class Bullhorn_WP_Job_Manager_Addon {
public function __construct() {
add_filter( 'job_manager_locate_template', array( __CLASS__, 'job_manager_locate_template' ), 10, 3 );
add_filter( 'job_manager_application_details_bullhorn', array( __CLASS__, 'render_application_form' ) );
// support for addons
if ( is_plugin_active( 'wp-job-manager-locations/wp-job-manager-locations.php' ) ) {
require 'wp-job-manager-addon-regions.php';
new WP_Job_Manager_Addon_Regions();
}
}
public static function render_application_form() {
$option = get_option( 'job_manager_bullhorn_default_form_input' );
if ( 'name_email_phone' === $option ) {
echo \bullhorn_2_wp\Shortcodes::render_cv_form();
} else if ( 'name_email_phone_address' === $option ) {
echo \bullhorn_2_wp\Shortcodes::render_cv_appication();
} else {
echo \bullhorn_2_wp\Shortcodes::render_cv_form();
}
}
public static function job_manager_locate_template( $template, $template_name, $template_path ) {
if ( 'job-application.php' === $template_name && 'bullhorn2wp' === get_option( 'job_manager_allowed_application_method' ) ) {
return dirname( __FILE__ ) . '/wp-job-manager-job-application-template.php';
}
return $template;
}
public static function wp_job_manager_menu( $sections ) {
for ( $i = 0; $i < count( $sections['job_submission'][1] ); $i++ ) {
if ( 'job_manager_allowed_application_method' === $sections['job_submission'][1][ $i ]['name'] ) {
$sections['job_submission'][1][ $i ]['options']['bullhorn2wp'] = __( 'Bullhorn', 'bh-staffing-job-listing-and-cv-upload-for-wp' );
}
}
$settings[] = array(
'name' => 'job_manager_bullhorn_client_id',
'std' => '',
'placeholder' => '',
'label' => __( 'Client ID', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'desc' => '',
'type' => 'input',
);
$settings[] = array(
'name' => 'job_manager_bullhorn_client_secret',
'std' => '',
'placeholder' => '',
'label' => __( 'Client Secret', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'desc' => sprintf( __( 'Note: You will have to ask Bullhorn support to add this URL "%s" to your API white list for this to work. (see the plugin install notes for more info)',
'bh-staffing-job-listing-and-cv-upload-for-wp'
), Bullhorn_Settings::get_api_redirect_uri() ),
'type' => 'input',
);
$settings[] = array(
'name' => '',
'std' => '',
'placeholder' => '',
'label' => __( 'Synchronize', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'desc' => '',
'type' => 'bullhorn_sync',
);
add_action( 'wp_job_manager_admin_field_bullhorn_sync', array( __CLASS__, 'form_sync_button_handler' ) );
$settings[] = array(
'name' => 'job_manager_bullhorn_client_corporation',
'std' => '',
'placeholder' => '',
'label' => __( 'Client Corporation', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'desc' => __( 'This field is optional, but will filter the jobs retreived from Bullhorn to only those listed under a specific Client Corporation. This must be the ID of the corporation. Leave blank to sync all job listings.', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'type' => 'input',
);
$settings[] = array(
'name' => 'job_manager_bullhorn_default_form_input',
'std' => 'false',
'placeholder' => '',
'label' => __( 'Default Form Input', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'desc' => '',
'type' => 'select',
'options' => array(
'name_email_phone' => __( 'Name + Email + Phone', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'name_email_phone_address' => __( 'Name + Email + Phone + Address', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
),
);
$settings[] = array(
'name' => 'job_manager_bullhorn_send_email',
'std' => '',
'placeholder' => '',
'label' => __( 'Email address for applications', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'desc' => __( 'This field is optional, but if set, you will get a copy of the application sent to the email provided.', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'type' => 'input',
);
$settings[] = array(
'name' => 'job_manager_bullhorn_run_cron',
'std' => 'false',
'placeholder' => '',
'label' => __( 'Auto-sync', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'desc' => __( 'Fetch Jobs from Bullhorn every hour or using the manual sync button below ( shows once you have connected to Bullhorn ).', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'type' => 'select',
'options' => array(
'true' => __( 'On', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'false' => __( 'Off', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
),
);
$settings[] = array(
'name' => 'job_manager_bullhorn_cron_error_email',
'std' => 'true',
'placeholder' => '',
'label' => __( 'Auto-sync Error Email', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'desc' => __( 'Send an Email to the WP admin email address if the synic errors.', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'type' => 'select',
'options' => array(
'on' => __( 'On', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'off' => __( 'Off', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
),
);
$settings[] = array(
'name' => 'job_manager_bullhorn_cron_is_public',
'std' => 'true',
'placeholder' => '',
'label' => __( 'Filter isPublic', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'desc' => __( 'By Default the isPublic field is hidden in Vacancy by default if no job as syniced try set to this to false. To show the field the steps are : Fields Mapping Vacancy isPublic, uncheck "hidden" .', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'type' => 'select',
'options' => array(
'true' => __( 'On', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'false' => __( 'Off', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
),
);
$settings[] = array(
'name' => 'job_manager_bullhorn_cron_mark_submitted',
'std' => 'true',
'placeholder' => '',
'label' => __( 'Mark Submitted', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'desc' => __( 'Choose if to mark a submission to a job as "Submitted" or as "New Lead".', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'type' => 'select',
'options' => array(
'true' => __( 'Submitted', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'false' => __( 'New Lead', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
),
);
if ( Bullhorn_Settings::authorized() ) {
$settings[] = array(
'name' => '',
'std' => '',
'placeholder' => '',
'label' => __( 'Sync with Bullhorn', 'bh-staffing-job-listing-and-cv-upload-for-wp' ),
'desc' => '',
'type' => 'bullhorn_sync_now_button',
);
add_action( 'wp_job_manager_admin_field_bullhorn_sync_now_button', array(
__CLASS__,
'sync_now_button_handler',
) );
}
//"invisible" field
$settings[] = array(
'name' => '',
'std' => '',
'placeholder' => '',
'label' => '',
'desc' => '',
'type' => 'bullhorn_js',
);
add_action( 'wp_job_manager_admin_field_bullhorn_js', array( __CLASS__, 'form_js_handler' ) );
//"invisible" field
$settings[] = array(
'name' => '',
'std' => '',
'placeholder' => '',
'label' => '',
'desc' => '',
'type' => 'bullhorn_code_authorization',
);
add_action( 'wp_job_manager_admin_field_bullhorn_code_authorization', array( 'Bullhorn_Settings', 'authorize' ) );
$sections['bullhorn'] = array( __( 'Bullhorn', 'bh-staffing-job-listing-and-cv-upload-for-wp' ), $settings );
return $sections;
}
public static function sync_now_button_handler() {
printf( '<a href="%s" class="button">%s</a>',
admin_url( 'edit.php?post_type=job_listing&page=job-manager-settings&sync=bullhorn#settings-bullhorn' ),
__( 'Sync Now', 'bh-staffing-job-listing-and-cv-upload-for-wp' )
);
}
public static function form_sync_button_handler() {
$settings = apply_filters( 'wp_bullhorn_settings', (array) get_option( 'bullhorn_settings' ) );
$state_string = __( 'not ready', 'bh-staffing-job-listing-and-cv-upload-for-wp' );
if ( Bullhorn_Settings::authorized() ) {
$state_string = __( 'Re-connect to Bullhorn', 'bh-staffing-job-listing-and-cv-upload-for-wp' );
} elseif ( Bullhorn_Settings::connected() ) {
$state_string = __( 'Connect to Bullhorn', 'bh-staffing-job-listing-and-cv-upload-for-wp' );
}
$url = add_query_arg(
array(
'client_id' => $settings['client_id'],
'response_type' => 'code',
'redirect_uri' => Bullhorn_Settings::get_api_redirect_uri(),
),
'auth.bullhornstaffing.com/oauth/authorize'
);
printf( '<a class="button" href="https://%s">%s</a>', $url, esc_html( $state_string ) );
}
public static function form_js_handler() {
?>
<script>
jQuery(function(){
var tabsIds = jQuery('.job-manager-settings-wrap div').toArray().map(function(value) { return '#' + value.id } );
if((tabsIds.indexOf(window.location.hash) > -1)) {
jQuery('.nav-tab-wrapper a[href="#settings-job_listings"]').removeClass('nav-tab-active');
jQuery('.settings_panel').css('display', 'none');
jQuery('.nav-tab-wrapper a[href="' + window.location.hash + '"]').addClass('nav-tab-active');
jQuery('div' + window.location.hash).css('display', 'block');
}
});
</script>
<?php
}
}