PluginProbe
Gutenberg / 21.4.0
Gutenberg v21.4.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / lib / experimental / synchronization.php

synchronization.php in Gutenberg 21.4.0, at lib/experimental/synchronization.php

25 lines 905 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Bootstraps synchronization (collaborative editing).
4 *
5 * @package gutenberg
6 */
7
8 /**
9 * Initializes the collaborative editing secret.
10 */
11 function gutenberg_rest_api_init_collaborative_editing() {
12 $gutenberg_experiments = get_option( 'gutenberg-experiments' );
13 if ( ! $gutenberg_experiments || ! array_key_exists( 'gutenberg-sync-collaboration', $gutenberg_experiments ) ) {
14 return;
15 }
16 $collaborative_editing_secret = get_site_option( 'collaborative_editing_secret' );
17 if ( ! $collaborative_editing_secret ) {
18 $collaborative_editing_secret = wp_generate_password( 64, false );
19 }
20 add_site_option( 'collaborative_editing_secret', $collaborative_editing_secret );
21
22 wp_add_inline_script( 'wp-sync', 'window.__experimentalCollaborativeEditingSecret = "' . $collaborative_editing_secret . '";', 'before' );
23 }
24 add_action( 'admin_init', 'gutenberg_rest_api_init_collaborative_editing' );
25