Initial commit
This commit is contained in:
337
wp-content/plugins/gp-premium/elements/assets/admin/balloon.css
Normal file
337
wp-content/plugins/gp-premium/elements/assets/admin/balloon.css
Normal file
@ -0,0 +1,337 @@
|
||||
button[data-balloon] {
|
||||
overflow: visible; }
|
||||
|
||||
[data-balloon] {
|
||||
position: relative;
|
||||
cursor: pointer; }
|
||||
[data-balloon]:after {
|
||||
filter: alpha(opacity=0);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||
-moz-opacity: 0;
|
||||
-khtml-opacity: 0;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
-webkit-transition: all 0.18s ease-out 0.18s;
|
||||
-moz-transition: all 0.18s ease-out 0.18s;
|
||||
-ms-transition: all 0.18s ease-out 0.18s;
|
||||
-o-transition: all 0.18s ease-out 0.18s;
|
||||
transition: all 0.18s ease-out 0.18s;
|
||||
font-weight: normal !important;
|
||||
font-style: normal !important;
|
||||
text-shadow: none !important;
|
||||
font-size: 12px !important;
|
||||
background: rgba(17, 17, 17, 0.9);
|
||||
border-radius: 4px;
|
||||
color: #fff;
|
||||
content: attr(data-balloon);
|
||||
padding: .5em 1em;
|
||||
position: absolute;
|
||||
white-space: nowrap;
|
||||
z-index: 10; }
|
||||
[data-balloon]:before {
|
||||
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(0)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
|
||||
background-size: 100% auto;
|
||||
width: 18px;
|
||||
height: 6px;
|
||||
filter: alpha(opacity=0);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||
-moz-opacity: 0;
|
||||
-khtml-opacity: 0;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
-webkit-transition: all 0.18s ease-out 0.18s;
|
||||
-moz-transition: all 0.18s ease-out 0.18s;
|
||||
-ms-transition: all 0.18s ease-out 0.18s;
|
||||
-o-transition: all 0.18s ease-out 0.18s;
|
||||
transition: all 0.18s ease-out 0.18s;
|
||||
content: '';
|
||||
position: absolute;
|
||||
z-index: 10; }
|
||||
[data-balloon]:hover:before, [data-balloon]:hover:after, [data-balloon][data-balloon-visible]:before, [data-balloon][data-balloon-visible]:after {
|
||||
filter: alpha(opacity=100);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
|
||||
-moz-opacity: 1;
|
||||
-khtml-opacity: 1;
|
||||
opacity: 1;
|
||||
pointer-events: auto; }
|
||||
[data-balloon].font-awesome:after {
|
||||
font-family: FontAwesome; }
|
||||
[data-balloon][data-balloon-break]:after {
|
||||
white-space: pre; }
|
||||
[data-balloon][data-balloon-blunt]:before, [data-balloon][data-balloon-blunt]:after {
|
||||
-webkit-transition: none;
|
||||
-moz-transition: none;
|
||||
-ms-transition: none;
|
||||
-o-transition: none;
|
||||
transition: none; }
|
||||
[data-balloon][data-balloon-pos="up"]:after {
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
margin-bottom: 11px;
|
||||
-webkit-transform: translate(-50%, 10px);
|
||||
-moz-transform: translate(-50%, 10px);
|
||||
-ms-transform: translate(-50%, 10px);
|
||||
transform: translate(-50%, 10px);
|
||||
-webkit-transform-origin: top;
|
||||
-moz-transform-origin: top;
|
||||
-ms-transform-origin: top;
|
||||
transform-origin: top; }
|
||||
[data-balloon][data-balloon-pos="up"]:before {
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
margin-bottom: 5px;
|
||||
-webkit-transform: translate(-50%, 10px);
|
||||
-moz-transform: translate(-50%, 10px);
|
||||
-ms-transform: translate(-50%, 10px);
|
||||
transform: translate(-50%, 10px);
|
||||
-webkit-transform-origin: top;
|
||||
-moz-transform-origin: top;
|
||||
-ms-transform-origin: top;
|
||||
transform-origin: top; }
|
||||
[data-balloon][data-balloon-pos="up"]:hover:after, [data-balloon][data-balloon-pos="up"][data-balloon-visible]:after {
|
||||
-webkit-transform: translate(-50%, 0);
|
||||
-moz-transform: translate(-50%, 0);
|
||||
-ms-transform: translate(-50%, 0);
|
||||
transform: translate(-50%, 0); }
|
||||
[data-balloon][data-balloon-pos="up"]:hover:before, [data-balloon][data-balloon-pos="up"][data-balloon-visible]:before {
|
||||
-webkit-transform: translate(-50%, 0);
|
||||
-moz-transform: translate(-50%, 0);
|
||||
-ms-transform: translate(-50%, 0);
|
||||
transform: translate(-50%, 0); }
|
||||
[data-balloon][data-balloon-pos="up-left"]:after {
|
||||
bottom: 100%;
|
||||
left: 0;
|
||||
margin-bottom: 11px;
|
||||
-webkit-transform: translate(0, 10px);
|
||||
-moz-transform: translate(0, 10px);
|
||||
-ms-transform: translate(0, 10px);
|
||||
transform: translate(0, 10px);
|
||||
-webkit-transform-origin: top;
|
||||
-moz-transform-origin: top;
|
||||
-ms-transform-origin: top;
|
||||
transform-origin: top; }
|
||||
[data-balloon][data-balloon-pos="up-left"]:before {
|
||||
bottom: 100%;
|
||||
left: 5px;
|
||||
margin-bottom: 5px;
|
||||
-webkit-transform: translate(0, 10px);
|
||||
-moz-transform: translate(0, 10px);
|
||||
-ms-transform: translate(0, 10px);
|
||||
transform: translate(0, 10px);
|
||||
-webkit-transform-origin: top;
|
||||
-moz-transform-origin: top;
|
||||
-ms-transform-origin: top;
|
||||
transform-origin: top; }
|
||||
[data-balloon][data-balloon-pos="up-left"]:hover:after, [data-balloon][data-balloon-pos="up-left"][data-balloon-visible]:after {
|
||||
-webkit-transform: translate(0, 0);
|
||||
-moz-transform: translate(0, 0);
|
||||
-ms-transform: translate(0, 0);
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos="up-left"]:hover:before, [data-balloon][data-balloon-pos="up-left"][data-balloon-visible]:before {
|
||||
-webkit-transform: translate(0, 0);
|
||||
-moz-transform: translate(0, 0);
|
||||
-ms-transform: translate(0, 0);
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos="up-right"]:after {
|
||||
bottom: 100%;
|
||||
right: 0;
|
||||
margin-bottom: 11px;
|
||||
-webkit-transform: translate(0, 10px);
|
||||
-moz-transform: translate(0, 10px);
|
||||
-ms-transform: translate(0, 10px);
|
||||
transform: translate(0, 10px);
|
||||
-webkit-transform-origin: top;
|
||||
-moz-transform-origin: top;
|
||||
-ms-transform-origin: top;
|
||||
transform-origin: top; }
|
||||
[data-balloon][data-balloon-pos="up-right"]:before {
|
||||
bottom: 100%;
|
||||
right: 5px;
|
||||
margin-bottom: 5px;
|
||||
-webkit-transform: translate(0, 10px);
|
||||
-moz-transform: translate(0, 10px);
|
||||
-ms-transform: translate(0, 10px);
|
||||
transform: translate(0, 10px);
|
||||
-webkit-transform-origin: top;
|
||||
-moz-transform-origin: top;
|
||||
-ms-transform-origin: top;
|
||||
transform-origin: top; }
|
||||
[data-balloon][data-balloon-pos="up-right"]:hover:after, [data-balloon][data-balloon-pos="up-right"][data-balloon-visible]:after {
|
||||
-webkit-transform: translate(0, 0);
|
||||
-moz-transform: translate(0, 0);
|
||||
-ms-transform: translate(0, 0);
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos="up-right"]:hover:before, [data-balloon][data-balloon-pos="up-right"][data-balloon-visible]:before {
|
||||
-webkit-transform: translate(0, 0);
|
||||
-moz-transform: translate(0, 0);
|
||||
-ms-transform: translate(0, 0);
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos='down']:after {
|
||||
left: 50%;
|
||||
margin-top: 11px;
|
||||
top: 100%;
|
||||
-webkit-transform: translate(-50%, -10px);
|
||||
-moz-transform: translate(-50%, -10px);
|
||||
-ms-transform: translate(-50%, -10px);
|
||||
transform: translate(-50%, -10px); }
|
||||
[data-balloon][data-balloon-pos='down']:before {
|
||||
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
|
||||
background-size: 100% auto;
|
||||
width: 18px;
|
||||
height: 6px;
|
||||
left: 50%;
|
||||
margin-top: 5px;
|
||||
top: 100%;
|
||||
-webkit-transform: translate(-50%, -10px);
|
||||
-moz-transform: translate(-50%, -10px);
|
||||
-ms-transform: translate(-50%, -10px);
|
||||
transform: translate(-50%, -10px); }
|
||||
[data-balloon][data-balloon-pos='down']:hover:after, [data-balloon][data-balloon-pos='down'][data-balloon-visible]:after {
|
||||
-webkit-transform: translate(-50%, 0);
|
||||
-moz-transform: translate(-50%, 0);
|
||||
-ms-transform: translate(-50%, 0);
|
||||
transform: translate(-50%, 0); }
|
||||
[data-balloon][data-balloon-pos='down']:hover:before, [data-balloon][data-balloon-pos='down'][data-balloon-visible]:before {
|
||||
-webkit-transform: translate(-50%, 0);
|
||||
-moz-transform: translate(-50%, 0);
|
||||
-ms-transform: translate(-50%, 0);
|
||||
transform: translate(-50%, 0); }
|
||||
[data-balloon][data-balloon-pos='down-left']:after {
|
||||
left: 0;
|
||||
margin-top: 11px;
|
||||
top: 100%;
|
||||
-webkit-transform: translate(0, -10px);
|
||||
-moz-transform: translate(0, -10px);
|
||||
-ms-transform: translate(0, -10px);
|
||||
transform: translate(0, -10px); }
|
||||
[data-balloon][data-balloon-pos='down-left']:before {
|
||||
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
|
||||
background-size: 100% auto;
|
||||
width: 18px;
|
||||
height: 6px;
|
||||
left: 5px;
|
||||
margin-top: 5px;
|
||||
top: 100%;
|
||||
-webkit-transform: translate(0, -10px);
|
||||
-moz-transform: translate(0, -10px);
|
||||
-ms-transform: translate(0, -10px);
|
||||
transform: translate(0, -10px); }
|
||||
[data-balloon][data-balloon-pos='down-left']:hover:after, [data-balloon][data-balloon-pos='down-left'][data-balloon-visible]:after {
|
||||
-webkit-transform: translate(0, 0);
|
||||
-moz-transform: translate(0, 0);
|
||||
-ms-transform: translate(0, 0);
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos='down-left']:hover:before, [data-balloon][data-balloon-pos='down-left'][data-balloon-visible]:before {
|
||||
-webkit-transform: translate(0, 0);
|
||||
-moz-transform: translate(0, 0);
|
||||
-ms-transform: translate(0, 0);
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos='down-right']:after {
|
||||
right: 0;
|
||||
margin-top: 11px;
|
||||
top: 100%;
|
||||
-webkit-transform: translate(0, -10px);
|
||||
-moz-transform: translate(0, -10px);
|
||||
-ms-transform: translate(0, -10px);
|
||||
transform: translate(0, -10px); }
|
||||
[data-balloon][data-balloon-pos='down-right']:before {
|
||||
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
|
||||
background-size: 100% auto;
|
||||
width: 18px;
|
||||
height: 6px;
|
||||
right: 5px;
|
||||
margin-top: 5px;
|
||||
top: 100%;
|
||||
-webkit-transform: translate(0, -10px);
|
||||
-moz-transform: translate(0, -10px);
|
||||
-ms-transform: translate(0, -10px);
|
||||
transform: translate(0, -10px); }
|
||||
[data-balloon][data-balloon-pos='down-right']:hover:after, [data-balloon][data-balloon-pos='down-right'][data-balloon-visible]:after {
|
||||
-webkit-transform: translate(0, 0);
|
||||
-moz-transform: translate(0, 0);
|
||||
-ms-transform: translate(0, 0);
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos='down-right']:hover:before, [data-balloon][data-balloon-pos='down-right'][data-balloon-visible]:before {
|
||||
-webkit-transform: translate(0, 0);
|
||||
-moz-transform: translate(0, 0);
|
||||
-ms-transform: translate(0, 0);
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos='left']:after {
|
||||
margin-right: 11px;
|
||||
right: 100%;
|
||||
top: 50%;
|
||||
-webkit-transform: translate(10px, -50%);
|
||||
-moz-transform: translate(10px, -50%);
|
||||
-ms-transform: translate(10px, -50%);
|
||||
transform: translate(10px, -50%); }
|
||||
[data-balloon][data-balloon-pos='left']:before {
|
||||
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(-90 18 18)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
|
||||
background-size: 100% auto;
|
||||
width: 6px;
|
||||
height: 18px;
|
||||
margin-right: 5px;
|
||||
right: 100%;
|
||||
top: 50%;
|
||||
-webkit-transform: translate(10px, -50%);
|
||||
-moz-transform: translate(10px, -50%);
|
||||
-ms-transform: translate(10px, -50%);
|
||||
transform: translate(10px, -50%); }
|
||||
[data-balloon][data-balloon-pos='left']:hover:after, [data-balloon][data-balloon-pos='left'][data-balloon-visible]:after {
|
||||
-webkit-transform: translate(0, -50%);
|
||||
-moz-transform: translate(0, -50%);
|
||||
-ms-transform: translate(0, -50%);
|
||||
transform: translate(0, -50%); }
|
||||
[data-balloon][data-balloon-pos='left']:hover:before, [data-balloon][data-balloon-pos='left'][data-balloon-visible]:before {
|
||||
-webkit-transform: translate(0, -50%);
|
||||
-moz-transform: translate(0, -50%);
|
||||
-ms-transform: translate(0, -50%);
|
||||
transform: translate(0, -50%); }
|
||||
[data-balloon][data-balloon-pos='right']:after {
|
||||
left: 100%;
|
||||
margin-left: 11px;
|
||||
top: 50%;
|
||||
-webkit-transform: translate(-10px, -50%);
|
||||
-moz-transform: translate(-10px, -50%);
|
||||
-ms-transform: translate(-10px, -50%);
|
||||
transform: translate(-10px, -50%); }
|
||||
[data-balloon][data-balloon-pos='right']:before {
|
||||
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(90 6 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
|
||||
background-size: 100% auto;
|
||||
width: 6px;
|
||||
height: 18px;
|
||||
left: 100%;
|
||||
margin-left: 5px;
|
||||
top: 50%;
|
||||
-webkit-transform: translate(-10px, -50%);
|
||||
-moz-transform: translate(-10px, -50%);
|
||||
-ms-transform: translate(-10px, -50%);
|
||||
transform: translate(-10px, -50%); }
|
||||
[data-balloon][data-balloon-pos='right']:hover:after, [data-balloon][data-balloon-pos='right'][data-balloon-visible]:after {
|
||||
-webkit-transform: translate(0, -50%);
|
||||
-moz-transform: translate(0, -50%);
|
||||
-ms-transform: translate(0, -50%);
|
||||
transform: translate(0, -50%); }
|
||||
[data-balloon][data-balloon-pos='right']:hover:before, [data-balloon][data-balloon-pos='right'][data-balloon-visible]:before {
|
||||
-webkit-transform: translate(0, -50%);
|
||||
-moz-transform: translate(0, -50%);
|
||||
-ms-transform: translate(0, -50%);
|
||||
transform: translate(0, -50%); }
|
||||
[data-balloon][data-balloon-length='small']:after {
|
||||
white-space: normal;
|
||||
width: 80px; }
|
||||
[data-balloon][data-balloon-length='medium']:after {
|
||||
white-space: normal;
|
||||
width: 150px; }
|
||||
[data-balloon][data-balloon-length='large']:after {
|
||||
white-space: normal;
|
||||
width: 260px; }
|
||||
[data-balloon][data-balloon-length='xlarge']:after {
|
||||
white-space: normal;
|
||||
width: 380px; }
|
||||
@media screen and (max-width: 768px) {
|
||||
[data-balloon][data-balloon-length='xlarge']:after {
|
||||
white-space: normal;
|
||||
width: 90vw; } }
|
||||
[data-balloon][data-balloon-length='fit']:after {
|
||||
white-space: normal;
|
||||
width: 100%; }
|
446
wp-content/plugins/gp-premium/elements/assets/admin/metabox.css
Normal file
446
wp-content/plugins/gp-premium/elements/assets/admin/metabox.css
Normal file
@ -0,0 +1,446 @@
|
||||
.no-element-type #titlediv,
|
||||
.no-element-type h1.wp-heading-inline,
|
||||
.no-element-type h1.wp-heading-inline + .page-title-action,
|
||||
.no-element-type #submitdiv,
|
||||
.no-element-type .postbox:not(#generate_premium_elements),
|
||||
.no-element-type .notice,
|
||||
.no-element-type .error,
|
||||
.element-settings.no-element-type {
|
||||
opacity: 0;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#generate_premium_elements {
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
box-shadow: 0 0 0;
|
||||
}
|
||||
|
||||
#generate_premium_elements .inside {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#generate_premium_elements .CodeMirror {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
background: white;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
tr.generate-element-row td {
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
zoom: 1;
|
||||
}
|
||||
|
||||
td.generate-element-row-heading {
|
||||
background: #F9F9F9;
|
||||
border-right: 1px solid #E1E1E1;
|
||||
padding: 13px 15px;
|
||||
width: 24%;
|
||||
}
|
||||
|
||||
td.generate-element-row-heading label {
|
||||
display: inline-block;
|
||||
font-size: 13px;
|
||||
line-height: 1.4em;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 0 0 3px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
td.generate-element-row-content {
|
||||
padding: 13px 15px;
|
||||
position: relative;
|
||||
width: 75%;
|
||||
}
|
||||
|
||||
#generate_premium_elements .handlediv,
|
||||
#generate_premium_elements .hndle {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#generate_premium_elements .inside {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#generate_premium_elements select,
|
||||
#generate_premium_elements input[type="number"],
|
||||
#generate_premium_elements input[type="text"] {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#generate_premium_elements .condition select.condition-object-select + .select2 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#generate_premium_elements .condition.generate-elements-rule-objects-visible select.condition-select + .select2 {
|
||||
margin-right: 5px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#generate_premium_elements .condition.generate-elements-rule-objects-visible select.condition-object-select + .select2 {
|
||||
display: inline-block;
|
||||
margin-left: 5px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#generate_premium_elements .condition {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#generate_premium_elements .condition .select2 {
|
||||
-webkit-box-flex: 1;
|
||||
-ms-flex-positive: 1;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
button.remove-condition {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
line-height: 1;
|
||||
width: 30px;
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
opacity: 0.5;
|
||||
position: relative;
|
||||
bottom: -3px;
|
||||
}
|
||||
|
||||
button.add-condition {
|
||||
margin-top: 10px !important;
|
||||
}
|
||||
|
||||
button.remove-condition:before {
|
||||
content: "\f153";
|
||||
font-family: dashicons;
|
||||
}
|
||||
|
||||
table.generate-elements-settings {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
background: white;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.generate-element-row-loading {
|
||||
background-color: rgba(255,255,255,0.9);
|
||||
background-image: url('spinner.gif');
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
ul.element-metabox-tabs {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
margin: 0 0 20px;
|
||||
background: white;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
ul.element-metabox-tabs li {
|
||||
width: auto;
|
||||
-ms-flex: none;
|
||||
flex: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
border-top: none;
|
||||
text-align: center;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
ul.element-metabox-tabs li a {
|
||||
display: block;
|
||||
width: auto;
|
||||
padding: 16px 16px 14px 16px;
|
||||
color: #0087be;
|
||||
font-weight: 400;
|
||||
text-decoration: none;
|
||||
box-shadow: 0 0 0;
|
||||
}
|
||||
|
||||
ul.element-metabox-tabs li a:hover {
|
||||
color: #00a0d2;
|
||||
}
|
||||
|
||||
ul.element-metabox-tabs li.is-selected {
|
||||
border-bottom-color: #2e4453;
|
||||
}
|
||||
|
||||
ul.element-metabox-tabs li.is-selected a {
|
||||
color: #2e4453;
|
||||
}
|
||||
|
||||
#generate-element-content,
|
||||
#generate-element-content + .CodeMirror {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
select.select-type {
|
||||
position: relative;
|
||||
padding: 10px 15px;
|
||||
margin: 0;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
height: auto;
|
||||
border: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
select.select-type:hover {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.dark-mode select.select-type:hover {
|
||||
background-color: #23282d;
|
||||
}
|
||||
|
||||
.element-metabox-tabs li:not([data-tab="display-rules"]):not([data-tab="internal-notes"]),
|
||||
.generate-elements-settings:not([data-tab="display-rules"]):not([data-tab="internal-notes"]) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.element-settings.header .element-metabox-tabs li[data-type="header"],
|
||||
.element-settings.hook .element-metabox-tabs li[data-type="hook"],
|
||||
.element-settings.layout .element-metabox-tabs li[data-type="layout"] {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.element-settings.header table[data-tab="hero"],
|
||||
.element-settings.hook table[data-tab="hook-settings"],
|
||||
.element-settings.layout table[data-tab="sidebars"] {
|
||||
display: table;
|
||||
}
|
||||
|
||||
.element-settings.layout #generate-element-content {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.padding-container {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.single-value-padding-container {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.single-value-padding-container input[type="number"] {
|
||||
width: 60px !important;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.padding-element span.unit {
|
||||
border: 1px solid #ddd;
|
||||
display: inline-block;
|
||||
line-height: 26px;
|
||||
padding: 0 10px;
|
||||
margin-left: -5px;
|
||||
vertical-align: middle;
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
.padding-element input {
|
||||
width: 60px !important;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
.padding-element select {
|
||||
width: auto !important;
|
||||
position: relative;
|
||||
top: -2.5px;
|
||||
left: -5px;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
.padding-element span {
|
||||
display: block;
|
||||
font-size: 90%;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.generate-element-row-content .responsive-controls.single-responsive-value {
|
||||
padding: 8px 15px 7px 0;
|
||||
}
|
||||
|
||||
.generate-element-row-content .responsive-controls.checkbox-responsive-value {
|
||||
padding: 2px 15px 0 0;
|
||||
}
|
||||
|
||||
#postimagediv {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.image-preview img {
|
||||
height: 30px;
|
||||
width: auto;
|
||||
vertical-align: middle;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.gp-media-preview img {
|
||||
vertical-align: middle;
|
||||
background-color: #efefef;
|
||||
border-radius: 5px;
|
||||
height: 30px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.media-container,
|
||||
.change-featured-image,
|
||||
.set-featured-image {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.media-container > input,
|
||||
.media-container .gp-media-preview img,
|
||||
.change-featured-image > *,
|
||||
.set-featured-image > * {
|
||||
margin-right: 10px !important;
|
||||
}
|
||||
|
||||
.generate-element-row-content .responsive-controls {
|
||||
float: left;
|
||||
padding: 15px 15px 15px 0;
|
||||
}
|
||||
|
||||
.generate-element-row-content .responsive-controls a {
|
||||
text-decoration: none;
|
||||
color: #222;
|
||||
opacity: 0.5;
|
||||
outline: 0;
|
||||
box-shadow: 0 0 0;
|
||||
}
|
||||
|
||||
.generate-element-row-content .responsive-controls a.is-selected {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.generate-element-row-content .responsive-controls a span {
|
||||
font-size: 14px;
|
||||
width: auto;
|
||||
height: auto;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
#generate-element-content {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
.choose-element-type-parent:before {
|
||||
content: "";
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.choose-element-type {
|
||||
position: fixed;
|
||||
width: 500px;
|
||||
background: #fff;
|
||||
left: calc(50% - 250px);
|
||||
padding: 50px;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 0 20px rgba(0,0,0,0.05);
|
||||
border: 1px solid #ddd;
|
||||
z-index: 11;
|
||||
}
|
||||
|
||||
#poststuff .choose-element-type h2 {
|
||||
font-size: 30px;
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
padding: 0;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.layout-radio-item {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.layout-radio-item:first-child {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
span.tip {
|
||||
display: inline-block;
|
||||
float: right;
|
||||
background: #b3b3b3;
|
||||
height: 15px;
|
||||
width: 15px;
|
||||
text-align: center;
|
||||
line-height: 15px;
|
||||
color: #fff;
|
||||
border-radius: 50%;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
body:not(.header-element-type) #generate_page_hero_template_tags {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#_generate_element_internal_notes {
|
||||
width: 100%;
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
.select2-results__option {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body .select2-container--default .select2-selection--single {
|
||||
border-color: #ddd;
|
||||
}
|
||||
|
||||
.select2-results__option[role="list"] {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#generate_premium_elements #_generate_content_width {
|
||||
width: 65px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#_generate_content_width + span {
|
||||
border: 1px solid #ddd;
|
||||
height: 26px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
line-height: 26px;
|
||||
padding: 0 10px;
|
||||
margin-left: -6px;
|
||||
}
|
||||
|
||||
.generate-element-row-content .color-alpha {
|
||||
height: 100% !important;
|
||||
}
|
386
wp-content/plugins/gp-premium/elements/assets/admin/metabox.js
Normal file
386
wp-content/plugins/gp-premium/elements/assets/admin/metabox.js
Normal file
@ -0,0 +1,386 @@
|
||||
jQuery(document).ready(function( $ ) {
|
||||
if ( $( '.element-settings' ).hasClass( 'header' ) || $( '.element-settings' ).hasClass( 'hook' ) ) {
|
||||
$( function() {
|
||||
if ( elements.settings) {
|
||||
wp.codeEditor.initialize( "generate-element-content", elements.settings );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
if ( $( '.choose-element-type-parent' ).is( ':visible' ) ) {
|
||||
$( '.select-type' ).focus();
|
||||
}
|
||||
|
||||
$( 'select[name="_generate_element_type"]' ).on( 'change', function() {
|
||||
var _this = $( this ),
|
||||
element = _this.val();
|
||||
|
||||
if ( '' == element ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$( '.element-settings' ).addClass( element ).removeClass( 'no-element-type' ).css( 'opacity', '' );
|
||||
$( 'body' ).removeClass( 'no-element-type' );
|
||||
|
||||
var active_tab = $( '.element-metabox-tabs' ).find( 'li:visible:first' );
|
||||
active_tab.addClass( 'is-selected' );
|
||||
$( '.generate-elements-settings[data-tab="' + active_tab.attr( 'data-tab' ) + '"]' ).show();
|
||||
|
||||
if ( 'layout' === element ) {
|
||||
$( '#generate-element-content' ).hide();
|
||||
}
|
||||
|
||||
if ( 'header' === element ) {
|
||||
$( 'body' ).addClass( 'header-element-type' );
|
||||
}
|
||||
|
||||
if ( elements.settings && 'layout' !== element ) {
|
||||
$( function() {
|
||||
wp.codeEditor.initialize( "generate-element-content", elements.settings );
|
||||
} );
|
||||
}
|
||||
|
||||
_this.closest( '.choose-element-type-parent' ).hide();
|
||||
} );
|
||||
|
||||
$( '#_generate_hook' ).on( 'change', function() {
|
||||
var _this = $( this );
|
||||
|
||||
$( '.disable-header-hook' ).hide();
|
||||
$( '.disable-footer-hook' ).hide();
|
||||
$( '.custom-hook-name' ).hide();
|
||||
|
||||
if ( 'generate_header' === _this.val() ) {
|
||||
$( '.disable-header-hook' ).show();
|
||||
}
|
||||
|
||||
if ( 'generate_footer' === _this.val() ) {
|
||||
$( '.disable-footer-hook' ).show();
|
||||
}
|
||||
|
||||
if ( 'custom' === _this.val() ) {
|
||||
$( '.custom-hook-name' ).show();
|
||||
}
|
||||
} );
|
||||
|
||||
$( '#_generate_hook' ).select2( {
|
||||
width: '100%'
|
||||
} );
|
||||
|
||||
$( '.element-metabox-tabs li' ).on( 'click', function() {
|
||||
var _this = $( this ),
|
||||
tab = _this.data( 'tab' );
|
||||
|
||||
_this.siblings().removeClass( 'is-selected' );
|
||||
_this.addClass( 'is-selected' );
|
||||
$( '.generate-elements-settings' ).hide();
|
||||
$( '.generate-elements-settings[data-tab="' + tab + '"]' ).show();
|
||||
|
||||
if ( $( '.element-settings' ).hasClass( 'header' ) ) {
|
||||
if ( 'hero' !== tab ) {
|
||||
$( '#generate-element-content' ).next( '.CodeMirror' ).hide();
|
||||
} else {
|
||||
$( '#generate-element-content' ).next( '.CodeMirror' ).show();
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
var select2Init = function() {
|
||||
var selects = $( '.generate-element-row-content .condition:not(.hidden) select:not(.select2-init)' );
|
||||
|
||||
selects.each( function() {
|
||||
var select = $( this ),
|
||||
config = {
|
||||
width: 'style'
|
||||
};
|
||||
|
||||
select.select2( config );
|
||||
select.addClass( 'select2-init' );
|
||||
} );
|
||||
};
|
||||
|
||||
select2Init();
|
||||
|
||||
$( '.add-condition' ).on( 'click', function() {
|
||||
var _this = $( this );
|
||||
|
||||
var row = _this.closest( '.generate-element-row-content' ).find( '.condition.hidden.screen-reader-text' ).clone(true);
|
||||
row.removeClass( 'hidden screen-reader-text' );
|
||||
row.insertBefore( _this.closest( '.generate-element-row-content' ).find( '.condition:last' ) );
|
||||
|
||||
select2Init();
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$( '.remove-condition' ).on('click', function() {
|
||||
$(this).parents('.condition').remove();
|
||||
|
||||
select2Init();
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
var get_location_objects = function( _this, onload = false ) {
|
||||
var select = _this,
|
||||
parent = select.parent(),
|
||||
location = select.val(),
|
||||
object_select = parent.find( '.condition-object-select' ),
|
||||
locationString = '',
|
||||
actionType = 'terms';
|
||||
|
||||
if ( '' == location ) {
|
||||
|
||||
parent.removeClass( 'generate-elements-rule-objects-visible' );
|
||||
select.closest( '.generate-element-row-content' ).find( '.generate-element-row-loading' ).remove();
|
||||
|
||||
} else {
|
||||
if ( location.indexOf( ':taxonomy:' ) > 0 ) {
|
||||
var locationType = 'taxonomy';
|
||||
} else {
|
||||
var locationType = location.substr( 0, location.indexOf( ':' ) );
|
||||
}
|
||||
|
||||
var locationID = location.substr( location.lastIndexOf( ':' ) + 1 );
|
||||
|
||||
locationString = location;
|
||||
|
||||
if ( 'taxonomy' == locationType || 'post' == locationType ) {
|
||||
|
||||
if ( ! ( '.generate-element-row-loading' ).length ) {
|
||||
select.closest( '.generate-element-row-content' ).prepend( '<div class="generate-element-row-loading"></div>' );
|
||||
}
|
||||
|
||||
if ( 'post' == locationType ) {
|
||||
if ( 'taxonomy' == locationType ) {
|
||||
actionType = 'terms';
|
||||
} else {
|
||||
actionType = 'posts';
|
||||
}
|
||||
}
|
||||
|
||||
$.post( ajaxurl, {
|
||||
action : 'generate_elements_get_location_' + actionType,
|
||||
id : locationID,
|
||||
nonce : elements.nonce
|
||||
}, function( response ) {
|
||||
response = $.parseJSON( response );
|
||||
var objects = response.objects;
|
||||
|
||||
var blank = {
|
||||
'id': '',
|
||||
'name': 'All ' + response.label,
|
||||
};
|
||||
|
||||
if ( location.indexOf( ':taxonomy:' ) > 0 ) {
|
||||
blank.name = elements.choose;
|
||||
}
|
||||
|
||||
objects.unshift( blank );
|
||||
object_select.empty();
|
||||
$.each( objects, function( key, value ) {
|
||||
object_select.append( $( '<option>', {
|
||||
value: value.id,
|
||||
label: elements.showID && value.id ? value.name + ': ' + value.id : value.name,
|
||||
text: elements.showID && value.id ? value.name + ': ' + value.id : value.name,
|
||||
} ) );
|
||||
} );
|
||||
|
||||
parent.addClass( 'generate-elements-rule-objects-visible' );
|
||||
|
||||
if ( onload ) {
|
||||
object_select.val( object_select.attr( 'data-saved-value' ) );
|
||||
}
|
||||
|
||||
select.closest( '.generate-element-row-content' ).find( '.generate-element-row-loading' ).remove();
|
||||
} );
|
||||
|
||||
} else {
|
||||
parent.removeClass( 'generate-elements-rule-objects-visible' );
|
||||
select.closest( '.generate-element-row-content' ).find( '.generate-element-row-loading' ).remove();
|
||||
object_select.empty().append( '<option value="0"></option>' );
|
||||
object_select.val( '0' );
|
||||
}
|
||||
|
||||
//remove.show();
|
||||
}
|
||||
};
|
||||
|
||||
$( '.condition select.condition-select' ).on( 'change', function() {
|
||||
get_location_objects( $( this ) );
|
||||
} );
|
||||
|
||||
$( '.generate-elements-rule-objects-visible' ).each( function() {
|
||||
var _this = $( this ),
|
||||
select = _this.find( 'select.condition-select' );
|
||||
|
||||
$( '<div class="generate-element-row-loading"></div>' ).insertBefore( _this );
|
||||
|
||||
get_location_objects( select, true );
|
||||
} );
|
||||
|
||||
$( '.set-featured-image a, .change-featured-image a:not(.remove-image)' ).on( 'click', function( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
// Stop propagation to prevent thickbox from activating.
|
||||
event.stopPropagation();
|
||||
|
||||
// Open the featured image modal
|
||||
wp.media.featuredImage.frame().open();
|
||||
} );
|
||||
|
||||
wp.media.featuredImage.frame().on( 'select', function() {
|
||||
$( '.set-featured-image' ).hide();
|
||||
$( '.change-featured-image' ).show();
|
||||
|
||||
setTimeout( function() {
|
||||
$( '.image-preview' ).empty();
|
||||
$( '#postimagediv img' ).appendTo( '.image-preview' );
|
||||
}, 500 );
|
||||
} );
|
||||
|
||||
$( '#postimagediv' ).on( 'click', '#remove-post-thumbnail', function() {
|
||||
$( '.set-featured-image' ).show();
|
||||
$( '.change-featured-image' ).hide();
|
||||
$( '.image-preview' ).empty();
|
||||
return false;
|
||||
});
|
||||
|
||||
$( '.remove-image' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
$( '#remove-post-thumbnail' ).trigger( 'click' );
|
||||
} );
|
||||
|
||||
$( '.generate-upload-file' ).on( 'click', function() {
|
||||
if ( frame ) {
|
||||
frame.open();
|
||||
return;
|
||||
}
|
||||
|
||||
var _this = $( this ),
|
||||
container = _this.closest( '.media-container' );
|
||||
|
||||
var frame = wp.media( {
|
||||
title: _this.data( 'title' ),
|
||||
multiple: false,
|
||||
library: { type : _this.data( 'type' ) },
|
||||
button: { text : _this.data( 'insert' ) }
|
||||
} );
|
||||
|
||||
frame.on( 'select', function() {
|
||||
var attachment = frame.state().get('selection').first().toJSON();
|
||||
|
||||
container.find( '.media-field' ).val( attachment.id );
|
||||
container.find( '.remove-field' ).show();
|
||||
|
||||
if ( _this.data( 'preview' ) ) {
|
||||
container.find( '.gp-media-preview' ).empty().append( '<img src="' + attachment.url + '" width="50" />' ).show();
|
||||
}
|
||||
} );
|
||||
|
||||
frame.open();
|
||||
} );
|
||||
|
||||
$( '.remove-field' ).on( 'click', function() {
|
||||
var _this = $( this ),
|
||||
container = _this.closest( '.media-container' );
|
||||
|
||||
_this.hide();
|
||||
container.find( '.media-field' ).val( '' );
|
||||
container.find( '.gp-media-preview' ).empty();
|
||||
} );
|
||||
|
||||
$( '#_generate_hero_background_image' ).on( 'change', function() {
|
||||
var _this = $( this );
|
||||
|
||||
if ( '' !== _this.val() ) {
|
||||
$( '.requires-background-image' ).show();
|
||||
} else {
|
||||
$( '.requires-background-image' ).hide();
|
||||
}
|
||||
|
||||
if ( 'featured-image' == _this.val() ) {
|
||||
$( '.image-text' ).text( elements.fallback_image );
|
||||
}
|
||||
|
||||
if ( 'custom-image' == _this.val() ) {
|
||||
$( '.image-text' ).text( elements.custom_image );
|
||||
}
|
||||
} );
|
||||
|
||||
// Responsive controls in our settings.
|
||||
$( '.responsive-controls a' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
var _this = $( this ),
|
||||
control = _this.attr( 'data-control' ),
|
||||
control_area = _this.closest( '.generate-element-row-content' );
|
||||
|
||||
control_area.find( '.padding-container' ).hide();
|
||||
control_area.find( '.padding-container.' + control ).show();
|
||||
_this.siblings().removeClass( 'is-selected' );
|
||||
_this.addClass( 'is-selected' );
|
||||
} );
|
||||
|
||||
$( '#_generate_site_header_merge' ).on( 'change', function() {
|
||||
var _this = $( this );
|
||||
|
||||
if ( '' !== _this.val() ) {
|
||||
$( '.requires-header-merge' ).show();
|
||||
|
||||
if ( $( '#_generate_navigation_colors' ).is( ':checked' ) ) {
|
||||
$( '.requires-navigation-colors' ).show();
|
||||
}
|
||||
|
||||
if ( $( '#_generate_hero_full_screen' ).is( ':checked' ) ) {
|
||||
$( '.requires-full-screen' ).show();
|
||||
}
|
||||
} else {
|
||||
$( '.requires-header-merge' ).hide();
|
||||
$( '.requires-navigation-colors' ).hide();
|
||||
$( '.requires-full-screen' ).hide();
|
||||
}
|
||||
} );
|
||||
|
||||
$( '#_generate_navigation_colors' ).on( 'change', function() {
|
||||
var _this = $( this );
|
||||
|
||||
if ( _this.is( ':checked' ) ) {
|
||||
$( '.requires-navigation-colors' ).show();
|
||||
} else {
|
||||
$( '.requires-navigation-colors' ).hide();
|
||||
}
|
||||
} );
|
||||
|
||||
$( '#_generate_hero_full_screen' ).on( 'change', function() {
|
||||
var _this = $( this );
|
||||
|
||||
if ( _this.is( ':checked' ) ) {
|
||||
$( '.requires-full-screen' ).show();
|
||||
} else {
|
||||
$( '.requires-full-screen' ).hide();
|
||||
}
|
||||
} );
|
||||
|
||||
$( '#_generate_hero_background_parallax' ).on( 'change', function() {
|
||||
var _this = $( this );
|
||||
|
||||
if ( _this.is( ':checked' ) ) {
|
||||
$( '#_generate_hero_background_position' ).val( '' ).change();
|
||||
$( '#_generate_hero_background_position option[value="left center"]' ).attr( 'disabled', true );
|
||||
$( '#_generate_hero_background_position option[value="left bottom"]' ).attr( 'disabled', true );
|
||||
$( '#_generate_hero_background_position option[value="right center"]' ).attr( 'disabled', true );
|
||||
$( '#_generate_hero_background_position option[value="right bottom"]' ).attr( 'disabled', true );
|
||||
$( '#_generate_hero_background_position option[value="center center"]' ).attr( 'disabled', true );
|
||||
$( '#_generate_hero_background_position option[value="center bottom"]' ).attr( 'disabled', true );
|
||||
} else {
|
||||
$( '#_generate_hero_background_position option[value="left center"]' ).attr( 'disabled', false );
|
||||
$( '#_generate_hero_background_position option[value="left bottom"]' ).attr( 'disabled', false );
|
||||
$( '#_generate_hero_background_position option[value="right center"]' ).attr( 'disabled', false );
|
||||
$( '#_generate_hero_background_position option[value="right bottom"]' ).attr( 'disabled', false );
|
||||
$( '#_generate_hero_background_position option[value="center center"]' ).attr( 'disabled', false );
|
||||
$( '#_generate_hero_background_position option[value="center bottom"]' ).attr( 'disabled', false );
|
||||
}
|
||||
} );
|
||||
} );
|
BIN
wp-content/plugins/gp-premium/elements/assets/admin/spinner.gif
Normal file
BIN
wp-content/plugins/gp-premium/elements/assets/admin/spinner.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
11
wp-content/plugins/gp-premium/elements/assets/admin/wp-color-picker-alpha.min.js
vendored
Normal file
11
wp-content/plugins/gp-premium/elements/assets/admin/wp-color-picker-alpha.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
17
wp-content/plugins/gp-premium/elements/assets/js/parallax.js
Normal file
17
wp-content/plugins/gp-premium/elements/assets/js/parallax.js
Normal file
@ -0,0 +1,17 @@
|
||||
function generate_parallax_element( selector, context ) {
|
||||
context = context || document;
|
||||
var elements = context.querySelectorAll( selector );
|
||||
return Array.prototype.slice.call( elements );
|
||||
}
|
||||
|
||||
window.addEventListener( "scroll", function() {
|
||||
var scrolledHeight= window.pageYOffset;
|
||||
generate_parallax_element( ".page-hero" ).forEach( function( el, index, array ) {
|
||||
var limit = el.offsetTop + el.offsetHeight;
|
||||
if( scrolledHeight > el.offsetTop && scrolledHeight <= limit ) {
|
||||
el.style.backgroundPositionY = ( scrolledHeight - el.offsetTop ) / hero.parallax + "px";
|
||||
} else {
|
||||
el.style.backgroundPositionY = "0";
|
||||
}
|
||||
});
|
||||
});
|
1
wp-content/plugins/gp-premium/elements/assets/js/parallax.min.js
vendored
Normal file
1
wp-content/plugins/gp-premium/elements/assets/js/parallax.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
function generate_parallax_element(e,o){var t=(o=o||document).querySelectorAll(e);return Array.prototype.slice.call(t)}window.addEventListener("scroll",function(){var r=window.pageYOffset;generate_parallax_element(".page-hero").forEach(function(e,o,t){var a=e.offsetTop+e.offsetHeight;r>e.offsetTop&&r<=a?e.style.backgroundPositionY=(r-e.offsetTop)/hero.parallax+"px":e.style.backgroundPositionY="0"})});
|
367
wp-content/plugins/gp-premium/elements/class-conditions.php
Normal file
367
wp-content/plugins/gp-premium/elements/class-conditions.php
Normal file
@ -0,0 +1,367 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class GeneratePress_Conditions {
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @var instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self;
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output our available location conditions.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_conditions() {
|
||||
$types = array(
|
||||
'general' => array(
|
||||
'label' => esc_attr__( 'General', 'gp-premium' ),
|
||||
'locations' => array(
|
||||
'general:site' => esc_attr__( 'Entire Site', 'gp-premium' ),
|
||||
'general:front_page' => esc_attr__( 'Front Page', 'gp-premium' ),
|
||||
'general:blog' => esc_attr__( 'Blog', 'gp-premium' ),
|
||||
'general:singular' => esc_attr__( 'All Singular', 'gp-premium' ),
|
||||
'general:archive' => esc_attr__( 'All Archives', 'gp-premium' ),
|
||||
'general:author' => esc_attr__( 'Author Archives', 'gp-premium' ),
|
||||
'general:date' => esc_attr__( 'Date Archives', 'gp-premium' ),
|
||||
'general:search' => esc_attr__( 'Search Results', 'gp-premium' ),
|
||||
'general:404' => esc_attr__( '404 Template', 'gp-premium' ),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Add the post types.
|
||||
$post_types = get_post_types( array(
|
||||
'public' => true,
|
||||
), 'objects' );
|
||||
|
||||
foreach ( $post_types as $post_type_slug => $post_type ) {
|
||||
|
||||
if ( in_array( $post_type_slug, array( 'fl-theme-layout' ) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$post_type_object = get_post_type_object( $post_type_slug );
|
||||
$counts = wp_count_posts( $post_type_slug );
|
||||
$count = $counts->publish + $counts->future + $counts->draft + $counts->pending + $counts->private;
|
||||
|
||||
// Add the post type.
|
||||
$types[ $post_type_slug ] = array(
|
||||
'label' => esc_html( $post_type->labels->name ),
|
||||
'locations' => array(
|
||||
'post:' . $post_type_slug => esc_html( $post_type->labels->singular_name )
|
||||
)
|
||||
);
|
||||
|
||||
// Add the post type archive.
|
||||
if ( 'post' == $post_type_slug || ! empty( $post_type_object->has_archive ) ) {
|
||||
$types[ $post_type_slug . '_archive' ] = array(
|
||||
'label' => sprintf( esc_html_x( '%s Archives', '%s is a singular post type name', 'gp-premium' ), $post_type->labels->singular_name ),
|
||||
'locations' => array(
|
||||
'archive:' . $post_type_slug => sprintf( esc_html_x( '%s Archive', '%s is a singular post type name', 'gp-premium' ), $post_type->labels->singular_name ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Add the taxonomies for the post type.
|
||||
$taxonomies = get_object_taxonomies( $post_type_slug, 'objects' );
|
||||
|
||||
foreach ( $taxonomies as $taxonomy_slug => $taxonomy ) {
|
||||
|
||||
$public = $taxonomy->public && $taxonomy->show_ui;
|
||||
|
||||
if ( 'post_format' == $taxonomy_slug ) {
|
||||
continue;
|
||||
} elseif ( ! apply_filters( 'generate_elements_show_taxonomy', $public, $taxonomy ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$label = str_replace( array(
|
||||
$post_type->labels->name,
|
||||
$post_type->labels->singular_name,
|
||||
), '', $taxonomy->labels->singular_name );
|
||||
|
||||
if ( isset( $types[ $post_type_slug . '_archive' ]['locations'] ) ) {
|
||||
$types[ $post_type_slug . '_archive' ]['locations']['taxonomy:' . $taxonomy_slug] = sprintf( esc_html_x( '%1$s %2$s Archive', '%1$s is post type label. %2$s is taxonomy label.', 'gp-premium' ), $post_type->labels->singular_name, $label );
|
||||
}
|
||||
|
||||
if ( isset( $types[ $post_type_slug ]['locations'] ) ) {
|
||||
$types[ $post_type_slug ]['locations'][$post_type_slug . ':taxonomy:' . $taxonomy_slug] = esc_html( $post_type->labels->singular_name . ' ' . $label );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output our available user conditions.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_user_conditions() {
|
||||
$rules = array(
|
||||
'general' => array(
|
||||
'label' => esc_attr__( 'General', 'gp-premium' ),
|
||||
'rules' => array(
|
||||
'general:all' => esc_attr__( 'All Users', 'gp-premium' ),
|
||||
'general:logged_in' => esc_attr__( 'Logged In', 'gp-premium' ),
|
||||
'general:logged_out' => esc_attr__( 'Logged Out', 'gp-premium' ),
|
||||
)
|
||||
),
|
||||
'role' => array(
|
||||
'label' => esc_attr__( 'Roles', 'gp-premium' ),
|
||||
'rules' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
$roles = get_editable_roles();
|
||||
|
||||
foreach ( $roles as $slug => $data ) {
|
||||
$rules['role']['rules'][ $slug ] = $data['name'];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our current location.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_current_location() {
|
||||
global $wp_query;
|
||||
global $post;
|
||||
|
||||
$location = null;
|
||||
$object = null;
|
||||
$queried_object = get_queried_object();
|
||||
|
||||
// Get the location string.
|
||||
if ( is_front_page() ) {
|
||||
$location = 'general:front_page';
|
||||
} elseif ( is_home() ) {
|
||||
$location = 'general:blog';
|
||||
} elseif ( is_author() ) {
|
||||
$location = 'general:author';
|
||||
} elseif ( is_date() ) {
|
||||
$location = 'general:date';
|
||||
} elseif ( is_search() ) {
|
||||
$location = 'general:search';
|
||||
} elseif ( is_404() ) {
|
||||
$location = 'general:404';
|
||||
} elseif ( is_category() ) {
|
||||
|
||||
$location = 'taxonomy:category';
|
||||
|
||||
if ( is_object( $queried_object ) ) {
|
||||
$object = $queried_object->term_id;
|
||||
}
|
||||
} elseif ( is_tag() ) {
|
||||
|
||||
$location = 'taxonomy:post_tag';
|
||||
|
||||
if ( is_object( $queried_object ) ) {
|
||||
$object = $queried_object->term_id;
|
||||
}
|
||||
} elseif ( is_tax() ) {
|
||||
|
||||
$location = 'taxonomy:' . get_query_var( 'taxonomy' );
|
||||
|
||||
if ( is_object( $queried_object ) ) {
|
||||
$location = 'taxonomy:' . $queried_object->taxonomy;
|
||||
$object = $queried_object->term_id;
|
||||
}
|
||||
} elseif ( is_post_type_archive() ) {
|
||||
$location = 'archive:' . $wp_query->get( 'post_type' );
|
||||
} elseif ( is_singular() ) {
|
||||
|
||||
if ( is_object( $post ) ) {
|
||||
$location = 'post:' . $post->post_type;
|
||||
}
|
||||
|
||||
if ( is_object( $queried_object ) ) {
|
||||
$object = $queried_object->ID;
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'rule' => $location,
|
||||
'object' => $object,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get info on the current user.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_current_user() {
|
||||
$status = array();
|
||||
if ( is_user_logged_in() ) {
|
||||
$status[] = 'general:logged_in';
|
||||
} else {
|
||||
$status[] = 'general:logged_out';
|
||||
}
|
||||
|
||||
$user = wp_get_current_user();
|
||||
|
||||
foreach ( ( array ) $user->roles as $role ) {
|
||||
$status[] = $role;
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Figure out if we should display the element or not.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function show_data( $conditionals, $exclude, $roles ) {
|
||||
$current_location = self::get_current_location();
|
||||
$show = false;
|
||||
|
||||
// Show depending on location conditionals.
|
||||
if ( ! $show ) {
|
||||
foreach( ( array ) $conditionals as $conditional ) {
|
||||
if ( in_array( 'general:site', $conditional ) ) {
|
||||
$show = true;
|
||||
} elseif ( is_singular() && in_array( 'general:singular', $conditional ) ) {
|
||||
$show = true;
|
||||
} elseif ( is_archive() && in_array( 'general:archive', $conditional ) ) {
|
||||
$show = true;
|
||||
} elseif ( ! empty( $current_location['rule'] ) && in_array( $current_location['rule'], $conditional ) ) {
|
||||
if ( ! isset( $conditional['object'] ) || empty( $conditional['object'] ) ) {
|
||||
$show = true;
|
||||
} else {
|
||||
if ( in_array( $current_location['object'], $conditional ) ) {
|
||||
$show = true;
|
||||
}
|
||||
}
|
||||
} elseif ( is_singular() && strstr( $conditional['rule'], ':taxonomy:' ) ) {
|
||||
$tax = substr( $conditional['rule'], strrpos( $conditional['rule'], ':' ) + 1 );
|
||||
|
||||
if ( $tax && isset( $conditional['object'] ) && has_term( $conditional['object'], $tax ) ) {
|
||||
$show = true;
|
||||
}
|
||||
} elseif ( is_front_page() && is_home() && ( in_array( 'general:blog', $conditional ) || in_array( 'general:front_page', $conditional ) ) ) {
|
||||
// If the home page is the blog, both of general:blog and general:front_page apply.
|
||||
$show = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Exclude based on exclusion conditionals.
|
||||
if ( $show ) {
|
||||
foreach( ( array ) $exclude as $conditional ) {
|
||||
if ( is_singular() && in_array( 'general:singular', $conditional ) ) {
|
||||
$show = false;
|
||||
} elseif ( is_archive() && in_array( 'general:archive', $conditional ) ) {
|
||||
$show = false;
|
||||
} elseif ( ! empty( $current_location['rule'] ) && in_array( $current_location['rule'], $conditional ) ) {
|
||||
if ( ! isset( $conditional['object'] ) || empty( $conditional['object'] ) ) {
|
||||
$show = false;
|
||||
} else {
|
||||
if ( in_array( $current_location['object'], $conditional ) ) {
|
||||
$show = false;
|
||||
}
|
||||
}
|
||||
} elseif ( is_singular() && strstr( $conditional['rule'], ':taxonomy:' ) ) {
|
||||
$tax = substr( $conditional['rule'], strrpos( $conditional['rule'], ':') + 1 );
|
||||
|
||||
if ( $tax && isset( $conditional['object'] ) && has_term( $conditional['object'], $tax ) ) {
|
||||
$show = false;
|
||||
}
|
||||
} elseif ( is_front_page() && is_home() && ( in_array( 'general:blog', $conditional ) || in_array( 'general:front_page', $conditional ) ) ) {
|
||||
// If the home page is the blog, both of general:blog and general:front_page apply.
|
||||
$show = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Exclude user roles.
|
||||
if ( $show && ! empty( $roles ) ) {
|
||||
$user_info = self::get_current_user();
|
||||
|
||||
$check = array_intersect( $roles, $user_info );
|
||||
if ( ! count( $check ) > 0 && ! in_array( 'general:all', $roles ) ) {
|
||||
$show = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the label for a saved location.
|
||||
*
|
||||
* @since 1.7
|
||||
* @param string $saved_location
|
||||
* @return string|bool
|
||||
*/
|
||||
static public function get_saved_label( $saved_location ) {
|
||||
$locations = self::get_conditions();
|
||||
|
||||
$rule = $saved_location['rule'];
|
||||
$object_id = $saved_location['object'];
|
||||
$object_type = '';
|
||||
$label = false;
|
||||
|
||||
foreach ( $locations as $data ) {
|
||||
if ( isset( $data['locations'][ $rule ] ) && ! $label ) {
|
||||
$label = $data['locations'][ $rule ];
|
||||
|
||||
$object_types = explode( ':', $rule );
|
||||
|
||||
if ( in_array( 'taxonomy', $object_types ) && $object_id ) {
|
||||
$term = get_term( $object_id );
|
||||
|
||||
if ( ! is_object( $term ) || is_wp_error( $term ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$label .= ': ' . $term->name;
|
||||
} elseif ( ( in_array( 'post', $object_types ) || in_array( 'page', $object_types ) ) && $object_id ) {
|
||||
$post = get_post( $object_id );
|
||||
|
||||
if ( ! is_object( $post ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$label .= ': ' . $post->post_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $label;
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Conditions::get_instance();
|
108
wp-content/plugins/gp-premium/elements/class-elements-helper.php
Normal file
108
wp-content/plugins/gp-premium/elements/class-elements-helper.php
Normal file
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
class GeneratePress_Elements_Helper {
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @access private
|
||||
* @var object Instance
|
||||
* @since 1.7
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator.
|
||||
*
|
||||
* @since 1.7
|
||||
* @return object initialized object of class.
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self;
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if specific theme/GPP options exist and are set.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function does_option_exist( $option ) {
|
||||
if ( function_exists( 'generate_get_defaults' ) ) {
|
||||
$theme_settings = wp_parse_args(
|
||||
get_option( 'generate_settings', array() ),
|
||||
generate_get_defaults()
|
||||
);
|
||||
|
||||
if ( 'site-title' === $option ) {
|
||||
return $theme_settings['hide_title'] ? false : true;
|
||||
}
|
||||
|
||||
if ( 'site-tagline' === $option ) {
|
||||
return $theme_settings['hide_tagline'] ? false : true;
|
||||
}
|
||||
|
||||
if ( 'retina-logo' === $option ) {
|
||||
return $theme_settings['retina_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'site-logo' === $option ) {
|
||||
return get_theme_mod( 'custom_logo' );
|
||||
}
|
||||
|
||||
if ( function_exists( 'generate_menu_plus_get_defaults' ) ) {
|
||||
$menu_settings = wp_parse_args(
|
||||
get_option( 'generate_menu_plus_settings', array() ),
|
||||
generate_menu_plus_get_defaults()
|
||||
);
|
||||
|
||||
if ( 'navigation-as-header' === $option ) {
|
||||
return $menu_settings['navigation_as_header'];
|
||||
}
|
||||
|
||||
if ( 'mobile-logo' === $option ) {
|
||||
return $menu_settings['mobile_header_logo'];
|
||||
}
|
||||
|
||||
if ( 'navigation-logo' === $option ) {
|
||||
return $menu_settings['sticky_menu_logo'];
|
||||
}
|
||||
|
||||
if ( 'sticky-navigation' === $option ) {
|
||||
return 'false' !== $menu_settings['sticky_menu'] ? true : false;
|
||||
}
|
||||
|
||||
if ( 'sticky-navigation-logo' === $option ) {
|
||||
return $menu_settings['sticky_navigation_logo'];
|
||||
}
|
||||
|
||||
if ( 'mobile-header-branding' === $option ) {
|
||||
return $menu_settings['mobile_header_branding'];
|
||||
}
|
||||
|
||||
if ( 'sticky-mobile-header' === $option ) {
|
||||
return 'disable' !== $menu_settings['mobile_header_sticky'] ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function should_execute_php() {
|
||||
$php = true;
|
||||
|
||||
if ( defined( 'DISALLOW_FILE_EDIT' ) ) {
|
||||
$php = false;
|
||||
}
|
||||
|
||||
return apply_filters( 'generate_hooks_execute_php', $php );
|
||||
}
|
||||
}
|
913
wp-content/plugins/gp-premium/elements/class-hero.php
Normal file
913
wp-content/plugins/gp-premium/elements/class-hero.php
Normal file
@ -0,0 +1,913 @@
|
||||
<?php
|
||||
|
||||
class GeneratePress_Hero {
|
||||
/**
|
||||
* Our conditionals for this header.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $conditional = array();
|
||||
|
||||
/**
|
||||
* Our exclusions for this header.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $exclude = array();
|
||||
|
||||
/**
|
||||
* Our user conditionals for this header.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $users = array();
|
||||
|
||||
/**
|
||||
* Our array of available options.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected static $options = array();
|
||||
|
||||
/**
|
||||
* The element ID.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected static $post_id = '';
|
||||
|
||||
/**
|
||||
* How many times this class has been called per page.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static $instances = 0;
|
||||
|
||||
/**
|
||||
* Get our current instance.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected static $hero = '';
|
||||
|
||||
/**
|
||||
* Kicks it all off.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param int The element post ID.
|
||||
*/
|
||||
function __construct( $post_id ) {
|
||||
|
||||
self::$post_id = $post_id;
|
||||
|
||||
// We need this to reference our instance in remove_hentry().
|
||||
self::$hero = $this;
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_display_conditions', true ) ) {
|
||||
$this->conditional = get_post_meta( $post_id, '_generate_element_display_conditions', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) ) {
|
||||
$this->exclude = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_user_conditions', true ) ) {
|
||||
$this->users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
|
||||
}
|
||||
|
||||
$display = apply_filters( 'generate_header_element_display', GeneratePress_Conditions::show_data( $this->conditional, $this->exclude, $this->users ), $post_id );
|
||||
|
||||
if ( $display ) {
|
||||
$location = apply_filters( 'generate_page_hero_location', 'generate_after_header', $post_id );
|
||||
|
||||
add_action( $location, array( $this, 'build_hero' ), 9 );
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 100 );
|
||||
add_action( 'wp', array( $this, 'after_setup' ), 100 );
|
||||
|
||||
self::$instances++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add necessary scripts and styles.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function enqueue() {
|
||||
$options = self::get_options();
|
||||
|
||||
wp_add_inline_style( 'generate-style', self::build_css() );
|
||||
|
||||
if ( $options['parallax'] ) {
|
||||
wp_enqueue_script( 'generate-hero-parallax', plugin_dir_url( __FILE__ ) . '/assets/js/parallax.min.js', array(), GP_PREMIUM_VERSION, true );
|
||||
wp_localize_script( 'generate-hero-parallax', 'hero', array(
|
||||
'parallax' => apply_filters( 'generate_hero_parallax_speed', 2 ),
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the HTML structure for Page Headers.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function build_hero() {
|
||||
$options = self::get_options();
|
||||
|
||||
if ( empty( $options['content'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$options['container_classes'] = implode( ' ', array(
|
||||
'page-hero',
|
||||
'contained' === $options['container'] ? 'grid-container grid-parent' : '',
|
||||
$options['classes'],
|
||||
) );
|
||||
|
||||
$options['inner_container_classes'] = implode( ' ', array(
|
||||
'inside-page-hero',
|
||||
'full-width' !== $options['inner_container'] ? 'grid-container grid-parent' : '',
|
||||
) );
|
||||
|
||||
$options['content'] = self::template_tags( $options['content'] );
|
||||
$options['content'] = do_shortcode( $options['content'] );
|
||||
|
||||
echo apply_filters( 'generate_page_hero_output', sprintf(
|
||||
'<div class="%1$s">
|
||||
<div class="%2$s">
|
||||
%3$s
|
||||
</div>
|
||||
</div>',
|
||||
trim( $options['container_classes'] ),
|
||||
trim( $options['inner_container_classes'] ),
|
||||
$options['content']
|
||||
), $options );
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds all of our custom CSS for Page Headers.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return string Dynamic CSS.
|
||||
*/
|
||||
public static function build_css() {
|
||||
$options = self::get_options();
|
||||
|
||||
// Initiate our CSS class
|
||||
require_once GP_LIBRARY_DIRECTORY . 'class-make-css.php';
|
||||
$css = new GeneratePress_Pro_CSS;
|
||||
|
||||
$image_url = false;
|
||||
if ( $options['background_image'] && function_exists( 'get_the_post_thumbnail_url' ) ) {
|
||||
if ( 'featured-image' === $options['background_image'] ) {
|
||||
if ( is_singular() ) {
|
||||
$image_url = get_the_post_thumbnail_url( get_the_ID(), 'full' );
|
||||
}
|
||||
|
||||
if ( ! $image_url ) {
|
||||
$image_url = get_the_post_thumbnail_url( self::$post_id, 'full' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'custom-image' === $options['background_image'] ) {
|
||||
$image_url = get_the_post_thumbnail_url( self::$post_id, 'full' );
|
||||
}
|
||||
}
|
||||
|
||||
$image_url = apply_filters( 'generate_page_hero_background_image_url', $image_url, $options );
|
||||
|
||||
// Figure out desktop units.
|
||||
$options['padding_top_unit'] = $options['padding_top_unit'] ? $options['padding_top_unit'] : 'px';
|
||||
$options['padding_right_unit'] = $options['padding_right_unit'] ? $options['padding_right_unit'] : 'px';
|
||||
$options['padding_bottom_unit'] = $options['padding_bottom_unit'] ? $options['padding_bottom_unit'] : 'px';
|
||||
$options['padding_left_unit'] = $options['padding_left_unit'] ? $options['padding_left_unit'] : 'px';
|
||||
|
||||
// Figure out mobile units.
|
||||
$options['padding_top_unit_mobile'] = $options['padding_top_unit_mobile'] ? $options['padding_top_unit_mobile'] : 'px';
|
||||
$options['padding_right_unit_mobile'] = $options['padding_right_unit_mobile'] ? $options['padding_right_unit_mobile'] : 'px';
|
||||
$options['padding_bottom_unit_mobile'] = $options['padding_bottom_unit_mobile'] ? $options['padding_bottom_unit_mobile'] : 'px';
|
||||
$options['padding_left_unit_mobile'] = $options['padding_left_unit_mobile'] ? $options['padding_left_unit_mobile'] : 'px';
|
||||
|
||||
$css->set_selector( '.page-hero' );
|
||||
|
||||
if ( $options['background_color'] ) {
|
||||
$css->add_property( 'background-color', esc_attr( $options['background_color'] ) );
|
||||
}
|
||||
|
||||
if ( $image_url ) {
|
||||
$css->add_property( 'background-image', 'url(' . esc_url( $image_url ) . ')' );
|
||||
$css->add_property( 'background-size', 'cover' );
|
||||
|
||||
if ( $options['background_color'] && $options['background_overlay'] ) {
|
||||
$css->add_property( 'background-image', 'linear-gradient(0deg, ' . $options['background_color'] . ',' . $options['background_color'] . '), url(' . $image_url . ')' );
|
||||
}
|
||||
|
||||
if ( $options['background_position'] ) {
|
||||
$css->add_property( 'background-position', esc_attr( $options['background_position'] ) );
|
||||
}
|
||||
|
||||
$css->add_property( 'background-repeat', 'no-repeat' );
|
||||
}
|
||||
|
||||
if ( $options['text_color'] ) {
|
||||
$css->add_property( 'color', esc_attr( $options['text_color'] ) );
|
||||
}
|
||||
|
||||
if ( $options['padding_top'] ) {
|
||||
$css->add_property( 'padding-top', absint( $options['padding_top'] ), false, esc_html( $options['padding_top_unit'] ) );
|
||||
}
|
||||
|
||||
if ( $options['padding_right'] ) {
|
||||
$css->add_property( 'padding-right', absint( $options['padding_right'] ), false, esc_html( $options['padding_right_unit'] ) );
|
||||
}
|
||||
|
||||
if ( $options['padding_bottom'] ) {
|
||||
$css->add_property( 'padding-bottom', absint( $options['padding_bottom'] ), false, esc_html( $options['padding_bottom_unit'] ) );
|
||||
}
|
||||
|
||||
if ( $options['padding_left'] ) {
|
||||
$css->add_property( 'padding-left', absint( $options['padding_left'] ), false, esc_html( $options['padding_left_unit'] ) );
|
||||
}
|
||||
|
||||
if ( $options['horizontal_alignment'] ) {
|
||||
$css->add_property( 'text-align', esc_html( $options['horizontal_alignment'] ) );
|
||||
}
|
||||
|
||||
$css->add_property( 'box-sizing', 'border-box' );
|
||||
|
||||
if ( $options['site_header_merge'] && $options['full_screen'] ) {
|
||||
$css->add_property( 'min-height', '100vh' );
|
||||
|
||||
if ( $options['vertical_alignment'] ) {
|
||||
$css->add_property( 'display', '-webkit-flex' );
|
||||
$css->add_property( 'display', '-ms-flex' );
|
||||
$css->add_property( 'display', 'flex' );
|
||||
|
||||
if ( 'center' === $options['vertical_alignment'] ) {
|
||||
$css->add_property( '-webkit-box', 'center' );
|
||||
$css->add_property( '-ms-flex-pack', 'center' );
|
||||
$css->add_property( 'justify-content', 'center' );
|
||||
} elseif ( 'bottom' === $options['vertical_alignment'] ) {
|
||||
$css->add_property( '-webkit-box', 'end' );
|
||||
$css->add_property( '-ms-flex-pack', 'end' );
|
||||
$css->add_property( 'justify-content', 'flex-end' );
|
||||
}
|
||||
|
||||
$css->add_property( '-webkit-box-orient', 'vertical' );
|
||||
$css->add_property( '-webkit-box-direction', 'normal' );
|
||||
$css->add_property( '-ms-flex-direction', 'column' );
|
||||
$css->add_property( 'flex-direction', 'column' );
|
||||
|
||||
$css->set_selector( '.page-hero .inside-page-hero' );
|
||||
$css->add_property( 'width', '100%' );
|
||||
}
|
||||
}
|
||||
|
||||
$css->set_selector( '.page-hero h1, .page-hero h2, .page-hero h3, .page-hero h4, .page-hero h5, .page-hero h6' );
|
||||
if ( $options['text_color'] ) {
|
||||
$css->add_property( 'color', esc_attr( $options['text_color'] ) );
|
||||
}
|
||||
|
||||
$css->set_selector( '.inside-page-hero > *:last-child' );
|
||||
$css->add_property( 'margin-bottom', '0px' );
|
||||
|
||||
$css->set_selector( '.page-hero a, .page-hero a:visited' );
|
||||
|
||||
if ( $options['link_color'] ) {
|
||||
$css->add_property( 'color', esc_attr( $options['link_color'] ) );
|
||||
}
|
||||
|
||||
if ( $options['content'] ) {
|
||||
$css->set_selector( '.page-hero time.updated' );
|
||||
$css->add_property( 'display', 'none' );
|
||||
}
|
||||
|
||||
$css->set_selector( '.page-hero a:hover' );
|
||||
|
||||
if ( $options['link_color_hover'] ) {
|
||||
$css->add_property( 'color', esc_attr( $options['link_color_hover'] ) );
|
||||
}
|
||||
|
||||
if ( '' !== $options['site_header_merge'] ) {
|
||||
if ( 'merge-desktop' === $options['site_header_merge'] ) {
|
||||
$css->start_media_query( apply_filters( 'generate_not_mobile_media_query', '(min-width: 769px)' ) );
|
||||
}
|
||||
|
||||
$header_background = $options['header_background_color'] ? $options['header_background_color'] : 'transparent';
|
||||
|
||||
if ( $options['site_header_height'] ) {
|
||||
$css->set_selector( '.page-hero' );
|
||||
|
||||
if ( $options['padding_top'] ) {
|
||||
$css->add_property( 'padding-top', 'calc(' . absint( $options['padding_top'] ) . esc_html( $options['padding_top_unit'] ) . ' + ' . absint( $options['site_header_height'] ) . 'px)' );
|
||||
} else {
|
||||
$css->add_property( 'padding-top', absint( $options['site_header_height'] ), false, 'px' );
|
||||
}
|
||||
}
|
||||
|
||||
$css->set_selector( '.header-wrap' );
|
||||
$css->add_property( 'position', 'absolute' );
|
||||
$css->add_property( 'left', '0px' );
|
||||
$css->add_property( 'right', '0px' );
|
||||
$css->add_property( 'z-index', '10' );
|
||||
|
||||
$css->set_selector( '.header-wrap .site-header' );
|
||||
$css->add_property( 'background', $header_background );
|
||||
|
||||
$css->set_selector( '.header-wrap .main-title a, .header-wrap .main-title a:hover, .header-wrap .main-title a:visited' );
|
||||
$css->add_property( 'color', esc_attr( $options['header_title_color'] ) );
|
||||
|
||||
if ( ! GeneratePress_Elements_Helper::does_option_exist( 'navigation-as-header' ) ) {
|
||||
$css->set_selector( '.header-wrap .mobile-header-navigation:not(.navigation-stick):not(.toggled) .main-title a, .header-wrap .mobile-header-navigation:not(.navigation-stick):not(.toggled) .main-title a:hover, .header-wrap .mobile-header-navigation:not(.navigation-stick):not(.toggled) .main-title a:visited' );
|
||||
$css->add_property( 'color', esc_attr( $options['header_title_color'] ) );
|
||||
}
|
||||
|
||||
if ( function_exists( 'generate_get_color_defaults' ) ) {
|
||||
$color_settings = wp_parse_args(
|
||||
get_option( 'generate_settings', array() ),
|
||||
generate_get_color_defaults()
|
||||
);
|
||||
|
||||
if ( GeneratePress_Elements_Helper::does_option_exist( 'navigation-as-header' ) ) {
|
||||
$css->set_selector( '.header-wrap .toggled .main-title a, .header-wrap .toggled .main-title a:hover, .header-wrap .toggled .main-title a:visited, .header-wrap .navigation-stick .main-title a, .header-wrap .navigation-stick .main-title a:hover, .header-wrap .navigation-stick .main-title a:visited' );
|
||||
$css->add_property( 'color', esc_attr( $color_settings['site_title_color'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
$css->set_selector( '.header-wrap .site-description' );
|
||||
$css->add_property( 'color', esc_attr( $options['header_tagline_color'] ) );
|
||||
|
||||
if ( $options['navigation_colors'] ) {
|
||||
$navigation_background = $options['navigation_background_color'] ? $options['navigation_background_color'] : 'transparent';
|
||||
$navigation_background_hover = $options['navigation_background_color_hover'] ? $options['navigation_background_color_hover'] : 'transparent';
|
||||
$navigation_background_current = $options['navigation_background_color_current'] ? $options['navigation_background_color_current'] : 'transparent';
|
||||
|
||||
$css->set_selector( '.header-wrap #site-navigation:not(.toggled), .header-wrap #mobile-header:not(.toggled):not(.navigation-stick)' );
|
||||
$css->add_property( 'background', $navigation_background );
|
||||
|
||||
$css->set_selector( '.header-wrap #site-navigation:not(.toggled) .main-nav > ul > li > a, .header-wrap #mobile-header:not(.toggled):not(.navigation-stick) .main-nav > ul > li > a, .header-wrap .main-navigation:not(.toggled):not(.navigation-stick) .menu-toggle, .header-wrap .main-navigation:not(.toggled):not(.navigation-stick) .menu-toggle:hover, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a:hover, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a:focus' );
|
||||
$css->add_property( 'color', esc_attr( $options['navigation_text_color' ] ) );
|
||||
|
||||
$css->set_selector( '.header-wrap #site-navigation:not(.toggled) .main-nav > ul > li:hover > a, .header-wrap #site-navigation:not(.toggled) .main-nav > ul > li:focus > a, .header-wrap #site-navigation:not(.toggled) .main-nav > ul > li.sfHover > a, .header-wrap #mobile-header:not(.toggled) .main-nav > ul > li:hover > a' );
|
||||
$css->add_property( 'background', $navigation_background_hover );
|
||||
|
||||
if ( '' !== $options[ 'navigation_text_color_hover' ] ) {
|
||||
$css->add_property( 'color', esc_attr( $options[ 'navigation_text_color_hover' ] ) );
|
||||
} else {
|
||||
$css->add_property( 'color', esc_attr( $options[ 'navigation_text_color' ] ) );
|
||||
}
|
||||
|
||||
$css->set_selector( '.header-wrap #site-navigation:not(.toggled) .main-nav > ul > li[class*="current-menu-"] > a, .header-wrap #mobile-header:not(.toggled) .main-nav > ul > li[class*="current-menu-"] > a, .header-wrap #site-navigation:not(.toggled) .main-nav > ul > li[class*="current-menu-"]:hover > a, .header-wrap #mobile-header:not(.toggled) .main-nav > ul > li[class*="current-menu-"]:hover > a' );
|
||||
$css->add_property( 'background', $navigation_background_current );
|
||||
|
||||
if ( '' !== $options[ 'navigation_text_color_current' ] ) {
|
||||
$css->add_property( 'color', esc_attr( $options[ 'navigation_text_color_current' ] ) );
|
||||
} else {
|
||||
$css->add_property( 'color', esc_attr( $options[ 'navigation_text_color' ] ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $options['site_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'navigation-as-header' ) ) {
|
||||
$css->set_selector( '.main-navigation .site-logo, .main-navigation.toggled .page-hero-logo, .main-navigation.navigation-stick .page-hero-logo' );
|
||||
$css->add_property( 'display', 'none' );
|
||||
|
||||
$css->set_selector( '.main-navigation .page-hero-logo, .main-navigation.toggled .site-logo:not(.page-hero-logo), #mobile-header .mobile-header-logo' );
|
||||
$css->add_property( 'display', 'block' );
|
||||
|
||||
if ( ! GeneratePress_Elements_Helper::does_option_exist( 'sticky-navigation-logo' ) ) {
|
||||
$css->set_selector( '.main-navigation.navigation-stick .site-logo:not(.page-hero-logo)' );
|
||||
$css->add_property( 'display', 'block' );
|
||||
|
||||
$css->set_selector( '.main-navigation.navigation-stick .page-hero-logo' );
|
||||
$css->add_property( 'display', 'none' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $options['navigation_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'sticky-navigation' ) ) {
|
||||
$css->set_selector( '#site-navigation:not(.navigation-stick):not(.toggled) .navigation-logo:not(.page-hero-navigation-logo)' );
|
||||
$css->add_property( 'display', 'none' );
|
||||
|
||||
$css->set_selector( '#sticky-navigation .page-hero-navigation-logo, #site-navigation.navigation-stick .page-hero-navigation-logo, #site-navigation.toggled .page-hero-navigation-logo' );
|
||||
$css->add_property( 'display', 'none' );
|
||||
}
|
||||
|
||||
if ( $options['mobile_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'mobile-logo' ) ) {
|
||||
$css->set_selector( '#mobile-header:not(.navigation-stick):not(.toggled) .mobile-header-logo:not(.page-hero-mobile-logo)' );
|
||||
$css->add_property( 'display', 'none' );
|
||||
|
||||
$css->set_selector( '#mobile-header.navigation-stick .page-hero-mobile-logo, #mobile-header.toggled .page-hero-mobile-logo' );
|
||||
$css->add_property( 'display', 'none' );
|
||||
}
|
||||
|
||||
if ( $options['site_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'site-logo' ) ) {
|
||||
$css->set_selector( '.site-logo:not(.page-hero-logo)' );
|
||||
$css->add_property( 'display', 'none' );
|
||||
}
|
||||
|
||||
if ( 'merge-desktop' === $options['site_header_merge'] ) {
|
||||
$css->stop_media_query();
|
||||
}
|
||||
|
||||
if ( class_exists( 'Elementor\Plugin' ) ) {
|
||||
$css->set_selector( '.elementor-editor-active .header-wrap' );
|
||||
$css->add_property( 'pointer-events', 'none' );
|
||||
}
|
||||
}
|
||||
|
||||
$css->start_media_query( generate_premium_get_media_query( 'mobile' ) );
|
||||
|
||||
$css->set_selector( '.page-hero' );
|
||||
|
||||
if ( $options['padding_top_mobile'] || '0' === $options['padding_top_mobile'] ) {
|
||||
$css->add_property( 'padding-top', absint( $options['padding_top_mobile'] ), false, esc_html( $options['padding_top_unit_mobile'] ) );
|
||||
}
|
||||
|
||||
if ( 'merge' === $options['site_header_merge'] && $options['site_header_height_mobile'] ) {
|
||||
if ( $options['padding_top_mobile'] || '0' === $options['padding_top_mobile'] ) {
|
||||
$css->add_property( 'padding-top', 'calc(' . absint( $options['padding_top_mobile'] ) . esc_html( $options['padding_top_unit_mobile'] ) . ' + ' . absint( $options['site_header_height_mobile'] ) . 'px)' );
|
||||
} elseif ( $options['padding_top'] ) {
|
||||
$css->add_property( 'padding-top', 'calc(' . absint( $options['padding_top'] ) . esc_html( $options['padding_top_unit'] ) . ' + ' . absint( $options['site_header_height_mobile'] ) . 'px)' );
|
||||
} else {
|
||||
$css->add_property( 'padding-top', absint( $options['site_header_height_mobile'] ), false, 'px' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $options['padding_right_mobile'] || '0' === $options['padding_right_mobile'] ) {
|
||||
$css->add_property( 'padding-right', absint( $options['padding_right_mobile'] ), false, esc_html( $options['padding_right_unit_mobile'] ) );
|
||||
}
|
||||
|
||||
if ( $options['padding_bottom_mobile'] || '0' === $options['padding_bottom_mobile'] ) {
|
||||
$css->add_property( 'padding-bottom', absint( $options['padding_bottom_mobile'] ), false, esc_html( $options['padding_bottom_unit_mobile'] ) );
|
||||
}
|
||||
|
||||
if ( $options['padding_left_mobile'] || '0' === $options['padding_left_mobile'] ) {
|
||||
$css->add_property( 'padding-left', absint( $options['padding_left_mobile'] ), false, esc_html( $options['padding_left_unit_mobile'] ) );
|
||||
}
|
||||
|
||||
if ( GeneratePress_Elements_Helper::does_option_exist( 'site-logo' ) && 'merge-desktop' === $options['site_header_merge'] ) {
|
||||
$css->set_selector( '.inside-header .page-hero-logo, .main-navigation .page-hero-logo, #mobile-header .page-hero-mobile-logo' );
|
||||
$css->add_property( 'display', 'none' );
|
||||
}
|
||||
|
||||
$css->stop_media_query();
|
||||
|
||||
return apply_filters( 'generate_page_hero_css_output', $css->css_output(), $options );
|
||||
}
|
||||
|
||||
/**
|
||||
* Put all of our meta options within an array.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return array All Page Header options.
|
||||
*/
|
||||
public static function get_options() {
|
||||
$post_id = self::$post_id;
|
||||
|
||||
return apply_filters( 'generate_hero_options', array(
|
||||
'element_id' => $post_id,
|
||||
'content' => get_post_meta( $post_id, '_generate_element_content', true ),
|
||||
'classes' => get_post_meta( $post_id, '_generate_hero_custom_classes', true ),
|
||||
'container' => get_post_meta( $post_id, '_generate_hero_container', true ),
|
||||
'inner_container' => get_post_meta( $post_id, '_generate_hero_inner_container', true ),
|
||||
'horizontal_alignment' => get_post_meta( $post_id, '_generate_hero_horizontal_alignment', true ),
|
||||
'full_screen' => get_post_meta( $post_id, '_generate_hero_full_screen', true ),
|
||||
'vertical_alignment' => get_post_meta( $post_id, '_generate_hero_vertical_alignment', true ),
|
||||
'padding_top' => get_post_meta( $post_id, '_generate_hero_padding_top', true ),
|
||||
'padding_top_unit' => get_post_meta( $post_id, '_generate_hero_padding_top_unit', true ),
|
||||
'padding_right' => get_post_meta( $post_id, '_generate_hero_padding_right', true ),
|
||||
'padding_right_unit' => get_post_meta( $post_id, '_generate_hero_padding_right_unit', true ),
|
||||
'padding_bottom' => get_post_meta( $post_id, '_generate_hero_padding_bottom', true ),
|
||||
'padding_bottom_unit' => get_post_meta( $post_id, '_generate_hero_padding_bottom_unit', true ),
|
||||
'padding_left' => get_post_meta( $post_id, '_generate_hero_padding_left', true ),
|
||||
'padding_left_unit' => get_post_meta( $post_id, '_generate_hero_padding_left_unit', true ),
|
||||
'padding_top_mobile' => get_post_meta( $post_id, '_generate_hero_padding_top_mobile', true ),
|
||||
'padding_top_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_top_unit_mobile', true ),
|
||||
'padding_right_mobile' => get_post_meta( $post_id, '_generate_hero_padding_right_mobile', true ),
|
||||
'padding_right_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_right_unit_mobile', true ),
|
||||
'padding_bottom_mobile' => get_post_meta( $post_id, '_generate_hero_padding_bottom_mobile', true ),
|
||||
'padding_bottom_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_bottom_unit_mobile', true ),
|
||||
'padding_left_mobile' => get_post_meta( $post_id, '_generate_hero_padding_left_mobile', true ),
|
||||
'padding_left_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_left_unit_mobile', true ),
|
||||
'background_image' => get_post_meta( $post_id, '_generate_hero_background_image', true ),
|
||||
'disable_featured_image' => get_post_meta( $post_id, '_generate_hero_disable_featured_image', true ),
|
||||
'background_overlay' => get_post_meta( $post_id, '_generate_hero_background_overlay', true ),
|
||||
'background_position' => get_post_meta( $post_id, '_generate_hero_background_position', true ),
|
||||
'parallax' => get_post_meta( $post_id, '_generate_hero_background_parallax', true ),
|
||||
'background_color' => get_post_meta( $post_id, '_generate_hero_background_color', true ),
|
||||
'text_color' => get_post_meta( $post_id, '_generate_hero_text_color', true ),
|
||||
'link_color' => get_post_meta( $post_id, '_generate_hero_link_color', true ),
|
||||
'link_color_hover' => get_post_meta( $post_id, '_generate_hero_background_link_color_hover', true ),
|
||||
'site_header_merge' => get_post_meta( $post_id, '_generate_site_header_merge', true ),
|
||||
'site_header_height' => get_post_meta( $post_id, '_generate_site_header_height', true ),
|
||||
'site_header_height_mobile' => get_post_meta( $post_id, '_generate_site_header_height_mobile', true ),
|
||||
'site_logo' => get_post_meta( $post_id, '_generate_site_logo', true ),
|
||||
'retina_logo' => get_post_meta( $post_id, '_generate_retina_logo', true ),
|
||||
'navigation_logo' => get_post_meta( $post_id, '_generate_navigation_logo', true ),
|
||||
'mobile_logo' => get_post_meta( $post_id, '_generate_mobile_logo', true ),
|
||||
'navigation_location' => get_post_meta( $post_id, '_generate_navigation_location', true ),
|
||||
'header_background_color' => get_post_meta( $post_id, '_generate_site_header_background_color', true ),
|
||||
'header_title_color' => get_post_meta( $post_id, '_generate_site_header_title_color', true ),
|
||||
'header_tagline_color' => get_post_meta( $post_id, '_generate_site_header_tagline_color', true ),
|
||||
'navigation_colors' => get_post_meta( $post_id, '_generate_navigation_colors', true ),
|
||||
'navigation_background_color' => get_post_meta( $post_id, '_generate_navigation_background_color', true ),
|
||||
'navigation_text_color' => get_post_meta( $post_id, '_generate_navigation_text_color', true ),
|
||||
'navigation_background_color_hover' => get_post_meta( $post_id, '_generate_navigation_background_color_hover', true ),
|
||||
'navigation_text_color_hover' => get_post_meta( $post_id, '_generate_navigation_text_color_hover', true ),
|
||||
'navigation_background_color_current' => get_post_meta( $post_id, '_generate_navigation_background_color_current', true ),
|
||||
'navigation_text_color_current' => get_post_meta( $post_id, '_generate_navigation_text_color_current', true ),
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the bulk of the work after everything has initialized.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function after_setup() {
|
||||
$options = self::get_options();
|
||||
|
||||
if ( $options['disable_featured_image'] && is_singular() ) {
|
||||
remove_action( 'generate_after_entry_header', 'generate_blog_single_featured_image' );
|
||||
remove_action( 'generate_before_content', 'generate_blog_single_featured_image' );
|
||||
remove_action( 'generate_after_header', 'generate_blog_single_featured_image' );
|
||||
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single' );
|
||||
remove_action( 'generate_after_header', 'generate_featured_page_header' );
|
||||
}
|
||||
|
||||
if ( $options['site_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'site-logo' ) ) {
|
||||
if ( '' !== $options['site_header_merge'] ) {
|
||||
add_action( 'generate_after_logo', array( $this, 'add_site_logo' ) );
|
||||
} else {
|
||||
add_filter( 'theme_mod_custom_logo', array( $this, 'replace_logo' ) );
|
||||
|
||||
if ( $options['retina_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'retina-logo' ) ) {
|
||||
add_filter( 'generate_retina_logo', array( $this, 'replace_logo' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $options['navigation_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'navigation-logo' ) ) {
|
||||
if ( $options['site_header_merge'] && GeneratePress_Elements_Helper::does_option_exist( 'sticky-navigation' ) ) {
|
||||
add_action( 'generate_inside_navigation', array( $this, 'add_navigation_logo' ) );
|
||||
} else {
|
||||
add_filter( 'generate_navigation_logo', array( $this, 'replace_logo' ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $options['mobile_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'mobile-logo' ) ) {
|
||||
if ( 'merge' === $options['site_header_merge'] ) {
|
||||
add_action( 'generate_inside_mobile_header', array( $this, 'add_mobile_header_logo' ) );
|
||||
} else {
|
||||
add_filter( 'generate_mobile_header_logo', array( $this, 'replace_logo' ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $options['navigation_location'] ) {
|
||||
add_filter( 'generate_navigation_location', array( $this, 'navigation_location' ) );
|
||||
}
|
||||
|
||||
if ( '' !== $options['site_header_merge'] ) {
|
||||
add_action( 'generate_before_header', array( $this, 'merged_header_start' ), 1 );
|
||||
add_action( 'generate_after_header', array( $this, 'merged_header_end' ), 8 );
|
||||
|
||||
if ( 'contained' === $options['container'] ) {
|
||||
add_filter( 'generate_header_class', array( $this, 'site_header_classes' ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $options['content'] ) {
|
||||
self::remove_template_elements();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns our custom logos if set within the Page Header.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return string New URLs to images.
|
||||
*/
|
||||
public static function replace_logo() {
|
||||
$filter = current_filter();
|
||||
$options = self::get_options();
|
||||
|
||||
if ( 'theme_mod_custom_logo' === $filter ) {
|
||||
return $options['site_logo'];
|
||||
}
|
||||
|
||||
if ( 'generate_retina_logo' === $filter ) {
|
||||
return wp_get_attachment_url( $options['retina_logo'] );
|
||||
}
|
||||
|
||||
if ( 'generate_navigation_logo' === $filter ) {
|
||||
return wp_get_attachment_url( $options['navigation_logo'] );
|
||||
}
|
||||
|
||||
if ( 'generate_mobile_header_logo' === $filter ) {
|
||||
return wp_get_attachment_url( $options['mobile_logo'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new site logo element if our header is merged on desktop only.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function add_site_logo() {
|
||||
$options = self::get_options();
|
||||
|
||||
$logo_url = wp_get_attachment_url( $options['site_logo'] );
|
||||
$retina_logo_url = wp_get_attachment_url( $options['retina_logo'] );
|
||||
|
||||
if ( ! $logo_url ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attr = apply_filters( 'generate_page_hero_logo_attributes', array(
|
||||
'class' => 'header-image',
|
||||
'alt' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
|
||||
'src' => $logo_url,
|
||||
'title' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
|
||||
) );
|
||||
|
||||
if ( '' !== $retina_logo_url ) {
|
||||
$attr['srcset'] = $logo_url . ' 1x, ' . $retina_logo_url . ' 2x';
|
||||
|
||||
// Add dimensions to image if retina is set. This fixes a container width bug in Firefox.
|
||||
$data = wp_get_attachment_metadata( $options['site_logo'] );
|
||||
|
||||
if ( ! empty( $data ) ) {
|
||||
$attr['width'] = $data['width'];
|
||||
$attr['height'] = $data['height'];
|
||||
}
|
||||
}
|
||||
|
||||
$attr = array_map( 'esc_attr', $attr );
|
||||
$html_attr = '';
|
||||
|
||||
foreach ( $attr as $name => $value ) {
|
||||
$html_attr .= " $name=" . '"' . $value . '"';
|
||||
}
|
||||
|
||||
echo apply_filters( 'generate_page_hero_logo_output', sprintf( // WPCS: XSS ok, sanitization ok.
|
||||
'<div class="site-logo page-hero-logo">
|
||||
<a href="%1$s" title="%2$s" rel="home">
|
||||
<img %3$s />
|
||||
</a>
|
||||
</div>',
|
||||
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
|
||||
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
|
||||
$html_attr
|
||||
), $logo_url, $html_attr );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the custom navigation logo if needed.
|
||||
* Only needed if there's a sticky navigation.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function add_navigation_logo() {
|
||||
$options = self::get_options();
|
||||
|
||||
printf(
|
||||
'<div class="site-logo sticky-logo navigation-logo page-hero-navigation-logo">
|
||||
<a href="%1$s" title="%2$s" rel="home">
|
||||
<img class="header-image" src="%3$s" alt="%4$s" />
|
||||
</a>
|
||||
</div>',
|
||||
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
|
||||
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
|
||||
esc_url( wp_get_attachment_url( $options['navigation_logo'] ) ),
|
||||
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the custom mobile header if needed.
|
||||
* Only needed if there's a sticky navigation.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function add_mobile_header_logo() {
|
||||
$options = self::get_options();
|
||||
|
||||
if ( 'title' === GeneratePress_Elements_Helper::does_option_exist( 'mobile-header-branding' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf(
|
||||
'<div class="site-logo mobile-header-logo page-hero-mobile-logo">
|
||||
<a href="%1$s" title="%2$s" rel="home">
|
||||
<img class="header-image" src="%3$s" alt="%4$s" />
|
||||
</a>
|
||||
</div>',
|
||||
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
|
||||
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
|
||||
esc_url( wp_get_attachment_url( $options['mobile_logo'] ) ),
|
||||
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the navigation location if set.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return string The navigation location.
|
||||
*/
|
||||
public static function navigation_location() {
|
||||
$options = self::get_options();
|
||||
|
||||
if ( 'no-navigation' === $options['navigation_location'] ) {
|
||||
return '';
|
||||
} else {
|
||||
return $options['navigation_location'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The opening merged header element.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function merged_header_start() {
|
||||
echo '<div class="header-wrap">';
|
||||
}
|
||||
|
||||
/**
|
||||
* The closing merged header element.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function merged_header_end() {
|
||||
echo '</div><!-- .header-wrap -->';
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds classes to the site header.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param $classes Existing classes.
|
||||
* @return array New classes.
|
||||
*/
|
||||
public static function site_header_classes( $classes ) {
|
||||
$classes[] = 'grid-container';
|
||||
$classes[] = 'grid-parent';
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if template tags exist, and removes those elements from elsewhere.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function remove_template_elements() {
|
||||
$options = self::get_options();
|
||||
|
||||
if ( strpos( $options[ 'content' ], '{{post_title}}' ) !== false ) {
|
||||
add_filter( 'generate_show_title', '__return_false' );
|
||||
remove_action( 'generate_archive_title', 'generate_archive_title' );
|
||||
add_filter( 'post_class', array( self::$hero, 'remove_hentry' ) );
|
||||
}
|
||||
|
||||
if ( strpos( $options[ 'content' ], '{{post_date}}' ) !== false ) {
|
||||
add_filter( 'generate_post_date', '__return_false' );
|
||||
add_filter( 'post_class', array( self::$hero, 'remove_hentry' ) );
|
||||
}
|
||||
|
||||
if ( strpos( $options[ 'content' ], '{{post_author}}' ) !== false ) {
|
||||
add_filter( 'generate_post_author', '__return_false' );
|
||||
add_filter( 'post_class', array( self::$hero, 'remove_hentry' ) );
|
||||
}
|
||||
|
||||
if ( strpos( $options[ 'content' ], '{{post_terms.category}}' ) !== false ) {
|
||||
add_filter( 'generate_show_categories', '__return_false' );
|
||||
}
|
||||
|
||||
if ( strpos( $options[ 'content' ], '{{post_terms.post_tag}}' ) !== false ) {
|
||||
add_filter( 'generate_show_tags', '__return_false' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for template tags and replaces them.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param $content The content to check.
|
||||
* @return mixed The content with the template tags replaced.
|
||||
*/
|
||||
public static function template_tags( $content ) {
|
||||
$search = array();
|
||||
$replace = array();
|
||||
|
||||
$search[] = '{{post_title}}';
|
||||
$post_title = '';
|
||||
|
||||
if ( is_singular() ) {
|
||||
$post_title = get_the_title();
|
||||
} elseif ( is_tax() || is_category() || is_tag() ) {
|
||||
$post_title = get_queried_object()->name;
|
||||
} elseif ( is_post_type_archive() ) {
|
||||
$post_title = post_type_archive_title( '', false );
|
||||
} elseif ( is_archive() && function_exists( 'get_the_archive_title' ) ) {
|
||||
$post_title = get_the_archive_title();
|
||||
} elseif ( is_home() ) {
|
||||
$post_title = __( 'Blog', 'gp-premium' );
|
||||
}
|
||||
|
||||
$replace[] = apply_filters( 'generate_page_hero_post_title', $post_title );
|
||||
|
||||
if ( is_singular() ) {
|
||||
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
|
||||
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
|
||||
$time_string = '<time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>' . $time_string;
|
||||
}
|
||||
|
||||
$time_string = sprintf( $time_string,
|
||||
esc_attr( get_the_date( 'c' ) ),
|
||||
esc_html( get_the_date() ),
|
||||
esc_attr( get_the_modified_date( 'c' ) ),
|
||||
esc_html( get_the_modified_date() )
|
||||
);
|
||||
|
||||
$search[] = '{{post_date}}';
|
||||
$replace[] = apply_filters( 'generate_page_hero_post_date', $time_string );
|
||||
|
||||
// Author
|
||||
global $post;
|
||||
$author_id = $post->post_author;
|
||||
|
||||
$author = sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><a class="url fn n" href="%1$s" title="%2$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%3$s</span></a></span>',
|
||||
esc_url( get_author_posts_url( $author_id ) ),
|
||||
esc_attr( sprintf( __( 'View all posts by %s', 'gp-premium' ), get_the_author_meta( 'display_name', $author_id ) ) ),
|
||||
esc_html( get_the_author_meta( 'display_name', $author_id ) )
|
||||
);
|
||||
|
||||
$search[] = '{{post_author}}';
|
||||
$replace[] = apply_filters( 'generate_page_hero_post_author', $author );
|
||||
|
||||
// Post terms
|
||||
if ( strpos( $content, '{{post_terms' ) !== false ) {
|
||||
$data = preg_match_all( '/{{post_terms.([^}]*)}}/', $content, $matches );
|
||||
foreach ( $matches[1] as $match ) {
|
||||
$search[] = '{{post_terms.' . $match . '}}';
|
||||
$terms = get_the_term_list( get_the_ID(), $match, apply_filters( 'generate_page_hero_terms_before', '' ), apply_filters( 'generate_page_hero_terms_separator', ', ' ), apply_filters( 'generate_page_hero_terms_after', '' ) );
|
||||
|
||||
if ( ! is_wp_error( $terms ) ) {
|
||||
$replace[] = $terms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Custom field
|
||||
if ( strpos( $content, '{{custom_field' ) !== false ) {
|
||||
$data = preg_match_all( '/{{custom_field.([^}]*)}}/', $content, $matches );
|
||||
foreach ( $matches[1] as $match ) {
|
||||
if ( null !== get_post_meta( get_the_ID(), $match, true ) && '_thumbnail_id' !== $match ) {
|
||||
$search[] = '{{custom_field.' . $match . '}}';
|
||||
$replace[] = get_post_meta( get_the_ID(), $match, true );
|
||||
}
|
||||
}
|
||||
|
||||
$thumbnail_id = get_post_meta( get_the_ID(), '_thumbnail_id', true );
|
||||
if ( null !== $thumbnail_id ) {
|
||||
$search[] = '{{custom_field._thumbnail_id}}';
|
||||
$replace[] = wp_get_attachment_image( $thumbnail_id, apply_filters( 'generate_hero_thumbnail_id_size', 'medium' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Taxonomy description
|
||||
if ( is_tax() || is_category() || is_tag() ) {
|
||||
if ( strpos( $content, '{{custom_field' ) !== false ) {
|
||||
$search[] = '{{custom_field.description}}';
|
||||
$replace[] = term_description( get_queried_object()->term_id, get_queried_object()->taxonomy );
|
||||
}
|
||||
}
|
||||
|
||||
return str_replace( $search, $replace, $content );
|
||||
}
|
||||
|
||||
/**
|
||||
* When the post title, author or date are in the Page Hero, they appear outside of the
|
||||
* hentry element. This causes errors in Google Search Console.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param array $classes
|
||||
* @return array
|
||||
*/
|
||||
public function remove_hentry( $classes ) {
|
||||
$classes = array_diff( $classes, array( 'hentry' ) );
|
||||
|
||||
return $classes;
|
||||
}
|
||||
}
|
189
wp-content/plugins/gp-premium/elements/class-hooks.php
Normal file
189
wp-content/plugins/gp-premium/elements/class-hooks.php
Normal file
@ -0,0 +1,189 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute our hook elements.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
class GeneratePress_Hook {
|
||||
|
||||
/**
|
||||
* Set our content variable.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $content = '';
|
||||
|
||||
/**
|
||||
* Set our hook/action variable.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $hook = '';
|
||||
|
||||
/**
|
||||
* Set our custom hook variable.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $custom_hook = '';
|
||||
|
||||
/**
|
||||
* Set our disable site header variable.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $disable_site_header = false;
|
||||
|
||||
/**
|
||||
* Set our disable footer variable.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $disable_site_footer = false;
|
||||
|
||||
/**
|
||||
* Set our priority variable.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $priority = 10;
|
||||
|
||||
/**
|
||||
* Set our execute PHP variable.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $php = false;
|
||||
|
||||
/**
|
||||
* Set our execute shortcodes variable.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $shortcodes = false;
|
||||
|
||||
/**
|
||||
* Set our location variable.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $conditional = array();
|
||||
|
||||
/**
|
||||
* Set our exclusions variable.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $exclude = array();
|
||||
|
||||
/**
|
||||
* Set our user condition variable.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $users = array();
|
||||
|
||||
/**
|
||||
* Set up our class and give variables their values.
|
||||
*
|
||||
* @param int $post_id The post ID of the element we're executing.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
function __construct( $post_id ) {
|
||||
|
||||
$this->hook = get_post_meta( $post_id, '_generate_hook', true );
|
||||
|
||||
if ( empty( $this->hook ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->content = get_post_meta( $post_id, '_generate_element_content', true );
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_custom_hook', true ) ) {
|
||||
$this->custom_hook = get_post_meta( $post_id, '_generate_custom_hook', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_hook_disable_site_header', true ) ) {
|
||||
$this->disable_site_header = get_post_meta( $post_id, '_generate_hook_disable_site_header', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_hook_disable_site_footer', true ) ) {
|
||||
$this->disable_site_footer = get_post_meta( $post_id, '_generate_hook_disable_site_footer', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_hook_priority', true ) || '0' === get_post_meta( $post_id, '_generate_hook_priority', true ) ) {
|
||||
$this->priority = get_post_meta( $post_id, '_generate_hook_priority', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_hook_execute_php', true ) ) {
|
||||
$this->php = get_post_meta( $post_id, '_generate_hook_execute_php', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_hook_execute_shortcodes', true ) ) {
|
||||
$this->shortcodes = get_post_meta( $post_id, '_generate_hook_execute_shortcodes', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_display_conditions', true ) ) {
|
||||
$this->conditional = get_post_meta( $post_id, '_generate_element_display_conditions', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) ) {
|
||||
$this->exclude = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_user_conditions', true ) ) {
|
||||
$this->users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
|
||||
}
|
||||
|
||||
if ( 'custom' === $this->hook && $this->custom_hook ) {
|
||||
$this->hook = $this->custom_hook;
|
||||
}
|
||||
|
||||
$display = apply_filters( 'generate_hook_element_display', GeneratePress_Conditions::show_data( $this->conditional, $this->exclude, $this->users ), $post_id );
|
||||
|
||||
if ( $display ) {
|
||||
if ( 'generate_header' === $this->hook && $this->disable_site_header ) {
|
||||
remove_action( 'generate_header', 'generate_construct_header' );
|
||||
}
|
||||
|
||||
if ( 'generate_footer' === $this->hook && $this->disable_site_footer ) {
|
||||
remove_action( 'generate_footer', 'generate_construct_footer' );
|
||||
add_filter( 'generate_footer_widgets', '__return_null' );
|
||||
}
|
||||
|
||||
add_action( esc_attr( $this->hook ), array( $this, 'execute_hook' ), absint( $this->priority ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Output our hook content.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function execute_hook() {
|
||||
|
||||
$content = $this->content;
|
||||
|
||||
if ( $this->shortcodes ) {
|
||||
$content = do_shortcode( $content );
|
||||
}
|
||||
|
||||
if ( $this->php && GeneratePress_Elements_Helper::should_execute_php() ) {
|
||||
ob_start();
|
||||
// @codingStandardsIgnoreStart
|
||||
eval( '?>' . $content . '<?php ' );
|
||||
// @codingStandardsIgnoreEnd
|
||||
echo ob_get_clean();
|
||||
} else {
|
||||
echo $content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
296
wp-content/plugins/gp-premium/elements/class-layout.php
Normal file
296
wp-content/plugins/gp-premium/elements/class-layout.php
Normal file
@ -0,0 +1,296 @@
|
||||
<?php
|
||||
|
||||
class GeneratePress_Site_Layout {
|
||||
/**
|
||||
* Set our location variable.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $conditional = array();
|
||||
|
||||
/**
|
||||
* Set our exclusion variable.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $exclude = array();
|
||||
|
||||
/**
|
||||
* Set our user condition variable.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected $users = array();
|
||||
|
||||
/**
|
||||
* Set up our other options.
|
||||
*
|
||||
* @since 1.7
|
||||
* @deprecated 1.7.3
|
||||
*/
|
||||
protected static $options = array();
|
||||
|
||||
/**
|
||||
* Set up options.
|
||||
*
|
||||
* @since 1.7.3
|
||||
*/
|
||||
protected $sidebar_layout = null;
|
||||
protected $footer_widgets = null;
|
||||
protected $disable_site_header = null;
|
||||
protected $disable_top_bar = null;
|
||||
protected $disable_primary_navigation = null;
|
||||
protected $disable_secondary_navigation = null;
|
||||
protected $disable_featured_image = null;
|
||||
protected $disable_content_title = null;
|
||||
protected $disable_footer = null;
|
||||
protected $content_area = null;
|
||||
protected $content_width = null;
|
||||
|
||||
/**
|
||||
* Set our post ID.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
protected static $post_id = '';
|
||||
|
||||
/**
|
||||
* Count how many instances are set.
|
||||
*
|
||||
* @since 1.7
|
||||
* @deprecated 1.7.3
|
||||
*/
|
||||
public static $instances = 0;
|
||||
|
||||
/**
|
||||
* Set our class and give our variables values.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param int $post_ID The post ID of our element.
|
||||
*/
|
||||
function __construct( $post_id ) {
|
||||
|
||||
self::$post_id = $post_id;
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_display_conditions', true ) ) {
|
||||
$this->conditional = get_post_meta( $post_id, '_generate_element_display_conditions', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) ) {
|
||||
$this->exclude = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_user_conditions', true ) ) {
|
||||
$this->users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_sidebar_layout', true ) ) {
|
||||
$this->sidebar_layout = get_post_meta( $post_id, '_generate_sidebar_layout', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_footer_widgets', true ) ) {
|
||||
$this->footer_widgets = get_post_meta( $post_id, '_generate_footer_widgets', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_site_header', true ) ) {
|
||||
$this->disable_site_header = get_post_meta( $post_id, '_generate_disable_site_header', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_top_bar', true ) ) {
|
||||
$this->disable_top_bar = get_post_meta( $post_id, '_generate_disable_top_bar', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_primary_navigation', true ) ) {
|
||||
$this->disable_primary_navigation = get_post_meta( $post_id, '_generate_disable_primary_navigation', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_secondary_navigation', true ) ) {
|
||||
$this->disable_secondary_navigation = get_post_meta( $post_id, '_generate_disable_secondary_navigation', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_featured_image', true ) ) {
|
||||
$this->disable_featured_image = get_post_meta( $post_id, '_generate_disable_featured_image', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_content_title', true ) ) {
|
||||
$this->disable_content_title = get_post_meta( $post_id, '_generate_disable_content_title', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_footer', true ) ) {
|
||||
$this->disable_footer = get_post_meta( $post_id, '_generate_disable_footer', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_content_area', true ) ) {
|
||||
$this->content_area = get_post_meta( $post_id, '_generate_content_area', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_content_width', true ) ) {
|
||||
$this->content_width = get_post_meta( $post_id, '_generate_content_width', true );
|
||||
}
|
||||
|
||||
$display = apply_filters( 'generate_layout_element_display', GeneratePress_Conditions::show_data( $this->conditional, $this->exclude, $this->users ), $post_id );
|
||||
|
||||
if ( $display ) {
|
||||
add_action( 'wp', array( $this, 'after_setup' ), 100 );
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'build_css' ), 50 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return our available options.
|
||||
*
|
||||
* @since 1.7
|
||||
* @deprecated 1.7.3
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_options() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiate our set layout changes.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function after_setup() {
|
||||
if ( $this->sidebar_layout && ! self::post_meta_exists( '_generate-sidebar-layout-meta' ) ) {
|
||||
add_filter( 'generate_sidebar_layout', array( $this, 'filter_options' ) );
|
||||
}
|
||||
|
||||
if ( $this->footer_widgets && ! self::post_meta_exists( '_generate-footer-widget-meta' ) ) {
|
||||
add_filter( 'generate_footer_widgets', array( $this, 'filter_options' ) );
|
||||
}
|
||||
|
||||
if ( $this->disable_site_header ) {
|
||||
remove_action( 'generate_header', 'generate_construct_header' );
|
||||
}
|
||||
|
||||
if ( $this->disable_top_bar ) {
|
||||
remove_action( 'generate_before_header', 'generate_top_bar', 5 );
|
||||
}
|
||||
|
||||
if ( $this->disable_primary_navigation ) {
|
||||
add_filter( 'generate_navigation_location', '__return_false', 20 );
|
||||
remove_action( 'generate_after_header', 'generate_menu_plus_mobile_header', 5 );
|
||||
}
|
||||
|
||||
if ( $this->disable_secondary_navigation ) {
|
||||
add_filter( 'has_nav_menu', array( $this, 'disable_secondary_navigation' ), 10, 2 );
|
||||
}
|
||||
|
||||
if ( $this->disable_featured_image ) {
|
||||
remove_action( 'generate_after_entry_header', 'generate_blog_single_featured_image' );
|
||||
remove_action( 'generate_before_content', 'generate_blog_single_featured_image' );
|
||||
remove_action( 'generate_after_header', 'generate_blog_single_featured_image' );
|
||||
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single' );
|
||||
remove_action( 'generate_after_header', 'generate_featured_page_header' );
|
||||
}
|
||||
|
||||
if ( $this->disable_content_title ) {
|
||||
add_filter( 'generate_show_title', '__return_false' );
|
||||
}
|
||||
|
||||
if ( $this->disable_footer ) {
|
||||
remove_action( 'generate_footer', 'generate_construct_footer' );
|
||||
add_filter( 'generate_footer_widgets', '__return_null' );
|
||||
}
|
||||
|
||||
if ( $this->content_area ) {
|
||||
add_filter( 'body_class', array( $this, 'body_classes' ) );
|
||||
}
|
||||
}
|
||||
|
||||
public function build_css() {
|
||||
if ( $this->content_width ) {
|
||||
wp_add_inline_style( 'generate-style', '#content {max-width: ' . absint( $this->content_width ) . 'px;margin-left: auto;margin-right: auto;}' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if our individual post metabox has a value.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param string $meta The meta key we're checking for.
|
||||
* @return bool
|
||||
*/
|
||||
public static function post_meta_exists( $meta ) {
|
||||
if ( ! is_singular() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$value = get_post_meta( get_the_ID(), $meta, true );
|
||||
|
||||
if ( '_generate-footer-widget-meta' === $meta && '0' === $value ) {
|
||||
$value = true;
|
||||
}
|
||||
|
||||
if ( $value ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter our filterable options.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function filter_options() {
|
||||
$filter = current_filter();
|
||||
|
||||
if ( 'generate_sidebar_layout' === $filter ) {
|
||||
return $this->sidebar_layout;
|
||||
}
|
||||
|
||||
if ( 'generate_footer_widgets' === $filter ) {
|
||||
if ( 'no-widgets' === $this->footer_widgets ) {
|
||||
return 0;
|
||||
} else {
|
||||
return $this->footer_widgets;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the Secondary Navigation if set.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param bool $has_nav_menu
|
||||
* @param string $location
|
||||
* @return bool
|
||||
*/
|
||||
public static function disable_secondary_navigation( $has_nav_menu, $location ) {
|
||||
if ( 'secondary' === $location ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $has_nav_menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets any necessary body classes.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param array $classes Our existing body classes.
|
||||
* @return array Our new set of classes.
|
||||
*/
|
||||
public function body_classes( $classes ) {
|
||||
if ( 'full-width' === $this->content_area ) {
|
||||
$classes[] = 'full-width-content';
|
||||
}
|
||||
|
||||
if ( 'contained' === $this->content_area ) {
|
||||
$classes[] = 'contained-content';
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
}
|
2152
wp-content/plugins/gp-premium/elements/class-metabox.php
Normal file
2152
wp-content/plugins/gp-premium/elements/class-metabox.php
Normal file
File diff suppressed because it is too large
Load Diff
277
wp-content/plugins/gp-premium/elements/class-post-type.php
Normal file
277
wp-content/plugins/gp-premium/elements/class-post-type.php
Normal file
@ -0,0 +1,277 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
class GeneratePress_Elements_Post_Type {
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @var instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self;
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build it.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( $this, 'post_type' ) );
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'admin_menu', array( $this, 'menu_item' ), 100 );
|
||||
add_action( 'admin_head', array( $this, 'fix_current_item' ) );
|
||||
add_filter( 'manage_gp_elements_posts_columns', array( $this, 'register_columns' ) );
|
||||
add_action( 'manage_gp_elements_posts_custom_column', array( $this, 'add_columns' ), 10, 2 );
|
||||
add_action( 'restrict_manage_posts', array( $this, 'build_element_type_filter' ) );
|
||||
add_filter( 'pre_get_posts', array( $this, 'filter_element_types' ) );
|
||||
|
||||
self::setup_metabox();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the metabox.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function setup_metabox() {
|
||||
require plugin_dir_path( __FILE__ ) . 'class-metabox.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up our custom post type.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function post_type() {
|
||||
$labels = array(
|
||||
'name' => _x( 'Elements', 'Post Type General Name', 'gp-premium' ),
|
||||
'singular_name' => _x( 'Element', 'Post Type Singular Name', 'gp-premium' ),
|
||||
'menu_name' => __( 'Elements', 'gp-premium' ),
|
||||
'all_items' => __( 'All Elements', 'gp-premium' ),
|
||||
'add_new_item' => __( 'Add New Element', 'gp-premium' ),
|
||||
'new_item' => __( 'New Element', 'gp-premium' ),
|
||||
'edit_item' => __( 'Edit Element', 'gp-premium' ),
|
||||
'update_item' => __( 'Update Element', 'gp-premium' ),
|
||||
'search_items' => __( 'Search Element', 'gp-premium' ),
|
||||
'featured_image' => __( 'Background Image', 'gp-premium' ),
|
||||
'set_featured_image' => __( 'Set background image', 'gp-premium' ),
|
||||
'remove_featured_image' => __( 'Remove background image', 'gp-premium' ),
|
||||
);
|
||||
|
||||
$args = array(
|
||||
'labels' => $labels,
|
||||
'supports' => array( 'title', 'thumbnail' ),
|
||||
'hierarchical' => false,
|
||||
'public' => false,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => false,
|
||||
'can_export' => true,
|
||||
'has_archive' => false,
|
||||
'exclude_from_search' => true,
|
||||
);
|
||||
|
||||
register_post_type( 'gp_elements', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register custom post type columns.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param array $columns Existing CPT columns.
|
||||
* @return array All our CPT columns.
|
||||
*/
|
||||
public function register_columns( $columns ) {
|
||||
$columns['element_type'] = esc_html__( 'Type', 'gp-premium' );
|
||||
$columns['location'] = esc_html__( 'Location', 'gp-premium' );
|
||||
$columns['exclusions'] = esc_html__( 'Exclusions', 'gp-premium' );
|
||||
$columns['users'] = esc_html__( 'Users', 'gp-premium' );
|
||||
|
||||
$new_columns = array();
|
||||
|
||||
// Need to do some funky stuff to display these columns before the date.
|
||||
foreach ( $columns as $key => $value ) {
|
||||
if ( 'date' === $key ) {
|
||||
$new_columns['element_type'] = esc_html__( 'Type', 'gp-premium' );
|
||||
$new_columns['location'] = esc_html__( 'Location', 'gp-premium' );
|
||||
$new_columns['exclusions'] = esc_html__( 'Exclusions', 'gp-premium' );
|
||||
$new_columns['users'] = esc_html__( 'Users', 'gp-premium' );
|
||||
}
|
||||
|
||||
$new_columns[ $key ] = $value;
|
||||
}
|
||||
|
||||
return $new_columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a filter select input to the admin list.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function build_element_type_filter() {
|
||||
if ( 'gp_elements' !== get_post_type() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$values = array(
|
||||
'header' => esc_html__( 'Headers', 'gp-premium' ),
|
||||
'hook' => esc_html__( 'Hooks', 'gp-premium' ),
|
||||
'layout' => esc_html__( 'Layouts', 'gp-premium' ),
|
||||
);
|
||||
|
||||
?>
|
||||
<select name="gp_element_type_filter">
|
||||
<option value=""><?php esc_html_e( 'All types', 'gp-premium' ); ?></option>
|
||||
<?php
|
||||
$current = isset( $_GET['gp_element_type_filter'] )? esc_html( $_GET['gp_element_type_filter'] ) : '';
|
||||
foreach ( $values as $value => $label ) {
|
||||
printf(
|
||||
'<option value="%1$s" %2$s>%3$s</option>',
|
||||
esc_html( $value ),
|
||||
$value === $current ? 'selected="selected"' : '',
|
||||
$label
|
||||
);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the shown elements in the admin list if our filter is set.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param object $query Existing query.
|
||||
*/
|
||||
public function filter_element_types( $query ) {
|
||||
if ( ! isset( $_GET['post_type'] ) || 'gp_elements' != $_GET['post_type'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $pagenow;
|
||||
|
||||
$type = isset( $_GET['gp_element_type_filter'] ) ? $_GET['gp_element_type_filter'] : '';
|
||||
|
||||
if ( 'edit.php' === $pagenow && $query->is_main_query() && '' !== $type ) {
|
||||
$query->set( 'meta_key', '_generate_element_type' );
|
||||
$query->set( 'meta_value', esc_attr( $type ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add content to our custom post type columns.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param string $column The name of the column.
|
||||
* @param int $post_id The ID of the post row.
|
||||
*/
|
||||
public function add_columns( $column, $post_id ) {
|
||||
switch ( $column ) {
|
||||
case 'element_type' :
|
||||
$type = get_post_meta( $post_id, '_generate_element_type', true );
|
||||
|
||||
if ( 'header' === $type ) {
|
||||
echo esc_html__( 'Header', 'gp-premium' );
|
||||
}
|
||||
|
||||
if ( 'hook' === $type ) {
|
||||
echo esc_html__( 'Hook', 'gp-premium' );
|
||||
}
|
||||
|
||||
if ( 'layout' === $type ) {
|
||||
echo esc_html__( 'Layout', 'gp-premium' );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'location' :
|
||||
$location = get_post_meta( $post_id, '_generate_element_display_conditions', true );
|
||||
|
||||
if ( $location ) {
|
||||
foreach ( ( array ) $location as $data ) {
|
||||
echo GeneratePress_Conditions::get_saved_label( $data );
|
||||
echo '<br />';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'exclusions' :
|
||||
$location = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
|
||||
|
||||
if ( $location ) {
|
||||
foreach ( ( array ) $location as $data ) {
|
||||
echo GeneratePress_Conditions::get_saved_label( $data );
|
||||
echo '<br />';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'users' :
|
||||
$users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
|
||||
|
||||
if ( $users ) {
|
||||
foreach ( ( array ) $users as $data ) {
|
||||
if ( strpos( $data, ':' ) !== FALSE ) {
|
||||
$data = substr( $data, strpos( $data, ':' ) + 1 );
|
||||
}
|
||||
|
||||
$return = ucwords( str_replace( '_', ' ', $data ) );
|
||||
|
||||
echo $return . '<br />';
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create our admin menu item.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function menu_item() {
|
||||
add_submenu_page(
|
||||
'themes.php',
|
||||
esc_html__( 'Elements', 'gp-premium' ),
|
||||
esc_html__( 'Elements', 'gp-premium' ),
|
||||
apply_filters( 'generate_elements_admin_menu_capability', 'manage_options' ),
|
||||
'edit.php?post_type=gp_elements'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure our admin menu item is highlighted.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function fix_current_item() {
|
||||
global $parent_file, $submenu_file, $post_type;
|
||||
|
||||
if ( 'gp_elements' === $post_type ) {
|
||||
$parent_file = 'themes.php';
|
||||
$submenu_file = 'edit.php?post_type=gp_elements';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Elements_Post_Type::get_instance();
|
99
wp-content/plugins/gp-premium/elements/elements.php
Normal file
99
wp-content/plugins/gp-premium/elements/elements.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
require plugin_dir_path( __FILE__ ) . 'class-elements-helper.php';
|
||||
require plugin_dir_path( __FILE__ ) . 'class-hooks.php';
|
||||
require plugin_dir_path( __FILE__ ) . 'class-hero.php';
|
||||
require plugin_dir_path( __FILE__ ) . 'class-layout.php';
|
||||
require plugin_dir_path( __FILE__ ) . 'class-conditions.php';
|
||||
require plugin_dir_path( __FILE__ ) . 'class-post-type.php';
|
||||
|
||||
add_action( 'wp', 'generate_premium_do_elements' );
|
||||
/**
|
||||
* Execute our Elements.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
function generate_premium_do_elements() {
|
||||
$args = array(
|
||||
'post_type' => 'gp_elements',
|
||||
'no_found_rows' => true,
|
||||
'post_status' => 'publish',
|
||||
'numberposts' => 500,
|
||||
'fields' => 'ids',
|
||||
'order' => 'ASC',
|
||||
'suppress_filters' => false,
|
||||
);
|
||||
|
||||
// Prevent Polylang from altering the query.
|
||||
if ( function_exists( 'pll_get_post_language' ) ) {
|
||||
$args['lang'] = '';
|
||||
}
|
||||
|
||||
$posts = get_posts( $args );
|
||||
|
||||
foreach ( $posts as $post_id ) {
|
||||
$post_id = apply_filters( 'generate_element_post_id', $post_id );
|
||||
$type = get_post_meta( $post_id, '_generate_element_type', true );
|
||||
|
||||
if ( 'hook' === $type ) {
|
||||
new GeneratePress_Hook( $post_id );
|
||||
}
|
||||
|
||||
if ( 'header' === $type && ! GeneratePress_Hero::$instances ) {
|
||||
new GeneratePress_Hero( $post_id );
|
||||
}
|
||||
|
||||
if ( 'layout' === $type ) {
|
||||
new GeneratePress_Site_Layout( $post_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'generate_dashboard_tabs', 'generate_elements_dashboard_tab' );
|
||||
/**
|
||||
* Add the Sites tab to our Dashboard tabs.
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param array $tabs Existing tabs.
|
||||
* @return array New tabs.
|
||||
*/
|
||||
function generate_elements_dashboard_tab( $tabs ) {
|
||||
$tabs['Elements'] = array(
|
||||
'name' => __( 'Elements', 'gp-premium' ),
|
||||
'url' => admin_url( 'edit.php?post_type=gp_elements' ),
|
||||
'class' => '',
|
||||
);
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
add_filter( 'generate_element_post_id', 'generate_elements_ignore_languages' );
|
||||
/**
|
||||
* Disable Polylang elements if their language doesn't match.
|
||||
* We disable their automatic quering so Elements with no language display by default.
|
||||
*
|
||||
* @since 1.8
|
||||
*
|
||||
* @param int $post_id
|
||||
* @return bool|int
|
||||
*/
|
||||
function generate_elements_ignore_languages( $post_id ) {
|
||||
if ( function_exists( 'pll_get_post_language' ) && function_exists( 'pll_current_language' ) ) {
|
||||
$language = pll_get_post_language( $post_id, 'locale' );
|
||||
$disable = get_post_meta( $post_id, '_generate_element_ignore_languages', true );
|
||||
|
||||
if ( $disable ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
if ( $language && $language !== pll_current_language( 'locale' ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $post_id;
|
||||
}
|
Reference in New Issue
Block a user