[wp-hackers] Customizer Return URL

Otto otto at ottodestruct.com
Wed May 20 16:05:04 UTC 2015


The return value should not be a full url, but a relative one.

Look at what happens when you select the "Customize" link in the Appearance
menu from any Admin screen.

If you're looking at the Dashboard, you get this URL:
http://localhost/wp-admin/customize.php?return=%2Fwp-admin%2F

If you're looking at, say, Settings->General, you get this URL:
http://localhost/wp-admin/customize.php?return=%2Fwp-admin%2Foptions-general.php

So, your add_query_arg will work, if you do it like this:

$url = add_query_arg(
   array(
      'url' => urlencode( $login_url ),
      'return' => '/wp-admin/themes.php',
   ),
   admin_url( 'customize.php' )
);


-Otto

On Wed, May 20, 2015 at 10:08 AM, Frank Bueltge <frank at bueltge.de> wrote:

> Hello at all.
>
> I work on examples to use the customizer as standard control for different
> customization topics on front end. But I can't find a solution to change
> the return url, the close icon/button on the customizer.
>
> In the source was asked for a var $return. But how is it possible to change
> this? Maybe a reader can help me.
>
> From the Core, wp-admin/customize.php:
>
> wp_reset_vars( array( 'url', 'return' ) );
> $url = wp_unslash( $url );
> $url = wp_validate_redirect( $url, home_url( '/' ) );
> if ( $return ) {
>     $return = wp_unslash( $return );
>     $return = wp_validate_redirect( $return );
> }
> if ( ! $return ) {
>
> I init the customizer via a menu item below Appearance menu item. I set the
> url on add the menu with the hook 'admin_menu' and filter the link to set a
> new url, my custom url. The url was set via the code below.
>
> // Create specific url for login view
> $login_url = wp_login_url();
> $url = add_query_arg(
>    'url',
>    urlencode( $login_url ),
>    admin_url( 'customize.php' )
> );
>
> Works fine and is also on front end, inside the customizer as return url.
> I have played with the follow source to change the return value.
>
> $url = add_query_arg(
>    'return',
>    admin_url( 'themes.php' )
> );
> I have include this via hook like 'init' or 'customize_register', but no
> changes on this value.
>
> But how can I change the return url?
> Thanks for hints or examples.
> best regards
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list