So what I did was:
First make a function that would be returning these slugs based on custom post type name, and if the provided custom slug didn’t meet the requirements it falls back to a default value:
function my_get_custom_slugs($cpt){
$all_the_slugs = [
"ugly_machine_name_1" => "default-pretty-name-1",
"ugly_machine_name_2" => "default-pretty-name-2",
//...etc
];
$r_val = array();
$options = get_option('my_option_name');
foreach ($all_the_slugs as $key => $val) {
if (strlen(trim($options[$key . "_slug"])) > 2){
$r_val[$key] = $options[$key . "_slug"];
} else {
$r_val[$key] = $val;
}
}
return $r_val[$cpt];
}
Of course I now have to rename the id’s of the custom options fields to match the custom-post-type-name + “_slug”.
And now I can use it in my register post type declarations:
register_post_type( 'this_cpt',
array(
'labels' => array(
'name' => __( 'This CPT Name', 'my-child-theme' ),
'singular_name' => __( 'This CPT Name', 'my-child-theme' )
),
'public' => true,
'has_archive' => my_get_custom_slugs('this_cpt'),
'rewrite' => array( 'slug' => my_get_custom_slugs('this_cpt'), 'with_front' => false ),
'supports' => array( 'title', 'editor', 'custom-fields' )
)
);
And also anywhere in my template files, if I need to.