Multilingual Edit Page

This topic contains 5 reply and 3 voices, and was last updated by Gonzalo 10 years, 2 months ago
Viewing 5 Posts - 1 through 5 (of 5 total)
Author Posts
July 10, 2013 at 6:53 pm 5838
Gonzalo Hi. I am using WPML plugin to set a multilingual site, default language is english, second language is french. WPML manage page translation by creating a page for each language, each page has a language attribute. When I define the page edit in WPFUE settings, this page is used for both languages. Here is the process I have followed : 1. Set the edit page in english admin context as 'Edit' (my english edit page with the wpufe_edit shortcode) 2. Switch in admin in French Language 3. Set the edit page in french admin context as 'Modifier' (my french edit page with the wpufe_edit shortcode) 4. Switch in admin in English Language 5. Problem : the settings for english are reseted, no page is selected, and wordpress will use the french edit page for both language. Is there a way to fix it ? Thank you
July 11, 2013 at 4:46 am 5855
Tareq Hasan Tareq Hasan

So what I understand, if you switch to English, the form should be in English. And when you switch to French, the form should be in French, isn’t that right?

If thats the case, WPUF isn’t capable doing this yet, even with WPML.

July 11, 2013 at 1:40 pm 5873
obouilland obouilland

Ok Thank you for your reply. Do you plan to create WPML compatibility in a next future ?

July 11, 2013 at 2:02 pm 5876
Tareq Hasan Tareq Hasan

Yes, that would be a cool feature 🙂

July 11, 2013 at 3:35 pm 5878
obouilland obouilland

Yes, for sure !

For those who face the same problem, i find the solution by changing your function wpuf_edit_post_link, line 217 in wpuf-functions.php like this :

/**
 * Edit post link for frontend
 *
 * @since 0.7
 * @param string $url url of the original post edit link
 * @param int $post_id
 * @return string url of the current edit post page
 */
function wpuf_edit_post_link( $url, $post_id ) {
    if ( is_admin() ) {
        return $url;
    }

    $override = wpuf_get_option( 'override_editlink', 'wpuf_general', 'yes' );
    if ( $override == 'yes' ) {
        $url = '';
        if ( wpuf_get_option( 'enable_post_edit', 'wpuf_dashboard', 'yes' ) == 'yes' ) {
            $edit_page = (int) wpuf_get_option( 'edit_page_id', 'wpuf_general' );
			$current_language =ICL_LANGUAGE_CODE ;
			if($current_language == 'fr') {
   			 $edit_page_wpml = icl_object_id($edit_page,'page',true);
  			}
			else {
				$edit_page_wpml = $edit_page ;
				}
			
			
            $url = get_permalink( $edit_page_wpml );

            $url = wp_nonce_url( $url . '?pid=' . $post_id, 'wpuf_edit' );
        }
    }

    return $url;
}

add_filter( 'get_edit_post_link', 'wpuf_edit_post_link', 10, 2 );

The changes are just for additional languages, no need to had anything for default language.

Perhaps it is possible in next release just to add a function exists test on this function in order to hack it in my function.php and not have to change core plugin files.

In the same way, here is the function I had to my function.php file in order to save a post in the correct language (same again, only needed for additional languages, not for the default one):


/**
 * Update the lanuage  when the form submits
 *
 * @param type $post_id
 */
function update_language_hook( $post_id ) {
	$language = $_POST['icl_post_language'] = ICL_LANGUAGE_CODE;
    if ( isset( $language) && $language == 'fr' ) {
		global $wpdb;
		 $wpdb->update('wp_icl_translations', array('language_code'=>$language), array('element_id'=> $post_id)); 
	}
}
 
add_action( 'wpuf_add_post_after_insert', 'update_language_hook');

I hope it could help multilingual integration for wpufe.

Olivier

January 16, 2014 at 4:25 am 14457
Gonzalo Gonzalo

Hi

I was wondering if this has been incorporated.

Thanks
Gonzalo

Viewing 5 Posts - 1 through 5 (of 5 total)