modified file bootstrap-buttons.css

This commit is contained in:
2023-12-08 23:23:36 +00:00
committed by Gitium
parent 33d18af972
commit 3f4d8b933f
2304 changed files with 24432 additions and 417943 deletions

View File

@ -1,211 +0,0 @@
button[data-balloon] {
overflow: visible; }
[data-balloon] {
position: relative;
cursor: pointer; }
[data-balloon]:after {
filter: alpha(opacity=0);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
-moz-opacity: 0;
-khtml-opacity: 0;
opacity: 0;
pointer-events: none;
transition: all 0.18s ease-out 0.18s;
font-weight: normal !important;
font-style: normal !important;
text-shadow: none !important;
font-size: 12px !important;
background: rgba(17, 17, 17, 0.9);
border-radius: 4px;
color: #fff;
content: attr(data-balloon);
padding: .5em 1em;
position: absolute;
white-space: nowrap;
z-index: 10; }
[data-balloon]:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(0)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 18px;
height: 6px;
filter: alpha(opacity=0);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
-moz-opacity: 0;
-khtml-opacity: 0;
opacity: 0;
pointer-events: none;
transition: all 0.18s ease-out 0.18s;
content: '';
position: absolute;
z-index: 10; }
[data-balloon]:hover:before, [data-balloon]:hover:after, [data-balloon][data-balloon-visible]:before, [data-balloon][data-balloon-visible]:after {
filter: alpha(opacity=100);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
-moz-opacity: 1;
-khtml-opacity: 1;
opacity: 1;
pointer-events: auto; }
[data-balloon].font-awesome:after {
font-family: FontAwesome; }
[data-balloon][data-balloon-break]:after {
white-space: pre; }
[data-balloon][data-balloon-blunt]:before, [data-balloon][data-balloon-blunt]:after {
transition: none; }
[data-balloon][data-balloon-pos="up"]:after {
bottom: 100%;
left: 50%;
margin-bottom: 11px;
transform: translate(-50%, 10px);
transform-origin: top; }
[data-balloon][data-balloon-pos="up"]:before {
bottom: 100%;
left: 50%;
margin-bottom: 5px;
transform: translate(-50%, 10px);
transform-origin: top; }
[data-balloon][data-balloon-pos="up"]:hover:after, [data-balloon][data-balloon-pos="up"][data-balloon-visible]:after {
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos="up"]:hover:before, [data-balloon][data-balloon-pos="up"][data-balloon-visible]:before {
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos="up-left"]:after {
bottom: 100%;
left: 0;
margin-bottom: 11px;
transform: translate(0, 10px);
transform-origin: top; }
[data-balloon][data-balloon-pos="up-left"]:before {
bottom: 100%;
left: 5px;
margin-bottom: 5px;
transform: translate(0, 10px);
transform-origin: top; }
[data-balloon][data-balloon-pos="up-left"]:hover:after, [data-balloon][data-balloon-pos="up-left"][data-balloon-visible]:after {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos="up-left"]:hover:before, [data-balloon][data-balloon-pos="up-left"][data-balloon-visible]:before {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos="up-right"]:after {
bottom: 100%;
right: 0;
margin-bottom: 11px;
transform: translate(0, 10px);
transform-origin: top; }
[data-balloon][data-balloon-pos="up-right"]:before {
bottom: 100%;
right: 5px;
margin-bottom: 5px;
transform: translate(0, 10px);
transform-origin: top; }
[data-balloon][data-balloon-pos="up-right"]:hover:after, [data-balloon][data-balloon-pos="up-right"][data-balloon-visible]:after {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos="up-right"]:hover:before, [data-balloon][data-balloon-pos="up-right"][data-balloon-visible]:before {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down']:after {
left: 50%;
margin-top: 11px;
top: 100%;
transform: translate(-50%, -10px); }
[data-balloon][data-balloon-pos='down']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 18px;
height: 6px;
left: 50%;
margin-top: 5px;
top: 100%;
transform: translate(-50%, -10px); }
[data-balloon][data-balloon-pos='down']:hover:after, [data-balloon][data-balloon-pos='down'][data-balloon-visible]:after {
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos='down']:hover:before, [data-balloon][data-balloon-pos='down'][data-balloon-visible]:before {
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos='down-left']:after {
left: 0;
margin-top: 11px;
top: 100%;
transform: translate(0, -10px); }
[data-balloon][data-balloon-pos='down-left']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 18px;
height: 6px;
left: 5px;
margin-top: 5px;
top: 100%;
transform: translate(0, -10px); }
[data-balloon][data-balloon-pos='down-left']:hover:after, [data-balloon][data-balloon-pos='down-left'][data-balloon-visible]:after {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down-left']:hover:before, [data-balloon][data-balloon-pos='down-left'][data-balloon-visible]:before {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down-right']:after {
right: 0;
margin-top: 11px;
top: 100%;
transform: translate(0, -10px); }
[data-balloon][data-balloon-pos='down-right']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 18px;
height: 6px;
right: 5px;
margin-top: 5px;
top: 100%;
transform: translate(0, -10px); }
[data-balloon][data-balloon-pos='down-right']:hover:after, [data-balloon][data-balloon-pos='down-right'][data-balloon-visible]:after {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down-right']:hover:before, [data-balloon][data-balloon-pos='down-right'][data-balloon-visible]:before {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='left']:after {
margin-right: 11px;
right: 100%;
top: 50%;
transform: translate(10px, -50%); }
[data-balloon][data-balloon-pos='left']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(-90 18 18)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 6px;
height: 18px;
margin-right: 5px;
right: 100%;
top: 50%;
transform: translate(10px, -50%); }
[data-balloon][data-balloon-pos='left']:hover:after, [data-balloon][data-balloon-pos='left'][data-balloon-visible]:after {
transform: translate(0, -50%); }
[data-balloon][data-balloon-pos='left']:hover:before, [data-balloon][data-balloon-pos='left'][data-balloon-visible]:before {
transform: translate(0, -50%); }
[data-balloon][data-balloon-pos='right']:after {
left: 100%;
margin-left: 11px;
top: 50%;
transform: translate(-10px, -50%); }
[data-balloon][data-balloon-pos='right']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(90 6 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 6px;
height: 18px;
left: 100%;
margin-left: 5px;
top: 50%;
transform: translate(-10px, -50%); }
[data-balloon][data-balloon-pos='right']:hover:after, [data-balloon][data-balloon-pos='right'][data-balloon-visible]:after {
transform: translate(0, -50%); }
[data-balloon][data-balloon-pos='right']:hover:before, [data-balloon][data-balloon-pos='right'][data-balloon-visible]:before {
transform: translate(0, -50%); }
[data-balloon][data-balloon-length='small']:after {
white-space: normal;
width: 80px; }
[data-balloon][data-balloon-length='medium']:after {
white-space: normal;
width: 150px; }
[data-balloon][data-balloon-length='large']:after {
white-space: normal;
width: 260px; }
[data-balloon][data-balloon-length='xlarge']:after {
white-space: normal;
width: 380px; }
@media screen and (max-width: 768px) {
[data-balloon][data-balloon-length='xlarge']:after {
white-space: normal;
width: 90vw; } }
[data-balloon][data-balloon-length='fit']:after {
white-space: normal;
width: 100%; }

View File

@ -1,82 +0,0 @@
.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;
}

View File

@ -1,29 +0,0 @@
jQuery( function( $ ) {
$( '.post-type-gp_elements .page-title-action:not(.legacy-button)' ).on( 'click', function( e ) {
e.preventDefault();
$( '.choose-element-type-parent' ).show();
$( '.choose-element-type .select-type' ).focus();
} );
$( '.close-choose-element-type' ).on( 'click', function( e ) {
e.preventDefault();
$( '.choose-element-type-parent' ).hide();
$( '.page-title-action' ).focus();
} );
$( '.post-type-gp_elements' ).on( 'keyup', function( e ) {
const $element = $( '.choose-element-type-parent' );
if ( e.key === 'Escape' && $element.is( ':visible' ) ) {
$element.hide();
$( '.page-title-action' ).focus();
}
} );
// Don't allow Elements to quick edit parents.
$( '.inline-edit-gp_elements select#post_parent, .inline-edit-gp_elements .inline-edit-menu-order-input, .bulk-edit-gp_elements select#post_parent' ).each( function() {
$( this ).closest( 'label' ).remove();
} );
} );

View File

