As an addition to the other answer by @m0r7if3r:
You can use current_theme_supports()
to only load the parent themes stylesheet if there's theme support.
function add_supported_stylesheets()
{
if ( current_theme_supports( 'parent-stylesheet' ) )
wp_enqueue_style( 'main', get_stylesheet_directory_uri().'/style.css', array(), filemtime( get_stylesheet_directory().'/style.css' );
}
// In your parent themes bootstrap in the functions.php file
// Add the theme support:
add_theme_support( 'parent-stylesheet' );
// Then add the stylesheet:
add_action( 'after_setup_theme', 'add_supported_stylesheets', 20 );
Note, that this function adds filemtime
on the version-nr. to prevent browser caching if the files contents were changed.
This will allow your users to disable the stylesheet in the child themes bootstrap with a simple single fn call:
remove_theme_support( 'parent-stylesheet' );
// ...or...
add_theme_support( 'parent-stylesheet' );