PluginProbe
Elementor Website Builder – more than just a page builder / 3.8.0
Elementor Website Builder – more than just a page builder v3.8.0
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / app / modules / import-export / assets / js / hooks / use-plugins-data.js

use-plugins-data.js in Elementor Website Builder – more than just a page builder 3.8.0, at app/modules/import-export/assets/js/hooks/use-plugins-data.js

40 lines 935 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useMemo } from 'react';
2
3 export const PLUGINS_KEYS = Object.freeze( {
4 ELEMENTOR: 'Elementor',
5 ELEMENTOR_PRO: 'Elementor Pro',
6 } );
7
8 export default function usePluginsData( plugins ) {
9 const getPluginsData = () => {
10 if ( ! plugins ) {
11 return [];
12 }
13
14 const elementorPlugins = [],
15 generalPlugins = [];
16
17 plugins.forEach( ( plugin ) => {
18 switch ( plugin.name ) {
19 case PLUGINS_KEYS.ELEMENTOR:
20 // Making sure that the core plugin is always first.
21 elementorPlugins.unshift( plugin );
22 break;
23 case PLUGINS_KEYS.ELEMENTOR_PRO:
24 // Making sure that the pro plugin is always second.
25 elementorPlugins.push( plugin );
26 break;
27 default:
28 generalPlugins.push( plugin );
29 }
30 } );
31
32 // Making sure that the elementor plugins are always first.
33 return elementorPlugins.concat( generalPlugins );
34 };
35
36 return {
37 pluginsData: useMemo( () => getPluginsData(), [ plugins ] ),
38 };
39 }
40