<?php jobify_addAPI(array('key' => 'github_jobs', 'title' => __('GitHub Jobs', 'jobify'), 'logo' => plugins_url('img/github-jobs.jpg', JOBIFY_PLUGIN), 'requirements' => array('geolocation' => __('Supports geolocation if enabled.', 'jobify')), 'getJobs' => function ($args) { $jobs = array(); $results = wp_cache_get('jobs-github-jobs-' . jobify_string($args), 'jobify'); if (false === $results) { $link = 'https://jobs.github.com/positions.json?'; if (!empty($args['keyword'])) { $link .= 'description=' . urlencode($args['keyword']) . '&'; } // Location if (!empty($args['lat']) && !empty($args['lng'])) { $link .= 'lat=' . urlencode($args['lat']) . '&'; $link .= 'long=' . urlencode($args['lng']) . '&'; } elseif (!empty($args['location'])) { $link .= 'location=' . urlencode($args['location']) . '&'; } if (!empty($args['githubjobs_fulltime'])) { $link .= 'full_time=' . urlencode($args['githubjobs_fulltime']); } $results = json_decode(file_get_contents($link)); wp_cache_set('jobs-github-jobs-' . jobify_string($args), $results, 'jobify', 43200); // Half a day } if (count($results) > 0) { foreach ($results as $key => $obj) { $jobs[] = array('portal' => 'github_jobs', 'title' => !empty($obj->title) ? $obj->title : false, 'company' => !empty($obj->company) ? $obj->company : false, 'company_logo' => !empty($obj->company_logo) ? $obj->company_logo : false, 'company_url' => !empty($obj->company_url) ? $obj->company_url : false, 'desc' => !empty($obj->description) ? $obj->description : false, 'app_url' => !empty($obj->url) ? $obj->url : false, 'date' => !empty($obj->created_at) ? $obj->created_at : false, 'location' => !empty($obj->location) ? $obj->location : false, 'custom' => array('how_to_apply' => !empty($obj->how_to_apply) ? $obj->how_to_apply : false), 'type' => !empty($obj->type) ? $obj->type : false); } } return $jobs; }, 'options' => array(array('title' => __('Full-time', 'jobify'), 'name' => 'githubjobs_fulltime', 'desc' => __('If you want to limit results to full time positions.', 'jobify'), 'type' => 'checkbox', 'options' => array('yes' => __('Yes', 'jobify')), 'default' => ''))));
$params['radius'] = !empty($args['indeed_radius']) ? $args['indeed_radius'] : '25'; $params['sort'] = !empty($args['indeed_sort']) ? $args['indeed_sort'] : 'relevance'; $params['limit'] = !empty($args['indeed_limit']) ? $args['indeed_limit'] : 10; $params['fromage'] = !empty($args['indeed_fromage']) ? $args['indeed_fromage'] : ''; // Location if (!empty($args['lat']) && !empty($args['lng'])) { $location = jobify_get_location($args['lat'] . ',' . $args['lng']); if (count($location) > 0) { $params['l'] = $location[3]; } } elseif (!empty($_POST['params']['location'])) { $params['l'] = $args['location']; } $results = $client->search($params); if (!empty($results['error'])) { // API error $jobs[] = array('error' => __('<b>Indeed API Error:</b> ', 'jobify') . $results['error']); } else { // Save results to cache wp_cache_set('jobs-indeed-' . jobify_string($args), $results, 'jobify', 43200); // Half a day if (count($results['results']) > 0) { foreach ($results['results'] as $key => $ary) { // Add job to array $jobs[] = array('portal' => 'indeed', 'title' => !empty($ary['jobtitle']) ? $ary['jobtitle'] : false, 'company' => !empty($ary['company']) ? $ary['company'] : false, 'company_url' => !empty($obj->company_url) ? $obj->company_url : false, 'city' => !empty($ary['city']) ? $ary['city'] : false, 'state' => !empty($ary['state']) ? $ary['state'] : false, 'country' => !empty($ary['country']) ? $ary['country'] : false, 'desc' => !empty($ary['snippet']) ? $ary['snippet'] : false, 'app_url' => !empty($ary['url']) ? $ary['url'] : false, 'lat' => !empty($ary['latitude']) ? $ary['latitude'] : false, 'long' => !empty($ary['longitude']) ? $ary['longitude'] : false, 'date' => !empty($ary['date']) ? $ary['date'] : false, 'location' => !empty($ary['formattedLocationFull']) ? $ary['formattedLocationFull'] : false, 'custom' => array('onmousedown' => !empty($ary['onmousedown']) ? $ary['onmousedown'] : false, 'source' => !empty($ary['source']) ? $ary['source'] : false, 'sponsored' => !empty($ary['sponsored']) ? $ary['sponsored'] : false, 'expired' => !empty($ary['expired']) ? $ary['expired'] : false, 'indeedApply' => !empty($ary['indeedApply']) ? $ary['indeedApply'] : false, 'formattedRelativeTime' => !empty($ary['formattedRelativeTime']) ? $ary['formattedRelativeTime'] : false, 'noUniqueUrl' => !empty($ary['noUniqueUrl']) ? $ary['noUniqueUrl'] : false)); } } } } return $jobs; }, 'options' => array(array('group' => array(array('title' => __('Radius', 'jobify'), 'name' => 'indeed_radius', 'desc' => __('Distance from search location.', 'jobify'), 'default' => '25', 'type' => 'number'), array('title' => __('Number of Days', 'jobify'), 'name' => 'indeed_fromage', 'desc' => __('Number of days back to search.', 'jobify'), 'default' => '30', 'type' => 'number'))), array('title' => __('Limit', 'jobify'), 'name' => 'indeed_limit', 'desc' => __('Max number of results from Indeed (Max. 25).', 'jobify'), 'default' => '10', 'type' => 'number'))));
// Query the Careerjet PHP API $careerjet = new Careerjet_API($careerjet_locale); $params = array('page' => 1, 'affid' => $careerjet_api_key); $params['keywords'] = !empty($args['keyword']) ? $args['keyword'] : ''; // Location if (!empty($args['lat']) && !empty($args['lng'])) { $location = jobify_get_location($args['lat'] . ',' . $args['lng']); if (count($location) > 0) { $params['location'] = $location[3]; } } elseif (!empty($args['location'])) { $params['location'] = $args['location']; } $results = $careerjet->search($params); if (!$results->type == 'JOBS') { // API error $jobs[] = array('error' => __('<b>Careerjet API Error:</b> ', 'jobify') . ' Invalid result type: ' . $results->type); } else { // Save results to cache wp_cache_set('jobs-careerjet-' . jobify_string($args), $results, 'jobify', 43200); // Half a day if (!empty($results->jobs) && count($results->jobs) > 0) { foreach ($results->jobs as $key => $obj) { // Add job to array $jobs[] = array('portal' => 'careerjet', 'title' => !empty($obj->title) ? $obj->title : false, 'company' => !empty($obj->company) ? $obj->company : false, 'desc' => !empty($obj->description) ? $obj->description : false, 'app_url' => !empty($obj->url) ? $obj->url : false, 'date' => !empty($obj->date) ? $obj->date : false, 'location' => !empty($obj->locations) ? $obj->locations : false, 'custom' => array()); } } } } return $jobs; }, 'options' => array(array('title' => __('Careerjet Locale', 'jobify'), 'name' => 'careerjet_locale', 'desc' => __('Select your Careerjet locale.', 'jobify'), 'default' => 'en_US', 'type' => 'select', 'options' => array('cs_CZ' => __('Czech Republic', 'jobify'), 'da_DK' => __('Denmark', 'jobify'), 'de_AT' => __('Austria', 'jobify'), 'de_CH' => __('Switzerland (DE)', 'jobify'), 'de_DE' => __('Germany', 'jobify'), 'en_AE' => __('United Arab Emirates', 'jobify'), 'en_AU' => __('Australia', 'jobify'), 'en_CA' => __('Canada (EN)', 'jobify'), 'en_CN' => __('China (EN)', 'jobify'), 'en_HK' => __('Hong Kong', 'jobify'), 'en_IE' => __('Ireland', 'jobify'), 'en_IN' => __('India', 'jobify'), 'en_MY' => __('Malaysia', 'jobify'), 'en_NZ' => __('New Zealand', 'jobify'), 'en_OM' => __('Oman', 'jobify'), 'en_PH' => __('Philippines', 'jobify'), 'en_PK' => __('Pakistan', 'jobify'), 'en_QA' => __('Qatar', 'jobify'), 'en_SG' => __('Singapore', 'jobify'), 'en_GB' => __('United Kingdom', 'jobify'), 'en_US' => __('United States', 'jobify'), 'en_ZA' => __('South Africa', 'jobify'), 'en_TW' => __('Taiwan', 'jobify'), 'en_VN' => __('Vietnam (EN)', 'jobify'), 'es_AR' => __('Argentina', 'jobify'), 'es_BO' => __('Bolivia', 'jobify'), 'es_CL' => __('Chile', 'jobify'), 'es_CR' => __('Costa Rica', 'jobify'), 'es_DO' => __('Dominican Republic', 'jobify'), 'es_EC' => __('Ecuador', 'jobify'), 'es_ES' => __('Spain', 'jobify'), 'es_GT' => __('Guatemala', 'jobify'), 'es_MX' => __('Mexico', 'jobify'), 'es_PA' => __('Panama', 'jobify'), 'es_PE' => __('Peru', 'jobify'), 'es_PR' => __('Puerto Rico', 'jobify'), 'es_PY' => __('Paraguay', 'jobify'), 'es_UY' => __('Uruguay', 'jobify'), 'es_VE' => __('Venezuela', 'jobify'), 'fi_FI' => __('Finland', 'jobify'), 'fr_CA' => __('Canada (FR)', 'jobify'), 'fr_BE' => __('Belgium (FR)', 'jobify'), 'fr_CH' => __('Switzerland (FR)', 'jobify'), 'fr_FR' => __('France', 'jobify'), 'fr_LU' => __('Luxembourg', 'jobify'), 'fr_MA' => __('Morocco', 'jobify'), 'hu_HU' => __('Hungary', 'jobify'), 'it_IT' => __('Italy', 'jobify'), 'ja_JP' => __('Japan', 'jobify'), 'ko_KR' => __('Korea', 'jobify'), 'nl_BE' => __('Belgium (NL)', 'jobify'), 'nl_NL' => __('Netherlands', 'jobify'), 'no_NO' => __('Norway', 'jobify'), 'pl_PL' => __('Poland', 'jobify'), 'pt_PT' => __('Portugal', 'jobify'), 'pt_BR' => __('Brazil', 'jobify'), 'ru_RU' => __('Russia', 'jobify'), 'ru_UA' => __('Ukraine (RU)', 'jobify'), 'sv_SE' => __('Sweden', 'jobify'), 'sk_SK' => __('Slovakia', 'jobify'), 'tr_TR' => __('Turkey', 'jobify'), 'uk_UA' => __('Ukraine (UK)', 'jobify'), 'vi_VN' => __('Vietnam (VI)', 'jobify'), 'zh_CN' => __('China (ZH)', 'jobify'))))));
} elseif (!empty($args['location'])) { $link .= 'LocationName=' . urlencode($args['location']) . '&'; } if (!empty($options['usajobs_page'])) { $link .= 'Page=' . urlencode($options['usajobs_page']) . '&'; } if (!empty($options['usajobs_limit'])) { $link .= 'ResultsPerPage=' . urlencode($options['usajobs_limit']) . '&'; } // Get cURL resource $curl = curl_init(); // Set some options - we are passing in a useragent too here curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $link, CURLOPT_HTTPHEADER => array('Host: data.usajobs.gov', 'User-Agent: ' . $settings['usajobs_email'], 'Authorization-Key: ' . $settings['usajobs_api_key']))); // Send the request & save response to $resp $response = curl_exec($curl); // Close request to clear up some resources curl_close($curl); $results = json_decode($response); wp_cache_set('jobs-usajobs-' . jobify_string($options), $results, 'jobify', 43200); // Half a day $search_results = !empty($results->SearchResult->SearchResultItems) ? $results->SearchResult->SearchResultItems : false; if ($search_results) { foreach ($search_results as $key => $obj) { //print_r($obj); $jobs[] = array('portal' => 'usajobs', 'title' => !empty($obj->MatchedObjectDescriptor->PositionTitle) ? $obj->MatchedObjectDescriptor->PositionTitle : false, 'company' => !empty($obj->MatchedObjectDescriptor->OrganizationName) ? $obj->MatchedObjectDescriptor->OrganizationName : false, 'city' => !empty($obj->MatchedObjectDescriptor->PositionLocation[0]->CityName) ? $obj->MatchedObjectDescriptor->PositionLocation[0]->CityName : false, 'state' => !empty($obj->MatchedObjectDescriptor->PositionLocation[0]->CountrySubDivisionCode) ? $obj->MatchedObjectDescriptor->PositionLocation[0]->CountrySubDivisionCode : false, 'country' => !empty($obj->MatchedObjectDescriptor->PositionLocation[0]->CountryCode) ? $obj->MatchedObjectDescriptor->PositionLocation[0]->CountryCode : false, 'desc' => !empty($obj->MatchedObjectDescriptor->PositionFormattedDescription[0]->Content) ? $obj->MatchedObjectDescriptor->PositionFormattedDescription[0]->Content : false, 'app_url' => !empty($obj->MatchedObjectDescriptor->PositionURI) ? $obj->MatchedObjectDescriptor->PositionURI : false, 'location' => !empty($obj->MatchedObjectDescriptor->PositionLocation[0]->LocationName) ? $obj->MatchedObjectDescriptor->PositionLocation[0]->LocationName : false); } } } return $jobs; }, 'options' => array(array('title' => __('Exclude Keywords', 'jobify'), 'name' => 'usajobs_exclude_keyword', 'desc' => __('Search terms to exclude from the search (comma seperated).', 'jobify'), 'default' => ''), array('title' => __('Limit', 'jobify'), 'name' => 'usajobs_limit', 'desc' => __('Max number of results from USAJOBS (Max. 500).', 'jobify'), 'default' => '10', 'type' => 'number')))); }