wp_collaboration_inject_setting()WP 7.0.0

Injects the real-time collaboration setting into a global variable.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.

Returns

null. Nothing (null).

Usage

wp_collaboration_inject_setting();

Notes

  • Global. String. $pagenow The filename of the current screen.

Changelog

Since 7.0.0 Introduced.

wp_collaboration_inject_setting() code WP 7.0

function wp_collaboration_inject_setting() {
	global $pagenow;

	if ( ! wp_is_collaboration_enabled() ) {
		return;
	}

	// Disable real-time collaboration on the site editor.
	$enabled = true;
	if ( 'site-editor.php' === $pagenow ) {
		$enabled = false;
	}

	wp_add_inline_script(
		'wp-core-data',
		'window._wpCollaborationEnabled = ' . wp_json_encode( $enabled ) . ';',
		'after'
	);
}