• I want to translate a custom function that adds “Log in/out” menu items for Woocommerce.
    The problem is that I am not sure what is the correct way to register the strings.

    This is the function

    
    add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
    
    function add_loginout_link( $items, $args ) {
    
       if (is_user_logged_in() && $args->theme_location == 'grve_top_right_nav') {
    
           $items .= '<li><a href="'. wp_logout_url( get_permalink( woocommerce_get_page_id( 'myaccount' ) ) ) .'">Log Out</a></li>';
    
       }
    
       elseif (!is_user_logged_in() && $args->theme_location == 'primary') {
    
           $items .= '<li><a href="' . get_permalink( woocommerce_get_page_id( 'myaccount' ) ) . '">Log In</a></li>';
    
       }
    
       return $items;
    
    }

    In my case, I need to translate the words “log out” and “log in”

    I understand that I have to use pll_register_string in my functions.php but not sure how to use.

    Any help would be much appreciated, thanks!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Adding string translation custom function’ is closed to new replies.