我试图从Wordpress中的function.php中删除一些行而不使其永久化。我最初的想法是使用儿童主题。据我所知,如果你将“functions.php”添加为子节点,它可以用来修改父节点功能。有什么建议?在此先感谢您的支持!!!
这是我想要定位的代码:
function top_bar_front_end_menu(){
$top_bar_status= esc_html ( get_option('wp_estate_enable_top_bar','') );
if($top_bar_status=='yes'){
$current_user = wp_get_current_user();
$username=$current_user->user_login ;$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => 'user-dashboard-add.php'
));
if( $pages ){
$add_link = get_permalink( $pages[0]->ID);
}else{
$add_link='';
}
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => 'user-dashboard-profile.php'
));
if( $pages ){
$dash_profile = get_permalink( $pages[0]->ID);
}else{
$dash_profile=home_url();
}
$dash_link = get_dashboard_link();
print'<div class="top-user-menu-wrapper">
<div class="top-user-menu">
<div class="wellcome-user">';
$show_user_not_logged_in='';
$show_user_logged_in='';
if ( is_user_logged_in() ) {
$show_user_not_logged_in='geohide' ;
}else{
$show_user_logged_in='geohide';
}
$paid_submission_status = esc_html ( get_option('wp_estate_paid_submission','') );
print '
<div id="user_logged_in" class="'.$show_user_logged_in.'">';
if($dash_link!=''){
print ' <a href="'.$dash_link.'">'.__('My Properties','wpestate').'</a> | ';
}else{
print '<a href="'.$dash_profile.'">' .__('My Profile','wpestate').'</a> | ';
}
if($add_link!=''){
print '<a href="'.$add_link.'">' .__('List a Property','wpestate').'</a> | ';
}
print'
<a href="'.wp_logout_url().'">'.__('Log Out','wpestate').'</a>
</div>';
$front_end_register = esc_html( get_option('wp_estate_front_end_register','') );
$front_end_login = esc_html( get_option('wp_estate_front_end_login ','') );
print '
<div id="user_not_logged_in" class="'.$show_user_not_logged_in.'">
<a href="'.$front_end_login.'">'.__('Login','wpestate').'</a> |
<a href="'.$front_end_register.'">'.__('Register','wpestate').'</a>
</div>';
print'
</div>
</div>
</div>';
}
}
答案 0 :(得分:3)
是的,建议是使用儿童主题。
的style.css
/*
Theme Name: My Child Theme
Description: My Child Theme's description
Author: John Doe
Author URI: http://example.com
Template: child-theme
Version: 1.0.0
*/
@import url("../parent-theme/style.css");
然后在子主题中创建一个functions.php。
然而,下一部分是你想要替换一些不应该做的代码,而应该删除它已实现的动作/过滤器钩子:
remove_action( $tag, $function_to_remove, $priority );
或者如果它被添加为过滤器:
remove_filter( $tag, $function_to_remove, $priority );