Customizer Return URL

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Customizer Return URL

Frank Bueltge
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
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Customizer Return URL

Otto-19
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 <[hidden email]> 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
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|

Re: Customizer Return URL

Frank Bueltge
Hello Otto,

thanks, it works!
Now I add this two parameters to the url via

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


Liebe Grüße
Frank
Ⓦ WordPress solution architect
__
http://bueltge.de
http://inpsyde.com
http://multilingualpress.pro
http://marketpress.com

Privat: +49 36428 169305 | Mobil: +49 170 5322053

Inpsyde GmbH, http://inpsyde.com, Mutzer Heide 3, 51467 Bergisch Gladbach
Steuernr: 204/5756/0999, Steueridentnr.: DE263849534
Geschäftsführender Gesellschafter: Heinz Rohé, HRB 65224, Amtsgericht Köln

On Wed, May 20, 2015 at 6:05 PM, Otto <[hidden email]> wrote:

> 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 <[hidden email]> 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
> > [hidden email]
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers