File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,6 +81,30 @@ function wp_revisions_are_globally_supported() {
8181 return 0 !== (int ) WP_POST_REVISIONS ;
8282}
8383
84+ /**
85+ * Determines whether real-time collaboration is disabled for a post type.
86+ *
87+ * @since 7.1.0
88+ *
89+ * @param string $post_type Post type name.
90+ * @return bool Whether real-time collaboration is disabled for the post type.
91+ */
92+ function wp_is_post_type_collaboration_disabled ( $ post_type ) {
93+ if ( ! post_type_exists ( $ post_type ) ) {
94+ return true ;
95+ }
96+
97+ /**
98+ * Filters whether real-time collaboration is disabled for a post type.
99+ *
100+ * @since 7.1.0
101+ *
102+ * @param bool $disabled Whether real-time collaboration is disabled for the post type.
103+ * @param string $post_type Post type name.
104+ */
105+ return (bool ) apply_filters ( 'wp_is_post_type_collaboration_disabled ' , false , $ post_type );
106+ }
107+
84108/**
85109 * Injects the real-time collaboration setting into a global variable.
86110 *
@@ -103,9 +127,17 @@ function wp_collaboration_inject_setting() {
103127 $ enabled = false ;
104128 }
105129
130+ $ disabled_post_types = array_values (
131+ array_filter (
132+ get_post_types ( array ( 'show_in_rest ' => true ) ),
133+ 'wp_is_post_type_collaboration_disabled '
134+ )
135+ );
136+
106137 wp_add_inline_script (
107138 'wp-core-data ' ,
108- 'window._wpCollaborationEnabled = ' . wp_json_encode ( $ enabled ) . '; ' ,
139+ 'window._wpCollaborationEnabled = ' . wp_json_encode ( $ enabled ) . '; ' .
140+ 'window._wpCollaborationDisabledPostTypes = ' . wp_json_encode ( $ disabled_post_types ) . '; ' ,
109141 'after '
110142 );
111143}
You can’t perform that action at this time.
0 commit comments