跳过导航

Open

Reported for: BuddyPress Multilingual 1.7.0

Topic Tags: Compatibility

Overview of the issue

If you are using BuddyBoss, you may notice that the language switcher is missing flag icons, displaying only blank icons instead. This issue affects both the top menu and side panel language switchers.

Workaround

Please, make sure of having a full backup of your site before proceeding.

For fixing the BuddyBoss panel:

  • Open the …/wp-content/themes/buddyboss-theme/inc/theme/functions.php file.
  • Look for line 582.
  • Replace:
    function bb_buddypanel_menu_atts( $atts, $item, $args ) {
    	if (
    		isset( $args->theme_location ) &&
    		(
    			'buddypanel-loggedin' === $args->theme_location ||
    			'buddypanel-loggedout' === $args->theme_location
    		)
    	) {
    		$atts['class'] = 'bb-menu-item';
    
    		$header = (int) buddyboss_theme_get_option( 'buddyboss_header' );
    		if ( 3 === $header ) {
    			$buddypanel_side = buddyboss_theme_get_option( 'buddypanel_position_h3' );
    		} else {
    			$buddypanel_side = buddyboss_theme_get_option( 'buddypanel_position' );
    		}
    
    		if ( $buddypanel_side && $buddypanel_side == 'right' ) {
    			$atts['data-balloon-pos'] = 'left';
    		} else {
    			$atts['data-balloon-pos'] = 'right';
    		}
    		$atts['data-balloon'] = $item->title;
    	}
    
    	return $atts;
    }
    
  • With:
    function bb_buddypanel_menu_atts( $atts, $item, $args ) {
    	if (
    		isset( $args->theme_location ) &&
    		(
    			'buddypanel-loggedin' === $args->theme_location ||
    			'buddypanel-loggedout' === $args->theme_location
    		)
    	) {
    		$atts['class'] = 'bb-menu-item';
    
    		$header = (int) buddyboss_theme_get_option( 'buddyboss_header' );
    		if ( 3 === $header ) {
    			$buddypanel_side = buddyboss_theme_get_option( 'buddypanel_position_h3' );
    		} else {
    			$buddypanel_side = buddyboss_theme_get_option( 'buddypanel_position' );
    		}
    
    		if ( $buddypanel_side && $buddypanel_side == 'right' ) {
    			$atts['data-balloon-pos'] = 'left';
    		} else {
    			$atts['data-balloon-pos'] = 'right';
    		}
    		$atts['data-balloon'] = $item->title;
    		// WPMl workaround for compsupp-7115
    		if (class_exists('Sitepress')) {
    			$atts['data-balloon'] = wp_strip_all_tags($item->title);
    		}
    	}
    
    	return $atts;
    }
    
  • In the same file around line 895, replace:
    if ( ! $icon ) {
    	if ( in_array( 'bp-menu', $item->classes ) ) {
    		if ( 'bp-profile-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-user';
    		} elseif ( 'bp-settings-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-cog';
    		} elseif ( 'bp-activity-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-activity';
    		} elseif ( 'bp-notifications-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-bell';
    		} elseif ( 'bp-messages-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-inbox';
    		} elseif ( 'bp-friends-nav' === $item->classes[1] || 'bp-friends-sub-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-user-friends';
    		} elseif ( 'bp-groups-nav' === $item->classes[1] || 'bp-groups-sub-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-users';
    		} elseif ( 'bp-forums-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-comments-square';
    		} elseif ( 'bp-videos-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-video';
    		} elseif ( 'bp-documents-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-folder-alt';
    		} elseif ( 'bp-photos-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-image';
    		} elseif ( 'bp-invites-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-envelope';
    		} elseif ( 'bp-logout-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-sign-out';
    		} elseif ( 'bp-login-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-sign-in';
    		} elseif ( 'bp-register-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-clipboard';
    		} elseif ( 'bp-courses-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-graduation-cap';
    		}
    	}
    	if ( ! $icon ) {
    		$item->title = "<i class='bb-icon-file'></i><span class='link-text'>{$item->title}</span>";
    	} else {
    		$item->title = "<i class='_mi _before buddyboss bb-icon-l " . $icon . "'></i><span class='link-text'>{$item->title}</span>";
    	}
    }
    
  • With:
    if ( ! $icon ) {
    	if ( in_array( 'bp-menu', $item->classes ) ) {
    		if ( 'bp-profile-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-user';
    		} elseif ( 'bp-settings-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-cog';
    		} elseif ( 'bp-activity-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-activity';
    		} elseif ( 'bp-notifications-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-bell';
    		} elseif ( 'bp-messages-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-inbox';
    		} elseif ( 'bp-friends-nav' === $item->classes[1] || 'bp-friends-sub-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-user-friends';
    		} elseif ( 'bp-groups-nav' === $item->classes[1] || 'bp-groups-sub-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-users';
    		} elseif ( 'bp-forums-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-comments-square';
    		} elseif ( 'bp-videos-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-video';
    		} elseif ( 'bp-documents-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-folder-alt';
    		} elseif ( 'bp-photos-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-image';
    		} elseif ( 'bp-invites-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-envelope';
    		} elseif ( 'bp-logout-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-sign-out';
    		} elseif ( 'bp-login-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-sign-in';
    		} elseif ( 'bp-register-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-clipboard';
    		} elseif ( 'bp-courses-nav' === $item->classes[1] ) {
    			$icon = 'bb-icon-graduation-cap';
    		}
    	}
    
    	// WPML Workround for compsupp-7115
    	elseif (in_array( 'wpml-ls-item', $item->classes)) {
    		$icon = 'bb-icon-globe';
    	}
    
    	if ( ! $icon ) {
    		$item->title = "<i class='bb-icon-file'></i><span class='link-text'>{$item->title}</span>";
    	} else {
    		if (! preg_match('/<img/', $item->title) ) {
    			$item->title = "<i class='_mi _before buddyboss bb-icon-l " . $icon . "'></i><span class='link-text'>{$item->title}</span>";
    		}
    	}
    }
    

For fixing the language switcher on the BuddyBoss header menu:

  • In the same file, around the line 1056.
  • Just before:
    		if ( ! $icon ) {
    			$classes[] = 'no-icon';
    
  • Add:
    		// WPML Workround for compsupp-7139
    		if (in_array( 'wpml-ls-item', $item->classes)) {
    			$icon = 'bb-icon-globe';
    		}	
    

7 所有回复 给 “BuddyBoss - WPML Menu Language Switcher does not display flags”

  1. Is it possible to add this workaround about WPML’s flags and BuddyBoss to the child theme’s function.php?

    Every time BuddyBoss updates its theme (that happens very frequently), I need to change the above rows in the “buddyboss-theme/inc/theme/functions.php” file manually. Can these instructions be saved in a separate file, like the function file of the child theme?

    Thanks.

    • Unfortunately, we don’t have a way to add this workaround directly in the functions.php.
      We will keep this erratum updated once we have any updates.

  2. Hi WPML Team – thanks for posting about this issue!

    We, too, would be discouraged when thinking about updating this code every time BuddyBoss theme is updated (which I agree with @micheleB-25 comes in regular intervals!).

    Could you clarify if there is a chance that the WPML team might work this into the BuddyBoss Multilingual glue plugin so that we won’t have to manually intervene in the future – do you think that is possible? Or is there more of a chance we will have to edit these files manually for the foreseeable future?

    Thanks so much as always if you are able to give a reply!

    • Hello @calebW-2,
      I totally understand you. Sure, we are in contact with BuddyBoss team and we are working together in a permanent solution. However, we can’t provide you and ETA at this point.
      We will keep this page updated.
      Regards

      • All good, Andrés – thanks so much for letting us know, and no worries on any replies to this comment! Any update when it’s resolved will work just fine regardless of the ETA. Appreciate you guys starting to work on it right away! Thanks, again, for letting us know!

      • PS – We ended up putting the language switcher in the footer and that works great for now. Thanks, again, to the WPML team for constantly improving WPML!

留下回复

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

您可以使用这些标签:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>