@ -1,396 +0,0 @@
#generate_premium_elements {
background-color: transparent;
border: 0;
box-shadow: 0 0 0;
}
#generate_premium_elements .inside {
padding: 0;
margin: 0;
}
#generate_premium_elements .CodeMirror {
position: relative;
padding: 0;
background: white;
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
width: 100%;
overflow: hidden;
}
tr.generate-element-row td {
border-bottom: 1px solid #f0f0f0;
zoom: 1;
}
td.generate-element-row-heading {
background: #F9F9F9;
border-right: 1px solid #E1E1E1;
padding: 13px 15px;
width: 24%;
}
td.generate-element-row-heading label {
display: inline-block;
font-size: 13px;
line-height: 1.4em;
font-weight: bold;
padding: 0;
margin: 0 0 3px;
color: #333;
}
td.generate-element-row-content {
padding: 13px 15px;
position: relative;
width: 75%;
}
#generate_premium_elements .handlediv,
#generate_premium_elements .hndle,
#generate_premium_elements .postbox-header {
display: none;
}
#generate_premium_elements .inside {
padding: 0;
}
#generate_premium_elements select,
#generate_premium_elements input[type="number"],
#generate_premium_elements input[type="text"] {
width: 100%;
}
#generate_premium_elements .condition select.condition-object-select + .select2 {
display: none;
}
#generate_premium_elements .condition.generate-elements-rule-objects-visible select.condition-select + .select2 {
margin-right: 5px;
width: 100%;
}
#generate_premium_elements .condition.generate-elements-rule-objects-visible select.condition-object-select + .select2 {
display: inline-block;
margin-left: 5px;
width: 100%;
}
#generate_premium_elements .condition {
display: flex;
margin-bottom: 10px;
}
#generate_premium_elements .condition .select2 {
flex-grow: 1;
}
button.remove-condition {
background: transparent;
border: 0;
line-height: 1;
width: 30px;
font-size: 20px;
cursor: pointer;
opacity: 0.5;
position: relative;
bottom: -3px;
}
button.add-condition {
margin-top: 10px !important;
}
button.remove-condition:before {
content: "\f153";
font-family: dashicons;
}
table.generate-elements-settings {
position: relative;
padding: 0;
background: white;
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
width: 100%;
overflow: hidden;
}
.generate-element-row-loading {
background-color: rgba(255,255,255,0.9);
background-image: url('spinner.gif');
background-position: center center;
background-repeat: no-repeat;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
}
ul.element-metabox-tabs {
position: relative;
padding: 0;
margin: 0 0 20px;
background: white;
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
display: flex;
width: 100%;
overflow: hidden;
}
ul.element-metabox-tabs li {
width: auto;
flex: none;
border-bottom: 2px solid transparent;
border-top: none;
text-align: center;
margin-bottom: 0;
}
ul.element-metabox-tabs li a {
display: block;
width: auto;
padding: 16px 16px 14px 16px;
color: #0087be;
font-weight: 400;
text-decoration: none;
box-shadow: 0 0 0;
}
ul.element-metabox-tabs li a:hover {
color: #00a0d2;
}
ul.element-metabox-tabs li.is-selected {
border-bottom-color: #2e4453;
}
ul.element-metabox-tabs li.is-selected a {
color: #2e4453;
}
#generate-element-content,
#generate-element-content + .CodeMirror {
margin-bottom: 20px;
}
.element-metabox-tabs li:not([data-tab="display-rules"]):not([data-tab="internal-notes"]),
.generate-elements-settings:not([data-tab="display-rules"]):not([data-tab="internal-notes"]) {
display: none;
}
.element-settings.header .element-metabox-tabs li[data-type="header"],
.element-settings.hook .element-metabox-tabs li[data-type="hook"],
.element-settings.block .element-metabox-tabs li[data-type="hook"],
.element-settings.layout .element-metabox-tabs li[data-type="layout"] {
display: block;
}
.element-settings.header:not(.has-page-hero) table[data-tab="site-header"],
.element-settings.header.has-page-hero 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.header:not(.has-page-hero) #generate-element-content {
display: none;
}
.element-settings.header:not(.has-page-hero) #generate-element-content + .CodeMirror:not(.gpp-elements-show-codemirror) {
height: 0;
overflow: hidden;
opacity: 0;
margin: 0;
}
.padding-container {
display: flex;
}
.single-value-padding-container {
display: block;
}
.single-value-padding-container input[type="number"] {
width: 60px !important;
display: inline-block;
vertical-align: middle;
}
.padding-element-options {
display: flex;
}
.padding-element span.unit {
border: 1px solid #ddd;
display: inline-block;
line-height: 26px;
padding: 0 10px;
margin-left: -5px;
vertical-align: middle;
border-left: 0;
}
.padding-element input {
width: 60px !important;
min-height: 30px;
}
.padding-element select {
width: auto !important;
position: relative;
left: -5px;
min-height: 30px;
}
.padding-element span {
display: block;
font-size: 90%;
opacity: 0.8;
}
.generate-element-row-content .responsive-controls.single-responsive-value {
padding: 8px 15px 7px 0;
}
.generate-element-row-content .responsive-controls.checkbox-responsive-value {
padding: 2px 15px 0 0;
}
#postimagediv {
display: none;
}
.image-preview img {
height: 30px;
width: auto;
vertical-align: middle;
border-radius: 5px;
}
.gp-media-preview img {
vertical-align: middle;
background-color: #efefef;
border-radius: 5px;
height: 30px;
width: auto;
}
.media-container,
.change-featured-image,
.set-featured-image {
display: flex;
align-items: center;
}
.media-container > input,
.media-container .gp-media-preview img,
.change-featured-image > *,
.set-featured-image > * {
margin-right: 10px !important;
}
.generate-element-row-content .responsive-controls {
float: left;
padding: 15px 15px 15px 0;
}
.generate-element-row-content .responsive-controls a {
text-decoration: none;
color: #222;
opacity: 0.5;
outline: 0;
box-shadow: 0 0 0;
}
.generate-element-row-content .responsive-controls a.is-selected {
opacity: 1;
}
.generate-element-row-content .responsive-controls a span {
font-size: 14px;
width: auto;
height: auto;
vertical-align: baseline;
}
#generate-element-content {
width: 100%;
height: 300px;
}
.layout-radio-item {
margin-bottom: 3px;
}
.layout-radio-item:first-child {
margin-bottom: 15px;
}
span.tip {
display: inline-block;
float: right;
background: #b3b3b3;
height: 15px;
width: 15px;
text-align: center;
line-height: 15px;
color: #fff;
border-radius: 50%;
font-size: 10px;
}
body:not(.header-element-type) #generate_page_hero_template_tags,
.header-element-type:not(.element-has-page-hero) #generate_page_hero_template_tags {
display: none;
}
#_generate_element_internal_notes {
width: 100%;
height: 250px;
}
.select2-results__option {
margin: 0;
}
body .select2-container--default .select2-selection--single {
border-color: #ddd;
}
.select2-results__option[role="list"] {
padding: 0;
}
#generate_premium_elements #_generate_content_width {
width: 65px;
vertical-align: middle;
}
#_generate_content_width + span {
border: 1px solid #ddd;
height: 26px;
display: inline-block;
vertical-align: middle;
line-height: 26px;
padding: 0 10px;
margin-left: -6px;
}
.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;
}

View File

@ -1,424 +0,0 @@
jQuery( function( $ ) {
if ( $( '.element-settings' ).hasClass( 'header' ) || $( '.element-settings' ).hasClass( 'hook' ) ) {
$( function() {
if ( elements.settings ) {
wp.codeEditor.initialize( 'generate-element-content', elements.settings );
}
} );
}
$( '#_generate_block_type' ).on( 'change', function() {
var _this = $( this ).val();
if ( 'hook' === _this ) {
$( '.hook-row' ).removeClass( 'hide-hook-row' );
} else {
$( '.hook-row' ).addClass( 'hide-hook-row' );
}
$( 'body' ).removeClass( 'right-sidebar-block-type' );
$( 'body' ).removeClass( 'left-sidebar-block-type' );
$( 'body' ).removeClass( 'header-block-type' );
$( 'body' ).removeClass( 'footer-block-type' );
$( 'body' ).addClass( _this + '-block-type' );
if ( 'left-sidebar' === _this || 'right-sidebar' === _this ) {
$( '.sidebar-notice' ).show();
} else {
$( '.sidebar-notice' ).hide();
}
} );
$( '#_generate_hook' ).on( 'change', function() {
var _this = $( this );
$( '.disable-header-hook' ).hide();
$( '.disable-footer-hook' ).hide();
$( '.custom-hook-name' ).hide();
if ( 'generate_header' === _this.val() ) {
$( '.disable-header-hook' ).show();
}
if ( 'generate_footer' === _this.val() ) {
$( '.disable-footer-hook' ).show();
}
if ( 'custom' === _this.val() ) {
$( '.custom-hook-name' ).show();
}
} );
$( '#_generate_hook' ).select2( {
width: '100%',
} );
$( '.element-metabox-tabs li' ).on( 'click', function() {
var _this = $( this ),
tab = _this.data( 'tab' );
_this.siblings().removeClass( 'is-selected' );
_this.addClass( 'is-selected' );
$( '.generate-elements-settings' ).hide();
$( '.generate-elements-settings[data-tab="' + tab + '"]' ).show();
if ( $( '.element-settings' ).hasClass( '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' ).removeClass( 'gpp-elements-show-codemirror' );
$( '#generate_page_hero_template_tags' ).css( 'display', '' );
} else {
$( '#generate-element-content' ).next( '.CodeMirror' ).addClass( 'gpp-elements-show-codemirror' );
$( '#generate_page_hero_template_tags' ).css( 'display', 'block' );
}
}
} );
var select2Init = function() {
var selects = $( '.generate-element-row-content .condition:not(.hidden) select:not(.select2-init)' );
selects.each( function() {
var select = $( this ),
config = {
width: 'style',
};
select.select2( config );
select.addClass( 'select2-init' );
} );
};
select2Init();
$( '.add-condition' ).on( 'click', function() {
var _this = $( this );
var row = _this.closest( '.generate-element-row-content' ).find( '.condition.hidden.screen-reader-text' ).clone( true );
row.removeClass( 'hidden screen-reader-text' );
row.insertBefore( _this.closest( '.generate-element-row-content' ).find( '.condition:last' ) );
select2Init();
return false;
} );
$( '.remove-condition' ).on( 'click', function() {
$( this ).parents( '.condition' ).remove();
select2Init();
return false;
} );
var getLocationObjects = function( _this, onload = false, data = '' ) {
var select = _this,
parent = select.parent(),
location = select.val(),
objectSelect = parent.find( '.condition-object-select' ),
locationType = '',
actionType = 'terms';
if ( '' === location ) {
parent.removeClass( 'generate-elements-rule-objects-visible' );
select.closest( '.generate-element-row-content' ).find( '.generate-element-row-loading' ).remove();
} else {
if ( location.indexOf( ':taxonomy:' ) > 0 ) {
locationType = 'taxonomy';
} else {
locationType = location.substr( 0, location.indexOf( ':' ) );
}
var locationID = location.substr( location.lastIndexOf( ':' ) + 1 );
if ( 'taxonomy' === locationType || 'post' === locationType ) {
if ( ! ( '.generate-element-row-loading' ).length ) {
select.closest( '.generate-element-row-content' ).prepend( '<div class="generate-element-row-loading"></div>' );
}
var fillObjects = function( response ) {
var objects = response[ locationID ].objects;
var blank = {
id: '',
name: 'All ' + response[ locationID ].label,
};
if ( location.indexOf( ':taxonomy:' ) > 0 ) {
blank.name = elements.choose;
}
objectSelect.empty();
objectSelect.append( $( '<option>', {
value: blank.id,
label: blank.name,
text: blank.name,
} ) );
$.each( objects, function( key, value ) {
objectSelect.append( $( '<option>', {
value: value.id,
label: elements.showID && value.id ? value.name + ': ' + value.id : value.name,
text: elements.showID && value.id ? value.name + ': ' + value.id : value.name,
} ) );
} );
parent.addClass( 'generate-elements-rule-objects-visible' );
if ( onload ) {
objectSelect.val( objectSelect.attr( 'data-saved-value' ) );
}
select.closest( '.generate-element-row-content' ).find( '.generate-element-row-loading' ).remove();
};
if ( data && onload ) {
// Use pre-fetched data if we just loaded the page.
fillObjects( data );
} else {
if ( 'post' === locationType ) {
if ( 'taxonomy' === locationType ) {
actionType = 'terms';
} else {
actionType = 'posts';
}
}
$.post( ajaxurl, {
action: 'generate_elements_get_location_' + actionType,
id: locationID,
nonce: elements.nonce,
}, function( response ) {
response = JSON.parse( response );
fillObjects( response );
} );
}
} else {
parent.removeClass( 'generate-elements-rule-objects-visible' );
select.closest( '.generate-element-row-content' ).find( '.generate-element-row-loading' ).remove();
objectSelect.empty().append( '<option value="0"></option>' );
objectSelect.val( '0' );
}
}
};
$( '.condition select.condition-select' ).on( 'change', function() {
getLocationObjects( $( this ) );
$( '.elements-no-location-error' ).hide();
} );
var postObjects = [];
var termObjects = [];
$( '.generate-elements-rule-objects-visible' ).each( function() {
var _this = $( this ),
select = _this.find( 'select.condition-select' ),
location = select.val(),
locationID = location.substr( location.lastIndexOf( ':' ) + 1 ),
locationType = '';
if ( location.indexOf( ':taxonomy:' ) > 0 ) {
locationType = 'taxonomy';
} else {
locationType = location.substr( 0, location.indexOf( ':' ) );
}
if ( 'post' === locationType ) {
if ( ! postObjects.includes( locationID ) ) {
postObjects.push( locationID );
}
} else if ( 'taxonomy' === locationType && ! termObjects.includes( locationID ) ) {
termObjects.push( locationID );
}
} );
if ( postObjects.length > 0 || termObjects.length > 0 ) {
$.post( ajaxurl, {
action: 'generate_elements_get_location_objects',
posts: postObjects,
terms: termObjects,
nonce: elements.nonce,
}, function( response ) {
response = JSON.parse( response );
$( '.generate-elements-rule-objects-visible' ).each( function() {
var _this = $( this ),
select = _this.find( 'select.condition-select' );
$( '<div class="generate-element-row-loading"></div>' ).insertBefore( _this );
getLocationObjects( select, true, response );
} );
} );
}
$( '.set-featured-image a, .change-featured-image a:not(.remove-image)' ).on( 'click', function( event ) {
event.preventDefault();
// Stop propagation to prevent thickbox from activating.
event.stopPropagation();
// Open the featured image modal
wp.media.featuredImage.frame().open();
} );
wp.media.featuredImage.frame().on( 'select', function() {
$( '.set-featured-image' ).hide();
$( '.change-featured-image' ).show();
setTimeout( function() {
$( '.image-preview' ).empty();
$( '#postimagediv img' ).appendTo( '.image-preview' );
}, 500 );
} );
$( '#postimagediv' ).on( 'click', '#remove-post-thumbnail', function() {
$( '.set-featured-image' ).show();
$( '.change-featured-image' ).hide();
$( '.image-preview' ).empty();
return false;
} );
$( '.remove-image' ).on( 'click', function( e ) {
e.preventDefault();
$( '#remove-post-thumbnail' ).trigger( 'click' );
} );
$( '.generate-upload-file' ).on( 'click', function() {
if ( frame ) {
frame.open();
return;
}
var _this = $( this ),
container = _this.closest( '.media-container' );
var frame = wp.media( {
title: _this.data( 'title' ),
multiple: false,
library: { type: _this.data( 'type' ) },
button: { text: _this.data( 'insert' ) },
} );
frame.on( 'select', function() {
var attachment = frame.state().get( 'selection' ).first().toJSON();
container.find( '.media-field' ).val( attachment.id );
container.find( '.remove-field' ).show();
if ( _this.data( 'preview' ) ) {
container.find( '.gp-media-preview' ).empty().append( '<img src="' + attachment.url + '" width="50" />' ).show();
}
} );
frame.open();
} );
$( '.remove-field' ).on( 'click', function() {
var _this = $( this ),
container = _this.closest( '.media-container' );
_this.hide();
container.find( '.media-field' ).val( '' );
container.find( '.gp-media-preview' ).empty();
} );
$( '#_generate_hero_background_image' ).on( 'change', function() {
var _this = $( this );
if ( '' !== _this.val() ) {
$( '.requires-background-image' ).show();
} else {
$( '.requires-background-image' ).hide();
}
if ( 'featured-image' === _this.val() ) {
$( '.image-text' ).text( elements.fallback_image );
}
if ( 'custom-image' === _this.val() ) {
$( '.image-text' ).text( elements.custom_image );
}
} );
// Responsive controls in our settings.
$( '.responsive-controls a' ).on( 'click', function( e ) {
e.preventDefault();
var _this = $( this ),
control = _this.attr( 'data-control' ),
controlArea = _this.closest( '.generate-element-row-content' );
controlArea.find( '.padding-container' ).hide();
controlArea.find( '.padding-container.' + control ).show();
_this.siblings().removeClass( 'is-selected' );
_this.addClass( 'is-selected' );
} );
$( '#_generate_site_header_merge' ).on( 'change', function() {
var _this = $( this );
if ( '' !== _this.val() ) {
$( '.requires-header-merge' ).show();
if ( $( '#_generate_navigation_colors' ).is( ':checked' ) ) {
$( '.requires-navigation-colors' ).show();
}
if ( $( '#_generate_hero_full_screen' ).is( ':checked' ) ) {
$( '.requires-full-screen' ).show();
}
} else {
$( '.requires-header-merge' ).hide();
$( '.requires-navigation-colors' ).hide();
$( '.requires-full-screen' ).hide();
}
} );
$( '#_generate_navigation_colors' ).on( 'change', function() {
var _this = $( this );
if ( _this.is( ':checked' ) ) {
$( '.requires-navigation-colors' ).show();
} else {
$( '.requires-navigation-colors' ).hide();
}
} );
$( '#_generate_hero_full_screen' ).on( 'change', function() {
var _this = $( this );
if ( _this.is( ':checked' ) ) {
$( '.requires-full-screen' ).show();
} else {
$( '.requires-full-screen' ).hide();
}
} );
$( '#_generate_hero_background_parallax' ).on( 'change', function() {
var _this = $( this );
if ( _this.is( ':checked' ) ) {
$( '#_generate_hero_background_position' ).val( '' ).change();
$( '#_generate_hero_background_position option[value="left center"]' ).attr( 'disabled', true );
$( '#_generate_hero_background_position option[value="left bottom"]' ).attr( 'disabled', true );
$( '#_generate_hero_background_position option[value="right center"]' ).attr( 'disabled', true );
$( '#_generate_hero_background_position option[value="right bottom"]' ).attr( 'disabled', true );
$( '#_generate_hero_background_position option[value="center center"]' ).attr( 'disabled', true );
$( '#_generate_hero_background_position option[value="center bottom"]' ).attr( 'disabled', true );
} else {
$( '#_generate_hero_background_position option[value="left center"]' ).attr( 'disabled', false );
$( '#_generate_hero_background_position option[value="left bottom"]' ).attr( 'disabled', false );
$( '#_generate_hero_background_position option[value="right center"]' ).attr( 'disabled', false );
$( '#_generate_hero_background_position option[value="right bottom"]' ).attr( 'disabled', false );
$( '#_generate_hero_background_position option[value="center center"]' ).attr( 'disabled', false );
$( '#_generate_hero_background_position option[value="center bottom"]' ).attr( 'disabled', false );
}
} );
} );

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -1,17 +0,0 @@
function generate_parallax_element( selector, context ) {
context = context || document;
var elements = context.querySelectorAll( selector );
return Array.prototype.slice.call( elements );
}
window.addEventListener( "scroll", function() {
var scrolledHeight= window.pageYOffset;
generate_parallax_element( ".page-hero" ).forEach( function( el, index, array ) {
var limit = el.offsetTop + el.offsetHeight;
if( scrolledHeight > el.offsetTop && scrolledHeight <= limit ) {
el.style.backgroundPositionY = ( scrolledHeight - el.offsetTop ) / hero.parallax + "px";
} else {
el.style.backgroundPositionY = "0";
}
});
});

