PluginProbe
WP Ultimate Post Grid / 4.0.1
WP Ultimate Post Grid v4.0.1
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / assets / js / admin-template / general / Helpers.js

Helpers.js in WP Ultimate Post Grid 4.0.1, at assets/js/admin-template/general/Helpers.js

79 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 export default {
2 parseCSS(template) {
3 let css = template.style.css;
4
5 // Reconstruct CSS with new value and comments.
6 for ( let property of Object.values(template.style.properties) ) {
7 let fields = '';
8 Object.entries(property).forEach(([field, value]) => {
9 if ( ! ['id', 'name', 'default', 'value', 'options'].includes( field ) ) {
10 fields = ` ${field}=${value}`;
11 }
12 });
13
14 const replacement = `${property.value}; /*wpupg_${property.id}${fields}*/`;
15 css = css.replace( new RegExp( `%wpupg_${property.id}%\s*;`, 'g' ), replacement );
16 }
17
18 return css;
19 },
20 getShortcodeName(id) {
21 let name = id.replace('wpupg-', '');
22 name = name.replace(/-/g, ' ');
23 name = name.toLowerCase().replace(/\b[a-z]/g, function(letter) {
24 return letter.toUpperCase();
25 });
26
27 return name;
28 },
29 getFullShortcode(shortcode) {
30 let fullShortcode = '[' + shortcode.id;
31
32 // Add shortcode attributes.
33 for (let attribute in shortcode.attributes) {
34 if ( shortcode.attributes.hasOwnProperty(attribute) ) {
35 let value = shortcode.attributes[attribute];
36
37 // Replace " and ] with HTML entity to prevent breaking shortcode.
38 value = value.replace(/"/gm, '"');
39 value = value.replace(/\]/gm, ']');
40 fullShortcode += ' ' + attribute + '="' + value + '"';
41 }
42 }
43
44 // Close shortcode.
45 fullShortcode += ']';
46
47 return fullShortcode;
48 },
49 dependencyMet(object, properties) {
50 if (properties && object.hasOwnProperty('dependency')) {
51 let dependencies = object.dependency;
52
53 // Make sure dependencies is an array.
54 if ( ! Array.isArray( dependencies ) ) {
55 dependencies = [dependencies];
56 }
57
58 // Check all dependencies.
59 for ( let dependency of dependencies ) {
60 if ( properties.hasOwnProperty(dependency.id) ) {
61 const dependency_value = properties[dependency.id].value;
62
63 if ( dependency.hasOwnProperty('type') && 'inverse' == dependency.type ) {
64 if (dependency_value == dependency.value) {
65 return false;
66 }
67 } else {
68 if (dependency_value != dependency.value) {
69 return false;
70 }
71 }
72 }
73 }
74 }
75
76 return true;
77 },
78 };
79