understrap / understrap-child

The starter child theme for Understrap, the renowned open-source WordPress starter theme.
GNU General Public License v3.0
581 stars 331 forks source link

Remove Customizations #369

Closed axlright closed 1 year ago

axlright commented 1 year ago

Hello friends!

Does anyone know an easy way to turn off the customizations that show up in Appearance > Customize > Theme Layout Settings ( /wp-admin/customize.php )? I really don't want or need my clients changing the Bootstrap version, or anything like that. I'd like to set these customizations in functions.php then turn off these user controllable settings which would break the website if changed.

Thanks!

-Alex

bacoords commented 1 year ago

Yes! The child theme uses the 'thememod' filter to hard-code those values. And it includes a warning in the Customizer that some values are hard-coded. It doesn't disable the settings but they can't really be edited: https://github.com/understrap/understrap-child/blob/main/functions.php#L73

axlright commented 1 year ago

Thanks! Is there a relatively easy way to fully disable / remove those customization settings? I'd feel much more comfortable building websites for clients that don't have those customizations. Showing a warning that they don't work isn't ideal - it actually feels worse to have something that shouldn't be there that then shows a message that it may not work. I get that these customizations work for people making websites for themselves, but it doesn't fly for me for client work.

bacoords commented 1 year ago

You can overwrite any function in the parent theme by declaring it in the child theme. So if you didn't want to register the customizer settings, you could overwrite that function and just leave it empty, something like this (untested):

function understrap_theme_customize_register() {}
axlright commented 1 year ago

Oh wow, okay thanks so much. Really appreciate the speedy replies!

bacoords commented 1 year ago

Let us know if we're OK to close this issue

axlright commented 1 year ago

Yes! Thank you @bacoords the below totally works for me:

function understrap_default_bootstrap_version( $current_mod ) {
return 'bootstrap5';
}
add_filter( 'theme_mod_understrap_bootstrap_version', 'understrap_default_bootstrap_version', 20 );

function understrap_default_navbar_type( $current_mod ) {
return 'offcanvas';
}
add_filter( 'theme_mod_understrap_navbar_type', 'understrap_default_navbar_type', 20 );

function understrap_default_container_type( $current_mod ) {
return 'container';
}
add_filter( 'theme_mod_understrap_container_type', 'understrap_default_container_type', 20 );

function understrap_theme_customize_register() {}