View File

@ -1 +0,0 @@
function generate_parallax_element(e,o){var t=(o=o||document).querySelectorAll(e);return Array.prototype.slice.call(t)}window.addEventListener("scroll",function(){var r=window.pageYOffset;generate_parallax_element(".page-hero").forEach(function(e,o,t){var a=e.offsetTop+e.offsetHeight;r>e.offsetTop&&r<=a?e.style.backgroundPositionY=(r-e.offsetTop)/hero.parallax+"px":e.style.backgroundPositionY="0"})});

View File

@ -1,469 +0,0 @@
<?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 = '';
/**
* Has post ancestors.
*
* @since 2.0.0
* @var boolean If this post has a parent.
*/
protected $has_parent = false;
/**
* 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 );
$has_content_template_condition = get_post_meta( $post_id, '_generate_post_loop_item_display', true );
// Take over the $post_id temporarily if this is a child block.
// This allows us to inherit the parent block Display Rules.
if ( 'content-template' === $this->type && $has_content_template_condition ) {
$parent_block = wp_get_post_parent_id( $post_id );
if ( ! empty( $parent_block ) ) {
$this->has_parent = true;
$post_id = $parent_block;
}
}
$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
);
/**
* Simplify filter name.
*
* @since 2.0.0
*/
$display = apply_filters(
'generate_element_display',
$display,
$post_id
);
// Restore our actual post ID if it's been changed.
if ( 'content-template' === $this->type && $has_content_template_condition ) {
$post_id = $this->post_id;
}
if ( $display ) {
global $generate_elements;
$generate_elements[ $post_id ] = array(
'is_block_element' => true,
'type' => $this->type,
'id' => $post_id,
);
$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 'content-template':
$hook = 'generate_before_do_template_part';
break;
case 'loop-template':
$hook = 'generate_before_main_content';
break;
case 'search-modal':
$hook = 'generate_inside_search_modal';
break;
}
if ( 'custom' === $hook && $custom_hook ) {
$hook = $custom_hook;
}
if ( 'post-meta-template' === $this->type ) {
$post_meta_location = get_post_meta( $post_id, '_generate_post_meta_location', true );
if ( '' === $post_meta_location || 'after-post-title' === $post_meta_location ) {
$hook = 'generate_after_entry_title';
if ( is_page() ) {
$hook = 'generate_after_page_title';
}
} elseif ( 'before-post-title' === $post_meta_location ) {
$hook = 'generate_before_entry_title';
if ( is_page() ) {
$hook = 'generate_before_page_title';
}
} elseif ( 'after-content' === $post_meta_location ) {
$hook = 'generate_after_content';
}
}
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' );
}
if ( 'content-template' === $this->type && ! $this->has_parent ) {
add_filter( 'generate_do_template_part', array( $this, 'do_template_part' ) );
}
if ( 'loop-template' === $this->type ) {
add_filter( 'generate_has_default_loop', '__return_false' );
add_filter( 'generate_blog_columns', '__return_false' );
add_filter( 'option_generate_blog_settings', array( $this, 'filter_blog_settings' ) );
add_filter( 'post_class', array( $this, 'post_classes' ) );
}
if ( 'search-modal' === $this->type ) {
remove_action( 'generate_inside_search_modal', 'generate_do_search_fields' );
}
add_action( 'wp', array( $this, 'remove_elements' ), 100 );
add_action( esc_attr( $hook ), array( $this, 'build_hook' ), absint( $priority ) );
add_filter( 'generateblocks_do_content', array( $this, 'do_block_content' ) );
}
}
/**
* Disable our post loop items if needed.
*
* @param boolean $do Whether to display the default post loop item or not.
*/
public function do_template_part( $do ) {
if ( GeneratePress_Elements_Helper::should_render_content_template( $this->post_id ) ) {
return false;
}
return $do;
}
/**
* 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;
}
/**
* Filter some of our blog settings.
*
* @param array $settings Existing blog settings.
*/
public function filter_blog_settings( $settings ) {
if ( 'loop-template' === $this->type ) {
$settings['infinite_scroll'] = false;
$settings['read_more_button'] = false;
}
return $settings;
}
/**
* Add class to our loop template item posts.
*
* @param array $classes Post classes.
*/
public function post_classes( $classes ) {
if ( 'loop-template' === $this->type && is_main_query() ) {
$classes[] = 'is-loop-template-item';
}
return $classes;
}
/**
* Remove existing elements.
*
* @since 2.0.0
*/
public function remove_elements() {
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' );
}
if ( 'page-hero' === $this->type ) {
$disable_title = get_post_meta( $this->post_id, '_generate_disable_title', true );
$disable_featured_image = get_post_meta( $this->post_id, '_generate_disable_featured_image', true );
$disable_primary_post_meta = get_post_meta( $this->post_id, '_generate_disable_primary_post_meta', true );
if ( $disable_title ) {
if ( is_singular() ) {
add_filter( 'generate_show_title', '__return_false' );
}
remove_action( 'generate_archive_title', 'generate_archive_title' );
remove_filter( 'get_the_archive_title', 'generate_filter_the_archive_title' );
// WooCommerce removal.
if ( class_exists( 'WooCommerce' ) ) {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_filter( 'woocommerce_show_page_title', '__return_false' );
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );
remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description' );
}
}
if ( $disable_primary_post_meta ) {
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
}
if ( $disable_featured_image && is_singular() ) {
remove_action( 'generate_after_entry_header', 'generate_blog_single_featured_image' );
remove_action( 'generate_before_content', 'generate_blog_single_featured_image' );
remove_action( 'generate_after_header', 'generate_blog_single_featured_image' );
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single' );
remove_action( 'generate_after_header', 'generate_featured_page_header' );
}
}
if ( 'post-meta-template' === $this->type ) {
$post_meta_location = get_post_meta( $this->post_id, '_generate_post_meta_location', true );
$disable_primary_post_meta = get_post_meta( $this->post_id, '_generate_disable_primary_post_meta', true );
$disable_secondary_post_meta = get_post_meta( $this->post_id, '_generate_disable_secondary_post_meta', true );
if ( '' === $post_meta_location || 'after-post-title' === $post_meta_location || 'custom' === $post_meta_location ) {
if ( $disable_primary_post_meta ) {
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
}
} elseif ( 'before-post-title' === $post_meta_location || 'custom' === $post_meta_location ) {
if ( $disable_primary_post_meta ) {
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
}
} elseif ( 'after-content' === $post_meta_location || 'custom' === $post_meta_location ) {
if ( $disable_secondary_post_meta ) {
remove_action( 'generate_after_entry_content', 'generate_footer_meta' );
}
}
}
if ( 'post-navigation-template' === $this->type ) {
$disable_post_navigation = get_post_meta( $this->post_id, '_generate_disable_post_navigation', true );
if ( $disable_post_navigation ) {
add_filter( 'generate_footer_entry_meta_items', array( $this, 'disable_post_navigation' ) );
}
}
if ( 'archive-navigation-template' === $this->type ) {
$disable_archive_navigation = get_post_meta( $this->post_id, '_generate_disable_archive_navigation', true );
if ( $disable_archive_navigation ) {
remove_action( 'generate_after_loop', 'generate_do_post_navigation' );
}
}
}
/**
* Disable post navigation.
*
* @param array $items The post meta items.
*/
public function disable_post_navigation( $items ) {
return array_diff( $items, array( 'post-navigation' ) );
}
/**
* Builds the HTML structure for Page Headers.
*
* @since 1.11.0
*/
public function build_hook() {
$post_id = $this->post_id;
if ( 'content-template' === $this->type ) {
// Check for child templates if this isn't already one.
if ( ! $this->has_parent ) {
$children = get_posts(
array(
'post_type' => 'gp_elements',
'post_parent' => $post_id,
'order' => 'ASC',
'orderby' => 'menu_order',
'no_found_rows' => true,
'post_status' => 'publish',
'numberposts' => 20,
'fields' => 'ids',
)
);
if ( ! empty( $children ) ) {
// Loop through any child templates and overwrite $post_id if applicable.
foreach ( (array) $children as $child_id ) {
if ( GeneratePress_Elements_Helper::should_render_content_template( $child_id ) ) {
$post_id = $child_id;
break;
}
}
} else {
// No children, check if parent should render.
if ( ! GeneratePress_Elements_Helper::should_render_content_template( $post_id ) ) {
return;
}
}
} else {
// No children, check if template should render.
if ( ! GeneratePress_Elements_Helper::should_render_content_template( $post_id ) ) {
return;
}
}
// Don't display child elements - they will replace the parent element if applicable.
if ( $this->has_parent ) {
return;
}
$tag_name_value = get_post_meta( $post_id, '_generate_post_loop_item_tagname', true );
$use_theme_container = get_post_meta( $post_id, '_generate_use_theme_post_container', true );
if ( $tag_name_value ) {
$tag_name = $tag_name_value;
} else {
$tag_name = 'article';
}
printf(
'<%s id="%s" class="%s">',
esc_attr( $tag_name ),
'post-' . get_the_ID(),
implode( ' ', get_post_class( 'dynamic-content-template' ) ) // phpcs:ignore -- No escaping needed.
);
if ( $use_theme_container ) {
echo '<div class="inside-article">';
}
}
if ( 'archive-navigation-template' === $this->type || 'post-navigation-template' === $this->type ) {
$use_theme_pagination_container = get_post_meta( $post_id, '_generate_use_archive_navigation_container', true );
if ( $use_theme_pagination_container ) {
echo '<div class="paging-navigation">';
}
}
echo GeneratePress_Elements_Helper::build_content( $post_id ); // phpcs:ignore -- No escaping needed.
if ( 'content-template' === $this->type ) {
if ( $use_theme_container ) {
echo '</div>';
}
echo '</' . esc_attr( $tag_name ) . '>';
}
if ( 'archive-navigation-template' === $this->type || 'post-navigation-template' === $this->type ) {
$use_theme_pagination_container = get_post_meta( $post_id, '_generate_use_archive_navigation_container', true );
if ( $use_theme_pagination_container ) {
echo '</div>';
}
}
}
}

