public function update_settings()
{
if (!$this->nonce->is_valid()) {
return false;
}
$custom_post_types = $this->repository->get_custom_post_types();
if (!$custom_post_types || empty($_POST[self::SETTINGS_NAME])) {
return $this->repository->unsupport_all_post_types();
}
$custom_post_types = array_keys($custom_post_types);
$settings = (array) $_POST[self::SETTINGS_NAME];
$custom_post_types = array_combine($custom_post_types, array_map(function ($slug) use($settings) {
if (empty($settings[$slug])) {
return PostTypeRepository::CPT_INACTIVE;
}
return empty($settings["{$slug}|links"]) ? PostTypeRepository::CPT_ACTIVE : PostTypeRepository::CPT_QUERY_BASED;
}, $custom_post_types));
return $this->repository->set_supported_post_types($custom_post_types);
}