Skip to content

Commit 5584141

Browse files
committed
Prepare version 1.2.1
- The core page links are localized using the `page_link` hook. - The logout redirect URL is localized.
1 parent bb20604 commit 5584141

File tree

4 files changed

+97
-24
lines changed

4 files changed

+97
-24
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Integrates the **Ultimate Member** plugin with the **Polylang** plugin. Makes Ul
55
## Key features
66

77
- Language switcher shortcode. Display the Polylang language switcher where you need it.
8-
- Localize permalinks for the Account and User (profile) pages.
8+
- Adds rewrite rules for localized Account and User (profile) pages.
9+
- Localize links for Ultimate Member pages in menu.
910
- Ability to duplicate Ultimate Member pages for all languages in one click.
1011
- Ability to duplicate Ultimate Member forms for all languages in one click.
1112
- Ability to translate email templates.
@@ -27,7 +28,7 @@ Once the plugin is cloned, enter your site admin dashboard and go to _wp-admin >
2728

2829
### How to install from ZIP archive
2930

30-
You can install this plugin from the [ZIP archive](https://drive.google.com/file/d/1rj0W6639PMrFQqLfeCZXhoYgRcnCac8d/view?usp=sharing) as any other plugin. Follow [this instruction](https://wordpress.org/support/article/managing-plugins/#upload-via-wordpress-admin).
31+
You can install this plugin from the [ZIP archive](https://drive.google.com/file/d/1K5DMJYQtof32NftqDat9ACc0wNqIbmNa/view?usp=sharing) as any other plugin. Follow [this instruction](https://wordpress.org/support/article/managing-plugins/#upload-via-wordpress-admin).
3132

3233
## How to use
3334

@@ -114,12 +115,14 @@ Image - Translate profile tabs.
114115
This is a free extension created for the community. The Ultimate Member team does not provide support for this extension.
115116
Open new [issue](https://github.com/umdevelopera/um-polylang/issues) if you are facing a problem or have a suggestion.
116117

117-
## Related links
118+
**Please give a star if you think this extension is useful. I wish to know how many people use it. Thanks.**
118119

119-
Ultimate Member home page: https://ultimatemember.com/
120+
## Useful links
120121

121-
Ultimate Member documentation: https://docs.ultimatemember.com/
122+
[Ultimate Member documentation](https://docs.ultimatemember.com)
122123

123-
Ultimate Member download: https://wordpress.org/plugins/ultimate-member/
124+
[Ultimate Member core plugin info and download](https://wordpress.org/plugins/ultimate-member)
124125

125-
Articles: [How to translate plugin](https://docs.ultimatemember.com/article/1449-how-to-translate-plugin#switch), [The language switcher](https://polylang.pro/doc/the-language-switcher/)
126+
[Free extensions for Ultimate Member](https://docs.google.com/document/d/1wp5oLOyuh5OUtI9ogcPy8NL428rZ8PVTu_0R-BuKKp8/edit?usp=sharing)
127+
128+
[Code snippets for Ultimate Member](https://docs.google.com/document/d/1_bikh4JYlSjjQa0bX1HDGznpLtI0ur_Ma3XQfld2CKk/edit?usp=sharing)

includes/core/class-permalinks.php

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public function __construct() {
3434
// Pages.
3535
add_filter( 'um_get_core_page_filter', array( &$this, 'localize_core_page_url' ), 10, 3 );
3636
add_filter( 'um_localize_permalink_filter', array( &$this, 'localize_profile_permalink' ), 10, 2 );
37+
add_filter( 'page_link', array( $this, 'localize_core_page_link' ), 10, 2 );
38+
39+
// Logout.
40+
add_action( 'template_redirect', array( $this, 'localize_logout_page' ), 9990 );
3741

3842
// Buttons.
3943
add_filter( 'um_login_form_button_two_url', array( &$this, 'localize_page_url' ), 10, 2 );
@@ -50,7 +54,7 @@ public function __construct() {
5054
/**
5155
* Add rewrite rules for the Account and User page.
5256
*
53-
* @hook rewrite_rules_array
57+
* @hooked rewrite_rules_array
5458
*
5559
* @since 1.0.0
5660
*
@@ -210,7 +214,7 @@ public function get_page_url_for_language( $post_id, $language = '' ) {
210214
/**
211215
* Check if the current page is a UM Core Page or not.
212216
*
213-
* @hook um_is_core_page
217+
* @hooked um_is_core_page
214218
*
215219
* @since 1.0.0
216220
* @deprecated since version 1.0.1
@@ -236,26 +240,48 @@ public function is_core_page( $is_core_page, $page ) {
236240
/**
237241
* Filter account activation link.
238242
*
239-
* @hook um_activate_url
240-
* @see um\core\Permalinks::activate_url()
243+
* @hooked um_activate_url
244+
*
245+
* @see um\core\Permalinks
241246
* @since 1.1.0
242247
*
243248
* @param string $url Account activation link.
244-
*
245249
* @return string Localized account activation link.
246250
*/
247251
public function localize_activate_url( $url ){
248252
if ( ! UM()->Polylang()->is_default() ) {
249253
$url = add_query_arg( 'lang', UM()->Polylang()->get_current(), $url );
250-
}
254+
}
251255
return $url;
252256
}
253257

254258

259+
/**
260+
* Filter logout page URL.
261+
*
262+
* @hooked page_link
263+
*
264+
* @since version 1.2.1
265+
*
266+
* @param string $link The page's permalink.
267+
* @param int $post_id The ID of the page.
268+
* @return string The page permalink.
269+
*/
270+
public function localize_core_page_link( $link, $post_id ) {
271+
if ( ! UM()->Polylang()->is_default() ) {
272+
if ( is_array( UM()->config()->permalinks ) && in_array( $post_id, UM()->config()->permalinks, true ) ) {
273+
$url = $this->get_page_url_for_language( $post_id, UM()->Polylang()->get_current() );
274+
$link = ( $link !== $url ) ? $url : add_query_arg( 'lang', pll_current_language(), $url );
275+
}
276+
}
277+
return $link;
278+
}
279+
280+
255281
/**
256282
* Filter core page URL.
257283
*
258-
* @hook um_get_core_page_filter
284+
* @hooked um_get_core_page_filter
259285
*
260286
* @since 1.0.0
261287
*
@@ -276,11 +302,45 @@ public function localize_core_page_url( $url, $slug, $updated = '' ) {
276302
}
277303

278304

305+
/**
306+
* The logout redirect URL.
307+
*
308+
* @hooked template_redirect - 9990
309+
*
310+
* @see \um\core\Logout
311+
* @since version 1.2.1
312+
*/
313+
public function localize_logout_page() {
314+
if ( is_user_logged_in() && um_is_core_page( 'logout' ) && empty( $_REQUEST['redirect_to'] ) ) {
315+
$lang = UM()->Polylang()->get_current();
316+
317+
if ( 'redirect_home' === um_user( 'after_logout' ) ) {
318+
// if "Action to be taken after logout" is set to "Go to Homepage".
319+
320+
$link = home_url();
321+
$url = PLL()->links->get_home_url( $lang );
322+
$_REQUEST['redirect_to'] = ( $link !== $url ) ? $url : add_query_arg( 'lang', $lang, $url );
323+
324+
} elseif( 'redirect_url' === um_user( 'after_logout' ) ) {
325+
// if "Action to be taken after logout" is set to "Go to Custom URL".
326+
327+
$redirect_url = apply_filters( 'um_logout_redirect_url', um_user( 'logout_redirect_url' ), um_user( 'ID' ) );
328+
$page_path = trim( str_replace( home_url(), '', $redirect_url ), " \t\n\r\0\x0B/\\" );
329+
$page = get_page_by_path( $page_path );
330+
if ( is_object( $page ) ) {
331+
$redirect_to = $this->get_page_url_for_language( $page->ID, $lang );
332+
$_REQUEST['redirect_to'] = $redirect_to;
333+
}
334+
}
335+
}
336+
}
337+
338+
279339
/**
280340
* Filter page URL on buttons.
281341
*
282-
* @hook um_login_form_button_two_url
283-
* @hook um_register_form_button_two_url
342+
* @hooked um_login_form_button_two_url
343+
* @hooked um_register_form_button_two_url
284344
*
285345
* @since 1.0.0
286346
*
@@ -300,7 +360,7 @@ public function localize_page_url( $url, $args = array() ) {
300360
/**
301361
* Filter profile page URL.
302362
*
303-
* @hook um_localize_permalink_filter
363+
* @hooked um_localize_permalink_filter
304364
*
305365
* @since 1.0.0
306366
*

readme.txt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ Author: umdevelopera
44
Author URI: https://github.com/umdevelopera
55
Plugin URI: https://github.com/umdevelopera/um-polylang
66
Tags: ultimate member, polylang, multilingual
7+
License: GNU Version 2 or Any Later Version
8+
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
9+
710
Requires at least: 6.5
8-
Tested up to: 6.7
11+
Tested up to: 6.7.1
912
Requires UM core at least: 2.6.8
1013
Tested UM core up to: 2.9.1
11-
Stable tag: 1.2.0
12-
License: GNU Version 2 or Any Later Version
13-
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
14+
Stable tag: 1.2.1
1415

1516
== Description ==
1617

@@ -19,7 +20,8 @@ Integrates the "Ultimate Member" plugin with the "Polylang" plugin. Makes UM mul
1920
= Key Features =
2021

2122
* Language switcher shortcode. Displays the Polylang language switcher where you need it.
22-
* Localized permalinks for the Account and User (profile) pages.
23+
* Adds rewrite rules for localized Account and User (profile) pages.
24+
* Localize links for Ultimate Member pages in menu.
2325
* Ability to duplicate Ultimate Member pages for all languages in one click.
2426
* Ability to duplicate Ultimate Member forms for all languages in one click.
2527
* Ability to translate email templates.
@@ -41,6 +43,13 @@ Download ZIP file from GitHub or Google Drive. You can find download links here:
4143

4244
== Changelog ==
4345

46+
= 1.2.1: December 18, 2024 =
47+
48+
* Enhancements:
49+
50+
- Tweak: The core page links are localized using the `page_link` hook.
51+
- Tweak: The logout redirect URL is localized.
52+
4453
= 1.2.0: November 10, 2024 =
4554

4655
* Enhancements:

um-polylang.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
* Text Domain: um-polylang
99
* Domain Path: /languages
1010
*
11+
* Requires Plugins: ultimate-member, polylang
1112
* Requires at least: 6.5
1213
* Requires PHP: 7.4
13-
* UM version: 2.8.9
14-
* Version: 1.2.0
14+
* UM version: 2.9.1
15+
* Version: 1.2.1
1516
*
1617
* @package um_ext\um_polylang
1718
*/

0 commit comments

Comments
 (0)