View File

@ -1,438 +0,0 @@
<?php
/**
* This file handles the Display Rule conditions for Elements.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* The conditions class.
*/
class GeneratePress_Conditions {
/**
* Instance.
*
* @var instance
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Output our available location conditions.
*
* @since 1.7
*
* @return array
*/
public static function get_conditions() {
$types = array(
'general' => array(
'label' => esc_attr__( 'General', 'gp-premium' ),
'locations' => array(
'general:site' => esc_attr__( 'Entire Site', 'gp-premium' ),
'general:front_page' => esc_attr__( 'Front Page', 'gp-premium' ),
'general:blog' => esc_attr__( 'Blog', 'gp-premium' ),
'general:singular' => esc_attr__( 'All Singular', 'gp-premium' ),
'general:archive' => esc_attr__( 'All Archives', 'gp-premium' ),
'general:author' => esc_attr__( 'Author Archives', 'gp-premium' ),
'general:date' => esc_attr__( 'Date Archives', 'gp-premium' ),
'general:search' => esc_attr__( 'Search Results', 'gp-premium' ),
'general:no_results' => esc_attr__( 'No Search Results', 'gp-premium' ),
'general:404' => esc_attr__( '404 Template', 'gp-premium' ),
'general:is_paged' => esc_attr__( 'Paginated Results', 'gp-premium' ),
),
),
);
// Add the post types.
$post_types = get_post_types(
array(
'public' => true,
),
'objects'
);
foreach ( $post_types as $post_type_slug => $post_type ) {
if ( in_array( $post_type_slug, array( 'fl-theme-layout' ) ) ) {
continue;
}
$post_type_object = get_post_type_object( $post_type_slug );
$counts = wp_count_posts( $post_type_slug );
$count = $counts->publish + $counts->future + $counts->draft + $counts->pending + $counts->private;
// Add the post type.
$types[ $post_type_slug ] = array(
'label' => esc_html( $post_type->labels->name ),
'locations' => array(
'post:' . $post_type_slug => esc_html( $post_type->labels->singular_name ),
),
);
// Add the post type archive.
if ( 'post' === $post_type_slug || ! empty( $post_type_object->has_archive ) ) {
$types[ $post_type_slug . '_archive' ] = array(
/* 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 ),
),
);
}
// Add the taxonomies for the post type.
$taxonomies = get_object_taxonomies( $post_type_slug, 'objects' );
foreach ( $taxonomies as $taxonomy_slug => $taxonomy ) {
$public = $taxonomy->public && $taxonomy->show_ui;
if ( 'post_format' === $taxonomy_slug ) {
continue;
} elseif ( ! apply_filters( 'generate_elements_show_taxonomy', $public, $taxonomy ) ) {
continue;
}
$label = str_replace(
array(
$post_type->labels->name,
$post_type->labels->singular_name,
),
'',
$taxonomy->labels->singular_name
);
if ( isset( $types[ $post_type_slug . '_archive' ]['locations'] ) ) {
/* 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 );
}
}
}
return $types;
}
/**
* Output our available user conditions.
*
* @since 1.7
*
* @return array
*/
public static function get_user_conditions() {
$rules = array(
'general' => array(
'label' => esc_attr__( 'General', 'gp-premium' ),
'rules' => array(
'general:all' => esc_attr__( 'All Users', 'gp-premium' ),
'general:logged_in' => esc_attr__( 'Logged In', 'gp-premium' ),
'general:logged_out' => esc_attr__( 'Logged Out', 'gp-premium' ),
),
),
'role' => array(
'label' => esc_attr__( 'Roles', 'gp-premium' ),
'rules' => array(),
),
);
$roles = get_editable_roles();
foreach ( $roles as $slug => $data ) {
$rules['role']['rules'][ $slug ] = $data['name'];
}
return $rules;
}
/**
* Get our current location.
*
* @since 1.7
*
* @return array
*/
public static function get_current_location() {
global $wp_query;
global $post;
$location = null;
$object = null;
$queried_object = get_queried_object();
// Get the location string.
if ( is_front_page() ) {
$location = 'general:front_page';
} elseif ( is_home() ) {
$location = 'general:blog';
} elseif ( is_author() ) {
$location = 'general:author';
} elseif ( is_date() ) {
$location = 'general:date';
} elseif ( is_search() ) {
$location = 'general:search';
global $wp_query;
if ( 0 === $wp_query->found_posts ) {
$location = 'general:no_results';
}
} elseif ( is_404() ) {
$location = 'general:404';
} elseif ( is_category() ) {
$location = 'taxonomy:category';
if ( is_object( $queried_object ) ) {
$object = $queried_object->term_id;
}
} elseif ( is_tag() ) {
$location = 'taxonomy:post_tag';
if ( is_object( $queried_object ) ) {
$object = $queried_object->term_id;
}
} elseif ( is_tax() ) {
$location = 'taxonomy:' . get_query_var( 'taxonomy' );
if ( is_object( $queried_object ) ) {
$location = 'taxonomy:' . $queried_object->taxonomy;
$object = $queried_object->term_id;
}
} elseif ( is_post_type_archive() ) {
$post_type = $wp_query->get( 'post_type' );
if ( is_array( $post_type ) ) {
$location = 'archive:' . $post_type[0];
} else {
$location = 'archive:' . $post_type;
}
} elseif ( is_singular() ) {
if ( is_object( $post ) ) {
$location = 'post:' . $post->post_type;
}
if ( is_object( $queried_object ) ) {
$object = $queried_object->ID;
}
}
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;
}
} elseif ( isset( $_GET['post_type'] ) ) { // phpcs:ignore -- Just checking if it's set.
$location = 'post:' . esc_attr( $_GET['post_type'] ); // phpcs:ignore -- No data processing going on.
}
}
}
return array(
'rule' => $location,
'object' => $object,
);
}
/**
* Get info on the current user.
*
* @since 1.7
*
* @return array
*/
public static function get_current_user() {
$status = array();
if ( is_user_logged_in() ) {
$status[] = 'general:logged_in';
} else {
$status[] = 'general:logged_out';
}
$user = wp_get_current_user();
foreach ( (array) $user->roles as $role ) {
$status[] = $role;
}
return $status;
}
/**
* Figure out if we should display the element or not.
*
* @since 1.7
*
* @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 ) {
$current_location = self::get_current_location();
$show = false;
// Show depending on location conditionals.
if ( ! $show ) {
foreach ( (array) $conditionals as $conditional ) {
if ( in_array( 'general:site', $conditional ) ) {
$show = true;
} elseif ( is_singular() && in_array( 'general:singular', $conditional ) ) {
$show = true;
} elseif ( is_archive() && in_array( 'general:archive', $conditional ) ) {
$show = true;
} elseif ( ! empty( $current_location['rule'] ) && in_array( $current_location['rule'], $conditional ) ) {
if ( ! isset( $conditional['object'] ) || empty( $conditional['object'] ) ) {
$show = true;
} else {
if ( in_array( $current_location['object'], $conditional ) ) {
$show = true;
}
}
} elseif ( is_singular() && strstr( $conditional['rule'], ':taxonomy:' ) ) {
$tax = substr( $conditional['rule'], strrpos( $conditional['rule'], ':' ) + 1 );
if ( $tax && isset( $conditional['object'] ) && has_term( $conditional['object'], $tax ) ) {
$show = true;
}
} elseif ( is_front_page() && is_home() && ( in_array( 'general:blog', $conditional ) || in_array( 'general:front_page', $conditional ) ) ) {
// If the home page is the blog, both of general:blog and general:front_page apply.
$show = true;
} elseif ( in_array( 'general:is_paged', $conditional ) && is_paged() ) {
$show = true;
}
}
}
// Exclude based on exclusion conditionals.
if ( $show ) {
foreach ( (array) $exclude as $conditional ) {
if ( is_singular() && in_array( 'general:singular', $conditional ) ) {
$show = false;
} elseif ( is_archive() && in_array( 'general:archive', $conditional ) ) {
$show = false;
} elseif ( ! empty( $current_location['rule'] ) && in_array( $current_location['rule'], $conditional ) ) {
if ( ! isset( $conditional['object'] ) || empty( $conditional['object'] ) ) {
$show = false;
} else {
if ( in_array( $current_location['object'], $conditional ) ) {
$show = false;
}
}
} elseif ( is_singular() && strstr( $conditional['rule'], ':taxonomy:' ) ) {
$tax = substr( $conditional['rule'], strrpos( $conditional['rule'], ':' ) + 1 );
if ( $tax && isset( $conditional['object'] ) && has_term( $conditional['object'], $tax ) ) {
$show = false;
}
} elseif ( is_front_page() && is_home() && ( in_array( 'general:blog', $conditional ) || in_array( 'general:front_page', $conditional ) ) ) {
// If the home page is the blog, both of general:blog and general:front_page apply.
$show = false;
} elseif ( in_array( 'general:is_paged', $conditional ) && is_paged() ) {
$show = false;
}
}
}
// Exclude user roles.
if ( $show && ! empty( $roles ) ) {
$user_info = self::get_current_user();
$check = array_intersect( $roles, $user_info );
if ( ! count( $check ) > 0 && ! in_array( 'general:all', $roles ) ) {
$show = false;
}
}
return $show;
}
/**
* Returns the label for a saved location.
*
* @since 1.7
* @param string $saved_location The location.
* @return string|bool
*/
public static function get_saved_label( $saved_location ) {
$locations = self::get_conditions();
$rule = $saved_location['rule'];
$object_id = $saved_location['object'];
$object_type = '';
$label = false;
foreach ( $locations as $data ) {
if ( isset( $data['locations'][ $rule ] ) && ! $label ) {
$label = $data['locations'][ $rule ];
$object_types = explode( ':', $rule );
if ( in_array( 'taxonomy', $object_types ) && $object_id ) {
$term = get_term( $object_id );
if ( ! is_object( $term ) || is_wp_error( $term ) ) {
return false;
}
$label .= ': ' . $term->name;
} elseif ( ( in_array( 'post', $object_types ) || in_array( 'page', $object_types ) ) && $object_id ) {
$post = get_post( $object_id );
if ( ! is_object( $post ) ) {
return false;
}
$label .= ': ' . $post->post_title;
}
}
}
return $label;
}
}
GeneratePress_Conditions::get_instance();

