/** * save_job_listing_data function. * * @access public * @param mixed $post_id * @param mixed $post * @return void */ public function save_job_listing_data($post_id, $post) { global $wpdb; foreach ($this->job_listing_fields() as $key => $field) { // Expirey date if ('_job_expires' == $key) { if (!empty($_POST[$key])) { update_post_meta($post_id, $key, date('Y-m-d', strtotime(sanitize_text_field($_POST[$key])))); } else { update_post_meta($post_id, $key, ''); } continue; } elseif ('_job_location' == $key) { if (update_post_meta($post_id, $key, sanitize_text_field($_POST[$key]))) { do_action('job_manager_job_location_edited', $post_id, sanitize_text_field($_POST[$key])); } elseif (apply_filters('job_manager_geolocation_enabled', true) && !WP_Job_Manager_Geocode::has_location_data($post_id)) { WP_Job_Manager_Geocode::generate_location_data($post_id, sanitize_text_field($_POST[$key])); } } else { if (isset($_POST[$key])) { if (is_array($_POST[$key])) { update_post_meta($post_id, $key, array_map('sanitize_text_field', $_POST[$key])); } else { update_post_meta($post_id, $key, sanitize_text_field($_POST[$key])); } } elseif (!empty($field['type']) && $field['type'] == 'checkbox') { update_post_meta($post_id, $key, 0); } } } }
/** * Save Resume Meta * * @param mixed $post_id * @param mixed $post */ public function save_resume_data($post_id, $post) { global $wpdb; // These need to exist add_post_meta($post_id, '_featured', 0, true); foreach ($this->resume_fields() as $key => $field) { // Expirey date if ('_resume_expires' === $key) { if (!empty($_POST[$key])) { update_post_meta($post_id, $key, date('Y-m-d', strtotime(sanitize_text_field($_POST[$key])))); } else { update_post_meta($post_id, $key, ''); } } elseif ('_candidate_location' === $key) { if (update_post_meta($post_id, $key, sanitize_text_field($_POST[$key]))) { do_action('resume_manager_candidate_location_edited', $post_id, sanitize_text_field($_POST[$key])); } elseif (apply_filters('resume_manager_geolocation_enabled', true) && !WP_Job_Manager_Geocode::has_location_data($post_id)) { WP_Job_Manager_Geocode::generate_location_data($post_id, sanitize_text_field($_POST[$key])); } continue; } elseif ('_resume_author' === $key) { $wpdb->update($wpdb->posts, array('post_author' => $_POST[$key] > 0 ? absint($_POST[$key]) : 0), array('ID' => $post_id)); } else { $type = !empty($field['type']) ? $field['type'] : ''; switch ($type) { case 'textarea': update_post_meta($post_id, $key, wp_kses_post(stripslashes($_POST[$key]))); break; case 'checkbox': if (isset($_POST[$key])) { update_post_meta($post_id, $key, 1); } else { update_post_meta($post_id, $key, 0); } break; default: if (is_array($_POST[$key])) { update_post_meta($post_id, $key, array_filter(array_map('sanitize_text_field', $_POST[$key]))); } else { update_post_meta($post_id, $key, sanitize_text_field($_POST[$key])); } break; } } } $save_repeated_fields = array('_links' => $this->resume_links_fields(), '_candidate_education' => $this->resume_education_fields(), '_candidate_experience' => $this->resume_experience_fields()); foreach ($save_repeated_fields as $meta_key => $fields) { $this->save_repeated_row($post_id, $meta_key, $fields); } }
/** * save_job_listing_data function. * * @access public * @param mixed $post_id * @param mixed $post * @return void */ public function save_job_listing_data($post_id, $post) { global $wpdb; // These need to exist add_post_meta($post_id, '_filled', 0, true); add_post_meta($post_id, '_featured', 0, true); // Save fields foreach ($this->job_listing_fields() as $key => $field) { // Expirey date if ('_job_expires' === $key) { if (!empty($_POST[$key])) { update_post_meta($post_id, $key, date('Y-m-d', strtotime(sanitize_text_field($_POST[$key])))); } else { update_post_meta($post_id, $key, ''); } } elseif ('_job_location' === $key) { if (update_post_meta($post_id, $key, sanitize_text_field($_POST[$key]))) { // Location data will be updated by hooked in methods } elseif (apply_filters('job_manager_geolocation_enabled', true) && !WP_Job_Manager_Geocode::has_location_data($post_id)) { WP_Job_Manager_Geocode::generate_location_data($post_id, sanitize_text_field($_POST[$key])); } } elseif ('_job_author' === $key) { $wpdb->update($wpdb->posts, array('post_author' => $_POST[$key] > 0 ? absint($_POST[$key]) : 0), array('ID' => $post_id)); } elseif ('_application' === $key) { update_post_meta($post_id, $key, sanitize_text_field(urldecode($_POST[$key]))); } else { $type = !empty($field['type']) ? $field['type'] : ''; switch ($type) { case 'textarea': update_post_meta($post_id, $key, wp_kses_post(stripslashes($_POST[$key]))); break; case 'checkbox': if (isset($_POST[$key])) { update_post_meta($post_id, $key, 1); } else { update_post_meta($post_id, $key, 0); } break; default: if (!isset($_POST[$key])) { continue; } elseif (is_array($_POST[$key])) { update_post_meta($post_id, $key, array_filter(array_map('sanitize_text_field', $_POST[$key]))); } else { update_post_meta($post_id, $key, sanitize_text_field($_POST[$key])); } break; } } } }
/** * After importing via WP ALL Import, add default meta data * @param int $post_id */ public function pmxi_saved_post($post_id) { if ('job_listing' === get_post_type($post_id)) { $this->maybe_add_default_meta_data($post_id); if (!WP_Job_Manager_Geocode::has_location_data($post_id) && ($location = get_post_meta($post_id, '_job_location', true))) { WP_Job_Manager_Geocode::generate_location_data($post_id, $location); } } }
/** * Save Resume Meta * * @param mixed $post_id * @param mixed $post */ public function save_resume_data($post_id, $post) { global $wpdb; // These need to exist add_post_meta($post_id, '_featured', 0, true); foreach ($this->resume_fields() as $key => $field) { // Expirey date if ('_resume_expires' === $key) { if (!empty($_POST[$key])) { update_post_meta($post_id, $key, date('Y-m-d', strtotime(sanitize_text_field($_POST[$key])))); } else { update_post_meta($post_id, $key, ''); } } elseif ('_candidate_location' === $key) { if (update_post_meta($post_id, $key, sanitize_text_field($_POST[$key]))) { do_action('resume_manager_candidate_location_edited', $post_id, sanitize_text_field($_POST[$key])); } elseif (apply_filters('resume_manager_geolocation_enabled', true) && !WP_Job_Manager_Geocode::has_location_data($post_id)) { WP_Job_Manager_Geocode::generate_location_data($post_id, sanitize_text_field($_POST[$key])); } continue; } elseif ('_resume_author' === $key) { $wpdb->update($wpdb->posts, array('post_author' => $_POST[$key] > 0 ? absint($_POST[$key]) : 0), array('ID' => $post_id)); } else { $type = !empty($field['type']) ? $field['type'] : ''; switch ($type) { case 'textarea': update_post_meta($post_id, $key, wp_kses_post(stripslashes($_POST[$key]))); break; case 'checkbox': if (isset($_POST[$key])) { update_post_meta($post_id, $key, 1); } else { update_post_meta($post_id, $key, 0); } break; default: if (is_array($_POST[$key])) { update_post_meta($post_id, $key, array_filter(array_map('sanitize_text_field', $_POST[$key]))); } else { update_post_meta($post_id, $key, sanitize_text_field($_POST[$key])); } break; } } } // Education $candidate_education = array(); $locations = isset($_POST['resume_education_location']) ? $_POST['resume_education_location'] : array(); $qualifications = isset($_POST['resume_education_qualification']) ? $_POST['resume_education_qualification'] : array(); $dates = isset($_POST['resume_education_date']) ? $_POST['resume_education_date'] : array(); $notes = isset($_POST['resume_education_notes']) ? $_POST['resume_education_notes'] : array(); foreach ($locations as $index => $location) { if (!empty($location) && !empty($qualifications[$index]) && !empty($dates[$index])) { $candidate_education[] = array('location' => sanitize_text_field(stripslashes($location)), 'qualification' => sanitize_text_field(stripslashes($qualifications[$index])), 'date' => sanitize_text_field(stripslashes($dates[$index])), 'notes' => wp_kses_post(stripslashes($notes[$index]))); } } update_post_meta($post_id, '_candidate_education', $candidate_education); // Education $candidate_experience = array(); $employers = isset($_POST['resume_experience_employer']) ? $_POST['resume_experience_employer'] : array(); $job_titles = isset($_POST['resume_experience_job_title']) ? $_POST['resume_experience_job_title'] : array(); $dates = isset($_POST['resume_experience_date']) ? $_POST['resume_experience_date'] : array(); $notes = isset($_POST['resume_experience_notes']) ? $_POST['resume_experience_notes'] : array(); foreach ($employers as $index => $employer) { if (!empty($employer) && !empty($job_titles[$index]) && !empty($dates[$index])) { $candidate_experience[] = array('employer' => sanitize_text_field(stripslashes($employer)), 'job_title' => sanitize_text_field(stripslashes($job_titles[$index])), 'date' => sanitize_text_field(stripslashes($dates[$index])), 'notes' => wp_kses_post(stripslashes($notes[$index]))); } } update_post_meta($post_id, '_candidate_experience', $candidate_experience); // URLS $links = array(); $resume_url_names = isset($_POST['resume_url_name']) ? $_POST['resume_url_name'] : array(); $resume_urls = isset($_POST['resume_url']) ? $_POST['resume_url'] : array(); foreach ($resume_url_names as $index => $name) { if (!empty($name) && !empty($resume_urls[$index])) { $links[] = array('name' => sanitize_text_field(stripslashes($name)), 'url' => sanitize_text_field(stripslashes($resume_urls[$index]))); } } update_post_meta($post_id, '_links', $links); }