PluginProbe
Extendify / 0.9.3
Extendify v0.9.3
3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 0.7.0 All 126 releases
extendify / src / Library / util / general.js

general.js in Extendify 0.9.3, at src/Library/util/general.js

61 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from '@wordpress/i18n'
2 import { isString, toLower } from 'lodash'
3 import { useUserStore } from '@library/state/User'
4
5 /**
6 * Will check if the given string contains the search string
7 *
8 * @param {string} string
9 * @param {string} searchString
10 */
11
12 export function search(string, searchString) {
13 // type validation
14 if (!isString(string) || !isString(searchString)) {
15 return false
16 }
17
18 // changing case
19 string = toLower(string)
20 searchString = toLower(searchString)
21
22 // comparing
23 return -1 !== searchString.indexOf(string) ? true : false
24 }
25
26 export const openModal = (source) => setModalVisibility(source, 'open')
27 // export const closeModal = () => setModalVisibility('', 'close')
28 export function setModalVisibility(source = 'broken-event', state = 'open') {
29 useUserStore.setState({
30 entryPoint: source,
31 })
32 window.dispatchEvent(
33 new CustomEvent(`extendify::${state}-library`, {
34 detail: source,
35 bubbles: true,
36 }),
37 )
38 }
39
40 export function getPluginDescription(plugin) {
41 switch (plugin) {
42 case 'editorplus':
43 return 'Editor Plus'
44 case 'ml-slider':
45 return 'MetaSlider'
46 }
47 return plugin
48 }
49
50 export function getTaxonomyName(key) {
51 switch (key) {
52 case 'siteType':
53 return __('Site Type', 'extendify')
54 case 'patternType':
55 return __('Content', 'extendify')
56 case 'layoutType':
57 return __('Page Types', 'extendify')
58 }
59 return key
60 }
61