Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author John Godley

    (@johnny5)

    It is working – it says it is redirecting – it’s just then redirecting in a loop. You haven’t given the URL so I can’t check but you can use https://redirect.li to check the loop. You will need to adjust your redirect so it doesn’t cause the loop.

    Thread Starter karmeljuk

    (@karmeljuk)

    Thank you @johnny5

    As i see the shortcode [dashes]data[/dashes]?– convert any underscores in the data to dashes. So I can’t use it for the plus symbol. Have can I convert pluses into dashes?

    Plugin Author John Godley

    (@johnny5)

    There is no function to do that. If you want you can use one of the hooks described here to make your own function (e.g. redirection_url_target)

    https://redirection.me/developer/wordpress-hooks/

    Thread Starter karmeljuk

    (@karmeljuk)

    Thank you @johnny5

    Is it possible to use my own shortcode in the plugin? I wrote it, but doesn’t work

    function pluses_to_dashes( $attrs, $content, $tag ) {
    
    	if ( $tag === 'pluses' ) {
    		return str_replace( [ '+', ' ' ], '-', $content );
    	}
    
    	return apply_filters( 'redirection_url_transform', '', $tag, $attrs, $content );
    }
    
    add_shortcode( 'pluses', 'pluses_to_dashes' );

    It redirect me to url [pluses]lorem+ipsum[/[pluses]pluses]lorem+ipsum[/pluses]…

    Thread Starter karmeljuk

    (@karmeljuk)

    Hey @johnny5

    Here is my solution:

    /**
     * Redirect old Drupal pages with "+" in the URL
     */
    add_filter( 'redirect_has_pluses', function ( $result, $url ) {
    	if ( strpos( $url, '+' ) !== false ) {
    		$target_url = str_replace("+", "-", $url);
    
    
    		var_dump($target_url);
    
    		wp_safe_redirect( $target_url );
    		exit;
    	}
    
    }, 10, 2 );
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Redirect pages with “+” symbol’ is closed to new replies.