WPML
Status
Resolved
Reported for
WPML Multilingual CMS 4.5.8
Resolved in
MailChimp Multilingual v 0.1.0
Related plugin/theme
MC4WP: Mailchimp for WordPress
Topic tags
Compatibility

Overview of the issue

If you are using Mailchimp for WordPress (MC4WP) with WPML and you go to WPMLTranslation Management, the Edit link points to a broken URL.

Workaround

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

  1. Open your theme functions.php file.
  2. Add the following code:
    add_filter( 'wpml_document_edit_item_link', 'document_edit_item_link', 10, 5 );
    
    function document_edit_item_link( $link, $text, $current_document, $prefix, $type ) {
    		
    	if ( "mc4wp-form" !== $type ) {
    		return $link;
    	} 
    
    	$query = [];
    	$query['page']      = 'mailchimp-for-wp-forms';
    	$query['view']      = 'edit-form';
    	$query['admin_bar'] = 1;
    	$query['form_id']   = $current_document->ID;
    	$query['lang']      = $current_document->language_code;
    
    	$url_parsed          = array();
    	$url_parsed['query'] = http_build_query( $query );
    
    	$url = http_build_url( get_admin_url( null, 'admin.php' ), $url_parsed );
    	$url = esc_url( $url, null, 'redirect' );
    	
    	return "<a href='$url'>$text</a>";
    }
    
    add_filter( 'wpml_document_view_item_link', 'document_view_item_link' , 10, 5 );
    
    function document_view_item_link( $link, $text, $job, $prefix, $type ) {
    	if ( "mc4wp-form" !== $type ) {
    		return $link;
    	} 
    
    	return '';
    }

All known issues →