Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/wp-includes/collaboration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,24 @@
* @access private
*/
function wp_collaboration_inject_setting() {
if ( get_option( 'wp_enable_real_time_collaboration' ) ) {
wp_add_inline_script(
'wp-core-data',
'window._wpCollaborationEnabled = true;',
'after'
);
global $pagenow;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add missing doc for global.

@global string $pagenow The filename of the current screen.


if ( ! get_option( 'wp_enable_real_time_collaboration' ) ) {
return;
}

// Disable real-time collaboration on the site editor.
$enabled = true;
if (
'site-editor.php' === $pagenow ||
( 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'site-editor-v2' === $_GET['page'] )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe we have site-editor-v2 in core

) {
$enabled = false;
}

wp_add_inline_script(
'wp-core-data',
'window._wpCollaborationEnabled = ' . ( $enabled ? 'true' : 'false' ) . ';',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using a ternary ( $enabled ? 'true' : 'false' ), using wp_json_encode() is a cleaner, more "standard" way to pass PHP booleans into JavaScript.

'after'
);
}
Loading