mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 15:08:10 +01:00
Customize: Return user to referring URL when leaving Customizer in absence of return
query param.
When referring URL is not available, default returning user to frontend URL instead of admin URL. Themes page is updated to include the `return` path in Customizer links. Props McGuive7, westonruter. Fixes #32637. Built from https://develop.svn.wordpress.org/trunk@35483 git-svn-id: http://core.svn.wordpress.org/trunk@35447 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
10f3ff1753
commit
8fed77574c
@ -525,6 +525,16 @@ function wp_prepare_themes_for_js( $themes = null ) {
|
|||||||
$parents[ $slug ] = $theme->parent()->get_stylesheet();
|
$parents[ $slug ] = $theme->parent()->get_stylesheet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$customize_action = null;
|
||||||
|
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
|
||||||
|
$customize_action = esc_url( add_query_arg(
|
||||||
|
array(
|
||||||
|
'return' => urlencode( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ),
|
||||||
|
),
|
||||||
|
wp_customize_url( $slug )
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
|
||||||
$prepared_themes[ $slug ] = array(
|
$prepared_themes[ $slug ] = array(
|
||||||
'id' => $slug,
|
'id' => $slug,
|
||||||
'name' => $theme->display( 'Name' ),
|
'name' => $theme->display( 'Name' ),
|
||||||
@ -540,7 +550,7 @@ function wp_prepare_themes_for_js( $themes = null ) {
|
|||||||
'update' => get_theme_update_available( $theme ),
|
'update' => get_theme_update_available( $theme ),
|
||||||
'actions' => array(
|
'actions' => array(
|
||||||
'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
|
'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,
|
||||||
'customize' => ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) ? wp_customize_url( $slug ) : null,
|
'customize' => $customize_action,
|
||||||
'delete' => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null,
|
'delete' => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -387,7 +387,7 @@ $can_install = current_user_can( 'install_themes' );
|
|||||||
|
|
||||||
<# if ( data.active ) { #>
|
<# if ( data.active ) { #>
|
||||||
<# if ( data.actions.customize ) { #>
|
<# if ( data.actions.customize ) { #>
|
||||||
<a class="button button-primary customize load-customize hide-if-no-customize" href="{{ data.actions.customize }}"><?php _e( 'Customize' ); ?></a>
|
<a class="button button-primary customize load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Customize' ); ?></a>
|
||||||
<# } #>
|
<# } #>
|
||||||
<# } else { #>
|
<# } else { #>
|
||||||
<a class="button button-secondary activate" href="{{{ data.actions.activate }}}"><?php _e( 'Activate' ); ?></a>
|
<a class="button button-secondary activate" href="{{{ data.actions.activate }}}"><?php _e( 'Activate' ); ?></a>
|
||||||
|
@ -1473,14 +1473,15 @@ final class WP_Customize_Manager {
|
|||||||
* @return string URL for link to close Customizer.
|
* @return string URL for link to close Customizer.
|
||||||
*/
|
*/
|
||||||
public function get_return_url() {
|
public function get_return_url() {
|
||||||
|
$referer = wp_get_referer();
|
||||||
if ( $this->return_url ) {
|
if ( $this->return_url ) {
|
||||||
$return_url = $this->return_url;
|
$return_url = $this->return_url;
|
||||||
|
} else if ( $referer ) {
|
||||||
|
$return_url = $referer;
|
||||||
} else if ( $this->preview_url ) {
|
} else if ( $this->preview_url ) {
|
||||||
$return_url = $this->preview_url;
|
$return_url = $this->preview_url;
|
||||||
} else if ( current_user_can( 'edit_theme_options' ) || current_user_can( 'switch_themes' ) ) {
|
|
||||||
$return_url = admin_url( 'themes.php' );
|
|
||||||
} else {
|
} else {
|
||||||
$return_url = admin_url();
|
$return_url = home_url( '/' );
|
||||||
}
|
}
|
||||||
return $return_url;
|
return $return_url;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-beta2-35482';
|
$wp_version = '4.4-beta2-35483';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user