Bestway to write php functions
I have seen that every theme use this format
if( !function_exists( 'blogrock__f' )) :
function blogrock__f () {
/// code here
}
endif;
add_action('after_setup_theme', 'blogrock_setup');
I am pretty bored writing if.. endif blocks. I know I can create new classes to avoid this . But can I do this in this way?
if (!function_exists('theme_add_next_page_button')) {
function theme_add_next_page_button(){
// function blocks
}
add_filter( 'mce_buttons', 'theme_add_next_page_button', 1, 2 );
}
Can I remove function conflict by this way? If there are otherways,what are those? And does my later way impact negative on theme performance?
Thanks
Topic function-exists theme-development Wordpress
Category Web