Skip to content Skip to sidebar

Waiting for author

Topic Tags: Compatibility

Overview of the issue

When using AffiliateWP with the AffiliateWP Portal addon and WPML, custom menu links added to the Affiliate Portal display in both languages, but their labels are not translatable. There is no built-in option to translate these custom link labels.

Workaround

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

  • Open the …/wp-content/plugins/affiliatewp-affiliate-portal/includes/core/class-menu-links.php file.
  • Look for line 102.
  • Replace:
    // filter only menu links with a page.
    $menu_links = array_filter(
    	$menu_links,
    	function( $menu_link) {
    		return ! empty( $menu_link['id'] );
    	}
    );
            
  • With:
    // filter only menu links with a page.
    $menu_links = array_filter(
    	$menu_links,
    	function( $menu_link) {
    		return ! empty( $menu_link['id'] );
    	}
    );
    // WPML Workaround for compsupp-8049 - Register menu links labels with WPML
    foreach ( $menu_links as $index => &$link ) {
    	if ( ! empty( $link['label'] ) ) {
    		do_action( 'wpml_register_single_string', 'affiliatewp-portal-menu', 'portal_menu_link_label_' . $index, $link['label'] );
    		$link['label'] = apply_filters( 'wpml_translate_single_string', $link['label'], 'affiliatewp-portal-menu', 'portal_menu_link_label_' . $index );
    	}
    }
            
  • Go to AffiliateWP > Settings > Affiliate Portal and resave your settings.
  • Then go to WPML > String Translation to translate the custom menu link labels.

Leave a Reply

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.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>