View File

@ -1,503 +0,0 @@
<?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.
*
* @access private
* @var object Instance
* @since 1.7
*/
private static $instance;
/**
* Initiator.
*
* @since 1.7
* @return object initialized object of class.
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Check to see if specific theme/GPP options exist and are set.
*
* @since 1.7
*
* @param string $option Option to check.
* @return bool
*/
public static function does_option_exist( $option ) {
if ( function_exists( 'generate_get_defaults' ) ) {
$theme_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
if ( 'site-title' === $option ) {
return $theme_settings['hide_title'] ? false : true;
}
if ( 'site-tagline' === $option ) {
return $theme_settings['hide_tagline'] ? false : true;
}
if ( 'retina-logo' === $option ) {
return $theme_settings['retina_logo'];
}
}
if ( 'site-logo' === $option ) {
return get_theme_mod( 'custom_logo' );
}
if ( function_exists( 'generate_menu_plus_get_defaults' ) ) {
$menu_settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
if ( 'navigation-as-header' === $option ) {
return $menu_settings['navigation_as_header'];
}
if ( 'mobile-logo' === $option ) {
return $menu_settings['mobile_header_logo'];
}
if ( 'navigation-logo' === $option ) {
return $menu_settings['sticky_menu_logo'];
}
if ( 'sticky-navigation' === $option ) {
return 'false' !== $menu_settings['sticky_menu'] ? true : false;
}
if ( 'sticky-navigation-logo' === $option ) {
return $menu_settings['sticky_navigation_logo'];
}
if ( 'mobile-header-branding' === $option ) {
return $menu_settings['mobile_header_branding'];
}
if ( 'sticky-mobile-header' === $option ) {
return 'disable' !== $menu_settings['mobile_header_sticky'] ? true : false;
}
}
return false;
}
/**
* Check whether we should execute PHP or not.
*/
public static function should_execute_php() {
$php = true;
if ( defined( 'DISALLOW_FILE_EDIT' ) ) {
$php = false;
}
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 '';
}
$block_type = get_post_meta( $id, '_generate_block_type', true );
if ( 'site-footer' === $block_type ) {
$block_element->post_content = str_replace( '{{current_year}}', date( 'Y' ), $block_element->post_content ); // phpcs:ignore -- Prefer date().
}
// Handle embeds for block elements.
global $wp_embed;
if ( is_object( $wp_embed ) && method_exists( $wp_embed, 'autoembed' ) ) {
$block_element->post_content = $wp_embed->autoembed( $block_element->post_content );
}
return apply_filters( 'generate_do_block_element_content', do_blocks( $block_element->post_content ) );
}
/**
* Get our Element type label.
*
* @since 2.0.0
* @param string $type The type value.
*/
public static function get_element_type_label( $type ) {
switch ( $type ) {
case 'block':
$label = __( 'Block', 'gp-premium' );
break;
case 'header':
$label = __( 'Header', 'gp-premium' );
break;
case 'hook':
$label = __( 'Hook', 'gp-premium' );
break;
case 'layout':
$label = __( 'Layout', 'gp-premium' );
break;
case 'site-header':
$label = __( 'Site Header', 'gp-premium' );
break;
case 'page-hero':
$label = __( 'Page Hero', 'gp-premium' );
break;
case 'content-template':
$label = __( 'Content Template', 'gp-premium' );
break;
case 'loop-template':
$label = __( 'Loop Template', 'gp-premium' );
break;
case 'post-meta-template':
$label = __( 'Post Meta Template', 'gp-premium' );
break;
case 'post-navigation-template':
$label = __( 'Post Navigation', 'gp-premium' );
break;
case 'archive-navigation-template':
$label = __( 'Archive Navigation', 'gp-premium' );
break;
case 'right-sidebar':
$label = __( 'Right Sidebar', 'gp-premium' );
break;
case 'left-sidebar':
$label = __( 'Left Sidebar', 'gp-premium' );
break;
case 'site-footer':
$label = __( 'Site Footer', 'gp-premium' );
break;
default:
$label = esc_html( str_replace( '-', ' ', ucfirst( $type ) ) );
break;
}
return $label;
}
/**
* Check for content template conditions.
*
* @since 2.0.0
* @param int $post_id The post to check.
*/
public static function should_render_content_template( $post_id ) {
$loop_item_display = get_post_meta( $post_id, '_generate_post_loop_item_display', true );
$display = true;
if ( 'has-term' === $loop_item_display ) {
$tax = get_post_meta( $post_id, '_generate_post_loop_item_display_tax', true );
if ( $tax ) {
$term = get_post_meta( $post_id, '_generate_post_loop_item_display_term', true );
// Add support for multiple comma separated terms.
if ( ! empty( $term ) ) {
$term = str_replace( ' ', '', $term );
$term = explode( ',', $term );
}
if ( has_term( $term, $tax ) ) {
$display = true;
} else {
$display = false;
}
}
}
if ( 'has-post-meta' === $loop_item_display ) {
$post_meta_name = get_post_meta( $post_id, '_generate_post_loop_item_display_post_meta', true );
if ( $post_meta_name ) {
$post_meta = get_post_meta( get_the_ID(), $post_meta_name, true );
if ( $post_meta ) {
$display = true;
} else {
$display = false;
}
}
}
if ( 'is-first-post' === $loop_item_display ) {
global $wp_query;
if ( 0 === $wp_query->current_post && ! is_paged() ) {
$display = true;
} else {
$display = false;
}
}
return apply_filters( 'generate_should_render_content_template', $display, $post_id );
}
/**
* Build our entire list of hooks to display.
*
* @since 1.7
*
* @return array Our list of hooks.
*/
public static function get_available_hooks() {
$hooks = array(
'scripts' => array(
'group' => esc_attr__( 'Scripts/Styles', 'gp-premium' ),
'hooks' => array(
'wp_head',
'wp_body_open',
'wp_footer',
),
),
'header' => array(
'group' => esc_attr__( 'Header', 'gp-premium' ),
'hooks' => array(
'generate_before_header',
'generate_after_header',
'generate_before_header_content',
'generate_after_header_content',
'generate_before_logo',
'generate_after_logo',
'generate_header',
),
),
'navigation' => array(
'group' => esc_attr__( 'Navigation', 'gp-premium' ),
'hooks' => array(
'generate_inside_navigation',
'generate_after_primary_menu',
'generate_inside_secondary_navigation',
'generate_inside_mobile_menu',
'generate_inside_mobile_menu_bar',
'generate_inside_mobile_header',
'generate_inside_slideout_navigation',
'generate_after_slideout_navigation',
),
),
'content' => array(
'group' => esc_attr__( 'Content', 'gp-premium' ),
'hooks' => array(
'generate_inside_site_container',
'generate_inside_container',
'generate_before_main_content',
'generate_after_main_content',
'generate_before_content',
'generate_after_content',
'generate_after_entry_content',
'generate_after_primary_content_area',
'generate_before_entry_title',
'generate_after_entry_title',
'generate_after_entry_header',
'generate_before_archive_title',
'generate_after_archive_title',
'generate_after_archive_description',
),
),
'comments' => array(
'group' => esc_attr__( 'Comments', 'gp-premium' ),
'hooks' => array(
'generate_before_comments_container',
'generate_before_comments',
'generate_inside_comments',
'generate_below_comments_title',
),
),
'sidebars' => array(
'group' => esc_attr__( 'Sidebars', 'gp-premium' ),
'hooks' => array(
'generate_before_right_sidebar_content',
'generate_after_right_sidebar_content',
'generate_before_left_sidebar_content',
'generate_after_left_sidebar_content',
),
),
'footer' => array(
'group' => esc_attr__( 'Footer', 'gp-premium' ),
'hooks' => array(
'generate_before_footer',
'generate_after_footer',
'generate_after_footer_widgets',
'generate_before_footer_content',
'generate_after_footer_content',
'generate_footer',
),
),
);
if ( class_exists( 'WooCommerce' ) ) {
$hooks['navigation']['hooks'][] = 'generate_mobile_cart_items';
$hooks['woocommerce-global'] = array(
'group' => esc_attr__( 'WooCommerce - Global', 'gp-premium' ),
'hooks' => array(
'woocommerce_before_main_content',
'woocommerce_after_main_content',
'woocommerce_sidebar',
'woocommerce_breadcrumb',
),
);
$hooks['woocommerce-shop'] = array(
'group' => esc_attr__( 'WooCommerce - Shop', 'gp-premium' ),
'hooks' => array(
'woocommerce_archive_description',
'woocommerce_before_shop_loop',
'woocommerce_after_shop_loop',
'woocommerce_before_shop_loop_item_title',
'woocommerce_after_shop_loop_item_title',
),
);
$hooks['woocommerce-product'] = array(
'group' => esc_attr__( 'WooCommerce - Product', 'gp-premium' ),
'hooks' => array(
'woocommerce_before_single_product',
'woocommerce_before_single_product_summary',
'woocommerce_after_single_product_summary',
'woocommerce_single_product_summary',
'woocommerce_share',
'woocommerce_simple_add_to_cart',
'woocommerce_before_add_to_cart_form',
'woocommerce_after_add_to_cart_form',
'woocommerce_before_add_to_cart_button',
'woocommerce_after_add_to_cart_button',
'woocommerce_before_add_to_cart_quantity',
'woocommerce_after_add_to_cart_quantity',
'woocommerce_product_meta_start',
'woocommerce_product_meta_end',
'woocommerce_after_single_product',
),
);
$hooks['woocommerce-cart'] = array(
'group' => esc_attr__( 'WooCommerce - Cart', 'gp-premium' ),
'hooks' => array(
'woocommerce_before_calculate_totals',
'woocommerce_after_calculate_totals',
'woocommerce_before_cart',
'woocommerce_after_cart_table',
'woocommerce_before_cart_table',
'woocommerce_before_cart_contents',
'woocommerce_cart_contents',
'woocommerce_after_cart_contents',
'woocommerce_cart_coupon',
'woocommerce_cart_actions',
'woocommerce_before_cart_totals',
'woocommerce_cart_totals_before_order_total',
'woocommerce_cart_totals_after_order_total',
'woocommerce_proceed_to_checkout',
'woocommerce_after_cart_totals',
'woocommerce_after_cart',
),
);
$hooks['woocommerce-checkout'] = array(
'group' => esc_attr__( 'WooCommerce - Checkout', 'gp-premium' ),
'hooks' => array(
'woocommerce_before_checkout_form',
'woocommerce_checkout_before_customer_details',
'woocommerce_checkout_after_customer_details',
'woocommerce_checkout_billing',
'woocommerce_before_checkout_billing_form',
'woocommerce_after_checkout_billing_form',
'woocommerce_before_order_notes',
'woocommerce_after_order_notes',
'woocommerce_checkout_shipping',
'woocommerce_checkout_before_order_review',
'woocommerce_checkout_order_review',
'woocommerce_review_order_before_cart_contents',
'woocommerce_review_order_after_cart_contents',
'woocommerce_review_order_before_order_total',
'woocommerce_review_order_after_order_total',
'woocommerce_review_order_before_payment',
'woocommerce_review_order_before_submit',
'woocommerce_review_order_after_submit',
'woocommerce_review_order_after_payment',
'woocommerce_checkout_after_order_review',
'woocommerce_after_checkout_form',
),
);
$hooks['woocommerce-account'] = array(
'group' => esc_attr__( 'WooCommerce - Account', 'gp-premium' ),
'hooks' => array(
'woocommerce_before_account_navigation',
'woocommerce_account_navigation',
'woocommerce_after_account_navigation',
),
);
}
if ( function_exists( 'generate_is_using_flexbox' ) && generate_is_using_flexbox() ) {
$hooks['navigation']['hooks'][] = 'generate_menu_bar_items';
}
if ( defined( 'GENERATE_VERSION' ) && version_compare( GENERATE_VERSION, '3.0.0-alpha.1', '>' ) ) {
$hooks['navigation']['hooks'][] = 'generate_before_navigation';
$hooks['navigation']['hooks'][] = 'generate_after_navigation';
$hooks['navigation']['hooks'][] = 'generate_after_mobile_menu_button';
$hooks['navigation']['hooks'][] = 'generate_inside_mobile_menu_control_wrapper';
$hooks['content']['hooks'][] = 'generate_after_loop';
$hooks['content']['hooks'][] = 'generate_before_do_template_part';
$hooks['content']['hooks'][] = 'generate_after_do_template_part';
}
return apply_filters( 'generate_hooks_list', $hooks );
}
}

