Question

I am trying to remove some lines from function.php in Wordpress without making this permanent. My initial thought was to use a child theme. I understand that if you add "functions.php" as a child, it can be used to modify the parents function. Any recommendations? Thanks in advance for your support!!!

This is the code I want to target:

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>';

} 

}

Was it helpful?

Solution

Yes, the recommendation would be to use the child theme.

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");

Then create a functions.php in child theme.

However, the next part is that you're wanting to replace some code, which should not be done, instead you should remove it's action/filter hook that it has implemented :

remove_action( $tag, $function_to_remove, $priority );

Or if it was added as a filter:

remove_filter( $tag, $function_to_remove, $priority ); 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top