I noticed something odd in this course. Kezz (the instructor) adds extra sidebars through a custom_functions.php but she does not wrap it in a function or add that function with add_action as it is shown in the WP Codes here:
https://codex.wordpress.org/Function_Reference/register_sidebar
Codex Example:
add_action( 'widgets_init', 'theme_slug_widgets_init' );
function theme_slug_widgets_init() {
register_sidebar( array(
'name' => __( 'Main Sidebar', 'theme-slug' ),
'id' => 'sidebar-1',
'description' => __( 'Widgets in this area will be shown on all posts and pages.', 'theme-slug' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
) );
}`
Kezz’s example is basically just:
register_sidebar( array(
'name' => __( 'Main Sidebar', 'theme-slug' ),
'id' => 'sidebar-1',
'description' => __( 'Widgets in this area will be shown on all posts and pages.', 'theme-slug' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
) );
And yet the code works. I don’t know why it works, but I know it’s not best practices. Can you explain why she did it this way when it can lead to unexpected results? Is it an oversight or am I wrong? I don’t think I’m wrong because I’ve asked around about it.