0

I'm looking for a way to alter the href target for the "close" button from the theme customizer. Another question/answer came very close, but in my case the solution used which involved "load-themes.php" doesn't work because the user in question wouldn't have permission to access that page. ( Wordpress Customizer: custom redirection after closing )

Basically the "Close" button now takes the user to a page that tells them they don't have permission to access it. I'd like it to redirect to the main admin page but I'm not sure how to do that. The other solution mentioned using jQuery, but I have NO clue how to do that. I tried messing around with it for a while but I really have no idea what I'm doing at this point. Any help would be greatly appreciated!

1 Answer 1

0

You can try this jQuery script injected via the customize_controls_print_footer_scripts hook:

/**
 * Change the url of the Close link in the /wp-admin/customize.php page
 * See http://wordpress.stackexchange.com/q/116257
 */
function change_close_url_wpse_116257() {
    $url = get_admin_url(); // Edit this to your needs
    printf( "<script>
                jQuery(document).ready( function(){ 
                    jQuery('#customize-header-actions a.back.button').attr('href', '%s'); 
                });
            </script>"
            , esc_js( $url ) );     
}
add_action( 'customize_controls_print_footer_scripts', 'change_close_url_wpse_116257' );
1
  • I filed a Core track ticket #25457 here. My user-experience is that the Theme Customizer feels like a fullscreen popup with a close button. When I close it, I expect to go back to the previous page.
    – birgire
    Commented Dec 30, 2013 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.