How can I define a selection rule to use for Panels variants in code?
You can add Panels selection rules.

However, in your case, have you tried just calling a module function instead in your PHP code for the selection rule?

e.g, call a function defined in a module:

return my_module_selection_rule('foo');


instead of all the raw code there.

That way, it can be updated once in the module codebase.

I use that technique a lot for views php contextual filter handling code.

If so inclined, see 


panels/plugins/task_handlers/panel_context.inc 


for the default selection rules plugin definition. and


ctools_context_handler_edit_criteria


for the default form builder function for the selection rules.