Enabling Additional CSS / custom-css

Lol, coming back to my own post 3 years later looking for answers.

Deactivating plugins did nothing, but ended up finding WP_Customize_Code_Editor_Control which has options for code_type.

So here is a manual method for adding a proper CSS editor to a theme. This probably only useful for updating older themes that were already installed.

add_action( 'customize_register', function($wp_customize) {

    $wp_customize->add_setting( 'custom_css', array(
    ) );

    $wp_customize->add_control( new WP_Customize_Code_Editor_Control( $wp_customize,'custom_css', array(
      'label' => __( 'Custom CSS' ),
      'code_type' => 'css',
      'section' => 'custom_css',
      'settings'  => 'custom_css',
    ) ));

    $wp_customize->add_section( 'custom_css', array(
      'title' => __( 'Custom CSS' ),
      'description' => __( 'Add custom CSS here' ),
      'panel' => '', // Not typically needed.
      'priority' => 160,
      'capability' => 'edit_theme_options',
      'theme_supports' => '', // Rarely needed.
    ) );

    $custom_css = get_theme_mod( 'custom_css', '' );
    wp_register_style( 'custom-css', false );
    wp_enqueue_style( 'custom-css' );
    wp_add_inline_style( 'custom-css', $custom_css );

});