PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
← All changes | admin/advanced-settings/includes/userlisting/modify-permalinks-single.php +28 -5 3.9.6 → 4.0.3 View file →
@@ -1,5 +1,7 @@
1 1 <?php
2 +// Exit if accessed directly
3 +if ( ! defined( 'ABSPATH' ) ) exit;
2 4
3 5 function wppb_toolbox_flush_rewrite_rules() {
4 6 $base = wppb_toolbox_get_settings( 'userlisting', 'modify-permalinks-single' );
5 7
@@ -6,14 +8,22 @@
6 8 if ( $base == false ) return;
7 9
8 10 $rules = get_option( 'rewrite_rules' );
9 11 $frontpage_id = get_option( 'page_on_front' );
12 + $lang_pattern = function_exists( 'wppb_userlisting_get_language_pattern' ) ? wppb_userlisting_get_language_pattern() : '';
10 13
11 - if ( !isset($rules['(.+?)/'.$base.'/([^/]+)']) ||
14 + $needs_flush = (
15 + !isset($rules['(.+?)/'.$base.'/([^/]+)']) ||
12 16 !isset($rules['(.?.+?)/' . wppb_get_users_pagination_slug() . '/?([0-9]{1,})/?$'] ) ||
13 - ( !empty( $frontpage_id ) && !isset( $rules[wppb_get_users_pagination_slug() . '/?([0-9]{1,})/?$'] ) ) ) {
17 + ( !empty( $frontpage_id ) && !isset( $rules[wppb_get_users_pagination_slug() . '/?([0-9]{1,})/?$'] ) )
18 + );
19 +
20 + if ( ! $needs_flush && $lang_pattern !== '' && ! isset( $rules[ $lang_pattern . '/(.+?)/' . $base . '/([^/]+)' ] ) ) {
21 + $needs_flush = true;
22 + }
23 +
24 + if ( $needs_flush ) {
14 25 global $wp_rewrite;
15 -
16 26 $wp_rewrite->flush_rules();
17 27 }
18 28 }
19 29 add_action( 'wp_loaded', 'wppb_toolbox_flush_rewrite_rules' );
@@ -25,15 +35,28 @@
25 35
26 36 $wppb_addonOptions = get_option('wppb_module_settings');
27 37
28 38 if( $wppb_addonOptions['wppb_userListing'] == 'show' ) {
29 - $new_rules = array();
39 + $new_rules = array();
40 + $frontpage_id = get_option('page_on_front');
41 + $lang_pattern = function_exists( 'wppb_userlisting_get_language_pattern' ) ? wppb_userlisting_get_language_pattern() : '';
30 42
43 + // Polylang compatibility: capture the language slug separately so the pagename only
44 + // contains the actual page slug.
45 + if ( $lang_pattern !== '' ) {
46 + $new_rules[ $lang_pattern . '/(.+?)/' . $base . '/([^/]+)' ] = 'index.php?lang=$matches[1]&pagename=$matches[2]&username=$matches[3]';
47 +
48 + if ( !empty($frontpage_id) ) {
49 + $new_rules[ $lang_pattern . '/' . wppb_get_users_pagination_slug() . '/?([0-9]{1,})/?$' ] = 'index.php?lang=$matches[1]&page_id=' . $frontpage_id . '&wppb_page=$matches[2]';
50 + }
51 +
52 + $new_rules[ $lang_pattern . '/(.?.+?)/' . wppb_get_users_pagination_slug() . '/?([0-9]{1,})/?$' ] = 'index.php?lang=$matches[1]&pagename=$matches[2]&wppb_page=$matches[3]';
53 + }
54 +
31 55 //user rule
32 56 $new_rules['(.+?)/'. $base .'/([^/]+)'] = 'index.php?pagename=$matches[1]&username=$matches[2]';
33 57
34 58 //users-page rule
35 - $frontpage_id = get_option('page_on_front');
36 59 if (!empty($frontpage_id)) {
37 60 $new_rules[wppb_get_users_pagination_slug() . '/?([0-9]{1,})/?$'] = 'index.php?&page_id=' . $frontpage_id . '&wppb_page=$matches[1]';
38 61 }
39 62