Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to figure out how exactly I can add a button to the top of the theme customizer. The spot I am talking about is where the "close" and "save" buttons are. The ones that are above everything else and directly above the preview panel.

Would this have to be done through a modification of the core WP files or can it be done through the theme and customizer API itself? If it can be done without modifying the core wordpress files then how can I access it?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

If you take a look at the source code of this part …

do_action( 'customize_controls_print_styles' );
do_action( 'customize_controls_print_scripts' );
?>
</head>
<body class="<?php echo esc_attr( $body_class ); ?>">
<div class="wp-full-overlay expanded">
    <form id="customize-controls" class="wrap wp-full-overlay-sidebar">

        <div id="customize-header-actions" class="wp-full-overlay-header">
            <?php
                $save_text = $wp_customize->is_theme_active() ? __( 'Save &amp; Publish' ) : __( 'Save &amp; Activate' );
                submit_button( $save_text, 'primary save', 'save', false );
            ?>
            <span class="spinner"></span>
            <a class="back button" href="<?php echo esc_url( $return ? $return : admin_url( 'themes.php' ) ); ?>">
                <?php _e( 'Cancel' ); ?>
            </a>
        </div>

… you can see there is no action for this place.

But you can hook into customize_controls_print_scripts and register a new JavaScript that inserts a button.

add_action( 'customize_controls_print_scripts', 'add_customizer_button' );

function add_customizer_button()
{
    wp_register_script( 'my_customizer_script', plugins_url('/customizer_button.js', __FILE__) );
    wp_enqueue_script( 'my_customizer_script' );
}
share|improve this answer
    
Thank you toscho, I wanted to make sure my the code I was using the button for was going to work before hand. I appreciate it. –  user1632018 Apr 24 '13 at 2:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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