PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / form-builder / blocks / src / components / ForceDisableFullscreen.js

ForceDisableFullscreen.js in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 4.0.3, at form-builder/blocks/src/components/ForceDisableFullscreen.js

45 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Keep fullscreen off on PB form CPTs without writing the global
3 * `fullscreenMode` preference. Strip `is-fullscreen-mode` from body and
4 * re-strip on MutationObserver (PB CPTs only).
5 */
6
7 import { useEffect } from '@wordpress/element';
8 import { useSelect } from '@wordpress/data';
9 import { registerPlugin } from '@wordpress/plugins';
10
11 const PB_CPTS = [ 'wppb-rf-cpt', 'wppb-epf-cpt' ];
12 const FULLSCREEN_CLASS = 'is-fullscreen-mode';
13
14 const ForceDisableFullscreen = () => {
15 const postType = useSelect(
16 ( select ) => select( 'core/editor' ).getCurrentPostType(),
17 []
18 );
19 const isOurPostType = PB_CPTS.includes( postType );
20
21 useEffect( () => {
22 if ( ! isOurPostType ) return undefined;
23
24 const body = document.body;
25 if ( ! body ) return undefined;
26
27 const strip = () => {
28 if ( body.classList.contains( FULLSCREEN_CLASS ) ) {
29 body.classList.remove( FULLSCREEN_CLASS );
30 }
31 };
32
33 strip();
34
35 const observer = new MutationObserver( strip );
36 observer.observe( body, { attributes: true, attributeFilter: [ 'class' ] } );
37
38 return () => observer.disconnect();
39 }, [ isOurPostType ] );
40
41 return null;
42 };
43
44 registerPlugin( 'wppb-fb-force-disable-fullscreen', { render: ForceDisableFullscreen } );
45