PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
← All changes | assets/src/apps/js/blocks/utilBlock.js +47 -47 4.3.94.4.8 View file →
@@ -1,47 +1,47 @@
1 -/**
2 - * Check if the block can be loaded in the current template.
3 - *
4 - * @since 4.2.8.4
5 - * @version 1.0.0
6 - */
7 -import { unregisterBlockType, getBlockType } from '@wordpress/blocks';
8 -import { subscribe, select } from '@wordpress/data';
9 -
10 -let currentPostIdOld = null;
11 -const checkTemplatesCanLoadBlock = ( templates, metadata, callBack ) => {
12 - subscribe( () => {
13 - const metaDataNew = { ...metadata };
14 - const store = select( 'core/editor' ) || null;
15 -
16 - if ( ! store || typeof store.getCurrentPostId !== 'function' || ! store.getCurrentPostId() ) {
17 - return;
18 - }
19 -
20 - const currentPostId = store.getCurrentPostId();
21 -
22 - if ( currentPostId === null ) {
23 - return;
24 - }
25 -
26 - if ( currentPostIdOld === currentPostId ) {
27 - return;
28 - }
29 -
30 - currentPostIdOld = currentPostId;
31 - if ( getBlockType( metaDataNew.name ) ) {
32 - unregisterBlockType( metaDataNew.name );
33 -
34 - if ( templates.includes( currentPostId ) ) {
35 - metaDataNew.ancestor = null;
36 - callBack( metaDataNew );
37 - } else {
38 - if ( ! metaDataNew.ancestor ) {
39 - metaDataNew.ancestor = [];
40 - }
41 - callBack( metaDataNew );
42 - }
43 - }
44 - } );
45 -};
46 -
47 -export { checkTemplatesCanLoadBlock };
1 +/**
2 + * Check if the block can be loaded in the current template.
3 + *
4 + * @since 4.2.8.4
5 + * @version 1.0.0
6 + */
7 +import { unregisterBlockType, getBlockType } from '@wordpress/blocks';
8 +import { subscribe, select } from '@wordpress/data';
9 +
10 +let currentPostIdOld = null;
11 +const checkTemplatesCanLoadBlock = ( templates, metadata, callBack ) => {
12 + subscribe( () => {
13 + const metaDataNew = { ...metadata };
14 + const store = select( 'core/editor' ) || null;
15 +
16 + if ( ! store || typeof store.getCurrentPostId !== 'function' || ! store.getCurrentPostId() ) {
17 + return;
18 + }
19 +
20 + const currentPostId = store.getCurrentPostId();
21 +
22 + if ( currentPostId === null ) {
23 + return;
24 + }
25 +
26 + if ( currentPostIdOld === currentPostId ) {
27 + return;
28 + }
29 +
30 + currentPostIdOld = currentPostId;
31 + if ( getBlockType( metaDataNew.name ) ) {
32 + unregisterBlockType( metaDataNew.name );
33 +
34 + if ( templates.includes( currentPostId ) ) {
35 + metaDataNew.ancestor = null;
36 + callBack( metaDataNew );
37 + } else {
38 + if ( ! metaDataNew.ancestor ) {
39 + metaDataNew.ancestor = [];
40 + }
41 + callBack( metaDataNew );
42 + }
43 + }
44 + } );
45 +};
46 +
47 +export { checkTemplatesCanLoadBlock };