View File

@ -1,223 +0,0 @@
<?php
/**
* This file handles the Hook Element.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* Execute our hook elements.
*
* @since 1.7
*/
class GeneratePress_Hook {
/**
* Set our content variable.
*
* @since 1.7
* @var string The content.
*/
protected $content = '';
/**
* Set our hook/action variable.
*
* @since 1.7
* @var string The hook.
*/
protected $hook = '';
/**
* Set our custom hook variable.
*
* @since 1.7
* @var string The custom hook.
*/
protected $custom_hook = '';
/**
* Set our disable site header variable.
*
* @since 1.7
* @var boolean Whether we're disabling the header.
*/
protected $disable_site_header = false;
/**
* Set our disable footer variable.
*
* @since 1.7
* @var boolean Whether we're disabling the footer.
*/
protected $disable_site_footer = false;
/**
* Set our priority variable.
*
* @since 1.7
* @var int The hook priority.
*/
protected $priority = 10;
/**
* Set our execute PHP variable.
*
* @since 1.7
* @var boolean Whether we're executing PHP.
*/
protected $php = false;
/**
* Set our execute shortcodes variable.
*
* @since 1.7
* @var boolean Whether we're executing shortcodes.
*/
protected $shortcodes = false;
/**
* Set our location variable.
*
* @since 1.7
* @var array The conditions.
*/
protected $conditional = array();
/**
* Set our exclusions variable.
*
* @since 1.7
* @var array The exclusions.
*/
protected $exclude = array();
/**
* Set our user condition variable.
*
* @since 1.7
* @var array The user roles.
*/
protected $users = array();
/**
* Set up our class and give variables their values.
*
* @param int $post_id The post ID of the element we're executing.
*
* @since 1.7
*/
public function __construct( $post_id ) {
$this->hook = get_post_meta( $post_id, '_generate_hook', true );
if ( empty( $this->hook ) ) {
return;
}
$this->content = get_post_meta( $post_id, '_generate_element_content', true );
if ( get_post_meta( $post_id, '_generate_custom_hook', true ) ) {
$this->custom_hook = get_post_meta( $post_id, '_generate_custom_hook', true );
}
if ( get_post_meta( $post_id, '_generate_hook_disable_site_header', true ) ) {
$this->disable_site_header = get_post_meta( $post_id, '_generate_hook_disable_site_header', true );
}
if ( get_post_meta( $post_id, '_generate_hook_disable_site_footer', true ) ) {
$this->disable_site_footer = get_post_meta( $post_id, '_generate_hook_disable_site_footer', true );
}
if ( get_post_meta( $post_id, '_generate_hook_priority', true ) || '0' === get_post_meta( $post_id, '_generate_hook_priority', true ) ) {
$this->priority = get_post_meta( $post_id, '_generate_hook_priority', true );
}
if ( get_post_meta( $post_id, '_generate_hook_execute_php', true ) ) {
$this->php = get_post_meta( $post_id, '_generate_hook_execute_php', true );
}
if ( get_post_meta( $post_id, '_generate_hook_execute_shortcodes', true ) ) {
$this->shortcodes = get_post_meta( $post_id, '_generate_hook_execute_shortcodes', true );
}
if ( get_post_meta( $post_id, '_generate_element_display_conditions', true ) ) {
$this->conditional = get_post_meta( $post_id, '_generate_element_display_conditions', true );
}
if ( get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) ) {
$this->exclude = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
}
if ( get_post_meta( $post_id, '_generate_element_user_conditions', true ) ) {
$this->users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
}
if ( 'custom' === $this->hook && $this->custom_hook ) {
$this->hook = $this->custom_hook;
}
$display = apply_filters( 'generate_hook_element_display', GeneratePress_Conditions::show_data( $this->conditional, $this->exclude, $this->users ), $post_id );
/**
* Simplify filter name.
*
* @since 2.0.0
*/
$display = apply_filters(
'generate_element_display',
$display,
$post_id
);
if ( $display ) {
global $generate_elements;
$generate_elements[ $post_id ] = array(
'is_block_element' => false,
'type' => 'hook',
'id' => $post_id,
);
if ( 'generate_header' === $this->hook && $this->disable_site_header ) {
remove_action( 'generate_header', 'generate_construct_header' );
}
if ( 'generate_footer' === $this->hook && $this->disable_site_footer ) {
remove_action( 'generate_footer', 'generate_construct_footer' );
add_filter( 'generate_footer_widgets', '__return_null' );
}
add_action( esc_attr( $this->hook ), array( $this, 'execute_hook' ), absint( $this->priority ) );
}
}
/**
* Output our hook content.
*
* @since 1.7
*/
public function execute_hook() {
$content = $this->content;
if ( $this->shortcodes ) {
$content = do_shortcode( $content );
}
if ( $this->php && GeneratePress_Elements_Helper::should_execute_php() ) {
ob_start();
eval( '?>' . $content . '<?php ' ); // phpcs:ignore -- Using eval() to execute PHP.
echo ob_get_clean(); // phpcs:ignore -- Escaping not necessary.
} else {
echo $content; // phpcs:ignore -- Escaping not necessary.
}
}
}

View File

