WordPress.org

Make WordPress Core

Ticket #31897: customizer-nonce-heartbeat.diff

File customizer-nonce-heartbeat.diff, 1.1 KB (added by joeyblake, 4 years ago)
  • wp-admin/customize.php

     
    5252 */
    5353do_action( 'customize_controls_init' );
    5454
     55//setup heartbeat to keep nonces up to date
     56wp_enqueue_script( 'heartbeat' );
     57
    5558wp_enqueue_script( 'customize-controls' );
    5659wp_enqueue_style( 'customize-controls' );
    5760
  • wp-admin/js/customize-controls.js

     
    29472947                        };
    29482948
    29492949                        /*
     2950                         * Set up heartbeat to refresh the nonces so that if a user leaves
     2951                         * a customizer window open beyond the nonce expiration
     2952                         * saving and previewing will continue to work
     2953                         */
     2954                        $(document ).on('heartbeat-send', $.proxy( function( e ) {
     2955                                this.refreshNonces();
     2956                        }, this ));
     2957
     2958                        /*
    29502959                         * Wrap this.refresh to prevent it from hammering the servers:
    29512960                         *
    29522961                         * If refresh is called once and no other refresh requests are