/**
  * job_listing_fields function.
  *
  * @access public
  * @return void
  */
 public function job_listing_fields()
 {
     global $post;
     $current_user = wp_get_current_user();
     $fields = array('_job_location' => array('label' => __('Location', 'wp-job-manager'), 'placeholder' => __('e.g. "London"', 'wp-job-manager'), 'description' => __('Leave this blank if the location is not important.', 'wp-job-manager'), 'priority' => 1), '_application' => array('label' => __('Application Email or URL', 'wp-job-manager'), 'placeholder' => __('URL or email which applicants use to apply', 'wp-job-manager'), 'description' => __('This field is required for the "application" area to appear beneath the listing.', 'wp-job-manager'), 'value' => metadata_exists('post', $post->ID, '_application') ? get_post_meta($post->ID, '_application', true) : $current_user->user_email, 'priority' => 2), '_company_name' => array('label' => __('Company Name', 'wp-job-manager'), 'placeholder' => '', 'priority' => 3), '_company_website' => array('label' => __('Company Website', 'wp-job-manager'), 'placeholder' => '', 'priority' => 4), '_company_tagline' => array('label' => __('Company Tagline', 'wp-job-manager'), 'placeholder' => __('Brief description about the company', 'wp-job-manager'), 'priority' => 5), '_company_twitter' => array('label' => __('Company Twitter', 'wp-job-manager'), 'placeholder' => '@yourcompany', 'priority' => 6), '_company_logo' => array('label' => __('Company Logo', 'wp-job-manager'), 'placeholder' => __('URL to the company logo', 'wp-job-manager'), 'type' => 'file', 'priority' => 7), '_company_video' => array('label' => __('Company Video', 'wp-job-manager'), 'placeholder' => __('URL to the company video', 'wp-job-manager'), 'type' => 'file', 'priority' => 8), '_filled' => array('label' => __('Position Filled', 'wp-job-manager'), 'type' => 'checkbox', 'priority' => 9, 'description' => __('Filled listings will no longer accept applications.', 'wp-job-manager')));
     if ($current_user->has_cap('manage_job_listings')) {
         $fields['_featured'] = array('label' => __('Featured Listing', 'wp-job-manager'), 'type' => 'checkbox', 'description' => __('Featured listings will be sticky during searches, and can be styled differently.', 'wp-job-manager'), 'priority' => 10);
         $fields['_job_expires'] = array('label' => __('Listing Expiry Date', 'wp-job-manager'), 'placeholder' => __('yyyy-mm-dd', 'wp-job-manager'), 'priority' => 11, 'value' => metadata_exists('post', $post->ID, '_job_expires') ? get_post_meta($post->ID, '_job_expires', true) : calculate_job_expiry($post->ID));
     }
     if ($current_user->has_cap('edit_others_job_listings')) {
         $fields['_job_author'] = array('label' => __('Posted by', 'wp-job-manager'), 'type' => 'author', 'priority' => 12);
     }
     $fields = apply_filters('job_manager_job_listing_data_fields', $fields);
     uasort($fields, array($this, 'sort_by_priority'));
     return $fields;
 }
 /**
  * Set expirey date when job status changes
  */
 public function set_expiry($post)
 {
     if ($post->post_type !== 'job_listing') {
         return;
     }
     // See if it is already set
     if (metadata_exists('post', $post->ID, '_job_expires')) {
         $expires = get_post_meta($post->ID, '_job_expires', true);
         if ($expires && strtotime($expires) < current_time('timestamp')) {
             update_post_meta($post->ID, '_job_expires', '');
             $_POST['_job_expires'] = '';
         }
         return;
     }
     // No metadata set so we can generate an expiry date
     // See if the user has set the expiry manually:
     if (!empty($_POST['_job_expires'])) {
         update_post_meta($post->ID, '_job_expires', date('Y-m-d', strtotime(sanitize_text_field($_POST['_job_expires']))));
         // No manual setting? Lets generate a date
     } else {
         $expires = calculate_job_expiry($post->ID);
         update_post_meta($post->ID, '_job_expires', $expires);
         // In case we are saving a post, ensure post data is updated so the field is not overridden
         if (isset($_POST['_job_expires'])) {
             $_POST['_job_expires'] = $expires;
         }
     }
 }