mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
Fixed WPML compatibility issue
This commit is contained in:
+25
-26
@@ -43,43 +43,42 @@ class UM_Rewrite {
|
||||
$user_slug = $user->post_name;
|
||||
$account = get_post($account_page_id);
|
||||
$account_slug = $account->post_name;
|
||||
|
||||
|
||||
add_rewrite_rule(
|
||||
'^'.$user_slug.'/([^/]*)$',
|
||||
'index.php?page_id='.$user_page_id.'&um_user=$matches[1]',
|
||||
'top'
|
||||
);
|
||||
|
||||
add_rewrite_rule(
|
||||
'^'.$account_slug.'/([^/]*)$',
|
||||
'index.php?page_id='.$account_page_id.'&um_tab=$matches[1]',
|
||||
'top'
|
||||
);
|
||||
$add_lang_code = '';
|
||||
|
||||
if ( function_exists('icl_object_id') || function_exists('icl_get_current_language') && icl_get_current_language() != icl_get_default_language() ) {
|
||||
if ( function_exists('icl_object_id') || function_exists('icl_get_current_language') ) {
|
||||
|
||||
if( function_exists('icl_get_current_language') ){
|
||||
$language_code = icl_get_current_language();
|
||||
}else if( function_exists('icl_object_id') ){
|
||||
$language_code = ICL_LANGUAGE_CODE;
|
||||
}
|
||||
|
||||
add_rewrite_rule(
|
||||
'^'.$language_code.'/'.$user_slug.'/([^/]*)$',
|
||||
'index.php?page_id='.$user_page_id.'&um_user=$matches[1]',
|
||||
'bottom'
|
||||
);
|
||||
|
||||
add_rewrite_rule(
|
||||
'^'.$language_code.'/'.$account_slug.'/([^/]*)$',
|
||||
'index.php?page_id='.$account_page_id.'&um_tab=$matches[1]',
|
||||
'bottom'
|
||||
);
|
||||
|
||||
}else{
|
||||
// get the post ID in en
|
||||
$lang_post_id = icl_object_id( $user->ID, 'post', FALSE, $language_code );
|
||||
// get the post object
|
||||
$lang_post_obj = get_post( $lang_post_id );
|
||||
// get the name
|
||||
if( isset( $lang_post_obj->post_name ) ){
|
||||
$user_slug = $lang_post_obj->post_name;
|
||||
}
|
||||
|
||||
if( $language_code != icl_get_default_language() ){
|
||||
$add_lang_code = $language_code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
add_rewrite_rule($user_slug.'/([^/]+)/?$',
|
||||
'index.php?page_id='.$user_page_id.'&um_user=$matches[1]&lang='.$add_lang_code,
|
||||
'top'
|
||||
);
|
||||
|
||||
add_rewrite_rule($account_slug.'/([^/]+)?$',
|
||||
'index.php?page_id='.$account_page_id.'&um_tab=$matches[1]&lang='.$add_lang_code,
|
||||
'top'
|
||||
);
|
||||
|
||||
|
||||
flush_rewrite_rules( true );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user