From 286063e9c0be652dca818ecec04be0e6df3f78ad Mon Sep 17 00:00:00 2001 From: champsupertramp Date: Tue, 12 Jan 2016 10:25:50 +0800 Subject: [PATCH] Add option for port forwarding in URL --- core/um-permalinks.php | 11 ++++++++--- um-config.php | 10 ++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/core/um-permalinks.php b/core/um-permalinks.php index 9e564fb0..6878feba 100644 --- a/core/um-permalinks.php +++ b/core/um-permalinks.php @@ -33,8 +33,10 @@ class UM_Permalinks { function get_current_url( $no_query_params = false ) { global $post; - $server_name_method = ( um_get_option('current_url_method') ) ? um_get_option('current_url_method') : 'SERVER_NAME'; - + $um_get_option = get_option('um_options'); + $server_name_method = ( $um_get_option['current_url_method'] ) ? $um_get_option['current_url_method'] : 'SERVER_NAME'; + $um_port_forwarding_url = ( $um_get_option['um_port_forwarding_url'] ) ? $um_get_option['um_port_forwarding_url']: ''; + if ( !isset( $_SERVER['SERVER_NAME'] ) ) return ''; @@ -52,16 +54,19 @@ class UM_Permalinks { } $page_url .= "://"; - if ( isset( $_SERVER["SERVER_PORT"] ) && $_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443" ) { + if ( $um_port_forwarding_url == 1 && isset( $_SERVER["SERVER_PORT"] ) ) { $page_url .= $_SERVER[ $server_name_method ].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; + } else { $page_url .= $_SERVER[ $server_name_method ].$_SERVER["REQUEST_URI"]; } + } if ( $no_query_params == true ) { $page_url = strtok($page_url, '?'); } + return apply_filters( 'um_get_current_page_url', $page_url ); } diff --git a/um-config.php b/um-config.php index 487b7be3..4c8cb665 100644 --- a/um-config.php +++ b/um-config.php @@ -1876,6 +1876,16 @@ $this->sections[] = array( ), ), + array( + 'id' => 'um_port_forwarding_url', + 'type' => 'switch', + 'title' => __( 'Allow Port forwarding in URL','ultimatemember' ), + 'default' => 0, + 'desc' => __('Turn on If you want to include port number in URLs','ultimatemember'), + 'on' => __('On','ultimatemember'), + 'off' => __('Off','ultimatemember'), + ), + array( 'id' => 'advanced_denied_roles', 'type' => 'text',