Skip to content

Commit

Permalink
Added - Redirection even if we put the slug as redirect_url in login …
Browse files Browse the repository at this point in the history
…shortcode
  • Loading branch information
MILAN88888 committed Sep 5, 2023
1 parent f6ff721 commit eec90fa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
14 changes: 14 additions & 0 deletions includes/class-ur-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,18 @@ private static function render_form( $form_id ) {
)
);
}
/**
* Check the redirection url is valid url or slug.
*
* @param string $redirect_url redirection url.
*/
public static function check_is_valid_redirect_url( $redirect_url ) {
if ( filter_var( $redirect_url, FILTER_VALIDATE_URL ) === false ) {
$all_page_slug = ur_get_all_page_slugs();
if ( in_array( $redirect_url, $all_page_slug, true ) ) {
$redirect_url = site_url( $redirect_url );
}
}
return $redirect_url;
}
}
1 change: 1 addition & 0 deletions includes/shortcodes/class-ur-shortcode-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static function output( $atts ) {
global $wp, $post;

$redirect_url = isset( $atts['redirect_url'] ) ? trim( $atts['redirect_url'] ) : '';
$redirect_url = UR_Shortcodes::check_is_valid_redirect_url( $redirect_url );

if ( ! is_user_logged_in() ) {
// After password reset, add confirmation message.
Expand Down
7 changes: 1 addition & 6 deletions includes/shortcodes/class-ur-shortcode-my-account.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,7 @@ public static function output( $atts ) {
if ( ! is_user_logged_in() ) {

$redirect_url = isset( $atts['redirect_url'] ) ? trim( $atts['redirect_url'] ) : '';
if ( filter_var( $redirect_url, FILTER_VALIDATE_URL ) === false ) {
$all_page_slug = ur_get_all_page_slugs();
if ( in_array( $redirect_url, $all_page_slug, true ) ) {
$redirect_url = site_url( $redirect_url );
}
}
$redirect_url = UR_Shortcodes::check_is_valid_redirect_url( $redirect_url );
$redirect_url = esc_url( $redirect_url );
$redirect_url = ( isset( $_GET['redirect_to'] ) && empty( $redirect_url ) ) ? esc_url( wp_unslash( $_GET['redirect_to'] ) ) : $redirect_url; // @codingStandardsIgnoreLine
$form_id = isset( $atts['form_id'] ) ? absint( $atts['form_id'] ) : 0;
Expand Down

0 comments on commit eec90fa

Please sign in to comment.