Commit b2a9170e authored by Michael Iseard's avatar Michael Iseard
Browse files

Add header/footer scripts option

parent 4fbdb25a
......@@ -158,7 +158,21 @@ add_action( 'carbon_fields_register_fields', function () {
->set_required(),
Field::make( 'text', 'cta_link', __( 'CTA Link', 'kudos-website' ) )
->set_required(),
] );
] )
// Scripts tab
->add_tab( 'Scripts',
[
Field::make( 'complex', 'header_scripts', __( 'Header scripts', 'kudos-website' ) )
->add_fields([
Field::make('text', 'script_content', __('Script'))
]),
Field::make( 'complex', 'footer_scripts', __( 'Footer scripts', 'kudos-website' ) )
->add_fields([
Field::make('text', 'script_content', __('Script'))
])
] );
});
......
......@@ -151,3 +151,25 @@ add_filter( 'query_vars',
return $vars;
} );
/**
* Add custom header scripts specified in "Site Options"
*/
add_action('wp_head', function () {
$scripts = carbon_get_theme_option('header_scripts');
foreach ($scripts as $script) {
echo $script['script_content'];
}
return null;
});
/**
* Add custom footer scripts specified in "Site Options"
*/
add_action('wp_footer', function () {
$scripts = carbon_get_theme_option('footer_scripts');
foreach ($scripts as $script) {
echo $script['script_content'];
}
return null;
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment