updated plugin GP Premium
version 1.11.2
This commit is contained in:
@ -11,10 +11,6 @@ button[data-balloon] {
|
||||
-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;
|
||||
@ -39,10 +35,6 @@ button[data-balloon] {
|
||||
-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;
|
||||
@ -59,120 +51,59 @@ button[data-balloon] {
|
||||
[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");
|
||||
@ -182,27 +113,15 @@ button[data-balloon] {
|
||||
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");
|
||||
@ -212,27 +131,15 @@ button[data-balloon] {
|
||||
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");
|
||||
@ -242,27 +149,15 @@ button[data-balloon] {
|
||||
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");
|
||||
@ -272,27 +167,15 @@ button[data-balloon] {
|
||||
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");
|
||||
@ -302,19 +185,10 @@ button[data-balloon] {
|
||||
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;
|
||||
|
@ -0,0 +1,82 @@
|
||||
.choose-element-type-parent:before {
|
||||
content: "";
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0,0,0,0.5);
|
||||
z-index: 9991;
|
||||
}
|
||||
|
||||
.choose-element-type {
|
||||
position: fixed;
|
||||
width: 500px;
|
||||
background: #fff;
|
||||
left: 50%;
|
||||
padding: 30px;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 0 20px rgba(0,0,0,0.05);
|
||||
border: 1px solid #ddd;
|
||||
z-index: 9992;
|
||||
transform: translate(-50%, -50%);
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
.choose-element-type h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
.choose-element-type button.button {
|
||||
font-size: 17px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.select-type-container {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
button.close-choose-element-type {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
box-shadow: 0 0 0;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
button.close-choose-element-type svg {
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.hook-location {
|
||||
background: #efefef;
|
||||
padding: 2px 5px;
|
||||
font-family: monospace;
|
||||
font-size: 11px;
|
||||
border-radius: 2px;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
$( '.post-type-gp_elements .page-title-action' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
$( '.choose-element-type-parent' ).show();
|
||||
} );
|
||||
|
||||
$( '.close-choose-element-type' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
$( '.choose-element-type-parent' ).hide();
|
||||
} );
|
||||
} );
|
@ -1,16 +1,3 @@
|
||||
.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;
|
||||
@ -60,7 +47,8 @@ td.generate-element-row-content {
|
||||
}
|
||||
|
||||
#generate_premium_elements .handlediv,
|
||||
#generate_premium_elements .hndle {
|
||||
#generate_premium_elements .hndle,
|
||||
#generate_premium_elements .postbox-header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@ -90,16 +78,12 @@ td.generate-element-row-content {
|
||||
}
|
||||
|
||||
#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;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
button.remove-condition {
|
||||
@ -151,7 +135,6 @@ ul.element-metabox-tabs {
|
||||
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;
|
||||
@ -159,7 +142,6 @@ ul.element-metabox-tabs {
|
||||
|
||||
ul.element-metabox-tabs li {
|
||||
width: auto;
|
||||
-ms-flex: none;
|
||||
flex: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
border-top: none;
|
||||
@ -194,27 +176,6 @@ ul.element-metabox-tabs li.is-selected a {
|
||||
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;
|
||||
@ -222,23 +183,24 @@ select.select-type:hover {
|
||||
|
||||
.element-settings.header .element-metabox-tabs li[data-type="header"],
|
||||
.element-settings.hook .element-metabox-tabs li[data-type="hook"],
|
||||
.element-settings.block .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.block table[data-tab="hook-settings"],
|
||||
.element-settings.layout table[data-tab="sidebars"] {
|
||||
display: table;
|
||||
}
|
||||
|
||||
.element-settings.layout #generate-element-content {
|
||||
.element-settings.layout #generate-element-content,
|
||||
.element-settings.block #generate-element-content {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.padding-container {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
@ -252,6 +214,10 @@ select.select-type:hover {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.padding-element-options {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.padding-element span.unit {
|
||||
border: 1px solid #ddd;
|
||||
display: inline-block;
|
||||
@ -270,7 +236,6 @@ select.select-type:hover {
|
||||
.padding-element select {
|
||||
width: auto !important;
|
||||
position: relative;
|
||||
top: -2.5px;
|
||||
left: -5px;
|
||||
min-height: 30px;
|
||||
}
|
||||
@ -278,7 +243,7 @@ select.select-type:hover {
|
||||
.padding-element span {
|
||||
display: block;
|
||||
font-size: 90%;
|
||||
opacity: 0.8;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.generate-element-row-content .responsive-controls.single-responsive-value {
|
||||
@ -311,12 +276,8 @@ select.select-type:hover {
|
||||
.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;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.media-container > input,
|
||||
@ -355,35 +316,6 @@ select.select-type:hover {
|
||||
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;
|
||||
}
|
||||
@ -441,6 +373,16 @@ body .select2-container--default .select2-selection--single {
|
||||
margin-left: -6px;
|
||||
}
|
||||
|
||||
.generate-element-row-content .color-alpha {
|
||||
height: 100% !important;
|
||||
.hide-hook-row,
|
||||
.sidebar-notice {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sidebar-notice {
|
||||
margin-top: 10px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.element-settings.block .generate-elements-settings[data-type="hook"] tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
@ -7,40 +7,27 @@ jQuery(document).ready(function( $ ) {
|
||||
} );
|
||||
}
|
||||
|
||||
if ( $( '.choose-element-type-parent' ).is( ':visible' ) ) {
|
||||
$( '.select-type' ).focus();
|
||||
}
|
||||
$( '#_generate_block_type' ).on( 'change', function() {
|
||||
var _this = $( this ).val();
|
||||
|
||||
$( 'select[name="_generate_element_type"]' ).on( 'change', function() {
|
||||
var _this = $( this ),
|
||||
element = _this.val();
|
||||
|
||||
if ( '' == element ) {
|
||||
return;
|
||||
if ( 'hook' === _this ) {
|
||||
$( '.hook-row' ).removeClass( 'hide-hook-row' );
|
||||
} else {
|
||||
$( '.hook-row' ).addClass( 'hide-hook-row' );
|
||||
}
|
||||
|
||||
$( '.element-settings' ).addClass( element ).removeClass( 'no-element-type' ).css( 'opacity', '' );
|
||||
$( 'body' ).removeClass( 'no-element-type' );
|
||||
$( 'body' ).removeClass( 'right-sidebar-block-type' );
|
||||
$( 'body' ).removeClass( 'left-sidebar-block-type' );
|
||||
$( 'body' ).removeClass( 'header-block-type' );
|
||||
$( 'body' ).removeClass( 'footer-block-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();
|
||||
$( 'body' ).addClass( _this + '-block-type' );
|
||||
|
||||
if ( 'layout' === element ) {
|
||||
$( '#generate-element-content' ).hide();
|
||||
if ( 'left-sidebar' === _this || 'right-sidebar' === _this ) {
|
||||
$( '.sidebar-notice' ).show();
|
||||
} else {
|
||||
$( '.sidebar-notice' ).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() {
|
||||
@ -76,6 +63,10 @@ jQuery(document).ready(function( $ ) {
|
||||
$( '.generate-elements-settings' ).hide();
|
||||
$( '.generate-elements-settings[data-tab="' + tab + '"]' ).show();
|
||||
|
||||
if ( $( '.element-settings' ).hasClass( 'block' ) & 'hook-settings' === tab ) {
|
||||
$( '.generate-elements-settings[data-tab="display-rules"]' ).show();
|
||||
}
|
||||
|
||||
if ( $( '.element-settings' ).hasClass( 'header' ) ) {
|
||||
if ( 'hero' !== tab ) {
|
||||
$( '#generate-element-content' ).next( '.CodeMirror' ).hide();
|
||||
@ -208,6 +199,8 @@ jQuery(document).ready(function( $ ) {
|
||||
|
||||
$( '.condition select.condition-select' ).on( 'change', function() {
|
||||
get_location_objects( $( this ) );
|
||||
|
||||
$( '.elements-no-location-error' ).hide();
|
||||
} );
|
||||
|
||||
$( '.generate-elements-rule-objects-visible' ).each( function() {
|
||||
|
@ -0,0 +1,498 @@
|
||||
/**!
|
||||
* wp-color-picker-alpha
|
||||
*
|
||||
* Overwrite Automattic Iris for enabled Alpha Channel in wpColorPicker
|
||||
* Only run in input and is defined data alpha in true
|
||||
*
|
||||
* Version: 2.1.4
|
||||
* https://github.com/kallookoo/wp-color-picker-alpha
|
||||
* Licensed under the GPLv2 license or later.
|
||||
*/
|
||||
( function( $ ) {
|
||||
// Prevent double-init.
|
||||
if ( $.wp.wpColorPicker.prototype._hasAlpha ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Variable for some backgrounds ( grid )
|
||||
var image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==',
|
||||
// html stuff for wpColorPicker copy of the original color-picker.js
|
||||
_after = '<div class="wp-picker-holder" />',
|
||||
_wrap = '<div class="wp-picker-container" />',
|
||||
_button = '<input type="button" class="button button-small" />',
|
||||
// Prevent CSS issues in < WordPress 4.9
|
||||
_deprecated = ( wpColorPickerL10n.current !== undefined );
|
||||
// Declare some global variables when is deprecated or not
|
||||
if ( _deprecated ) {
|
||||
var _before = '<a tabindex="0" class="wp-color-result" />';
|
||||
} else {
|
||||
var _before = '<button type="button" class="button wp-color-result" aria-expanded="false"><span class="wp-color-result-text"></span></button>',
|
||||
_wrappingLabel = '<label></label>',
|
||||
_wrappingLabelText = '<span class="screen-reader-text"></span>';
|
||||
}
|
||||
/**
|
||||
* Overwrite Color
|
||||
* for enable support rbga
|
||||
*/
|
||||
Color.fn.toString = function() {
|
||||
if ( this._alpha < 1 )
|
||||
return this.toCSS( 'rgba', this._alpha ).replace( /\s+/g, '' );
|
||||
|
||||
var hex = parseInt( this._color, 10 ).toString( 16 );
|
||||
|
||||
if ( this.error )
|
||||
return '';
|
||||
|
||||
if ( hex.length < 6 )
|
||||
hex = ( '00000' + hex ).substr( -6 );
|
||||
|
||||
return '#' + hex;
|
||||
};
|
||||
|
||||
/**
|
||||
* Overwrite wpColorPicker
|
||||
*/
|
||||
$.widget( 'wp.wpColorPicker', $.wp.wpColorPicker, {
|
||||
_hasAlpha: true,
|
||||
/**
|
||||
* @summary Creates the color picker.
|
||||
*
|
||||
* Creates the color picker, sets default values, css classes and wraps it all in HTML.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
_create: function() {
|
||||
// Return early if Iris support is missing.
|
||||
if ( ! $.support.iris ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var self = this,
|
||||
el = self.element;
|
||||
|
||||
// Override default options with options bound to the element.
|
||||
$.extend( self.options, el.data() );
|
||||
|
||||
// Create a color picker which only allows adjustments to the hue.
|
||||
if ( self.options.type === 'hue' ) {
|
||||
return self._createHueOnly();
|
||||
}
|
||||
|
||||
// Bind the close event.
|
||||
self.close = $.proxy( self.close, self );
|
||||
|
||||
self.initialValue = el.val();
|
||||
|
||||
// Add a CSS class to the input field.
|
||||
el.addClass( 'wp-color-picker' );
|
||||
|
||||
if ( _deprecated ) {
|
||||
el.hide().wrap( _wrap );
|
||||
self.wrap = el.parent();
|
||||
self.toggler = $( _before )
|
||||
.insertBefore( el )
|
||||
.css( { backgroundColor : self.initialValue } )
|
||||
.attr( 'title', wpColorPickerL10n.pick )
|
||||
.attr( 'data-current', wpColorPickerL10n.current );
|
||||
self.pickerContainer = $( _after ).insertAfter( el );
|
||||
self.button = $( _button ).addClass('hidden');
|
||||
} else {
|
||||
/*
|
||||
* Check if there's already a wrapping label, e.g. in the Customizer.
|
||||
* If there's no label, add a default one to match the Customizer template.
|
||||
*/
|
||||
if ( ! el.parent( 'label' ).length ) {
|
||||
// Wrap the input field in the default label.
|
||||
el.wrap( _wrappingLabel );
|
||||
// Insert the default label text.
|
||||
self.wrappingLabelText = $( _wrappingLabelText )
|
||||
.insertBefore( el )
|
||||
.text( wpColorPickerL10n.defaultLabel );
|
||||
}
|
||||
|
||||
/*
|
||||
* At this point, either it's the standalone version or the Customizer
|
||||
* one, we have a wrapping label to use as hook in the DOM, let's store it.
|
||||
*/
|
||||
self.wrappingLabel = el.parent();
|
||||
|
||||
// Wrap the label in the main wrapper.
|
||||
self.wrappingLabel.wrap( _wrap );
|
||||
// Store a reference to the main wrapper.
|
||||
self.wrap = self.wrappingLabel.parent();
|
||||
// Set up the toggle button and insert it before the wrapping label.
|
||||
self.toggler = $( _before )
|
||||
.insertBefore( self.wrappingLabel )
|
||||
.css( { backgroundColor: self.initialValue } );
|
||||
// Set the toggle button span element text.
|
||||
self.toggler.find( '.wp-color-result-text' ).text( wpColorPickerL10n.pick );
|
||||
// Set up the Iris container and insert it after the wrapping label.
|
||||
self.pickerContainer = $( _after ).insertAfter( self.wrappingLabel );
|
||||
// Store a reference to the Clear/Default button.
|
||||
self.button = $( _button );
|
||||
}
|
||||
|
||||
// Set up the Clear/Default button.
|
||||
if ( self.options.defaultColor ) {
|
||||
self.button.addClass( 'wp-picker-default' ).val( wpColorPickerL10n.defaultString );
|
||||
if ( ! _deprecated ) {
|
||||
self.button.attr( 'aria-label', wpColorPickerL10n.defaultAriaLabel );
|
||||
}
|
||||
} else {
|
||||
self.button.addClass( 'wp-picker-clear' ).val( wpColorPickerL10n.clear );
|
||||
if ( ! _deprecated ) {
|
||||
self.button.attr( 'aria-label', wpColorPickerL10n.clearAriaLabel );
|
||||
}
|
||||
}
|
||||
|
||||
if ( _deprecated ) {
|
||||
el.wrap( '<span class="wp-picker-input-wrap" />' ).after( self.button );
|
||||
} else {
|
||||
// Wrap the wrapping label in its wrapper and append the Clear/Default button.
|
||||
self.wrappingLabel
|
||||
.wrap( '<span class="wp-picker-input-wrap hidden" />' )
|
||||
.after( self.button );
|
||||
|
||||
/*
|
||||
* The input wrapper now contains the label+input+Clear/Default button.
|
||||
* Store a reference to the input wrapper: we'll use this to toggle
|
||||
* the controls visibility.
|
||||
*/
|
||||
self.inputWrapper = el.closest( '.wp-picker-input-wrap' );
|
||||
}
|
||||
|
||||
el.iris( {
|
||||
target: self.pickerContainer,
|
||||
hide: self.options.hide,
|
||||
width: self.options.width,
|
||||
mode: self.options.mode,
|
||||
palettes: self.options.palettes,
|
||||
/**
|
||||
* @summary Handles the onChange event if one has been defined in the options.
|
||||
*
|
||||
* Handles the onChange event if one has been defined in the options and additionally
|
||||
* sets the background color for the toggler element.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {Event} event The event that's being called.
|
||||
* @param {HTMLElement} ui The HTMLElement containing the color picker.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
change: function( event, ui ) {
|
||||
if ( self.options.alpha ) {
|
||||
self.toggler.css( { 'background-image' : 'url(' + image + ')' } );
|
||||
if ( _deprecated ) {
|
||||
self.toggler.html( '<span class="color-alpha" />' );
|
||||
} else {
|
||||
self.toggler.css( {
|
||||
'position' : 'relative'
|
||||
} );
|
||||
if ( self.toggler.find('span.color-alpha').length == 0 ) {
|
||||
self.toggler.append('<span class="color-alpha" />');
|
||||
}
|
||||
}
|
||||
|
||||
self.toggler.find( 'span.color-alpha' ).css( {
|
||||
'width' : '30px',
|
||||
'height' : '100%',
|
||||
'position' : 'absolute',
|
||||
'top' : 0,
|
||||
'left' : 0,
|
||||
'border-top-left-radius' : '2px',
|
||||
'border-bottom-left-radius' : '2px',
|
||||
'background' : ui.color.toString()
|
||||
} );
|
||||
} else {
|
||||
self.toggler.css( { backgroundColor : ui.color.toString() } );
|
||||
}
|
||||
|
||||
if ( $.isFunction( self.options.change ) ) {
|
||||
self.options.change.call( this, event, ui );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
el.val( self.initialValue );
|
||||
self._addListeners();
|
||||
|
||||
// Force the color picker to always be closed on initial load.
|
||||
if ( ! self.options.hide ) {
|
||||
self.toggler.click();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @summary Binds event listeners to the color picker.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @access private
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
_addListeners: function() {
|
||||
var self = this;
|
||||
|
||||
/**
|
||||
* @summary Prevent any clicks inside this widget from leaking to the top and closing it.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {Event} event The event that's being called.
|
||||
*
|
||||
* @returs {void}
|
||||
*/
|
||||
self.wrap.on( 'click.wpcolorpicker', function( event ) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
/**
|
||||
* @summary Open or close the color picker depending on the class.
|
||||
*
|
||||
* @since 3.5
|
||||
*/
|
||||
self.toggler.click( function(){
|
||||
if ( self.toggler.hasClass( 'wp-picker-open' ) ) {
|
||||
self.close();
|
||||
} else {
|
||||
self.open();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @summary Checks if value is empty when changing the color in the color picker.
|
||||
*
|
||||
* Checks if value is empty when changing the color in the color picker.
|
||||
* If so, the background color is cleared.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {Event} event The event that's being called.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
self.element.on( 'change', function( event ) {
|
||||
// Empty or Error = clear
|
||||
if ( $( this ).val() === '' || self.element.hasClass( 'iris-error' ) ) {
|
||||
if ( self.options.alpha ) {
|
||||
if ( _deprecated ) {
|
||||
self.toggler.removeAttr( 'style' );
|
||||
}
|
||||
self.toggler.find( 'span.color-alpha' ).css( 'backgroundColor', '' );
|
||||
} else {
|
||||
self.toggler.css( 'backgroundColor', '' );
|
||||
}
|
||||
|
||||
// fire clear callback if we have one
|
||||
if ( $.isFunction( self.options.clear ) )
|
||||
self.options.clear.call( this, event );
|
||||
}
|
||||
} );
|
||||
|
||||
/**
|
||||
* @summary Enables the user to clear or revert the color in the color picker.
|
||||
*
|
||||
* Enables the user to either clear the color in the color picker or revert back to the default color.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*
|
||||
* @param {Event} event The event that's being called.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
self.button.on( 'click', function( event ) {
|
||||
if ( $( this ).hasClass( 'wp-picker-clear' ) ) {
|
||||
self.element.val( '' );
|
||||
if ( self.options.alpha ) {
|
||||
if ( _deprecated ) {
|
||||
self.toggler.removeAttr( 'style' );
|
||||
}
|
||||
self.toggler.find( 'span.color-alpha' ).css( 'backgroundColor', '' );
|
||||
} else {
|
||||
self.toggler.css( 'backgroundColor', '' );
|
||||
}
|
||||
|
||||
if ( $.isFunction( self.options.clear ) )
|
||||
self.options.clear.call( this, event );
|
||||
|
||||
self.element.trigger( 'change' );
|
||||
} else if ( $( this ).hasClass( 'wp-picker-default' ) ) {
|
||||
self.element.val( self.options.defaultColor ).change();
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Overwrite iris
|
||||
*/
|
||||
$.widget( 'a8c.iris', $.a8c.iris, {
|
||||
_create: function() {
|
||||
this._super();
|
||||
|
||||
// Global option for check is mode rbga is enabled
|
||||
this.options.alpha = this.element.data( 'alpha' ) || false;
|
||||
|
||||
// Is not input disabled
|
||||
if ( ! this.element.is( ':input' ) )
|
||||
this.options.alpha = false;
|
||||
|
||||
if ( typeof this.options.alpha !== 'undefined' && this.options.alpha ) {
|
||||
var self = this,
|
||||
el = self.element,
|
||||
_html = '<div class="iris-strip iris-slider iris-alpha-slider"><div class="iris-slider-offset iris-slider-offset-alpha"></div></div>',
|
||||
aContainer = $( _html ).appendTo( self.picker.find( '.iris-picker-inner' ) ),
|
||||
aSlider = aContainer.find( '.iris-slider-offset-alpha' ),
|
||||
controls = {
|
||||
aContainer : aContainer,
|
||||
aSlider : aSlider
|
||||
};
|
||||
|
||||
if ( typeof el.data( 'custom-width' ) !== 'undefined' ) {
|
||||
self.options.customWidth = parseInt( el.data( 'custom-width' ) ) || 0;
|
||||
} else {
|
||||
self.options.customWidth = 100;
|
||||
}
|
||||
|
||||
// Set default width for input reset
|
||||
self.options.defaultWidth = el.width();
|
||||
|
||||
// Update width for input
|
||||
if ( self._color._alpha < 1 || self._color.toString().indexOf('rgb') != -1 )
|
||||
el.width( parseInt( self.options.defaultWidth + self.options.customWidth ) );
|
||||
|
||||
// Push new controls
|
||||
$.each( controls, function( k, v ) {
|
||||
self.controls[k] = v;
|
||||
} );
|
||||
|
||||
// Change size strip and add margin for sliders
|
||||
self.controls.square.css( { 'margin-right': '0' } );
|
||||
var emptyWidth = ( self.picker.width() - self.controls.square.width() - 20 ),
|
||||
stripsMargin = ( emptyWidth / 6 ),
|
||||
stripsWidth = ( ( emptyWidth / 2 ) - stripsMargin );
|
||||
|
||||
$.each( [ 'aContainer', 'strip' ], function( k, v ) {
|
||||
self.controls[v].width( stripsWidth ).css( { 'margin-left' : stripsMargin + 'px' } );
|
||||
} );
|
||||
|
||||
// Add new slider
|
||||
self._initControls();
|
||||
|
||||
// For updated widget
|
||||
self._change();
|
||||
}
|
||||
},
|
||||
_initControls: function() {
|
||||
this._super();
|
||||
|
||||
if ( this.options.alpha ) {
|
||||
var self = this,
|
||||
controls = self.controls;
|
||||
|
||||
controls.aSlider.slider({
|
||||
orientation : 'vertical',
|
||||
min : 0,
|
||||
max : 100,
|
||||
step : 1,
|
||||
value : parseInt( self._color._alpha * 100 ),
|
||||
slide : function( event, ui ) {
|
||||
// Update alpha value
|
||||
self._color._alpha = parseFloat( ui.value / 100 );
|
||||
self._change.apply( self, arguments );
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
_change: function() {
|
||||
this._super();
|
||||
|
||||
var self = this,
|
||||
el = self.element;
|
||||
|
||||
if ( this.options.alpha ) {
|
||||
var controls = self.controls,
|
||||
alpha = parseInt( self._color._alpha * 100 ),
|
||||
color = self._color.toRgb(),
|
||||
gradient = [
|
||||
'rgb(' + color.r + ',' + color.g + ',' + color.b + ') 0%',
|
||||
'rgba(' + color.r + ',' + color.g + ',' + color.b + ', 0) 100%'
|
||||
],
|
||||
defaultWidth = self.options.defaultWidth,
|
||||
customWidth = self.options.customWidth,
|
||||
target = self.picker.closest( '.wp-picker-container' ).find( '.wp-color-result' );
|
||||
|
||||
// Generate background slider alpha, only for CSS3 old browser fuck!! :)
|
||||
controls.aContainer.css( { 'background' : 'linear-gradient(to bottom, ' + gradient.join( ', ' ) + '), url(' + image + ')' } );
|
||||
|
||||
if ( target.hasClass( 'wp-picker-open' ) ) {
|
||||
// Update alpha value
|
||||
controls.aSlider.slider( 'value', alpha );
|
||||
|
||||
/**
|
||||
* Disabled change opacity in default slider Saturation ( only is alpha enabled )
|
||||
* and change input width for view all value
|
||||
*/
|
||||
if ( self._color._alpha < 1 ) {
|
||||
controls.strip.attr( 'style', controls.strip.attr( 'style' ).replace( /rgba\(([0-9]+,)(\s+)?([0-9]+,)(\s+)?([0-9]+)(,(\s+)?[0-9\.]+)\)/g, 'rgb($1$3$5)' ) );
|
||||
el.width( parseInt( defaultWidth + customWidth ) );
|
||||
} else {
|
||||
el.width( defaultWidth );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var reset = el.data( 'reset-alpha' ) || false;
|
||||
|
||||
if ( reset ) {
|
||||
self.picker.find( '.iris-palette-container' ).on( 'click.palette', '.iris-palette', function() {
|
||||
self._color._alpha = 1;
|
||||
self.active = 'external';
|
||||
self._change();
|
||||
} );
|
||||
}
|
||||
el.trigger( 'change' );
|
||||
},
|
||||
_addInputListeners: function( input ) {
|
||||
var self = this,
|
||||
debounceTimeout = 100,
|
||||
callback = function( event ) {
|
||||
var color = new Color( input.val() ),
|
||||
val = input.val();
|
||||
|
||||
input.removeClass( 'iris-error' );
|
||||
// we gave a bad color
|
||||
if ( color.error ) {
|
||||
// don't error on an empty input
|
||||
if ( val !== '' )
|
||||
input.addClass( 'iris-error' );
|
||||
} else {
|
||||
if ( color.toString() !== self._color.toString() ) {
|
||||
// let's not do this on keyup for hex shortcodes
|
||||
if ( ! ( event.type === 'keyup' && val.match( /^[0-9a-fA-F]{3}$/ ) ) )
|
||||
self._setOption( 'color', color.toString() );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
input.on( 'change', callback ).on( 'keyup', self._debounce( callback, debounceTimeout ) );
|
||||
|
||||
// If we initialized hidden, show on first focus. The rest is up to you.
|
||||
if ( self.options.hide ) {
|
||||
input.on( 'focus', function() {
|
||||
self.show();
|
||||
} );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
||||
|
||||
// Auto Call plugin is class is color-picker
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
$( '.color-picker' ).wpColorPicker();
|
||||
} );
|
File diff suppressed because one or more lines are too long
163
wp-content/plugins/gp-premium/elements/class-block.php
Normal file
163
wp-content/plugins/gp-premium/elements/class-block.php
Normal file
@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/**
|
||||
* This file displays our block elements on the site.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Build our Block Elements.
|
||||
*/
|
||||
class GeneratePress_Block_Element {
|
||||
|
||||
/**
|
||||
* The element ID.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @var int ID of the element.
|
||||
*/
|
||||
protected $post_id = '';
|
||||
|
||||
/**
|
||||
* The element type.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @var string Type of element.
|
||||
*/
|
||||
protected $type = '';
|
||||
|
||||
/**
|
||||
* Kicks it all off.
|
||||
*
|
||||
* @since 1.11.0
|
||||
*
|
||||
* @param int $post_id The element post ID.
|
||||
*/
|
||||
public function __construct( $post_id ) {
|
||||
$this->post_id = $post_id;
|
||||
$this->type = get_post_meta( $post_id, '_generate_block_type', true );
|
||||
|
||||
$display_conditions = get_post_meta( $post_id, '_generate_element_display_conditions', true ) ? get_post_meta( $post_id, '_generate_element_display_conditions', true ) : array();
|
||||
$exclude_conditions = get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) ? get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) : array();
|
||||
$user_conditions = get_post_meta( $post_id, '_generate_element_user_conditions', true ) ? get_post_meta( $post_id, '_generate_element_user_conditions', true ) : array();
|
||||
|
||||
$display = apply_filters(
|
||||
'generate_block_element_display',
|
||||
GeneratePress_Conditions::show_data(
|
||||
$display_conditions,
|
||||
$exclude_conditions,
|
||||
$user_conditions
|
||||
),
|
||||
$post_id
|
||||
);
|
||||
|
||||
if ( $display ) {
|
||||
$hook = get_post_meta( $post_id, '_generate_hook', true );
|
||||
$custom_hook = get_post_meta( $post_id, '_generate_custom_hook', true );
|
||||
$priority = get_post_meta( $post_id, '_generate_hook_priority', true );
|
||||
|
||||
if ( '' === $priority ) {
|
||||
$priority = 10;
|
||||
}
|
||||
|
||||
switch ( $this->type ) {
|
||||
case 'site-header':
|
||||
$hook = 'generate_header';
|
||||
break;
|
||||
|
||||
case 'site-footer':
|
||||
$hook = 'generate_footer';
|
||||
break;
|
||||
|
||||
case 'right-sidebar':
|
||||
$hook = 'generate_before_right_sidebar_content';
|
||||
break;
|
||||
|
||||
case 'left-sidebar':
|
||||
$hook = 'generate_before_left_sidebar_content';
|
||||
break;
|
||||
|
||||
case 'custom':
|
||||
$hook = $custom_hook;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! $hook ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'generate_header' === $hook ) {
|
||||
remove_action( 'generate_header', 'generate_construct_header' );
|
||||
}
|
||||
|
||||
if ( 'generate_footer' === $hook ) {
|
||||
remove_action( 'generate_footer', 'generate_construct_footer' );
|
||||
}
|
||||
|
||||
add_action( esc_attr( $hook ), array( $this, 'build_hook' ), absint( $priority ) );
|
||||
|
||||
if ( 'right-sidebar' === $this->type || 'left-sidebar' === $this->type ) {
|
||||
add_filter( 'sidebars_widgets', array( $this, 'remove_sidebar_widgets' ) );
|
||||
add_filter( 'generate_show_default_sidebar_widgets', '__return_false' );
|
||||
}
|
||||
|
||||
add_filter( 'generateblocks_do_content', array( $this, 'do_block_content' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell GenerateBlocks about our block element content so it can build CSS.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @param string $content The existing content.
|
||||
*/
|
||||
public function do_block_content( $content ) {
|
||||
if ( has_blocks( $this->post_id ) ) {
|
||||
$block_element = get_post( $this->post_id );
|
||||
|
||||
if ( ! $block_element || 'gp_elements' !== $block_element->post_type ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
if ( 'publish' !== $block_element->post_status || ! empty( $block_element->post_password ) ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
$content .= $block_element->post_content;
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove existing sidebar widgets.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @param array $widgets The existing widgets.
|
||||
*/
|
||||
public function remove_sidebar_widgets( $widgets ) {
|
||||
if ( 'right-sidebar' === $this->type ) {
|
||||
unset( $widgets['sidebar-1'] );
|
||||
}
|
||||
|
||||
if ( 'left-sidebar' === $this->type ) {
|
||||
unset( $widgets['sidebar-2'] );
|
||||
}
|
||||
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the HTML structure for Page Headers.
|
||||
*
|
||||
* @since 1.11.0
|
||||
*/
|
||||
public function build_hook() {
|
||||
echo GeneratePress_Elements_Helper::build_content( $this->post_id); // phpcs:ignore -- No escaping needed.
|
||||
}
|
||||
}
|
@ -1,9 +1,17 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
/**
|
||||
* This file handles the Display Rule conditions for Elements.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* The conditions class.
|
||||
*/
|
||||
class GeneratePress_Conditions {
|
||||
/**
|
||||
* Instance.
|
||||
@ -17,7 +25,7 @@ class GeneratePress_Conditions {
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self;
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
@ -33,25 +41,28 @@ class GeneratePress_Conditions {
|
||||
public static function get_conditions() {
|
||||
$types = array(
|
||||
'general' => array(
|
||||
'label' => esc_attr__( 'General', 'gp-premium' ),
|
||||
'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' ),
|
||||
)
|
||||
)
|
||||
'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' );
|
||||
$post_types = get_post_types(
|
||||
array(
|
||||
'public' => true,
|
||||
),
|
||||
'objects'
|
||||
);
|
||||
|
||||
foreach ( $post_types as $post_type_slug => $post_type ) {
|
||||
|
||||
@ -67,15 +78,17 @@ class GeneratePress_Conditions {
|
||||
$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 )
|
||||
)
|
||||
'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 ) ) {
|
||||
if ( 'post' === $post_type_slug || ! empty( $post_type_object->has_archive ) ) {
|
||||
$types[ $post_type_slug . '_archive' ] = array(
|
||||
/* translators: post type name */
|
||||
'label' => sprintf( esc_html_x( '%s Archives', '%s is a singular post type name', 'gp-premium' ), $post_type->labels->singular_name ),
|
||||
'locations' => array(
|
||||
/* translators: post type name */
|
||||
'archive:' . $post_type_slug => sprintf( esc_html_x( '%s Archive', '%s is a singular post type name', 'gp-premium' ), $post_type->labels->singular_name ),
|
||||
),
|
||||
);
|
||||
@ -88,23 +101,28 @@ class GeneratePress_Conditions {
|
||||
|
||||
$public = $taxonomy->public && $taxonomy->show_ui;
|
||||
|
||||
if ( 'post_format' == $taxonomy_slug ) {
|
||||
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 );
|
||||
$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 );
|
||||
/* translators: '%1$s is post type label. %2$s is taxonomy label. */
|
||||
$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 );
|
||||
$types[ $post_type_slug ]['locations'][ $post_type_slug . ':taxonomy:' . $taxonomy_slug ] = esc_html( $post_type->labels->singular_name . ' ' . $label );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -122,17 +140,17 @@ class GeneratePress_Conditions {
|
||||
public static function get_user_conditions() {
|
||||
$rules = array(
|
||||
'general' => array(
|
||||
'label' => esc_attr__( 'General', 'gp-premium' ),
|
||||
'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' ),
|
||||
)
|
||||
'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();
|
||||
@ -207,6 +225,37 @@ class GeneratePress_Conditions {
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( isset( $current_screen->is_block_editor ) && $current_screen->is_block_editor ) {
|
||||
$post_id = false;
|
||||
|
||||
if ( isset( $_GET['post'] ) ) { // phpcs:ignore -- Just checking if it's set.
|
||||
$post_id = absint( $_GET['post'] ); // phpcs:ignore -- No data processing going on.
|
||||
}
|
||||
|
||||
if ( $post_id ) {
|
||||
|
||||
// Get the location string.
|
||||
$front_page_id = get_option( 'page_on_front' );
|
||||
$blog_id = get_option( 'page_for_posts' );
|
||||
|
||||
if ( (int) $post_id === (int) $front_page_id ) {
|
||||
$location = 'general:front_page';
|
||||
} elseif ( (int) $post_id === (int) $blog_id ) {
|
||||
$location = 'general:blog';
|
||||
} else {
|
||||
if ( isset( $current_screen->post_type ) ) {
|
||||
$location = 'post:' . $current_screen->post_type;
|
||||
}
|
||||
|
||||
$object = $post_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'rule' => $location,
|
||||
'object' => $object,
|
||||
@ -230,7 +279,7 @@ class GeneratePress_Conditions {
|
||||
|
||||
$user = wp_get_current_user();
|
||||
|
||||
foreach ( ( array ) $user->roles as $role ) {
|
||||
foreach ( (array) $user->roles as $role ) {
|
||||
$status[] = $role;
|
||||
}
|
||||
|
||||
@ -242,6 +291,9 @@ class GeneratePress_Conditions {
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param array $conditionals The conditions.
|
||||
* @param array $exclude The exclusions.
|
||||
* @param array $roles The roles.
|
||||
* @return bool
|
||||
*/
|
||||
public static function show_data( $conditionals, $exclude, $roles ) {
|
||||
@ -250,7 +302,7 @@ class GeneratePress_Conditions {
|
||||
|
||||
// Show depending on location conditionals.
|
||||
if ( ! $show ) {
|
||||
foreach( ( array ) $conditionals as $conditional ) {
|
||||
foreach ( (array) $conditionals as $conditional ) {
|
||||
if ( in_array( 'general:site', $conditional ) ) {
|
||||
$show = true;
|
||||
} elseif ( is_singular() && in_array( 'general:singular', $conditional ) ) {
|
||||
@ -280,7 +332,7 @@ class GeneratePress_Conditions {
|
||||
|
||||
// Exclude based on exclusion conditionals.
|
||||
if ( $show ) {
|
||||
foreach( ( array ) $exclude as $conditional ) {
|
||||
foreach ( (array) $exclude as $conditional ) {
|
||||
if ( is_singular() && in_array( 'general:singular', $conditional ) ) {
|
||||
$show = false;
|
||||
} elseif ( is_archive() && in_array( 'general:archive', $conditional ) ) {
|
||||
@ -294,7 +346,7 @@ class GeneratePress_Conditions {
|
||||
}
|
||||
}
|
||||
} elseif ( is_singular() && strstr( $conditional['rule'], ':taxonomy:' ) ) {
|
||||
$tax = substr( $conditional['rule'], strrpos( $conditional['rule'], ':') + 1 );
|
||||
$tax = substr( $conditional['rule'], strrpos( $conditional['rule'], ':' ) + 1 );
|
||||
|
||||
if ( $tax && isset( $conditional['object'] ) && has_term( $conditional['object'], $tax ) ) {
|
||||
$show = false;
|
||||
@ -323,11 +375,11 @@ class GeneratePress_Conditions {
|
||||
* Returns the label for a saved location.
|
||||
*
|
||||
* @since 1.7
|
||||
* @param string $saved_location
|
||||
* @param string $saved_location The location.
|
||||
* @return string|bool
|
||||
*/
|
||||
static public function get_saved_label( $saved_location ) {
|
||||
$locations = self::get_conditions();
|
||||
public static function get_saved_label( $saved_location ) {
|
||||
$locations = self::get_conditions();
|
||||
|
||||
$rule = $saved_location['rule'];
|
||||
$object_id = $saved_location['object'];
|
||||
|
@ -1,8 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* This file contains helper functions for Elements.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper functions.
|
||||
*/
|
||||
class GeneratePress_Elements_Helper {
|
||||
/**
|
||||
* Instance.
|
||||
@ -21,7 +30,7 @@ class GeneratePress_Elements_Helper {
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self;
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
@ -32,6 +41,7 @@ class GeneratePress_Elements_Helper {
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param string $option Option to check.
|
||||
* @return bool
|
||||
*/
|
||||
public static function does_option_exist( $option ) {
|
||||
@ -96,6 +106,9 @@ class GeneratePress_Elements_Helper {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether we should execute PHP or not.
|
||||
*/
|
||||
public static function should_execute_php() {
|
||||
$php = true;
|
||||
|
||||
@ -105,4 +118,30 @@ class GeneratePress_Elements_Helper {
|
||||
|
||||
return apply_filters( 'generate_hooks_execute_php', $php );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build our HTML generated by the blocks.
|
||||
*
|
||||
* @since 1.11.0
|
||||
*
|
||||
* @param int $id The ID to check.
|
||||
* @return string
|
||||
*/
|
||||
public static function build_content( $id ) {
|
||||
if ( ! function_exists( 'do_blocks' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$block_element = get_post( $id );
|
||||
|
||||
if ( ! $block_element || 'gp_elements' !== $block_element->post_type ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( 'publish' !== $block_element->post_status || ! empty( $block_element->post_password ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return apply_filters( 'generate_do_block_element_content', do_blocks( $block_element->post_content ) );
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the Header Element type.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* The Header Element type.
|
||||
*/
|
||||
class GeneratePress_Hero {
|
||||
/**
|
||||
* Our conditionals for this header.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array Conditions.
|
||||
*/
|
||||
protected $conditional = array();
|
||||
|
||||
@ -12,6 +25,7 @@ class GeneratePress_Hero {
|
||||
* Our exclusions for this header.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array Exclusions.
|
||||
*/
|
||||
protected $exclude = array();
|
||||
|
||||
@ -19,6 +33,7 @@ class GeneratePress_Hero {
|
||||
* Our user conditionals for this header.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array Users.
|
||||
*/
|
||||
protected $users = array();
|
||||
|
||||
@ -26,6 +41,7 @@ class GeneratePress_Hero {
|
||||
* Our array of available options.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array Options.
|
||||
*/
|
||||
protected static $options = array();
|
||||
|
||||
@ -33,6 +49,7 @@ class GeneratePress_Hero {
|
||||
* The element ID.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var int Post ID.
|
||||
*/
|
||||
protected static $post_id = '';
|
||||
|
||||
@ -40,6 +57,7 @@ class GeneratePress_Hero {
|
||||
* How many times this class has been called per page.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var int Instances.
|
||||
*/
|
||||
public static $instances = 0;
|
||||
|
||||
@ -47,6 +65,7 @@ class GeneratePress_Hero {
|
||||
* Get our current instance.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var instance This hero.
|
||||
*/
|
||||
protected static $hero = '';
|
||||
|
||||
@ -54,10 +73,9 @@ class GeneratePress_Hero {
|
||||
* Kicks it all off.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param int The element post ID.
|
||||
* @param int $post_id The element post ID.
|
||||
*/
|
||||
function __construct( $post_id ) {
|
||||
public function __construct( $post_id ) {
|
||||
|
||||
self::$post_id = $post_id;
|
||||
|
||||
@ -81,9 +99,9 @@ class GeneratePress_Hero {
|
||||
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 );
|
||||
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++;
|
||||
}
|
||||
@ -102,9 +120,13 @@ class GeneratePress_Hero {
|
||||
|
||||
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 ),
|
||||
) );
|
||||
wp_localize_script(
|
||||
'generate-hero-parallax',
|
||||
'hero',
|
||||
array(
|
||||
'parallax' => apply_filters( 'generate_hero_parallax_speed', 2 ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,30 +142,41 @@ class GeneratePress_Hero {
|
||||
return;
|
||||
}
|
||||
|
||||
$options['container_classes'] = implode( ' ', array(
|
||||
'page-hero',
|
||||
'contained' === $options['container'] ? 'grid-container grid-parent' : '',
|
||||
$options['classes'],
|
||||
) );
|
||||
$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['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 );
|
||||
// phpcs:ignore -- No escaping needed.
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -156,9 +189,9 @@ class GeneratePress_Hero {
|
||||
public static function build_css() {
|
||||
$options = self::get_options();
|
||||
|
||||
// Initiate our CSS class
|
||||
// Initiate our CSS class.
|
||||
require_once GP_LIBRARY_DIRECTORY . 'class-make-css.php';
|
||||
$css = new GeneratePress_Pro_CSS;
|
||||
$css = new GeneratePress_Pro_CSS();
|
||||
|
||||
$image_url = false;
|
||||
if ( $options['background_image'] && function_exists( 'get_the_post_thumbnail_url' ) ) {
|
||||
@ -180,16 +213,16 @@ class GeneratePress_Hero {
|
||||
$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_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';
|
||||
$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';
|
||||
$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' );
|
||||
|
||||
@ -349,24 +382,24 @@ class GeneratePress_Hero {
|
||||
$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->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' ] ) );
|
||||
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->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' ] ) );
|
||||
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' ] ) );
|
||||
$css->add_property( 'color', esc_attr( $options['navigation_text_color'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -467,59 +500,62 @@ class GeneratePress_Hero {
|
||||
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 ),
|
||||
) );
|
||||
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 ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -627,12 +663,15 @@ class GeneratePress_Hero {
|
||||
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' ) ) ),
|
||||
) );
|
||||
$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';
|
||||
@ -653,16 +692,22 @@ class GeneratePress_Hero {
|
||||
$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' ) ) ),
|
||||
// phpcs:ignore -- Escaping not needed.
|
||||
echo apply_filters(
|
||||
'generate_page_hero_logo_output',
|
||||
sprintf(
|
||||
'<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
|
||||
), $logo_url, $html_attr );
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -680,7 +725,7 @@ class GeneratePress_Hero {
|
||||
<img class="header-image" src="%3$s" alt="%4$s" />
|
||||
</a>
|
||||
</div>',
|
||||
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
|
||||
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' ) ) )
|
||||
@ -706,7 +751,7 @@ class GeneratePress_Hero {
|
||||
<img class="header-image" src="%3$s" alt="%4$s" />
|
||||
</a>
|
||||
</div>',
|
||||
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
|
||||
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' ) ) )
|
||||
@ -753,7 +798,7 @@ class GeneratePress_Hero {
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param $classes Existing classes.
|
||||
* @param array $classes Existing classes.
|
||||
* @return array New classes.
|
||||
*/
|
||||
public static function site_header_classes( $classes ) {
|
||||
@ -771,27 +816,27 @@ class GeneratePress_Hero {
|
||||
public static function remove_template_elements() {
|
||||
$options = self::get_options();
|
||||
|
||||
if ( strpos( $options[ 'content' ], '{{post_title}}' ) !== false ) {
|
||||
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 ) {
|
||||
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 ) {
|
||||
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 ) {
|
||||
if ( strpos( $options['content'], '{{post_terms.category}}' ) !== false ) {
|
||||
add_filter( 'generate_show_categories', '__return_false' );
|
||||
}
|
||||
|
||||
if ( strpos( $options[ 'content' ], '{{post_terms.post_tag}}' ) !== false ) {
|
||||
if ( strpos( $options['content'], '{{post_terms.post_tag}}' ) !== false ) {
|
||||
add_filter( 'generate_show_tags', '__return_false' );
|
||||
}
|
||||
}
|
||||
@ -801,7 +846,7 @@ class GeneratePress_Hero {
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param $content The content to check.
|
||||
* @param string $content The content to check.
|
||||
* @return mixed The content with the template tags replaced.
|
||||
*/
|
||||
public static function template_tags( $content ) {
|
||||
@ -831,7 +876,8 @@ class GeneratePress_Hero {
|
||||
$time_string = '<time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>' . $time_string;
|
||||
}
|
||||
|
||||
$time_string = sprintf( $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' ) ),
|
||||
@ -841,12 +887,14 @@ class GeneratePress_Hero {
|
||||
$search[] = '{{post_date}}';
|
||||
$replace[] = apply_filters( 'generate_page_hero_post_date', $time_string );
|
||||
|
||||
// Author
|
||||
// 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>',
|
||||
$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 ) ),
|
||||
/* translators: author name */
|
||||
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 ) )
|
||||
);
|
||||
@ -854,7 +902,7 @@ class GeneratePress_Hero {
|
||||
$search[] = '{{post_author}}';
|
||||
$replace[] = apply_filters( 'generate_page_hero_post_author', $author );
|
||||
|
||||
// Post terms
|
||||
// Post terms.
|
||||
if ( strpos( $content, '{{post_terms' ) !== false ) {
|
||||
$data = preg_match_all( '/{{post_terms.([^}]*)}}/', $content, $matches );
|
||||
foreach ( $matches[1] as $match ) {
|
||||
@ -867,7 +915,7 @@ class GeneratePress_Hero {
|
||||
}
|
||||
}
|
||||
|
||||
// Custom field
|
||||
// Custom field.
|
||||
if ( strpos( $content, '{{custom_field' ) !== false ) {
|
||||
$data = preg_match_all( '/{{custom_field.([^}]*)}}/', $content, $matches );
|
||||
foreach ( $matches[1] as $match ) {
|
||||
@ -885,7 +933,7 @@ class GeneratePress_Hero {
|
||||
}
|
||||
}
|
||||
|
||||
// Taxonomy description
|
||||
// Taxonomy description.
|
||||
if ( is_tax() || is_category() || is_tag() ) {
|
||||
if ( strpos( $content, '{{custom_field' ) !== false ) {
|
||||
$search[] = '{{custom_field.description}}';
|
||||
@ -902,7 +950,7 @@ class GeneratePress_Hero {
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param array $classes
|
||||
* @param array $classes Existing classes.
|
||||
* @return array
|
||||
*/
|
||||
public function remove_hentry( $classes ) {
|
||||
|
@ -1,4 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the Hook Element.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
@ -14,6 +20,7 @@ class GeneratePress_Hook {
|
||||
* Set our content variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var string The content.
|
||||
*/
|
||||
protected $content = '';
|
||||
|
||||
@ -21,6 +28,7 @@ class GeneratePress_Hook {
|
||||
* Set our hook/action variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var string The hook.
|
||||
*/
|
||||
protected $hook = '';
|
||||
|
||||
@ -28,6 +36,7 @@ class GeneratePress_Hook {
|
||||
* Set our custom hook variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var string The custom hook.
|
||||
*/
|
||||
protected $custom_hook = '';
|
||||
|
||||
@ -35,6 +44,7 @@ class GeneratePress_Hook {
|
||||
* Set our disable site header variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var boolean Whether we're disabling the header.
|
||||
*/
|
||||
protected $disable_site_header = false;
|
||||
|
||||
@ -42,6 +52,7 @@ class GeneratePress_Hook {
|
||||
* Set our disable footer variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var boolean Whether we're disabling the footer.
|
||||
*/
|
||||
protected $disable_site_footer = false;
|
||||
|
||||
@ -49,6 +60,7 @@ class GeneratePress_Hook {
|
||||
* Set our priority variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var int The hook priority.
|
||||
*/
|
||||
protected $priority = 10;
|
||||
|
||||
@ -56,6 +68,7 @@ class GeneratePress_Hook {
|
||||
* Set our execute PHP variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var boolean Whether we're executing PHP.
|
||||
*/
|
||||
protected $php = false;
|
||||
|
||||
@ -63,6 +76,7 @@ class GeneratePress_Hook {
|
||||
* Set our execute shortcodes variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var boolean Whether we're executing shortcodes.
|
||||
*/
|
||||
protected $shortcodes = false;
|
||||
|
||||
@ -70,6 +84,7 @@ class GeneratePress_Hook {
|
||||
* Set our location variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array The conditions.
|
||||
*/
|
||||
protected $conditional = array();
|
||||
|
||||
@ -77,6 +92,7 @@ class GeneratePress_Hook {
|
||||
* Set our exclusions variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array The exclusions.
|
||||
*/
|
||||
protected $exclude = array();
|
||||
|
||||
@ -84,6 +100,7 @@ class GeneratePress_Hook {
|
||||
* Set our user condition variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array The user roles.
|
||||
*/
|
||||
protected $users = array();
|
||||
|
||||
@ -94,7 +111,7 @@ class GeneratePress_Hook {
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
function __construct( $post_id ) {
|
||||
public function __construct( $post_id ) {
|
||||
|
||||
$this->hook = get_post_meta( $post_id, '_generate_hook', true );
|
||||
|
||||
@ -176,12 +193,10 @@ class GeneratePress_Hook {
|
||||
|
||||
if ( $this->php && GeneratePress_Elements_Helper::should_execute_php() ) {
|
||||
ob_start();
|
||||
// @codingStandardsIgnoreStart
|
||||
eval( '?>' . $content . '<?php ' );
|
||||
// @codingStandardsIgnoreEnd
|
||||
echo ob_get_clean();
|
||||
eval( '?>' . $content . '<?php ' ); // phpcs:ignore -- Using eval() to execute PHP.
|
||||
echo ob_get_clean(); // phpcs:ignore -- Escaping not necessary.
|
||||
} else {
|
||||
echo $content;
|
||||
echo $content; // phpcs:ignore -- Escaping not necessary.
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles our Layout Element functionality.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* The Layout Element.
|
||||
*/
|
||||
class GeneratePress_Site_Layout {
|
||||
/**
|
||||
* Set our location variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array
|
||||
*/
|
||||
protected $conditional = array();
|
||||
|
||||
@ -12,6 +25,7 @@ class GeneratePress_Site_Layout {
|
||||
* Set our exclusion variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array
|
||||
*/
|
||||
protected $exclude = array();
|
||||
|
||||
@ -19,6 +33,7 @@ class GeneratePress_Site_Layout {
|
||||
* Set our user condition variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array
|
||||
*/
|
||||
protected $users = array();
|
||||
|
||||
@ -27,30 +42,111 @@ class GeneratePress_Site_Layout {
|
||||
*
|
||||
* @since 1.7
|
||||
* @deprecated 1.7.3
|
||||
* @var array
|
||||
*/
|
||||
protected static $options = array();
|
||||
|
||||
/**
|
||||
* Set up options.
|
||||
* Sidebar layout.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var string
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Footer widgets layout.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var int
|
||||
*/
|
||||
protected $footer_widgets = null;
|
||||
|
||||
/**
|
||||
* Whether to disable site header.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_site_header = null;
|
||||
|
||||
/**
|
||||
* Whether to disable mobile header.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_mobile_header = null;
|
||||
|
||||
/**
|
||||
* Whether to disable top bar.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_top_bar = null;
|
||||
|
||||
/**
|
||||
* Whether to disable primary nav.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_primary_navigation = null;
|
||||
|
||||
/**
|
||||
* Whether to disable secondary nav.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_secondary_navigation = null;
|
||||
|
||||
/**
|
||||
* Whether to disable featured image.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_featured_image = null;
|
||||
|
||||
/**
|
||||
* Whether to disable content title.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_content_title = null;
|
||||
|
||||
/**
|
||||
* Whether to disable footer.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_footer = null;
|
||||
|
||||
/**
|
||||
* Container type (full width etc..).
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var string
|
||||
*/
|
||||
protected $content_area = null;
|
||||
|
||||
/**
|
||||
* Content width.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var int
|
||||
*/
|
||||
protected $content_width = null;
|
||||
|
||||
/**
|
||||
* Set our post ID.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var int
|
||||
*/
|
||||
protected static $post_id = '';
|
||||
|
||||
@ -59,6 +155,7 @@ class GeneratePress_Site_Layout {
|
||||
*
|
||||
* @since 1.7
|
||||
* @deprecated 1.7.3
|
||||
* @var int
|
||||
*/
|
||||
public static $instances = 0;
|
||||
|
||||
@ -67,9 +164,9 @@ class GeneratePress_Site_Layout {
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param int $post_ID The post ID of our element.
|
||||
* @param int $post_id The post ID of our element.
|
||||
*/
|
||||
function __construct( $post_id ) {
|
||||
public function __construct( $post_id ) {
|
||||
|
||||
self::$post_id = $post_id;
|
||||
|
||||
@ -89,39 +186,43 @@ class GeneratePress_Site_Layout {
|
||||
$this->sidebar_layout = get_post_meta( $post_id, '_generate_sidebar_layout', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_footer_widgets', 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 ) ) {
|
||||
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 ) ) {
|
||||
if ( get_post_meta( $post_id, '_generate_disable_mobile_header', true ) ) {
|
||||
$this->disable_mobile_header = get_post_meta( $post_id, '_generate_disable_mobile_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 ) ) {
|
||||
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 ) ) {
|
||||
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 ) ) {
|
||||
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 ) ) {
|
||||
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 ) ) {
|
||||
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 ) ) {
|
||||
if ( get_post_meta( $post_id, '_generate_content_area', true ) ) {
|
||||
$this->content_area = get_post_meta( $post_id, '_generate_content_area', true );
|
||||
}
|
||||
|
||||
@ -132,8 +233,13 @@ class GeneratePress_Site_Layout {
|
||||
$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 );
|
||||
add_action( 'wp', array( $this, 'after_setup' ), 100 );
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'build_css' ), 50 );
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'current_screen', array( $this, 'after_setup' ), 100 );
|
||||
add_action( 'enqueue_block_editor_assets', array( $this, 'build_css' ), 50 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -168,13 +274,17 @@ class GeneratePress_Site_Layout {
|
||||
remove_action( 'generate_header', 'generate_construct_header' );
|
||||
}
|
||||
|
||||
if ( $this->disable_mobile_header ) {
|
||||
remove_action( 'generate_after_header', 'generate_menu_plus_mobile_header', 5 );
|
||||
}
|
||||
|
||||
if ( $this->disable_top_bar ) {
|
||||
remove_action( 'generate_before_header', 'generate_top_bar', 5 );
|
||||
remove_action( 'generate_inside_secondary_navigation', 'generate_secondary_nav_top_bar_widget', 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 ) {
|
||||
@ -201,12 +311,49 @@ class GeneratePress_Site_Layout {
|
||||
if ( $this->content_area ) {
|
||||
add_filter( 'body_class', array( $this, 'body_classes' ) );
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
if ( $this->sidebar_layout && ! self::admin_post_meta_exists( '_generate-sidebar-layout-meta' ) ) {
|
||||
add_filter( 'generate_block_editor_sidebar_layout', array( $this, 'filter_options' ) );
|
||||
}
|
||||
|
||||
if ( $this->disable_content_title ) {
|
||||
add_filter( 'generate_block_editor_show_content_title', '__return_false' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build dynamic CSS
|
||||
*/
|
||||
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;}' );
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
$admin_css = '';
|
||||
|
||||
if ( 'full-width' === $this->content_area ) {
|
||||
$admin_css .= 'body .wp-block{max-width: 100%}';
|
||||
}
|
||||
|
||||
if ( $this->content_area ) {
|
||||
$admin_css .= '#generate-layout-page-builder-container {opacity: 0.5;pointer-events: none;}';
|
||||
}
|
||||
|
||||
if ( $this->disable_content_title ) {
|
||||
$admin_css .= '.content-title-visibility{display: none !important;}label[for="meta-generate-disable-headline"] {opacity: 0.5;pointer-events: none;}';
|
||||
}
|
||||
|
||||
if ( $this->content_width ) {
|
||||
$admin_css .= 'body .wp-block{max-width: ' . absint( $this->content_width ) . 'px;}';
|
||||
}
|
||||
|
||||
if ( $admin_css ) {
|
||||
wp_add_inline_style( 'generate-block-editor-styles', $admin_css );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,6 +382,42 @@ class GeneratePress_Site_Layout {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if our individual post metabox has a value in the admin area.
|
||||
*
|
||||
* @since 1.11.0
|
||||
*
|
||||
* @param string $meta The meta key we're checking for.
|
||||
* @return bool
|
||||
*/
|
||||
public static function admin_post_meta_exists( $meta ) {
|
||||
if ( is_admin() ) {
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( isset( $current_screen->is_block_editor ) && $current_screen->is_block_editor ) {
|
||||
$post_id = false;
|
||||
|
||||
if ( isset( $_GET['post'] ) ) { // phpcs:ignore -- No data processing happening here.
|
||||
$post_id = absint( $_GET['post'] ); // phpcs:ignore -- No data processing happening here.
|
||||
}
|
||||
|
||||
if ( $post_id ) {
|
||||
$value = get_post_meta( $post_id, $meta, true );
|
||||
|
||||
if ( '_generate-footer-widget-meta' === $meta && '0' === $value ) {
|
||||
$value = true;
|
||||
}
|
||||
|
||||
if ( $value ) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter our filterable options.
|
||||
*
|
||||
@ -243,7 +426,7 @@ class GeneratePress_Site_Layout {
|
||||
public function filter_options() {
|
||||
$filter = current_filter();
|
||||
|
||||
if ( 'generate_sidebar_layout' === $filter ) {
|
||||
if ( 'generate_sidebar_layout' === $filter || 'generate_block_editor_sidebar_layout' === $filter ) {
|
||||
return $this->sidebar_layout;
|
||||
}
|
||||
|
||||
@ -261,8 +444,8 @@ class GeneratePress_Site_Layout {
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param bool $has_nav_menu
|
||||
* @param string $location
|
||||
* @param bool $has_nav_menu The existing value.
|
||||
* @param string $location The location we're checking.
|
||||
* @return bool
|
||||
*/
|
||||
public static function disable_secondary_navigation( $has_nav_menu, $location ) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* This file sets up our Elements post type.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Start our Elements post type class.
|
||||
*/
|
||||
class GeneratePress_Elements_Post_Type {
|
||||
/**
|
||||
* Instance.
|
||||
@ -20,7 +29,7 @@ class GeneratePress_Elements_Post_Type {
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self;
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
@ -35,12 +44,15 @@ class GeneratePress_Elements_Post_Type {
|
||||
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' ) );
|
||||
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' ) );
|
||||
add_filter( 'register_post_type_args', array( $this, 'set_standard_element' ), 10, 2 );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
||||
add_action( 'admin_footer', array( $this, 'element_modal' ) );
|
||||
|
||||
self::setup_metabox();
|
||||
}
|
||||
@ -66,19 +78,20 @@ class GeneratePress_Elements_Post_Type {
|
||||
'singular_name' => _x( 'Element', 'Post Type Singular Name', 'gp-premium' ),
|
||||
'menu_name' => __( 'Elements', 'gp-premium' ),
|
||||
'all_items' => __( 'All Elements', 'gp-premium' ),
|
||||
'add_new' => __( 'Add New Element', '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' ),
|
||||
'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' ),
|
||||
'supports' => array( 'title', 'editor', 'thumbnail' ),
|
||||
'hierarchical' => false,
|
||||
'public' => false,
|
||||
'show_ui' => true,
|
||||
@ -86,11 +99,66 @@ class GeneratePress_Elements_Post_Type {
|
||||
'can_export' => true,
|
||||
'has_archive' => false,
|
||||
'exclude_from_search' => true,
|
||||
'show_in_rest' => true,
|
||||
);
|
||||
|
||||
register_post_type( 'gp_elements', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable editor and show_in_rest support for non-Block Elements.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @param array $args The existing args.
|
||||
* @param string $post_type The current post type.
|
||||
*/
|
||||
public function set_standard_element( $args, $post_type ) {
|
||||
if ( 'gp_elements' === $post_type ) {
|
||||
$post_id = false;
|
||||
$type = false;
|
||||
|
||||
if ( isset( $_GET['post'] ) ) { // phpcs:ignore -- No processing happening.
|
||||
$post_id = absint( $_GET['post'] ); // phpcs:ignore -- No processing happening.
|
||||
}
|
||||
|
||||
if ( $post_id ) {
|
||||
$type = get_post_meta( $post_id, '_generate_element_type', true );
|
||||
} elseif ( isset( $_GET['element_type'] ) ) { // phpcs:ignore -- No processing happening.
|
||||
$type = esc_html( $_GET['element_type'] ); // phpcs:ignore -- No processing happening.
|
||||
}
|
||||
|
||||
if ( ! $type ) {
|
||||
return $args;
|
||||
}
|
||||
|
||||
if ( 'block' !== $type ) {
|
||||
$args['supports'] = array( 'title', 'thumbnail' );
|
||||
$args['show_in_rest'] = false;
|
||||
}
|
||||
|
||||
if ( 'block' === $type ) {
|
||||
$args['supports'] = array( 'title', 'editor' );
|
||||
}
|
||||
|
||||
if ( 'layout' === $type ) {
|
||||
$args['labels']['add_new_item'] = __( 'Add New Layout', 'gp-premium' );
|
||||
$args['labels']['edit_item'] = __( 'Edit Layout', 'gp-premium' );
|
||||
}
|
||||
|
||||
if ( 'hook' === $type ) {
|
||||
$args['labels']['add_new_item'] = __( 'Add New Hook', 'gp-premium' );
|
||||
$args['labels']['edit_item'] = __( 'Edit Hook', 'gp-premium' );
|
||||
}
|
||||
|
||||
if ( 'header' === $type ) {
|
||||
$args['labels']['add_new_item'] = __( 'Add New Header', 'gp-premium' );
|
||||
$args['labels']['edit_item'] = __( 'Edit Header', 'gp-premium' );
|
||||
}
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register custom post type columns.
|
||||
*
|
||||
@ -133,6 +201,7 @@ class GeneratePress_Elements_Post_Type {
|
||||
}
|
||||
|
||||
$values = array(
|
||||
'block' => esc_html__( 'Blocks', 'gp-premium' ),
|
||||
'header' => esc_html__( 'Headers', 'gp-premium' ),
|
||||
'hook' => esc_html__( 'Hooks', 'gp-premium' ),
|
||||
'layout' => esc_html__( 'Layouts', 'gp-premium' ),
|
||||
@ -142,15 +211,16 @@ class GeneratePress_Elements_Post_Type {
|
||||
<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
|
||||
);
|
||||
}
|
||||
$current = isset( $_GET['gp_element_type_filter'] )? esc_html( $_GET['gp_element_type_filter'] ) : ''; // phpcs:ignore -- No processing happening.
|
||||
|
||||
foreach ( $values as $value => $label ) {
|
||||
printf(
|
||||
'<option value="%1$s" %2$s>%3$s</option>',
|
||||
esc_html( $value ),
|
||||
$value === $current ? 'selected="selected"' : '',
|
||||
esc_html( $label )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
@ -164,13 +234,14 @@ class GeneratePress_Elements_Post_Type {
|
||||
* @param object $query Existing query.
|
||||
*/
|
||||
public function filter_element_types( $query ) {
|
||||
// phpcs:ignore -- No processing happening.
|
||||
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'] : '';
|
||||
$type = isset( $_GET['gp_element_type_filter'] ) ? $_GET['gp_element_type_filter'] : ''; // phpcs:ignore -- No processing happening.
|
||||
|
||||
if ( 'edit.php' === $pagenow && $query->is_main_query() && '' !== $type ) {
|
||||
$query->set( 'meta_key', '_generate_element_type' );
|
||||
@ -184,12 +255,28 @@ class GeneratePress_Elements_Post_Type {
|
||||
* @since 1.7
|
||||
*
|
||||
* @param string $column The name of the column.
|
||||
* @param int $post_id The ID of the post row.
|
||||
* @param int $post_id The ID of the post row.
|
||||
*/
|
||||
public function add_columns( $column, $post_id ) {
|
||||
switch ( $column ) {
|
||||
case 'element_type' :
|
||||
case 'element_type':
|
||||
$type = get_post_meta( $post_id, '_generate_element_type', true );
|
||||
$hook_location = get_post_meta( $post_id, '_generate_hook', true );
|
||||
|
||||
if ( 'block' === $type ) {
|
||||
echo esc_html__( 'Block', 'gp-premium' );
|
||||
|
||||
$block_type = get_post_meta( $post_id, '_generate_block_type', true );
|
||||
|
||||
if ( $block_type ) {
|
||||
echo ' - ' . esc_html( str_replace( '-', ' ', ucfirst( $block_type ) ) );
|
||||
|
||||
if ( 'hook' === $block_type && $hook_location ) {
|
||||
echo '<br />';
|
||||
echo '<span class="hook-location">' . esc_html( $hook_location ) . '</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'header' === $type ) {
|
||||
echo esc_html__( 'Header', 'gp-premium' );
|
||||
@ -197,50 +284,57 @@ class GeneratePress_Elements_Post_Type {
|
||||
|
||||
if ( 'hook' === $type ) {
|
||||
echo esc_html__( 'Hook', 'gp-premium' );
|
||||
|
||||
if ( $hook_location ) {
|
||||
echo '<br />';
|
||||
echo '<span class="hook-location">' . esc_html( $hook_location ) . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'layout' === $type ) {
|
||||
echo esc_html__( 'Layout', 'gp-premium' );
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'location' :
|
||||
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 );
|
||||
foreach ( (array) $location as $data ) {
|
||||
echo esc_html( GeneratePress_Conditions::get_saved_label( $data ) );
|
||||
echo '<br />';
|
||||
}
|
||||
} else {
|
||||
echo esc_html__( 'Not set', 'gp-premium' );
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'exclusions' :
|
||||
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 );
|
||||
foreach ( (array) $location as $data ) {
|
||||
echo esc_html( GeneratePress_Conditions::get_saved_label( $data ) );
|
||||
echo '<br />';
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'users' :
|
||||
case 'users':
|
||||
$users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
|
||||
|
||||
if ( $users ) {
|
||||
foreach ( ( array ) $users as $data ) {
|
||||
if ( strpos( $data, ':' ) !== FALSE ) {
|
||||
foreach ( (array) $users as $data ) {
|
||||
if ( strpos( $data, ':' ) !== false ) {
|
||||
$data = substr( $data, strpos( $data, ':' ) + 1 );
|
||||
}
|
||||
|
||||
$return = ucwords( str_replace( '_', ' ', $data ) );
|
||||
|
||||
echo $return . '<br />';
|
||||
echo esc_html( $return ) . '<br />';
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,8 +362,71 @@ class GeneratePress_Elements_Post_Type {
|
||||
global $parent_file, $submenu_file, $post_type;
|
||||
|
||||
if ( 'gp_elements' === $post_type ) {
|
||||
$parent_file = 'themes.php';
|
||||
$submenu_file = 'edit.php?post_type=gp_elements';
|
||||
$parent_file = 'themes.php'; // phpcs:ignore
|
||||
$submenu_file = 'edit.php?post_type=gp_elements'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add scripts to the edit/post area of Elements.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @param string $hook The current hook for the page.
|
||||
*/
|
||||
public function admin_scripts( $hook ) {
|
||||
if ( ! function_exists( 'get_current_screen' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( 'edit.php' === $hook || 'post.php' === $hook ) {
|
||||
if ( 'gp_elements' === $current_screen->post_type ) {
|
||||
wp_enqueue_script( 'generate-elements', plugin_dir_url( __FILE__ ) . 'assets/admin/elements.js', array( 'jquery' ), GP_PREMIUM_VERSION, true );
|
||||
wp_enqueue_style( 'generate-elements', plugin_dir_url( __FILE__ ) . 'assets/admin/elements.css', array(), GP_PREMIUM_VERSION );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Add New Element modal.
|
||||
*
|
||||
* @since 1.11.0
|
||||
*/
|
||||
public function element_modal() {
|
||||
if ( ! function_exists( 'get_current_screen' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( 'edit-gp_elements' === $current_screen->id || 'gp_elements' === $current_screen->id ) {
|
||||
?>
|
||||
<form method="get" class="choose-element-type-parent" action="<?php echo esc_url( admin_url( 'post-new.php' ) ); ?>" style="display: none;">
|
||||
<input type="hidden" name="post_type" value="gp_elements" />
|
||||
|
||||
<div class="choose-element-type">
|
||||
<h2><?php _e( 'Choose Element Type', 'gp-premium' ); ?></h2>
|
||||
<div class="select-type-container">
|
||||
<select class="select-type" name="element_type">
|
||||
<option value=""><?php esc_attr_e( 'Choose...', 'gp-premium' ); ?></option>
|
||||
<option value="block"><?php esc_attr_e( 'Block', 'gp-premium' ); ?></option>
|
||||
<option value="header"><?php esc_attr_e( 'Header', 'gp-premium' ); ?></option>
|
||||
<option value="hook"><?php esc_attr_e( 'Hook', 'gp-premium' ); ?></option>
|
||||
<option value="layout"><?php esc_attr_e( 'Layout', 'gp-premium' ); ?></option>
|
||||
</select>
|
||||
|
||||
<button class="button button-primary"><?php _e( 'Create', 'gp-premium' ); ?></button>
|
||||
</div>
|
||||
|
||||
<button class="close-choose-element-type" aria-label="<?php esc_attr_e( 'Close', 'gp-premium' ); ?>">
|
||||
<svg aria-hidden="true" data-prefix="fas" data-icon="times" class="svg-inline--fa fa-times fa-w-11" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 512">
|
||||
<path fill="currentColor" d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* This file sets up our Elements module.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
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';
|
||||
$elements_dir = plugin_dir_path( __FILE__ );
|
||||
|
||||
require $elements_dir . 'class-conditions.php';
|
||||
require $elements_dir . 'class-elements-helper.php';
|
||||
require $elements_dir . 'class-hooks.php';
|
||||
require $elements_dir . 'class-hero.php';
|
||||
require $elements_dir . 'class-layout.php';
|
||||
require $elements_dir . 'class-block.php';
|
||||
require $elements_dir . 'class-post-type.php';
|
||||
|
||||
add_action( 'wp', 'generate_premium_do_elements' );
|
||||
add_action( 'current_screen', 'generate_premium_do_elements' );
|
||||
/**
|
||||
* Execute our Elements.
|
||||
*
|
||||
@ -18,20 +30,15 @@ add_action( 'wp', 'generate_premium_do_elements' );
|
||||
*/
|
||||
function generate_premium_do_elements() {
|
||||
$args = array(
|
||||
'post_type' => 'gp_elements',
|
||||
'no_found_rows' => true,
|
||||
'post_status' => 'publish',
|
||||
'numberposts' => 500,
|
||||
'fields' => 'ids',
|
||||
'suppress_filters' => false,
|
||||
'post_type' => 'gp_elements',
|
||||
'no_found_rows' => true,
|
||||
'post_status' => 'publish',
|
||||
'numberposts' => 500, // phpcs:ignore
|
||||
'fields' => 'ids',
|
||||
'order' => 'ASC',
|
||||
'suppress_filters' => false,
|
||||
);
|
||||
|
||||
$custom_args = apply_filters( 'generate_elements_custom_args', array(
|
||||
'order' => 'ASC',
|
||||
) );
|
||||
|
||||
$args = array_merge( $args, $custom_args );
|
||||
|
||||
// Prevent Polylang from altering the query.
|
||||
if ( function_exists( 'pll_get_post_language' ) ) {
|
||||
$args['lang'] = '';
|
||||
@ -54,6 +61,10 @@ function generate_premium_do_elements() {
|
||||
if ( 'layout' === $type ) {
|
||||
new GeneratePress_Site_Layout( $post_id );
|
||||
}
|
||||
|
||||
if ( 'block' === $type ) {
|
||||
new GeneratePress_Block_Element( $post_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +94,7 @@ add_filter( 'generate_element_post_id', 'generate_elements_ignore_languages' );
|
||||
*
|
||||
* @since 1.8
|
||||
*
|
||||
* @param int $post_id
|
||||
* @param int $post_id The current post ID.
|
||||
* @return bool|int
|
||||
*/
|
||||
function generate_elements_ignore_languages( $post_id ) {
|
||||
@ -95,10 +106,77 @@ function generate_elements_ignore_languages( $post_id ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
if ( $language && $language !== pll_current_language( 'locale' ) ) {
|
||||
if ( $language && $language !== pll_current_language( 'locale' ) ) { // phpcs:ignore -- Using Yoda check I am.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
add_action( 'save_post_wp_block', 'generate_elements_wp_block_update', 10, 2 );
|
||||
/**
|
||||
* Regenerate the GenerateBlocks CSS file when a re-usable block is saved.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @param int $post_id The post ID.
|
||||
* @param object $post The post object.
|
||||
*/
|
||||
function generate_elements_wp_block_update( $post_id, $post ) {
|
||||
$is_autosave = wp_is_post_autosave( $post_id );
|
||||
$is_revision = wp_is_post_revision( $post_id );
|
||||
|
||||
if ( $is_autosave || $is_revision || ! current_user_can( 'edit_post', $post_id ) ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
if ( isset( $post->post_content ) ) {
|
||||
if ( strpos( $post->post_content, 'wp:generateblocks' ) !== false ) {
|
||||
global $wpdb;
|
||||
|
||||
$option = get_option( 'generateblocks_dynamic_css_posts', array() );
|
||||
|
||||
$posts = $wpdb->get_col( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_generateblocks_reusable_blocks'" );
|
||||
|
||||
foreach ( (array) $posts as $id ) {
|
||||
$display_conditions = get_post_meta( $id, '_generate_element_display_conditions', true );
|
||||
|
||||
if ( $display_conditions ) {
|
||||
foreach ( (array) $display_conditions as $condition ) {
|
||||
if ( 'general:site' === $condition['rule'] ) {
|
||||
$option = array();
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $condition['object'] && isset( $option[ $condition['object'] ] ) ) {
|
||||
unset( $option[ $condition['object'] ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'generateblocks_dynamic_css_posts', $option );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
add_filter( 'generate_do_block_element_content', 'generate_add_block_element_content_filters' );
|
||||
/**
|
||||
* Apply content filters to our block elements.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @param string $content The block element content.
|
||||
*/
|
||||
function generate_add_block_element_content_filters( $content ) {
|
||||
$content = shortcode_unautop( $content );
|
||||
$content = do_shortcode( $content );
|
||||
|
||||
if ( function_exists( 'wp_filter_content_tags' ) ) {
|
||||
$content = wp_filter_content_tags( $content );
|
||||
} elseif ( function_exists( 'wp_make_content_images_responsive' ) ) {
|
||||
$content = wp_make_content_images_responsive( $content );
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
Reference in New Issue
Block a user