mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
WPML compatibility
This commit is contained in:
@@ -151,6 +151,24 @@ class UM_Permalinks {
|
||||
}
|
||||
}
|
||||
|
||||
// WPML compatibility
|
||||
if ( function_exists('icl_object_id') ) {
|
||||
|
||||
|
||||
$language_code = ICL_LANGUAGE_CODE;
|
||||
$lang_post_id = icl_object_id( $page_id , 'page', true, $language_code );
|
||||
|
||||
if($lang_post_id != 0) {
|
||||
$profile_url = get_permalink( $lang_post_id );
|
||||
}else {
|
||||
// No page found, it's most likely the homepage
|
||||
global $sitepress;
|
||||
$profile_url = $sitepress->language_url( $language );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if ( um_get_option('permalink_base') == 'user_login' ) {
|
||||
$user_in_url = um_user('user_login');
|
||||
|
||||
|
||||
+33
-8
@@ -43,18 +43,43 @@ 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'
|
||||
'^'.$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'
|
||||
'^'.$account_slug.'/([^/]*)$',
|
||||
'index.php?page_id='.$account_page_id.'&um_tab=$matches[1]',
|
||||
'top'
|
||||
);
|
||||
|
||||
if ( function_exists('icl_object_id') || function_exists('icl_get_current_language') && icl_get_current_language() != icl_get_default_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{
|
||||
|
||||
}
|
||||
|
||||
flush_rewrite_rules( true );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user