/** * Build a Person object based on data from startup_roles * * @since 1.1 * @param stdClass $person_data data of a confirmed person associated with a company as returned by startup_roles */ public function __construct($person_data) { if (isset($person_data->role)) { $this->role = strtolower(trim(str_replace('_', ' ', $person_data->role))); } if (isset($person_data->tagged)) { if (isset($person_data->tagged->name)) { $this->name = trim($person_data->tagged->name); } if (isset($person_data->tagged->angellist_url)) { $url = esc_url($person_data->tagged->angellist_url, array('http', 'https')); if ($url) { $this->url = $url; } unset($url); } if (isset($person_data->tagged->image)) { if (!class_exists('AngelList_API')) { require_once dirname(dirname(__FILE__)) . '/api.php'; } $url = AngelList_API::filter_static_asset_url($person_data->tagged->image); if ($url && $url !== AngelList_API::DEFAULT_IMAGE) { $image = new stdClass(); $image->url = $url; $image->width = $image->height = 140; $this->image = $image; unset($image); } unset($url); } } }
/** * Display jobs at the company listed in AngelList * * @since 1.2 * @param int $limit show at most N jobs * @return string HTML list of job listings */ private function jobs($limit = 3) { // check for garbage if (!is_int($limit) || $limit < 1) { $limit = 3; } if (!class_exists('AngelList_API')) { require_once dirname(dirname(__FILE__)) . '/api.php'; } $jobs = AngelList_API::get_jobs_by_company($this->id); if (!is_array($jobs) || empty($jobs)) { return ''; } if (count($jobs) > $limit) { $jobs = array_slice($jobs, 0, $limit); } if (!class_exists('AngelList_Job')) { require_once dirname(__FILE__) . '/job.php'; } $jobs_html = ''; foreach ($jobs as $job_data) { $job = new AngelList_Job($job_data); if (isset($job->title)) { $jobs_html .= $job->render($this->schema_org, $this->anchor_extra); } } if ($jobs_html) { return '<div class="angellist-jobs"><span>' . esc_html(sprintf(__('%s is hiring:', 'angellist'), $this->name)) . '</span><ol>' . $jobs_html . '</ol>'; } else { return ''; } }
/** * Get open job listings for a given company * * @since 1.2 * @param int $company_id AngelList company identifier * @return null|stdClass json_decode response as stdClass or null if request or JSON decode failed */ public static function get_jobs_by_company($company_id) { if (!AngelList_API::is_valid_company_id($company_id)) { return; } return AngelList_API::get_json_url('startups/' . $company_id . '/jobs'); }