@ -1,550 +0,0 @@
<?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();
/**
* Set our exclusion variable.
*
* @since 1.7
* @var array
*/
protected $exclude = array();
/**
* Set our user condition variable.
*
* @since 1.7
* @var array
*/
protected $users = array();
/**
* Set up our other options.
*
* @since 1.7
* @deprecated 1.7.3
* @var array
*/
protected static $options = array();
/**
* Sidebar layout.
*
* @since 1.7.3
* @var string
*/
protected $sidebar_layout = 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 = '';
/**
* Count how many instances are set.
*
* @since 1.7
* @deprecated 1.7.3
* @var int
*/
public static $instances = 0;
/**
* Set our class and give our variables values.
*
* @since 1.7
*
* @param int $post_id The post ID of our element.
*/
public function __construct( $post_id ) {
self::$post_id = $post_id;
if ( get_post_meta( $post_id, '_generate_element_display_conditions', true ) ) {
$this->conditional = get_post_meta( $post_id, '_generate_element_display_conditions', true );
}
if ( get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) ) {
$this->exclude = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
}
if ( get_post_meta( $post_id, '_generate_element_user_conditions', true ) ) {
$this->users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
}
if ( get_post_meta( $post_id, '_generate_sidebar_layout', true ) ) {
$this->sidebar_layout = get_post_meta( $post_id, '_generate_sidebar_layout', true );
}
if ( get_post_meta( $post_id, '_generate_footer_widgets', true ) ) {
$this->footer_widgets = get_post_meta( $post_id, '_generate_footer_widgets', true );
}
if ( get_post_meta( $post_id, '_generate_disable_site_header', true ) ) {
$this->disable_site_header = get_post_meta( $post_id, '_generate_disable_site_header', true );
}
if ( get_post_meta( $post_id, '_generate_disable_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 ) ) {
$this->disable_primary_navigation = get_post_meta( $post_id, '_generate_disable_primary_navigation', true );
}
if ( get_post_meta( $post_id, '_generate_disable_secondary_navigation', true ) ) {
$this->disable_secondary_navigation = get_post_meta( $post_id, '_generate_disable_secondary_navigation', true );
}
if ( get_post_meta( $post_id, '_generate_disable_featured_image', true ) ) {
$this->disable_featured_image = get_post_meta( $post_id, '_generate_disable_featured_image', true );
}
if ( get_post_meta( $post_id, '_generate_disable_content_title', true ) ) {
$this->disable_content_title = get_post_meta( $post_id, '_generate_disable_content_title', true );
}
if ( get_post_meta( $post_id, '_generate_disable_footer', true ) ) {
$this->disable_footer = get_post_meta( $post_id, '_generate_disable_footer', true );
}
if ( get_post_meta( $post_id, '_generate_content_area', true ) ) {
$this->content_area = get_post_meta( $post_id, '_generate_content_area', true );
}
if ( get_post_meta( $post_id, '_generate_content_width', true ) ) {
$this->content_width = get_post_meta( $post_id, '_generate_content_width', true );
}
$display = apply_filters( 'generate_layout_element_display', GeneratePress_Conditions::show_data( $this->conditional, $this->exclude, $this->users ), $post_id );
/**
* Simplify filter name.
*
* @since 2.0.0
*/
$display = apply_filters(
'generate_element_display',
$display,
$post_id
);
if ( $display ) {
global $generate_elements;
$generate_elements[ $post_id ] = array(
'is_block_element' => false,
'type' => 'layout',
'id' => $post_id,
);
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 );
}
}
}
/**
* Return our available options.
*
* @since 1.7
* @deprecated 1.7.3
*
* @return array
*/
public static function get_options() {
return false;
}
/**
* Initiate our set layout changes.
*
* @since 1.7
*/
public function after_setup() {
if ( $this->sidebar_layout && ! self::post_meta_exists( '_generate-sidebar-layout-meta' ) ) {
add_filter( 'generate_sidebar_layout', array( $this, 'filter_options' ) );
}
if ( $this->footer_widgets && ! self::post_meta_exists( '_generate-footer-widget-meta' ) ) {
add_filter( 'generate_footer_widgets', array( $this, 'filter_options' ) );
}
if ( $this->disable_site_header ) {
remove_action( 'generate_header', 'generate_construct_header' );
}
if ( $this->disable_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 );
add_filter( 'generate_disable_mobile_header_menu', '__return_true' );
}
if ( $this->disable_secondary_navigation ) {
add_filter( 'has_nav_menu', array( $this, 'disable_secondary_navigation' ), 10, 2 );
}
if ( $this->disable_featured_image ) {
remove_action( 'generate_after_entry_header', 'generate_blog_single_featured_image' );
remove_action( 'generate_before_content', 'generate_blog_single_featured_image' );
remove_action( 'generate_after_header', 'generate_blog_single_featured_image' );
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single' );
remove_action( 'generate_after_header', 'generate_featured_page_header' );
add_filter( 'body_class', array( $this, 'remove_featured_image_class' ), 20 );
}
if ( $this->disable_content_title ) {
add_filter( 'generate_show_title', '__return_false' );
}
if ( $this->disable_footer ) {
remove_action( 'generate_footer', 'generate_construct_footer' );
add_filter( 'generate_footer_widgets', '__return_null' );
}
if ( $this->content_area ) {
add_filter( 'body_class', array( $this, 'body_classes' ) );
}
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' );
}
if ( $this->content_area ) {
add_filter( 'generate_block_editor_content_area_type', array( $this, 'set_editor_content_area' ) );
}
if ( $this->content_width ) {
add_filter( 'generate_block_editor_container_width', array( $this, 'set_editor_content_width' ) );
}
}
}
/**
* 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 ( version_compare( generate_premium_get_theme_version(), '3.2.0-alpha.1', '<' ) ) {
if ( 'full-width' === $this->content_area ) {
$admin_css .= 'html .editor-styles-wrapper .wp-block{max-width: 100%}';
}
if ( $this->content_width ) {
$admin_css .= 'html .editor-styles-wrapper .wp-block{max-width: ' . absint( $this->content_width ) . 'px;}';
}
}
if ( $this->content_area ) {
$admin_css .= '#generate-layout-page-builder-container {opacity: 0.5;pointer-events: none;}';
}
if ( $admin_css ) {
wp_add_inline_style( 'wp-edit-blocks', $admin_css );
}
}
}
/**
* Check to see if our individual post metabox has a value.
*
* @since 1.7
*
* @param string $meta The meta key we're checking for.
* @return bool
*/
public static function post_meta_exists( $meta ) {
if ( ! is_singular() ) {
return false;
}
$value = get_post_meta( get_the_ID(), $meta, true );
if ( '_generate-footer-widget-meta' === $meta && '0' === $value ) {
$value = true;
}
if ( $value ) {
return true;
}
return false;
}
/**
* 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.
*
* @since 1.7
*/
public function filter_options() {
$filter = current_filter();
if ( 'generate_sidebar_layout' === $filter || 'generate_block_editor_sidebar_layout' === $filter ) {
return $this->sidebar_layout;
}
if ( 'generate_footer_widgets' === $filter ) {
if ( 'no-widgets' === $this->footer_widgets ) {
return 0;
} else {
return $this->footer_widgets;
}
}
}
/**
* Set the content area type in the editor.
*
* @param string $area Content area type.
*/
public function set_editor_content_area( $area ) {
if ( 'full-width' === $this->content_area ) {
$area = 'true';
}
if ( 'contained-container' === $this->content_area ) {
$area = 'contained';
}
return $area;
}
/**
* Set the content width in the editor.
*
* @param string $width Content width with unit.
*/
public function set_editor_content_width( $width ) {
if ( $this->content_width ) {
$width = absint( $this->content_width ) . 'px';
}
return $width;
}
/**
* Disable the Secondary Navigation if set.
*
* @since 1.7
*
* @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 ) {
if ( 'secondary' === $location ) {
return false;
}
return $has_nav_menu;
}
/**
* Sets any necessary body classes.
*
* @since 1.7
*
* @param array $classes Our existing body classes.
* @return array Our new set of classes.
*/
public function body_classes( $classes ) {
if ( 'full-width' === $this->content_area ) {
$classes[] = 'full-width-content';
}
if ( 'contained' === $this->content_area ) {
$classes[] = 'contained-content';
}
return $classes;
}
/**
* Remove the featured image class if it's disabled.
*
* @since 2.1.0
* @param array $classes The body classes.
*/
public function remove_featured_image_class( $classes ) {
if ( is_singular() ) {
$classes = generate_premium_remove_featured_image_class( $classes, $this->disable_featured_image );
}
return $classes;
}
}

View File

