Changeset 62334 for trunk/src/wp-includes/collaboration.php
- Timestamp:
- 05/08/2026 02:03:18 PM (7 weeks ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/collaboration.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/collaboration.php
r62100 r62334 1 <?php2 /**3 * Bootstraps collaborative editing.4 *5 * @package WordPress6 * @since 7.0.07 */8 9 /**10 * Determines whether real-time collaboration is enabled.11 *12 * If the WP_ALLOW_COLLABORATION constant is false,13 * collaboration is always disabled regardless of the database option.14 * Otherwise, falls back to the 'wp_collaboration_enabled' option.15 *16 * @since 7.0.017 *18 * @return bool Whether real-time collaboration is enabled.19 */20 function wp_is_collaboration_enabled() {21 return (22 wp_is_collaboration_allowed() &&23 (bool) get_option( 'wp_collaboration_enabled' )24 );25 }26 27 /**28 * Determines whether real-time collaboration is allowed.29 *30 * If the WP_ALLOW_COLLABORATION constant is false,31 * collaboration is not allowed and cannot be enabled.32 * The constant defaults to true, unless the WP_ALLOW_COLLABORATION33 * environment variable is set to string "false".34 *35 * @since 7.0.036 *37 * @return bool Whether real-time collaboration is enabled.38 */39 function wp_is_collaboration_allowed() {40 if ( ! defined( 'WP_ALLOW_COLLABORATION' ) ) {41 $env_value = getenv( 'WP_ALLOW_COLLABORATION' );42 if ( false === $env_value ) {43 // Environment variable is not defined, default to allowing collaboration.44 define( 'WP_ALLOW_COLLABORATION', true );45 } else {46 /*47 * Environment variable is defined, let's confirm it is actually set to48 * "true" as it may still have a string value "false" – the preceeding49 * `if` branch only tests for the boolean `false`.50 */51 define( 'WP_ALLOW_COLLABORATION', 'true' === $env_value );52 }53 }54 55 return WP_ALLOW_COLLABORATION;56 }57 58 /**59 * Injects the real-time collaboration setting into a global variable.60 *61 * @since 7.0.062 *63 * @access private64 *65 * @global string $pagenow The filename of the current screen.66 */67 function wp_collaboration_inject_setting() {68 global $pagenow;69 70 if ( ! wp_is_collaboration_enabled() ) {71 return;72 }73 74 // Disable real-time collaboration on the site editor.75 $enabled = true;76 if ( 'site-editor.php' === $pagenow ) {77 $enabled = false;78 }79 80 wp_add_inline_script(81 'wp-core-data',82 'window._wpCollaborationEnabled = ' . wp_json_encode( $enabled ) . ';',83 'after'84 );85 }
Note: See TracChangeset
for help on using the changeset viewer.