/** * @param $current_linked_posts * * @return mixed */ private function maybe_parse_candidate_linked_posts(array $current_linked_posts = array()) { $linked_post_type_container = $this->linked_posts->get_post_type_container($this->post_type); // filter out any non-truthy values $current_linked_posts = array_filter($current_linked_posts); $has_no_current_linked_posts = empty($current_linked_posts); $submitted_data_contains_candidate_linked_posts = !empty($_POST[$linked_post_type_container]); if ($has_no_current_linked_posts && $submitted_data_contains_candidate_linked_posts) { $candidate_linked_posts = $_POST[$linked_post_type_container]; $linked_post_type_id_field = $this->linked_posts->get_post_type_id_field_index($this->post_type); if (!empty($candidate_linked_posts[$linked_post_type_id_field])) { $candidate_linked_posts = $candidate_linked_posts[$linked_post_type_id_field]; return $candidate_linked_posts; } return $current_linked_posts; } return $current_linked_posts; }