File tree Expand file tree Collapse file tree 7 files changed +55
-10
lines changed
Expand file tree Collapse file tree 7 files changed +55
-10
lines changed Original file line number Diff line number Diff line change 112112<tr>
113113<th scope="row"><?php _e ( 'Collaboration ' ); ?> </th>
114114<td>
115- <label for="wp_collaboration_enabled">
116- <input name="wp_collaboration_enabled" type="checkbox" id="wp_collaboration_enabled" value="1" <?php checked ( '1 ' , (bool ) get_option ( 'wp_collaboration_enabled ' ) ); ?> />
117- <?php _e ( 'Enable real-time collaboration ' ); ?>
118- </label>
115+ <?php if ( ! defined ( 'WP_ALLOW_COLLABORATION ' ) || true === WP_ALLOW_COLLABORATION ) : ?>
116+ <div class="notice notice-warning inline">
117+ <p><?php _e ( '<strong>Note:</strong> Real-time collaboration has been disabled. ' ); ?> </p>
118+ </div>
119+ <?php else : ?>
120+ <label for="wp_collaboration_enabled">
121+ <input name="wp_collaboration_enabled" type="checkbox" id="wp_collaboration_enabled" value="1" <?php checked ( '1 ' , (bool ) get_option ( 'wp_collaboration_enabled ' ) ); ?> />
122+ <?php _e ( 'Enable real-time collaboration ' ); ?>
123+ </label>
124+ <?php endif ; ?>
119125</td>
120126</tr>
121127<?php
Original file line number Diff line number Diff line change 66 * @since 7.0.0
77 */
88
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.0
17+ *
18+ * @return bool Whether real-time collaboration is enabled.
19+ */
20+ function wp_is_collaboration_enabled () {
21+ if ( ! defined ( 'WP_ALLOW_COLLABORATION ' ) || ! WP_ALLOW_COLLABORATION ) {
22+ return false ;
23+ }
24+
25+ return (bool ) get_option ( 'wp_collaboration_enabled ' );
26+ }
27+
928/**
1029 * Injects the real-time collaboration setting into a global variable.
1130 *
1837function wp_collaboration_inject_setting () {
1938 global $ pagenow ;
2039
21- if ( ! ( bool ) get_option ( ' wp_collaboration_enabled ' ) ) {
40+ if ( ! wp_is_collaboration_enabled ( ) ) {
2241 return ;
2342 }
2443
Original file line number Diff line number Diff line change @@ -398,6 +398,26 @@ function wp_functionality_constants() {
398398 if ( ! defined ( 'WP_CRON_LOCK_TIMEOUT ' ) ) {
399399 define ( 'WP_CRON_LOCK_TIMEOUT ' , MINUTE_IN_SECONDS );
400400 }
401+
402+ /**
403+ * Whether real time collaboration is permitted to be enabled.
404+ *
405+ * @since 7.0.0
406+ */
407+ if ( ! defined ( 'WP_ALLOW_COLLABORATION ' ) ) {
408+ $ env_value = getenv ( 'WP_ALLOW_COLLABORATION ' );
409+ if ( false === $ env_value ) {
410+ // Environment variable is not defined, default to allowing collaboration.
411+ define ( 'WP_ALLOW_COLLABORATION ' , true );
412+ } else {
413+ /*
414+ * Environment variable is defined, let's confirm it is actually set to
415+ * "true" as it may still have a string value "false" – the preceeding
416+ * `if` branch only tests for the boolean `false`.
417+ */
418+ define ( 'WP_ALLOW_COLLABORATION ' , 'true ' === $ env_value );
419+ }
420+ }
401421}
402422
403423/**
Original file line number Diff line number Diff line change @@ -657,7 +657,7 @@ function create_initial_post_types() {
657657 )
658658 );
659659
660- if ( ( bool ) get_option ( ' wp_collaboration_enabled ' ) ) {
660+ if ( wp_is_collaboration_enabled ( ) ) {
661661 register_post_type (
662662 'wp_sync_storage ' ,
663663 array (
@@ -8672,7 +8672,7 @@ function wp_create_initial_post_meta() {
86728672 )
86738673 );
86748674
8675- if ( ( bool ) get_option ( ' wp_collaboration_enabled ' ) ) {
8675+ if ( wp_is_collaboration_enabled ( ) ) {
86768676 register_meta (
86778677 'post ' ,
86788678 '_crdt_document ' ,
Original file line number Diff line number Diff line change @@ -430,7 +430,7 @@ function create_initial_rest_routes() {
430430 $ icons_controller ->register_routes ();
431431
432432 // Collaboration.
433- if ( ( bool ) get_option ( ' wp_collaboration_enabled ' ) ) {
433+ if ( wp_is_collaboration_enabled ( ) ) {
434434 $ sync_storage = new WP_Sync_Post_Meta_Storage ();
435435 $ sync_server = new WP_HTTP_Polling_Sync_Server ( $ sync_storage );
436436 $ sync_server ->register_routes ();
Original file line number Diff line number Diff line change @@ -254,7 +254,7 @@ public function create_item( $request ) {
254254 * the saved post. This diff is then applied to the in-memory CRDT
255255 * document, which can lead to duplicate inserts or deletions.
256256 */
257- $ is_collaboration_enabled = ( bool ) get_option ( ' wp_collaboration_enabled ' );
257+ $ is_collaboration_enabled = wp_is_collaboration_enabled ( );
258258
259259 if ( $ is_draft && (int ) $ post ->post_author === $ user_id && ! $ post_lock && ! $ is_collaboration_enabled ) {
260260 /*
Original file line number Diff line number Diff line change 1616 *
1717 * @global string $wp_version
1818 */
19- $ wp_version = '7.0-beta5-62074 ' ;
19+ $ wp_version = '7.0-beta5-62075 ' ;
2020
2121/**
2222 * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
You can’t perform that action at this time.
0 commit comments