Optimization for creating child theme

Hi there !

Is it possible for you to optimize function.php for child theme by adding condition if ( ! function_exists ( 'moesia_function' ) ) {}
to all your functions ?

In mine i created a new sidebar but moesia_widgets_init function is not conditional so, i cant override it in the child theme.

finally i succeed to override the original function like this : `/**

  • deleting parent moesia_widgets_init function
    */

function child_remove_moesia_widgets_init() {
remove_action( ‘widgets_init’, ‘moesia_widgets_init’ );
}
add_action( ‘wp_loaded’, ‘child_remove_moesia_widgets_init’ );

/**

  • moesia_widgets_init custom function
    */

function child_moesia_widgets_init() {
register_sidebar( array(
‘name’ => __( ‘Sidebar’, ‘moesia’ ),
‘id’ => ‘sidebar-1’,
‘description’ => ‘’,
‘before_widget’ => ‘<aside id="%1$s" class=“widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h2 class=“widget-title”>’,
‘after_title’ => ‘</h2>’,
) );
register_sidebar( array(
‘name’ => __( ‘Footer A’, ‘moesia’ ),
‘id’ => ‘sidebar-3’,
‘before_widget’ => ‘<aside id="%1$s" class=“widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h3 class=“widget-title”>’,
‘after_title’ => ‘</h3>’,
) );
register_sidebar( array(
‘name’ => __( ‘Footer B’, ‘moesia’ ),
‘id’ => ‘sidebar-4’,
‘before_widget’ => ‘<aside id="%1$s" class=“widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h3 class=“widget-title”>’,
‘after_title’ => ‘</h3>’,
) );
register_sidebar( array(
‘name’ => __( ‘Footer C’, ‘moesia’ ),
‘id’ => ‘sidebar-5’,
‘before_widget’ => ‘<aside id="%1$s" class=“widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h3 class=“widget-title”>’,
‘after_title’ => ‘</h3>’,
) );
register_sidebar( array(
‘name’ => __( ‘Footer D’, ‘moesia’ ),
‘id’ => ‘sidebar-6’,
‘before_widget’ => ‘<aside id="%1$s" class=“widget %2$s”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h3 class=“widget-title”>’,
‘after_title’ => ‘</h3>’,
) );

//Register the front page widgets
if ( function_exists('siteorigin_panels_activate') ) {
	register_widget( 'Moesia_Services' );
	register_widget( 'Moesia_Employees' );
	register_widget( 'Moesia_Fp_Social_Profile' );
	register_widget( 'Moesia_Blockquote' );
	register_widget( 'Moesia_Skills' );
	register_widget( 'Moesia_Facts' );
	register_widget( 'Moesia_Testimonials' );
	register_widget( 'Moesia_Clients' );
	register_widget( 'Moesia_Projects' );
	register_widget( 'Moesia_Action' );
	register_widget( 'Moesia_Latest_News' );
}

//Register the sidebar widgets
register_widget( 'Moesia_Recent_Comments' );
register_widget( 'Moesia_Recent_Posts' );
register_widget( 'Moesia_Social_Profile' );
register_widget( 'Moesia_Video_Widget' );
register_widget( 'Moesia_Contact_Info' );	

}
add_action( ‘widgets_init’, ‘child_moesia_widgets_init’ );`

but i think it will be more user friendly to add condition to your own

Hi,

Great! I’m glad it’s resolved! If you need help with anything else, please open a new topic.

Have a nice day!

Best Regards,
Csaba