Skip to content

Instantly share code, notes, and snippets.

@dillansimmons
Created October 5, 2017 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dillansimmons/10262b1e0f0f7ccf9a6e91bc32a31e23 to your computer and use it in GitHub Desktop.
Save dillansimmons/10262b1e0f0f7ccf9a6e91bc32a31e23 to your computer and use it in GitHub Desktop.
Worpdress Shortcode for showing / filtering Jobvite listings. Uses Jobvite v2 api.
<?php
// if you want to function for location later on you can use the $loc var and uncomment the if (if arr_key) code below
function showJobvite(){
/* Jobvite url to start with: Update your Job api key and secret, we start by filtering open and externally facing jobs */
$url = "https://api.jobvite.com/api/v2/job?api=company_jobfeedapi_key&sc=secretKey&jobStatus=Open&availableTo=External&callback=?";
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);
// Will dump json :3
$json = json_decode($result, true);
foreach ($json["requisitions"] as $innerArray) {
// drop down into the jobs array
if (is_array($innerArray)){
// if the job is with Company X (update with your company)
if (array_key_exists("company", $innerArray) && "Company X" == $innerArray["company"]) {
// // need to add $loc as variable in the function if you want to use this code
//if (array_key_exists("location", $innerArray) && $loc == $innerArray["location"]) {
// Scan through job object and grab variables we use
foreach ($innerArray as $key => $value) {
if ($key == 'title'){
$title = $value;
}
if ($key == 'eId'){
$dLink = $value;
}
if ($key == 'location'){
$loc2 = $value;
}
}
// this is what is displayed for each job posting
echo '<div class="jobvite"><a target="_blank" href="http://jobs.jobvite.com/projectlineservices/job/'.$dLink.'">'.$title.'</a><span> / '.$loc2.'</span></div>';
//}
}
}else{
echo '<div class="jobvite"><p>no jobs currently</p></div>';
}
}
}
add_shortcode('jobvite', 'showJobvite');
/*
add the shortcode with [jobvite]
or <?php echo do_shortcode( '[jobvite]' ); ?>
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment