Skip to content

Commit

Permalink
adds customizer warning to theme layout section
Browse files Browse the repository at this point in the history
  • Loading branch information
bacoords committed Sep 14, 2021
1 parent 20b26a1 commit 4579e82
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
21 changes: 20 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,29 @@ function add_child_theme_textdomain() {
/**
* Overrides the theme_mod to default to Bootstrap 5
*
* @param string $current_mod
* This function uses the `theme_mod_{$name}` hook and
* can be duplicated to override other theme settings.
*
* @param string $current_mod The current value of the theme_mod.
* @return string
*/
function understrap_default_bootstrap_version( $current_mod ) {
return 'bootstrap5';
}
add_filter( 'theme_mod_understrap_bootstrap_version', 'understrap_default_bootstrap_version', 20 );



/**
* Loads javascript for showing customizer warning dialog.
*/
function understrap_child_customize_controls_js() {
wp_enqueue_script(
'understrap_child_customizer',
get_stylesheet_directory_uri() . '/js/customizer-controls.js',
array( 'customize-preview' ),
'20130508',
true
);
}
add_action( 'customize_controls_enqueue_scripts', 'understrap_child_customize_controls_js' );
18 changes: 18 additions & 0 deletions js/customizer-controls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Scripts within the customizer controls window.
*
* Adds a warning to the Theme Layout Settings section.
*/

(function() {
wp.customize.bind( 'ready', function() {
// Only show the navbar type setting when running Bootstrap 5.
wp.customize.section( 'understrap_theme_layout_options').notifications.add( 'example-warning', new wp.customize.Notification(
'example-warning',
{
type: 'warning',
message: 'You are currently using an Understrap child theme, which may override some of these settings.'
}
) );
});
})();

0 comments on commit 4579e82

Please sign in to comment.