wp_heartbeat_settings() WordPress Function

The wp_heartbeat_settings() function allows you to modify the way that the WordPress Heartbeat API works. This function is useful for plugins and themes that need to change the default behavior of the API.

wp_heartbeat_settings( array $settings ) #

Default settings for heartbeat


Description

Outputs the nonce used in the heartbeat XHR


Top ↑

Parameters

$settings

(array)(Required)


Top ↑

Return

(array) Heartbeat settings.


Top ↑

Source

File: wp-includes/general-template.php

function wp_heartbeat_settings( $settings ) {
	if ( ! is_admin() ) {
		$settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' );
	}

	if ( is_user_logged_in() ) {
		$settings['nonce'] = wp_create_nonce( 'heartbeat-nonce' );
	}

	return $settings;
}


Top ↑

Changelog

Changelog
VersionDescription
3.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More