mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-19 06:33:50 +09:00
Fix WPML compatibility
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
add_filter("um_localize_permalink_filter","um_localize_permalink_filter",10,3);
|
||||
function um_localize_permalink_filter( $core_pages, $page_id, $profile_url ){
|
||||
global $ultimatemember;
|
||||
|
||||
get_post( $page_id );
|
||||
|
||||
if ( function_exists('icl_get_current_language') && icl_get_current_language() != icl_get_default_language() ) {
|
||||
if ( get_the_ID() > 0 && get_post_meta( get_the_ID(), '_um_wpml_user', true ) == 1 ) {
|
||||
$profile_url = get_permalink( get_the_ID() );
|
||||
}
|
||||
}
|
||||
|
||||
// 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_code );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $profile_url;
|
||||
|
||||
}
|
||||
|
||||
add_filter('um_core_page_id_filter','um_core_page_id_filter');
|
||||
function um_core_page_id_filter( $page_id ){
|
||||
|
||||
/* if( ! empty( $_GET['lang'] ) && isset( $_GET['lang'] ) ){
|
||||
$page_id = $page_id.'_'.$_GET['lang'];
|
||||
}
|
||||
*/
|
||||
return $page_id;
|
||||
}
|
||||
+1
-19
@@ -191,28 +191,10 @@ class UM_Permalinks {
|
||||
$page_id = $this->core['user'];
|
||||
$profile_url = get_permalink( $page_id );
|
||||
|
||||
if ( function_exists('icl_get_current_language') && icl_get_current_language() != icl_get_default_language() ) {
|
||||
if ( get_the_ID() > 0 && get_post_meta( get_the_ID(), '_um_wpml_user', true ) == 1 ) {
|
||||
$profile_url = get_permalink( get_the_ID() );
|
||||
}
|
||||
}
|
||||
|
||||
// WPML compatibility
|
||||
if ( function_exists('icl_object_id') ) {
|
||||
$profile_url = apply_filters('um_localize_permalink_filter', $this->core, $page_id, $profile_url );
|
||||
|
||||
|
||||
$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');
|
||||
|
||||
|
||||
+10
-6
@@ -12,16 +12,20 @@ class UM_Query {
|
||||
*** @get wp pages
|
||||
***/
|
||||
function wp_pages() {
|
||||
$count_pages = wp_count_posts('page');
|
||||
global $wpdb;
|
||||
$pages = $wpdb->get_results('SELECT * FROM '.$wpdb->posts.' WHERE post_type = "page" AND post_status = "publish" ', OBJECT);
|
||||
$count_pages = $wpdb->num_rows;
|
||||
|
||||
if ( $count_pages->publish > 300 )
|
||||
return;
|
||||
if ( $count_pages > 300 )
|
||||
return 'reached_maximum_limit';
|
||||
|
||||
$pages = get_pages();
|
||||
$array = '';
|
||||
foreach ($pages as $page_data) {
|
||||
$array[ $page_data->ID ] = $page_data->post_title;
|
||||
if( $wpdb->num_rows > 0 ){
|
||||
foreach ($pages as $page_data) {
|
||||
$array[ $page_data->ID ] = $page_data->post_title;
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
@@ -1567,3 +1567,18 @@ function um_fetch_user( $user_id ) {
|
||||
function um_search_form() {
|
||||
echo um_get_search_form();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get localization
|
||||
* @return string
|
||||
*/
|
||||
function um_get_locale(){
|
||||
|
||||
$lang_code = get_locale();
|
||||
|
||||
if( strpos( $lang_code , 'en_' ) > -1 || empty( $lang_code ) || $lang_code == 0 ){
|
||||
return 'en';
|
||||
}
|
||||
|
||||
return $lang_code;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user