@ -1,508 +0,0 @@
<?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.
*
* @since 1.7
*
* @var instance
*/
private static $instance;
/**
* Initiator
*
* @since 1.7
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Build it.
*
* @since 1.7
*/
public function __construct() {
add_action( 'init', array( $this, 'post_type' ) );
if ( is_admin() ) {
add_action( 'admin_menu', array( $this, 'menu_item' ), 100 );
add_action( 'admin_head', array( $this, 'fix_current_item' ) );
add_filter( 'manage_gp_elements_posts_columns', array( $this, 'register_columns' ) );
add_action( 'manage_gp_elements_posts_custom_column', array( $this, 'add_columns' ), 10, 2 );
add_action( 'restrict_manage_posts', array( $this, 'build_element_type_filter' ) );
add_filter( 'pre_get_posts', array( $this, 'filter_element_types' ) );
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();
}
}
/**
* Load the metabox.
*
* @since 1.7
*/
public function setup_metabox() {
require plugin_dir_path( __FILE__ ) . 'class-metabox.php';
}
/**
* Set up our custom post type.
*
* @since 1.7
*/
public function post_type() {
$labels = array(
'name' => _x( 'Elements', 'Post Type General Name', 'gp-premium' ),
'singular_name' => _x( 'Element', 'Post Type Singular Name', 'gp-premium' ),
'menu_name' => __( 'Elements', 'gp-premium' ),
'all_items' => __( 'All Elements', 'gp-premium' ),
'add_new' => __( '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' ),
'item_published' => __( 'Element published.', 'gp-premium' ),
'item_updated' => __( 'Element updated.', 'gp-premium' ),
'item_scheduled' => __( 'Element scheduled.', 'gp-premium' ),
'item_reverted_to_draft' => __( 'Element reverted to draft.', 'gp-premium' ),
);
$args = array(
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'page-attributes', 'revisions' ),
'hierarchical' => true,
'public' => false,
'show_ui' => true,
'show_in_menu' => false,
'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;
$args['hierarchical'] = false;
}
if ( 'block' === $type ) {
$args['supports'] = array( 'title', 'editor', 'custom-fields', 'page-attributes', 'revisions' );
}
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.
*
* @since 1.7
*
* @param array $columns Existing CPT columns.
* @return array All our CPT columns.
*/
public function register_columns( $columns ) {
$columns['element_type'] = esc_html__( 'Type', 'gp-premium' );
$columns['location'] = esc_html__( 'Location', 'gp-premium' );
$columns['exclusions'] = esc_html__( 'Exclusions', 'gp-premium' );
$columns['users'] = esc_html__( 'Users', 'gp-premium' );
$new_columns = array();
// Need to do some funky stuff to display these columns before the date.
foreach ( $columns as $key => $value ) {
if ( 'date' === $key ) {
$new_columns['element_type'] = esc_html__( 'Type', 'gp-premium' );
$new_columns['location'] = esc_html__( 'Location', 'gp-premium' );
$new_columns['exclusions'] = esc_html__( 'Exclusions', 'gp-premium' );
$new_columns['users'] = esc_html__( 'Users', 'gp-premium' );
}
$new_columns[ $key ] = $value;
}
return $new_columns;
}
/**
* Add a filter select input to the admin list.
*
* @since 1.7
*/
public function build_element_type_filter() {
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
if ( ! $screen ) {
return;
}
if ( ! isset( $screen->post_type ) || 'gp_elements' !== $screen->post_type ) {
return;
}
$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' ),
);
$current_element_type = isset( $_GET['gp_element_type_filter'] ) ? esc_html( $_GET['gp_element_type_filter'] ) : ''; // phpcs:ignore -- No processing happening.
$current_block_type = isset( $_GET['gp_elements_block_type_filter'] ) ? esc_html( $_GET['gp_elements_block_type_filter'] ) : ''; // phpcs:ignore -- No processing happening.
?>
<select name="gp_element_type_filter">
<option value=""><?php esc_html_e( 'All types', 'gp-premium' ); ?></option>
<?php
foreach ( $values as $value => $label ) {
printf(
'<option value="%1$s" %2$s>%3$s</option>',
esc_html( $value ),
$value === $current_element_type ? 'selected="selected"' : '',
esc_html( $label )
);
}
?>
</select>
<?php
if ( 'block' === $current_element_type ) {
$block_types = array(
'hook',
'site-header',
'page-hero',
'content-template',
'loop-template',
'post-meta-template',
'post-navigation-template',
'archive-navigation-template',
'right-sidebar',
'left-sidebar',
'site-footer',
);
?>
<select name="gp_elements_block_type_filter">
<option value=""><?php esc_html_e( 'All block types', 'gp-premium' ); ?></option>
<?php
foreach ( $block_types as $value ) {
printf(
'<option value="%1$s" %2$s>%3$s</option>',
esc_html( $value ),
$value === $current_block_type ? 'selected="selected"' : '',
esc_html( GeneratePress_Elements_Helper::get_element_type_label( $value ) )
);
}
?>
</select>
<?php
}
}
/**
* Filter the shown elements in the admin list if our filter is set.
*
* @since 1.7
*
* @param object $query Existing query.
*/
public function filter_element_types( $query ) {
// 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'] : ''; // phpcs:ignore -- No processing happening.
$meta_query = array();
if ( 'edit.php' === $pagenow && $query->is_main_query() && '' !== $type ) {
$meta_query[] = array(
'key' => '_generate_element_type',
'value' => esc_attr( $type ),
'compare' => '=',
);
$block_type = isset( $_GET['gp_elements_block_type_filter'] ) ? $_GET['gp_elements_block_type_filter'] : ''; // phpcs:ignore -- No processing happening.
if ( 'block' === $type && '' !== $block_type ) {
$meta_query['relation'] = 'AND';
$meta_query[] = array(
'key' => '_generate_block_type',
'value' => esc_attr( $block_type ),
'compare' => '=',
);
}
$query->set( 'meta_query', $meta_query );
}
}
/**
* Add content to our custom post type columns.
*
* @since 1.7
*
* @param string $column The name of the column.
* @param int $post_id The ID of the post row.
*/
public function add_columns( $column, $post_id ) {
switch ( $column ) {
case 'element_type':
$type = get_post_meta( $post_id, '_generate_element_type', true );
$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( GeneratePress_Elements_Helper::get_element_type_label( $block_type ) );
if ( 'hook' === $block_type && $hook_location ) {
echo '<br />';
if ( 'custom' === $hook_location ) {
$custom_hook = get_post_meta( $post_id, '_generate_custom_hook', true );
echo '<span class="hook-location">' . esc_html( $custom_hook ) . '</span>';
} else {
echo '<span class="hook-location">' . esc_html( $hook_location ) . '</span>';
}
}
}
}
if ( 'header' === $type ) {
echo esc_html__( 'Header', 'gp-premium' );
}
if ( 'hook' === $type ) {
echo esc_html__( 'Hook', 'gp-premium' );
if ( $hook_location ) {
echo '<br />';
if ( 'custom' === $hook_location ) {
$custom_hook = get_post_meta( $post_id, '_generate_custom_hook', true );
echo '<span class="hook-location">' . esc_html( $custom_hook ) . '</span>';
} else {
echo '<span class="hook-location">' . esc_html( $hook_location ) . '</span>';
}
}
}
if ( 'layout' === $type ) {
echo esc_html__( 'Layout', 'gp-premium' );
}
break;
case 'location':
$location = get_post_meta( $post_id, '_generate_element_display_conditions', true );
$parent_block = wp_get_post_parent_id( $post_id );
if ( $location ) {
foreach ( (array) $location as $data ) {
echo esc_html( GeneratePress_Conditions::get_saved_label( $data ) );
echo '<br />';
}
} elseif ( ! empty( $parent_block ) ) {
echo esc_html__( 'Inherit from parent', 'gp-premium' );
} else {
echo esc_html__( 'Not set', 'gp-premium' );
}
break;
case 'exclusions':
$location = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
if ( $location ) {
foreach ( (array) $location as $data ) {
echo esc_html( GeneratePress_Conditions::get_saved_label( $data ) );
echo '<br />';
}
}
break;
case 'users':
$users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
if ( $users ) {
foreach ( (array) $users as $data ) {
if ( strpos( $data, ':' ) !== false ) {
$data = substr( $data, strpos( $data, ':' ) + 1 );
}
$return = ucwords( str_replace( '_', ' ', $data ) );
echo esc_html( $return ) . '<br />';
}
}
break;
}
}
/**
* Create our admin menu item.
*
* @since 1.7
*/
public function menu_item() {
add_submenu_page(
'themes.php',
esc_html__( 'Elements', 'gp-premium' ),
esc_html__( 'Elements', 'gp-premium' ),
apply_filters( 'generate_elements_admin_menu_capability', 'manage_options' ),
'edit.php?post_type=gp_elements'
);
}
/**
* Make sure our admin menu item is highlighted.
*
* @since 1.7
*/
public function fix_current_item() {
global $parent_file, $submenu_file, $post_type;
if ( 'gp_elements' === $post_type ) {
$parent_file = 'themes.php'; // 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="hook"><?php esc_attr_e( 'Hook', 'gp-premium' ); ?></option>
<option value="layout"><?php esc_attr_e( 'Layout', 'gp-premium' ); ?></option>
<option value="header"><?php esc_attr_e( 'Header', '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
}
}
}
GeneratePress_Elements_Post_Type::get_instance();

View File

@ -1,289 +0,0 @@
<?php
/**
* This file sets up our Elements module.
*
* @since 1.7.0
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
$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-block-elements.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.
*
* @since 1.7
*/
function generate_premium_do_elements() {
$args = array(
'post_type' => 'gp_elements',
'no_found_rows' => true,
'post_status' => 'publish',
'numberposts' => 500, // phpcs:ignore
'fields' => 'ids',
'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'] = '';
}
$posts = get_posts( $args );
foreach ( $posts as $post_id ) {
$post_id = apply_filters( 'generate_element_post_id', $post_id );
$type = get_post_meta( $post_id, '_generate_element_type', true );
if ( 'hook' === $type ) {
new GeneratePress_Hook( $post_id );
}
if ( 'header' === $type && ! GeneratePress_Hero::$instances ) {
new GeneratePress_Hero( $post_id );
}
if ( 'layout' === $type ) {
new GeneratePress_Site_Layout( $post_id );
}
if ( 'block' === $type ) {
new GeneratePress_Block_Element( $post_id );
}
}
}
add_filter( 'generate_dashboard_tabs', 'generate_elements_dashboard_tab' );
/**
* Add the Sites tab to our Dashboard tabs.
*
* @since 1.6
*
* @param array $tabs Existing tabs.
* @return array New tabs.
*/
function generate_elements_dashboard_tab( $tabs ) {
$screen = get_current_screen();
$tabs['Elements'] = array(
'name' => __( 'Elements', 'gp-premium' ),
'url' => admin_url( 'edit.php?post_type=gp_elements' ),
'class' => 'edit-gp_elements' === $screen->id ? 'active' : '',
);
return $tabs;
}
add_filter( 'generate_dashboard_screens', 'generate_elements_dashboard_screen' );
/**
* Add the Sites tab to our Dashboard screens.
*
* @since 2.1.0
*
* @param array $screens Existing screens.
* @return array New screens.
*/
function generate_elements_dashboard_screen( $screens ) {
$screens[] = 'edit-gp_elements';
return $screens;
}
add_filter( 'generate_element_post_id', 'generate_elements_ignore_languages' );
/**
* Disable Polylang elements if their language doesn't match.
* We disable their automatic quering so Elements with no language display by default.
*
* @since 1.8
*
* @param int $post_id The current post ID.
* @return bool|int
*/
function generate_elements_ignore_languages( $post_id ) {
if ( function_exists( 'pll_get_post_language' ) && function_exists( 'pll_current_language' ) ) {
$language = pll_get_post_language( $post_id, 'locale' );
$disable = get_post_meta( $post_id, '_generate_element_ignore_languages', true );
if ( $disable ) {
return $post_id;
}
if ( $language && $language !== pll_current_language( 'locale' ) ) { // 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;
}
add_action( 'admin_bar_menu', 'generate_add_elements_admin_bar', 100 );
/**
* Add the Elementd admin bar item.
*
* @since 2.0.0
*/
function generate_add_elements_admin_bar() {
$current_user_can = 'manage_options';
if ( apply_filters( 'generate_elements_metabox_ajax_allow_editors', false ) ) {
$current_user_can = 'edit_posts';
}
if ( ! current_user_can( $current_user_can ) ) {
return;
}
global $wp_admin_bar;
global $generate_elements;
$title = __( 'Elements', 'gp-premium' );
$count = ! empty( $generate_elements ) ? count( $generate_elements ) : 0;
// Prevent "Entire Site" Elements from being counted on non-edit pages in the admin.
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
$screen = get_current_screen();
if ( ! isset( $screen->is_block_editor ) || ! $screen->is_block_editor ) {
$count = 0;
}
if ( 'edit' !== $screen->parent_base ) {
$count = 0;
}
}
if ( $count > 0 ) {
$title = sprintf(
/* translators: Active Element count. */
__( 'Elements (%s)', 'gp-premium' ),
$count
);
}
$wp_admin_bar->add_menu(
array(
'id' => 'gp_elements-menu',
'title' => $title,
'href' => esc_url( admin_url( 'edit.php?post_type=gp_elements' ) ),
)
);
if ( ! empty( $generate_elements ) ) {
// Prevent "Entire Site" Elements from being counted on non-edit pages in the admin.
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
$screen = get_current_screen();
if ( ! isset( $screen->is_block_editor ) || ! $screen->is_block_editor ) {
return;
}
if ( 'edit' !== $screen->parent_base ) {
return;
}
}
foreach ( (array) $generate_elements as $key => $data ) {
$label = GeneratePress_Elements_Helper::get_element_type_label( $data['type'] );
$wp_admin_bar->add_menu(
array(
'id' => 'element-' . absint( $data['id'] ),
'parent' => 'gp_elements-menu',
'title' => get_the_title( $data['id'] ) . ' (' . $label . ')',
'href' => get_edit_post_link( $data['id'] ),
)
);
}
}
}