Review how the variable scope works..
Let’s not add yet another global variable, instead we can e.g. fetch the option values within the filter’s callback:
function wpse251261_custom_body_classes( $classes ) {
// Get option values
$rounded_corner_radio = of_get_option( 'rounded_corner_radio' );
$gradient_radio = of_get_option( 'gradient_radio' );
// Assign new body classes
$classes[] = esc_attr( $rounded_corner_radio );
$classes[] = esc_attr( $gradient_radio );
return $classes;
}
add_filter( 'body_class','wpse251261_custom_body_classes' );
Note that we escaped it with esc_attr()
, because the body_class
filter is applied after such escaping in get_body_class()
.