PluginProbe ʕ •ᴥ•ʔ
Starter Sites & Templates by Neve / trunk
Starter Sites & Templates by Neve vtrunk
1.4.0 1.3.0 1.2.29 1.2.28 1.2.6 1.2.7 1.2.8 1.2.9 trunk 1.0.10 1.0.11 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 1.1.20 1.1.21 1.1.22 1.1.23 1.1.24 1.1.25 1.1.26 1.1.27 1.1.28 1.1.29 1.1.3 1.1.30 1.1.31 1.1.32 1.1.33 1.1.34 1.1.35 1.1.36 1.1.37 1.1.38 1.1.39 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.3 1.2.4 1.2.5
templates-patterns-collection / onboarding / src / utils / common.js
templates-patterns-collection / onboarding / src / utils Last commit date
common.js 2 weeks ago rest.js 2 weeks ago search.js 2 weeks ago site-import.js 2 years ago svg.js 2 weeks ago
common.js
62 lines
1 import { __ } from '@wordpress/i18n';
2
3 const untrailingSlashIt = ( str ) => str.replace( /\/$/, '' );
4 const trailingSlashIt = ( str ) => untrailingSlashIt( str ) + '/';
5
6 const ONBOARDING_CAT = {
7 business: __( 'Business', 'templates-patterns-collection' ),
8 blog: __( 'Blog', 'templates-patterns-collection' ),
9 portfolio: __( 'Portfolio', 'templates-patterns-collection' ),
10 education: __( 'Education', 'templates-patterns-collection' ),
11 woocommerce: __( 'eCommerce', 'templates-patterns-collection' ),
12 news: __( 'News', 'templates-patterns-collection' ),
13 nonprofit: __( 'Non-Profit', 'templates-patterns-collection' ),
14 health: __( 'Health', 'templates-patterns-collection' ),
15 };
16
17 const EDITOR_MAP = {
18 gutenberg: {
19 icon: 'gutenberg.jpg',
20 niceName: 'Gutenberg',
21 },
22 elementor: {
23 icon: 'elementor.jpg',
24 niceName: 'Elementor',
25 },
26 };
27
28 const sendPostMessage = ( data ) => {
29 const frame = document.getElementById( 'ti-ss-preview' );
30 if ( ! frame ) {
31 return;
32 }
33
34 frame.contentWindow.postMessage(
35 {
36 call: 'starterTemplatePreviewDispatch',
37 value: data,
38 },
39 '*'
40 );
41 };
42
43 /**
44 * Convert text to file URL.
45 *
46 * @param {string} text - Text to convert
47 * @return {string} - File URL
48 */
49 const textToFileURL = ( text ) => {
50 const blob = new Blob( [ text ], { type: 'text/plain' } );
51 return URL.createObjectURL( blob );
52 };
53
54 export {
55 trailingSlashIt,
56 untrailingSlashIt,
57 sendPostMessage,
58 EDITOR_MAP,
59 ONBOARDING_CAT,
60 textToFileURL,
61 };
62