Trying to modify Parent Menus function on child theme, the original function is:
function original_theme_menus() {
$menus = array(
'top' => __( 'Top Menu', 'theme-domain' ),
'primary' => __( 'Primary Menu', 'theme-domain' ),
'secondary' => __( 'Secondary Menu', 'theme-domain' ),
);
return apply_filters( 'original_theme_menus', $menus );
}
I'm doing:
function remove_original_theme_menus() {
remove_action('original_theme_menus');
}
add_action('init', 'remove_original_theme_menus');
function original_theme_menus() {
$menus = array(
'top' => __( 'Top Menu', 'theme-domain' ),
'primary' => __( 'Primary Menu', 'theme-domain' ),
'secondary' => __( 'Secondary Menu', 'theme-domain' ),
'footer' => __( 'Footer Menu', 'theme-domain' )
);
return apply_filters( 'original_theme_menus', $menus );
}
How should I unregister the original function?
I get a Fatal Error because the original function is still there and cannot redeclare it.
I tried creating a new function name but the problem is the original one; If I just remove the original parent function everything works as expected.
I've read this and this to solve on my own but can not figure out what is the proper way to unregister~override the original menu function, and call it from child theme functions.
I presume it is also related with the "init" part because I should be doing this on the apply filters instead.