Inpsyde\MultilingualPress\Module\CustomPostTypeSupport\PostTypeSupportSettingsUpdater::update_settings PHP Method

update_settings() public method

Updates the post type support settings.
Since: 3.0.0
public update_settings ( ) : boolean
return boolean Whether or not the settings were updated successfully.
    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);
    }
PostTypeSupportSettingsUpdater