-
Notifications
You must be signed in to change notification settings - Fork 0
/
_functions.pug
72 lines (58 loc) · 2.07 KB
/
_functions.pug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
-
function openPopup() {
return "javascript:window.open(this.href,'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;";
}
function bg(text) {
return util.format("background-image: url('%s');", text);
}
function bgFromPHP(text) {
return bg(php(text));
}
function bgFromURL(text) {
return bg(echo(text));
}
function echoImgURLFromField(field, size, id) {
var _size = size ? util.format("'%s'", size) : 'null',
_id = id || 'null';
return echo(util.format("get_image_field_url('%s', %s, %s);",field, _id, _size))
}
function bgFromField(field, id, size) {
return bg(echoImgURLFromField(field, size, id));
}
function echoFeaturedImage(size, isIcon, id){
var _size = size ? "'" + size + "'": 'null',
_isIcon = !!isIcon,
_id = id || 'null';
return echo(util.format("get_post_featured_img(%s, %s, %s)" ,_size , _isIcon, _id))
}
function bgFromFeaturedImage(size, isIcon, id) {
return bg(echoFeaturedImage(size, isIcon, id));
}
function echoField(fieldName, id) {
if(id){
return echo(util.format('get_field("%s", %s);', fieldName, id));
} else {
return echo(util.format('get_field("%s");', fieldName));
}
}
function echoSubField(fieldName) {
return echo(util.format('get_sub_field("%s");', fieldName));
}
function _e(str) {
return php(util.format('_e("%s", "%s");', str, namespace));
}
function _x(str) {
return php(util.format('_x("%s", "%s");', str, namespace));
}
function echo(str) {
return php(util.format('echo %s;', str));
}
function echoThemeMod(str) {
return echo(util.format("get_theme_mod(\"%s\")", str));
}
function php(str) {
return util.format('<?php %s ?>', str);
}
function buildClassListStr(blockClass, classList){
return classList.map(function(className){ return blockClass + '--' + className; }).join(' ');
}