How to change a specific character in a theme option value – replace a space with a plus sign

Wouldn’t a better solution be to build your own list of available fonts, and then let the user select which font to use? That way, your validation is much easier, and also, you have more control over how you use/implement the specific setting.

In any case, you should be able to do what you want, within your sanitization callback, where you will (presumably) be ensuring that the input string is sanitized and validated (i.e. that the string actually corresponds to a Google web font name).

Once you have “Valid Name” as the setting value, it is easy enough to do a str_replace() to replace ” ” with “+”.

I would use two settings: $themename_options['google-webfont-css'] to hold the Font Family name (for CSS), and $themename_options['google-webfont-link'] to hold the link parameter.

So:

$valid_input['google-webfont-css'] = // validated and sanitized $input['google-webfont-css'];
$valid_input['google-webfont-link'] = str_replace( ' ', '+', $valid_input['google-webfont-css'];

return $valid_input;

(This is inside your validation callback function.)