rebase on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:23:21 -04:00
parent d37566ffb6
commit d096058d7d
4789 changed files with 254611 additions and 307223 deletions
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
!function(r){const s={container:"",init(){const a=this;jQuery(document).on("click",".aiosrs-rating-wrap .aiosrs-star-rating",function(s){s.preventDefault(),a.star_rating(this)}),jQuery(document).on("mouseover",".aiosrs-rating-wrap .aiosrs-star-rating",function(s){s.preventDefault(),a.hover_star_rating(this)}),jQuery(document).on("mouseout",".aiosrs-rating-wrap .aiosrs-star-rating-wrap",function(s){s.preventDefault(),r(this).hasClass("disabled")||(s=r(this).parent().find(".aiosrs-rating").text(),a.update_stars(r(this),s))})},hover_star_rating(s){const a=r(s).closest(".aiosrs-star-rating-wrap"),t=r(s).data("index");a.hasClass("disabled")||this.update_stars(a,t)},update_stars(s,a){let t=5<a?5:parseInt(a);t=5<a?5:a<0?0:parseInt(a);const n=a===t||5<a||a<0?0:1;s.find("span").each(function(s){r(this).removeClass("dashicons-star-filled dashicons-star-half dashicons-star-empty"),s<t?r(this).addClass("dashicons-star-filled"):(s===t&&n,r(this).addClass("dashicons-star-empty"))})},star_rating(s){const i=this,a=r(s).closest(".aiosrs-rating-wrap").data("schema-id"),e=r(s).closest(".aiosrs-star-rating-wrap"),t=r(s).data("index");e.hasClass("disabled")||(i.update_stars(e,t),e.addClass("disabled"),r.ajax({url:AIOSRS_Frontend.ajaxurl,type:"POST",data:{action:"aiosrs_user_rating",rating:t,schemaId:a,post_id:AIOSRS_Frontend.post_id,nonce:AIOSRS_Frontend.user_rating_nonce}}).success(function(s){if(!0===s.success){const a=e.next(".aiosrs-rating-summary-wrap"),t=s.rating,n=s["rating-avg"],r=s["review-count"];a.find(".aiosrs-rating").text(n),a.find(".aiosrs-rating-count").text(r),0===e.next(".success-msg").length&&e.after('<span class="success-msg">'+AIOSRS_Frontend.success_msg+"</span>"),setTimeout(function(){e.parent().find(".success-msg").remove(),e.removeClass("disabled")},5e3),i.update_stars(e,t)}}))}};r(function(){s.init()})}(jQuery);
!function(e){const s={container:"",init(){const a=this;jQuery(document).on("click",".aiosrs-rating-wrap .aiosrs-star-rating",function(s){s.preventDefault(),a.star_rating(this)}),jQuery(document).on("mouseover",".aiosrs-rating-wrap .aiosrs-star-rating",function(s){s.preventDefault(),a.hover_star_rating(this)}),jQuery(document).on("mouseout",".aiosrs-rating-wrap .aiosrs-star-rating-wrap",function(s){s.preventDefault(),e(this).hasClass("disabled")||(s=e(this).parent().find(".aiosrs-rating").text(),a.update_stars(e(this),s))})},hover_star_rating(s){var a=e(s).closest(".aiosrs-star-rating-wrap"),s=e(s).data("index");a.hasClass("disabled")||this.update_stars(a,s)},update_stars(s,a){let t=5<a?5:parseInt(a);const r=a===(t=5<a?5:a<0?0:parseInt(a))||5<a||a<0?0:1;s.find("span").each(function(s){e(this).removeClass("dashicons-star-filled dashicons-star-half dashicons-star-empty"),s<t?e(this).addClass("dashicons-star-filled"):(s===t&&r,e(this).addClass("dashicons-star-empty"))})},star_rating(s){const n=this,a=e(s).closest(".aiosrs-rating-wrap").data("schema-id"),i=e(s).closest(".aiosrs-star-rating-wrap"),t=e(s).data("index");i.hasClass("disabled")||(n.update_stars(i,t),i.addClass("disabled"),e.ajax({url:AIOSRS_Frontend.ajaxurl,type:"POST",data:{action:"aiosrs_user_rating",rating:t,schemaId:a,post_id:AIOSRS_Frontend.post_id,nonce:AIOSRS_Frontend.user_rating_nonce}}).success(function(s){var a,t,r;!0===s.success&&(a=i.next(".aiosrs-rating-summary-wrap"),t=s.rating,r=s["rating-avg"],s=s["review-count"],a.find(".aiosrs-rating").text(r),a.find(".aiosrs-rating-count").text(s),0===i.next(".success-msg").length&&i.after('<span class="success-msg">'+AIOSRS_Frontend.success_msg+"</span>"),setTimeout(function(){i.parent().find(".success-msg").remove(),i.removeClass("disabled")},5e3),n.update_stars(i,t))}))}};e(function(){s.init()})}(jQuery);
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
!function(s){jQuery(document).ready(function(){s(document).on("click",".aiosrs-pro-schema-temp-wrap",function(e){e.preventDefault(),s(".aiosrs-pro-schema-temp-wrap").removeClass("selected"),s(".aiosrs-pro-setup-actions").find(".button-next").removeAttr("disabled"),s(this).addClass("selected");var t=s(this).data("schema-type"),e=s(this).data("schema-title");s(document).find(".bsf-aiosrs-schema-type").val(t),s(document).find(".bsf-aiosrs-schema-title").val(e)})})}(jQuery);
!function(s){jQuery(document).ready(function(){s(document).on("click",".aiosrs-pro-schema-temp-wrap",function(e){e.preventDefault(),s(".aiosrs-pro-schema-temp-wrap").removeClass("selected"),s(".aiosrs-pro-setup-actions").find(".button-next").removeAttr("disabled"),s(this).addClass("selected");var e=s(this).data("schema-type"),t=s(this).data("schema-title");s(document).find(".bsf-aiosrs-schema-type").val(e),s(document).find(".bsf-aiosrs-schema-title").val(t)})})}(jQuery);
@@ -1,172 +1,172 @@
/* ========================================================================
* Frosty.js
* https://owensbla.github.com/frosty
* by Blake Owens (http://blakeowens.com/)
* ======================================================================== */
.bsf-has-tip,
.has-tip {
cursor: help;
}
.tip {
background-color: black;
background-color: rgba(0, 0, 0, 0.8);
color: #eeeeee;
font-size: 11px;
line-height: 1.5em;
max-width: 200px;
padding: 4px 8px;
}
.tip.success {
background-color: #47fe42;
background-color: rgba(71, 254, 66, 0.8);
color: #025600;
}
.tip.error {
background-color: #ff7f86;
background-color: rgba(255, 127, 134, 0.8);
color: #7f0006;
}
.tip.light {
background-color: #ebebeb;
background-color: rgba(235, 235, 235, 0.8);
color: #222222;
}
.tip[class*="arrow"]:before {
content: ' ';
position: absolute;
border: solid transparent;
width: 0px;
height: 0px;
border-width: 5px;
border-color: black;
border-color: rgba(0, 0, 0, 0.8);
}
.success[class*="arrow"]:before {
border-color: #47fe42;
border-color: rgba(71, 254, 66, 0.8);
}
.error[class*="arrow"]:before {
border-color: #ff7f86;
border-color: rgba(255, 127, 134, 0.8);
}
.light[class*="arrow"]:before {
border-color: #ebebeb;
border-color: rgba(235, 235, 235, 0.8);
}
.tip.arrow-right:before {
border-right-color: transparent;
border-top-color: transparent;
border-bottom-color: transparent;
margin-top: -5px;
top: 50%;
left: 100%;
}
.tip.arrow-left:before {
border-left-color: transparent;
border-top-color: transparent;
border-bottom-color: transparent;
margin-top: -5px;
top: 50%;
right: 100%;
}
.tip.arrow-top:before {
border-top-color: transparent;
border-left-color: transparent;
border-right-color: transparent;
margin-left: -5px;
bottom: 100%;
left: 50%;
}
.tip.arrow-bottom:before {
border-bottom-color: transparent;
border-left-color: transparent;
border-right-color: transparent;
margin-left: -5px;
top: 100%;
left: 50%;
}
/* Customizer Tooltip */
.customize-support .tip {
background-color: rgba(0, 148, 221, 0.95);
color: #FFF;
font-size: 13px;
line-height: 1.5em;
max-width: 200px;
padding: 5px 11px;
border: 1px solid #0094DD;
border-radius: 1px;
}
.customize-support .tip[class*="arrow"]:before {
border-width: 5px;
border-color: #0094DD;
border-color: rgba(0, 148, 221, 0.95);
}
.customize-support .tip.arrow-right:before {
border-right-color: transparent;
border-top-color: transparent;
border-bottom-color: transparent;
margin-top: -5px;
top: 50%;
left: 100%;
}
.customize-support .tip.arrow-left:before {
border-left-color: transparent;
border-top-color: transparent;
border-bottom-color: transparent;
margin-top: -5px;
top: 50%;
right: 100%;
}
.customize-support .tip.arrow-top:before {
border-top-color: transparent;
border-left-color: transparent;
border-right-color: transparent;
margin-left: -5px;
bottom: 100%;
left: 50%;
}
.customize-support .tip.arrow-bottom:before {
border-bottom-color: transparent;
border-left-color: transparent;
border-right-color: transparent;
margin-left: -5px;
top: 100%;
left: 50%;
}
/*---close button tooltip--------*/
.tip[class*="close-tip-content"]{
border-radius:7px;
max-width:300px;
padding: 15px 30px;
}
.tip[class*="close-tip-content"]:before{
border-width: 8px!important;
margin-top: -8px!important;
}
.tip[class*="close-tip-content"][class*="arrow-bottom"]{
/* margin-top:-10px; */
}
.tip[class*="close-tip-content"][class*="arrow-bottom"]:before{
margin-top: -1px!important;
}
.tip[class*="close-tip-content"][class*="arrow-right"]:before {
left: 100%;
left: calc(100% - 1px);
}
.cp-innertip.tip[class*="close-tip-content"][class*="arrow"]{
margin-top: 30px!important;
}
@media (max-width:768px) {
.tip[class*="close-tip-content"]{
border-radius:7px;
max-width:200px;
padding: 5px 20px;
}
}
@media (max-width:610px) {
.tip[class*="close-tip-content"]{
max-width:170px;
}
/* ========================================================================
* Frosty.js
* https://owensbla.github.com/frosty
* by Blake Owens (http://blakeowens.com/)
* ======================================================================== */
.bsf-has-tip,
.has-tip {
cursor: help;
}
.tip {
background-color: black;
background-color: rgba(0, 0, 0, 0.8);
color: #eeeeee;
font-size: 11px;
line-height: 1.5em;
max-width: 200px;
padding: 4px 8px;
}
.tip.success {
background-color: #47fe42;
background-color: rgba(71, 254, 66, 0.8);
color: #025600;
}
.tip.error {
background-color: #ff7f86;
background-color: rgba(255, 127, 134, 0.8);
color: #7f0006;
}
.tip.light {
background-color: #ebebeb;
background-color: rgba(235, 235, 235, 0.8);
color: #222222;
}
.tip[class*="arrow"]:before {
content: ' ';
position: absolute;
border: solid transparent;
width: 0px;
height: 0px;
border-width: 5px;
border-color: black;
border-color: rgba(0, 0, 0, 0.8);
}
.success[class*="arrow"]:before {
border-color: #47fe42;
border-color: rgba(71, 254, 66, 0.8);
}
.error[class*="arrow"]:before {
border-color: #ff7f86;
border-color: rgba(255, 127, 134, 0.8);
}
.light[class*="arrow"]:before {
border-color: #ebebeb;
border-color: rgba(235, 235, 235, 0.8);
}
.tip.arrow-right:before {
border-right-color: transparent;
border-top-color: transparent;
border-bottom-color: transparent;
margin-top: -5px;
top: 50%;
left: 100%;
}
.tip.arrow-left:before {
border-left-color: transparent;
border-top-color: transparent;
border-bottom-color: transparent;
margin-top: -5px;
top: 50%;
right: 100%;
}
.tip.arrow-top:before {
border-top-color: transparent;
border-left-color: transparent;
border-right-color: transparent;
margin-left: -5px;
bottom: 100%;
left: 50%;
}
.tip.arrow-bottom:before {
border-bottom-color: transparent;
border-left-color: transparent;
border-right-color: transparent;
margin-left: -5px;
top: 100%;
left: 50%;
}
/* Customizer Tooltip */
.customize-support .tip {
background-color: rgba(0, 148, 221, 0.95);
color: #FFF;
font-size: 13px;
line-height: 1.5em;
max-width: 200px;
padding: 5px 11px;
border: 1px solid #0094DD;
border-radius: 1px;
}
.customize-support .tip[class*="arrow"]:before {
border-width: 5px;
border-color: #0094DD;
border-color: rgba(0, 148, 221, 0.95);
}
.customize-support .tip.arrow-right:before {
border-right-color: transparent;
border-top-color: transparent;
border-bottom-color: transparent;
margin-top: -5px;
top: 50%;
left: 100%;
}
.customize-support .tip.arrow-left:before {
border-left-color: transparent;
border-top-color: transparent;
border-bottom-color: transparent;
margin-top: -5px;
top: 50%;
right: 100%;
}
.customize-support .tip.arrow-top:before {
border-top-color: transparent;
border-left-color: transparent;
border-right-color: transparent;
margin-left: -5px;
bottom: 100%;
left: 50%;
}
.customize-support .tip.arrow-bottom:before {
border-bottom-color: transparent;
border-left-color: transparent;
border-right-color: transparent;
margin-left: -5px;
top: 100%;
left: 50%;
}
/*---close button tooltip--------*/
.tip[class*="close-tip-content"]{
border-radius:7px;
max-width:300px;
padding: 15px 30px;
}
.tip[class*="close-tip-content"]:before{
border-width: 8px!important;
margin-top: -8px!important;
}
.tip[class*="close-tip-content"][class*="arrow-bottom"]{
/* margin-top:-10px; */
}
.tip[class*="close-tip-content"][class*="arrow-bottom"]:before{
margin-top: -1px!important;
}
.tip[class*="close-tip-content"][class*="arrow-right"]:before {
left: 100%;
left: calc(100% - 1px);
}
.cp-innertip.tip[class*="close-tip-content"][class*="arrow"]{
margin-top: 30px!important;
}
@media (max-width:768px) {
.tip[class*="close-tip-content"]{
border-radius:7px;
max-width:200px;
padding: 5px 20px;
}
}
@media (max-width:610px) {
.tip[class*="close-tip-content"]{
max-width:170px;
}
}
@@ -1,138 +1,138 @@
.bsf-core-license-form p {
padding: 5px 0px 5px 0px;
font-style: normal;
}
.license-form-allow-email .submit-button-wrap > input,
.license-form-allow-email .submit-button-wrap > p {
display: inline-block;
vertical-align: bottom;
}
.bsf-core-license-form .license-form-allow-email .purchase-license a {
text-decoration: none;
}
.license-form-allow-email {
margin-bottom: 15px;
}
.license-form-allow-email .license-form-external-links {
font-style: italic;
}
.license-form-field input {
width: 100%;
}
.bsf-core-license-form .license-form-allow-email h3 {
font-size: 2em;
margin-bottom: 0.5em;
}
.bsf-core-license-form .license-form-allow-email .purchase-license {
margin-left: 10px;
}
.bsf-core-license-form .license-form-allow-email .submit-button-wrap {
padding: 20px 0px 10px 0px;
}
.license-form-allow-email .bsf-core-license-form-inner, {
padding: 10px 30px 30px;
}
.bsf-core-license-form .bsf-core-license-form-overlay {
background: #000;
opacity: 0.7;
filter: alpha(opacity=70);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 100050;
}
.bsf-core-license-form .bsf-core-license-form-inner {
background: #fcfcfc;
position: fixed;
background-color: #fff;
z-index: 999999999;
padding: 2px 20px 20px;
text-align: left;
top: 50%;
left: 50%;
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
}
.bsf-core-license-form-close-btn {
position: absolute;
left: auto;
right: 0;
top: 0;
width: 29px;
height: 29px;
border: 0;
padding: 0;
background: none;
cursor: pointer;
outline: none;
-webkit-transition: color .1s ease-in-out, background .1s ease-in-out;
-webkit-transform: translateX(100%) translateY(-100%);
transform: translateX(100%) translateY(-100%);
transition: color .1s ease-in-out, background .1s ease-in-out;
color: #eee;
}
.bsf-core-license-form-close-btn:hover {
color: #00a0d2;
}
.bsf-core-license-form-close-btn .dashicons {
display: block;
text-align: center;
line-height: 29px;
width: 29px;
height: 29px;
font-size: 29px;
position: absolute;
top: 0;
right: 0;
}
.bsf-core-license-form .license-form-field input.regular-text {
margin-right: 10px;
}
/** License link */
.bsf-core-license-form-btn.inactive {
color: #3db634;
font-weight: 500;
}
.bsf-core-license-form-btn {
cursor: pointer;
}
.bsf-license-message.license-success {
display: none;
}
.bsf-system-info-wrapper {
overflow: scroll;
max-height: 60vh;
}
.bsf-license-heading {
margin: 1em 0;
}
.bsf-license-not-active-astra-portfolio.bsf-license-heading {
margin: 1em 0 0 0;
}
.envato-license-registration form {
margin-bottom: 1em;
.bsf-core-license-form p {
padding: 5px 0px 5px 0px;
font-style: normal;
}
.license-form-allow-email .submit-button-wrap > input,
.license-form-allow-email .submit-button-wrap > p {
display: inline-block;
vertical-align: bottom;
}
.bsf-core-license-form .license-form-allow-email .purchase-license a {
text-decoration: none;
}
.license-form-allow-email {
margin-bottom: 15px;
}
.license-form-allow-email .license-form-external-links {
font-style: italic;
}
.license-form-field input {
width: 100%;
}
.bsf-core-license-form .license-form-allow-email h3 {
font-size: 2em;
margin-bottom: 0.5em;
}
.bsf-core-license-form .license-form-allow-email .purchase-license {
margin-left: 10px;
}
.bsf-core-license-form .license-form-allow-email .submit-button-wrap {
padding: 20px 0px 10px 0px;
}
.license-form-allow-email .bsf-core-license-form-inner, {
padding: 10px 30px 30px;
}
.bsf-core-license-form .bsf-core-license-form-overlay {
background: #000;
opacity: 0.7;
filter: alpha(opacity=70);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 100050;
}
.bsf-core-license-form .bsf-core-license-form-inner {
background: #fcfcfc;
position: fixed;
background-color: #fff;
z-index: 999999999;
padding: 2px 20px 20px;
text-align: left;
top: 50%;
left: 50%;
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
}
.bsf-core-license-form-close-btn {
position: absolute;
left: auto;
right: 0;
top: 0;
width: 29px;
height: 29px;
border: 0;
padding: 0;
background: none;
cursor: pointer;
outline: none;
-webkit-transition: color .1s ease-in-out, background .1s ease-in-out;
-webkit-transform: translateX(100%) translateY(-100%);
transform: translateX(100%) translateY(-100%);
transition: color .1s ease-in-out, background .1s ease-in-out;
color: #eee;
}
.bsf-core-license-form-close-btn:hover {
color: #00a0d2;
}
.bsf-core-license-form-close-btn .dashicons {
display: block;
text-align: center;
line-height: 29px;
width: 29px;
height: 29px;
font-size: 29px;
position: absolute;
top: 0;
right: 0;
}
.bsf-core-license-form .license-form-field input.regular-text {
margin-right: 10px;
}
/** License link */
.bsf-core-license-form-btn.inactive {
color: #3db634;
font-weight: 500;
}
.bsf-core-license-form-btn {
cursor: pointer;
}
.bsf-license-message.license-success {
display: none;
}
.bsf-system-info-wrapper {
overflow: scroll;
max-height: 60vh;
}
.bsf-license-heading {
margin: 1em 0;
}
.bsf-license-not-active-astra-portfolio.bsf-license-heading {
margin: 1em 0 0 0;
}
.envato-license-registration form {
margin-bottom: 1em;
}
@@ -1,84 +1,84 @@
.bsf-core-rollback-overlay {
background: #000;
opacity: 0.7;
filter: alpha(opacity=70);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 100050;
}
.bsf-confirm-rollback-popup-content {
background: #fcfcfc;
position: fixed;
/* background-color: #fff; */
z-index: 999999999;
padding: 2px 20px 0px;
text-align: left;
top: 50%;
left: 50%;
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
border-radius: 2px;
}
.bsf-confirm-rollback-popup-buttons-wrapper .bsf-confirm-cancel{
padding: 0px 16px;
margin-right: 149px;
}
.bsf-confirm-text{
margin-bottom: 25px;
}
.bsf-confirm-rollback-popup-buttons-wrapper .bsf-confirm-ok{
margin-right: 0px;
padding: 0px 16px;
float: right;
}
.bsf-rollback-heading{
text-align: center;
}
.bsf-confirm-rollback-popup-header {
font-size: 15px;
color: #495157;
padding: 30px 0 10px;
font-weight: 500;
text-align: center;
}
.bsf-confirm-rollback-popup-message {
-webkit-box-sizing: border-box;
box-sizing: border-box;
min-height: 50px;
text-align: center;
}
.bsf-confirm-rollback-popup-buttons-wrapper {
border-top: 1px solid #e4e4e4;
width: 100%;
padding: 9px 0px 9px 0px
}
.bsf-confirm-rollback-popup-button {
font-family: Roboto, Arial, Helvetica, Verdana, sans-serif;
width: 50%;
border: none;
background: none;
color: #6d7882;
font-size: 15px;
cursor: pointer;
padding: 13px 0;
outline: 0;
}
.bsf-confirm-rollback-popup-button:hover {
background:#e6e9ec6b
}
.bsf-confirm-rollback-popup-button.confirm-cancel {
border-right: 1px solid #e6e9ec;
}
.bsf-confirm-rollback-popup-button.confirm-ok {
color: rgb(74, 0, 224);
}
.bsf-confirm-rollback-popup.show {
display: block;
.bsf-core-rollback-overlay {
background: #000;
opacity: 0.7;
filter: alpha(opacity=70);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 100050;
}
.bsf-confirm-rollback-popup-content {
background: #fcfcfc;
position: fixed;
/* background-color: #fff; */
z-index: 999999999;
padding: 2px 20px 0px;
text-align: left;
top: 50%;
left: 50%;
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
border-radius: 2px;
}
.bsf-confirm-rollback-popup-buttons-wrapper .bsf-confirm-cancel{
padding: 0px 16px;
margin-right: 149px;
}
.bsf-confirm-text{
margin-bottom: 25px;
}
.bsf-confirm-rollback-popup-buttons-wrapper .bsf-confirm-ok{
margin-right: 0px;
padding: 0px 16px;
float: right;
}
.bsf-rollback-heading{
text-align: center;
}
.bsf-confirm-rollback-popup-header {
font-size: 15px;
color: #495157;
padding: 30px 0 10px;
font-weight: 500;
text-align: center;
}
.bsf-confirm-rollback-popup-message {
-webkit-box-sizing: border-box;
box-sizing: border-box;
min-height: 50px;
text-align: center;
}
.bsf-confirm-rollback-popup-buttons-wrapper {
border-top: 1px solid #e4e4e4;
width: 100%;
padding: 9px 0px 9px 0px
}
.bsf-confirm-rollback-popup-button {
font-family: Roboto, Arial, Helvetica, Verdana, sans-serif;
width: 50%;
border: none;
background: none;
color: #6d7882;
font-size: 15px;
cursor: pointer;
padding: 13px 0;
outline: 0;
}
.bsf-confirm-rollback-popup-button:hover {
background:#e6e9ec6b
}
.bsf-confirm-rollback-popup-button.confirm-cancel {
border-right: 1px solid #e6e9ec;
}
.bsf-confirm-rollback-popup-button.confirm-ok {
color: rgb(74, 0, 224);
}
.bsf-confirm-rollback-popup.show {
display: block;
}
File diff suppressed because it is too large Load Diff
@@ -1,146 +1,146 @@
input.form-control.smile-switch.switch + label.bsf-switch-btn:before {
display: none;
}
input.form-control.smile-input.bsf-switch-input {
display: none;
}
.switch-wrapper {
width: 95px;
}
.shadow_type .onoffswitch-switch {
width: 45px;
}
.shadow_type .onoffswitch-inactive .onoffswitch-switch:before {
right: 45px;
}
.shadow_type .onoffswitch-active .onoffswitch-switch:before {
left: 45px;
}
.ios-toggle, .ios-toggle:active {
position:absolute;
top:-5000px;
height:0;
width:0;
opacity:0;
border:none;
outline:none;
}
.checkbox-label {
display:block;
position:relative;
padding:0px;
margin: 0px;
margin-bottom:20px;
font-size:12px;
line-height:16px;
width:40px;
height:20px;
-webkit-border-radius:18px;
-moz-border-radius:18px;
border-radius:18px;
background:#f8f8f8;
cursor:pointer;
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
.checkbox-label:before {
content:'';
display:block;
position:absolute;
z-index:1;
line-height:34px;
text-indent:40px;
height:20px;
width:20px;
-webkit-border-radius:100%;
-moz-border-radius:100%;
border-radius:100%;
top:0px;
left:0px;
right:auto;
background:white;
-webkit-box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
-moz-box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
.checkbox-label:after {
content: attr(data-off);
font-size: 13px;
display: block;
position: absolute;
z-index: 0;
top: 0;
left: 50px;
padding: 0;
height: 20px;
line-height: 20px;
width: 36px;
text-align: left;
color: #BFBFBF;
white-space: nowrap;
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
/* Switch CHECKBOX */
.switch-checkbox + .checkbox-label {
-webkit-box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
-moz-box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
background: #dddddd;
}
.switch-checkbox:checked + .checkbox-label {
-webkit-box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
-moz-box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
background: #0094DD;
}
.switch-checkbox:checked + .checkbox-label:after {
color:#0094DD;
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
/* Toggle Checkbox */
.ios-toggle:checked + .checkbox-label {
-webkit-box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
-moz-box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
}
.ios-toggle:checked + .checkbox-label:before {
left:calc(100% - 21px);
-webkit-box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
-moz-box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
.ios-toggle:checked + .checkbox-label:after {
content:attr(data-on);
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
.ios-toggle[type=checkbox] {
display: none;
}
.brainstorm-updater-switch {
display: inline-block;
position: absolute;
right: 0;
top: 0;
}
input.form-control.smile-switch.switch + label.bsf-switch-btn:before {
display: none;
}
input.form-control.smile-input.bsf-switch-input {
display: none;
}
.switch-wrapper {
width: 95px;
}
.shadow_type .onoffswitch-switch {
width: 45px;
}
.shadow_type .onoffswitch-inactive .onoffswitch-switch:before {
right: 45px;
}
.shadow_type .onoffswitch-active .onoffswitch-switch:before {
left: 45px;
}
.ios-toggle, .ios-toggle:active {
position:absolute;
top:-5000px;
height:0;
width:0;
opacity:0;
border:none;
outline:none;
}
.checkbox-label {
display:block;
position:relative;
padding:0px;
margin: 0px;
margin-bottom:20px;
font-size:12px;
line-height:16px;
width:40px;
height:20px;
-webkit-border-radius:18px;
-moz-border-radius:18px;
border-radius:18px;
background:#f8f8f8;
cursor:pointer;
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
.checkbox-label:before {
content:'';
display:block;
position:absolute;
z-index:1;
line-height:34px;
text-indent:40px;
height:20px;
width:20px;
-webkit-border-radius:100%;
-moz-border-radius:100%;
border-radius:100%;
top:0px;
left:0px;
right:auto;
background:white;
-webkit-box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
-moz-box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
.checkbox-label:after {
content: attr(data-off);
font-size: 13px;
display: block;
position: absolute;
z-index: 0;
top: 0;
left: 50px;
padding: 0;
height: 20px;
line-height: 20px;
width: 36px;
text-align: left;
color: #BFBFBF;
white-space: nowrap;
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
/* Switch CHECKBOX */
.switch-checkbox + .checkbox-label {
-webkit-box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
-moz-box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
background: #dddddd;
}
.switch-checkbox:checked + .checkbox-label {
-webkit-box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
-moz-box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
background: #0094DD;
}
.switch-checkbox:checked + .checkbox-label:after {
color:#0094DD;
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
/* Toggle Checkbox */
.ios-toggle:checked + .checkbox-label {
-webkit-box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
-moz-box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
}
.ios-toggle:checked + .checkbox-label:before {
left:calc(100% - 21px);
-webkit-box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
-moz-box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
.ios-toggle:checked + .checkbox-label:after {
content:attr(data-on);
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
.ios-toggle[type=checkbox] {
display: none;
}
.brainstorm-updater-switch {
display: inline-block;
position: absolute;
right: 0;
top: 0;
}
@@ -1,11 +1,11 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Generated by IcoMoon</metadata>
<defs>
<font id="icomoon" horiz-adv-x="1024">
<font-face units-per-em="1024" ascent="960" descent="-64" />
<missing-glyph horiz-adv-x="1024" />
<glyph unicode="&#x20;" d="" horiz-adv-x="512" />
<glyph unicode="&#xe603;" d="M467.577-21.5c-2.284 7.369-0.104 15.762 7.18 20.556 10.155 6.679 25.5 20.586 84.534 27.952 35.525 4.396-8.694-54.877-3.142-34.181 1.955 7.287-25.91 1.952-25.91 1.952s-46.553-8.773-58.643-24.894c0 0-1.733 2.227-4.019 8.615zM138.271 557.027c0 0 15.887 237.492 368.384 222.11 0 0 146.319-12.099 215.165-56.96 0 0-293.96 10.546-583.551-165.149zM181.807 507.887c0 0 203.521 128.399 558.772 144.239 0 0 48.21-0.329 72.158-35.208 0 0 14.367-31.64 14.086-88.5 0 0-48.229-1.442-85.408-2.723 0 0-355.977-11.586-537.674-199.511 12.648 44.529-121.089 119.532-21.934 181.703zM255.72 238.57c0 0-14.079 43.451 43.498 69.493 54.329 24.572 127.831 96.191 426.625 133.305 0 0 124.558 25.427 48.884-54.439-84.28-88.948-100.337-111.947-100.337-111.947s-22.41-25.55-14.155 5.204c8.255 30.756-120.967 22.15-120.967 22.15s-201.788-45.676-252.733-113.604c0 0-21.178 22.924-30.816 49.839zM369.409 146.887c0 0 106.32 73.825 227.492 55.88 0 0 29.174-1.921-1.115-22.419-30.29-20.503-226.376-33.461-226.376-33.461zM418.719 53.659c0 0-11.482 30.506 7.413 36.941s36.903 30.834 136.907 41.988c40.619-4.038 1.169-110.607-7.296-79.135 2.763 10.295-10.126 9.762-10.126 9.762s-93.985-18.303-111.035-41.039c0 0-12.635 22.476-15.862 31.483zM899.013 687.749c92.851-208.867-26.868-487.037-271.661-536.994 233.968 65.7 273.711 363.944 218.284 497.451-81.853 197.157-343.286 268.698-505.34 206.428-162.056-62.269-203.018-122.175-238.522-224.811 32.087 89.126 91.171 209.056 273.127 278.972 181.958 69.917 431.262-12.179 524.112-221.047z" />
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Generated by IcoMoon</metadata>
<defs>
<font id="icomoon" horiz-adv-x="1024">
<font-face units-per-em="1024" ascent="960" descent="-64" />
<missing-glyph horiz-adv-x="1024" />
<glyph unicode="&#x20;" d="" horiz-adv-x="512" />
<glyph unicode="&#xe603;" d="M467.577-21.5c-2.284 7.369-0.104 15.762 7.18 20.556 10.155 6.679 25.5 20.586 84.534 27.952 35.525 4.396-8.694-54.877-3.142-34.181 1.955 7.287-25.91 1.952-25.91 1.952s-46.553-8.773-58.643-24.894c0 0-1.733 2.227-4.019 8.615zM138.271 557.027c0 0 15.887 237.492 368.384 222.11 0 0 146.319-12.099 215.165-56.96 0 0-293.96 10.546-583.551-165.149zM181.807 507.887c0 0 203.521 128.399 558.772 144.239 0 0 48.21-0.329 72.158-35.208 0 0 14.367-31.64 14.086-88.5 0 0-48.229-1.442-85.408-2.723 0 0-355.977-11.586-537.674-199.511 12.648 44.529-121.089 119.532-21.934 181.703zM255.72 238.57c0 0-14.079 43.451 43.498 69.493 54.329 24.572 127.831 96.191 426.625 133.305 0 0 124.558 25.427 48.884-54.439-84.28-88.948-100.337-111.947-100.337-111.947s-22.41-25.55-14.155 5.204c8.255 30.756-120.967 22.15-120.967 22.15s-201.788-45.676-252.733-113.604c0 0-21.178 22.924-30.816 49.839zM369.409 146.887c0 0 106.32 73.825 227.492 55.88 0 0 29.174-1.921-1.115-22.419-30.29-20.503-226.376-33.461-226.376-33.461zM418.719 53.659c0 0-11.482 30.506 7.413 36.941s36.903 30.834 136.907 41.988c40.619-4.038 1.169-110.607-7.296-79.135 2.763 10.295-10.126 9.762-10.126 9.762s-93.985-18.303-111.035-41.039c0 0-12.635 22.476-15.862 31.483zM899.013 687.749c92.851-208.867-26.868-487.037-271.661-536.994 233.968 65.7 273.711 363.944 218.284 497.451-81.853 197.157-343.286 268.698-505.34 206.428-162.056-62.269-203.018-122.175-238.522-224.811 32.087 89.126 91.171 209.056 273.127 278.972 181.958 69.917 431.262-12.179 524.112-221.047z" />
</font></defs></svg>

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

@@ -1,32 +1,32 @@
jQuery( document ).on('click', '.bsf-envato-form-activation', function(event) {
submitButton = jQuery( this ).parent('.submit-button-wrap');
console.log(submitButton);
product_id = submitButton.siblings( 'form input[name="product_id"]' ).val();
url = submitButton.siblings( 'form input[name="url"]' ).val();
redirect = submitButton.siblings( 'form input[name="redirect"]' ).val();
privacyConsent = submitButton.siblings( 'input#bsf-license-privacy-consent').val();
termsConditionConsent = submitButton.siblings( 'input#bsf-license-terms-conditions-consent').val();
envato_activation_nonce = bsf_core.envato_activation_nonce;
jQuery.ajax({
url: ajaxurl,
dataType: 'json',
data: {
action: 'bsf_envato_redirect_url',
product_id: product_id,
url: url,
redirect: redirect,
privacy_consent: privacyConsent,
terms_conditions_consent: termsConditionConsent,
envato_activation_nonce: envato_activation_nonce,
}
})
.done(function( response ) {
window.location = response.data.url;
return true;
})
.fail(function(e) {
return false;
});
return false;
jQuery( document ).on('click', '.bsf-envato-form-activation', function(event) {
submitButton = jQuery( this ).parent('.submit-button-wrap');
console.log(submitButton);
product_id = submitButton.siblings( 'form input[name="product_id"]' ).val();
url = submitButton.siblings( 'form input[name="url"]' ).val();
redirect = submitButton.siblings( 'form input[name="redirect"]' ).val();
privacyConsent = submitButton.siblings( 'input#bsf-license-privacy-consent').val();
termsConditionConsent = submitButton.siblings( 'input#bsf-license-terms-conditions-consent').val();
envato_activation_nonce = bsf_core.envato_activation_nonce;
jQuery.ajax({
url: ajaxurl,
dataType: 'json',
data: {
action: 'bsf_envato_redirect_url',
product_id: product_id,
url: url,
redirect: redirect,
privacy_consent: privacyConsent,
terms_conditions_consent: termsConditionConsent,
envato_activation_nonce: envato_activation_nonce,
}
})
.done(function( response ) {
window.location = response.data.url;
return true;
})
.fail(function(e) {
return false;
});
return false;
});
@@ -1,105 +1,105 @@
(function ($) {
var BSFExtensionInstaller = {
init: function () {
$(document).on('click', '.bsf-install-button', BSFExtensionInstaller._installNow);
$( document ).on('wp-plugin-installing' , BSFExtensionInstaller._pluginInstalling);
$( document ).on('wp-plugin-install-error' , BSFExtensionInstaller._installError);
$( document ).on('wp-plugin-install-success' , BSFExtensionInstaller._installSuccess);
},
/**
* Install Now
*/
_installNow: function (event) {
event.preventDefault();
var $button = jQuery(event.target),
$document = jQuery(document);
if ( $button.hasClass('updating-message') || $button.hasClass('button-disabled') ) {
return;
}
if (wp.updates.shouldRequestFilesystemCredentials && !wp.updates.ajaxLocked) {
wp.updates.requestFilesystemCredentials(event);
$document.on('credential-modal-cancel', function () {
var $message = $('.install-now.updating-message');
$message
.removeClass('updating-message')
.text(wp.updates.l10n.installNow);
wp.a11y.speak(wp.updates.l10n.updateCancel, 'polite');
});
}
wp.updates.installPlugin({
slug: $button.data('slug')
});
},
/**
* Install Success
*/
_installSuccess: function( event, response ) {
event.preventDefault();
// Transform the 'Install' button into an 'Activate' button.
var $init = $( '.bsf-extension-' + response.slug ).data('init');
var nonce = $( '#bsf_activate_extension_nonce' ).val();
// WordPress adds "Activate" button after waiting for 1000ms. So we will run our activation after that.
setTimeout( function() {
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
'action' : 'bsf-extention-activate',
'init' : $init,
'security' : nonce
},
})
.done(function (result) {
if( result.success ) {
$ext = $('.bsf-extension-' + response.slug );
$ext.addClass('bsf-plugin-installed');
$ext.find('.bsf-install-button').addClass('bsf-plugin-installed-button').html('Installed <i class="dashicons dashicons-yes"></i>');
$ext.find('.bsf-extension-start-install').removeClass('show-install');
}
});
}, 1200 );
},
/**
* Plugin Installation Error.
*/
_installError: function( event, response ) {
var $card = $( '.bsf-extension-' + response.slug + ' .bsf-extension-start-install-content')
$card.html( '<h2>' + response.errorMessage + '</h2>' );
},
/**
* Installing Plugin
*/
_pluginInstalling: function(event, args) {
event.preventDefault();
$('.bsf-extension-' + args.slug + ' .bsf-extension-start-install').addClass('show-install');
},
}
/**
* Initialize BSFExtensionInstaller
*/
$(function () {
BSFExtensionInstaller.init();
});
(function ($) {
var BSFExtensionInstaller = {
init: function () {
$(document).on('click', '.bsf-install-button', BSFExtensionInstaller._installNow);
$( document ).on('wp-plugin-installing' , BSFExtensionInstaller._pluginInstalling);
$( document ).on('wp-plugin-install-error' , BSFExtensionInstaller._installError);
$( document ).on('wp-plugin-install-success' , BSFExtensionInstaller._installSuccess);
},
/**
* Install Now
*/
_installNow: function (event) {
event.preventDefault();
var $button = jQuery(event.target),
$document = jQuery(document);
if ( $button.hasClass('updating-message') || $button.hasClass('button-disabled') ) {
return;
}
if (wp.updates.shouldRequestFilesystemCredentials && !wp.updates.ajaxLocked) {
wp.updates.requestFilesystemCredentials(event);
$document.on('credential-modal-cancel', function () {
var $message = $('.install-now.updating-message');
$message
.removeClass('updating-message')
.text(wp.updates.l10n.installNow);
wp.a11y.speak(wp.updates.l10n.updateCancel, 'polite');
});
}
wp.updates.installPlugin({
slug: $button.data('slug')
});
},
/**
* Install Success
*/
_installSuccess: function( event, response ) {
event.preventDefault();
// Transform the 'Install' button into an 'Activate' button.
var $init = $( '.bsf-extension-' + response.slug ).data('init');
var nonce = $( '#bsf_activate_extension_nonce' ).val();
// WordPress adds "Activate" button after waiting for 1000ms. So we will run our activation after that.
setTimeout( function() {
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
'action' : 'bsf-extention-activate',
'init' : $init,
'security' : nonce
},
})
.done(function (result) {
if( result.success ) {
$ext = $('.bsf-extension-' + response.slug );
$ext.addClass('bsf-plugin-installed');
$ext.find('.bsf-install-button').addClass('bsf-plugin-installed-button').html('Installed <i class="dashicons dashicons-yes"></i>');
$ext.find('.bsf-extension-start-install').removeClass('show-install');
}
});
}, 1200 );
},
/**
* Plugin Installation Error.
*/
_installError: function( event, response ) {
var $card = $( '.bsf-extension-' + response.slug + ' .bsf-extension-start-install-content')
$card.html( '<h2>' + response.errorMessage + '</h2>' );
},
/**
* Installing Plugin
*/
_pluginInstalling: function(event, args) {
event.preventDefault();
$('.bsf-extension-' + args.slug + ' .bsf-extension-start-install').addClass('show-install');
},
}
/**
* Initialize BSFExtensionInstaller
*/
$(function () {
BSFExtensionInstaller.init();
});
})(jQuery);
@@ -1,263 +1,263 @@
/* ========================================================================
* Frosty.js v1.0
* https://github.com/owensbla/frosty
* http://labs.blakeowens.com/frosty
*
* Plugin boilerplate provied by: http://jqueryboilerplate.com/
* ========================================================================
* Copyright 2013 Blake Owens
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ======================================================================== */
;(function ($, window, document, undefined) {
var pluginName = "frosty";
var defaults = {
attribute: 'title',
className: 'tip',
content: '',
delay: 0,
hasArrow: true,
html: false,
offset: 30,
position: 'left',
removeTitle: true,
selector: false,
trigger: 'hover,focus',
onHidden: function() {},
onShown: function() {},
};
function Frosty(anchor, options) {
this.anchor = anchor;
this.$anchor = $(anchor);
this.options = $.extend({}, defaults, options, this.$anchor.data());
this._defaults = defaults;
this._name = pluginName;
this.init();
}
Frosty.prototype = {
init: function () {
this._createTip();
this._bindEvents();
},
show: function() {
var _this = this,
delay = typeof this.options.delay === 'object' ? parseInt(this.options.delay.show) : parseInt(this.options.delay);
clearTimeout(this.timeout);
this.timeout = delay === 0 ?
this._setState('visible') :
setTimeout(function() { _this._setState('visible'); }, delay);
},
hide: function() {
var _this = this
delay = typeof this.options.delay === 'object' ? parseInt(this.options.delay.hide) : parseInt(this.options.delay);
clearTimeout(this.timeout);
this.timeout = delay === 0 ?
this._setState('hidden') :
setTimeout(function() { _this._setState('hidden'); }, delay);
},
toggle: function() {
this.state === 'visible' ? this.hide() : this.show();
},
addClass: function(klass) {
console.log("in");
if (typeof klass === 'string') { this.$el.addClass(klass); }
},
removeClass: function(klass) {
if (typeof klass === 'string') { this.$el.removeClass(klass); }
},
_setState: function(state) {
this.state = state;
switch (state) {
case 'visible':
this.$el.appendTo('body');
this._checkContent();
this._setPosition();
this.options.onShown.call(this);
this.$anchor.trigger('shown');
break;
case 'hidden':
this.$el.detach();
this.options.onHidden.call(this);
this.$anchor.trigger('hidden');
break;
}
},
_checkContent: function() {
if (this.options.selector) {
this.tipContent = $(this.options.selector).html();
this.$el.html(this.tipContent);
}
},
_createTip: function() {
if (this.options.html) {
this.tipContent = this.options.content;
} else if (this.options.selector) {
this.tipContent = $(this.options.selector).html();
} else {
this.tipContent = this.$anchor.attr(this.options.attribute);
if (this.options.attribute === 'title' && this.options.removeTitle) {
this.$anchor.attr('data-original-title', this.tipContent);
this.$anchor.removeAttr('title');
}
}
this.$el = $('<div />', {
'class': this.options.className,
html: '<span class="cp_tooltip_text">'+this.tipContent+'</span>'
}).css({
'z-index': '9999999999',
'left': '-9999px',
'position': 'absolute',
});
this.$el.appendTo('body');
var coords = this.getPosition();
this.$el.detach().css(coords);
if (this.options.hasArrow) { this._addArrowClass(); }
},
_addArrowClass: function() {
switch (this.options.position) {
case 'left':
this.$el.addClass('arrow-right');
break;
case 'right':
this.$el.addClass('arrow-left');
break;
case 'bottom':
this.$el.addClass('arrow-top');
break;
default:
this.$el.addClass('arrow-bottom');
}
},
_bindEvents: function() {
switch (this.options.trigger) {
case 'click':
this.$anchor.click($.proxy(this.toggle, this));
break
case 'manual':
break;
case 'focus':
this.$anchor.focus($.proxy(this.show, this));
this.$anchor.blur($.proxy(this.hide, this));
break;
default:
this.$anchor.hover($.proxy(this.show, this), $.proxy(this.hide, this));
}
//$(window).resize($.proxy(this._setPosition, this));
},
getPosition: function () {
var coords = this.$anchor.offset();
switch (this.options.position) {
case 'left':
coords.left = coords.left - this.$el.outerWidth() - this.options.offset;
coords.top = coords.top + (this.$anchor.outerHeight() / 2) - (this.$el.outerHeight() / 2);
break;
case 'right':
coords.left = coords.left + this.$anchor.outerWidth() + this.options.offset;
coords.top = coords.top + (this.$anchor.outerHeight() / 2) - (this.$el.outerHeight() / 2);
break;
case 'bottom':
coords.top = coords.top + this.$anchor.outerHeight() + this.options.offset;
coords.left = coords.left + (this.$anchor.outerWidth() / 2) - (this.$el.outerWidth() / 2);
break;
default:
coords.top = coords.top - this.$el.outerHeight() - this.options.offset;
var left = coords.left + (this.$anchor.outerWidth() / 2) - (this.$el.outerWidth() / 2);
if( left < 0 )
left = 0;
coords.left = left;
}
//console.log(coords);
return coords;
},
_setPosition: function() {
this.$el.css(this.getPosition());
}
};
$.fn[pluginName] = function (options, args) {
//console.log($.data(this, "plugin_" + pluginName));
if (typeof options === 'string') {
//console.log(options);
switch (options) {
case 'show':
this.each(function() { $.data(this, "plugin_" + pluginName)['show'](); });
break;
case 'hide':
this.each(function() { $.data(this, "plugin_" + pluginName)['hide'](); });
break;
case 'toggle':
this.each(function() { $.data(this, "plugin_" + pluginName)['toggle'](); });
break;
case 'addClass':
this.each(function() { $.data(this, "plugin_" + pluginName)['addClass'](args); });
break;
case 'removeClass':
this.each(function() { $.data(this, "plugin_" + pluginName)['removeClass'](args); });
break;
}
}
return this.each(function () {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName, new Frosty(this, options));
}
});
};
})(jQuery, window, document);
(function($){
$(document).ready(function(){
$('.bsf-has-tip, .has-tip').each(function(i,tip){
$tip = $(tip);
var attribute = (typeof $tip.attr('data-attribute') != 'undefined') ? $tip.attr('data-attribute') : 'title';
var offset = (typeof $tip.attr('data-offset') != 'undefined') ? $tip.attr('data-offset') : 10;
var position = (typeof $tip.attr('data-position') != 'undefined') ? $tip.attr('data-position') : 'top';
var trigger = (typeof $tip.attr('data-trigger')) ? $tip.attr('data-trigger') : 'hover,focus';
var className = (typeof $tip.attr('data-classes') != 'undefined') ? 'tip '+$tip.attr('data-classes') : 'tip';
$tip.frosty({
className : className,
attribute: attribute,
offset: offset,
position: position,
trigger: trigger
});
});
});
})(jQuery);
/* ========================================================================
* Frosty.js v1.0
* https://github.com/owensbla/frosty
* http://labs.blakeowens.com/frosty
*
* Plugin boilerplate provied by: http://jqueryboilerplate.com/
* ========================================================================
* Copyright 2013 Blake Owens
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ======================================================================== */
;(function ($, window, document, undefined) {
var pluginName = "frosty";
var defaults = {
attribute: 'title',
className: 'tip',
content: '',
delay: 0,
hasArrow: true,
html: false,
offset: 30,
position: 'left',
removeTitle: true,
selector: false,
trigger: 'hover,focus',
onHidden: function() {},
onShown: function() {},
};
function Frosty(anchor, options) {
this.anchor = anchor;
this.$anchor = $(anchor);
this.options = $.extend({}, defaults, options, this.$anchor.data());
this._defaults = defaults;
this._name = pluginName;
this.init();
}
Frosty.prototype = {
init: function () {
this._createTip();
this._bindEvents();
},
show: function() {
var _this = this,
delay = typeof this.options.delay === 'object' ? parseInt(this.options.delay.show) : parseInt(this.options.delay);
clearTimeout(this.timeout);
this.timeout = delay === 0 ?
this._setState('visible') :
setTimeout(function() { _this._setState('visible'); }, delay);
},
hide: function() {
var _this = this
delay = typeof this.options.delay === 'object' ? parseInt(this.options.delay.hide) : parseInt(this.options.delay);
clearTimeout(this.timeout);
this.timeout = delay === 0 ?
this._setState('hidden') :
setTimeout(function() { _this._setState('hidden'); }, delay);
},
toggle: function() {
this.state === 'visible' ? this.hide() : this.show();
},
addClass: function(klass) {
console.log("in");
if (typeof klass === 'string') { this.$el.addClass(klass); }
},
removeClass: function(klass) {
if (typeof klass === 'string') { this.$el.removeClass(klass); }
},
_setState: function(state) {
this.state = state;
switch (state) {
case 'visible':
this.$el.appendTo('body');
this._checkContent();
this._setPosition();
this.options.onShown.call(this);
this.$anchor.trigger('shown');
break;
case 'hidden':
this.$el.detach();
this.options.onHidden.call(this);
this.$anchor.trigger('hidden');
break;
}
},
_checkContent: function() {
if (this.options.selector) {
this.tipContent = $(this.options.selector).html();
this.$el.html(this.tipContent);
}
},
_createTip: function() {
if (this.options.html) {
this.tipContent = this.options.content;
} else if (this.options.selector) {
this.tipContent = $(this.options.selector).html();
} else {
this.tipContent = this.$anchor.attr(this.options.attribute);
if (this.options.attribute === 'title' && this.options.removeTitle) {
this.$anchor.attr('data-original-title', this.tipContent);
this.$anchor.removeAttr('title');
}
}
this.$el = $('<div />', {
'class': this.options.className,
html: '<span class="cp_tooltip_text">'+this.tipContent+'</span>'
}).css({
'z-index': '9999999999',
'left': '-9999px',
'position': 'absolute',
});
this.$el.appendTo('body');
var coords = this.getPosition();
this.$el.detach().css(coords);
if (this.options.hasArrow) { this._addArrowClass(); }
},
_addArrowClass: function() {
switch (this.options.position) {
case 'left':
this.$el.addClass('arrow-right');
break;
case 'right':
this.$el.addClass('arrow-left');
break;
case 'bottom':
this.$el.addClass('arrow-top');
break;
default:
this.$el.addClass('arrow-bottom');
}
},
_bindEvents: function() {
switch (this.options.trigger) {
case 'click':
this.$anchor.click($.proxy(this.toggle, this));
break
case 'manual':
break;
case 'focus':
this.$anchor.focus($.proxy(this.show, this));
this.$anchor.blur($.proxy(this.hide, this));
break;
default:
this.$anchor.hover($.proxy(this.show, this), $.proxy(this.hide, this));
}
//$(window).resize($.proxy(this._setPosition, this));
},
getPosition: function () {
var coords = this.$anchor.offset();
switch (this.options.position) {
case 'left':
coords.left = coords.left - this.$el.outerWidth() - this.options.offset;
coords.top = coords.top + (this.$anchor.outerHeight() / 2) - (this.$el.outerHeight() / 2);
break;
case 'right':
coords.left = coords.left + this.$anchor.outerWidth() + this.options.offset;
coords.top = coords.top + (this.$anchor.outerHeight() / 2) - (this.$el.outerHeight() / 2);
break;
case 'bottom':
coords.top = coords.top + this.$anchor.outerHeight() + this.options.offset;
coords.left = coords.left + (this.$anchor.outerWidth() / 2) - (this.$el.outerWidth() / 2);
break;
default:
coords.top = coords.top - this.$el.outerHeight() - this.options.offset;
var left = coords.left + (this.$anchor.outerWidth() / 2) - (this.$el.outerWidth() / 2);
if( left < 0 )
left = 0;
coords.left = left;
}
//console.log(coords);
return coords;
},
_setPosition: function() {
this.$el.css(this.getPosition());
}
};
$.fn[pluginName] = function (options, args) {
//console.log($.data(this, "plugin_" + pluginName));
if (typeof options === 'string') {
//console.log(options);
switch (options) {
case 'show':
this.each(function() { $.data(this, "plugin_" + pluginName)['show'](); });
break;
case 'hide':
this.each(function() { $.data(this, "plugin_" + pluginName)['hide'](); });
break;
case 'toggle':
this.each(function() { $.data(this, "plugin_" + pluginName)['toggle'](); });
break;
case 'addClass':
this.each(function() { $.data(this, "plugin_" + pluginName)['addClass'](args); });
break;
case 'removeClass':
this.each(function() { $.data(this, "plugin_" + pluginName)['removeClass'](args); });
break;
}
}
return this.each(function () {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName, new Frosty(this, options));
}
});
};
})(jQuery, window, document);
(function($){
$(document).ready(function(){
$('.bsf-has-tip, .has-tip').each(function(i,tip){
$tip = $(tip);
var attribute = (typeof $tip.attr('data-attribute') != 'undefined') ? $tip.attr('data-attribute') : 'title';
var offset = (typeof $tip.attr('data-offset') != 'undefined') ? $tip.attr('data-offset') : 10;
var position = (typeof $tip.attr('data-position') != 'undefined') ? $tip.attr('data-position') : 'top';
var trigger = (typeof $tip.attr('data-trigger')) ? $tip.attr('data-trigger') : 'hover,focus';
var className = (typeof $tip.attr('data-classes') != 'undefined') ? 'tip '+$tip.attr('data-classes') : 'tip';
$tip.frosty({
className : className,
attribute: attribute,
offset: offset,
position: position,
trigger: trigger
});
});
});
})(jQuery);
@@ -1,151 +1,151 @@
(function($){
BSFCoreLicenseForm = {
/**
* Init
*/
init: function()
{
this._showFormOnLoad();
this._bind();
},
/**
* Binds events
*/
_bind: function()
{
$( document ).on('click', '.bsf-core-license-form-btn', BSFCoreLicenseForm._showFormOnClick);
$( document ).on('click', '.bsf-core-license-form-close-btn', BSFCoreLicenseForm._closeForm);
$( document ).on('click', '.bsf-core-license-form .bsf-core-license-form-overlay', BSFCoreLicenseForm._closeForm);
},
_changeURL: function( url )
{
History.pushState(null, null, url);
},
/**
* Show form on Load
*/
_showFormOnLoad: function( e )
{
if( BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
var slug = BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form');
BSFCoreLicenseForm._showForm( slug );
}
},
/**
* Show form on Click
*/
_showFormOnClick: function( e )
{
// don't override click action if the link is not from the popup form.
var licenseFormURl = $( this ).attr('href') || '';
if ( null !== BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form', licenseFormURl) ||
true === $( this ).hasClass('bsf-core-plugin-link') ) {
e.preventDefault();
var slug = $( this ).attr('plugin-slug') || '';
var url_params = {'bsf-inline-license-form':slug};
BSFCoreLicenseForm._showForm( slug );
// Change URL.
if( ! BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
var current_url = window.location.href;
var current_url_separator = ( window.location.href.indexOf( "?" ) === -1 ) ? "?" : "&";
var new_url = current_url + current_url_separator + decodeURIComponent( $.param( url_params ) );
BSFCoreLicenseForm._changeURL( new_url );
}
}
},
/**
* Show form by slug
*/
_showForm: function( slug )
{
if( $(".bsf-core-license-form[plugin-slug='"+slug+"']").length ) {
$(".bsf-core-license-form[plugin-slug='"+slug+"']").show();
$('body').addClass('bsf-core-license-form-open');
}
},
/**
* Close form.
*/
_closeForm: function( e )
{
e.preventDefault();
$('.bsf-core-license-form').hide();
$('body').removeClass('bsf-core-license-form-open');
if( BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
var url_params = BSFCoreLicenseForm._getQueryStrings();
delete url_params['bsf-inline-license-form'];
delete url_params['bsf-inline-license-form'];
delete url_params['license_action'];
delete url_params['token'];
delete url_params['product_id'];
delete url_params['purchase_key'];
delete url_params['success'];
delete url_params['status'];
delete url_params['message'];
delete url_params['debug'];
delete url_params['activation_method'];
var current_url = window.location.href;
var root_url = current_url.substr(0, current_url.indexOf('?'));
if( jQuery.isEmptyObject( url_params ) ) {
var new_url = root_url + decodeURIComponent( $.param( url_params ) );
} else {
var current_url_separator = ( root_url.indexOf( "?" ) === -1 ) ? "?" : "&";
var new_url = root_url + current_url_separator + decodeURIComponent( $.param( url_params ) );
}
// Change URL.
BSFCoreLicenseForm._changeURL( new_url );
}
},
/**
* Get URL param.
*/
_getParamFromURL: function(name, url)
{
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
},
/**
* Get query strings.
*/
_getQueryStrings( str )
{
return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
}
};
/**
* Initialization
*/
$(function(){
BSFCoreLicenseForm.init();
});
(function($){
BSFCoreLicenseForm = {
/**
* Init
*/
init: function()
{
this._showFormOnLoad();
this._bind();
},
/**
* Binds events
*/
_bind: function()
{
$( document ).on('click', '.bsf-core-license-form-btn', BSFCoreLicenseForm._showFormOnClick);
$( document ).on('click', '.bsf-core-license-form-close-btn', BSFCoreLicenseForm._closeForm);
$( document ).on('click', '.bsf-core-license-form .bsf-core-license-form-overlay', BSFCoreLicenseForm._closeForm);
},
_changeURL: function( url )
{
History.pushState(null, null, url);
},
/**
* Show form on Load
*/
_showFormOnLoad: function( e )
{
if( BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
var slug = BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form');
BSFCoreLicenseForm._showForm( slug );
}
},
/**
* Show form on Click
*/
_showFormOnClick: function( e )
{
// don't override click action if the link is not from the popup form.
var licenseFormURl = $( this ).attr('href') || '';
if ( null !== BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form', licenseFormURl) ||
true === $( this ).hasClass('bsf-core-plugin-link') ) {
e.preventDefault();
var slug = $( this ).attr('plugin-slug') || '';
var url_params = {'bsf-inline-license-form':slug};
BSFCoreLicenseForm._showForm( slug );
// Change URL.
if( ! BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
var current_url = window.location.href;
var current_url_separator = ( window.location.href.indexOf( "?" ) === -1 ) ? "?" : "&";
var new_url = current_url + current_url_separator + decodeURIComponent( $.param( url_params ) );
BSFCoreLicenseForm._changeURL( new_url );
}
}
},
/**
* Show form by slug
*/
_showForm: function( slug )
{
if( $(".bsf-core-license-form[plugin-slug='"+slug+"']").length ) {
$(".bsf-core-license-form[plugin-slug='"+slug+"']").show();
$('body').addClass('bsf-core-license-form-open');
}
},
/**
* Close form.
*/
_closeForm: function( e )
{
e.preventDefault();
$('.bsf-core-license-form').hide();
$('body').removeClass('bsf-core-license-form-open');
if( BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
var url_params = BSFCoreLicenseForm._getQueryStrings();
delete url_params['bsf-inline-license-form'];
delete url_params['bsf-inline-license-form'];
delete url_params['license_action'];
delete url_params['token'];
delete url_params['product_id'];
delete url_params['purchase_key'];
delete url_params['success'];
delete url_params['status'];
delete url_params['message'];
delete url_params['debug'];
delete url_params['activation_method'];
var current_url = window.location.href;
var root_url = current_url.substr(0, current_url.indexOf('?'));
if( jQuery.isEmptyObject( url_params ) ) {
var new_url = root_url + decodeURIComponent( $.param( url_params ) );
} else {
var current_url_separator = ( root_url.indexOf( "?" ) === -1 ) ? "?" : "&";
var new_url = root_url + current_url_separator + decodeURIComponent( $.param( url_params ) );
}
// Change URL.
BSFCoreLicenseForm._changeURL( new_url );
}
},
/**
* Get URL param.
*/
_getParamFromURL: function(name, url)
{
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
},
/**
* Get query strings.
*/
_getQueryStrings( str )
{
return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
}
};
/**
* Initialization
*/
$(function(){
BSFCoreLicenseForm.init();
});
})(jQuery);
@@ -1,16 +1,16 @@
jQuery(document).ready(function(){
var switch_btn = jQuery(".bsf-switch-btn");
jQuery(document).on('click', '.bsf-switch-btn', function(e){
var id = jQuery(this).data('id');
var value = jQuery(this).parents(".switch-wrapper").find("#"+id).val();
if( value == 1 || value == '1' ) {
jQuery(this).parents(".switch-wrapper").find("#"+id).attr('value','0');
} else {
jQuery(this).parents(".switch-wrapper").find("#"+id).attr('value','1');
}
jQuery(this).parents(".switch-wrapper").find(".bsf-switch-input").trigger('change');
});
jQuery(document).ready(function(){
var switch_btn = jQuery(".bsf-switch-btn");
jQuery(document).on('click', '.bsf-switch-btn', function(e){
var id = jQuery(this).data('id');
var value = jQuery(this).parents(".switch-wrapper").find("#"+id).val();
if( value == 1 || value == '1' ) {
jQuery(this).parents(".switch-wrapper").find("#"+id).attr('value','0');
} else {
jQuery(this).parents(".switch-wrapper").find("#"+id).attr('value','1');
}
jQuery(this).parents(".switch-wrapper").find(".bsf-switch-input").trigger('change');
});
});
@@ -1,61 +1,61 @@
(function($){
var currentRollbackButton;
rollbackVersion = {
init: function() {
$( document ).on('change', '.bsf-rollback-version-select' , rollbackVersion.onSelectVersion );
$( document ).on('click', '.bsf-rollback-button' , rollbackVersion.onRollbackClick );
$( document ).on('click', '.bsf-confirm-cancel' , rollbackVersion.closeRollbackPopup );
$( document ).on('click', '.bsf-confirm-ok' , rollbackVersion.onRollbackOk );
},
onSelectVersion:function() {
var selectRollback = jQuery( this );
rollbackButton = selectRollback.next( '.bsf-rollback-button' )
placeholderText = rollbackButton.data( 'placeholder-text' );
placeholderUrl = rollbackButton.data( 'placeholder-url' );
rollbackButton.attr( 'href', placeholderUrl.replace( 'VERSION', selectRollback.val() ) );
},
onRollbackClick: function ( e ) {
e.preventDefault();
var rollbackButton = jQuery( this );
// This will update the current rollback button object.
currentRollbackButton = rollbackButton;
rollbackHeading = $('.bsf-confirm-heading');
rollbackConfirmText = $('.bsf-rollback-text');
closestDiv = rollbackButton.closest('.bsf-rollback-version');
versionNumber = closestDiv.find('.bsf-rollback-version-select').val();
selectProductName = closestDiv.find('#bsf-product-name').val();
// Rollback Heading text.
rollbackHeadingdata = rollbackHeading.data('text').replace( '#PRODUCT_NAME#', selectProductName );
rollbackHeading.html( rollbackHeadingdata );
// Rollback Confirmation text.
rollbackConfirmdata = rollbackConfirmText.data('text').replace( '#PRODUCT_NAME#', selectProductName );
rollbackConfirmdata = rollbackConfirmdata.replace( '#VERSION#', versionNumber )
rollbackConfirmText.html( rollbackConfirmdata );
document.querySelector('.bsf-confirm-rollback-popup').style.display = 'block';
},
closeRollbackPopup: function ( e ) {
document.querySelector('.bsf-confirm-rollback-popup').style.display = 'none';
},
onRollbackOk:function ( e ) {
e.preventDefault();
if( currentRollbackButton ){
var redirectUrl = currentRollbackButton.closest('.bsf-rollback-version').find('.bsf-rollback-button').attr('href');
location.href = redirectUrl;
}
rollbackVersion.closeRollbackPopup( e );
}
}
$( document ).ready(function() {
rollbackVersion.init();
});
})( jQuery );
(function($){
var currentRollbackButton;
rollbackVersion = {
init: function() {
$( document ).on('change', '.bsf-rollback-version-select' , rollbackVersion.onSelectVersion );
$( document ).on('click', '.bsf-rollback-button' , rollbackVersion.onRollbackClick );
$( document ).on('click', '.bsf-confirm-cancel' , rollbackVersion.closeRollbackPopup );
$( document ).on('click', '.bsf-confirm-ok' , rollbackVersion.onRollbackOk );
},
onSelectVersion:function() {
var selectRollback = jQuery( this );
rollbackButton = selectRollback.next( '.bsf-rollback-button' )
placeholderText = rollbackButton.data( 'placeholder-text' );
placeholderUrl = rollbackButton.data( 'placeholder-url' );
rollbackButton.attr( 'href', placeholderUrl.replace( 'VERSION', selectRollback.val() ) );
},
onRollbackClick: function ( e ) {
e.preventDefault();
var rollbackButton = jQuery( this );
// This will update the current rollback button object.
currentRollbackButton = rollbackButton;
rollbackHeading = $('.bsf-confirm-heading');
rollbackConfirmText = $('.bsf-rollback-text');
closestDiv = rollbackButton.closest('.bsf-rollback-version');
versionNumber = closestDiv.find('.bsf-rollback-version-select').val();
selectProductName = closestDiv.find('#bsf-product-name').val();
// Rollback Heading text.
rollbackHeadingdata = rollbackHeading.data('text').replace( '#PRODUCT_NAME#', selectProductName );
rollbackHeading.html( rollbackHeadingdata );
// Rollback Confirmation text.
rollbackConfirmdata = rollbackConfirmText.data('text').replace( '#PRODUCT_NAME#', selectProductName );
rollbackConfirmdata = rollbackConfirmdata.replace( '#VERSION#', versionNumber )
rollbackConfirmText.html( rollbackConfirmdata );
document.querySelector('.bsf-confirm-rollback-popup').style.display = 'block';
},
closeRollbackPopup: function ( e ) {
document.querySelector('.bsf-confirm-rollback-popup').style.display = 'none';
},
onRollbackOk:function ( e ) {
e.preventDefault();
if( currentRollbackButton ){
var redirectUrl = currentRollbackButton.closest('.bsf-rollback-version').find('.bsf-rollback-button').attr('href');
location.href = redirectUrl;
}
rollbackVersion.closeRollbackPopup( e );
}
}
$( document ).ready(function() {
rollbackVersion.init();
});
})( jQuery );
@@ -1,413 +1,413 @@
<?php
/**
* Admin functions.
*
* @package BSF core
*/
if ( ! function_exists( 'bsf_generate_rand_token' ) ) {
/**
* Generate 32 characters random token.
*
* @return string
*/
function bsf_generate_rand_token() {
$valid_characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
$token = '';
$length = 32;
for ( $n = 1; $n < $length; $n++ ) {
$which_character = wp_rand( 0, strlen( $valid_characters ) - 1 );
$token .= $valid_characters[ $which_character ];
}
return $token;
}
}
/**
* Update version numbers of all the brainstorm products in options `brainstorm_products` and `brainstrom_bundled_products`
*
* @todo Current version numbers can be fetched from WordPress at runtime whenever ruquired,
* Remote version can only be required when transient for update data is deleted (i hope)
*/
if ( ! function_exists( 'bsf_update_all_product_version' ) ) {
/**
* Updates all product versions.
*
* @return void
*/
function bsf_update_all_product_version() {
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
$bsf_product_themes = array();
if ( ! empty( $brainstrom_products ) ) :
$bsf_product_plugins = ( isset( $brainstrom_products['plugins'] ) ) ? $brainstrom_products['plugins'] : array();
$bsf_product_themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
endif;
$bundled_product_updated = false;
if ( ! empty( $bsf_product_plugins ) ) {
foreach ( $bsf_product_plugins as $key => $plugin ) {
if ( ! isset( $plugin['id'] ) || empty( $plugin['id'] ) ) {
continue;
}
if ( ! isset( $plugin['template'] ) || empty( $plugin['template'] ) ) {
continue;
}
if ( ! isset( $plugin['type'] ) || empty( $plugin['type'] ) ) {
continue;
}
$version = ( isset( $plugin['version'] ) ) ? $plugin['version'] : '';
$current_version = bsf_get_current_version( $plugin['template'], $plugin['type'] );
$name = bsf_get_current_name( $plugin['template'], $plugin['type'] );
if ( '' !== $name ) {
$brainstrom_products['plugins'][ $key ]['product_name'] = $name;
}
if ( '' !== $current_version ) {
if ( version_compare( $version, $current_version ) === - 1 || 1 === version_compare( $version, $current_version ) ) {
$brainstrom_products['plugins'][ $key ]['version'] = $current_version;
}
}
}
}
if ( ! empty( $bsf_product_themes ) ) {
foreach ( $bsf_product_themes as $key => $theme ) {
if ( ! isset( $theme['id'] ) || empty( $theme['id'] ) ) {
continue;
}
if ( ! isset( $theme['template'] ) || empty( $theme['template'] ) ) {
continue;
}
if ( ! isset( $theme['type'] ) || empty( $theme['type'] ) ) {
continue;
}
$version = ( isset( $theme['version'] ) ) ? $theme['version'] : '';
$current_version = bsf_get_current_version( $theme['template'], $theme['type'] );
$name = bsf_get_current_name( $theme['template'], $theme['type'] );
if ( '' !== $name ) {
$brainstrom_products['themes'][ $key ]['product_name'] = $name;
}
if ( '' !== $current_version || false !== $current_version ) {
if ( version_compare( $version, $current_version ) === - 1 || 1 === version_compare( $version, $current_version ) ) {
$brainstrom_products['themes'][ $key ]['version'] = $current_version;
}
}
}
}
if ( ! empty( $brainstrom_bundled_products ) ) {
foreach ( $brainstrom_bundled_products as $keys => $bps ) {
$version = '';
if ( strlen( $keys ) > 1 ) {
foreach ( $bps as $key => $bp ) {
if ( ! isset( $bp->id ) || '' === $bp->id ) {
continue;
}
$version = $bp->version;
$current_version = bsf_get_current_version( $bp->init, $bp->type );
if ( '' !== $current_version && false !== $current_version ) {
if ( 1 === - version_compare( $version, $current_version ) || 1 === version_compare( $version, $current_version ) ) {
if ( is_object( $brainstrom_bundled_products ) ) {
$brainstrom_bundled_products = array( $brainstrom_bundled_products );
}
$single_bp = $brainstrom_bundled_products[ $keys ];
$single_bp[ $key ]->version = $current_version;
$bundled_product_updated = true;
$brainstrom_bundled_products[ $keys ] = $single_bp;
}
}
}
} else {
if ( ! isset( $bps->id ) || '' === $bps->id ) {
continue;
}
$version = $bps->version;
$current_version = bsf_get_current_version( $bps->init, $bps->type );
if ( '' !== $current_version || false !== $current_version ) {
if ( - 1 === version_compare( $version, $current_version ) || 1 === version_compare( $version, $current_version ) ) {
$brainstrom_bundled_products[ $keys ]->version = $current_version;
$bundled_product_updated = true;
}
}
}
}
}
update_option( 'brainstrom_products', $brainstrom_products );
if ( $bundled_product_updated ) {
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
}
}
}
add_action( 'admin_init', 'bsf_update_all_product_version', 1000 );
if ( ! function_exists( 'bsf_get_current_version' ) ) {
/**
* Get current version of plugin / theme.
*
* @param string $template plugin template/slug.
* @param string $type type of product.
*
* @return float
*/
function bsf_get_current_version( $template, $type ) {
if ( '' === $template ) {
return false;
}
if ( 'theme' === $type || 'themes' === $type ) {
$theme = wp_get_theme( $template );
$version = $theme->get( 'Version' );
} elseif ( 'plugin' === $type || 'plugins' === $type ) {
$plugin_file = rtrim( WP_PLUGIN_DIR, '/' ) . '/' . $template;
if ( ! is_file( $plugin_file ) ) {
return false;
}
$plugin = get_plugin_data( $plugin_file );
$version = $plugin['Version'];
}
return $version;
}
}
if ( ! function_exists( 'bsf_get_current_name' ) ) {
/**
* Get name of plugin / theme.
*
* @param string $template plugin template/slug.
* @param string $type type of product.
* @return string
*/
function bsf_get_current_name( $template, $type ) {
if ( '' === $template ) {
return false;
}
if ( 'theme' === $type || 'themes' === $type ) {
$theme = wp_get_theme( $template );
$name = $theme->get( 'Name' );
} elseif ( 'plugin' === $type || 'plugins' === $type ) {
$plugin_file = rtrim( WP_PLUGIN_DIR, '/' ) . '/' . $template;
if ( ! is_file( $plugin_file ) ) {
return false;
}
$plugin = get_plugin_data( $plugin_file );
$name = $plugin['Name'];
}
return $name;
}
}
add_action( 'admin_notices', 'bsf_notices', 1000 );
add_action( 'network_admin_notices', 'bsf_notices', 1000 );
if ( ! function_exists( 'bsf_notices' ) ) {
/**
* Display admin notices.
*
* @return bool
*/
function bsf_notices() {
global $pagenow;
if ( 'update-core.php' === $pagenow || 'plugins.php' === $pagenow || 'post-new.php' === $pagenow || 'edit.php' === $pagenow || 'post.php' === $pagenow ) {
$brainstrom_products = get_option( 'brainstrom_products' );
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
if ( empty( $brainstrom_products ) ) {
return false;
}
$brainstrom_bundled_products_keys = array();
if ( ! empty( $brainstrom_bundled_products ) ) :
foreach ( $brainstrom_bundled_products as $bps ) {
foreach ( $bps as $key => $bp ) {
array_push( $brainstrom_bundled_products_keys, $bp->id );
}
}
endif;
$mix = array();
$plugins = ( isset( $brainstrom_products['plugins'] ) ) ? $brainstrom_products['plugins'] : array();
$themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
$mix = array_merge( $plugins, $themes );
if ( empty( $mix ) ) {
return false;
}
if ( ( defined( 'BSF_PRODUCTS_NOTICES' ) && ( 'false' === BSF_PRODUCTS_NOTICES || false === BSF_PRODUCTS_NOTICES ) ) ) {
return false;
}
$is_multisite = is_multisite();
$is_network_admin = is_network_admin();
foreach ( $mix as $product ) :
if ( ! isset( $product['id'] ) ) {
continue;
}
if ( false === apply_filters( "bsf_display_product_activation_notice_{$product['id']}", true ) ) {
continue;
}
if ( isset( $product['is_product_free'] ) && ( 'true' === $product['is_product_free'] || true === $product['is_product_free'] ) ) {
continue;
}
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
$constant_nag = 'BSF_' . $constant . '_NAG';
$constant_notice = 'BSF_' . $constant . '_NOTICES';
if ( defined( $constant_nag ) && ( 'false' === constant( $constant_nag ) || false === constant( $constant_nag ) ) ) {
continue;
}
if ( defined( $constant_notice ) && ( 'false' === constant( $constant_notice ) || false === constant( $constant_notice ) ) ) {
continue;
}
$status = ( isset( $product['status'] ) ) ? $product['status'] : false;
$type = ( isset( $product['type'] ) ) ? $product['type'] : false;
if ( ! $type ) {
continue;
}
if ( 'plugin' === $type ) {
if ( ! is_plugin_active( $product['template'] ) ) {
continue;
}
} elseif ( 'theme' === $type ) {
$theme = wp_get_theme();
if ( $product['template'] !== $theme->template ) {
continue;
}
} else {
continue;
}
if ( BSF_Update_Manager::bsf_is_product_bundled( $product['id'] ) ) {
continue;
}
if ( 'registered' !== $status ) :
$url = bsf_registration_page_url( '', $product['id'] );
$message = __( 'Please', 'bsf' ) . ' <a href="' . esc_url( $url ) . '" class="bsf-core-license-form-btn" plugin-slug="' . esc_html( $product['id'] ) . '">' . __( 'activate', 'bsf' ) . '</a> ' . __( 'your copy of the', 'bsf' ) . ' <i>' . esc_html( $product['product_name'] ) . '</i> ' . __( 'to get update notifications, access to support features & other resources!', 'bsf' );
$message = apply_filters( "bsf_product_activation_notice_{$product['id']}", $message, $url, $product['product_name'] );
$allowed_html = array(
'a' => array(
'href' => array(),
'class' => array(),
'title' => array(),
'plugin-slug' => array(),
),
'br' => array(),
'em' => array(),
'strong' => array(),
'i' => array(),
);
if ( ( $is_multisite && $is_network_admin ) || ! $is_multisite ) {
echo '<div class="notice notice-warning"><p>' . wp_kses( $message, $allowed_html ) . '</p></div>';
}
endif;
endforeach;
}
}
}
// delete bundled products after switch theme.
if ( ! function_exists( 'bsf_theme_deactivation' ) ) {
/**
* Delete transients while switching theme.
*
* @return void
*/
function bsf_theme_deactivation() {
update_option( 'bsf_force_check_extensions', false );
}
}
add_action( 'switch_theme', 'bsf_theme_deactivation' );
add_action( 'deactivated_plugin', 'bsf_theme_deactivation' );
if ( ! function_exists( 'bsf_get_free_menu_position' ) ) {
/**
* Get free theme position.
*
* @param int $start menu position priority index.
* @param float $increment increment number for menu position.
* @return int
*/
function bsf_get_free_menu_position( $start, $increment = 0.3 ) {
foreach ( $GLOBALS['menu'] as $key => $menu ) {
$menus_positions[] = $key;
}
if ( ! in_array( $start, $menus_positions, true ) ) {
return $start;
}
/* the position is already reserved find the closet one */
while ( in_array( $start, $menus_positions, true ) ) {
$start += $increment;
}
return $start;
}
}
if ( ! function_exists( 'bsf_get_option' ) ) {
/**
* Get free theme position.
*
* @param bool $request return complete option data OR a single variable.
* @return array
*/
function bsf_get_option( $request = false ) {
$bsf_options = get_option( 'bsf_options' );
if ( ! $request ) {
return $bsf_options;
} else {
return ( isset( $bsf_options[ $request ] ) ) ? $bsf_options[ $request ] : false;
}
}
}
if ( ! function_exists( 'bsf_update_option' ) ) {
/**
* Update bsf option with key and value.
*
* @param string $request variable key.
* @param string $value variable value.
* @return bool
*/
function bsf_update_option( $request, $value ) {
$bsf_options = get_option( 'bsf_options' );
$bsf_options[ $request ] = $value;
return update_option( 'bsf_options', $bsf_options );
}
}
if ( ! function_exists( 'bsf_sort' ) ) {
/**
* Sort array of objects.
*
* @param string $a The first string.
* @param string $b The second string.
* @return int
*/
function bsf_sort( $a, $b ) {
return strcmp( strtolower( $a->short_name ), strtolower( $b->short_name ) );
}
}
<?php
/**
* Admin functions.
*
* @package BSF core
*/
if ( ! function_exists( 'bsf_generate_rand_token' ) ) {
/**
* Generate 32 characters random token.
*
* @return string
*/
function bsf_generate_rand_token() {
$valid_characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
$token = '';
$length = 32;
for ( $n = 1; $n < $length; $n++ ) {
$which_character = wp_rand( 0, strlen( $valid_characters ) - 1 );
$token .= $valid_characters[ $which_character ];
}
return $token;
}
}
/**
* Update version numbers of all the brainstorm products in options `brainstorm_products` and `brainstrom_bundled_products`
*
* @todo Current version numbers can be fetched from WordPress at runtime whenever ruquired,
* Remote version can only be required when transient for update data is deleted (i hope)
*/
if ( ! function_exists( 'bsf_update_all_product_version' ) ) {
/**
* Updates all product versions.
*
* @return void
*/
function bsf_update_all_product_version() {
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
$bsf_product_themes = array();
if ( ! empty( $brainstrom_products ) ) :
$bsf_product_plugins = ( isset( $brainstrom_products['plugins'] ) ) ? $brainstrom_products['plugins'] : array();
$bsf_product_themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
endif;
$bundled_product_updated = false;
if ( ! empty( $bsf_product_plugins ) ) {
foreach ( $bsf_product_plugins as $key => $plugin ) {
if ( ! isset( $plugin['id'] ) || empty( $plugin['id'] ) ) {
continue;
}
if ( ! isset( $plugin['template'] ) || empty( $plugin['template'] ) ) {
continue;
}
if ( ! isset( $plugin['type'] ) || empty( $plugin['type'] ) ) {
continue;
}
$version = ( isset( $plugin['version'] ) ) ? $plugin['version'] : '';
$current_version = bsf_get_current_version( $plugin['template'], $plugin['type'] );
$name = bsf_get_current_name( $plugin['template'], $plugin['type'] );
if ( '' !== $name ) {
$brainstrom_products['plugins'][ $key ]['product_name'] = $name;
}
if ( '' !== $current_version ) {
if ( version_compare( $version, $current_version ) === - 1 || 1 === version_compare( $version, $current_version ) ) {
$brainstrom_products['plugins'][ $key ]['version'] = $current_version;
}
}
}
}
if ( ! empty( $bsf_product_themes ) ) {
foreach ( $bsf_product_themes as $key => $theme ) {
if ( ! isset( $theme['id'] ) || empty( $theme['id'] ) ) {
continue;
}
if ( ! isset( $theme['template'] ) || empty( $theme['template'] ) ) {
continue;
}
if ( ! isset( $theme['type'] ) || empty( $theme['type'] ) ) {
continue;
}
$version = ( isset( $theme['version'] ) ) ? $theme['version'] : '';
$current_version = bsf_get_current_version( $theme['template'], $theme['type'] );
$name = bsf_get_current_name( $theme['template'], $theme['type'] );
if ( '' !== $name ) {
$brainstrom_products['themes'][ $key ]['product_name'] = $name;
}
if ( '' !== $current_version || false !== $current_version ) {
if ( version_compare( $version, $current_version ) === - 1 || 1 === version_compare( $version, $current_version ) ) {
$brainstrom_products['themes'][ $key ]['version'] = $current_version;
}
}
}
}
if ( ! empty( $brainstrom_bundled_products ) ) {
foreach ( $brainstrom_bundled_products as $keys => $bps ) {
$version = '';
if ( strlen( $keys ) > 1 ) {
foreach ( $bps as $key => $bp ) {
if ( ! isset( $bp->id ) || '' === $bp->id ) {
continue;
}
$version = $bp->version;
$current_version = bsf_get_current_version( $bp->init, $bp->type );
if ( '' !== $current_version && false !== $current_version ) {
if ( 1 === - version_compare( $version, $current_version ) || 1 === version_compare( $version, $current_version ) ) {
if ( is_object( $brainstrom_bundled_products ) ) {
$brainstrom_bundled_products = array( $brainstrom_bundled_products );
}
$single_bp = $brainstrom_bundled_products[ $keys ];
$single_bp[ $key ]->version = $current_version;
$bundled_product_updated = true;
$brainstrom_bundled_products[ $keys ] = $single_bp;
}
}
}
} else {
if ( ! isset( $bps->id ) || '' === $bps->id ) {
continue;
}
$version = $bps->version;
$current_version = bsf_get_current_version( $bps->init, $bps->type );
if ( '' !== $current_version || false !== $current_version ) {
if ( - 1 === version_compare( $version, $current_version ) || 1 === version_compare( $version, $current_version ) ) {
$brainstrom_bundled_products[ $keys ]->version = $current_version;
$bundled_product_updated = true;
}
}
}
}
}
update_option( 'brainstrom_products', $brainstrom_products );
if ( $bundled_product_updated ) {
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
}
}
}
add_action( 'admin_init', 'bsf_update_all_product_version', 1000 );
if ( ! function_exists( 'bsf_get_current_version' ) ) {
/**
* Get current version of plugin / theme.
*
* @param string $template plugin template/slug.
* @param string $type type of product.
*
* @return float
*/
function bsf_get_current_version( $template, $type ) {
if ( '' === $template ) {
return false;
}
if ( 'theme' === $type || 'themes' === $type ) {
$theme = wp_get_theme( $template );
$version = $theme->get( 'Version' );
} elseif ( 'plugin' === $type || 'plugins' === $type ) {
$plugin_file = rtrim( WP_PLUGIN_DIR, '/' ) . '/' . $template;
if ( ! is_file( $plugin_file ) ) {
return false;
}
$plugin = get_plugin_data( $plugin_file );
$version = $plugin['Version'];
}
return $version;
}
}
if ( ! function_exists( 'bsf_get_current_name' ) ) {
/**
* Get name of plugin / theme.
*
* @param string $template plugin template/slug.
* @param string $type type of product.
* @return string
*/
function bsf_get_current_name( $template, $type ) {
if ( '' === $template ) {
return false;
}
if ( 'theme' === $type || 'themes' === $type ) {
$theme = wp_get_theme( $template );
$name = $theme->get( 'Name' );
} elseif ( 'plugin' === $type || 'plugins' === $type ) {
$plugin_file = rtrim( WP_PLUGIN_DIR, '/' ) . '/' . $template;
if ( ! is_file( $plugin_file ) ) {
return false;
}
$plugin = get_plugin_data( $plugin_file );
$name = $plugin['Name'];
}
return $name;
}
}
add_action( 'admin_notices', 'bsf_notices', 1000 );
add_action( 'network_admin_notices', 'bsf_notices', 1000 );
if ( ! function_exists( 'bsf_notices' ) ) {
/**
* Display admin notices.
*
* @return bool
*/
function bsf_notices() {
global $pagenow;
if ( 'update-core.php' === $pagenow || 'plugins.php' === $pagenow || 'post-new.php' === $pagenow || 'edit.php' === $pagenow || 'post.php' === $pagenow ) {
$brainstrom_products = get_option( 'brainstrom_products' );
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
if ( empty( $brainstrom_products ) ) {
return false;
}
$brainstrom_bundled_products_keys = array();
if ( ! empty( $brainstrom_bundled_products ) ) :
foreach ( $brainstrom_bundled_products as $bps ) {
foreach ( $bps as $key => $bp ) {
array_push( $brainstrom_bundled_products_keys, $bp->id );
}
}
endif;
$mix = array();
$plugins = ( isset( $brainstrom_products['plugins'] ) ) ? $brainstrom_products['plugins'] : array();
$themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
$mix = array_merge( $plugins, $themes );
if ( empty( $mix ) ) {
return false;
}
if ( ( defined( 'BSF_PRODUCTS_NOTICES' ) && ( 'false' === BSF_PRODUCTS_NOTICES || false === BSF_PRODUCTS_NOTICES ) ) ) {
return false;
}
$is_multisite = is_multisite();
$is_network_admin = is_network_admin();
foreach ( $mix as $product ) :
if ( ! isset( $product['id'] ) ) {
continue;
}
if ( false === apply_filters( "bsf_display_product_activation_notice_{$product['id']}", true ) ) {
continue;
}
if ( isset( $product['is_product_free'] ) && ( 'true' === $product['is_product_free'] || true === $product['is_product_free'] ) ) {
continue;
}
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
$constant_nag = 'BSF_' . $constant . '_NAG';
$constant_notice = 'BSF_' . $constant . '_NOTICES';
if ( defined( $constant_nag ) && ( 'false' === constant( $constant_nag ) || false === constant( $constant_nag ) ) ) {
continue;
}
if ( defined( $constant_notice ) && ( 'false' === constant( $constant_notice ) || false === constant( $constant_notice ) ) ) {
continue;
}
$status = ( isset( $product['status'] ) ) ? $product['status'] : false;
$type = ( isset( $product['type'] ) ) ? $product['type'] : false;
if ( ! $type ) {
continue;
}
if ( 'plugin' === $type ) {
if ( ! is_plugin_active( $product['template'] ) ) {
continue;
}
} elseif ( 'theme' === $type ) {
$theme = wp_get_theme();
if ( $product['template'] !== $theme->template ) {
continue;
}
} else {
continue;
}
if ( BSF_Update_Manager::bsf_is_product_bundled( $product['id'] ) ) {
continue;
}
if ( 'registered' !== $status ) :
$url = bsf_registration_page_url( '', $product['id'] );
$message = __( 'Please', 'bsf' ) . ' <a href="' . esc_url( $url ) . '" class="bsf-core-license-form-btn" plugin-slug="' . esc_html( $product['id'] ) . '">' . __( 'activate', 'bsf' ) . '</a> ' . __( 'your copy of the', 'bsf' ) . ' <i>' . esc_html( $product['product_name'] ) . '</i> ' . __( 'to get update notifications, access to support features & other resources!', 'bsf' );
$message = apply_filters( "bsf_product_activation_notice_{$product['id']}", $message, $url, $product['product_name'] );
$allowed_html = array(
'a' => array(
'href' => array(),
'class' => array(),
'title' => array(),
'plugin-slug' => array(),
),
'br' => array(),
'em' => array(),
'strong' => array(),
'i' => array(),
);
if ( ( $is_multisite && $is_network_admin ) || ! $is_multisite ) {
echo '<div class="notice notice-warning"><p>' . wp_kses( $message, $allowed_html ) . '</p></div>';
}
endif;
endforeach;
}
}
}
// delete bundled products after switch theme.
if ( ! function_exists( 'bsf_theme_deactivation' ) ) {
/**
* Delete transients while switching theme.
*
* @return void
*/
function bsf_theme_deactivation() {
update_option( 'bsf_force_check_extensions', false );
}
}
add_action( 'switch_theme', 'bsf_theme_deactivation' );
add_action( 'deactivated_plugin', 'bsf_theme_deactivation' );
if ( ! function_exists( 'bsf_get_free_menu_position' ) ) {
/**
* Get free theme position.
*
* @param int $start menu position priority index.
* @param float $increment increment number for menu position.
* @return int
*/
function bsf_get_free_menu_position( $start, $increment = 0.3 ) {
foreach ( $GLOBALS['menu'] as $key => $menu ) {
$menus_positions[] = $key;
}
if ( ! in_array( $start, $menus_positions, true ) ) {
return $start;
}
/* the position is already reserved find the closet one */
while ( in_array( $start, $menus_positions, true ) ) {
$start += $increment;
}
return $start;
}
}
if ( ! function_exists( 'bsf_get_option' ) ) {
/**
* Get free theme position.
*
* @param bool $request return complete option data OR a single variable.
* @return array
*/
function bsf_get_option( $request = false ) {
$bsf_options = get_option( 'bsf_options' );
if ( ! $request ) {
return $bsf_options;
} else {
return ( isset( $bsf_options[ $request ] ) ) ? $bsf_options[ $request ] : false;
}
}
}
if ( ! function_exists( 'bsf_update_option' ) ) {
/**
* Update bsf option with key and value.
*
* @param string $request variable key.
* @param string $value variable value.
* @return bool
*/
function bsf_update_option( $request, $value ) {
$bsf_options = get_option( 'bsf_options' );
$bsf_options[ $request ] = $value;
return update_option( 'bsf_options', $bsf_options );
}
}
if ( ! function_exists( 'bsf_sort' ) ) {
/**
* Sort array of objects.
*
* @param string $a The first string.
* @param string $b The second string.
* @return int
*/
function bsf_sort( $a, $b ) {
return strcmp( strtolower( $a->short_name ), strtolower( $b->short_name ) );
}
}
@@ -1,239 +1,239 @@
<?php
/**
* Product update functions.
*
* @package BSF core
*/
// Alternative function for wp_remote_get.
if ( ! function_exists( 'bsf_get_remote_version' ) ) {
/**
* Get remote version for product
*
* @param array $product_list products data.
* @param array $products products data (deprecated).
* @return array
*/
function bsf_get_remote_version( $product_list, $products ) {
global $ultimate_referer;
$path = bsf_get_api_url() . '?referer=' . $ultimate_referer;
$data = array(
'action' => 'bsf_get_product_versions',
'ids' => $products,
'products' => $product_list,
'site_url' => get_site_url(),
'php_version' => bsf_get_php_version(),
'wp_version' => get_bloginfo( 'version' ),
'locale' => get_locale(),
'bsf_core_version' => BSF_UPDATER_VERSION,
'active_theme' => get_template(),
'active_stylesheet' => get_stylesheet(),
'php_max_input_vars' => ini_get( 'max_input_vars' ), // phpcs:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound
'php_post_max_size' => ini_get( 'post_max_size' ),
'php_max_execution_time' => ini_get( 'max_execution_time' ),
'php_memory_limit' => ini_get( 'memory_limit' ),
);
$request = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '10',
)
);
// Request http URL if the https version fails.
if ( is_wp_error( $request ) && 200 !== wp_remote_retrieve_response_code( $request ) ) {
$path = bsf_get_api_url( true ) . '?referer=' . $ultimate_referer;
$request = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '8',
)
);
}
if ( ! is_wp_error( $request ) || 200 === wp_remote_retrieve_response_code( $request ) ) {
$result = json_decode( wp_remote_retrieve_body( $request ) );
if ( ! empty( $result ) ) {
if ( empty( $result->error ) ) {
return $result->updated_versions;
} else {
return $result->error;
}
}
}
}
}
if ( ! function_exists( 'bsf_check_product_update' ) ) {
/**
* Check product updates.
*
* @return void
*/
function bsf_check_product_update() {
$is_update = true;
$registered = array(); // This list will be deprecated in favor of $product_list.
$product_list = array();
$all_products = brainstorm_get_all_products( false, false, true );
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
foreach ( $all_products as $key => $product ) {
if ( ! isset( $product['id'] ) ) {
continue;
}
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
$constant = 'BSF_' . $constant . '_CHECK_UPDATES';
if ( defined( $constant ) && ( 'false' === constant( $constant ) || false === constant( $constant ) ) ) {
continue;
}
$registered[] = $product['id'];
$product_list[ $product['id'] ] = array(
'id' => $product['id'],
'installed_version' => $product['version'],
);
// Add bundled products to the list.
if ( isset( $brainstrom_bundled_products[ $product['id'] ] ) ) {
$bundled_products = $brainstrom_bundled_products[ $product['id'] ];
$bundled_product_data = array();
foreach ( $bundled_products as $bundled_product ) {
$bundled_product_data[ $bundled_product->id ] = array(
'id' => $bundled_product->id,
'installed_version' => $bundled_product->version,
);
}
$product_list[ $product['id'] ]['bundled_products'] = $bundled_product_data;
}
}
$remote_versions = bsf_get_remote_version( $product_list, $registered );
$bsf_product_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$bsf_product_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
if ( false !== $remote_versions ) {
if ( ! empty( $remote_versions ) ) {
$is_bundled_update = false;
foreach ( $remote_versions as $rkey => $remote_data ) {
$rid = ( isset( $remote_data->id ) ) ? (string) $remote_data->id : '';
$remote_version = ( isset( $remote_data->remote_version ) ) ? $remote_data->remote_version : '';
$in_house = ( isset( $remote_data->in_house ) ) ? $remote_data->in_house : '';
$on_market = ( isset( $remote_data->on_market ) ) ? $remote_data->on_market : '';
$is_product_free = ( isset( $remote_data->is_product_free ) ) ? $remote_data->is_product_free : '';
$short_name = ( isset( $remote_data->short_name ) ) ? $remote_data->short_name : '';
$changelog_url = ( isset( $remote_data->changelog_url ) ) ? $remote_data->changelog_url : '';
$purchase_url = ( isset( $remote_data->purchase_url ) ) ? $remote_data->purchase_url : '';
$version_beta = ( isset( $remote_data->version_beta ) ) ? $remote_data->version_beta : '';
$download_url = ( isset( $remote_data->download_url ) ) ? $remote_data->download_url : '';
$download_url_beta = ( isset( $remote_data->download_url_beta ) ) ? $remote_data->download_url_beta : '';
$tested_upto = ( isset( $remote_data->tested ) ) ? $remote_data->tested : '';
foreach ( $bsf_product_plugins as $key => $plugin ) {
if ( ! isset( $plugin['id'] ) ) {
continue;
}
$pid = (string) $plugin['id'];
if ( $pid === $rid ) {
$brainstrom_products['plugins'][ $key ]['remote'] = $remote_version;
$brainstrom_products['plugins'][ $key ]['in_house'] = $in_house;
$brainstrom_products['plugins'][ $key ]['on_market'] = $on_market;
$brainstrom_products['plugins'][ $key ]['is_product_free'] = $is_product_free;
$brainstrom_products['plugins'][ $key ]['short_name'] = $short_name;
$brainstrom_products['plugins'][ $key ]['changelog_url'] = $changelog_url;
$brainstrom_products['plugins'][ $key ]['purchase_url'] = $purchase_url;
$brainstrom_products['plugins'][ $key ]['version_beta'] = $version_beta;
$brainstrom_products['plugins'][ $key ]['download_url_beta'] = $download_url_beta;
$brainstrom_products['plugins'][ $key ]['download_url'] = $download_url;
$brainstrom_products['plugins'][ $key ]['tested'] = $tested_upto;
// Deregister status for plugin.
if ( isset( $remote_data->status ) && 0 === $remote_data->status ) {
$brainstrom_products['plugins'][ $key ]['status'] = 'not-registered';
} else {
$brainstrom_products['plugins'][ $key ]['status'] = 'registered';
}
$is_update = true;
}
}
foreach ( $bsf_product_themes as $key => $theme ) {
if ( ! isset( $theme['id'] ) ) {
continue;
}
$pid = $theme['id'];
if ( $pid === $rid ) {
$brainstrom_products['themes'][ $key ]['remote'] = $remote_version;
$brainstrom_products['themes'][ $key ]['in_house'] = $in_house;
$brainstrom_products['themes'][ $key ]['on_market'] = $on_market;
$brainstrom_products['themes'][ $key ]['is_product_free'] = $is_product_free;
$brainstrom_products['themes'][ $key ]['short_name'] = $short_name;
$brainstrom_products['themes'][ $key ]['changelog_url'] = $changelog_url;
$brainstrom_products['themes'][ $key ]['purchase_url'] = $purchase_url;
$brainstrom_products['themes'][ $key ]['version_beta'] = $version_beta;
$brainstrom_products['themes'][ $key ]['download_url'] = $download_url;
$brainstrom_products['themes'][ $key ]['download_url_beta'] = $download_url_beta;
$is_update = true;
// Deregister status for theme.
if ( isset( $remote_data->status ) && 0 === $remote_data->status ) {
$brainstrom_products['themes'][ $key ]['status'] = 'not-registered';
} else {
$brainstrom_products['themes'][ $key ]['status'] = 'registered';
}
}
}
if ( isset( $remote_data->bundled_products ) && ! empty( $remote_data->bundled_products ) ) {
if ( ! empty( $brainstrom_bundled_products ) && is_array( $brainstrom_bundled_products ) ) {
foreach ( $brainstrom_bundled_products as $bkeys => $bps ) {
foreach ( $bps as $bkey => $bp ) {
if ( ! isset( $bp->id ) ) {
continue;
}
foreach ( $remote_data->bundled_products as $rbp ) {
if ( ! isset( $rbp->id ) ) {
continue;
}
if ( $rbp->id === $bp->id ) {
$bprd = $brainstrom_bundled_products[ $bkeys ];
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->remote = $rbp->remote_version;
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->parent = $rbp->parent;
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->short_name = $rbp->short_name;
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->changelog_url = $rbp->changelog_url;
if ( isset( $rbp->download_url ) ) {
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->download_url = $rbp->download_url;
}
if ( isset( $rbp->download_url_beta ) ) {
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->download_url_beta = $rbp->download_url_beta;
}
$is_bundled_update = true;
}
}
}
}
}
}
}
if ( $is_bundled_update ) {
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
}
}
}
if ( $is_update ) {
update_option( 'brainstrom_products', $brainstrom_products );
}
}
}
<?php
/**
* Product update functions.
*
* @package BSF core
*/
// Alternative function for wp_remote_get.
if ( ! function_exists( 'bsf_get_remote_version' ) ) {
/**
* Get remote version for product
*
* @param array $product_list products data.
* @param array $products products data (deprecated).
* @return array
*/
function bsf_get_remote_version( $product_list, $products ) {
global $ultimate_referer;
$path = bsf_get_api_url() . '?referer=' . $ultimate_referer;
$data = array(
'action' => 'bsf_get_product_versions',
'ids' => $products,
'products' => $product_list,
'site_url' => get_site_url(),
'php_version' => bsf_get_php_version(),
'wp_version' => get_bloginfo( 'version' ),
'locale' => get_locale(),
'bsf_core_version' => BSF_UPDATER_VERSION,
'active_theme' => get_template(),
'active_stylesheet' => get_stylesheet(),
'php_max_input_vars' => ini_get( 'max_input_vars' ), // phpcs:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound
'php_post_max_size' => ini_get( 'post_max_size' ),
'php_max_execution_time' => ini_get( 'max_execution_time' ),
'php_memory_limit' => ini_get( 'memory_limit' ),
);
$request = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '10',
)
);
// Request http URL if the https version fails.
if ( is_wp_error( $request ) && 200 !== wp_remote_retrieve_response_code( $request ) ) {
$path = bsf_get_api_url( true ) . '?referer=' . $ultimate_referer;
$request = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '8',
)
);
}
if ( ! is_wp_error( $request ) || 200 === wp_remote_retrieve_response_code( $request ) ) {
$result = json_decode( wp_remote_retrieve_body( $request ) );
if ( ! empty( $result ) ) {
if ( empty( $result->error ) ) {
return $result->updated_versions;
} else {
return $result->error;
}
}
}
}
}
if ( ! function_exists( 'bsf_check_product_update' ) ) {
/**
* Check product updates.
*
* @return void
*/
function bsf_check_product_update() {
$is_update = true;
$registered = array(); // This list will be deprecated in favor of $product_list.
$product_list = array();
$all_products = brainstorm_get_all_products( false, false, true );
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
foreach ( $all_products as $key => $product ) {
if ( ! isset( $product['id'] ) ) {
continue;
}
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
$constant = 'BSF_' . $constant . '_CHECK_UPDATES';
if ( defined( $constant ) && ( 'false' === constant( $constant ) || false === constant( $constant ) ) ) {
continue;
}
$registered[] = $product['id'];
$product_list[ $product['id'] ] = array(
'id' => $product['id'],
'installed_version' => $product['version'],
);
// Add bundled products to the list.
if ( isset( $brainstrom_bundled_products[ $product['id'] ] ) ) {
$bundled_products = $brainstrom_bundled_products[ $product['id'] ];
$bundled_product_data = array();
foreach ( $bundled_products as $bundled_product ) {
$bundled_product_data[ $bundled_product->id ] = array(
'id' => $bundled_product->id,
'installed_version' => $bundled_product->version,
);
}
$product_list[ $product['id'] ]['bundled_products'] = $bundled_product_data;
}
}
$remote_versions = bsf_get_remote_version( $product_list, $registered );
$bsf_product_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$bsf_product_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
if ( false !== $remote_versions ) {
if ( ! empty( $remote_versions ) ) {
$is_bundled_update = false;
foreach ( $remote_versions as $rkey => $remote_data ) {
$rid = ( isset( $remote_data->id ) ) ? (string) $remote_data->id : '';
$remote_version = ( isset( $remote_data->remote_version ) ) ? $remote_data->remote_version : '';
$in_house = ( isset( $remote_data->in_house ) ) ? $remote_data->in_house : '';
$on_market = ( isset( $remote_data->on_market ) ) ? $remote_data->on_market : '';
$is_product_free = ( isset( $remote_data->is_product_free ) ) ? $remote_data->is_product_free : '';
$short_name = ( isset( $remote_data->short_name ) ) ? $remote_data->short_name : '';
$changelog_url = ( isset( $remote_data->changelog_url ) ) ? $remote_data->changelog_url : '';
$purchase_url = ( isset( $remote_data->purchase_url ) ) ? $remote_data->purchase_url : '';
$version_beta = ( isset( $remote_data->version_beta ) ) ? $remote_data->version_beta : '';
$download_url = ( isset( $remote_data->download_url ) ) ? $remote_data->download_url : '';
$download_url_beta = ( isset( $remote_data->download_url_beta ) ) ? $remote_data->download_url_beta : '';
$tested_upto = ( isset( $remote_data->tested ) ) ? $remote_data->tested : '';
foreach ( $bsf_product_plugins as $key => $plugin ) {
if ( ! isset( $plugin['id'] ) ) {
continue;
}
$pid = (string) $plugin['id'];
if ( $pid === $rid ) {
$brainstrom_products['plugins'][ $key ]['remote'] = $remote_version;
$brainstrom_products['plugins'][ $key ]['in_house'] = $in_house;
$brainstrom_products['plugins'][ $key ]['on_market'] = $on_market;
$brainstrom_products['plugins'][ $key ]['is_product_free'] = $is_product_free;
$brainstrom_products['plugins'][ $key ]['short_name'] = $short_name;
$brainstrom_products['plugins'][ $key ]['changelog_url'] = $changelog_url;
$brainstrom_products['plugins'][ $key ]['purchase_url'] = $purchase_url;
$brainstrom_products['plugins'][ $key ]['version_beta'] = $version_beta;
$brainstrom_products['plugins'][ $key ]['download_url_beta'] = $download_url_beta;
$brainstrom_products['plugins'][ $key ]['download_url'] = $download_url;
$brainstrom_products['plugins'][ $key ]['tested'] = $tested_upto;
// Deregister status for plugin.
if ( isset( $remote_data->status ) && 0 === $remote_data->status ) {
$brainstrom_products['plugins'][ $key ]['status'] = 'not-registered';
} else {
$brainstrom_products['plugins'][ $key ]['status'] = 'registered';
}
$is_update = true;
}
}
foreach ( $bsf_product_themes as $key => $theme ) {
if ( ! isset( $theme['id'] ) ) {
continue;
}
$pid = $theme['id'];
if ( $pid === $rid ) {
$brainstrom_products['themes'][ $key ]['remote'] = $remote_version;
$brainstrom_products['themes'][ $key ]['in_house'] = $in_house;
$brainstrom_products['themes'][ $key ]['on_market'] = $on_market;
$brainstrom_products['themes'][ $key ]['is_product_free'] = $is_product_free;
$brainstrom_products['themes'][ $key ]['short_name'] = $short_name;
$brainstrom_products['themes'][ $key ]['changelog_url'] = $changelog_url;
$brainstrom_products['themes'][ $key ]['purchase_url'] = $purchase_url;
$brainstrom_products['themes'][ $key ]['version_beta'] = $version_beta;
$brainstrom_products['themes'][ $key ]['download_url'] = $download_url;
$brainstrom_products['themes'][ $key ]['download_url_beta'] = $download_url_beta;
$is_update = true;
// Deregister status for theme.
if ( isset( $remote_data->status ) && 0 === $remote_data->status ) {
$brainstrom_products['themes'][ $key ]['status'] = 'not-registered';
} else {
$brainstrom_products['themes'][ $key ]['status'] = 'registered';
}
}
}
if ( isset( $remote_data->bundled_products ) && ! empty( $remote_data->bundled_products ) ) {
if ( ! empty( $brainstrom_bundled_products ) && is_array( $brainstrom_bundled_products ) ) {
foreach ( $brainstrom_bundled_products as $bkeys => $bps ) {
foreach ( $bps as $bkey => $bp ) {
if ( ! isset( $bp->id ) ) {
continue;
}
foreach ( $remote_data->bundled_products as $rbp ) {
if ( ! isset( $rbp->id ) ) {
continue;
}
if ( $rbp->id === $bp->id ) {
$bprd = $brainstrom_bundled_products[ $bkeys ];
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->remote = $rbp->remote_version;
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->parent = $rbp->parent;
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->short_name = $rbp->short_name;
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->changelog_url = $rbp->changelog_url;
if ( isset( $rbp->download_url ) ) {
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->download_url = $rbp->download_url;
}
if ( isset( $rbp->download_url_beta ) ) {
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->download_url_beta = $rbp->download_url_beta;
}
$is_bundled_update = true;
}
}
}
}
}
}
}
if ( $is_bundled_update ) {
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
}
}
}
if ( $is_update ) {
update_option( 'brainstrom_products', $brainstrom_products );
}
}
}
@@ -1,2 +1,2 @@
/* Do not change otherwise you won't get updates */
/* Do not change otherwise you won't get updates */
ID:[bsf-core]
@@ -1,18 +1,18 @@
### Version - 1.21
# Support for beta updates of the products.
### Version - 1.19
- License Manager v2.0 - Allow plugins to individually set the license form.
- Update themes and plugins with WordPress's transients. so support for WP-CLI and any other website management tools.
- New License manager API.
- Improvement: Force check product update now works when WordPress updates are force checked.
- Slight redesign of help and debug settings screens.
- Support for white label with filters.
- Option to move Brainstorm registration menu in settings.
- Hide purchase key when it is validated.
- Remove use of deprecated 'mysql_' functions.
- Allow users to skip brainstorm account registration.
- Allow plugins/themes to completely hide the screen for Brainstorm Registration.
- Allow using staging API server for development.
### Version - 1.21
# Support for beta updates of the products.
### Version - 1.19
- License Manager v2.0 - Allow plugins to individually set the license form.
- Update themes and plugins with WordPress's transients. so support for WP-CLI and any other website management tools.
- New License manager API.
- Improvement: Force check product update now works when WordPress updates are force checked.
- Slight redesign of help and debug settings screens.
- Support for white label with filters.
- Option to move Brainstorm registration menu in settings.
- Hide purchase key when it is validated.
- Remove use of deprecated 'mysql_' functions.
- Allow users to skip brainstorm account registration.
- Allow plugins/themes to completely hide the screen for Brainstorm Registration.
- Allow using staging API server for development.
- Fix: Occasional PHP fatal errors when using the child theme.
@@ -1,449 +1,449 @@
<?php
/**
* BSf Evato Activation Class file.
*
* @package bsf-core
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* BSF_Envato_Activate setup
*
* @since 1.0
*/
class BSF_Envato_Activate {
/**
* Instance
*
* @var BSF_Envato_Activate
*/
private static $instance;
/**
* Reference to the License manager class.
*
* @var BSF_License_Manager
*/
private $license_manager;
/**
* Stores temporary response messsages from the API validations.
*
* @var array()
*/
private $message_box;
/**
* Initiator.
*/
public static function instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new BSF_Envato_Activate();
}
return self::$instance;
}
/**
* Constructor function that initializes required actions and hooks
*
* @since 1.0
*/
public function __construct() {
$this->license_manager = new BSF_License_Manager();
$action = isset( $_GET['license_action'] ) ? esc_attr( $_GET['license_action'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( 'activate_license' === $action ) {
$this->process_envato_activation();
}
add_filter( 'update_footer', array( $this, 'alternate_method_link' ), 20 );
add_action( 'bsf_inlne_license_envato_after_form', array( $this, 'inline_alternate_method_link' ), 20, 2 );
}
/**
* Envato Register.
*
* @param array $args Arguments.
*/
public function envato_register( $args ) {
// Check if alternate method is to be used.
$method = ( isset( $_GET['activation_method'] ) && isset( $_GET['bsf_activation_nonce'] ) && wp_verify_nonce( $_GET['bsf_activation_nonce'], 'bsf_activation_nonce' ) ) ? esc_attr( $_GET['activation_method'] ) : 'oauth';
$html = '';
$product_id = isset( $args['product_id'] ) ? $args['product_id'] : '';
$is_active = $this->license_manager->bsf_is_active_license( $product_id );
$product_name = $this->license_manager->bsf_get_product_info( $product_id, 'name' );
$purchase_url = $this->license_manager->bsf_get_product_info( $product_id, 'purchase_url' );
$bundled = BSF_Update_Manager::bsf_is_product_bundled( $product_id );
if ( ! empty( $bundled ) ) {
$parent_id = $bundled[0];
$is_active = $this->license_manager->bsf_is_active_license( $parent_id );
$parent_name = brainstrom_product_name( $parent_id );
$registration_page = bsf_registration_page_url( '', $parent_id );
$html .= '<div class="bundled-product-license-registration">';
$html .= '<span>';
if ( $is_active ) {
$html .= '<h3>License Active!</h3>';
$html .= '<p>' . sprintf(
'Your license is activated, you will receive updates for <i>%s</i> when they are available.',
$product_name
) . '</p>';
} else {
$html .= '<h3>Updates Unavailable!</h3>';
$html .= '<p>' . sprintf(
'This plugin is came bundled with the <i>%1$s</i>. For receiving updates, you need to activate license of <i>%2$s</i> <a href="%3$s">here</a>.',
$parent_name,
$parent_name,
$registration_page
) . '</p>';
}
$html .= '</span>';
$html .= '</div>';
return $html;
}
if ( 'license-key' === $method ) {
$html .= bsf_license_activation_form( $args );
return $html;
}
// Licence activation button.
$form_action = ( isset( $args['form_action'] ) && ! is_null( $args['form_action'] ) ) ? $args['form_action'] : '';
$form_class = ( isset( $args['form_class'] ) && ! is_null( $args['form_class'] ) ) ? $args['form_class'] : "bsf-license-form-{$product_id}";
$submit_button_class = ( isset( $args['submit_button_class'] ) && ! is_null( $args['submit_button_class'] ) ) ? $args['submit_button_class'] : '';
$license_form_heading_class = ( isset( $args['bsf_license_form_heading_class'] ) && ! is_null( $args['bsf_license_form_heading_class'] ) ) ? $args['bsf_license_form_heading_class'] : '';
$license_active_class = ( isset( $args['bsf_license_active_class'] ) && ! is_null( $args['bsf_license_active_class'] ) ) ? $args['bsf_license_active_class'] : '';
$license_not_activate_message = ( isset( $args['bsf_license_not_activate_message'] ) && ! is_null( $args['bsf_license_not_activate_message'] ) ) ? $args['bsf_license_not_activate_message'] : '';
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
$button_text_activate = ( isset( $args['button_text_activate'] ) && ! is_null( $args['button_text_activate'] ) ) ? __( 'Sign Up & Activate', 'bsf' ) : __( 'Sign Up & Activate', 'bsf' );
$button_text_deactivate = ( isset( $args['button_text_deactivate'] ) && ! is_null( $args['button_text_deactivate'] ) ) ? $args['button_text_deactivate'] : __( 'Deactivate License', 'bsf' );
$placeholder = ( isset( $args['placeholder'] ) && ! is_null( $args['placeholder'] ) ) ? $args['placeholder'] : 'Enter your license key..';
$popup_license_form = ( isset( $args['popup_license_form'] ) ) ? $args['popup_license_form'] : false;
$bsf_license_allow_email = ( isset( $args['bsf_license_allow_email'] ) && ! is_null( $args['bsf_license_allow_email'] ) ) ? $args['bsf_license_allow_email'] : true;
if ( true === $bsf_license_allow_email ) {
$form_class .= ' license-form-allow-email ';
if ( ! $is_active ) {
$submit_button_class .= ' button-primary button-hero bsf-envato-form-activation ';
}
}
if ( true !== $is_active ) {
$form_action = bsf_get_api_site() . 'envato-validation-callback/?wp-envato-validate';
} else {
$form_action = bsf_registration_page_url( '', $product_id );
}
$html .= '<div class="envato-license-registration">';
$html .= '<form method="post" class="' . $form_class . '" action="' . $form_action . '">';
$html .= wp_nonce_field( 'bsf_license_activation_deactivation_nonce', 'bsf_graupi_nonce', true, false );
if ( $this->get_message( 'message' ) !== '' ) {
$html .= '<span class="bsf-license-message license-' . $this->get_message( 'status' ) . '">';
$html .= $this->get_message( 'message' );
$html .= '</span>';
}
if ( $is_active ) {
$envato_active_oauth_title = apply_filters( "envato_active_oauth_title_{$product_id}", 'Updates & Support Registration - <span class="active">Active!</span>' );
$envato_active_oauth_subtitle = '<span class="active">' . sprintf(
'Your license is active.',
$product_name
) . '</span>';
$envato_active_oauth_subtitle = apply_filters( "envato_active_oauth_subtitle_{$product_id}", $envato_active_oauth_subtitle );
if ( $popup_license_form ) {
$html .= '<div class="bsf-wrap-title">';
$html .= '<h3 class="envato-oauth-heading">' . $product_name . '</h2>';
$html .= '<p class="envato-oauth-subheading">' . $envato_active_oauth_subtitle . '</p>';
$html .= '</div>';
} else {
$html .= '<div class="bsf-wrap-title">';
$html .= '<h3 class="envato-oauth-heading">' . $envato_active_oauth_title . '</h2>';
$html .= '<p class="envato-oauth-subheading">' . $envato_active_oauth_subtitle . '</p>';
$html .= '</div>';
}
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="bsf_license_manager[license_key]" value="License Validated"/>';
$html .= '<input type="hidden" class="' . $size . '-text" id="bsf_license_manager[product_id]" name="bsf_license_manager[product_id]" value="' . esc_attr( stripslashes( $product_id ) ) . '"/>';
$html .= '<input type="submit" class="button ' . $submit_button_class . '" name="bsf_deactivate_license" value="' . esc_attr( $button_text_deactivate ) . '"/>';
} else {
$envato_not_active_oauth_title = apply_filters( "envato_not_active_oauth_title_{$product_id}", __( 'Updates & Support Registration - <span class="not-active">Not Active!</span>', 'bsf' ) );
$envato_not_active_oauth_subtitle = apply_filters( "envato_not_active_oauth_subtitle_{$product_id}", __( 'Click on the button below to activate your license and subscribe to our newsletter.', 'bsf' ) );
if ( $popup_license_form ) {
$html .= '<div class="bsf-wrap-title">';
$html .= '<h3 class="envato-oauth-heading">' . $product_name . '</h2>';
$html .= '<p class="envato-oauth-subheading">' . $envato_not_active_oauth_subtitle . '</p>';
$html .= '</div>';
} else {
$html .= '<div class="bsf-wrap-title">';
$html .= '<h3 class="envato-oauth-heading">' . $envato_not_active_oauth_title . '</h2>';
$html .= '<p class="envato-oauth-subheading">' . $envato_not_active_oauth_subtitle . '</p>';
$html .= '</div>';
}
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="url" value="' . get_site_url() . '"/>';
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="redirect" value="' . $this->get_redirect_url( $product_id ) . '"/>';
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="product_id" value="' . $product_id . '"/>';
$html .= '<input id="bsf-license-privacy-consent" name="bsf_license_manager[privacy_consent]" type="hidden" value="true" />';
$html .= '<input id="bsf-license-terms-conditions-consent" name="bsf_license_manager[terms_conditions_consent]" type="hidden" value="true" />';
$html .= '<div class="submit-button-wrap">';
$html .= '<input type="button" class="button ' . $submit_button_class . '" name="bsf_activate_license" value="' . esc_attr( $button_text_activate ) . '"/>';
$html .= "<p class='purchase-license'><a target='_blank' href='$purchase_url'>Purchase License »</a></p>";
$html .= '</div>';
}
$html .= '</form>';
$html = apply_filters( 'bsf_inlne_license_envato_after_form', $html, $product_id );
$html .= '</div> <!-- envato-license-registration -->';
if ( isset( $_GET['debug'] ) ) {
$html .= get_bsf_systeminfo();
}
return $html;
}
/**
* Envato activation URL.
*
* @param array $form_data Form data.
* @return $envato_activation_url.
*/
public function envato_activation_url( $form_data ) {
$product_id = isset( $form_data['product_id'] ) ? esc_attr( $form_data['product_id'] ) : '';
$form_data['token'] = sha1( $this->create_token( $product_id ) );
$url = bsf_get_api_site() . 'envato-validation-callback/?wp-envato-validate';
$envato_activation_url = add_query_arg(
$form_data,
$url
);
return $envato_activation_url;
}
/**
* Get redirect URL.
*
* @param int $product_id Product ID.
* @return $current_url.
*/
protected function get_redirect_url( $product_id = '' ) {
if ( is_ssl() ) {
$current_url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
} else {
$current_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
$current_url = esc_url( remove_query_arg( array( 'license_action', 'token', 'product_id', 'purchase_key', 'success', 'status', 'message' ), $current_url ) );
if ( '' !== $product_id ) {
$current_url = add_query_arg(
array(
'bsf-inline-license-form' => $product_id,
),
$current_url
);
}
return $current_url;
}
/**
* Create Token.
*
* @param int $product_id Product ID.
* @return $token.
*/
protected function create_token( $product_id ) {
$token = $product_id . '|' . current_time( 'timestamp' ) . '|' . bsf_generate_rand_token();
update_site_option( "bsf_envato_token_$product_id", $token );
return $token;
}
/**
* Validate Token.
*
* @param string $token Token.
* @param int $product_id Product ID.
* @return bool.
*/
protected function validate_token( $token, $product_id ) {
$stored_token = get_site_option( "bsf_envato_token_$product_id", '' );
if ( sha1( $stored_token ) === $token ) {
$token_atts = explode( '|', $stored_token );
$stored_id = $token_atts[0];
if ( $stored_id !== $product_id ) {
// Token is invalid.
return false;
}
$timestamp = (int) $token_atts[1];
$valid_ultil = $timestamp + 900;
if ( current_time( 'timestamp' ) > $valid_ultil ) {
// Timestamp has expired.
return false;
}
// If above conditions did not meet, the token is valid.
return true;
}
return false;
}
/**
* Process envato activation.
*/
protected function process_envato_activation() {
$token = isset( $_GET['token'] ) ? esc_attr( $_GET['token'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$product_id = isset( $_GET['product_id'] ) ? esc_attr( $_GET['product_id'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( $this->validate_token( $token, $product_id ) ) {
$args = array();
$args['purchase_key'] = isset( $_GET['purchase_key'] ) ? esc_attr( $_GET['purchase_key'] ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$args['status'] = isset( $_GET['status'] ) ? esc_attr( $_GET['status'] ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$this->license_manager->bsf_update_product_info( $product_id, $args );
$this->set_message(
array(
'status' => 'success',
'message' => 'License successfully activated!',
)
);
} else {
$this->set_message(
array(
'status' => 'error',
'message' => 'The token is invalid or is expired, please try again.',
)
);
}
}
/**
* Set message.
*
* @param array $message Message.
*/
protected function set_message( $message = array() ) {
$this->message_box = $message;
}
/**
* Get message.
*
* @param string $key key.
* @return $mesage
*/
protected function get_message( $key ) {
$message = $this->message_box;
return isset( $message[ $key ] ) ? $message[ $key ] : '';
}
/**
* Inline alternate method link.
*
* @param string $html HTML.
* @param int $bsf_product_id Product ID.
* @return $html.
*/
public function inline_alternate_method_link( $html, $bsf_product_id ) {
$privacy_policy_link = $this->license_manager->bsf_get_product_info( $bsf_product_id, 'privacy_policy' );
$terms_conditions_link = $this->license_manager->bsf_get_product_info( $bsf_product_id, 'terms_conditions' );
if ( isset( $privacy_policy_link ) ) {
$html .= sprintf(
'<a class="license-form-external-links" target="_blank" href="%s">Privacy Policy</a> | ',
$privacy_policy_link
);
}
if ( isset( $terms_conditions_link ) ) {
$html .= sprintf(
'<a class="license-form-external-links" target="_blank" href="%s">Terms & Conditions</a>',
$terms_conditions_link
);
}
return $html;
}
/**
* ALternate method link.
*
* @param string $content Content.
* @return $content.
*/
public function alternate_method_link( $content ) {
$bsf_activation_nonce = wp_create_nonce( 'bsf_activation_nonce' );
$content = sprintf(
'<a href="%s">Activate license using purchase key</a>',
add_query_arg(
array(
'activation_method' => 'license-key',
'bsf_activation_nonce' => $bsf_activation_nonce,
)
)
);
return $content;
}
}
/**
* BSF envato register.
*
* @param string $args Arguments..
* @return envato_register().
*/
function bsf_envato_register( $args ) {
$bsf_envato_activate = BSF_Envato_Activate::instance();
return $bsf_envato_activate->envato_register( $args );
}
<?php
/**
* BSf Evato Activation Class file.
*
* @package bsf-core
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* BSF_Envato_Activate setup
*
* @since 1.0
*/
class BSF_Envato_Activate {
/**
* Instance
*
* @var BSF_Envato_Activate
*/
private static $instance;
/**
* Reference to the License manager class.
*
* @var BSF_License_Manager
*/
private $license_manager;
/**
* Stores temporary response messsages from the API validations.
*
* @var array()
*/
private $message_box;
/**
* Initiator.
*/
public static function instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new BSF_Envato_Activate();
}
return self::$instance;
}
/**
* Constructor function that initializes required actions and hooks
*
* @since 1.0
*/
public function __construct() {
$this->license_manager = new BSF_License_Manager();
$action = isset( $_GET['license_action'] ) ? esc_attr( $_GET['license_action'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( 'activate_license' === $action ) {
$this->process_envato_activation();
}
add_filter( 'update_footer', array( $this, 'alternate_method_link' ), 20 );
add_action( 'bsf_inlne_license_envato_after_form', array( $this, 'inline_alternate_method_link' ), 20, 2 );
}
/**
* Envato Register.
*
* @param array $args Arguments.
*/
public function envato_register( $args ) {
// Check if alternate method is to be used.
$method = ( isset( $_GET['activation_method'] ) && isset( $_GET['bsf_activation_nonce'] ) && wp_verify_nonce( $_GET['bsf_activation_nonce'], 'bsf_activation_nonce' ) ) ? esc_attr( $_GET['activation_method'] ) : 'oauth';
$html = '';
$product_id = isset( $args['product_id'] ) ? $args['product_id'] : '';
$is_active = $this->license_manager->bsf_is_active_license( $product_id );
$product_name = $this->license_manager->bsf_get_product_info( $product_id, 'name' );
$purchase_url = $this->license_manager->bsf_get_product_info( $product_id, 'purchase_url' );
$bundled = BSF_Update_Manager::bsf_is_product_bundled( $product_id );
if ( ! empty( $bundled ) ) {
$parent_id = $bundled[0];
$is_active = $this->license_manager->bsf_is_active_license( $parent_id );
$parent_name = brainstrom_product_name( $parent_id );
$registration_page = bsf_registration_page_url( '', $parent_id );
$html .= '<div class="bundled-product-license-registration">';
$html .= '<span>';
if ( $is_active ) {
$html .= '<h3>License Active!</h3>';
$html .= '<p>' . sprintf(
'Your license is activated, you will receive updates for <i>%s</i> when they are available.',
$product_name
) . '</p>';
} else {
$html .= '<h3>Updates Unavailable!</h3>';
$html .= '<p>' . sprintf(
'This plugin is came bundled with the <i>%1$s</i>. For receiving updates, you need to activate license of <i>%2$s</i> <a href="%3$s">here</a>.',
$parent_name,
$parent_name,
$registration_page
) . '</p>';
}
$html .= '</span>';
$html .= '</div>';
return $html;
}
if ( 'license-key' === $method ) {
$html .= bsf_license_activation_form( $args );
return $html;
}
// Licence activation button.
$form_action = ( isset( $args['form_action'] ) && ! is_null( $args['form_action'] ) ) ? $args['form_action'] : '';
$form_class = ( isset( $args['form_class'] ) && ! is_null( $args['form_class'] ) ) ? $args['form_class'] : "bsf-license-form-{$product_id}";
$submit_button_class = ( isset( $args['submit_button_class'] ) && ! is_null( $args['submit_button_class'] ) ) ? $args['submit_button_class'] : '';
$license_form_heading_class = ( isset( $args['bsf_license_form_heading_class'] ) && ! is_null( $args['bsf_license_form_heading_class'] ) ) ? $args['bsf_license_form_heading_class'] : '';
$license_active_class = ( isset( $args['bsf_license_active_class'] ) && ! is_null( $args['bsf_license_active_class'] ) ) ? $args['bsf_license_active_class'] : '';
$license_not_activate_message = ( isset( $args['bsf_license_not_activate_message'] ) && ! is_null( $args['bsf_license_not_activate_message'] ) ) ? $args['bsf_license_not_activate_message'] : '';
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
$button_text_activate = ( isset( $args['button_text_activate'] ) && ! is_null( $args['button_text_activate'] ) ) ? __( 'Sign Up & Activate', 'bsf' ) : __( 'Sign Up & Activate', 'bsf' );
$button_text_deactivate = ( isset( $args['button_text_deactivate'] ) && ! is_null( $args['button_text_deactivate'] ) ) ? $args['button_text_deactivate'] : __( 'Deactivate License', 'bsf' );
$placeholder = ( isset( $args['placeholder'] ) && ! is_null( $args['placeholder'] ) ) ? $args['placeholder'] : 'Enter your license key..';
$popup_license_form = ( isset( $args['popup_license_form'] ) ) ? $args['popup_license_form'] : false;
$bsf_license_allow_email = ( isset( $args['bsf_license_allow_email'] ) && ! is_null( $args['bsf_license_allow_email'] ) ) ? $args['bsf_license_allow_email'] : true;
if ( true === $bsf_license_allow_email ) {
$form_class .= ' license-form-allow-email ';
if ( ! $is_active ) {
$submit_button_class .= ' button-primary button-hero bsf-envato-form-activation ';
}
}
if ( true !== $is_active ) {
$form_action = bsf_get_api_site() . 'envato-validation-callback/?wp-envato-validate';
} else {
$form_action = bsf_registration_page_url( '', $product_id );
}
$html .= '<div class="envato-license-registration">';
$html .= '<form method="post" class="' . $form_class . '" action="' . $form_action . '">';
$html .= wp_nonce_field( 'bsf_license_activation_deactivation_nonce', 'bsf_graupi_nonce', true, false );
if ( $this->get_message( 'message' ) !== '' ) {
$html .= '<span class="bsf-license-message license-' . $this->get_message( 'status' ) . '">';
$html .= $this->get_message( 'message' );
$html .= '</span>';
}
if ( $is_active ) {
$envato_active_oauth_title = apply_filters( "envato_active_oauth_title_{$product_id}", 'Updates & Support Registration - <span class="active">Active!</span>' );
$envato_active_oauth_subtitle = '<span class="active">' . sprintf(
'Your license is active.',
$product_name
) . '</span>';
$envato_active_oauth_subtitle = apply_filters( "envato_active_oauth_subtitle_{$product_id}", $envato_active_oauth_subtitle );
if ( $popup_license_form ) {
$html .= '<div class="bsf-wrap-title">';
$html .= '<h3 class="envato-oauth-heading">' . $product_name . '</h2>';
$html .= '<p class="envato-oauth-subheading">' . $envato_active_oauth_subtitle . '</p>';
$html .= '</div>';
} else {
$html .= '<div class="bsf-wrap-title">';
$html .= '<h3 class="envato-oauth-heading">' . $envato_active_oauth_title . '</h2>';
$html .= '<p class="envato-oauth-subheading">' . $envato_active_oauth_subtitle . '</p>';
$html .= '</div>';
}
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="bsf_license_manager[license_key]" value="License Validated"/>';
$html .= '<input type="hidden" class="' . $size . '-text" id="bsf_license_manager[product_id]" name="bsf_license_manager[product_id]" value="' . esc_attr( stripslashes( $product_id ) ) . '"/>';
$html .= '<input type="submit" class="button ' . $submit_button_class . '" name="bsf_deactivate_license" value="' . esc_attr( $button_text_deactivate ) . '"/>';
} else {
$envato_not_active_oauth_title = apply_filters( "envato_not_active_oauth_title_{$product_id}", __( 'Updates & Support Registration - <span class="not-active">Not Active!</span>', 'bsf' ) );
$envato_not_active_oauth_subtitle = apply_filters( "envato_not_active_oauth_subtitle_{$product_id}", __( 'Click on the button below to activate your license and subscribe to our newsletter.', 'bsf' ) );
if ( $popup_license_form ) {
$html .= '<div class="bsf-wrap-title">';
$html .= '<h3 class="envato-oauth-heading">' . $product_name . '</h2>';
$html .= '<p class="envato-oauth-subheading">' . $envato_not_active_oauth_subtitle . '</p>';
$html .= '</div>';
} else {
$html .= '<div class="bsf-wrap-title">';
$html .= '<h3 class="envato-oauth-heading">' . $envato_not_active_oauth_title . '</h2>';
$html .= '<p class="envato-oauth-subheading">' . $envato_not_active_oauth_subtitle . '</p>';
$html .= '</div>';
}
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="url" value="' . get_site_url() . '"/>';
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="redirect" value="' . $this->get_redirect_url( $product_id ) . '"/>';
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="product_id" value="' . $product_id . '"/>';
$html .= '<input id="bsf-license-privacy-consent" name="bsf_license_manager[privacy_consent]" type="hidden" value="true" />';
$html .= '<input id="bsf-license-terms-conditions-consent" name="bsf_license_manager[terms_conditions_consent]" type="hidden" value="true" />';
$html .= '<div class="submit-button-wrap">';
$html .= '<input type="button" class="button ' . $submit_button_class . '" name="bsf_activate_license" value="' . esc_attr( $button_text_activate ) . '"/>';
$html .= "<p class='purchase-license'><a target='_blank' href='$purchase_url'>Purchase License »</a></p>";
$html .= '</div>';
}
$html .= '</form>';
$html = apply_filters( 'bsf_inlne_license_envato_after_form', $html, $product_id );
$html .= '</div> <!-- envato-license-registration -->';
if ( isset( $_GET['debug'] ) ) {
$html .= get_bsf_systeminfo();
}
return $html;
}
/**
* Envato activation URL.
*
* @param array $form_data Form data.
* @return $envato_activation_url.
*/
public function envato_activation_url( $form_data ) {
$product_id = isset( $form_data['product_id'] ) ? esc_attr( $form_data['product_id'] ) : '';
$form_data['token'] = sha1( $this->create_token( $product_id ) );
$url = bsf_get_api_site() . 'envato-validation-callback/?wp-envato-validate';
$envato_activation_url = add_query_arg(
$form_data,
$url
);
return $envato_activation_url;
}
/**
* Get redirect URL.
*
* @param int $product_id Product ID.
* @return $current_url.
*/
protected function get_redirect_url( $product_id = '' ) {
if ( is_ssl() ) {
$current_url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
} else {
$current_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
$current_url = esc_url( remove_query_arg( array( 'license_action', 'token', 'product_id', 'purchase_key', 'success', 'status', 'message' ), $current_url ) );
if ( '' !== $product_id ) {
$current_url = add_query_arg(
array(
'bsf-inline-license-form' => $product_id,
),
$current_url
);
}
return $current_url;
}
/**
* Create Token.
*
* @param int $product_id Product ID.
* @return $token.
*/
protected function create_token( $product_id ) {
$token = $product_id . '|' . current_time( 'timestamp' ) . '|' . bsf_generate_rand_token();
update_site_option( "bsf_envato_token_$product_id", $token );
return $token;
}
/**
* Validate Token.
*
* @param string $token Token.
* @param int $product_id Product ID.
* @return bool.
*/
protected function validate_token( $token, $product_id ) {
$stored_token = get_site_option( "bsf_envato_token_$product_id", '' );
if ( sha1( $stored_token ) === $token ) {
$token_atts = explode( '|', $stored_token );
$stored_id = $token_atts[0];
if ( $stored_id !== $product_id ) {
// Token is invalid.
return false;
}
$timestamp = (int) $token_atts[1];
$valid_ultil = $timestamp + 900;
if ( current_time( 'timestamp' ) > $valid_ultil ) {
// Timestamp has expired.
return false;
}
// If above conditions did not meet, the token is valid.
return true;
}
return false;
}
/**
* Process envato activation.
*/
protected function process_envato_activation() {
$token = isset( $_GET['token'] ) ? esc_attr( $_GET['token'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$product_id = isset( $_GET['product_id'] ) ? esc_attr( $_GET['product_id'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( $this->validate_token( $token, $product_id ) ) {
$args = array();
$args['purchase_key'] = isset( $_GET['purchase_key'] ) ? esc_attr( $_GET['purchase_key'] ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$args['status'] = isset( $_GET['status'] ) ? esc_attr( $_GET['status'] ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$this->license_manager->bsf_update_product_info( $product_id, $args );
$this->set_message(
array(
'status' => 'success',
'message' => 'License successfully activated!',
)
);
} else {
$this->set_message(
array(
'status' => 'error',
'message' => 'The token is invalid or is expired, please try again.',
)
);
}
}
/**
* Set message.
*
* @param array $message Message.
*/
protected function set_message( $message = array() ) {
$this->message_box = $message;
}
/**
* Get message.
*
* @param string $key key.
* @return $mesage
*/
protected function get_message( $key ) {
$message = $this->message_box;
return isset( $message[ $key ] ) ? $message[ $key ] : '';
}
/**
* Inline alternate method link.
*
* @param string $html HTML.
* @param int $bsf_product_id Product ID.
* @return $html.
*/
public function inline_alternate_method_link( $html, $bsf_product_id ) {
$privacy_policy_link = $this->license_manager->bsf_get_product_info( $bsf_product_id, 'privacy_policy' );
$terms_conditions_link = $this->license_manager->bsf_get_product_info( $bsf_product_id, 'terms_conditions' );
if ( isset( $privacy_policy_link ) ) {
$html .= sprintf(
'<a class="license-form-external-links" target="_blank" href="%s">Privacy Policy</a> | ',
$privacy_policy_link
);
}
if ( isset( $terms_conditions_link ) ) {
$html .= sprintf(
'<a class="license-form-external-links" target="_blank" href="%s">Terms & Conditions</a>',
$terms_conditions_link
);
}
return $html;
}
/**
* ALternate method link.
*
* @param string $content Content.
* @return $content.
*/
public function alternate_method_link( $content ) {
$bsf_activation_nonce = wp_create_nonce( 'bsf_activation_nonce' );
$content = sprintf(
'<a href="%s">Activate license using purchase key</a>',
add_query_arg(
array(
'activation_method' => 'license-key',
'bsf_activation_nonce' => $bsf_activation_nonce,
)
)
);
return $content;
}
}
/**
* BSF envato register.
*
* @param string $args Arguments..
* @return envato_register().
*/
function bsf_envato_register( $args ) {
$bsf_envato_activate = BSF_Envato_Activate::instance();
return $bsf_envato_activate->envato_register( $args );
}
File diff suppressed because it is too large Load Diff
@@ -1,180 +1,180 @@
<?php
/**
* BSF Rollback Version manager class file.
*
* @package bsf-core
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* BSF Rollback Version manager.
*/
class BSF_Rollback_Version_Manager {
/**
* This is set for page reload cache.
*
* @var $reload_page_cache
*/
public static $reload_page_cache = 1;
/**
* Constructor function that initializes required sections.
*/
public function __construct() {
add_action( 'admin_notices', array( $this, 'bsf_download_rollback_version' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
}
/**
* Display Rollback to privious versions form.
*
* @param string $product_id Product ID.
* @since 1.0.0
*/
public function render_rollback_version_form( $product_id ) {
add_action( 'admin_footer', array( $this, 'rollback_version_popup' ) );
// Enqueue scripts only when this function is called.
wp_enqueue_script( 'bsf-core-version-rollback' );
wp_enqueue_style( 'bsf-core-version-rollback-css' );
$product_details = get_brainstorm_product( $product_id );
$installed_version = isset( $product_details['version'] ) ? $product_details['version'] : '';
$product_versions = BSF_Rollback_Version::bsf_get_product_versions( $product_id ); // Get Remote versions
// Show versions above than latest install version of the product.
$sorted_versions = BSF_Rollback_Version::sort_product_versions( $product_versions, $installed_version );
if ( empty( $sorted_versions ) ) {
echo esc_html__( 'No Versions Found! ', 'bsf-core' );
return;
}
$product_name = isset( $product_details['name'] ) ? $product_details['name'] : '';
$white_label_name = bsf_get_white_lable_product_name( $product_id, $product_name );
?>
<div class="bsf-rollback-version">
<input type="hidden" name="product-name" id="bsf-product-name" value="<?php echo esc_attr( $white_label_name ); ?>">
<select class="bsf-rollback-version-select">
<?php
foreach ( $sorted_versions as $version ) {
?>
<option value="<?php echo esc_attr( $version ); ?>"><?php echo esc_html( $version ); ?> </option>
<?php
}
?>
</select>
<a data-placeholder-text=" <?php echo esc_html__( 'Rollback', 'bsf-core' ); ?>" href="<?php echo esc_url( add_query_arg( 'version_no', $sorted_versions[0], wp_nonce_url( admin_url( 'index.php?action=bsf_rollback&product_id=' . $product_id ), 'bsf_rollback' ) ) ); ?>"
data-placeholder-url="<?php echo esc_url( wp_nonce_url( admin_url( 'index.php?action=bsf_rollback&version_no=VERSION&product_id=' . $product_id ), 'bsf_rollback' ) ); ?>" class="button bsf-rollback-button"><?php echo esc_html__( 'Rollback', 'bsf-core' ); ?> </a>
</div>
<?php
}
/**
* Download Product Version.
*/
public function bsf_download_rollback_version() {
if ( ! current_user_can( 'update_plugins' ) ) {
return false;
}
if ( empty( $_GET['version_no'] ) || empty( $_GET['product_id'] ) || ! isset( $_GET['action'] ) ) {
return false;
}
check_admin_referer( 'bsf_rollback' );
$bsf_update_manager = new BSF_Update_Manager();
$version_no = sanitize_text_field( $_GET['version_no'] );
$product_id = sanitize_text_field( $_GET['product_id'] );
$product_details = get_brainstorm_product( $product_id );
$plugin_slug = ! empty( $product_details['slug'] ) ? $product_details['slug'] : '';
$plugin_name = ! empty( $product_details['template'] ) ? $product_details['template'] : '';
$bundled_plugin_name = ! empty( $product_details['init'] ) ? $product_details['init'] : '';
$purchase_key = $bsf_update_manager->get_purchse_key( $product_id );
$product_title = ! empty( $product_details['name'] ) ? $product_details['name'] : '';
$plugin_name = ! empty( $plugin_name ) ? $plugin_name : $bundled_plugin_name;
$download_params = array(
'version_no' => $version_no,
'purchase_key' => $purchase_key,
'site_url' => get_site_url(),
);
$download_url = bsf_get_api_site( false, true ) . 'download/' . $product_id . '?' . http_build_query( $download_params );
$rollback = new BSF_Rollback_Version(
array(
'version' => $version_no,
'plugin_name' => $plugin_name,
'plugin_slug' => $plugin_slug,
'package_url' => $download_url,
'product_title' => $product_title,
'product_id' => $product_id,
)
);
$rollback->run();
// Delete product versions transient data after update.
bsf_clear_versions_cache( $product_id );
wp_die();
}
/**
* Load Scripts
*
* @since 1.0.0
*
* @param string $hook Current Hook.
* @return void
*/
public function load_scripts( $hook = '' ) {
wp_register_script( 'bsf-core-version-rollback', bsf_core_url( '/assets/js/version-rollback.js' ), array( 'jquery' ), BSF_UPDATER_VERSION, true );
wp_register_style( 'bsf-core-version-rollback-css', bsf_core_url( '/assets/css/rollback-version.css' ), array(), BSF_UPDATER_VERSION );
}
/**
* Version rollback Confirmation popup.
*
* @since 1.0.0
*/
public function rollback_version_popup() {
// This is set to fix the duplicate markup on page load.
if ( 1 !== self::$reload_page_cache ) {
return;
}
self::$reload_page_cache = 0;
?>
<div class="bsf-confirm-rollback-popup" style="display:none;">
<div class="bsf-core-rollback-overlay"></div>
<div class="bsf-confirm-rollback-popup-content">
<h3 class="bsf-rollback-heading bsf-confirm-heading" data-text="<?php esc_html_e( 'Rollback #PRODUCT_NAME# Version', 'bsf-core' ); ?>"></h3>
<p class="bsf-confirm-text bsf-rollback-text" data-text="<?php esc_html_e( 'Are you sure you want to rollback #PRODUCT_NAME# to version #VERSION#?', 'bsf-core' ); ?>" ></p>
<div class="bsf-confirm-rollback-popup-buttons-wrapper">
<button class="button bsf-product-license button-default bsf-confirm-cancel"><?php esc_html_e( 'Cancel', 'bsf-core' ); ?></button>
<button class="button button-primary bsf-confirm-ok"><?php esc_html_e( 'Continue', 'bsf-core' ); ?></button>
</div>
</div>
</div>
<?php
}
}
new BSF_Rollback_Version_Manager();
/**
* Render Rollback versoin form.
*
* @param string $product_id Product ID.
*/
function bsf_get_version_rollback_form( $product_id ) {
if ( ! bsf_display_rollback_version_form( $product_id ) ) {
return false;
}
$instance = new BSF_Rollback_Version_Manager();
$instance->render_rollback_version_form( $product_id );
}
<?php
/**
* BSF Rollback Version manager class file.
*
* @package bsf-core
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* BSF Rollback Version manager.
*/
class BSF_Rollback_Version_Manager {
/**
* This is set for page reload cache.
*
* @var $reload_page_cache
*/
public static $reload_page_cache = 1;
/**
* Constructor function that initializes required sections.
*/
public function __construct() {
add_action( 'admin_notices', array( $this, 'bsf_download_rollback_version' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
}
/**
* Display Rollback to privious versions form.
*
* @param string $product_id Product ID.
* @since 1.0.0
*/
public function render_rollback_version_form( $product_id ) {
add_action( 'admin_footer', array( $this, 'rollback_version_popup' ) );
// Enqueue scripts only when this function is called.
wp_enqueue_script( 'bsf-core-version-rollback' );
wp_enqueue_style( 'bsf-core-version-rollback-css' );
$product_details = get_brainstorm_product( $product_id );
$installed_version = isset( $product_details['version'] ) ? $product_details['version'] : '';
$product_versions = BSF_Rollback_Version::bsf_get_product_versions( $product_id ); // Get Remote versions
// Show versions above than latest install version of the product.
$sorted_versions = BSF_Rollback_Version::sort_product_versions( $product_versions, $installed_version );
if ( empty( $sorted_versions ) ) {
echo esc_html__( 'No Versions Found! ', 'bsf-core' );
return;
}
$product_name = isset( $product_details['name'] ) ? $product_details['name'] : '';
$white_label_name = bsf_get_white_lable_product_name( $product_id, $product_name );
?>
<div class="bsf-rollback-version">
<input type="hidden" name="product-name" id="bsf-product-name" value="<?php echo esc_attr( $white_label_name ); ?>">
<select class="bsf-rollback-version-select">
<?php
foreach ( $sorted_versions as $version ) {
?>
<option value="<?php echo esc_attr( $version ); ?>"><?php echo esc_html( $version ); ?> </option>
<?php
}
?>
</select>
<a data-placeholder-text=" <?php echo esc_html__( 'Rollback', 'bsf-core' ); ?>" href="<?php echo esc_url( add_query_arg( 'version_no', $sorted_versions[0], wp_nonce_url( admin_url( 'index.php?action=bsf_rollback&product_id=' . $product_id ), 'bsf_rollback' ) ) ); ?>"
data-placeholder-url="<?php echo esc_url( wp_nonce_url( admin_url( 'index.php?action=bsf_rollback&version_no=VERSION&product_id=' . $product_id ), 'bsf_rollback' ) ); ?>" class="button bsf-rollback-button"><?php echo esc_html__( 'Rollback', 'bsf-core' ); ?> </a>
</div>
<?php
}
/**
* Download Product Version.
*/
public function bsf_download_rollback_version() {
if ( ! current_user_can( 'update_plugins' ) ) {
return false;
}
if ( empty( $_GET['version_no'] ) || empty( $_GET['product_id'] ) || ! isset( $_GET['action'] ) ) {
return false;
}
check_admin_referer( 'bsf_rollback' );
$bsf_update_manager = new BSF_Update_Manager();
$version_no = sanitize_text_field( $_GET['version_no'] );
$product_id = sanitize_text_field( $_GET['product_id'] );
$product_details = get_brainstorm_product( $product_id );
$plugin_slug = ! empty( $product_details['slug'] ) ? $product_details['slug'] : '';
$plugin_name = ! empty( $product_details['template'] ) ? $product_details['template'] : '';
$bundled_plugin_name = ! empty( $product_details['init'] ) ? $product_details['init'] : '';
$purchase_key = $bsf_update_manager->get_purchse_key( $product_id );
$product_title = ! empty( $product_details['name'] ) ? $product_details['name'] : '';
$plugin_name = ! empty( $plugin_name ) ? $plugin_name : $bundled_plugin_name;
$download_params = array(
'version_no' => $version_no,
'purchase_key' => $purchase_key,
'site_url' => get_site_url(),
);
$download_url = bsf_get_api_site( false, true ) . 'download/' . $product_id . '?' . http_build_query( $download_params );
$rollback = new BSF_Rollback_Version(
array(
'version' => $version_no,
'plugin_name' => $plugin_name,
'plugin_slug' => $plugin_slug,
'package_url' => $download_url,
'product_title' => $product_title,
'product_id' => $product_id,
)
);
$rollback->run();
// Delete product versions transient data after update.
bsf_clear_versions_cache( $product_id );
wp_die();
}
/**
* Load Scripts
*
* @since 1.0.0
*
* @param string $hook Current Hook.
* @return void
*/
public function load_scripts( $hook = '' ) {
wp_register_script( 'bsf-core-version-rollback', bsf_core_url( '/assets/js/version-rollback.js' ), array( 'jquery' ), BSF_UPDATER_VERSION, true );
wp_register_style( 'bsf-core-version-rollback-css', bsf_core_url( '/assets/css/rollback-version.css' ), array(), BSF_UPDATER_VERSION );
}
/**
* Version rollback Confirmation popup.
*
* @since 1.0.0
*/
public function rollback_version_popup() {
// This is set to fix the duplicate markup on page load.
if ( 1 !== self::$reload_page_cache ) {
return;
}
self::$reload_page_cache = 0;
?>
<div class="bsf-confirm-rollback-popup" style="display:none;">
<div class="bsf-core-rollback-overlay"></div>
<div class="bsf-confirm-rollback-popup-content">
<h3 class="bsf-rollback-heading bsf-confirm-heading" data-text="<?php esc_html_e( 'Rollback #PRODUCT_NAME# Version', 'bsf-core' ); ?>"></h3>
<p class="bsf-confirm-text bsf-rollback-text" data-text="<?php esc_html_e( 'Are you sure you want to rollback #PRODUCT_NAME# to version #VERSION#?', 'bsf-core' ); ?>" ></p>
<div class="bsf-confirm-rollback-popup-buttons-wrapper">
<button class="button bsf-product-license button-default bsf-confirm-cancel"><?php esc_html_e( 'Cancel', 'bsf-core' ); ?></button>
<button class="button button-primary bsf-confirm-ok"><?php esc_html_e( 'Continue', 'bsf-core' ); ?></button>
</div>
</div>
</div>
<?php
}
}
new BSF_Rollback_Version_Manager();
/**
* Render Rollback versoin form.
*
* @param string $product_id Product ID.
*/
function bsf_get_version_rollback_form( $product_id ) {
if ( ! bsf_display_rollback_version_form( $product_id ) ) {
return false;
}
$instance = new BSF_Rollback_Version_Manager();
$instance->render_rollback_version_form( $product_id );
}
@@ -1,113 +1,113 @@
<?php
/**
* WP CLI Commands to manage Brainstorm Force products.
*
* @package bsf-core
*/
/**
* Class BSF_WP_CLI_Command
*/
class BSF_WP_CLI_Command extends WP_CLI_Command {
/**
* BSF_License Manager instance.
*
* @var $license_manager
*/
private $license_manager = '';
/**
* Initiator.
*/
public function __construct() {
$this->license_manager = new BSF_License_Manager();
}
/**
* WP CLI Command to activate and deactivate licenses for brainstormforce products.
*
* ## OPTIONS
*
* <action>
* activate or deactivate
*
* <priduct-id>
* Product id is unique for each brainstorm product, it can be found in the file <product-root-directory>/admin/.bsf.yml
*
* <license-key>
* Your purchase key.
*
* ## EXAMPLES
*
* 1. wp brainstormforce license activate uabb <purchase-key>
* - This will activate the license for plugin Ultimate Addons for beaver builder with purchase key <purchase-key>
* 2. wp brainstormforce license deactivate uabb <purchase-key>
* - This will deactivate the license for plugin Ultimate Addons for beaver builder with purchase key <purchase-key>
*
* @param array $args Arguments.
* @param array $assoc_args Associative Arguments.
*/
public function license( $args, $assoc_args ) {
if ( isset( $args[0] ) && 'activate' === $args[0] || 'deactivate' === $args[0] ) {
$action = $args[0];
} else {
WP_CLI::error( 'Please enter the correct action.' );
}
if ( isset( $args[1] ) ) {
$poduct_id = $args[1];
} else {
WP_CLI::error( 'Please enter a product id.' );
}
if ( isset( $args[2] ) ) {
$purchase_key = $args[2];
} else {
WP_CLI::error( 'Please enter the purchase key.' );
}
// Setup brainstorm_products data.
init_bsf_core();
$_POST = array(
'bsf_license_manager' => array(
'license_key' => $purchase_key,
'product_id' => $poduct_id,
),
);
$bsf_action = '';
if ( 'activate' === $action ) {
$bsf_action = 'bsf_license_activation';
$_POST['bsf_activate_license'] = true;
$_POST['bsf_graupi_nonce'] = wp_create_nonce( 'bsf_license_activation_deactivation_nonce' );
$this->license_manager->bsf_activate_license();
} else {
$bsf_action = 'bsf_license_deactivation';
$_POST['bsf_deactivate_license'] = true;
$_POST['bsf_graupi_nonce'] = wp_create_nonce( 'bsf_license_activation_deactivation_nonce' );
$this->license_manager->bsf_deactivate_license();
}
if ( '' !== $bsf_action ) {
if ( isset( $_POST[ $bsf_action ]['success'] ) && ( true === $_POST[ $bsf_action ]['success'] || 'true' === $_POST[ $bsf_action ]['success'] ) && isset( $_POST['bsf_graupi_nonce'] ) && wp_verify_nonce( $_POST['bsf_graupi_nonce'], 'bsf_license_activation_deactivation_nonce' ) ) {
$success_message = esc_attr( $_POST[ $bsf_action ]['message'] );
WP_CLI::success( $success_message );
} else {
$error_message = esc_attr( $_POST[ $bsf_action ]['message'] );
WP_CLI::error( $error_message );
}
}
}
}
if ( class_exists( 'WP_CLI' ) ) {
WP_CLI::add_command( 'brainstormforce', 'BSF_WP_CLI_Command' );
}
<?php
/**
* WP CLI Commands to manage Brainstorm Force products.
*
* @package bsf-core
*/
/**
* Class BSF_WP_CLI_Command
*/
class BSF_WP_CLI_Command extends WP_CLI_Command {
/**
* BSF_License Manager instance.
*
* @var $license_manager
*/
private $license_manager = '';
/**
* Initiator.
*/
public function __construct() {
$this->license_manager = new BSF_License_Manager();
}
/**
* WP CLI Command to activate and deactivate licenses for brainstormforce products.
*
* ## OPTIONS
*
* <action>
* activate or deactivate
*
* <priduct-id>
* Product id is unique for each brainstorm product, it can be found in the file <product-root-directory>/admin/.bsf.yml
*
* <license-key>
* Your purchase key.
*
* ## EXAMPLES
*
* 1. wp brainstormforce license activate uabb <purchase-key>
* - This will activate the license for plugin Ultimate Addons for beaver builder with purchase key <purchase-key>
* 2. wp brainstormforce license deactivate uabb <purchase-key>
* - This will deactivate the license for plugin Ultimate Addons for beaver builder with purchase key <purchase-key>
*
* @param array $args Arguments.
* @param array $assoc_args Associative Arguments.
*/
public function license( $args, $assoc_args ) {
if ( isset( $args[0] ) && 'activate' === $args[0] || 'deactivate' === $args[0] ) {
$action = $args[0];
} else {
WP_CLI::error( 'Please enter the correct action.' );
}
if ( isset( $args[1] ) ) {
$poduct_id = $args[1];
} else {
WP_CLI::error( 'Please enter a product id.' );
}
if ( isset( $args[2] ) ) {
$purchase_key = $args[2];
} else {
WP_CLI::error( 'Please enter the purchase key.' );
}
// Setup brainstorm_products data.
init_bsf_core();
$_POST = array(
'bsf_license_manager' => array(
'license_key' => $purchase_key,
'product_id' => $poduct_id,
),
);
$bsf_action = '';
if ( 'activate' === $action ) {
$bsf_action = 'bsf_license_activation';
$_POST['bsf_activate_license'] = true;
$_POST['bsf_graupi_nonce'] = wp_create_nonce( 'bsf_license_activation_deactivation_nonce' );
$this->license_manager->bsf_activate_license();
} else {
$bsf_action = 'bsf_license_deactivation';
$_POST['bsf_deactivate_license'] = true;
$_POST['bsf_graupi_nonce'] = wp_create_nonce( 'bsf_license_activation_deactivation_nonce' );
$this->license_manager->bsf_deactivate_license();
}
if ( '' !== $bsf_action ) {
if ( isset( $_POST[ $bsf_action ]['success'] ) && ( true === $_POST[ $bsf_action ]['success'] || 'true' === $_POST[ $bsf_action ]['success'] ) && isset( $_POST['bsf_graupi_nonce'] ) && wp_verify_nonce( $_POST['bsf_graupi_nonce'], 'bsf_license_activation_deactivation_nonce' ) ) {
$success_message = esc_attr( $_POST[ $bsf_action ]['message'] );
WP_CLI::success( $success_message );
} else {
$error_message = esc_attr( $_POST[ $bsf_action ]['message'] );
WP_CLI::error( $error_message );
}
}
}
}
if ( class_exists( 'WP_CLI' ) ) {
WP_CLI::add_command( 'brainstormforce', 'BSF_WP_CLI_Command' );
}
@@ -1,117 +1,117 @@
<?php
/**
* BSF Core REST API
*
* @package bsf-core
*/
/**
* License Activation/Deactivation REST API.
*/
class Bsf_Core_Rest {
/**
* Member Variable
*
* @var instance
*/
private static $instance;
/**
* The namespace of this controller's route.
*
* @var string
*/
public $namespace;
/**
* The base of this controller's route.
*
* @var string
*/
public $rest_base;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor.
*/
public function __construct() {
$this->namespace = 'bsf-core/v1';
$this->rest_base = '/license';
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
}
/**
* Register the routes for the objects of the controller.
*/
public function register_routes() {
register_rest_route(
$this->namespace,
$this->rest_base . '/activate',
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'activate_license' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
'args' => array(
'product-id' => array(
'type' => 'string',
'required' => true,
'sanitize_callback' => 'sanitize_text_field',
),
'license-key' => array(
'type' => 'string',
'required' => true,
'sanitize_callback' => 'sanitize_text_field',
),
),
)
);
}
/**
* Check if a given request has access to activate license.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function get_items_permissions_check( $request ) {
if ( current_user_can( 'manage_options' ) ) {
return true;
}
return false;
}
/**
* Activate License Key.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response Rest Response with access key.
*/
public function activate_license( $request ) {
$product_id = $request->get_param( 'product-id' );
$license_key = $request->get_param( 'license-key' );
$data = array(
'privacy_consent' => true,
'terms_conditions_consent' => true,
'product_id' => $product_id,
'license_key' => $license_key,
);
return rest_ensure_response( BSF_License_Manager::instance()->bsf_process_license_activation( $data ) );
}
}
Bsf_Core_Rest::get_instance();
<?php
/**
* BSF Core REST API
*
* @package bsf-core
*/
/**
* License Activation/Deactivation REST API.
*/
class Bsf_Core_Rest {
/**
* Member Variable
*
* @var instance
*/
private static $instance;
/**
* The namespace of this controller's route.
*
* @var string
*/
public $namespace;
/**
* The base of this controller's route.
*
* @var string
*/
public $rest_base;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor.
*/
public function __construct() {
$this->namespace = 'bsf-core/v1';
$this->rest_base = '/license';
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
}
/**
* Register the routes for the objects of the controller.
*/
public function register_routes() {
register_rest_route(
$this->namespace,
$this->rest_base . '/activate',
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'activate_license' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
'args' => array(
'product-id' => array(
'type' => 'string',
'required' => true,
'sanitize_callback' => 'sanitize_text_field',
),
'license-key' => array(
'type' => 'string',
'required' => true,
'sanitize_callback' => 'sanitize_text_field',
),
),
)
);
}
/**
* Check if a given request has access to activate license.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function get_items_permissions_check( $request ) {
if ( current_user_can( 'manage_options' ) ) {
return true;
}
return false;
}
/**
* Activate License Key.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response Rest Response with access key.
*/
public function activate_license( $request ) {
$product_id = $request->get_param( 'product-id' );
$license_key = $request->get_param( 'license-key' );
$data = array(
'privacy_consent' => true,
'terms_conditions_consent' => true,
'product_id' => $product_id,
'license_key' => $license_key,
);
return rest_ensure_response( BSF_License_Manager::instance()->bsf_process_license_activation( $data ) );
}
}
Bsf_Core_Rest::get_instance();
@@ -1,98 +1,98 @@
<?php
/**
* BSF Core Update
*
* @package Astra
* @author Astra
* @copyright Copyright (c) 2020, Astra
* @link http://wpastra.com/
* @since Astra 1.0.0
*/
if ( ! class_exists( 'BSF_Core_Update' ) ) {
/**
* BSF_Core_Update initial setup
*
* @since 1.0.0
*/
class BSF_Core_Update {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
// Theme Updates.
add_action( 'admin_init', __CLASS__ . '::init', 0 );
add_filter( 'all_plugins', array( $this, 'update_products_slug' ), 10, 1 );
}
/**
* Implement theme update logic.
*
* @since 1.0.0
*/
public static function init() {
do_action( 'astra_update_before' );
// Get auto saved version number.
$saved_version = get_option( 'bsf-updater-version', false );
// If equals then return.
if ( version_compare( $saved_version, BSF_UPDATER_VERSION, '=' ) ) {
return;
}
// // Update auto saved version number.
update_option( 'bsf-updater-version', BSF_UPDATER_VERSION );
do_action( 'astra_update_after' );
}
/**
* Update bsf product slug in WP installed plugins data which will be used in enable/disablestaged updates products.
*
* @param array $plugins All installed plugins.
*
* @return array
*/
public function update_products_slug( $plugins ) {
$bsf_products = bsf_get_brainstorm_products( true );
foreach ( $bsf_products as $product => $data ) {
$plugin_file = isset( $data['template'] ) ? sanitize_text_field( $data['template'] ) : '';
if ( isset( $plugins[ $plugin_file ] ) && ! empty( $data['slug'] ) ) {
$plugins[ $plugin_file ]['slug'] = $data['slug'];
}
}
return $plugins;
}
}
}
/**
* Kicking this off by calling 'get_instance()' method
*/
BSF_Core_Update::get_instance();
<?php
/**
* BSF Core Update
*
* @package Astra
* @author Astra
* @copyright Copyright (c) 2020, Astra
* @link http://wpastra.com/
* @since Astra 1.0.0
*/
if ( ! class_exists( 'BSF_Core_Update' ) ) {
/**
* BSF_Core_Update initial setup
*
* @since 1.0.0
*/
class BSF_Core_Update {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
// Theme Updates.
add_action( 'admin_init', __CLASS__ . '::init', 0 );
add_filter( 'all_plugins', array( $this, 'update_products_slug' ), 10, 1 );
}
/**
* Implement theme update logic.
*
* @since 1.0.0
*/
public static function init() {
do_action( 'astra_update_before' );
// Get auto saved version number.
$saved_version = get_option( 'bsf-updater-version', false );
// If equals then return.
if ( version_compare( $saved_version, BSF_UPDATER_VERSION, '=' ) ) {
return;
}
// // Update auto saved version number.
update_option( 'bsf-updater-version', BSF_UPDATER_VERSION );
do_action( 'astra_update_after' );
}
/**
* Update bsf product slug in WP installed plugins data which will be used in enable/disablestaged updates products.
*
* @param array $plugins All installed plugins.
*
* @return array
*/
public function update_products_slug( $plugins ) {
$bsf_products = bsf_get_brainstorm_products( true );
foreach ( $bsf_products as $product => $data ) {
$plugin_file = isset( $data['template'] ) ? sanitize_text_field( $data['template'] ) : '';
if ( isset( $plugins[ $plugin_file ] ) && ! empty( $data['slug'] ) ) {
$plugins[ $plugin_file ]['slug'] = $data['slug'];
}
}
return $plugins;
}
}
}
/**
* Kicking this off by calling 'get_instance()' method
*/
BSF_Core_Update::get_instance();
@@ -1,89 +1,89 @@
<?php
/**
* BSF extension installer class file.
*
* @package bsf-core
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* BSF_Extension_Installer Extension installer.
*/
class BSF_Extension_Installer {
/**
* Constructor
*/
public function __construct() {
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
add_action( 'wp_ajax_bsf-extention-activate', array( $this, 'activate_plugin' ) );
}
/**
* Load scripts needed for extension installer.
*
* @param hook $hook current page hook.
* @return void
*/
public function load_scripts( $hook ) {
$bsf_ext_inst = apply_filters( 'bsf_extension_installer_screens', array( 'bsf-extensions' ), $hook );
foreach ( $bsf_ext_inst as $key => $value ) {
if ( false !== strpos( $hook, $value ) ) {
wp_register_script( 'bsf-extension-installer', bsf_core_url( '/assets/js/extension-installer.js' ), array( 'jquery', 'wp-util', 'updates' ), BSF_UPDATER_VERSION, true );
wp_enqueue_script( 'bsf-extension-installer' );
}
}
}
/**
* Activates plugin.
*
* @return void
*/
public function activate_plugin() {
if ( ! wp_verify_nonce( $_POST['security'], 'bsf_activate_extension_nonce' ) ) {
wp_send_json_error(
array(
'success' => false,
'message' => __( 'You are not authorized to perform this action.', 'bsf' ),
)
);
}
if ( ! current_user_can( 'install_plugins' ) || ! isset( $_POST['init'] ) || ! $_POST['init'] ) {
wp_send_json_error(
array(
'success' => false,
'message' => __( 'No plugin specified', 'bsf' ),
)
);
}
$plugin_init = ( isset( $_POST['init'] ) ) ? esc_attr( $_POST['init'] ) : '';
$activate = activate_plugin( $plugin_init, '', false, true );
if ( is_wp_error( $activate ) ) {
wp_send_json_error(
array(
'success' => false,
'message' => $activate->get_error_message(),
)
);
}
wp_send_json_success(
array(
'success' => true,
'message' => __( 'Plugin Activated', 'bsf' ),
)
);
}
}
new BSF_Extension_Installer();
<?php
/**
* BSF extension installer class file.
*
* @package bsf-core
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* BSF_Extension_Installer Extension installer.
*/
class BSF_Extension_Installer {
/**
* Constructor
*/
public function __construct() {
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
add_action( 'wp_ajax_bsf-extention-activate', array( $this, 'activate_plugin' ) );
}
/**
* Load scripts needed for extension installer.
*
* @param hook $hook current page hook.
* @return void
*/
public function load_scripts( $hook ) {
$bsf_ext_inst = apply_filters( 'bsf_extension_installer_screens', array( 'bsf-extensions' ), $hook );
foreach ( $bsf_ext_inst as $key => $value ) {
if ( false !== strpos( $hook, $value ) ) {
wp_register_script( 'bsf-extension-installer', bsf_core_url( '/assets/js/extension-installer.js' ), array( 'jquery', 'wp-util', 'updates' ), BSF_UPDATER_VERSION, true );
wp_enqueue_script( 'bsf-extension-installer' );
}
}
}
/**
* Activates plugin.
*
* @return void
*/
public function activate_plugin() {
if ( ! wp_verify_nonce( $_POST['security'], 'bsf_activate_extension_nonce' ) ) {
wp_send_json_error(
array(
'success' => false,
'message' => __( 'You are not authorized to perform this action.', 'bsf' ),
)
);
}
if ( ! current_user_can( 'install_plugins' ) || ! isset( $_POST['init'] ) || ! $_POST['init'] ) {
wp_send_json_error(
array(
'success' => false,
'message' => __( 'No plugin specified', 'bsf' ),
)
);
}
$plugin_init = ( isset( $_POST['init'] ) ) ? esc_attr( $_POST['init'] ) : '';
$activate = activate_plugin( $plugin_init, '', false, true );
if ( is_wp_error( $activate ) ) {
wp_send_json_error(
array(
'success' => false,
'message' => $activate->get_error_message(),
)
);
}
wp_send_json_success(
array(
'success' => true,
'message' => __( 'Plugin Activated', 'bsf' ),
)
);
}
}
new BSF_Extension_Installer();
@@ -1,242 +1,242 @@
<?php
/**
* BSF Rollback Version
*
* @package bsf-core
* @author Brainstorm Force
* @link http://wpastra.com/
*/
/**
* BSF_Core_Update initial setup
*/
class BSF_Rollback_Version {
/**
* Package URL.
*
* Holds the package URL.
* This will be the actual download URL od zip file.
*
* @access protected
*
* @var string Package URL.
*/
protected $package_url;
/**
* Product URL.
*
* @access protected
* @var string Product URL.
*/
protected $product_url;
/**
* Version.
*
* Holds the version.
*
* @access protected
*
* @var string Package URL.
*/
protected $version;
/**
* Plugin name.
*
* Holds the plugin name.
*
* @access protected
*
* @var string Plugin name.
*/
protected $plugin_name;
/**
* Plugin slug.
*
* Holds the plugin slug.
*
* @access protected
*
* @var string Plugin slug.
*/
protected $plugin_slug;
/**
* Product Title.
*
* Holds the Product Title.
*
* @access protected
*
* @var string Plugin Title.
*/
protected $product_title;
/**
* HOlds the Product ID.
*
* @access protected
* @var string Product ID.
*/
protected $product_id;
/**
*
* Initializing Rollback.
*
* @access public
*
* @param array $args Optional.Rollback arguments. Default is an empty array.
*/
public function __construct( $args = array() ) {
foreach ( $args as $key => $value ) {
$this->{$key} = $value;
}
}
/**
* Apply package.
*
* @since 1.0.0
* @access protected
*/
protected function apply_package() {
$update_products = get_site_transient( 'update_plugins' );
if ( ! is_object( $update_products ) ) {
$update_products = new stdClass();
}
$product_info = new stdClass();
$product_info->new_version = $this->version;
$product_info->slug = $this->plugin_slug;
$product_info->package = $this->package_url; // This will be the actual download URL of zip file..
$product_info->url = $this->product_url;
$update_products->response[ $this->plugin_name ] = $product_info;
set_site_transient( 'update_plugins', $update_products );
}
/**
* Upgrade.
*
* Run WordPress upgrade to Rollback to previous version.
*
* @since 1.0.0
* @access protected
*/
protected function upgrade() {
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader_args = array(
'url' => 'update.php?action=upgrade-plugin&plugin=' . rawurlencode( $this->plugin_name ),
'plugin' => $this->plugin_name,
'nonce' => 'upgrade-plugin_' . $this->plugin_name,
'title' => apply_filters( 'bsf_rollback_' . $this->product_id . '_title', '<h1>Rollback ' . bsf_get_white_lable_product_name( $this->product_id, $this->product_title ) . ' to version ' . $this->version . ' </h1>' ),
);
$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( $upgrader_args ) );
$upgrader->upgrade( $this->plugin_name );
}
/**
*
* Rollback to previous versions.
*
* @since 1.0.0
* @access public
*/
public function run() {
$this->apply_package();
$this->upgrade();
}
/**
* Get All versions of product.
*
* @param string $product_id Product ID.
*/
public static function bsf_get_product_versions( $product_id ) {
if ( empty( $product_id ) ) {
return array();
}
// Check is transient is expire or User has Enalbed/Disabled the beta version.
$versions_transient = get_site_transient( 'bsf-product-versions-' . $product_id );
if ( false !== $versions_transient && false === self::is_beta_enabled_rollback( $product_id ) ) {
return $versions_transient;
}
$per_page = apply_filters( 'bsf_show_versions_to_rollback_' . $product_id, 10 );
$path = bsf_get_api_site( false, true ) . 'versions/' . $product_id . '?per_page=' . $per_page;
if ( BSF_Update_Manager::bsf_allow_beta_updates( $product_id ) ) {
$path = add_query_arg( 'include_beta', 'true', $path );
}
$response = wp_remote_get(
$path,
array(
'timeout' => '10',
)
);
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 ) {
return array();
}
$response_versions = json_decode( wp_remote_retrieve_body( $response ), true );
// Cache product version for 24 hrs.
set_site_transient( 'bsf-product-versions-' . $product_id, $response_versions, 24 * HOUR_IN_SECONDS );
return $response_versions;
}
/**
* This will filter the versions and return the versions less than current installed version.
*
* @param array $version_arr array of versions.
* @param string $current_version Current install version.
*
* @return array
*/
public static function sort_product_versions( $version_arr, $current_version ) {
$rollback_versions = array();
foreach ( $version_arr as $version ) {
if ( version_compare( $version, $current_version, '>=' ) ) {
continue;
}
$rollback_versions[] = $version;
}
return $rollback_versions;
}
/**
* This function is added to update the trasient data of product version on beta update enabled/disabled action.
* This will set the flag in db options that should beta versions include/removed in the rollback versions list based on enabled/disabled beta updates for the product.
*
* @param string $product_id Product ID.
*
* @return bool
*/
public static function is_beta_enabled_rollback( $product_id ) {
$allow_beta_update = BSF_Update_Manager::bsf_allow_beta_updates( $product_id );
$is_beta_enable = ( false === $allow_beta_update ) ? '0' : '1';
// Set the initial flag for is beta enelbled/ disabled.
if ( false === get_option( 'is_beta_enable_rollback_' . $product_id ) ) {
update_option( 'is_beta_enable_rollback_' . $product_id, $is_beta_enable );
return false;
}
// If user has enalbed/ disabled beta update then upadate the rollback version transient data.
if ( get_option( 'is_beta_enable_rollback_' . $product_id ) !== $is_beta_enable ) {
update_option( 'is_beta_enable_rollback_' . $product_id, $is_beta_enable );
return true;
}
return false;
}
}
<?php
/**
* BSF Rollback Version
*
* @package bsf-core
* @author Brainstorm Force
* @link http://wpastra.com/
*/
/**
* BSF_Core_Update initial setup
*/
class BSF_Rollback_Version {
/**
* Package URL.
*
* Holds the package URL.
* This will be the actual download URL od zip file.
*
* @access protected
*
* @var string Package URL.
*/
protected $package_url;
/**
* Product URL.
*
* @access protected
* @var string Product URL.
*/
protected $product_url;
/**
* Version.
*
* Holds the version.
*
* @access protected
*
* @var string Package URL.
*/
protected $version;
/**
* Plugin name.
*
* Holds the plugin name.
*
* @access protected
*
* @var string Plugin name.
*/
protected $plugin_name;
/**
* Plugin slug.
*
* Holds the plugin slug.
*
* @access protected
*
* @var string Plugin slug.
*/
protected $plugin_slug;
/**
* Product Title.
*
* Holds the Product Title.
*
* @access protected
*
* @var string Plugin Title.
*/
protected $product_title;
/**
* HOlds the Product ID.
*
* @access protected
* @var string Product ID.
*/
protected $product_id;
/**
*
* Initializing Rollback.
*
* @access public
*
* @param array $args Optional.Rollback arguments. Default is an empty array.
*/
public function __construct( $args = array() ) {
foreach ( $args as $key => $value ) {
$this->{$key} = $value;
}
}
/**
* Apply package.
*
* @since 1.0.0
* @access protected
*/
protected function apply_package() {
$update_products = get_site_transient( 'update_plugins' );
if ( ! is_object( $update_products ) ) {
$update_products = new stdClass();
}
$product_info = new stdClass();
$product_info->new_version = $this->version;
$product_info->slug = $this->plugin_slug;
$product_info->package = $this->package_url; // This will be the actual download URL of zip file..
$product_info->url = $this->product_url;
$update_products->response[ $this->plugin_name ] = $product_info;
set_site_transient( 'update_plugins', $update_products );
}
/**
* Upgrade.
*
* Run WordPress upgrade to Rollback to previous version.
*
* @since 1.0.0
* @access protected
*/
protected function upgrade() {
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader_args = array(
'url' => 'update.php?action=upgrade-plugin&plugin=' . rawurlencode( $this->plugin_name ),
'plugin' => $this->plugin_name,
'nonce' => 'upgrade-plugin_' . $this->plugin_name,
'title' => apply_filters( 'bsf_rollback_' . $this->product_id . '_title', '<h1>Rollback ' . bsf_get_white_lable_product_name( $this->product_id, $this->product_title ) . ' to version ' . $this->version . ' </h1>' ),
);
$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( $upgrader_args ) );
$upgrader->upgrade( $this->plugin_name );
}
/**
*
* Rollback to previous versions.
*
* @since 1.0.0
* @access public
*/
public function run() {
$this->apply_package();
$this->upgrade();
}
/**
* Get All versions of product.
*
* @param string $product_id Product ID.
*/
public static function bsf_get_product_versions( $product_id ) {
if ( empty( $product_id ) ) {
return array();
}
// Check is transient is expire or User has Enalbed/Disabled the beta version.
$versions_transient = get_site_transient( 'bsf-product-versions-' . $product_id );
if ( false !== $versions_transient && false === self::is_beta_enabled_rollback( $product_id ) ) {
return $versions_transient;
}
$per_page = apply_filters( 'bsf_show_versions_to_rollback_' . $product_id, 10 );
$path = bsf_get_api_site( false, true ) . 'versions/' . $product_id . '?per_page=' . $per_page;
if ( BSF_Update_Manager::bsf_allow_beta_updates( $product_id ) ) {
$path = add_query_arg( 'include_beta', 'true', $path );
}
$response = wp_remote_get(
$path,
array(
'timeout' => '10',
)
);
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 ) {
return array();
}
$response_versions = json_decode( wp_remote_retrieve_body( $response ), true );
// Cache product version for 24 hrs.
set_site_transient( 'bsf-product-versions-' . $product_id, $response_versions, 24 * HOUR_IN_SECONDS );
return $response_versions;
}
/**
* This will filter the versions and return the versions less than current installed version.
*
* @param array $version_arr array of versions.
* @param string $current_version Current install version.
*
* @return array
*/
public static function sort_product_versions( $version_arr, $current_version ) {
$rollback_versions = array();
foreach ( $version_arr as $version ) {
if ( version_compare( $version, $current_version, '>=' ) ) {
continue;
}
$rollback_versions[] = $version;
}
return $rollback_versions;
}
/**
* This function is added to update the trasient data of product version on beta update enabled/disabled action.
* This will set the flag in db options that should beta versions include/removed in the rollback versions list based on enabled/disabled beta updates for the product.
*
* @param string $product_id Product ID.
*
* @return bool
*/
public static function is_beta_enabled_rollback( $product_id ) {
$allow_beta_update = BSF_Update_Manager::bsf_allow_beta_updates( $product_id );
$is_beta_enable = ( false === $allow_beta_update ) ? '0' : '1';
// Set the initial flag for is beta enelbled/ disabled.
if ( false === get_option( 'is_beta_enable_rollback_' . $product_id ) ) {
update_option( 'is_beta_enable_rollback_' . $product_id, $is_beta_enable );
return false;
}
// If user has enalbed/ disabled beta update then upadate the rollback version transient data.
if ( get_option( 'is_beta_enable_rollback_' . $product_id ) !== $is_beta_enable ) {
update_option( 'is_beta_enable_rollback_' . $product_id, $is_beta_enable );
return true;
}
return false;
}
}
@@ -1,26 +1,26 @@
{
"name": "brainstormforce/bsf-core",
"type": "wordpress-plugin",
"description": "WordPress updater for Premium Products from Brainstorm Force",
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "Brainstorm Force",
"email": "hello@bsf.io"
}
],
"require": {
"composer/installers": "^2.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"phpcompatibility/phpcompatibility-wp": "*",
"wp-cli/dist-archive-command": "^2.0",
"wp-coding-standards/wpcs": "dev-master"
},
"minimum-stability": "stable",
"scripts": {
"format": "vendor/bin/phpcbf --standard=phpcs.xml.dist",
"lint": "vendor/bin/phpcs --standard=phpcs.xml.dist"
}
}
{
"name": "brainstormforce/bsf-core",
"type": "wordpress-plugin",
"description": "WordPress updater for Premium Products from Brainstorm Force",
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "Brainstorm Force",
"email": "hello@bsf.io"
}
],
"require": {
"composer/installers": "^2.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"phpcompatibility/phpcompatibility-wp": "*",
"wp-cli/dist-archive-command": "^2.0",
"wp-coding-standards/wpcs": "dev-master"
},
"minimum-stability": "stable",
"scripts": {
"format": "vendor/bin/phpcbf --standard=phpcs.xml.dist",
"lint": "vendor/bin/phpcs --standard=phpcs.xml.dist"
}
}
@@ -1,292 +1,292 @@
<?php
/**
* System Info File.
*
* @author Brainstorm Force
* @package bsf-core
*/
/**
* Display system info.
*/
function bsf_systeminfo() {
?>
<table class="wp-list-table widefat fixed bsf-sys-info">
<tbody>
<tr class="alternate">
<th colspan="2"><?php esc_html_e( 'WordPress Environment', 'bsf' ); ?></th>
</tr>
<tr>
<td>Home URL</td>
<td><?php echo esc_url( site_url() ); ?></td>
</tr>
<tr>
<td>Site URL</td>
<td><?php echo esc_url( site_url() ); ?></td>
</tr>
<tr>
<?php global $wp_version; ?>
<td>WP Version</td>
<td><?php echo floatval( $wp_version ); ?></td>
</tr>
<tr>
<td>Multisite</td>
<td><?php echo ( is_multisite() ) ? 'Yes' : 'No'; ?></td>
</tr>
<?php
$limit = (int) ini_get( 'memory_limit' );
$usage = function_exists( 'memory_get_usage' ) ? round( memory_get_usage() / 1024 / 1024, 2 ) : 0;
?>
<tr>
<td>Memory Usage</td>
<td>
<?php echo floatval( $usage ); ?>
MB of
<?php echo intval( $limit ); ?>
MB
</td>
</tr>
<tr>
<td>WP Memory Limit</td>
<td>
<?php echo intval( WP_MEMORY_LIMIT ); ?>
</td>
</tr>
<tr>
<td>WP Debug</td>
<td><?php echo ( WP_DEBUG ) ? 'Enabled' : 'Disabled'; ?></td>
</tr>
<tr>
<td>WP Lang</td>
<?php $currentlang = get_bloginfo( 'language' ); ?>
<td><?php echo esc_html( $currentlang ); ?></td>
</tr>
<tr>
<td>WP Uploads Directory</td>
<td>
<?php
$wp_up = wp_upload_dir();
echo ( is_writable( $wp_up['basedir'] ) ) ? 'Writable' : 'Readable';
?>
</td>
</tr>
<tr>
<td>BSF Updater Path</td>
<td>
<?php echo '(v' . esc_attr( BSF_UPDATER_VERSION ) . ') ' . esc_attr( BSF_UPDATER_PATH ); ?>
</td>
</tr>
<?php if ( defined( 'WPB_VC_VERSION' ) ) : ?>
<tr>
<td>vc_shortcode_output Filter</td>
<td>
<?php echo ( has_filter( 'vc_shortcode_output' ) ) ? 'Available' : 'Not Available'; ?>
</td>
</tr>
<?php endif; ?>
<?php
$mix = bsf_get_brainstorm_products( true );
$temp_constant = '';
if ( ! empty( $mix ) ) :
foreach ( $mix as $key => $product ) :
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
$constant = 'BSF_' . $constant . '_CHECK_UPDATES';
if ( defined( $constant ) && ( constant( $constant ) === 'false' || constant( $constant ) === false ) ) {
$temp_constant .= $constant . '<br/>';
continue;
}
endforeach;
endif;
if ( defined( 'BSF_CHECK_PRODUCT_UPDATES' ) && false === BSF_CHECK_PRODUCT_UPDATES ) {
$temp_constant .= 'BSF_CHECK_PRODUCT_UPDATES';
}
if ( '' !== $temp_constant ) {
if ( ! defined( 'BSF_RESTRICTED_UPDATES' ) ) {
define( 'BSF_RESTRICTED_UPDATES', $temp_constant );
}
}
?>
<?php if ( defined( 'BSF_RESTRICTED_UPDATES' ) ) : ?>
<tr>
<td>Restrited Updates Filter</td>
<td>
<?php echo esc_html( BSF_RESTRICTED_UPDATES ); ?>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<table class="wp-list-table widefat fixed bsf-sys-info">
<tbody>
<tr class="alternate">
<th colspan="2"><?php esc_html_e( 'Server Environment', 'bsf' ); ?></th>
</tr>
<tr>
<td>Server Info</td>
<td><?php echo esc_html( $_SERVER['SERVER_SOFTWARE'] ); ?></td>
</tr>
<tr>
<td>PHP Version</td>
<td><?php echo ( function_exists( 'phpversion' ) ) ? floatval( phpversion() ) : 'Not sure'; ?></td>
</tr>
<tr>
<td>MYSQL Version</td>
<td>
<?php
global $wpdb;
echo floatval( $wpdb->db_version() );
?>
</td>
</tr>
<tr>
<td>PHP Post Max Size</td>
<td><?php echo esc_attr( ini_get( 'post_max_size' ) ); ?></td>
</tr>
<tr>
<td>PHP Max Execution Time</td>
<td><?php echo esc_attr( ini_get( 'max_execution_time' ) ); ?> Seconds</td>
</tr>
<tr>
<td>PHP Max Input Vars</td>
<td><?php echo intval( ini_get( 'max_input_vars' ) ); // PHPCS:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound ?></td>
</tr>
<tr>
<td>Max Upload Size</td>
<td><?php echo intval( ini_get( 'upload_max_filesize' ) ); ?></td>
</tr>
<tr>
<td>Default Time Zone</td>
<td>
<?php
if ( date_default_timezone_get() ) {
echo esc_html( date_default_timezone_get() );
}
if ( ini_get( 'date.timezone' ) ) {
echo ' ' . esc_html( ini_get( 'date.timezone' ) );
}
?>
</td>
</tr>
<tr class="<?php echo ( ! function_exists( 'curl_version' ) ) ? 'bsf-alert' : ''; ?>">
<td>SimpleXML</td>
<td>
<?php
if ( extension_loaded( 'simplexml' ) ) {
echo 'SimpleXML extension is installed';
} else {
echo 'SimpleXML extension is not enabled.';
}
?>
</td>
</tr>
<tr class="<?php echo ( ! function_exists( 'curl_version' ) ) ? 'bsf-alert' : ''; ?>">
<td>cURL</td>
<td>
<?php
if ( function_exists( 'curl_version' ) ) {
$curl_info = curl_version();
?>
<div>Version : <strong><?php echo floatval( $curl_info['version'] ); ?></strong></div>
<div>SSL Version : <strong><?php echo floatval( $curl_info['ssl_version'] ); ?></strong></div>
<div>Host : <strong><?php echo esc_html( $curl_info['host'] ); ?></strong></div>
<?php
} else {
echo 'Not Enabled';
}
?>
</td>
</tr>
<?php
$connection = wp_remote_get( bsf_get_api_site() );
$support_class = ( is_wp_error( $connection ) || 200 !== wp_remote_retrieve_response_code( $connection ) ) ? 'bsf-alert' : '';
?>
<tr class="<?php echo esc_attr( $support_class ); ?>">
<td>Connection to Support API</td>
<td>
<?php
if ( is_wp_error( $connection ) || 200 !== wp_remote_retrieve_response_code( $connection ) ) {
echo 'Connection to Support API has error';
echo '<p class="description">Status Code: ' . esc_attr( wp_remote_retrieve_response_code( $connection ) ) . '</p>';
echo '<p class="description">Error Message: ' . esc_attr( $connection->get_error_message() ) . '</p>';
} else {
echo 'Connecion to Support API was successful';
echo '<p class="description">Status Code: ' . esc_attr( wp_remote_retrieve_response_code( $connection ) ) . '</p>';
}
?>
</td>
</tr>
</tbody>
</table>
<table class="wp-list-table widefat fixed bsf-sys-info">
<tbody>
<tr class="alternate">
<th colspan="2"><?php esc_html_e( 'Theme Information', 'bsf' ); ?></th>
</tr>
<?php $theme_data = wp_get_theme(); ?>
<tr>
<td>Name</td>
<td><?php echo esc_html( $theme_data->Name ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?></td>
</tr>
<tr>
<td>Version</td>
<td><?php echo floatval( $theme_data->Version ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?></td>
</tr>
<tr>
<td>Author</td>
<td>
<?php echo wp_kses_post( $theme_data->Author ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?>
</td>
</tr>
</tbody>
</table>
<table class="wp-list-table widefat fixed bsf-sys-info bsf-table-active-plugin">
<tbody>
<tr class="alternate">
<th colspan="4"><?php esc_html_e( 'Installed Plugins', 'bsf' ); ?></th>
</tr>
<?php
$plugins = get_plugins();
asort( $plugins );
foreach ( $plugins as $plugin_file => $plugin_data ) {
?>
<tr>
<td><?php echo esc_html( str_pad( $plugin_data['Title'], 30 ) ); ?></td>
<td>
<?php
if ( is_plugin_active( $plugin_file ) ) {
echo esc_html( str_pad( 'Active', 10 ) );
} else {
echo esc_html( str_pad( 'Inactive', 10 ) );
}
?>
</td>
<td><?php echo esc_html( str_pad( $plugin_data['Version'], 10 ) ); ?></td>
<td><?php echo esc_html( $plugin_data['Author'] ); ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
/**
* Get BSF systeminfo.
*/
function get_bsf_systeminfo() {
$table = '<div class="bsf-system-info-wrapper">';
ob_start();
bsf_systeminfo();
$table .= ob_get_clean();
$table .= '</div>';
return $table;
}
<?php
/**
* System Info File.
*
* @author Brainstorm Force
* @package bsf-core
*/
/**
* Display system info.
*/
function bsf_systeminfo() {
?>
<table class="wp-list-table widefat fixed bsf-sys-info">
<tbody>
<tr class="alternate">
<th colspan="2"><?php esc_html_e( 'WordPress Environment', 'bsf' ); ?></th>
</tr>
<tr>
<td>Home URL</td>
<td><?php echo esc_url( site_url() ); ?></td>
</tr>
<tr>
<td>Site URL</td>
<td><?php echo esc_url( site_url() ); ?></td>
</tr>
<tr>
<?php global $wp_version; ?>
<td>WP Version</td>
<td><?php echo floatval( $wp_version ); ?></td>
</tr>
<tr>
<td>Multisite</td>
<td><?php echo ( is_multisite() ) ? 'Yes' : 'No'; ?></td>
</tr>
<?php
$limit = (int) ini_get( 'memory_limit' );
$usage = function_exists( 'memory_get_usage' ) ? round( memory_get_usage() / 1024 / 1024, 2 ) : 0;
?>
<tr>
<td>Memory Usage</td>
<td>
<?php echo floatval( $usage ); ?>
MB of
<?php echo intval( $limit ); ?>
MB
</td>
</tr>
<tr>
<td>WP Memory Limit</td>
<td>
<?php echo intval( WP_MEMORY_LIMIT ); ?>
</td>
</tr>
<tr>
<td>WP Debug</td>
<td><?php echo ( WP_DEBUG ) ? 'Enabled' : 'Disabled'; ?></td>
</tr>
<tr>
<td>WP Lang</td>
<?php $currentlang = get_bloginfo( 'language' ); ?>
<td><?php echo esc_html( $currentlang ); ?></td>
</tr>
<tr>
<td>WP Uploads Directory</td>
<td>
<?php
$wp_up = wp_upload_dir();
echo ( is_writable( $wp_up['basedir'] ) ) ? 'Writable' : 'Readable';
?>
</td>
</tr>
<tr>
<td>BSF Updater Path</td>
<td>
<?php echo '(v' . esc_attr( BSF_UPDATER_VERSION ) . ') ' . esc_attr( BSF_UPDATER_PATH ); ?>
</td>
</tr>
<?php if ( defined( 'WPB_VC_VERSION' ) ) : ?>
<tr>
<td>vc_shortcode_output Filter</td>
<td>
<?php echo ( has_filter( 'vc_shortcode_output' ) ) ? 'Available' : 'Not Available'; ?>
</td>
</tr>
<?php endif; ?>
<?php
$mix = bsf_get_brainstorm_products( true );
$temp_constant = '';
if ( ! empty( $mix ) ) :
foreach ( $mix as $key => $product ) :
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
$constant = 'BSF_' . $constant . '_CHECK_UPDATES';
if ( defined( $constant ) && ( constant( $constant ) === 'false' || constant( $constant ) === false ) ) {
$temp_constant .= $constant . '<br/>';
continue;
}
endforeach;
endif;
if ( defined( 'BSF_CHECK_PRODUCT_UPDATES' ) && false === BSF_CHECK_PRODUCT_UPDATES ) {
$temp_constant .= 'BSF_CHECK_PRODUCT_UPDATES';
}
if ( '' !== $temp_constant ) {
if ( ! defined( 'BSF_RESTRICTED_UPDATES' ) ) {
define( 'BSF_RESTRICTED_UPDATES', $temp_constant );
}
}
?>
<?php if ( defined( 'BSF_RESTRICTED_UPDATES' ) ) : ?>
<tr>
<td>Restrited Updates Filter</td>
<td>
<?php echo esc_html( BSF_RESTRICTED_UPDATES ); ?>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<table class="wp-list-table widefat fixed bsf-sys-info">
<tbody>
<tr class="alternate">
<th colspan="2"><?php esc_html_e( 'Server Environment', 'bsf' ); ?></th>
</tr>
<tr>
<td>Server Info</td>
<td><?php echo esc_html( $_SERVER['SERVER_SOFTWARE'] ); ?></td>
</tr>
<tr>
<td>PHP Version</td>
<td><?php echo ( function_exists( 'phpversion' ) ) ? floatval( phpversion() ) : 'Not sure'; ?></td>
</tr>
<tr>
<td>MYSQL Version</td>
<td>
<?php
global $wpdb;
echo floatval( $wpdb->db_version() );
?>
</td>
</tr>
<tr>
<td>PHP Post Max Size</td>
<td><?php echo esc_attr( ini_get( 'post_max_size' ) ); ?></td>
</tr>
<tr>
<td>PHP Max Execution Time</td>
<td><?php echo esc_attr( ini_get( 'max_execution_time' ) ); ?> Seconds</td>
</tr>
<tr>
<td>PHP Max Input Vars</td>
<td><?php echo intval( ini_get( 'max_input_vars' ) ); // PHPCS:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound ?></td>
</tr>
<tr>
<td>Max Upload Size</td>
<td><?php echo intval( ini_get( 'upload_max_filesize' ) ); ?></td>
</tr>
<tr>
<td>Default Time Zone</td>
<td>
<?php
if ( date_default_timezone_get() ) {
echo esc_html( date_default_timezone_get() );
}
if ( ini_get( 'date.timezone' ) ) {
echo ' ' . esc_html( ini_get( 'date.timezone' ) );
}
?>
</td>
</tr>
<tr class="<?php echo ( ! function_exists( 'curl_version' ) ) ? 'bsf-alert' : ''; ?>">
<td>SimpleXML</td>
<td>
<?php
if ( extension_loaded( 'simplexml' ) ) {
echo 'SimpleXML extension is installed';
} else {
echo 'SimpleXML extension is not enabled.';
}
?>
</td>
</tr>
<tr class="<?php echo ( ! function_exists( 'curl_version' ) ) ? 'bsf-alert' : ''; ?>">
<td>cURL</td>
<td>
<?php
if ( function_exists( 'curl_version' ) ) {
$curl_info = curl_version();
?>
<div>Version : <strong><?php echo floatval( $curl_info['version'] ); ?></strong></div>
<div>SSL Version : <strong><?php echo floatval( $curl_info['ssl_version'] ); ?></strong></div>
<div>Host : <strong><?php echo esc_html( $curl_info['host'] ); ?></strong></div>
<?php
} else {
echo 'Not Enabled';
}
?>
</td>
</tr>
<?php
$connection = wp_remote_get( bsf_get_api_site() );
$support_class = ( is_wp_error( $connection ) || 200 !== wp_remote_retrieve_response_code( $connection ) ) ? 'bsf-alert' : '';
?>
<tr class="<?php echo esc_attr( $support_class ); ?>">
<td>Connection to Support API</td>
<td>
<?php
if ( is_wp_error( $connection ) || 200 !== wp_remote_retrieve_response_code( $connection ) ) {
echo 'Connection to Support API has error';
echo '<p class="description">Status Code: ' . esc_attr( wp_remote_retrieve_response_code( $connection ) ) . '</p>';
echo '<p class="description">Error Message: ' . esc_attr( $connection->get_error_message() ) . '</p>';
} else {
echo 'Connecion to Support API was successful';
echo '<p class="description">Status Code: ' . esc_attr( wp_remote_retrieve_response_code( $connection ) ) . '</p>';
}
?>
</td>
</tr>
</tbody>
</table>
<table class="wp-list-table widefat fixed bsf-sys-info">
<tbody>
<tr class="alternate">
<th colspan="2"><?php esc_html_e( 'Theme Information', 'bsf' ); ?></th>
</tr>
<?php $theme_data = wp_get_theme(); ?>
<tr>
<td>Name</td>
<td><?php echo esc_html( $theme_data->Name ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?></td>
</tr>
<tr>
<td>Version</td>
<td><?php echo floatval( $theme_data->Version ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?></td>
</tr>
<tr>
<td>Author</td>
<td>
<?php echo wp_kses_post( $theme_data->Author ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?>
</td>
</tr>
</tbody>
</table>
<table class="wp-list-table widefat fixed bsf-sys-info bsf-table-active-plugin">
<tbody>
<tr class="alternate">
<th colspan="4"><?php esc_html_e( 'Installed Plugins', 'bsf' ); ?></th>
</tr>
<?php
$plugins = get_plugins();
asort( $plugins );
foreach ( $plugins as $plugin_file => $plugin_data ) {
?>
<tr>
<td><?php echo esc_html( str_pad( $plugin_data['Title'], 30 ) ); ?></td>
<td>
<?php
if ( is_plugin_active( $plugin_file ) ) {
echo esc_html( str_pad( 'Active', 10 ) );
} else {
echo esc_html( str_pad( 'Inactive', 10 ) );
}
?>
</td>
<td><?php echo esc_html( str_pad( $plugin_data['Version'], 10 ) ); ?></td>
<td><?php echo esc_html( $plugin_data['Author'] ); ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
/**
* Get BSF systeminfo.
*/
function get_bsf_systeminfo() {
$table = '<div class="bsf-system-info-wrapper">';
ob_start();
bsf_systeminfo();
$table .= ob_get_clean();
$table .= '</div>';
return $table;
}
File diff suppressed because it is too large Load Diff
@@ -1,300 +1,300 @@
<?php
/**
* Admin functions for bsf core.
*
* @package BSF core
*/
/**
* Prevent direct access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
if ( ! function_exists( 'check_bsf_product_status' ) ) {
/**
* Get status of product.
*
* @param int $id product id.
* @return bool
*/
function check_bsf_product_status( $id ) {
$brainstrom_products = ( get_option( 'brainstrom_products' ) ) ? get_option( 'brainstrom_products' ) : array();
$bsf_product_themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
if ( empty( $brainstrom_products ) ) {
return false;
}
$status = false;
foreach ( $brainstrom_products as $products ) {
foreach ( $products as $key => $product ) {
if ( $product['id'] === $id ) {
$status = ( isset( $product['status'] ) ) ? $product['status'] : '';
break;
}
}
}
return $status;
}
}
if ( ! function_exists( 'get_bundled_plugins' ) ) {
/**
* Retrieves bundled plugin data.
*
* @param string $template product template.
* @return void
*/
function get_bundled_plugins( $template = '' ) {
global $ultimate_referer;
$brainstrom_products = get_option( 'brainstrom_products', array() );
$prd_ids = array();
// If brainstrom_products is not yet set, call bsf core init.
if ( is_array( $brainstrom_products ) ) {
init_bsf_core();
$brainstrom_products = get_option( 'brainstrom_products', array() );
}
foreach ( $brainstrom_products as $key => $value ) {
foreach ( $value as $key => $value2 ) {
array_push( $prd_ids, $key );
}
}
$path = bsf_get_api_url() . '?referer=' . $ultimate_referer;
$data = array(
'action' => 'bsf_fetch_brainstorm_products',
'id' => $prd_ids,
);
$request = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '10',
)
);
// Request http URL if the https version fails.
if ( is_wp_error( $request ) && wp_remote_retrieve_response_code( $request ) !== 200 ) {
$path = bsf_get_api_url( true ) . '?referer=' . $ultimate_referer;
$request = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '8',
)
);
}
if ( ! is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) === 200 ) {
$result = json_decode( $request['body'] );
$bundled = array();
$simple = array();
if ( ! empty( $result ) ) {
if ( ! empty( $result->bundled ) ) {
$bundled = $result->bundled;
}
if ( ! empty( $result->simple ) ) {
$simple = $result->simple;
}
}
foreach ( $bundled as $key => $value ) {
if ( empty( $value ) ) {
unset( $bundled->$key );
}
}
$brainstrom_bundled_products = (array) $bundled;
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
// update 'brainstorm_products'.
$simple = json_decode( wp_json_encode( $simple ), 1 );
foreach ( $brainstrom_products as $type => $products ) {
foreach ( $products as $key => $product ) {
$old_id = isset( $product['id'] ) ? $product['id'] : '';
$simple[ $type ][ $old_id ]['template'] = isset( $brainstrom_products[ $type ][ $old_id ]['template'] ) ? $brainstrom_products[ $type ][ $old_id ]['template'] : '';
$simple[ $type ][ $old_id ]['remote'] = isset( $simple[ $type ][ $old_id ]['version'] ) ? $simple[ $type ][ $old_id ]['version'] : '';
$simple[ $type ][ $old_id ]['version'] = isset( $brainstrom_products[ $type ][ $old_id ]['version'] ) ? $brainstrom_products[ $type ][ $old_id ]['version'] : '';
$simple[ $type ][ $old_id ]['purchase_key'] = isset( $brainstrom_products[ $type ][ $old_id ]['purchase_key'] ) ? $brainstrom_products[ $type ][ $old_id ]['purchase_key'] : '';
$simple[ $type ][ $old_id ]['status'] = isset( $brainstrom_products[ $type ][ $old_id ]['status'] ) ? $brainstrom_products[ $type ][ $old_id ]['status'] : '';
$simple[ $type ][ $old_id ]['message'] = isset( $brainstrom_products[ $type ][ $old_id ]['message'] ) ? $brainstrom_products[ $type ][ $old_id ]['message'] : '';
}
}
update_option( 'brainstrom_products', $simple );
}
}
}
/**
* Displays bundled product list for product.
*
* @param string $product_id Product ID.
* @param bool $installed Show installed products?.
* @return string
*/
function bsf_render_bundled_products( $product_id, $installed ) {
$product_status = check_bsf_product_status( $product_id );
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
if ( isset( $brainstrom_bundled_products[ $product_id ] ) ) {
$brainstrom_bundled_products = $brainstrom_bundled_products[ $product_id ];
}
usort( $brainstrom_bundled_products, 'bsf_sort' );
$global_plugin_installed = 0;
$global_plugin_activated = 0;
$total_bundled_plugins = count( $brainstrom_bundled_products );
foreach ( $brainstrom_bundled_products as $key => $product ) {
if ( ! isset( $product->id ) || empty( $product->id ) ) {
continue;
}
if ( isset( $request_product_id ) && $request_product_id !== $product->id ) {
continue;
}
$plugin_abs_path = WP_PLUGIN_DIR . '/' . $product->init;
if ( is_file( $plugin_abs_path ) ) {
$global_plugin_installed++;
if ( is_plugin_active( $product->init ) ) {
$global_plugin_activated++;
}
}
}
ob_start();
if ( $total_bundled_plugins === $global_plugin_installed ) {
?>
<div class="bsf-extensions-no-active">
<div class="bsf-extensions-title-icon"><span class="dashicons dashicons-smiley"></span></div>
<p class="bsf-text-light"><em><?php esc_html_e( 'All available extensions have been installed!', 'bsf' ); ?></em></p>
</div>
<?php
return ob_get_clean();
}
if ( empty( $brainstrom_bundled_products ) ) {
?>
<div class="bsf-extensions-no-active">
<div class="bsf-extensions-title-icon"><span class="dashicons dashicons-download"></span></div>
<p class="bsf-text-light"><em><?php esc_html_e( 'No extensions available yet!', 'bsf' ); ?></em></p>
<div class="bsf-cp-rem-bundle" style="margin-top: 30px;">
<a class="button-primary" href="<?php echo esc_url( $reset_bundled_url ); ?>"><?php esc_html_e( 'Refresh Bundled Products', 'bsf' ); ?></a>
</div>
</div>
<?php
return ob_get_clean();
}
foreach ( $brainstrom_bundled_products as $key => $product ) {
if ( ! isset( $product->id ) || empty( $product->id ) ) {
continue;
}
if ( isset( $request_product_id ) && $request_product_id !== $product->id ) {
continue;
}
$is_plugin_installed = false;
$is_plugin_activated = false;
$plugin_abs_path = WP_PLUGIN_DIR . '/' . $product->init;
if ( is_file( $plugin_abs_path ) ) {
$is_plugin_installed = true;
if ( is_plugin_active( $product->init ) ) {
$is_plugin_activated = true;
}
}
if ( ( $is_plugin_installed && ! $installed ) || ( ! $is_plugin_installed && $installed ) ) {
continue;
}
if ( $is_plugin_installed && $is_plugin_activated ) {
$class = 'active-plugin';
} elseif ( $is_plugin_installed && ! $is_plugin_activated ) {
$class = 'inactive-plugin';
} else {
$class = 'plugin-not-installed';
}
?>
<li id="ext-<?php echo esc_attr( $key ); ?>" class="bsf-extension <?php echo esc_attr( $class ); ?> bsf-extension-<?php echo esc_attr( $product->slug ); ?>" data-init="<?php echo esc_attr( $product->init ); ?>">
<?php if ( ! $is_plugin_installed ) { ?>
<div class="bsf-extension-start-install">
<div class="bsf-extension-start-install-content">
<h2><?php esc_html_e( 'Downloading', 'bsf' ); ?><div class="bsf-css-loader"></div></h2>
</div>
</div>
<?php } ?>
<div class="top-section">
<?php if ( ! empty( $product->product_image ) ) { ?>
<div class="bsf-extension-product-image">
<div class="bsf-extension-product-image-stick">
<img src="<?php echo esc_url( $product->product_image ); ?>" class="img" alt="image"/>
</div>
</div>
<?php } ?>
<div class="bsf-extension-info">
<?php $name = ( isset( $product->short_name ) ) ? $product->short_name : $product->name; ?>
<h4 class="title"><?php echo esc_html( $name ); ?></h4>
<p class="desc"><?php echo esc_html( $product->description ); ?><span class="author"><cite>By <?php echo esc_html( $product->author ); ?></cite></span></p>
</div>
</div>
<div class="bottom-section">
<?php
$button_class = '';
if ( ! $is_plugin_installed ) {
if ( ( ! $product->licence_require || 'false' === $product->licence_require ) || 'registered' === $product_status ) {
$installer_url = bsf_exension_installer_url( $product_id );
$button = __( 'Install', 'bsf' );
$button_class = 'bsf-install-button install-now';
} elseif ( ( $product->licence_require || 'true' === $product->licence_require ) && 'registered' !== $product_status ) {
$installer_url = bsf_registration_page_url( '&id=' . $product_id, $product_id );
$button = __( 'Validate Purchase', 'bsf' );
$button_class = 'bsf-validate-licence-button';
}
} else {
$current_name = strtolower( bsf_get_current_name( $product->init, $product->type ) );
$current_name = preg_replace( '![^a-z0-9]+!i', '-', $current_name );
if ( is_multisite() ) {
$installer_url = network_admin_url( 'plugins.php#' . $current_name );
} else {
$installer_url = admin_url( 'plugins.php#' . $current_name );
}
$button = __( 'Installed', 'bsf' );
}
?>
<a class="button button-primary extension-button <?php echo esc_attr( $button_class ); ?>" href="<?php echo esc_url( $installer_url ); ?>" data-slug="<?php echo esc_html( $product->slug ); ?>" data-ext="<?php echo esc_attr( $key ); ?>" data-pid="<?php echo esc_attr( $product->id ); ?>" data-bundled="true" data-action="install"><?php echo esc_html( $button ); ?></a>
</div>
</li>
<?php
}
return ob_get_clean();
}
<?php
/**
* Admin functions for bsf core.
*
* @package BSF core
*/
/**
* Prevent direct access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
if ( ! function_exists( 'check_bsf_product_status' ) ) {
/**
* Get status of product.
*
* @param int $id product id.
* @return bool
*/
function check_bsf_product_status( $id ) {
$brainstrom_products = ( get_option( 'brainstrom_products' ) ) ? get_option( 'brainstrom_products' ) : array();
$bsf_product_themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
if ( empty( $brainstrom_products ) ) {
return false;
}
$status = false;
foreach ( $brainstrom_products as $products ) {
foreach ( $products as $key => $product ) {
if ( $product['id'] === $id ) {
$status = ( isset( $product['status'] ) ) ? $product['status'] : '';
break;
}
}
}
return $status;
}
}
if ( ! function_exists( 'get_bundled_plugins' ) ) {
/**
* Retrieves bundled plugin data.
*
* @param string $template product template.
* @return void
*/
function get_bundled_plugins( $template = '' ) {
global $ultimate_referer;
$brainstrom_products = get_option( 'brainstrom_products', array() );
$prd_ids = array();
// If brainstrom_products is not yet set, call bsf core init.
if ( is_array( $brainstrom_products ) ) {
init_bsf_core();
$brainstrom_products = get_option( 'brainstrom_products', array() );
}
foreach ( $brainstrom_products as $key => $value ) {
foreach ( $value as $key => $value2 ) {
array_push( $prd_ids, $key );
}
}
$path = bsf_get_api_url() . '?referer=' . $ultimate_referer;
$data = array(
'action' => 'bsf_fetch_brainstorm_products',
'id' => $prd_ids,
);
$request = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '10',
)
);
// Request http URL if the https version fails.
if ( is_wp_error( $request ) && wp_remote_retrieve_response_code( $request ) !== 200 ) {
$path = bsf_get_api_url( true ) . '?referer=' . $ultimate_referer;
$request = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '8',
)
);
}
if ( ! is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) === 200 ) {
$result = json_decode( $request['body'] );
$bundled = array();
$simple = array();
if ( ! empty( $result ) ) {
if ( ! empty( $result->bundled ) ) {
$bundled = $result->bundled;
}
if ( ! empty( $result->simple ) ) {
$simple = $result->simple;
}
}
foreach ( $bundled as $key => $value ) {
if ( empty( $value ) ) {
unset( $bundled->$key );
}
}
$brainstrom_bundled_products = (array) $bundled;
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
// update 'brainstorm_products'.
$simple = json_decode( wp_json_encode( $simple ), 1 );
foreach ( $brainstrom_products as $type => $products ) {
foreach ( $products as $key => $product ) {
$old_id = isset( $product['id'] ) ? $product['id'] : '';
$simple[ $type ][ $old_id ]['template'] = isset( $brainstrom_products[ $type ][ $old_id ]['template'] ) ? $brainstrom_products[ $type ][ $old_id ]['template'] : '';
$simple[ $type ][ $old_id ]['remote'] = isset( $simple[ $type ][ $old_id ]['version'] ) ? $simple[ $type ][ $old_id ]['version'] : '';
$simple[ $type ][ $old_id ]['version'] = isset( $brainstrom_products[ $type ][ $old_id ]['version'] ) ? $brainstrom_products[ $type ][ $old_id ]['version'] : '';
$simple[ $type ][ $old_id ]['purchase_key'] = isset( $brainstrom_products[ $type ][ $old_id ]['purchase_key'] ) ? $brainstrom_products[ $type ][ $old_id ]['purchase_key'] : '';
$simple[ $type ][ $old_id ]['status'] = isset( $brainstrom_products[ $type ][ $old_id ]['status'] ) ? $brainstrom_products[ $type ][ $old_id ]['status'] : '';
$simple[ $type ][ $old_id ]['message'] = isset( $brainstrom_products[ $type ][ $old_id ]['message'] ) ? $brainstrom_products[ $type ][ $old_id ]['message'] : '';
}
}
update_option( 'brainstrom_products', $simple );
}
}
}
/**
* Displays bundled product list for product.
*
* @param string $product_id Product ID.
* @param bool $installed Show installed products?.
* @return string
*/
function bsf_render_bundled_products( $product_id, $installed ) {
$product_status = check_bsf_product_status( $product_id );
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
if ( isset( $brainstrom_bundled_products[ $product_id ] ) ) {
$brainstrom_bundled_products = $brainstrom_bundled_products[ $product_id ];
}
usort( $brainstrom_bundled_products, 'bsf_sort' );
$global_plugin_installed = 0;
$global_plugin_activated = 0;
$total_bundled_plugins = count( $brainstrom_bundled_products );
foreach ( $brainstrom_bundled_products as $key => $product ) {
if ( ! isset( $product->id ) || empty( $product->id ) ) {
continue;
}
if ( isset( $request_product_id ) && $request_product_id !== $product->id ) {
continue;
}
$plugin_abs_path = WP_PLUGIN_DIR . '/' . $product->init;
if ( is_file( $plugin_abs_path ) ) {
$global_plugin_installed++;
if ( is_plugin_active( $product->init ) ) {
$global_plugin_activated++;
}
}
}
ob_start();
if ( $total_bundled_plugins === $global_plugin_installed ) {
?>
<div class="bsf-extensions-no-active">
<div class="bsf-extensions-title-icon"><span class="dashicons dashicons-smiley"></span></div>
<p class="bsf-text-light"><em><?php esc_html_e( 'All available extensions have been installed!', 'bsf' ); ?></em></p>
</div>
<?php
return ob_get_clean();
}
if ( empty( $brainstrom_bundled_products ) ) {
?>
<div class="bsf-extensions-no-active">
<div class="bsf-extensions-title-icon"><span class="dashicons dashicons-download"></span></div>
<p class="bsf-text-light"><em><?php esc_html_e( 'No extensions available yet!', 'bsf' ); ?></em></p>
<div class="bsf-cp-rem-bundle" style="margin-top: 30px;">
<a class="button-primary" href="<?php echo esc_url( $reset_bundled_url ); ?>"><?php esc_html_e( 'Refresh Bundled Products', 'bsf' ); ?></a>
</div>
</div>
<?php
return ob_get_clean();
}
foreach ( $brainstrom_bundled_products as $key => $product ) {
if ( ! isset( $product->id ) || empty( $product->id ) ) {
continue;
}
if ( isset( $request_product_id ) && $request_product_id !== $product->id ) {
continue;
}
$is_plugin_installed = false;
$is_plugin_activated = false;
$plugin_abs_path = WP_PLUGIN_DIR . '/' . $product->init;
if ( is_file( $plugin_abs_path ) ) {
$is_plugin_installed = true;
if ( is_plugin_active( $product->init ) ) {
$is_plugin_activated = true;
}
}
if ( ( $is_plugin_installed && ! $installed ) || ( ! $is_plugin_installed && $installed ) ) {
continue;
}
if ( $is_plugin_installed && $is_plugin_activated ) {
$class = 'active-plugin';
} elseif ( $is_plugin_installed && ! $is_plugin_activated ) {
$class = 'inactive-plugin';
} else {
$class = 'plugin-not-installed';
}
?>
<li id="ext-<?php echo esc_attr( $key ); ?>" class="bsf-extension <?php echo esc_attr( $class ); ?> bsf-extension-<?php echo esc_attr( $product->slug ); ?>" data-init="<?php echo esc_attr( $product->init ); ?>">
<?php if ( ! $is_plugin_installed ) { ?>
<div class="bsf-extension-start-install">
<div class="bsf-extension-start-install-content">
<h2><?php esc_html_e( 'Downloading', 'bsf' ); ?><div class="bsf-css-loader"></div></h2>
</div>
</div>
<?php } ?>
<div class="top-section">
<?php if ( ! empty( $product->product_image ) ) { ?>
<div class="bsf-extension-product-image">
<div class="bsf-extension-product-image-stick">
<img src="<?php echo esc_url( $product->product_image ); ?>" class="img" alt="image"/>
</div>
</div>
<?php } ?>
<div class="bsf-extension-info">
<?php $name = ( isset( $product->short_name ) ) ? $product->short_name : $product->name; ?>
<h4 class="title"><?php echo esc_html( $name ); ?></h4>
<p class="desc"><?php echo esc_html( $product->description ); ?><span class="author"><cite>By <?php echo esc_html( $product->author ); ?></cite></span></p>
</div>
</div>
<div class="bottom-section">
<?php
$button_class = '';
if ( ! $is_plugin_installed ) {
if ( ( ! $product->licence_require || 'false' === $product->licence_require ) || 'registered' === $product_status ) {
$installer_url = bsf_exension_installer_url( $product_id );
$button = __( 'Install', 'bsf' );
$button_class = 'bsf-install-button install-now';
} elseif ( ( $product->licence_require || 'true' === $product->licence_require ) && 'registered' !== $product_status ) {
$installer_url = bsf_registration_page_url( '&id=' . $product_id, $product_id );
$button = __( 'Validate Purchase', 'bsf' );
$button_class = 'bsf-validate-licence-button';
}
} else {
$current_name = strtolower( bsf_get_current_name( $product->init, $product->type ) );
$current_name = preg_replace( '![^a-z0-9]+!i', '-', $current_name );
if ( is_multisite() ) {
$installer_url = network_admin_url( 'plugins.php#' . $current_name );
} else {
$installer_url = admin_url( 'plugins.php#' . $current_name );
}
$button = __( 'Installed', 'bsf' );
}
?>
<a class="button button-primary extension-button <?php echo esc_attr( $button_class ); ?>" href="<?php echo esc_url( $installer_url ); ?>" data-slug="<?php echo esc_html( $product->slug ); ?>" data-ext="<?php echo esc_attr( $key ); ?>" data-pid="<?php echo esc_attr( $product->id ); ?>" data-bundled="true" data-action="install"><?php echo esc_html( $button ); ?></a>
</div>
</li>
<?php
}
return ob_get_clean();
}
@@ -1,15 +1,15 @@
<?php
/**
* Plugin installer.
*
* @package bsf-core
*/
/**
* Prevent direct access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
require_once BSF_UPDATER_PATH . '/includes/views/list-bundled-products.php';
<?php
/**
* Plugin installer.
*
* @package bsf-core
*/
/**
* Prevent direct access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
require_once BSF_UPDATER_PATH . '/includes/views/list-bundled-products.php';
@@ -1,8 +1,30 @@
v2.7.9
# Fix: Addressed a Broken Access Control security bug. Props to Patchstack for privately reporting it to our team.
# Fix: Issue with the custom image setting for How To Block.
v2.7.8
# New: Rollback to previous versions feature.
# Improvement: Addressed nonces verification more effectively.
# Improvement: Allowed HTML format for the Description field in Job Posting Schema as per Google's guidelines.
# Improvement: Updated Interaction Count field markup in the Video Object schema as per Google guidelines.
# Fix: Invalid value error for Rating and Review Count fields when set to none in Local Business schema.
v2.7.7
# Improvement: Updated markup for educationRequirements and experienceRequirements fields in Job Posting schema.
# Fix: Resolved PHP warning for Site Logo.
# Fix: Custom Fields used in schema not showing correct value.
v2.7.6
# Fix: Schema fields not showing after saving in the page editor.
v2.7.5
# Improvement: Added compatibility to PHP v8.1.
v2.7.4
# Fix: Added Credit Text, Creator and Copy Right Notice fields in the Image schema.
# Fix: Updated brand type markup in the product schema.
# Fix: Added content URL as required field in the recipe schema.
# Fix: Review tyle field validation in the Review schema.
# Fix: Review type field validation in the Review schema.
v2.7.3
# Fix: ACF field value is not added properly on global settings.
@@ -27,7 +49,7 @@ Improvements: Added Author.URL field in the article schema.
Improvements: Added backorder availability option in the Product schema.
Improvements: Added Day as base salary option in the Job posting schema.
Fix: Fatal Error issue with ACF on all singulars target rules.
Fix: Fixed Breadcrumb archive URL issue on the archive page.
Fix: Fixed Breadcrumb archive URL issue on the archive page.
Fix: Fixed index notice issue on the page level configuration.
v2.6.5
@@ -64,7 +86,7 @@ v2.6.0
# Improvements: Optimized blocks JS loading on the editor page.
# Improvements: Refactor FAQ and how-to blocks code-based structure.
# Improvements: Compatibility with the latest JavaScript standard rule.
# Improvements: Compatibility with the latest CSS standard rule.
# Improvements: Compatibility with the latest CSS standard rule.
# Fix: Fixed UI icon issue on the post or page.
# Fix Trim function console error issue in the FAQ schema.
# Fix: The URL warning issue in the Product item review type in the review schema.
@@ -108,7 +130,7 @@ v2.3.0
# Fix: Fixed schema markup error issue in the about page and contact page schema.
# Fix: Fixed Event attendance mode option select issue on the event schema.
# Fix: FAQ console error when accessing child by id in the FAQ block schema.
# Fix: Select other custom field option issue on the post or page.
# Fix: Select other custom field option issue on the post or page.
# Fix: Fixed online location markup issue inside Course schema.
# Fix: Fixed test link is not shown on the admin bar.
@@ -152,7 +174,7 @@ v2.1.2
# Improvements: Restructure Configuration settings.
# Improvements: Google+ field deprecated in the social profile section.
# Improvements: Added new types in the organization type option.
# Improvements: Organization schema is now only targeted on the home page.
# Improvements: Organization schema is now only targeted on the home page.
# Improvements: Removed extra contact information field in the corporate contact.
# Improvements: Added search box for search page option for a contact and about page schema.
# Improvements: Added backward compatibility for deprecated extra fields of corporate contact.
@@ -179,7 +201,7 @@ v2.1.0
v2.0.1
# New: Users can now share non-personal usage data to help us test and develop better products.
# Improvements: Added required field validation label on Corporate Contact.
# Improvements: Added required field validation label on Corporate Contact.
# Improvements: Added the Toggle button for the Enable Schema Markup filter.
# Fix: Fixed the close button not showing into the FAQ schema.
# Fix: Logo accepts from schema configuration into schema types.
@@ -251,12 +273,12 @@ v1.5.0
# New: Added schema markup for amp pages or posts compatibility.
# New: Delete schema data and settings on the uninstalled plugin with a delete option.
# New: Added Event schema types added in Event schema.
# New:`wp_schema_pro_remove_amp_schema_markup` Filter to disable schema markup for AMP pages or posts on Reader mode.
# New:`wp_schema_pro_remove_amp_schema_markup` Filter to disable schema markup for AMP pages or posts on Reader mode.
# Fix: Permalink added for the sameAs field in Review schema.
v1.4.1
# Improvement: Added new fields for product ItemReviewed type of review schema.
# Improvement: Added MPN field in product schema.
# Improvement: Added MPN field in product schema.
# Improvement: Added dependency to the SameAS field for Book ItemReviewed type in review schema.
# Improvement: Organization logo field in job posting schema.
# Fix: reviewBody and description fields are not working correctly in review schema.
@@ -149,7 +149,7 @@ if ( ! class_exists( 'Brainstorm_Update_AIOSRS_Pro' ) ) :
$version = file_get_contents( realpath( plugin_dir_path( BSF_AIOSRS_PRO_FILE ) . '/admin/bsf-core/version.yml' ) );
// Compare versions.
if ( version_compare( $version, $bsf_core_version, '>' ) ) {
if ( version_compare( $version, (string)$bsf_core_version, '>' ) ) {
$bsf_core_version = $version;
$bsf_core_path = $bsf_core_dir;
}
File diff suppressed because it is too large Load Diff
@@ -1,87 +1,87 @@
<?php
/**
* AMP for Schema Pro
*
* @package Schema Pro
*/
/**
* Exit if accessed directly.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* BSF_AIOSRS_Pro_Amp initial setup
*
* @since 1.5.0
*/
/**
* This class initializes Schema for AMP
*
* @class BSF_AIOSRS_Pro_Amp
*/
final class BSF_AIOSRS_Pro_Amp {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Initiator
*
* @access public
* @var $amp_activated set default to false.
*/
public static $amp_activated = false;
/**
* AMP Options.
*
* @access private
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor function.
*/
public function __construct() {
add_action( 'init', array( $this, 'amp_schema_markup' ) );
}
/**
* Rendering the Schema markup for AMP Template.
*/
public static function amp_schema_markup() {
if ( apply_filters( 'wp_schema_pro_remove_amp_schema_markup', true ) ) {
$settings = BSF_AIOSRS_Pro_Helper::$settings['aiosrs-pro-settings'];
$schema_markup = BSF_AIOSRS_Pro_Markup::get_instance();
if ( isset( $settings['schema-location'] ) ) {
switch ( $settings['schema-location'] ) {
case 'head':
add_action( 'amp_post_template_head', array( $schema_markup, 'schema_markup' ) );
add_action( 'amp_post_template_head', array( $schema_markup, 'global_schemas_markup' ) );
break;
case 'footer':
add_action( 'amp_post_template_footer', array( $schema_markup, 'schema_markup' ) );
add_action( 'amp_post_template_footer', array( $schema_markup, 'global_schemas_markup' ) );
break;
default:
break;
}
}
}
}
}
BSF_AIOSRS_Pro_Amp::get_instance();
<?php
/**
* AMP for Schema Pro
*
* @package Schema Pro
*/
/**
* Exit if accessed directly.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* BSF_AIOSRS_Pro_Amp initial setup
*
* @since 1.5.0
*/
/**
* This class initializes Schema for AMP
*
* @class BSF_AIOSRS_Pro_Amp
*/
final class BSF_AIOSRS_Pro_Amp {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Initiator
*
* @access public
* @var $amp_activated set default to false.
*/
public static $amp_activated = false;
/**
* AMP Options.
*
* @access private
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor function.
*/
public function __construct() {
add_action( 'init', array( $this, 'amp_schema_markup' ) );
}
/**
* Rendering the Schema markup for AMP Template.
*/
public static function amp_schema_markup() {
if ( apply_filters( 'wp_schema_pro_remove_amp_schema_markup', true ) ) {
$settings = BSF_AIOSRS_Pro_Helper::$settings['aiosrs-pro-settings'];
$schema_markup = BSF_AIOSRS_Pro_Markup::get_instance();
if ( isset( $settings['schema-location'] ) ) {
switch ( $settings['schema-location'] ) {
case 'head':
add_action( 'amp_post_template_head', array( $schema_markup, 'schema_markup' ) );
add_action( 'amp_post_template_head', array( $schema_markup, 'global_schemas_markup' ) );
break;
case 'footer':
add_action( 'amp_post_template_footer', array( $schema_markup, 'schema_markup' ) );
add_action( 'amp_post_template_footer', array( $schema_markup, 'global_schemas_markup' ) );
break;
default:
break;
}
}
}
}
}
BSF_AIOSRS_Pro_Amp::get_instance();
@@ -1,80 +1,80 @@
<?php
/**
* White labeling for Schema Pro
*
* @package Schema Pro
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Branding' ) ) {
/**
* BSF_AIOSRS_Pro_Branding initial setup
*
* @since 1.3.0
*/
/**
* This class initializes Schema Branding
*
* @class BSF_AIOSRS_Pro_Branding
*/
final class BSF_AIOSRS_Pro_Branding {
/**
* Function that initializes necessary filters
*
* @return void
*/
public static function init() {
add_filter( 'all_plugins', __CLASS__ . '::plugins_page' );
}
/**
* Branding on the plugins page.
*
* @since 1.3.0
* @param array $plugins An array data for each plugin.
* @return array
*/
public static function plugins_page( $plugins ) {
if ( is_multisite() ) {
$branding = get_site_option( 'wp-schema-pro-branding-settings' );
} else {
$branding = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
}
$basename = plugin_basename( BSF_AIOSRS_PRO_DIR . 'wp-schema-pro.php' );
if ( isset( $plugins[ $basename ] ) && is_array( $branding ) ) {
$sp_plugin_name = ( array_key_exists( 'sp_plugin_name', $branding ) ) ? $branding['sp_plugin_name'] : '';
$sp_plugin_desc = ( array_key_exists( 'sp_plugin_desc', $branding ) ) ? $branding['sp_plugin_desc'] : '';
$sp_author_name = ( array_key_exists( 'sp_plugin_author_name', $branding ) ) ? $branding['sp_plugin_author_name'] : '';
$sp_author_url = ( array_key_exists( 'sp_plugin_author_url', $branding ) ) ? $branding['sp_plugin_author_url'] : '';
if ( '' !== $sp_plugin_name ) {
$plugins[ $basename ]['Name'] = $sp_plugin_name;
$plugins[ $basename ]['Title'] = $sp_plugin_name;
}
if ( '' !== $sp_plugin_desc ) {
$plugins[ $basename ]['Description'] = $sp_plugin_desc;
}
if ( '' !== $sp_author_name ) {
$plugins[ $basename ]['Author'] = $sp_author_name;
$plugins[ $basename ]['AuthorName'] = $sp_author_name;
}
if ( '' !== $sp_author_url ) {
$plugins[ $basename ]['AuthorURI'] = $sp_author_url;
$plugins[ $basename ]['PluginURI'] = $sp_author_url;
}
}
return $plugins;
}
}
}
BSF_AIOSRS_Pro_Branding::init();
<?php
/**
* White labeling for Schema Pro
*
* @package Schema Pro
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Branding' ) ) {
/**
* BSF_AIOSRS_Pro_Branding initial setup
*
* @since 1.3.0
*/
/**
* This class initializes Schema Branding
*
* @class BSF_AIOSRS_Pro_Branding
*/
final class BSF_AIOSRS_Pro_Branding {
/**
* Function that initializes necessary filters
*
* @return void
*/
public static function init() {
add_filter( 'all_plugins', __CLASS__ . '::plugins_page' );
}
/**
* Branding on the plugins page.
*
* @since 1.3.0
* @param array $plugins An array data for each plugin.
* @return array
*/
public static function plugins_page( $plugins ) {
if ( is_multisite() ) {
$branding = get_site_option( 'wp-schema-pro-branding-settings' );
} else {
$branding = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
}
$basename = plugin_basename( BSF_AIOSRS_PRO_DIR . 'wp-schema-pro.php' );
if ( isset( $plugins[ $basename ] ) && is_array( $branding ) ) {
$sp_plugin_name = ( array_key_exists( 'sp_plugin_name', $branding ) ) ? $branding['sp_plugin_name'] : '';
$sp_plugin_desc = ( array_key_exists( 'sp_plugin_desc', $branding ) ) ? $branding['sp_plugin_desc'] : '';
$sp_author_name = ( array_key_exists( 'sp_plugin_author_name', $branding ) ) ? $branding['sp_plugin_author_name'] : '';
$sp_author_url = ( array_key_exists( 'sp_plugin_author_url', $branding ) ) ? $branding['sp_plugin_author_url'] : '';
if ( '' !== $sp_plugin_name ) {
$plugins[ $basename ]['Name'] = $sp_plugin_name;
$plugins[ $basename ]['Title'] = $sp_plugin_name;
}
if ( '' !== $sp_plugin_desc ) {
$plugins[ $basename ]['Description'] = $sp_plugin_desc;
}
if ( '' !== $sp_author_name ) {
$plugins[ $basename ]['Author'] = $sp_author_name;
$plugins[ $basename ]['AuthorName'] = $sp_author_name;
}
if ( '' !== $sp_author_url ) {
$plugins[ $basename ]['AuthorURI'] = $sp_author_url;
$plugins[ $basename ]['PluginURI'] = $sp_author_url;
}
}
return $plugins;
}
}
}
BSF_AIOSRS_Pro_Branding::init();
@@ -141,6 +141,10 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Custom_Fields_Markup' ) ) {
);
$post_id = empty( $args['post_id'] ) ? get_the_ID() : (int) $args['post_id'];
$allowed_post_types = array( 'post', 'page', 'comment', 'term' );
if ( ! in_array( $args['post_type'], $allowed_post_types ) ) {
return 'Invalid post type';
}
$output = get_metadata( $args['post_type'], $post_id, $args['field_key'], true );
if ( empty( $output ) || is_array( $output ) ) {
@@ -1147,7 +1151,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Custom_Fields_Markup' ) ) {
$array,
function ( &$value ) {
$value = filter_var( trim( $value ), FILTER_SANITIZE_STRING );
$value = filter_var( trim( $value ), FILTER_DEFAULT );
}
);
@@ -1187,7 +1191,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Custom_Fields_Markup' ) ) {
switch ( $sanitize_filter ) {
case 'FILTER_SANITIZE_STRING':
$meta_value = filter_input( INPUT_POST, $data['name'], FILTER_SANITIZE_STRING );
$meta_value = filter_input( INPUT_POST, $data['name'], FILTER_DEFAULT );
break;
case 'FILTER_SANITIZE_URL':
@@ -1209,7 +1213,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Custom_Fields_Markup' ) ) {
break;
}
update_post_meta( $post_id, $data['name'] . '-fieldtype', filter_input( INPUT_POST, $data['name'] . '-fieldtype', FILTER_SANITIZE_STRING ) );
update_post_meta( $post_id, $data['name'] . '-fieldtype', filter_input( INPUT_POST, $data['name'] . '-fieldtype', FILTER_DEFAULT ) );
update_post_meta( $post_id, $data['name'], $meta_value );
}
}
@@ -1,191 +1,191 @@
<?php
/**
* Utils.
*
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Class BSF_AIOSRS_Pro_Helper.
*/
class BSF_AIOSRS_Pro_Helper {
/**
* Member Variable
*
* @var instance
*/
private static $instance;
/**
* Member Variable
*
* @var settings
*/
public static $settings;
/**
* Default static array
*
* @var default_options
*/
private static $default_options = array(
// General Settings.
'wp-schema-pro-general-settings' => array(
'organization' => '',
'site-represent' => '',
'site-name' => '',
'person-name' => '',
'site-logo' => 'custom',
'site-logo-custom' => '',
),
// Social Profiles.
'wp-schema-pro-social-profiles' => array(
'facebook' => '',
'twitter' => '',
'google-plus' => '',
'instagram' => '',
'youtube' => '',
'linkedin' => '',
'pinterest' => '',
'soundcloud' => '',
'tumblr' => '',
'wikipedia' => '',
'myspace' => '',
'other' => array(),
),
// Global Schemas.
'wp-schema-pro-global-schemas' => array(
'about-page' => '',
'contact-page' => '',
'site-navigation-element' => '',
'breadcrumb' => '1',
'sitelink-search-box' => '1',
),
// Advanced Settings.
'aiosrs-pro-settings' => array(
'quick-test' => '1',
'menu-position' => 'options-general.php',
'schema-location' => 'head',
'yoast-compatibility' => '1',
'schema-validation' => '',
'default_image' => '',
'delete-schema-data' => '',
),
// Corporate Contact.
'wp-schema-pro-corporate-contact' => array(
'contact-type' => '',
'telephone' => '',
'url' => '',
'email' => '',
'areaServed' => '',
'contact-hear' => '',
'contact-toll' => '',
'availableLanguage' => '',
'cp-schema-type' => '',
'areaserved-type' => '',
'country' => array(),
'place' => '',
'contact-page-id' => '',
'contact-type-other' => '',
),
// Branding Settings.
'wp-schema-pro-branding-settings' => array(
'sp_plugin_name' => '',
'sp_plugin_sname' => '',
'sp_plugin_desc' => '',
'sp_plugin_author_name' => '',
'sp_plugin_author_url' => '',
'sp_hide_label' => 'disabled',
),
'wp-schema-pro-breadcrumb-setting' => array(
'product' => '',
'product_cat' => '',
'product_tag' => '',
'enable_bread' => '1',
),
);
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
self::prepare_schema_pro_options();
}
/**
* Prepare options from database.
*/
public static function prepare_schema_pro_options() {
$options = array_keys( self::$default_options );
foreach ( $options as $option ) {
self::$settings[ $option ] = get_option( $option );
}
}
/**
* Enqueue the scripts at the backend.
*/
public static function bsf_schema_pro_enqueue_admin_script() {
global $pagenow;
return 'post-new.php' === $pagenow || 'post.php' === $pagenow;
}
/**
* Set default options.
*/
public static function bsf_schema_pro_set_default_options() {
foreach ( self::$default_options as $key => $default_option ) {
$settings = get_option( $key );
if ( ! get_option( $key ) ) {
update_option( $key, $default_option );
} else {
foreach ( $default_option as $name => $setting ) {
if ( ! isset( $settings[ $name ] ) ) {
$settings[ $name ] = $default_option[ $name ];
}
}
// Updated settings if new settings added.
update_option( $key, $settings );
}
}
// Delete decrypted cached structured option data.
delete_option( BSF_AIOSRS_PRO_CACHE_KEY );
}
/**
* Return the WP_debug.
*/
public static function bsf_schema_pro_is_wp_debug_enable() {
return true === ( defined( 'WP_DEBUG' ) && WP_DEBUG );
}
}
BSF_AIOSRS_Pro_Helper::get_instance();
<?php
/**
* Utils.
*
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Class BSF_AIOSRS_Pro_Helper.
*/
class BSF_AIOSRS_Pro_Helper {
/**
* Member Variable
*
* @var instance
*/
private static $instance;
/**
* Member Variable
*
* @var settings
*/
public static $settings;
/**
* Default static array
*
* @var default_options
*/
private static $default_options = array(
// General Settings.
'wp-schema-pro-general-settings' => array(
'organization' => '',
'site-represent' => '',
'site-name' => '',
'person-name' => '',
'site-logo' => 'custom',
'site-logo-custom' => '',
),
// Social Profiles.
'wp-schema-pro-social-profiles' => array(
'facebook' => '',
'twitter' => '',
'google-plus' => '',
'instagram' => '',
'youtube' => '',
'linkedin' => '',
'pinterest' => '',
'soundcloud' => '',
'tumblr' => '',
'wikipedia' => '',
'myspace' => '',
'other' => array(),
),
// Global Schemas.
'wp-schema-pro-global-schemas' => array(
'about-page' => '',
'contact-page' => '',
'site-navigation-element' => '',
'breadcrumb' => '1',
'sitelink-search-box' => '1',
),
// Advanced Settings.
'aiosrs-pro-settings' => array(
'quick-test' => '1',
'menu-position' => 'options-general.php',
'schema-location' => 'head',
'yoast-compatibility' => '1',
'schema-validation' => '',
'default_image' => '',
'delete-schema-data' => '',
),
// Corporate Contact.
'wp-schema-pro-corporate-contact' => array(
'contact-type' => '',
'telephone' => '',
'url' => '',
'email' => '',
'areaServed' => '',
'contact-hear' => '',
'contact-toll' => '',
'availableLanguage' => '',
'cp-schema-type' => '',
'areaserved-type' => '',
'country' => array(),
'place' => '',
'contact-page-id' => '',
'contact-type-other' => '',
),
// Branding Settings.
'wp-schema-pro-branding-settings' => array(
'sp_plugin_name' => '',
'sp_plugin_sname' => '',
'sp_plugin_desc' => '',
'sp_plugin_author_name' => '',
'sp_plugin_author_url' => '',
'sp_hide_label' => 'disabled',
),
'wp-schema-pro-breadcrumb-setting' => array(
'product' => '',
'product_cat' => '',
'product_tag' => '',
'enable_bread' => '1',
),
);
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
self::prepare_schema_pro_options();
}
/**
* Prepare options from database.
*/
public static function prepare_schema_pro_options() {
$options = array_keys( self::$default_options );
foreach ( $options as $option ) {
self::$settings[ $option ] = get_option( $option );
}
}
/**
* Enqueue the scripts at the backend.
*/
public static function bsf_schema_pro_enqueue_admin_script() {
global $pagenow;
return 'post-new.php' === $pagenow || 'post.php' === $pagenow;
}
/**
* Set default options.
*/
public static function bsf_schema_pro_set_default_options() {
foreach ( self::$default_options as $key => $default_option ) {
$settings = get_option( $key );
if ( ! get_option( $key ) ) {
update_option( $key, $default_option );
} else {
foreach ( $default_option as $name => $setting ) {
if ( ! isset( $settings[ $name ] ) ) {
$settings[ $name ] = $default_option[ $name ];
}
}
// Updated settings if new settings added.
update_option( $key, $settings );
}
}
// Delete decrypted cached structured option data.
delete_option( BSF_AIOSRS_PRO_CACHE_KEY );
}
/**
* Return the WP_debug.
*/
public static function bsf_schema_pro_is_wp_debug_enable() {
return true === ( defined( 'WP_DEBUG' ) && WP_DEBUG );
}
}
BSF_AIOSRS_Pro_Helper::get_instance();
File diff suppressed because it is too large Load Diff
@@ -1,92 +1,92 @@
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.5.0
*/
/**
* Exit if accessed directly.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* This class initializes Schema for AMP
*
* @class BSF_AIOSRS_Pro_Schema_Global_Uninstall
*/
class BSF_AIOSRS_Pro_Schema_Global_Uninstall {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Constructor function.
*/
public function __construct() {
$this->delete_all_plugin_data();
}
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Delete function.
*/
public function delete_queries() {
global $wpdb;
$delete_keys = BSF_AIOSRS_Pro_Helper::$settings;
$delete_keys_options = array_keys( $delete_keys );
$delete_options_placeholders = implode( ', ', array_fill( 0, count( $delete_keys_options ), '%s' ) );
$wpdb->query( $wpdb->prepare( " DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE %s", '%' . $wpdb->esc_like( 'bsf-aiosrs-' ) . '%' ) );
$wpdb->query( $wpdb->prepare( " DELETE FROM {$wpdb->posts} WHERE post_type LIKE %s", '%' . $wpdb->esc_like( 'aiosrs-schema' ) . '%' ) );
$query = "DELETE FROM {$wpdb->options} WHERE option_name IN ($delete_options_placeholders)";
// @codingStandardsIgnoreStart
$wpdb->query( $wpdb->prepare( $query, $delete_keys_options ) );
wp_cache_delete($delete_options_placeholders,'options');
// @codingStandardsIgnoreEnd
}
/**
* Delete Schema from single site or multisite.
*/
public function delete_all_plugin_data() {
if ( ! is_multisite() ) {
$option_schema = BSF_AIOSRS_Pro_Helper::$settings['aiosrs-pro-settings'];
$delete_schema = isset( $option_schema['delete-schema-data'] ) ? $option_schema['delete-schema-data'] : '';
if ( '1' === $delete_schema ) {
self::delete_queries();
}
} else {
global $wpdb;
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
$original_blog_id = get_current_blog_id();
$option_schema = BSF_AIOSRS_Pro_Helper::$settings['aiosrs-pro-settings'];
$delete_schema = isset( $option_schema['delete-schema-data'] ) ? $option_schema['delete-schema-data'] : '';
foreach ( $blog_ids as $blog_id ) {
switch_to_blog( $blog_id );
if ( '1' === $delete_schema ) {
self::delete_queries();
}
}
switch_to_blog( $original_blog_id );
}
}
}
BSF_AIOSRS_Pro_Schema_Global_Uninstall::get_instance();
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.5.0
*/
/**
* Exit if accessed directly.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* This class initializes Schema for AMP
*
* @class BSF_AIOSRS_Pro_Schema_Global_Uninstall
*/
class BSF_AIOSRS_Pro_Schema_Global_Uninstall {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Constructor function.
*/
public function __construct() {
$this->delete_all_plugin_data();
}
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Delete function.
*/
public function delete_queries() {
global $wpdb;
$delete_keys = BSF_AIOSRS_Pro_Helper::$settings;
$delete_keys_options = array_keys( $delete_keys );
$delete_options_placeholders = implode( ', ', array_fill( 0, count( $delete_keys_options ), '%s' ) );
$wpdb->query( $wpdb->prepare( " DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE %s", '%' . $wpdb->esc_like( 'bsf-aiosrs-' ) . '%' ) );
$wpdb->query( $wpdb->prepare( " DELETE FROM {$wpdb->posts} WHERE post_type LIKE %s", '%' . $wpdb->esc_like( 'aiosrs-schema' ) . '%' ) );
$query = "DELETE FROM {$wpdb->options} WHERE option_name IN ($delete_options_placeholders)";
// @codingStandardsIgnoreStart
$wpdb->query( $wpdb->prepare( $query, $delete_keys_options ) );
wp_cache_delete($delete_options_placeholders,'options');
// @codingStandardsIgnoreEnd
}
/**
* Delete Schema from single site or multisite.
*/
public function delete_all_plugin_data() {
if ( ! is_multisite() ) {
$option_schema = BSF_AIOSRS_Pro_Helper::$settings['aiosrs-pro-settings'];
$delete_schema = isset( $option_schema['delete-schema-data'] ) ? $option_schema['delete-schema-data'] : '';
if ( '1' === $delete_schema ) {
self::delete_queries();
}
} else {
global $wpdb;
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
$original_blog_id = get_current_blog_id();
$option_schema = BSF_AIOSRS_Pro_Helper::$settings['aiosrs-pro-settings'];
$delete_schema = isset( $option_schema['delete-schema-data'] ) ? $option_schema['delete-schema-data'] : '';
foreach ( $blog_ids as $blog_id ) {
switch_to_blog( $blog_id );
if ( '1' === $delete_schema ) {
self::delete_queries();
}
}
switch_to_blog( $original_blog_id );
}
}
}
BSF_AIOSRS_Pro_Schema_Global_Uninstall::get_instance();
File diff suppressed because it is too large Load Diff
@@ -1,477 +1,477 @@
<?php
/**
* Schema Pro - Schema Wizard
*
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Wizard' ) ) :
/**
* BSF_AIOSRS_Pro_Schema_Wizard class.
*/
class BSF_AIOSRS_Pro_Schema_Wizard {
/**
* Hook in tabs.
*/
public function __construct() {
if ( apply_filters( 'wp_schema_pro_enable_setup_wizard', true ) && current_user_can( 'manage_options' ) ) {
add_action( 'admin_menu', array( $this, 'admin_menus' ) );
add_action( 'admin_init', array( $this, 'setup_wizard' ) );
}
}
/**
* Add admin menus/screens.
*/
public function admin_menus() {
add_dashboard_page( '', '', 'manage_options', 'aiosrs-pro-setup', '' );
}
/**
* Show the setup wizard.
*/
public function setup_wizard() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( $_REQUEST['wp_schema_pro_admin_page_nonce'], 'wp_schema_pro_admin_page' ) ) {
return;
}
if ( empty( $_GET['page'] ) || 'aiosrs-pro-setup' !== $_GET['page'] ) {
return;
}
$this->steps = array(
'basic-config' => array(
'name' => __( 'Choose Schema Type', 'wp-schema-pro' ),
'view' => array( $this, 'choose_schema_type' ),
'handler' => array( $this, 'choose_schema_type_save' ),
),
'enable-on' => array(
'name' => __( 'Set Target Pages', 'wp-schema-pro' ),
'view' => array( $this, 'implement_on_callback' ),
'handler' => array( $this, 'implement_on_callback_save' ),
),
'setup-ready' => array(
'name' => __( 'Ready!', 'wp-schema-pro' ),
'view' => array( $this, 'schema_ready' ),
'handler' => '',
),
);
$this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
wp_enqueue_style( 'aiosrs-pro-setup', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_css . 'setup-wizard.' . BSF_AIOSRS_Pro_Admin::$minfy_css_ext, array( 'dashicons', 'install' ), BSF_AIOSRS_PRO_VER );
wp_enqueue_style( 'aiosrs-pro-admin-edit-style', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_css . 'style.' . BSF_AIOSRS_Pro_Admin::$minfy_css_ext, BSF_AIOSRS_PRO_VER, 'false' );
wp_register_script( 'aiosrs-pro-admin-edit-script', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_js . 'script.' . BSF_AIOSRS_Pro_Admin::$minfy_js_ext, array( 'jquery', 'jquery-ui-tooltip' ), BSF_AIOSRS_PRO_VER, true );
wp_register_script( 'aiosrs-pro-setup', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_js . 'setup-wizard.' . BSF_AIOSRS_Pro_Admin::$minfy_js_ext, array( 'jquery' ), BSF_AIOSRS_PRO_VER, true );
wp_enqueue_style( 'bsf-target-rule-select2', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/select2.css', '', BSF_AIOSRS_PRO_VER, false );
wp_enqueue_style( 'bsf-target-rule', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/target-rule.css', '', BSF_AIOSRS_PRO_VER, false );
wp_register_script( 'bsf-target-rule-select2', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/select2.js', array( 'jquery', 'backbone', 'wp-util' ), BSF_AIOSRS_PRO_VER, true );
wp_register_script( 'bsf-target-rule', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/target-rule.js', array( 'jquery', 'bsf-target-rule-select2' ), BSF_AIOSRS_PRO_VER, true );
wp_register_script( 'bsf-user-role', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/user-role.js', array( 'jquery' ), BSF_AIOSRS_PRO_VER, true );
wp_enqueue_media();
wp_localize_script(
'bsf-target-rule',
'Targetrule',
array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'security' => wp_create_nonce( 'schema_nonce' ),
)
);
if ( ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'aiosrs-pro-setup' ) ) && ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
call_user_func( $this->steps[ $this->step ]['handler'] );
}
ob_start();
$this->setup_wizard_header();
$this->setup_wizard_steps();
$this->setup_wizard_content();
$this->setup_wizard_footer();
exit;
}
/**
* Get next step link
*/
public function get_next_step_link() {
$keys = array_keys( $this->steps );
return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ), true ) + 1 ] );
}
/**
* Setup Wizard Header.
*/
public function setup_wizard_header() {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php esc_html_e( 'Schema Setup', 'wp-schema-pro' ); ?></title>
<script type="text/javascript">
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
var ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ); ?>';
</script>
<?php wp_print_scripts( array( 'bsf-target-rule-select2', 'bsf-target-rule', 'bsf-user-role', 'aiosrs-pro-admin-edit-script', 'aiosrs-pro-setup' ) ); ?>
<?php do_action( 'admin_print_styles' ); ?>
</head>
<body class="aiosrs-pro-setup wp-core-ui">
<div id="aiosrs-pro-logo">
<?php
$brand_adv = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
if ( '' !== $brand_adv['sp_plugin_name'] ) {
?>
<h2 class="wpsp-setup-pro-title"><?php echo esc_html( $brand_adv['sp_plugin_name'] ); ?></h2>
<?php } else { ?>
<a href="<?php echo esc_url( BSF_AIOSRS_PRO_WEBSITE_URL ); ?>" target="_blank"><img src="<?php echo esc_url( BSF_AIOSRS_PRO_URI . '/admin/assets/images/schema-pro.png' ); ?>" alt="<?php esc_html_e( 'Schema Pro', 'wp-schema-pro' ); ?>" ></a>
<?php } ?>
</div>
<?php
}
/**
* Setup Wizard Footer.
*/
public function setup_wizard_footer() {
$admin_url = BSF_AIOSRS_Pro_Admin::get_page_url( BSF_AIOSRS_Pro_Admin::$parent_page_slug );
?>
<div class="close-button-wrapper">
<a href="<?php echo esc_url( $admin_url ); ?>" class="wizard-close-link" ><?php esc_html_e( 'Exit Setup Wizard', 'wp-schema-pro' ); ?></a>
</div>
</body>
</html>
<?php
}
/**
* Output the steps.
*/
public function setup_wizard_steps() {
$ouput_steps = $this->steps;
?>
<ol class="aiosrs-pro-setup-steps">
<?php
foreach ( $ouput_steps as $step_key => $step ) :
$classes = '';
if ( $step_key === $this->step ) {
$classes = 'active';
} elseif ( array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true ) ) {
$classes = 'done';
}
?>
<li class="<?php echo esc_attr( $classes ); ?>">
<span><?php echo esc_html( $step['name'] ); ?></span>
</li>
<?php endforeach; ?>
</ol>
<?php
}
/**
* Output the content for the current step.
*/
public function setup_wizard_content() {
echo '<div class="aiosrs-pro-setup-content">';
call_user_func( $this->steps[ $this->step ]['view'] );
echo '</div>';
}
/**
* Introduction step.
*/
public function choose_schema_type() {
?>
<h1><?php esc_html_e( 'Select the Schema Type:', 'wp-schema-pro' ); ?></h1>
<form method="post">
<input type="hidden" id="bsf-aiosrs-schema-title" name="bsf-aiosrs-schema-title" class="bsf-aiosrs-schema-title" >
<input type="hidden" id="bsf-aiosrs-schema-type" name="bsf-aiosrs-schema-type" class="bsf-aiosrs-schema-type" >
<table class="form-table aiosrs-pro-basic-config">
<tr>
<td><!-- Comment
<?php foreach ( BSF_AIOSRS_Pro_Schema::$schema_meta_fields as $key => $schema_field ) { ?>
--><span class="aiosrs-pro-schema-temp-wrap" data-schema-type="<?php echo esc_attr( $schema_field['key'] ); ?>" data-schema-title="<?php echo isset( $schema_field['label'] ) ? esc_attr( $schema_field['label'] ) : ''; ?>" >
<i class="<?php echo isset( $schema_field['icon'] ) ? esc_attr( $schema_field['icon'] ) : 'dashicons dashicons-media-default'; ?>"></i>
<?php echo isset( $schema_field['label'] ) ? esc_attr( $schema_field['label'] ) : ''; ?>
</span><!-- Comment
<?php } ?>
--></td>
</tr>
</table>
<p class="aiosrs-pro-setup-actions step">
<input type="submit" class="uct-activate button-primary button button-large button-next" disabled="true" value="<?php esc_html_e( 'Next', 'wp-schema-pro' ); ?>" name="save_step" />
<?php wp_nonce_field( 'aiosrs-pro-setup' ); ?>
</p>
</form>
<?php
}
/**
* Save Locale Settings.
*/
public function choose_schema_type_save() {
check_admin_referer( 'aiosrs-pro-setup' );
// Update site title & tagline.
$redirect_url = $this->get_next_step_link();
$title = isset( $_POST['bsf-aiosrs-schema-title'] ) ? sanitize_text_field( $_POST['bsf-aiosrs-schema-title'] ) : 0;
$type = isset( $_POST['bsf-aiosrs-schema-type'] ) ? sanitize_text_field( $_POST['bsf-aiosrs-schema-type'] ) : 0;
$default_fields = array();
if ( isset( BSF_AIOSRS_Pro_Schema::$schema_meta_fields[ 'bsf-aiosrs-' . $type ]['subkeys'] ) ) {
$default_data = BSF_AIOSRS_Pro_Schema::$schema_meta_fields[ 'bsf-aiosrs-' . $type ]['subkeys'];
foreach ( $default_data as $key => $value ) {
if ( 'repeater' === $value['type'] ) {
foreach ( $value['fields'] as $subkey => $subvalue ) {
if ( isset( $subvalue['default'] ) && 'none' !== $subvalue['default'] ) {
$default_fields[ $key ][0][ $subkey ] = $subvalue['default'];
} else {
$default_fields[ $key ][0][ $subkey ] = 'create-field';
}
}
} else {
if ( isset( $value['default'] ) && 'none' !== $value['default'] ) {
$default_fields[ $key ] = $value['default'];
} else {
$default_fields[ $key ] = 'create-field';
}
}
}
}
$postarr = array(
'post_type' => 'aiosrs-schema',
'post_title' => $title,
'post_status' => 'publish',
'meta_input' => array(
'bsf-aiosrs-schema-type' => $type,
'bsf-aiosrs-' . $type => $default_fields,
),
);
$post_id = wp_insert_post( $postarr );
if ( ! is_wp_error( $post_id ) ) {
$redirect_url = add_query_arg( 'schema-id', $post_id, $redirect_url );
}
wp_safe_redirect( esc_url_raw( $redirect_url ) );
exit;
}
/**
* Locale settings
*/
public function implement_on_callback() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( $_REQUEST['wp_schema_pro_admin_page_nonce'], 'wp_schema_pro_admin_page' ) ) {
return;
}
$schema_id = 0;
$title = '';
$redirect_url = $this->get_next_step_link();
if ( isset( $_GET['schema-id'] ) && ! empty( $_GET['schema-id'] ) ) {
$schema_id = intval( $_GET['schema-id'] );
$redirect_url = add_query_arg( 'schema-id', $schema_id, $redirect_url );
$title = get_the_title( $schema_id );
}
$meta_values = array(
'include-locations' => array(
'rule' => array( 'basic-singulars' ),
),
'exclude-locations' => array(),
);
?>
<h1>
<?php
printf(
/* translators: 1 schema title */
wp_kses_post( 'Where %s schema should be integrated?', 'wp-schema-pro' ),
esc_html( $title )
);
?>
</h1>
<form method="post">
<input type="hidden" name="schema-id" value="<?php echo esc_attr( $schema_id ); ?>">
<table class="bsf-aiosrs-schema-table widefat">
<tr class="bsf-aiosrs-schema-row">
<td class="bsf-aiosrs-schema-row-heading">
<label><?php esc_html_e( 'Enable On', 'wp-schema-pro' ); ?></label>
<i class="bsf-aiosrs-schema-heading-help dashicons dashicons-editor-help" title="<?php echo esc_attr__( 'Add target pages where this Schema should appear.', 'wp-schema-pro' ); ?>"></i>
</td>
<td class="bsf-aiosrs-schema-row-content">
<?php
BSF_Target_Rule_Fields::target_rule_settings_field(
'bsf-aiosrs-schema-location',
array(
'title' => __( 'Display Rules', 'wp-schema-pro' ),
'value' => '[{"type":"basic-global","specific":null}]',
'tags' => 'site,enable,target,pages',
'rule_type' => 'display',
'add_rule_label' => __( 'Add “AND” Rule', 'wp-schema-pro' ),
),
$meta_values['include-locations']
);
?>
</td>
</tr>
<tr class="bsf-aiosrs-schema-row">
<td class="bsf-aiosrs-schema-row-heading">
<label><?php esc_html_e( 'Exclude From', 'wp-schema-pro' ); ?></label>
<i class="bsf-aiosrs-schema-heading-help dashicons dashicons-editor-help" title="<?php echo esc_attr__( 'This Schema will not appear at these pages.', 'wp-schema-pro' ); ?>"></i>
</td>
<td class="bsf-aiosrs-schema-row-content">
<?php
BSF_Target_Rule_Fields::target_rule_settings_field(
'bsf-aiosrs-schema-exclusion',
array(
'title' => __( 'Exclude On', 'wp-schema-pro' ),
'value' => '[]',
'tags' => 'site,enable,target,pages',
'add_rule_label' => __( 'Add “OR” Rule', 'wp-schema-pro' ),
'rule_type' => 'exclude',
),
$meta_values['exclude-locations']
);
?>
</td>
</tr>
</table>
<p class="aiosrs-pro-setup-actions step">
<input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Next', 'wp-schema-pro' ); ?>" name="save_step" />
<?php wp_nonce_field( 'aiosrs-pro-setup' ); ?>
</p>
</form>
<?php
}
/**
* Save Locale Settings.
*/
public function implement_on_callback_save() {
check_admin_referer( 'aiosrs-pro-setup' );
$schema_id = isset( $_POST['schema-id'] ) ? sanitize_text_field( $_POST['schema-id'] ) : 0;
$enabled_on = BSF_Target_Rule_Fields::get_format_rule_value( $_POST, 'bsf-aiosrs-schema-location' );
$exclude_from = BSF_Target_Rule_Fields::get_format_rule_value( $_POST, 'bsf-aiosrs-schema-exclusion' );
$redirect_url = $this->get_next_step_link();
if ( $schema_id ) {
$redirect_url = add_query_arg( 'schema-id', $schema_id, $redirect_url );
update_post_meta( $schema_id, 'bsf-aiosrs-schema-location', $enabled_on );
update_post_meta( $schema_id, 'bsf-aiosrs-schema-exclusion', $exclude_from );
}
wp_safe_redirect( esc_url_raw( $redirect_url ) );
exit;
}
/**
* Get Location rules of schema for Custom meta box.
*
* @param array $enabled_on Enabled on rules.
* @param array $exclude_from Exlcude on rules.
* @return array
*/
public static function get_display_rules_for_meta_box( $enabled_on, $exclude_from ) {
$locations = array();
$enabled_location = array();
$exclude_location = array();
$args = array(
'public' => true,
'_builtin' => true,
);
$post_types = get_post_types( $args );
unset( $post_types['attachment'] );
$args['_builtin'] = false;
$custom_post_type = get_post_types( $args );
$post_types = array_merge( $post_types, $custom_post_type );
if ( ! empty( $enabled_on ) && isset( $enabled_on['rule'] ) ) {
$enabled_location = $enabled_on['rule'];
}
if ( ! empty( $exclude_from ) && isset( $exclude_from['rule'] ) ) {
$exclude_location = $exclude_from['rule'];
}
if ( in_array( 'specifics', $enabled_location, true ) || ( in_array( 'basic-singulars', $enabled_location, true ) && ! in_array( 'basic-singulars', $exclude_location, true ) ) ) {
foreach ( $post_types as $post_type ) {
$locations[ $post_type ] = 1;
}
} else {
foreach ( $post_types as $post_type ) {
$key = $post_type . '|all';
if ( in_array( $key, $enabled_location, true ) && ! in_array( $key, $exclude_location, true ) ) {
$locations[ $post_type ] = 1;
}
}
}
return $locations;
}
/**
* Final step.
*/
public function schema_ready() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( $_REQUEST['wp_schema_pro_admin_page_nonce'], 'wp_schema_pro_admin_page' ) ) {
return;
}
$schema_id = 0;
$title = '';
if ( isset( $_GET['schema-id'] ) && ! empty( $_GET['schema-id'] ) ) {
$schema_id = intval( $_GET['schema-id'] );
$title = get_the_title( $schema_id );
}
?>
<h1><?php esc_html_e( 'Your Schema is Ready!', 'wp-schema-pro' ); ?></h1>
<div class="aiosrs-pro-setup-next-steps">
<div class="aiosrs-pro-setup-next-steps-last">
<p class="success">
<?php
printf(
/* translators: 1 schema title */
wp_kses_post( 'Congratulations! The <i>%s</i> Schema has been added and enabled on selected target locations.', 'wp-schema-pro' ),
esc_html( $title )
);
?>
</p>
<p class="success">
<strong><?php esc_html_e( 'Heres what to do next:', 'wp-schema-pro' ); ?></strong><br>
<?php esc_html_e( 'Step 1: Complete the setup and proceed to fill the required properties of this schema.', 'wp-schema-pro' ); ?><br>
<?php esc_html_e( 'Step 2: Add necessary Schema information on individual pages and posts.', 'wp-schema-pro' ); ?><br>
<?php esc_html_e( 'Step 3: Test if Schema is integrated correctly.', 'wp-schema-pro' ); ?>
</p>
<table class="form-table aiosrs-pro-schema-ready">
<tr>
<td>
<a href="<?php echo ( $schema_id ) ? esc_attr( get_edit_post_link( $schema_id ) ) : '#'; ?>" type="button" class="button button-primary button-hero" ><?php esc_html_e( 'Complete Setup', 'wp-schema-pro' ); ?></a>
</td>
</tr>
</table>
</div>
</div>
<?php
}
}
new BSF_AIOSRS_Pro_Schema_Wizard();
endif;
<?php
/**
* Schema Pro - Schema Wizard
*
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Wizard' ) ) :
/**
* BSF_AIOSRS_Pro_Schema_Wizard class.
*/
class BSF_AIOSRS_Pro_Schema_Wizard {
/**
* Hook in tabs.
*/
public function __construct() {
if ( apply_filters( 'wp_schema_pro_enable_setup_wizard', true ) && current_user_can( 'manage_options' ) ) {
add_action( 'admin_menu', array( $this, 'admin_menus' ) );
add_action( 'admin_init', array( $this, 'setup_wizard' ) );
}
}
/**
* Add admin menus/screens.
*/
public function admin_menus() {
add_dashboard_page( '', '', 'manage_options', 'aiosrs-pro-setup', '' );
}
/**
* Show the setup wizard.
*/
public function setup_wizard() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( $_REQUEST['wp_schema_pro_admin_page_nonce'], 'wp_schema_pro_admin_page' ) ) {
return;
}
if ( empty( $_GET['page'] ) || 'aiosrs-pro-setup' !== $_GET['page'] ) {
return;
}
$this->steps = array(
'basic-config' => array(
'name' => __( 'Choose Schema Type', 'wp-schema-pro' ),
'view' => array( $this, 'choose_schema_type' ),
'handler' => array( $this, 'choose_schema_type_save' ),
),
'enable-on' => array(
'name' => __( 'Set Target Pages', 'wp-schema-pro' ),
'view' => array( $this, 'implement_on_callback' ),
'handler' => array( $this, 'implement_on_callback_save' ),
),
'setup-ready' => array(
'name' => __( 'Ready!', 'wp-schema-pro' ),
'view' => array( $this, 'schema_ready' ),
'handler' => '',
),
);
$this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
wp_enqueue_style( 'aiosrs-pro-setup', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_css . 'setup-wizard.' . BSF_AIOSRS_Pro_Admin::$minfy_css_ext, array( 'dashicons', 'install' ), BSF_AIOSRS_PRO_VER );
wp_enqueue_style( 'aiosrs-pro-admin-edit-style', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_css . 'style.' . BSF_AIOSRS_Pro_Admin::$minfy_css_ext, BSF_AIOSRS_PRO_VER, 'false' );
wp_register_script( 'aiosrs-pro-admin-edit-script', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_js . 'script.' . BSF_AIOSRS_Pro_Admin::$minfy_js_ext, array( 'jquery', 'jquery-ui-tooltip' ), BSF_AIOSRS_PRO_VER, true );
wp_register_script( 'aiosrs-pro-setup', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_js . 'setup-wizard.' . BSF_AIOSRS_Pro_Admin::$minfy_js_ext, array( 'jquery' ), BSF_AIOSRS_PRO_VER, true );
wp_enqueue_style( 'bsf-target-rule-select2', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/select2.css', '', BSF_AIOSRS_PRO_VER, false );
wp_enqueue_style( 'bsf-target-rule', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/target-rule.css', '', BSF_AIOSRS_PRO_VER, false );
wp_register_script( 'bsf-target-rule-select2', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/select2.js', array( 'jquery', 'backbone', 'wp-util' ), BSF_AIOSRS_PRO_VER, true );
wp_register_script( 'bsf-target-rule', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/target-rule.js', array( 'jquery', 'bsf-target-rule-select2' ), BSF_AIOSRS_PRO_VER, true );
wp_register_script( 'bsf-user-role', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/user-role.js', array( 'jquery' ), BSF_AIOSRS_PRO_VER, true );
wp_enqueue_media();
wp_localize_script(
'bsf-target-rule',
'Targetrule',
array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'security' => wp_create_nonce( 'schema_nonce' ),
)
);
if ( ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'aiosrs-pro-setup' ) ) && ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
call_user_func( $this->steps[ $this->step ]['handler'] );
}
ob_start();
$this->setup_wizard_header();
$this->setup_wizard_steps();
$this->setup_wizard_content();
$this->setup_wizard_footer();
exit;
}
/**
* Get next step link
*/
public function get_next_step_link() {
$keys = array_keys( $this->steps );
return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ), true ) + 1 ] );
}
/**
* Setup Wizard Header.
*/
public function setup_wizard_header() {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php esc_html_e( 'Schema Setup', 'wp-schema-pro' ); ?></title>
<script type="text/javascript">
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
var ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ); ?>';
</script>
<?php wp_print_scripts( array( 'bsf-target-rule-select2', 'bsf-target-rule', 'bsf-user-role', 'aiosrs-pro-admin-edit-script', 'aiosrs-pro-setup' ) ); ?>
<?php do_action( 'admin_print_styles' ); ?>
</head>
<body class="aiosrs-pro-setup wp-core-ui">
<div id="aiosrs-pro-logo">
<?php
$brand_adv = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
if ( '' !== $brand_adv['sp_plugin_name'] ) {
?>
<h2 class="wpsp-setup-pro-title"><?php echo esc_html( $brand_adv['sp_plugin_name'] ); ?></h2>
<?php } else { ?>
<a href="<?php echo esc_url( BSF_AIOSRS_PRO_WEBSITE_URL ); ?>" target="_blank"><img src="<?php echo esc_url( BSF_AIOSRS_PRO_URI . '/admin/assets/images/schema-pro.png' ); ?>" alt="<?php esc_html_e( 'Schema Pro', 'wp-schema-pro' ); ?>" ></a>
<?php } ?>
</div>
<?php
}
/**
* Setup Wizard Footer.
*/
public function setup_wizard_footer() {
$admin_url = BSF_AIOSRS_Pro_Admin::get_page_url( BSF_AIOSRS_Pro_Admin::$parent_page_slug );
?>
<div class="close-button-wrapper">
<a href="<?php echo esc_url( $admin_url ); ?>" class="wizard-close-link" ><?php esc_html_e( 'Exit Setup Wizard', 'wp-schema-pro' ); ?></a>
</div>
</body>
</html>
<?php
}
/**
* Output the steps.
*/
public function setup_wizard_steps() {
$ouput_steps = $this->steps;
?>
<ol class="aiosrs-pro-setup-steps">
<?php
foreach ( $ouput_steps as $step_key => $step ) :
$classes = '';
if ( $step_key === $this->step ) {
$classes = 'active';
} elseif ( array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true ) ) {
$classes = 'done';
}
?>
<li class="<?php echo esc_attr( $classes ); ?>">
<span><?php echo esc_html( $step['name'] ); ?></span>
</li>
<?php endforeach; ?>
</ol>
<?php
}
/**
* Output the content for the current step.
*/
public function setup_wizard_content() {
echo '<div class="aiosrs-pro-setup-content">';
call_user_func( $this->steps[ $this->step ]['view'] );
echo '</div>';
}
/**
* Introduction step.
*/
public function choose_schema_type() {
?>
<h1><?php esc_html_e( 'Select the Schema Type:', 'wp-schema-pro' ); ?></h1>
<form method="post">
<input type="hidden" id="bsf-aiosrs-schema-title" name="bsf-aiosrs-schema-title" class="bsf-aiosrs-schema-title" >
<input type="hidden" id="bsf-aiosrs-schema-type" name="bsf-aiosrs-schema-type" class="bsf-aiosrs-schema-type" >
<table class="form-table aiosrs-pro-basic-config">
<tr>
<td><!-- Comment
<?php foreach ( BSF_AIOSRS_Pro_Schema::$schema_meta_fields as $key => $schema_field ) { ?>
--><span class="aiosrs-pro-schema-temp-wrap" data-schema-type="<?php echo esc_attr( $schema_field['key'] ); ?>" data-schema-title="<?php echo isset( $schema_field['label'] ) ? esc_attr( $schema_field['label'] ) : ''; ?>" >
<i class="<?php echo isset( $schema_field['icon'] ) ? esc_attr( $schema_field['icon'] ) : 'dashicons dashicons-media-default'; ?>"></i>
<?php echo isset( $schema_field['label'] ) ? esc_attr( $schema_field['label'] ) : ''; ?>
</span><!-- Comment
<?php } ?>
--></td>
</tr>
</table>
<p class="aiosrs-pro-setup-actions step">
<input type="submit" class="uct-activate button-primary button button-large button-next" disabled="true" value="<?php esc_html_e( 'Next', 'wp-schema-pro' ); ?>" name="save_step" />
<?php wp_nonce_field( 'aiosrs-pro-setup' ); ?>
</p>
</form>
<?php
}
/**
* Save Locale Settings.
*/
public function choose_schema_type_save() {
check_admin_referer( 'aiosrs-pro-setup' );
// Update site title & tagline.
$redirect_url = $this->get_next_step_link();
$title = isset( $_POST['bsf-aiosrs-schema-title'] ) ? sanitize_text_field( $_POST['bsf-aiosrs-schema-title'] ) : 0;
$type = isset( $_POST['bsf-aiosrs-schema-type'] ) ? sanitize_text_field( $_POST['bsf-aiosrs-schema-type'] ) : 0;
$default_fields = array();
if ( isset( BSF_AIOSRS_Pro_Schema::$schema_meta_fields[ 'bsf-aiosrs-' . $type ]['subkeys'] ) ) {
$default_data = BSF_AIOSRS_Pro_Schema::$schema_meta_fields[ 'bsf-aiosrs-' . $type ]['subkeys'];
foreach ( $default_data as $key => $value ) {
if ( 'repeater' === $value['type'] ) {
foreach ( $value['fields'] as $subkey => $subvalue ) {
if ( isset( $subvalue['default'] ) && 'none' !== $subvalue['default'] ) {
$default_fields[ $key ][0][ $subkey ] = $subvalue['default'];
} else {
$default_fields[ $key ][0][ $subkey ] = 'create-field';
}
}
} else {
if ( isset( $value['default'] ) && 'none' !== $value['default'] ) {
$default_fields[ $key ] = $value['default'];
} else {
$default_fields[ $key ] = 'create-field';
}
}
}
}
$postarr = array(
'post_type' => 'aiosrs-schema',
'post_title' => $title,
'post_status' => 'publish',
'meta_input' => array(
'bsf-aiosrs-schema-type' => $type,
'bsf-aiosrs-' . $type => $default_fields,
),
);
$post_id = wp_insert_post( $postarr );
if ( ! is_wp_error( $post_id ) ) {
$redirect_url = add_query_arg( 'schema-id', $post_id, $redirect_url );
}
wp_safe_redirect( esc_url_raw( $redirect_url ) );
exit;
}
/**
* Locale settings
*/
public function implement_on_callback() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( $_REQUEST['wp_schema_pro_admin_page_nonce'], 'wp_schema_pro_admin_page' ) ) {
return;
}
$schema_id = 0;
$title = '';
$redirect_url = $this->get_next_step_link();
if ( isset( $_GET['schema-id'] ) && ! empty( $_GET['schema-id'] ) ) {
$schema_id = intval( $_GET['schema-id'] );
$redirect_url = add_query_arg( 'schema-id', $schema_id, $redirect_url );
$title = get_the_title( $schema_id );
}
$meta_values = array(
'include-locations' => array(
'rule' => array( 'basic-singulars' ),
),
'exclude-locations' => array(),
);
?>
<h1>
<?php
printf(
/* translators: 1 schema title */
wp_kses_post( 'Where %s schema should be integrated?', 'wp-schema-pro' ),
esc_html( $title )
);
?>
</h1>
<form method="post">
<input type="hidden" name="schema-id" value="<?php echo esc_attr( $schema_id ); ?>">
<table class="bsf-aiosrs-schema-table widefat">
<tr class="bsf-aiosrs-schema-row">
<td class="bsf-aiosrs-schema-row-heading">
<label><?php esc_html_e( 'Enable On', 'wp-schema-pro' ); ?></label>
<i class="bsf-aiosrs-schema-heading-help dashicons dashicons-editor-help" title="<?php echo esc_attr__( 'Add target pages where this Schema should appear.', 'wp-schema-pro' ); ?>"></i>
</td>
<td class="bsf-aiosrs-schema-row-content">
<?php
BSF_Target_Rule_Fields::target_rule_settings_field(
'bsf-aiosrs-schema-location',
array(
'title' => __( 'Display Rules', 'wp-schema-pro' ),
'value' => '[{"type":"basic-global","specific":null}]',
'tags' => 'site,enable,target,pages',
'rule_type' => 'display',
'add_rule_label' => __( 'Add “AND” Rule', 'wp-schema-pro' ),
),
$meta_values['include-locations']
);
?>
</td>
</tr>
<tr class="bsf-aiosrs-schema-row">
<td class="bsf-aiosrs-schema-row-heading">
<label><?php esc_html_e( 'Exclude From', 'wp-schema-pro' ); ?></label>
<i class="bsf-aiosrs-schema-heading-help dashicons dashicons-editor-help" title="<?php echo esc_attr__( 'This Schema will not appear at these pages.', 'wp-schema-pro' ); ?>"></i>
</td>
<td class="bsf-aiosrs-schema-row-content">
<?php
BSF_Target_Rule_Fields::target_rule_settings_field(
'bsf-aiosrs-schema-exclusion',
array(
'title' => __( 'Exclude On', 'wp-schema-pro' ),
'value' => '[]',
'tags' => 'site,enable,target,pages',
'add_rule_label' => __( 'Add “OR” Rule', 'wp-schema-pro' ),
'rule_type' => 'exclude',
),
$meta_values['exclude-locations']
);
?>
</td>
</tr>
</table>
<p class="aiosrs-pro-setup-actions step">
<input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Next', 'wp-schema-pro' ); ?>" name="save_step" />
<?php wp_nonce_field( 'aiosrs-pro-setup' ); ?>
</p>
</form>
<?php
}
/**
* Save Locale Settings.
*/
public function implement_on_callback_save() {
check_admin_referer( 'aiosrs-pro-setup' );
$schema_id = isset( $_POST['schema-id'] ) ? sanitize_text_field( $_POST['schema-id'] ) : 0;
$enabled_on = BSF_Target_Rule_Fields::get_format_rule_value( $_POST, 'bsf-aiosrs-schema-location' );
$exclude_from = BSF_Target_Rule_Fields::get_format_rule_value( $_POST, 'bsf-aiosrs-schema-exclusion' );
$redirect_url = $this->get_next_step_link();
if ( $schema_id ) {
$redirect_url = add_query_arg( 'schema-id', $schema_id, $redirect_url );
update_post_meta( $schema_id, 'bsf-aiosrs-schema-location', $enabled_on );
update_post_meta( $schema_id, 'bsf-aiosrs-schema-exclusion', $exclude_from );
}
wp_safe_redirect( esc_url_raw( $redirect_url ) );
exit;
}
/**
* Get Location rules of schema for Custom meta box.
*
* @param array $enabled_on Enabled on rules.
* @param array $exclude_from Exlcude on rules.
* @return array
*/
public static function get_display_rules_for_meta_box( $enabled_on, $exclude_from ) {
$locations = array();
$enabled_location = array();
$exclude_location = array();
$args = array(
'public' => true,
'_builtin' => true,
);
$post_types = get_post_types( $args );
unset( $post_types['attachment'] );
$args['_builtin'] = false;
$custom_post_type = get_post_types( $args );
$post_types = array_merge( $post_types, $custom_post_type );
if ( ! empty( $enabled_on ) && isset( $enabled_on['rule'] ) ) {
$enabled_location = $enabled_on['rule'];
}
if ( ! empty( $exclude_from ) && isset( $exclude_from['rule'] ) ) {
$exclude_location = $exclude_from['rule'];
}
if ( in_array( 'specifics', $enabled_location, true ) || ( in_array( 'basic-singulars', $enabled_location, true ) && ! in_array( 'basic-singulars', $exclude_location, true ) ) ) {
foreach ( $post_types as $post_type ) {
$locations[ $post_type ] = 1;
}
} else {
foreach ( $post_types as $post_type ) {
$key = $post_type . '|all';
if ( in_array( $key, $enabled_location, true ) && ! in_array( $key, $exclude_location, true ) ) {
$locations[ $post_type ] = 1;
}
}
}
return $locations;
}
/**
* Final step.
*/
public function schema_ready() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( $_REQUEST['wp_schema_pro_admin_page_nonce'], 'wp_schema_pro_admin_page' ) ) {
return;
}
$schema_id = 0;
$title = '';
if ( isset( $_GET['schema-id'] ) && ! empty( $_GET['schema-id'] ) ) {
$schema_id = intval( $_GET['schema-id'] );
$title = get_the_title( $schema_id );
}
?>
<h1><?php esc_html_e( 'Your Schema is Ready!', 'wp-schema-pro' ); ?></h1>
<div class="aiosrs-pro-setup-next-steps">
<div class="aiosrs-pro-setup-next-steps-last">
<p class="success">
<?php
printf(
/* translators: 1 schema title */
wp_kses_post( 'Congratulations! The <i>%s</i> Schema has been added and enabled on selected target locations.', 'wp-schema-pro' ),
esc_html( $title )
);
?>
</p>
<p class="success">
<strong><?php esc_html_e( 'Heres what to do next:', 'wp-schema-pro' ); ?></strong><br>
<?php esc_html_e( 'Step 1: Complete the setup and proceed to fill the required properties of this schema.', 'wp-schema-pro' ); ?><br>
<?php esc_html_e( 'Step 2: Add necessary Schema information on individual pages and posts.', 'wp-schema-pro' ); ?><br>
<?php esc_html_e( 'Step 3: Test if Schema is integrated correctly.', 'wp-schema-pro' ); ?>
</p>
<table class="form-table aiosrs-pro-schema-ready">
<tr>
<td>
<a href="<?php echo ( $schema_id ) ? esc_attr( get_edit_post_link( $schema_id ) ) : '#'; ?>" type="button" class="button button-primary button-hero" ><?php esc_html_e( 'Complete Setup', 'wp-schema-pro' ); ?></a>
</td>
</tr>
</table>
</div>
</div>
<?php
}
}
new BSF_AIOSRS_Pro_Schema_Wizard();
endif;
@@ -156,7 +156,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
check_ajax_referer( 'schema_nonce', 'nonce' );
$item_type = filter_input( INPUT_POST, 'itemType', FILTER_SANITIZE_STRING );
$item_type = sanitize_text_field( $_POST['itemType'] );
$post_id = filter_input( INPUT_POST, 'post_id', FILTER_VALIDATE_INT );
$item_type_fields = self::$schema_item_types[ $item_type ]['subkeys'];
@@ -4497,7 +4497,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema' ) ) {
switch ( $sanitize_filter ) {
case 'FILTER_SANITIZE_STRING':
$meta_value = filter_input( INPUT_POST, $key, FILTER_SANITIZE_STRING );
$meta_value = sanitize_text_field( $_POST[ $key ] );
break;
case 'FILTER_SANITIZE_URL':
File diff suppressed because it is too large Load Diff
@@ -1,130 +1,130 @@
<?php
/**
* Schema Pro Init
*
* @package Schema Pro
*/
define( 'BSF_REMOVE_WP-SCHEMA-PRO_FROM_REGISTRATION_LISTING', true );
if ( ! class_exists( 'BSF_AIOSRS_Pro' ) ) {
/**
* BSF_AIOSRS_Pro initial setup
*
* @since 1.0.0
*/
class BSF_AIOSRS_Pro {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
// Includes Required Files.
$this->includes();
add_action( 'admin_notices', array( $this, 'setup_wizard_notice' ) );
add_action( 'wp_ajax_wp_schema_pro_setup_wizard_notice', array( $this, 'wp_schema_pro_setup_wizard_notice_callback' ) );
}
/**
* Setup Wizard
*
* @since 1.1.0
*/
public function setup_wizard_notice() {
if ( get_transient( 'wp-schema-pro-activated' ) ) {
$url = admin_url( 'index.php?page=aiosrs-pro-setup-wizard' );
$branding_notice = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
echo '<div class="wp-schema-pro-setup-wizard-notice notice notice-success is-dismissible">';
if ( '' !== $branding_notice['sp_plugin_name'] ) {
/* translators: %s: search term */
$brand_notice = sprintf( esc_html__( 'Configure %s step by step. ', 'wp-schema-pro' ), $branding_notice['sp_plugin_name'] );
echo '<p>' . esc_html( $brand_notice ) . '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Start Setup Wizard &raquo;', 'wp-schema-pro' ) . '</a></p>';
} else {
echo '<p>' . esc_html__( 'Not sure where to start with Schema Pro? Check out our initial ', 'wp-schema-pro' ) . '<a href="' . esc_url( $url ) . '">' . esc_html__( 'setup wizard first &raquo;', 'wp-schema-pro' ) . '</a></p>';
}
echo '</div>';
?>
<script type="text/javascript">
(function($){
$(document).on('click', '.wp-schema-pro-setup-wizard-notice .notice-dismiss', function(){
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
action : 'wp_schema_pro_setup_wizard_notice',
nonce : '<?php echo esc_attr( wp_create_nonce( 'wp-schema-pro-setup-wizard-notice' ) ); ?>'
},
});
});
})(jQuery);
</script>
<?php
}
}
/**
* Dismiss Notice
*
* @return void
*/
public function wp_schema_pro_setup_wizard_notice_callback() {
check_ajax_referer( 'wp-schema-pro-setup-wizard-notice', 'nonce' );
delete_transient( 'wp-schema-pro-activated' );
wp_send_json_success();
}
/**
* Include required files.
*
* @since 1.0.0
* @return void
*/
public function includes() {
require_once BSF_AIOSRS_PRO_DIR . 'classes/lib/target-rule/class-bsf-target-rule-fields.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/lib/class-bsf-custom-post-list-table.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-wp-schema-pro-yoast-compatibility.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-admin.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-schema.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-custom-fields-markup.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-branding.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-amp.php';
/**
* Frontend.
*/
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-schema-template.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-markup.php';
}
}
}
/**
* Kicking this off by calling 'get_instance()' method
*/
BSF_AIOSRS_Pro::get_instance();
<?php
/**
* Schema Pro Init
*
* @package Schema Pro
*/
define( 'BSF_REMOVE_WP-SCHEMA-PRO_FROM_REGISTRATION_LISTING', true );
if ( ! class_exists( 'BSF_AIOSRS_Pro' ) ) {
/**
* BSF_AIOSRS_Pro initial setup
*
* @since 1.0.0
*/
class BSF_AIOSRS_Pro {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
// Includes Required Files.
$this->includes();
add_action( 'admin_notices', array( $this, 'setup_wizard_notice' ) );
add_action( 'wp_ajax_wp_schema_pro_setup_wizard_notice', array( $this, 'wp_schema_pro_setup_wizard_notice_callback' ) );
}
/**
* Setup Wizard
*
* @since 1.1.0
*/
public function setup_wizard_notice() {
if ( get_transient( 'wp-schema-pro-activated' ) ) {
$url = admin_url( 'index.php?page=aiosrs-pro-setup-wizard' );
$branding_notice = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
echo '<div class="wp-schema-pro-setup-wizard-notice notice notice-success is-dismissible">';
if ( '' !== $branding_notice['sp_plugin_name'] ) {
/* translators: %s: search term */
$brand_notice = sprintf( esc_html__( 'Configure %s step by step. ', 'wp-schema-pro' ), $branding_notice['sp_plugin_name'] );
echo '<p>' . esc_html( $brand_notice ) . '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Start Setup Wizard &raquo;', 'wp-schema-pro' ) . '</a></p>';
} else {
echo '<p>' . esc_html__( 'Not sure where to start with Schema Pro? Check out our initial ', 'wp-schema-pro' ) . '<a href="' . esc_url( $url ) . '">' . esc_html__( 'setup wizard first &raquo;', 'wp-schema-pro' ) . '</a></p>';
}
echo '</div>';
?>
<script type="text/javascript">
(function($){
$(document).on('click', '.wp-schema-pro-setup-wizard-notice .notice-dismiss', function(){
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
action : 'wp_schema_pro_setup_wizard_notice',
nonce : '<?php echo esc_attr( wp_create_nonce( 'wp-schema-pro-setup-wizard-notice' ) ); ?>'
},
});
});
})(jQuery);
</script>
<?php
}
}
/**
* Dismiss Notice
*
* @return void
*/
public function wp_schema_pro_setup_wizard_notice_callback() {
check_ajax_referer( 'wp-schema-pro-setup-wizard-notice', 'nonce' );
delete_transient( 'wp-schema-pro-activated' );
wp_send_json_success();
}
/**
* Include required files.
*
* @since 1.0.0
* @return void
*/
public function includes() {
require_once BSF_AIOSRS_PRO_DIR . 'classes/lib/target-rule/class-bsf-target-rule-fields.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/lib/class-bsf-custom-post-list-table.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-wp-schema-pro-yoast-compatibility.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-admin.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-schema.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-custom-fields-markup.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-branding.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-amp.php';
/**
* Frontend.
*/
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-schema-template.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-markup.php';
}
}
}
/**
* Kicking this off by calling 'get_instance()' method
*/
BSF_AIOSRS_Pro::get_instance();
@@ -1,91 +1,91 @@
<?php
/**
* Schema Pro Yoast Compatibilty
*
* @since 1.1.0
* @package Schema Pro
*/
if ( ! class_exists( 'WP_Schema_Pro_Yoast_Compatibility' ) ) {
/**
* WP_Schema_Pro_Yoast_Compatibility initial setup
*
* @since 1.1.0
*/
class WP_Schema_Pro_Yoast_Compatibility {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Yoast SEO is activated or not.
*
* @access private
* @var $activated Yoast SEO is activated or not.
*/
public static $activated = false;
/**
* Yoast SEO Options.
*
* @access private
* @var $wpseo Yoast SEO options.
*/
private static $wpseo = array();
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor function.
*/
public function __construct() {
if ( defined( 'WPSEO_VERSION' ) && class_exists( 'WPSEO_Options' ) ) {
self::$activated = true;
}
}
/**
* Get Yoast Options
*
* @param string $key Yoast Option key.
* @return array Get yoast compatibility options.
*/
public static function get_option( $key = '' ) {
$settings = get_option( 'aiosrs-pro-settings', array() );
if ( ! self::$activated || ( isset( $settings['yoast-compatibility'] ) && '1' !== $settings['yoast-compatibility'] ) ) {
return false;
}
if ( 'wp_schema_pro_yoast_enabled' === $key ) {
return true;
}
if ( empty( self::$wpseo ) && method_exists( 'WPSEO_Options', 'get_options' ) ) {
self::$wpseo = WPSEO_Options::get_options( array( 'wpseo', 'wpseo_social', 'wpseo_internallinks', 'wpseo_titles' ) );
}
return isset( self::$wpseo[ $key ] ) ? self::$wpseo[ $key ] : false;
}
}
}
/**
* Kicking this off by calling 'get_instance()' method
*/
WP_Schema_Pro_Yoast_Compatibility::get_instance();
<?php
/**
* Schema Pro Yoast Compatibilty
*
* @since 1.1.0
* @package Schema Pro
*/
if ( ! class_exists( 'WP_Schema_Pro_Yoast_Compatibility' ) ) {
/**
* WP_Schema_Pro_Yoast_Compatibility initial setup
*
* @since 1.1.0
*/
class WP_Schema_Pro_Yoast_Compatibility {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Yoast SEO is activated or not.
*
* @access private
* @var $activated Yoast SEO is activated or not.
*/
public static $activated = false;
/**
* Yoast SEO Options.
*
* @access private
* @var $wpseo Yoast SEO options.
*/
private static $wpseo = array();
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor function.
*/
public function __construct() {
if ( defined( 'WPSEO_VERSION' ) && class_exists( 'WPSEO_Options' ) ) {
self::$activated = true;
}
}
/**
* Get Yoast Options
*
* @param string $key Yoast Option key.
* @return array Get yoast compatibility options.
*/
public static function get_option( $key = '' ) {
$settings = get_option( 'aiosrs-pro-settings', array() );
if ( ! self::$activated || ( isset( $settings['yoast-compatibility'] ) && '1' !== $settings['yoast-compatibility'] ) ) {
return false;
}
if ( 'wp_schema_pro_yoast_enabled' === $key ) {
return true;
}
if ( empty( self::$wpseo ) && method_exists( 'WPSEO_Options', 'get_options' ) ) {
self::$wpseo = WPSEO_Options::get_options( array( 'wpseo', 'wpseo_social', 'wpseo_internallinks', 'wpseo_titles' ) );
}
return isset( self::$wpseo[ $key ] ) ? self::$wpseo[ $key ] : false;
}
}
}
/**
* Kicking this off by calling 'get_instance()' method
*/
WP_Schema_Pro_Yoast_Compatibility::get_instance();
File diff suppressed because it is too large Load Diff
@@ -36,33 +36,25 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Article' ) ) {
$schema['mainEntityOfPage']['@id'] = esc_url( $data['main-entity'] );
}
if ( isset( $data['name'] ) && ! empty( $data['name'] ) ) {
$schema['headline'] = wp_strip_all_tags( $data['name'] );
}
$schema['headline'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string)$data['name'] ) : NULL;
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
}
if ( isset( $data['published-date'] ) && ! empty( $data['published-date'] ) ) {
$schema['datePublished'] = wp_strip_all_tags( $data['published-date'] );
}
$schema['datePublished'] = ! empty( $data['published-date'] ) ? wp_strip_all_tags( (string)$data['published-date'] ) : NULL;
if ( isset( $data['modified-date'] ) && ! empty( $data['modified-date'] ) ) {
$schema['dateModified'] = wp_strip_all_tags( $data['modified-date'] );
}
$schema['dateModified'] = ! empty( $data['modified-date'] ) ? wp_strip_all_tags( (string)$data['modified-date'] ) : NULL;
if ( isset( $data['author'] ) && ! empty( $data['author'] ) ) {
if ( ! empty( $data['author'] ) ) {
$schema['author']['@type'] = 'Person';
$schema['author']['name'] = wp_strip_all_tags( $data['author'] );
if ( isset( $data['author-url'] ) && ! empty( $data['author-url'] ) ) {
$schema['author']['url'] = wp_strip_all_tags( $data['author-url'] );
}
$schema['author']['name'] = wp_strip_all_tags( (string)$data['author'] );
$schema['author']['url'] = ! empty( $data['author-url'] ) ? wp_strip_all_tags( (string)$data['author-url'] ) : NULL;
}
if ( isset( $data['orgnization-name'] ) && ! empty( $data['orgnization-name'] ) ) {
if ( ! empty( $data['orgnization-name'] ) ) {
$schema['publisher']['@type'] = 'Organization';
$schema['publisher']['name'] = wp_strip_all_tags( $data['orgnization-name'] );
$schema['publisher']['name'] = wp_strip_all_tags( (string)$data['orgnization-name'] );
}
if ( isset( $data['site-logo'] ) && ! empty( $data['site-logo'] ) ) {
@@ -88,9 +80,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Article' ) ) {
}
}
if ( isset( $data['description'] ) && ! empty( $data['description'] ) ) {
$schema['description'] = wp_strip_all_tags( $data['description'] );
}
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string)$data['description'] ) : NULL;
return apply_filters( 'wp_schema_pro_schema_article', $schema, $data, $post );
}
@@ -28,16 +28,14 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Book' ) ) {
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'Book';
if ( isset( $data['name'] ) && ! empty( $data['name'] ) ) {
$schema['name'] = wp_strip_all_tags( $data['name'] );
}
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string)$data['name'] ) : NULL;
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
}
if ( isset( $data['author'] ) && ! empty( $data['author'] ) ) {
if ( ! empty( $data['author'] ) ) {
$schema['author']['@type'] = 'Person';
$schema['author']['name'] = wp_strip_all_tags( $data['author'] );
$schema['author']['name'] = wp_strip_all_tags( (string)$data['author'] );
}
if ( isset( $data['url'] ) && ! empty( $data['url'] ) ) {
@@ -52,17 +50,11 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Book' ) ) {
foreach ( $data['work-example'] as $key => $value ) {
$schema['workExample'][ $key ]['@type'] = 'Book';
if ( isset( $value['serial-number'] ) && ! empty( $value['serial-number'] ) ) {
$schema['workExample'][ $key ]['isbn'] = wp_strip_all_tags( $value['serial-number'] );
}
$schema['workExample'][ $key ]['isbn'] = ! empty( $value['serial-number'] ) ? wp_strip_all_tags( (string)$value['serial-number'] ) : NULL;
if ( isset( $value['book-edition'] ) && ! empty( $value['book-edition'] ) ) {
$schema['workExample'][ $key ]['bookEdition'] = wp_strip_all_tags( $value['book-edition'] );
}
$schema['workExample'][ $key ]['bookEdition'] = ! empty( $value['book-edition'] ) ? wp_strip_all_tags( (string)$value['book-edition'] ) : NULL;
if ( isset( $value['book-format'] ) && ! empty( $value['book-format'] ) ) {
$schema['workExample'][ $key ]['bookFormat'] = 'https://schema.org/' . wp_strip_all_tags( $value['book-format'] );
}
$schema['workExample'][ $key ]['bookFormat'] = ! empty( $value['book-format'] ) ? 'https://schema.org/' . wp_strip_all_tags( (string)$value['book-format'] ) : NULL;
$schema['workExample'][ $key ]['potentialAction']['@type'] = 'ReadAction';
$schema['workExample'][ $key ]['potentialAction']['target']['@type'] = 'EntryPoint';
@@ -73,20 +65,10 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Book' ) ) {
$schema['workExample'][ $key ]['potentialAction']['expectsAcceptanceOf']['@type'] = 'Offer';
$schema['workExample'][ $key ]['potentialAction']['expectsAcceptanceOf']['price'] = '0';
if ( isset( $value['price'] ) && ! empty( $value['price'] ) ) {
$schema['workExample'][ $key ]['potentialAction']['expectsAcceptanceOf']['price'] = wp_strip_all_tags( $value['price'] );
}
$schema['workExample'][ $key ]['potentialAction']['expectsAcceptanceOf']['price'] = ! empty( $value['price'] ) ? wp_strip_all_tags( (string)$value['price'] ) : NULL;
if ( ( isset( $value['currency'] ) && ! empty( $value['currency'] ) ) ||
( isset( $value['avail'] ) && ! empty( $value['avail'] ) ) ) {
if ( isset( $value['currency'] ) && ! empty( $value['currency'] ) ) {
$schema['workExample'][ $key ]['potentialAction']['expectsAcceptanceOf']['priceCurrency'] = wp_strip_all_tags( $value['currency'] );
}
if ( isset( $value['avail'] ) && ! empty( $value['avail'] ) ) {
$schema['workExample'][ $key ]['potentialAction']['expectsAcceptanceOf']['availability'] = wp_strip_all_tags( $value['avail'] );
}
}
$schema['workExample'][ $key ]['potentialAction']['expectsAcceptanceOf']['priceCurrency'] = ! empty( $value['currency'] ) ? wp_strip_all_tags( (string)$value['currency'] ) : NULL;
$schema['workExample'][ $key ]['potentialAction']['expectsAcceptanceOf']['availability'] = ! empty( $value['avail'] ) ? wp_strip_all_tags( (string)$value['avail'] ) : NULL;
if ( isset( $value['country'] ) && ! empty( $value['country'] ) ) {
$expects_acceptance = explode( ',', $value['country'] );
@@ -28,17 +28,11 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Course' ) ) {
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'Course';
if ( isset( $data['name'] ) && ! empty( $data['name'] ) ) {
$schema['name'] = wp_strip_all_tags( $data['name'] );
}
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string)$data['name'] ) : NULL;
if ( isset( $data['course-code'] ) && ! empty( $data['course-code'] ) ) {
$schema['courseCode'] = wp_strip_all_tags( $data['course-code'] );
}
$schema['courseCode'] = ! empty( $data['course-code'] ) ? wp_strip_all_tags( (string)$data['course-code'] ) : NULL;
if ( isset( $data['description'] ) && ! empty( $data['description'] ) ) {
$schema['description'] = wp_strip_all_tags( $data['description'] );
}
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string)$data['description'] ) : NULL;
if ( isset( $data['course-instance'] ) && ! empty( $data['course-instance'] ) ) {
@@ -50,42 +44,28 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Course' ) ) {
isset( $value['location-address'] ) && ! empty( $value['location-address'] ) ) {
$schema['hasCourseInstance'][ $key ]['@type'] = 'CourseInstance';
if ( isset( $value['name'] ) && ! empty( $value['name'] ) ) {
$schema['hasCourseInstance'][ $key ]['name'] = wp_strip_all_tags( $value['name'] );
}
$schema['hasCourseInstance'][ $key ]['name'] = ! empty( $value['name'] ) ? wp_strip_all_tags( (string)$value['name'] ) : NULL;
if ( isset( $value['description'] ) && ! empty( $value['description'] ) ) {
$schema['hasCourseInstance'][ $key ]['description'] = wp_strip_all_tags( $value['description'] );
}
$schema['hasCourseInstance'][ $key ]['description'] = ! empty( $value['description'] ) ? wp_strip_all_tags( (string)$value['description'] ) : NULL;
if ( isset( $value['course-mode'] ) && ! empty( $value['course-mode'] ) ) {
$schema['hasCourseInstance'][ $key ]['courseMode'] = wp_strip_all_tags( $value['course-mode'] );
}
$schema['hasCourseInstance'][ $key ]['courseMode'] = ! empty( $value['course-mode'] ) ? wp_strip_all_tags( (string)$value['course-mode'] ) : NULL;
if ( isset( $value['event-status'] ) && ! empty( $value['event-status'] ) ) {
$schema['hasCourseInstance'][ $key ]['eventStatus'] = wp_strip_all_tags( $value['event-status'] );
}
$schema['hasCourseInstance'][ $key ]['eventStatus'] = ! empty( $value['event-status'] ) ? wp_strip_all_tags( (string)$value['event-status'] ) : NULL;
if ( isset( $value['event-attendance-mode'] ) && ! empty( $value['event-attendance-mode'] ) ) {
$schema['hasCourseInstance'][ $key ]['eventAttendanceMode'] = wp_strip_all_tags( $value['event-attendance-mode'] );
}
$schema['hasCourseInstance'][ $key ]['eventAttendanceMode'] = ! empty( $value['event-attendance-mode'] ) ? wp_strip_all_tags( (string)$value['event-attendance-mode'] ) : NULL;
if ( isset( $value['start-date'] ) && ! empty( $value['start-date'] ) ) {
if ( ! empty( $value['start-date'] ) ) {
if ( 'OfflineEventAttendanceMode' !== isset( $value['event-attendance-mode'] ) ) {
$start_date = gmdate( DATE_ISO8601, strtotime( $value['start-date'] ) );
$schema['hasCourseInstance'][ $key ]['startDate'] = wp_strip_all_tags( $start_date );
$schema['hasCourseInstance'][ $key ]['startDate'] = wp_strip_all_tags( (string)$start_date );
} else {
$schema['hasCourseInstance'][ $key ]['startDate'] = wp_strip_all_tags( $value['start-date'] );
$schema['hasCourseInstance'][ $key ]['startDate'] = wp_strip_all_tags( (string)$value['start-date'] );
}
}
if ( isset( $value['end-date'] ) && ! empty( $value['end-date'] ) ) {
$schema['hasCourseInstance'][ $key ]['endDate'] = wp_strip_all_tags( $value['end-date'] );
}
$schema['hasCourseInstance'][ $key ]['endDate'] = ! empty( $value['end-date'] ) ? wp_strip_all_tags( (string)$value['end-date'] ) : NULL;
if ( isset( $value['previous-date'] ) && ! empty( $value['previous-date'] ) && 'EventRescheduled' === $value['event-status'] ) {
$schema['hasCourseInstance'][ $key ]['previousStartDate'] = wp_strip_all_tags( $value['previous-date'] );
}
$schema['hasCourseInstance'][ $key ]['previousStartDate'] = ! empty( $value['previous-date'] ) ? wp_strip_all_tags( (string)$value['previous-date'] ) : NULL;
if ( isset( $value['online-location'] ) && ! empty( $value['online-location'] ) && 'OfflineEventAttendanceMode' !== $value['event-attendance-mode'] || 'MixedEventAttendanceMode' === $value['event-attendance-mode'] ) {
$schema['hasCourseInstance'][ $key ]['location']['@type'] = 'VirtualLocation';
@@ -96,50 +76,36 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Course' ) ) {
$schema['hasCourseInstance'][ $key ]['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $value['image'] );
}
if ( isset( $value['location-name'] ) && ! empty( $value['location-name'] ) && 'OnlineEventAttendanceMode' !== $value['event-attendance-mode'] ) {
if ( ! empty( $value['location-name'] ) && 'OnlineEventAttendanceMode' !== $value['event-attendance-mode'] ) {
$schema['hasCourseInstance'][ $key ]['location']['@type'] = 'Place';
$schema['hasCourseInstance'][ $key ]['location']['name'] = wp_strip_all_tags( $value['location-name'] );
$schema['hasCourseInstance'][ $key ]['location']['name'] = wp_strip_all_tags( (string)$value['location-name'] );
}
if ( isset( $value['location-address'] ) && ! empty( $value['location-address'] ) && 'OnlineEventAttendanceMode' !== $value['event-attendance-mode'] ) {
if ( ! empty( $value['location-address'] ) && 'OnlineEventAttendanceMode' !== $value['event-attendance-mode'] && is_string( $value['location-address'] ) ) {
$schema['hasCourseInstance'][ $key ]['location']['@type'] = 'Place';
$schema['hasCourseInstance'][ $key ]['location']['address'] = wp_strip_all_tags( $value['location-address'] );
$schema['hasCourseInstance'][ $key ]['location']['address'] = wp_strip_all_tags( (string)$value['location-address'] );
}
$schema['hasCourseInstance'][ $key ]['organizer']['@type'] = 'Organization';
if ( isset( $value['course-organizer-name'] ) && ! empty( $value['course-organizer-name'] ) ) {
$schema['hasCourseInstance'][ $key ]['organizer']['name'] = wp_strip_all_tags( $value['course-organizer-name'] );
}
if ( isset( $value['course-organizer-url'] ) && ! empty( $value['course-organizer-url'] ) ) {
$schema['hasCourseInstance'][ $key ]['organizer']['url'] = wp_strip_all_tags( $value['course-organizer-url'] );
}
$schema['hasCourseInstance'][ $key ]['organizer']['name'] = ! empty( $value['course-organizer-name'] ) ? wp_strip_all_tags( (string)$value['course-organizer-name'] ) : NULL;
$schema['hasCourseInstance'][ $key ]['organizer']['url'] = ! empty( $value['course-organizer-url'] ) ? wp_strip_all_tags( (string)$value['course-organizer-url'] ) : NULL;
$schema['hasCourseInstance'][ $key ]['offers']['@type'] = 'Offer';
$schema['hasCourseInstance'][ $key ]['offers']['price'] = '0';
if ( isset( $value['price'] ) && ! empty( $value['price'] ) ) {
$schema['hasCourseInstance'][ $key ]['offers']['price'] = wp_strip_all_tags( $value['price'] );
}
$schema['hasCourseInstance'][ $key ]['offers']['price'] = ! empty( $value['price'] ) ? wp_strip_all_tags( (string)$value['price'] ) : NULL;
if ( isset( $value['currency'] ) && ! empty( $value['currency'] ) ) {
$schema['hasCourseInstance'][ $key ]['offers']['priceCurrency'] = wp_strip_all_tags( $value['currency'] );
}
$schema['hasCourseInstance'][ $key ]['offers']['priceCurrency'] = ! empty( $value['currency'] ) ? wp_strip_all_tags( (string)$value['currency'] ) : NULL;
if ( isset( $value['url'] ) && ! empty( $value['url'] ) ) {
$schema['hasCourseInstance'][ $key ]['offers']['url'] = wp_strip_all_tags( $value['url'] );
}
$schema['hasCourseInstance'][ $key ]['offers']['url'] = ! empty( $value['url'] ) ? wp_strip_all_tags( (string)$value['url'] ) : NULL;
if ( isset( $value['valid-from'] ) && ! empty( $value['valid-from'] ) ) {
$schema['hasCourseInstance'][ $key ]['offers']['validFrom'] = wp_strip_all_tags( $value['valid-from'] );
}
$schema['hasCourseInstance'][ $key ]['offers']['validFrom'] = ! empty( $value['valid-from'] ) ? wp_strip_all_tags( (string)$value['valid-from'] ) : NULL;
if ( isset( $value['avail'] ) && ! empty( $value['avail'] ) ) {
$schema['hasCourseInstance'][ $key ]['offers']['availability'] = wp_strip_all_tags( $value['avail'] );
}
$schema['hasCourseInstance'][ $key ]['offers']['availability'] = ! empty( $value['avail'] ) ? wp_strip_all_tags( (string)$value['avail'] ) : NULL;
if ( isset( $value['performer'] ) && ! empty( $value['performer'] ) ) {
if ( ! empty( $value['performer'] ) ) {
$schema['hasCourseInstance'][ $key ]['performer']['@type'] = 'Person';
$schema['hasCourseInstance'][ $key ]['performer']['name'] = wp_strip_all_tags( $value['performer'] );
$schema['hasCourseInstance'][ $key ]['performer']['name'] = wp_strip_all_tags( (string)$value['performer'] );
}
}
}
@@ -150,9 +116,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Course' ) ) {
$schema['provider']['@type'] = 'Organization';
if ( isset( $data['orgnization-name'] ) && ! empty( $data['orgnization-name'] ) ) {
$schema['provider']['name'] = wp_strip_all_tags( $data['orgnization-name'] );
}
$schema['provider']['name'] = ! empty( $data['orgnization-name'] ) ? wp_strip_all_tags( (string)$data['orgnization-name'] ) : NULL;
if ( isset( $data['same-as'] ) && ! empty( $data['same-as'] ) ) {
$schema['provider']['sameAs'] = esc_url( $data['same-as'] );
}
@@ -163,12 +127,8 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Course' ) ) {
$schema['aggregateRating']['@type'] = 'AggregateRating';
if ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) {
$schema['aggregateRating']['ratingValue'] = wp_strip_all_tags( $data['rating'] );
}
if ( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) {
$schema['aggregateRating']['reviewCount'] = wp_strip_all_tags( $data['review-count'] );
}
$schema['aggregateRating']['ratingValue'] = ! empty( $data['rating'] ) ? wp_strip_all_tags( (string)$data['rating'] ) : NULL;
$schema['aggregateRating']['reviewCount'] = ! empty( $data['review-count'] ) ? wp_strip_all_tags( $data['review-count'] ) : NULL;
}
return apply_filters( 'wp_schema_pro_schema_course', $schema, $data, $post );
@@ -1,35 +1,35 @@
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 2.5.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Custom_Markup' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 2.5.0
*/
class BSF_AIOSRS_Pro_Schema_Custom_Markup {
/**
* Render Schema.
*
* @param array $data Meta Data.
* @param array $post Current Post Array.
* @return array
*/
public static function render( $data, $post ) {
$schema = array();
if ( isset( $data['custom-markup'] ) && ! empty( $data['custom-markup'] ) ) {
$schema['custom-markup'] = $data['custom-markup'];
}
return apply_filters( 'wp_schema_pro_schema_article', $schema, $data, $post );
}
}
}
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 2.5.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Custom_Markup' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 2.5.0
*/
class BSF_AIOSRS_Pro_Schema_Custom_Markup {
/**
* Render Schema.
*
* @param array $data Meta Data.
* @param array $post Current Post Array.
* @return array
*/
public static function render( $data, $post ) {
$schema = array();
if ( isset( $data['custom-markup'] ) && ! empty( $data['custom-markup'] ) ) {
$schema['custom-markup'] = $data['custom-markup'];
}
return apply_filters( 'wp_schema_pro_schema_article', $schema, $data, $post );
}
}
}
@@ -74,29 +74,21 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Event' ) ) {
public static function prepare_location( $schema, $data, $offline = true ) {
if ( $offline ) {
if ( isset( $data['location'] ) && ! empty( $data['location'] ) ) {
if ( ! empty( $data['location'] ) ) {
$schema['location']['@type'] = 'Place';
$schema['location']['name'] = wp_strip_all_tags( $data['location'] );
$schema['location']['name'] = wp_strip_all_tags( (string)$data['location'] );
}
$schema['location']['@type'] = 'Place';
$schema['location']['address']['@type'] = 'PostalAddress';
if ( isset( $data['location-street'] ) && ! empty( $data['location-street'] ) ) {
$schema['location']['address']['streetAddress'] = wp_strip_all_tags( $data['location-street'] );
}
if ( isset( $data['location-locality'] ) && ! empty( $data['location-locality'] ) ) {
$schema['location']['address']['addressLocality'] = wp_strip_all_tags( $data['location-locality'] );
}
if ( isset( $data['location-postal'] ) && ! empty( $data['location-postal'] ) ) {
$schema['location']['address']['postalCode'] = wp_strip_all_tags( $data['location-postal'] );
}
if ( isset( $data['location-region'] ) && ! empty( $data['location-region'] ) ) {
$schema['location']['address']['addressRegion'] = wp_strip_all_tags( $data['location-region'] );
}
if ( isset( $data['location-country'] ) && ! empty( $data['location-country'] ) ) {
$schema['location']['address']['streetAddress'] = ! empty( $data['location-street'] ) ? wp_strip_all_tags( (string)$data['location-street'] ) : NULL;
$schema['location']['address']['addressLocality'] = ! empty( $data['location-locality'] ) ? wp_strip_all_tags( (string)$data['location-locality'] ) : NULL;
$schema['location']['address']['postalCode'] = ! empty( $data['location-postal'] ) ? wp_strip_all_tags( (string)$data['location-postal'] ) : NULL;
$schema['location']['address']['addressRegion'] = ! empty( $data['location-region'] ) ? wp_strip_all_tags( (string)$data['location-region'] ) : NULL;
if ( ! empty( $data['location-country'] ) ) {
$schema['location']['address']['addressCountry']['@type'] = 'Country';
$schema['location']['address']['addressCountry']['name'] = wp_strip_all_tags( $data['location-country'] );
$schema['location']['address']['addressCountry']['name'] = wp_strip_all_tags( (string)$data['location-country'] );
}
} else {
$schema['location']['@type'] = 'VirtualLocation';
@@ -116,18 +108,10 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Event' ) ) {
$schema['offers']['@type'] = 'Offer';
$schema['offers']['price'] = '0';
if ( isset( $data['price'] ) && ! empty( $data['price'] ) ) {
$schema['offers']['price'] = wp_strip_all_tags( $data['price'] );
}
if ( isset( $data['avail'] ) && ! empty( $data['avail'] ) ) {
$schema['offers']['availability'] = wp_strip_all_tags( $data['avail'] );
}
if ( isset( $data['currency'] ) && ! empty( $data['currency'] ) ) {
$schema['offers']['priceCurrency'] = wp_strip_all_tags( $data['currency'] );
}
if ( isset( $data['valid-from'] ) && ! empty( $data['valid-from'] ) ) {
$schema['offers']['validFrom'] = wp_strip_all_tags( $data['valid-from'] );
}
$schema['offers']['price'] = ! empty( $data['price'] ) ? wp_strip_all_tags( (string)$data['price'] ) : NULL;
$schema['offers']['availability'] = ! empty( $data['avail'] ) ? wp_strip_all_tags( (string)$data['avail'] ) : NULL;
$schema['offers']['priceCurrency'] = ! empty( $data['currency'] ) ? wp_strip_all_tags( (string)$data['currency'] ) : NULL;
$schema['offers']['validFrom'] = ! empty( $data['valid-from'] ) ? wp_strip_all_tags( (string)$data['valid-from'] ) : NULL;
if ( isset( $data['ticket-buy-url'] ) && ! empty( $data['ticket-buy-url'] ) ) {
$schema['offers']['url'] = esc_url( $data['ticket-buy-url'] );
}
@@ -145,17 +129,13 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Event' ) ) {
*/
public static function prepare_performer( $schema, $data ) {
if ( isset( $data['performer'] ) && ! empty( $data['performer'] ) ) {
if ( ! empty( $data['performer'] ) ) {
$schema['performer']['@type'] = 'Person';
$schema['performer']['name'] = wp_strip_all_tags( $data['performer'] );
$schema['performer']['name'] = wp_strip_all_tags( (string)$data['performer'] );
}
$schema['organizer']['@type'] = 'Organization';
if ( isset( $data['event-organizer-name'] ) && ! empty( $data['event-organizer-name'] ) ) {
$schema['organizer']['name'] = wp_strip_all_tags( $data['event-organizer-name'] );
}
if ( isset( $data['event-organizer-url'] ) && ! empty( $data['event-organizer-url'] ) ) {
$schema['organizer']['url'] = wp_strip_all_tags( $data['event-organizer-url'] );
}
$schema['organizer']['name'] = ! empty( $data['event-organizer-name'] ) ? wp_strip_all_tags( (string)$data['event-organizer-name'] ) : NULL;
$schema['organizer']['url'] = ! empty( $data['event-organizer-url'] ) ? wp_strip_all_tags( (string)$data['event-organizer-url'] ) : NULL;
return $schema;
}
@@ -170,17 +150,11 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Event' ) ) {
public static function prepare_dates( $schema, $data ) {
$start_date = gmdate( DATE_ISO8601, strtotime( $data['start-date'] ) );
if ( isset( $start_date ) && ! empty( $start_date ) ) {
$schema['startDate'] = wp_strip_all_tags( $start_date );
}
$schema['startDate'] = ! empty( $start_date ) ? wp_strip_all_tags( (string)$start_date ) : NULL;
if ( isset( $data['end-date'] ) && ! empty( $data['end-date'] ) ) {
$schema['endDate'] = wp_strip_all_tags( $data['end-date'] );
}
$schema['endDate'] = ! empty( $data['end-date'] ) ? wp_strip_all_tags( (string)$data['end-date'] ) : NULL;
if ( 'EventRescheduled' === $data['event-status'] ) {
$schema['previousStartDate'] = wp_strip_all_tags( $data['previous-date'] );
}
$schema['previousStartDate'] = 'EventRescheduled' === $data['event-status'] ? wp_strip_all_tags( (string)$data['previous-date'] ) : NULL;
return $schema;
}
@@ -193,10 +167,8 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Event' ) ) {
* @return array
*/
public static function prepare_attendence_mode( $schema, $data ) {
if ( isset( $data['schema-type'] ) && isset( $data['event-attendance-mode'] ) && ! empty( $data['event-attendance-mode'] ) ) {
$schema['eventAttendanceMode'] = 'https://schema.org/' . wp_strip_all_tags( $data['event-attendance-mode'] );
}
$schema['eventAttendanceMode'] = isset( $data['schema-type'] ) && ! empty( $data['event-attendance-mode'] ) ? 'https://schema.org/' . wp_strip_all_tags( (string)$data['event-attendance-mode'] ) : NULL;
return $schema;
}
@@ -210,21 +182,15 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Event' ) ) {
*/
public static function prepare_basics( $schema, $data ) {
if ( isset( $data['name'] ) && ! empty( $data['name'] ) ) {
$schema['name'] = wp_strip_all_tags( $data['name'] );
}
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string)$data['name'] ) : NULL;
if ( isset( $data['event-status'] ) && ! empty( $data['event-status'] ) ) {
$schema['eventStatus'] = 'https://schema.org/' . wp_strip_all_tags( $data['event-status'] );
}
$schema['eventStatus'] = ! empty( $data['event-status'] ) ? 'https://schema.org/' . wp_strip_all_tags( (string)$data['event-status'] ) : NULL;
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
}
if ( isset( $data['description'] ) && ! empty( $data['description'] ) ) {
$schema['description'] = wp_strip_all_tags( $data['description'] );
}
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string)$data['description'] ) : NULL;
return $schema;
}
@@ -1,47 +1,47 @@
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.0.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_FAQ' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.0.0
*/
class BSF_AIOSRS_Pro_Schema_FAQ {
/**
* Render Schema.
*
* @param array $data Meta Data.
* @param array $post Current Post Array.
* @return array
*/
public static function render( $data, $post ) {
global $post;
$schema = array();
if ( isset( $data['question-answer'][0]['question'] ) && ! empty( $data['question-answer'][0]['question'] ) ) {
$schema['@context'] = 'https://schema.org';
$schema['type'] = 'FAQPage';
foreach ( $data['question-answer'] as $key => $value ) {
if ( isset( $value['question'] ) && ! empty( $value['question'] ) ) {
$schema['mainEntity'][ $key ]['@type'] = 'Question';
$schema['mainEntity'][ $key ]['name'] = $value['question'];
}
if ( isset( $value['answer'] ) && ! empty( $value['answer'] ) ) {
$schema['mainEntity'][ $key ]['acceptedAnswer']['@type'] = 'Answer';
$schema['mainEntity'][ $key ]['acceptedAnswer']['text'] = $value['answer'];
}
}
}
return apply_filters( 'wp_schema_pro_schema_faq', $schema, $data, $post );
}
}
}
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.0.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_FAQ' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.0.0
*/
class BSF_AIOSRS_Pro_Schema_FAQ {
/**
* Render Schema.
*
* @param array $data Meta Data.
* @param array $post Current Post Array.
* @return array
*/
public static function render( $data, $post ) {
global $post;
$schema = array();
if ( isset( $data['question-answer'][0]['question'] ) && ! empty( $data['question-answer'][0]['question'] ) ) {
$schema['@context'] = 'https://schema.org';
$schema['type'] = 'FAQPage';
foreach ( $data['question-answer'] as $key => $value ) {
if ( isset( $value['question'] ) && ! empty( $value['question'] ) ) {
$schema['mainEntity'][ $key ]['@type'] = 'Question';
$schema['mainEntity'][ $key ]['name'] = $value['question'];
}
if ( isset( $value['answer'] ) && ! empty( $value['answer'] ) ) {
$schema['mainEntity'][ $key ]['acceptedAnswer']['@type'] = 'Answer';
$schema['mainEntity'][ $key ]['acceptedAnswer']['text'] = $value['answer'];
}
}
}
return apply_filters( 'wp_schema_pro_schema_faq', $schema, $data, $post );
}
}
}
@@ -28,17 +28,11 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_How_To' ) ) {
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'HowTo';
if ( isset( $data['name'] ) && ! empty( $data['name'] ) ) {
$schema['name'] = wp_strip_all_tags( $data['name'] );
}
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string)$data['name'] ) : NULL;
if ( isset( $data['description'] ) && ! empty( $data['description'] ) ) {
$schema['description'] = wp_strip_all_tags( $data['description'] );
}
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string)$data['description'] ) : NULL;
if ( isset( $data['total-time'] ) && ! empty( $data['total-time'] ) ) {
$schema['totalTime'] = wp_strip_all_tags( $data['total-time'] );
}
$schema['totalTime'] = ! empty( $data['total-time'] ) ? wp_strip_all_tags( (string)$data['total-time'] ) : NULL;
if ( isset( $data['supply'] ) && ! empty( $data['supply'] ) ) {
@@ -48,9 +42,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_How_To' ) ) {
$schema['supply'][ $key ]['@type'] = 'HowToSupply';
if ( isset( $value['name'] ) && ! empty( $value['name'] ) ) {
$schema['supply'][ $key ]['name'] = wp_strip_all_tags( $value['name'] );
}
$schema['supply'][ $key ]['name'] = ! empty( $value['name'] ) ? wp_strip_all_tags( (string)$value['name'] ) : NULL;
}
}
}
@@ -63,9 +55,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_How_To' ) ) {
$schema['tool'][ $key ]['@type'] = 'HowToTool';
if ( isset( $value['name'] ) && ! empty( $value['name'] ) ) {
$schema['tool'][ $key ]['name'] = wp_strip_all_tags( $value['name'] );
}
$schema['tool'][ $key ]['name'] = ! empty( $value['name'] ) ? wp_strip_all_tags( (string)$value['name'] ) : NULL;
}
}
}
@@ -41,8 +41,8 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Image_License' ) ) {
if ( isset( $value['credit-text'] ) && ! empty( $value['credit-text'] ) ) {
$schema[ $key ]['creditText'] = esc_url( $value['credit-text'] );
}
if ( isset( $data['creator-type'] ) && ! empty( $data['creator-type'] ) ) {
$schema['creator']['@type'] = wp_strip_all_tags( $data['creator-type'] );
if ( ! empty( $data['creator-type'] ) ) {
$schema['creator']['@type'] = wp_strip_all_tags( (string)$data['creator-type'] );
} else {
$schema[ $key ]['creator']['@type'] = 'Person';
}
@@ -28,62 +28,42 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Job_Posting' ) ) {
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'JobPosting';
if ( isset( $data['title'] ) && ! empty( $data['title'] ) ) {
$schema['title'] = wp_strip_all_tags( $data['title'] );
$schema['title'] = ! empty( $data['title'] ) ? wp_strip_all_tags( (string)$data['title'] ) : NULL;
$schema['description'] = ! empty( $data['description'] ) ? (string)$data['description'] : NULL;
$schema['datePosted'] = ! empty( $data['start-date'] ) ? wp_strip_all_tags( (string)$data['start-date'] ) : NULL;
$schema['validThrough'] = ! empty( $data['expiry-date'] ) ? wp_strip_all_tags( (string)$data['expiry-date'] ) : NULL;
$schema['employmentType'] = ! empty( $data['job-type'] ) ? wp_strip_all_tags( (string)$data['job-type'] ) : NULL;
if ( ! empty( $data['education-requirements'] ) ) {
$schema['educationRequirements']['@type'] = 'EducationalOccupationalCredential';
$schema['educationRequirements']['credentialCategory'] = wp_strip_all_tags( (string)$data['education-requirements'] );
}
if ( isset( $data['description'] ) && ! empty( $data['description'] ) ) {
$schema['description'] = wp_strip_all_tags( $data['description'] );
if ( ! empty( $data['experience-requirements'] ) ) {
$schema['experienceRequirements']['@type'] = 'OccupationalExperienceRequirements';
$schema['experienceRequirements']['monthsOfExperience'] = wp_strip_all_tags( (string)$data['experience-requirements'] );
}
if ( isset( $data['start-date'] ) && ! empty( $data['start-date'] ) ) {
$schema['datePosted'] = wp_strip_all_tags( $data['start-date'] );
}
$schema['industry'] = ! empty( $data['industry'] ) ? wp_strip_all_tags( (string)$data['industry'] ) : NULL;
if ( isset( $data['expiry-date'] ) && ! empty( $data['expiry-date'] ) ) {
$schema['validThrough'] = wp_strip_all_tags( $data['expiry-date'] );
}
$schema['qualifications'] = ! empty( $data['qualifications'] ) ? wp_strip_all_tags( (string)$data['qualifications'] ) : NULL;
if ( isset( $data['job-type'] ) && ! empty( $data['job-type'] ) ) {
$schema['employmentType'] = wp_strip_all_tags( $data['job-type'] );
}
$schema['responsibilities'] = ! empty( $data['responsibilities'] ) ? wp_strip_all_tags( (string)$data['responsibilities'] ) : NULL;
if ( isset( $data['education-requirements'] ) && ! empty( $data['education-requirements'] ) ) {
$schema['educationRequirements'] = wp_strip_all_tags( $data['education-requirements'] );
}
$schema['skills'] = ! empty( $data['skills'] ) ? wp_strip_all_tags( (string)$data['skills'] ) : NULL;
if ( isset( $data['experience-requirements'] ) && ! empty( $data['experience-requirements'] ) ) {
$schema['experienceRequirements'] = wp_strip_all_tags( $data['experience-requirements'] );
}
if ( isset( $data['industry'] ) && ! empty( $data['industry'] ) ) {
$schema['industry'] = wp_strip_all_tags( $data['industry'] );
}
if ( isset( $data['qualifications'] ) && ! empty( $data['qualifications'] ) ) {
$schema['qualifications'] = wp_strip_all_tags( $data['qualifications'] );
}
if ( isset( $data['responsibilities'] ) && ! empty( $data['responsibilities'] ) ) {
$schema['responsibilities'] = wp_strip_all_tags( $data['responsibilities'] );
}
if ( isset( $data['skills'] ) && ! empty( $data['skills'] ) ) {
$schema['skills'] = wp_strip_all_tags( $data['skills'] );
}
if ( isset( $data['work-hours'] ) && ! empty( $data['work-hours'] ) ) {
$schema['workHours'] = wp_strip_all_tags( $data['work-hours'] );
}
$schema['workHours'] = ! empty( $data['work-hours'] ) ? wp_strip_all_tags( (string)$data['work-hours'] ) : NULL;
if ( ( isset( $data['orgnization-name'] ) && ! empty( $data['orgnization-name'] ) ) ||
( isset( $data['same-as'] ) && ! empty( $data['same-as'] ) ) ) {
$schema['hiringOrganization']['@type'] = 'Organization';
if ( isset( $data['orgnization-name'] ) && ! empty( $data['orgnization-name'] ) ) {
$schema['hiringOrganization']['name'] = wp_strip_all_tags( $data['orgnization-name'] );
}
$schema['hiringOrganization']['name'] = wp_strip_all_tags( (string)$data['orgnization-name'] );
if ( isset( $data['same-as'] ) && ! empty( $data['same-as'] ) ) {
$schema['hiringOrganization']['sameAs'] = esc_url( $data['same-as'] );
}
@@ -102,42 +82,30 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Job_Posting' ) ) {
$schema['jobLocation']['@type'] = 'Place';
$schema['jobLocation']['address']['@type'] = 'PostalAddress';
if ( isset( $data['location-street'] ) && ! empty( $data['location-street'] ) ) {
$schema['jobLocation']['address']['streetAddress'] = wp_strip_all_tags( $data['location-street'] );
}
if ( isset( $data['location-locality'] ) && ! empty( $data['location-locality'] ) ) {
$schema['jobLocation']['address']['addressLocality'] = wp_strip_all_tags( $data['location-locality'] );
}
if ( isset( $data['location-postal'] ) && ! empty( $data['location-postal'] ) ) {
$schema['jobLocation']['address']['postalCode'] = wp_strip_all_tags( $data['location-postal'] );
}
if ( isset( $data['location-region'] ) && ! empty( $data['location-region'] ) ) {
$schema['jobLocation']['address']['addressRegion'] = wp_strip_all_tags( $data['location-region'] );
}
if ( isset( $data['location-country'] ) && ! empty( $data['location-country'] ) ) {
$schema['jobLocation']['address']['addressCountry'] = wp_strip_all_tags( $data['location-country'] );
}
$schema['jobLocation']['address']['streetAddress'] = ! empty( $data['location-street'] ) ? wp_strip_all_tags( (string)$data['location-street'] ) : NULL;
$schema['jobLocation']['address']['addressLocality'] = ! empty( $data['location-locality'] ) ? wp_strip_all_tags( (string)$data['location-locality'] ) : NULL;
$schema['jobLocation']['address']['postalCode'] = ! empty( $data['location-postal'] ) ? wp_strip_all_tags( (string)$data['location-postal'] ) : NULL;
$schema['jobLocation']['address']['addressRegion'] = ! empty( $data['location-region'] ) ? wp_strip_all_tags( (string)$data['location-region'] ) : NULL;
$schema['jobLocation']['address']['addressCountry'] = ! empty( $data['location-country'] ) ? wp_strip_all_tags( (string)$data['location-country'] ) : NULL;
}
if ( isset( $data['job-location-type'] ) && ! empty( $data['job-location-type'] ) ) {
$schema['jobLocationType'] = wp_strip_all_tags( $data['job-location-type'] );
}
$schema['jobLocationType'] = ! empty( $data['job-location-type'] ) ? wp_strip_all_tags( (string)$data['job-location-type'] ) : NULL;
if ( isset( $data['remote-location'] ) && ! empty( $data['remote-location'] ) ) {
foreach ( $data['remote-location'] as $key => $value ) {
$schema['applicantLocationRequirements'][ $key ]['@type'] = 'Country';
$schema['applicantLocationRequirements'][ $key ]['name'] = wp_strip_all_tags( $value['applicant-location'] );
$schema['applicantLocationRequirements'][ $key ]['name'] = wp_strip_all_tags( (string)$value['applicant-location'] );
}
} else {
if ( isset( $data['applicant-location'] ) && ! empty( $data['applicant-location'] ) ) {
$schema['applicantLocationRequirements']['@type'] = 'Country';
$schema['applicantLocationRequirements']['name'] = wp_strip_all_tags( $data['applicant-location'] );
$schema['applicantLocationRequirements']['name'] = wp_strip_all_tags( (string)$data['applicant-location'] );
}
}
if ( isset( $data['salary-currency'] ) && ! empty( $data['salary-currency'] ) ) {
$schema['baseSalary']['@type'] = 'MonetaryAmount';
$schema['baseSalary']['currency'] = wp_strip_all_tags( $data['salary-currency'] );
$schema['baseSalary']['currency'] = wp_strip_all_tags( (string)$data['salary-currency'] );
}
if ( ( isset( $data['salary'] ) && ! empty( $data['salary'] ) ) ||
@@ -146,18 +114,10 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Job_Posting' ) ) {
$schema['baseSalary']['@type'] = 'MonetaryAmount';
$schema['baseSalary']['value']['@type'] = 'QuantitativeValue';
if ( isset( $data['salary'] ) && ! empty( $data['salary'] ) ) {
$schema['baseSalary']['value']['value'] = wp_strip_all_tags( $data['salary'] );
}
if ( isset( $data['salary-min-value'] ) && ! empty( $data['salary-min-value'] ) ) {
$schema['baseSalary']['value']['minValue'] = wp_strip_all_tags( $data['salary-min-value'] );
}
if ( isset( $data['salary-max-value'] ) && ! empty( $data['salary-max-value'] ) ) {
$schema['baseSalary']['value']['maxValue'] = wp_strip_all_tags( $data['salary-max-value'] );
}
if ( isset( $data['salary-unit'] ) && ! empty( $data['salary-unit'] ) ) {
$schema['baseSalary']['value']['unitText'] = wp_strip_all_tags( $data['salary-unit'] );
}
$schema['baseSalary']['value']['value'] = ! empty( $data['salary'] ) ? wp_strip_all_tags( (string)$data['salary'] ) : NULL;
$schema['baseSalary']['value']['minValue'] = ! empty( $data['salary-min-value'] ) ? wp_strip_all_tags( (string)$data['salary-min-value'] ) : NULL;
$schema['baseSalary']['value']['maxValue'] = ! empty( $data['salary-max-value'] ) ? wp_strip_all_tags( (string)$data['salary-max-value'] ) : NULL;
$schema['baseSalary']['value']['unitText'] = ! empty( $data['salary-unit'] ) ? wp_strip_all_tags( (string)$data['salary-unit'] ) : NULL;
}
return apply_filters( 'wp_schema_pro_schema_job_posting', $schema, $data, $post );
@@ -33,21 +33,15 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Local_Business' ) ) {
$schema['@type'] = 'LocalBusiness';
}
if ( isset( $data['name'] ) && ! empty( $data['name'] ) ) {
$schema['name'] = wp_strip_all_tags( $data['name'] );
}
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string)$data['name'] ) : NULL;
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
}
if ( isset( $data['telephone'] ) && ! empty( $data['telephone'] ) ) {
$schema['telephone'] = wp_strip_all_tags( $data['telephone'] );
}
$schema['telephone'] = ! empty( $data['telephone'] ) ? wp_strip_all_tags( (string)$data['telephone'] ) : NULL;
if ( isset( $data['url'] ) && ! empty( $data['url'] ) ) {
$schema['url'] = wp_strip_all_tags( $data['url'] );
}
$schema['url'] = ! empty( $data['url'] ) ? wp_strip_all_tags( (string)$data['url'] ) : NULL;
if ( ( isset( $data['location-street'] ) && ! empty( $data['location-street'] ) ) ||
( isset( $data['location-locality'] ) && ! empty( $data['location-locality'] ) ) ||
@@ -57,39 +51,22 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Local_Business' ) ) {
$schema['address']['@type'] = 'PostalAddress';
if ( isset( $data['location-street'] ) && ! empty( $data['location-street'] ) ) {
$schema['address']['streetAddress'] = wp_strip_all_tags( $data['location-street'] );
}
if ( isset( $data['location-locality'] ) && ! empty( $data['location-locality'] ) ) {
$schema['address']['addressLocality'] = wp_strip_all_tags( $data['location-locality'] );
}
if ( isset( $data['location-postal'] ) && ! empty( $data['location-postal'] ) ) {
$schema['address']['postalCode'] = wp_strip_all_tags( $data['location-postal'] );
}
if ( isset( $data['location-region'] ) && ! empty( $data['location-region'] ) ) {
$schema['address']['addressRegion'] = wp_strip_all_tags( $data['location-region'] );
}
if ( isset( $data['location-country'] ) && ! empty( $data['location-country'] ) ) {
$schema['address']['addressCountry'] = wp_strip_all_tags( $data['location-country'] );
}
$schema['address']['streetAddress'] = ! empty( $data['location-street'] ) ? wp_strip_all_tags( (string)$data['location-street'] ) : NULL;
$schema['address']['addressLocality'] = ! empty( $data['location-locality'] ) ? wp_strip_all_tags( (string)$data['location-locality'] ) : NULL;
$schema['address']['postalCode'] = ! empty( $data['location-postal'] ) ? wp_strip_all_tags( (string)$data['location-postal'] ) : NULL;
$schema['address']['addressRegion'] = ! empty( $data['location-region'] ) ? wp_strip_all_tags( (string)$data['location-region'] ) : NULL;
$schema['address']['addressCountry'] = ! empty( $data['location-country'] ) ? wp_strip_all_tags( (string)$data['location-country'] ) : NULL;
}
if ( ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) ||
( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) ) {
if ( ! empty( $data['rating'] ) && ! empty( $data['review-count'] ) && 'none' !== $data['rating'] && 'none' !== $data['review-count'] ) {
$schema['aggregateRating']['@type'] = 'AggregateRating';
if ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) {
$schema['aggregateRating']['ratingValue'] = wp_strip_all_tags( $data['rating'] );
}
if ( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) {
$schema['aggregateRating']['reviewCount'] = wp_strip_all_tags( $data['review-count'] );
}
$schema['aggregateRating']['ratingValue'] = ! empty( $data['rating'] ) ? wp_strip_all_tags( (string)$data['rating'] ) : NULL;
$schema['aggregateRating']['reviewCount'] = ! empty( $data['review-count'] ) ? wp_strip_all_tags( (string)$data['review-count'] ) : NULL;
}
if ( isset( $data['price-range'] ) && ! empty( $data['price-range'] ) ) {
$schema['priceRange'] = wp_strip_all_tags( $data['price-range'] );
}
$schema['priceRange'] = ! empty( $data['price-range'] ) ? wp_strip_all_tags( (string)$data['price-range'] ) : NULL;
if ( isset( $data['hours-specification'] ) && ! empty( $data['hours-specification'] ) ) {
foreach ( $data['hours-specification'] as $key => $value ) {
@@ -103,8 +80,8 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Local_Business' ) ) {
}
if ( isset( $data['geo-latitude'] ) && isset( $data['geo-longitude'] ) ) {
$schema['geo']['@type'] = 'GeoCoordinates';
$schema['geo']['latitude'] = wp_strip_all_tags( $data['geo-latitude'] );
$schema['geo']['longitude'] = wp_strip_all_tags( $data['geo-longitude'] );
$schema['geo']['latitude'] = wp_strip_all_tags( (string)$data['geo-latitude'] );
$schema['geo']['longitude'] = wp_strip_all_tags( (string)$data['geo-longitude'] );
}
$contact_type = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-corporate-contact'];
@@ -115,30 +92,22 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Local_Business' ) ) {
if ( '1' === $contact_type['cp-schema-type'] && true === apply_filters( 'wp_schema_pro_contactpoint_local_business_schema_enabled', true ) && isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) ) {
$schema['ContactPoint']['@type'] = 'ContactPoint';
if ( isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) ) {
$schema ['ContactPoint']['contactType'] = wp_strip_all_tags( $contact_type['contact-type'] );
}
if ( isset( $contact_type['telephone'] ) && ! empty( $contact_type['telephone'] ) ) {
$schema ['ContactPoint']['telephone'] = wp_strip_all_tags( $contact_type['telephone'] );
}
$schema ['ContactPoint']['contactType'] = ! empty( $contact_type['contact-type'] ) ? wp_strip_all_tags( (string)$contact_type['contact-type'] ) : NULL;
$schema ['ContactPoint']['telephone'] = ! empty( $contact_type['telephone'] ) ? wp_strip_all_tags( (string)$contact_type['telephone'] ) : NULL;
if ( isset( $contact_type['url'] ) && ! empty( $contact_type['url'] ) ) {
$schema ['ContactPoint']['url'] = esc_url( $contact_type['url'] );
}
if ( isset( $contact_type['email'] ) && ! empty( $contact_type['email'] ) ) {
$schema ['ContactPoint']['email'] = wp_strip_all_tags( $contact_type['email'] );
}
$schema ['ContactPoint']['email'] = ! empty( $contact_type['email'] ) ? wp_strip_all_tags( (string)$contact_type['email'] ) : NULL;
if ( isset( $contact_type['areaServed'] ) && ! empty( $contact_type['areaServed'] ) ) {
$language = explode( ',', $contact_type['areaServed'] );
foreach ( $language as $key => $value ) {
$schema ['ContactPoint']['areaServed'][ $key ] = wp_strip_all_tags( $value );
$schema ['ContactPoint']['areaServed'][ $key ] = wp_strip_all_tags( (string)$value );
}
}
foreach ( $contact_point_type as $key => $value ) {
$schema ['ContactPoint']['contactOption'][ $key ] = wp_strip_all_tags( $value );
}
if ( isset( $contact_type['availableLanguage'] ) && ! empty( $contact_type['availableLanguage'] ) ) {
$schema ['ContactPoint']['availableLanguage'] = wp_strip_all_tags( $contact_type['availableLanguage'] );
$schema ['ContactPoint']['contactOption'][ $key ] = wp_strip_all_tags( (string)$value );
}
$schema ['ContactPoint']['availableLanguage'] = ! empty( $contact_type['availableLanguage'] ) ? wp_strip_all_tags( (string)$contact_type['availableLanguage'] ) : NULL;
}
return apply_filters( 'wp_schema_pro_schema_local_business', $schema, $data, $post );
@@ -28,9 +28,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Person' ) ) {
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'Person';
if ( isset( $data['name'] ) && ! empty( $data['name'] ) ) {
$schema['name'] = wp_strip_all_tags( $data['name'] );
}
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string)$data['name'] ) : NULL;
if ( ( isset( $data['street'] ) && ! empty( $data['street'] ) ) ||
( isset( $data['locality'] ) && ! empty( $data['locality'] ) ) ||
@@ -39,55 +37,35 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Person' ) ) {
$schema['address']['@type'] = 'PostalAddress';
if ( isset( $data['locality'] ) && ! empty( $data['locality'] ) ) {
$schema['address']['addressLocality'] = wp_strip_all_tags( $data['locality'] );
}
$schema['address']['addressLocality'] = ! empty( $data['locality'] ) ? wp_strip_all_tags( (string)$data['locality'] ) : NULL;
if ( isset( $data['region'] ) && ! empty( $data['region'] ) ) {
$schema['address']['addressRegion'] = wp_strip_all_tags( $data['region'] );
}
$schema['address']['addressRegion'] = ! empty( $data['region'] ) ? wp_strip_all_tags( (string)$data['region'] ) : NULL;
if ( isset( $data['postal'] ) && ! empty( $data['postal'] ) ) {
$schema['address']['postalCode'] = wp_strip_all_tags( $data['postal'] );
}
$schema['address']['postalCode'] = ! empty( $data['postal'] ) ? wp_strip_all_tags( (string)$data['postal'] ) : NULL;
if ( isset( $data['street'] ) && ! empty( $data['street'] ) ) {
$schema['address']['streetAddress'] = wp_strip_all_tags( $data['street'] );
}
$schema['address']['streetAddress'] = ! empty( $data['street'] ) ? wp_strip_all_tags( (string)$data['street'] ) : NULL;
}
if ( isset( $data['email'] ) && ! empty( $data['email'] ) ) {
$schema['email'] = wp_strip_all_tags( $data['email'] );
}
$schema['email'] = ! empty( $data['email'] ) ? wp_strip_all_tags( (string)$data['email'] ) : NULL;
if ( isset( $data['gender'] ) && ! empty( $data['gender'] ) ) {
$schema['gender'] = wp_strip_all_tags( $data['gender'] );
}
$schema['gender'] = ! empty( $data['gender'] ) ? wp_strip_all_tags( (string)$data['gender'] ) : NULL;
if ( isset( $data['dob'] ) && ! empty( $data['dob'] ) ) {
$date_informat = gmdate( 'Y.m.d', strtotime( $data['dob'] ) );
$schema['birthDate'] = wp_strip_all_tags( $date_informat );
$schema['birthDate'] = wp_strip_all_tags( (string)$date_informat );
}
if ( isset( $data['member'] ) && ! empty( $data['member'] ) ) {
$schema['memberOf'] = wp_strip_all_tags( $data['member'] );
}
$schema['memberOf'] = ! empty( $data['member'] ) ? wp_strip_all_tags( (string)$data['member'] ) : NULL;
if ( isset( $data['nationality'] ) && ! empty( $data['nationality'] ) ) {
$schema['nationality'] = wp_strip_all_tags( $data['nationality'] );
}
$schema['nationality'] = ! empty( $data['nationality'] ) ? wp_strip_all_tags( (string)$data['nationality'] ) : NULL;
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
}
if ( isset( $data['job-title'] ) && ! empty( $data['job-title'] ) ) {
$schema['jobTitle'] = wp_strip_all_tags( $data['job-title'] );
}
$schema['jobTitle'] = ! empty( $data['job-title'] ) ? wp_strip_all_tags( (string)$data['job-title'] ) : NULL;
if ( isset( $data['telephone'] ) && ! empty( $data['telephone'] ) ) {
$schema['telephone'] = wp_strip_all_tags( $data['telephone'] );
}
$schema['telephone'] = ! empty( $data['telephone'] ) ? wp_strip_all_tags( (string)$data['telephone'] ) : NULL;
if ( isset( $data['homepage-url'] ) && ! empty( $data['homepage-url'] ) ) {
$schema['url'] = esc_url( $data['homepage-url'] );
@@ -108,30 +86,22 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Person' ) ) {
if ( '1' === $contact_type['cp-schema-type'] && true === apply_filters( 'wp_schema_pro_contactpoint_person_schema_enabled', true ) && isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) ) {
$schema['ContactPoint']['@type'] = 'ContactPoint';
if ( isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) ) {
$schema ['ContactPoint']['contactType'] = wp_strip_all_tags( $contact_type['contact-type'] );
}
if ( isset( $contact_type['telephone'] ) && ! empty( $contact_type['telephone'] ) ) {
$schema ['ContactPoint']['telephone'] = wp_strip_all_tags( $contact_type['telephone'] );
}
$schema ['ContactPoint']['contactType'] = ! empty( $contact_type['contact-type'] ) ? wp_strip_all_tags( (string)$contact_type['contact-type'] ) : NULL;
$schema ['ContactPoint']['telephone'] = ! empty( $contact_type['telephone'] ) ? wp_strip_all_tags( (string)$contact_type['telephone'] ) : NULL;
if ( isset( $contact_type['url'] ) && ! empty( $contact_type['url'] ) ) {
$schema ['ContactPoint']['url'] = esc_url( $contact_type['url'] );
}
if ( isset( $contact_type['email'] ) && ! empty( $contact_type['email'] ) ) {
$schema ['ContactPoint']['email'] = wp_strip_all_tags( $contact_type['email'] );
}
$schema ['ContactPoint']['email'] = ! empty( $contact_type['email'] ) ? wp_strip_all_tags( (string)$contact_type['email'] ) : NULL;
if ( isset( $contact_type['areaServed'] ) && ! empty( $contact_type['areaServed'] ) ) {
$language = explode( ',', $contact_type['areaServed'] );
foreach ( $language as $key => $value ) {
$schema ['ContactPoint']['areaServed'][ $key ] = wp_strip_all_tags( $value );
$schema ['ContactPoint']['areaServed'][ $key ] = wp_strip_all_tags( (string)$value );
}
}
foreach ( $contact_point_type as $key => $value ) {
$schema ['ContactPoint']['contactOption'][ $key ] = wp_strip_all_tags( $value );
}
if ( isset( $contact_type['availableLanguage'] ) && ! empty( $contact_type['availableLanguage'] ) ) {
$schema ['ContactPoint']['availableLanguage'] = wp_strip_all_tags( $contact_type['availableLanguage'] );
$schema ['ContactPoint']['contactOption'][ $key ] = wp_strip_all_tags( (string)$value );
}
$schema ['ContactPoint']['availableLanguage'] = ! empty( $contact_type['availableLanguage'] ) ? wp_strip_all_tags( (string)$contact_type['availableLanguage'] ) : NULL;
}
return apply_filters( 'wp_schema_pro_schema_person', $schema, $data, $post );
@@ -26,27 +26,19 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Product' ) ) {
$schema = array();
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'Product';
if ( isset( $data['name'] ) && ! empty( $data['name'] ) ) {
$schema['name'] = wp_strip_all_tags( $data['name'] );
}
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string)$data['name'] ) : NULL;
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
}
if ( isset( $data['description'] ) && ! empty( $data['description'] ) ) {
$schema['description'] = wp_strip_all_tags( $data['description'] );
}
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string)$data['description'] ) : NULL;
if ( isset( $data['sku'] ) && ! empty( $data['sku'] ) ) {
$schema['sku'] = wp_strip_all_tags( $data['sku'] );
}
if ( isset( $data['mpn'] ) && ! empty( $data['mpn'] ) ) {
$schema['mpn'] = wp_strip_all_tags( $data['mpn'] );
}
if ( isset( $data['brand-name'] ) && ! empty( $data['brand-name'] ) ) {
$schema['sku'] = ! empty( $data['sku'] ) ? wp_strip_all_tags( (string)$data['sku'] ) : NULL;
$schema['mpn'] = ! empty( $data['mpn'] ) ? wp_strip_all_tags( (string)$data['mpn'] ) : NULL;
if ( ! empty( $data['brand-name'] ) ) {
$schema['brand']['@type'] = 'Brand';
$schema['brand']['name'] = wp_strip_all_tags( $data['brand-name'] );
$schema['brand']['name'] = wp_strip_all_tags( (string)$data['brand-name'] );
}
if ( ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) ||
@@ -54,22 +46,14 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Product' ) ) {
$schema['aggregateRating']['@type'] = 'AggregateRating';
if ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) {
$schema['aggregateRating']['ratingValue'] = wp_strip_all_tags( $data['rating'] );
}
if ( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) {
$schema['aggregateRating']['reviewCount'] = wp_strip_all_tags( $data['review-count'] );
}
$schema['aggregateRating']['ratingValue'] = ! empty( $data['rating'] ) ? wp_strip_all_tags( (string)$data['rating'] ) : NULL;
$schema['aggregateRating']['reviewCount'] = ! empty( $data['review-count'] ) ? wp_strip_all_tags( (string)$data['review-count'] ) : NULL;
}
if ( apply_filters( 'wp_schema_pro_remove_product_offers', true ) ) {
$schema['offers']['@type'] = 'Offer';
$schema['offers']['price'] = '0';
if ( isset( $data['price'] ) && ! empty( $data['price'] ) ) {
$schema['offers']['price'] = wp_strip_all_tags( $data['price'] );
}
if ( isset( $data['price-valid-until'] ) && ! empty( $data['price-valid-until'] ) ) {
$schema['offers']['priceValidUntil'] = wp_strip_all_tags( $data['price-valid-until'] );
}
$schema['offers']['price'] = ! empty( $data['price'] ) ? wp_strip_all_tags( (string)$data['price'] ) : NULL;
$schema['offers']['priceValidUntil'] = ! empty( $data['price-valid-until'] ) ? wp_strip_all_tags( (string)$data['price-valid-until'] ) : NULL;
if ( isset( $data['url'] ) && ! empty( $data['url'] ) ) {
$schema['offers']['url'] = esc_url( $data['url'] );
@@ -78,12 +62,8 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Product' ) ) {
if ( ( isset( $data['currency'] ) && ! empty( $data['currency'] ) ) ||
( isset( $data['avail'] ) && ! empty( $data['avail'] ) ) ) {
if ( isset( $data['currency'] ) && ! empty( $data['currency'] ) ) {
$schema['offers']['priceCurrency'] = wp_strip_all_tags( $data['currency'] );
}
if ( isset( $data['avail'] ) && ! empty( $data['avail'] ) ) {
$schema['offers']['availability'] = wp_strip_all_tags( $data['avail'] );
}
$schema['offers']['priceCurrency'] = ! empty( $data['currency'] ) ? wp_strip_all_tags( (string)$data['currency'] ) : NULL;
$schema['offers']['availability'] = ! empty( $data['avail'] ) ? wp_strip_all_tags( (string)$data['avail'] ) : NULL;
}
}
@@ -91,23 +71,19 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Product' ) ) {
foreach ( $data['product-review'] as $key => $value ) {
if ( ( isset( $value['reviewer-name'] ) && ! empty( $value['reviewer-name'] ) ) && ( isset( $value['product-rating'] ) && ! empty( $value['product-rating'] ) ) ) {
$schema['review'][ $key ]['@type'] = 'Review';
if ( isset( $value['reviewer-name'] ) && ! empty( $value['reviewer-name'] ) ) {
$schema['review'][ $key ]['author']['name'] = wp_strip_all_tags( $value['reviewer-name'] );
if ( isset( $value['reviewer-type'] ) && ! empty( $value['reviewer-type'] ) ) {
$schema['review'][ $key ]['author']['@type'] = wp_strip_all_tags( $value['reviewer-type'] );
} else {
$schema['review'][ $key ]['author']['@type'] = 'Person';
}
$schema['review'][ $key ]['author']['name'] = wp_strip_all_tags( (string)$value['reviewer-name'] );
if ( isset( $value['reviewer-type'] ) && ! empty( $value['reviewer-type'] ) ) {
$schema['review'][ $key ]['author']['@type'] = wp_strip_all_tags( (string)$value['reviewer-type'] );
} else {
$schema['review'][ $key ]['author']['@type'] = 'Person';
}
if ( isset( $value['product-rating'] ) && ! empty( $value['product-rating'] ) ) {
$schema['review'][ $key ]['reviewRating']['@type'] = 'Rating';
$schema['review'][ $key ]['reviewRating']['ratingValue'] = wp_strip_all_tags( $value['product-rating'] );
$schema['review'][ $key ]['reviewRating']['ratingValue'] = wp_strip_all_tags( (string)$value['product-rating'] );
}
if ( isset( $value['review-body'] ) && ! empty( $value['review-body'] ) ) {
$schema['review'][ $key ]['reviewBody'] = wp_strip_all_tags( $value['review-body'] );
}
$schema['review'][ $key ]['reviewBody'] = ! empty( $value['review-body'] ) ? wp_strip_all_tags( (string)$value['review-body'] ) : NULL;
}
}
}
@@ -28,70 +28,50 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Recipe' ) ) {
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'Recipe';
if ( isset( $data['name'] ) && ! empty( $data['name'] ) ) {
$schema['name'] = wp_strip_all_tags( $data['name'] );
}
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string)$data['name'] ) : NULL;
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
}
if ( isset( $data['reviewer-type'] ) && ! empty( $data['reviewer-type'] ) ) {
$schema['author']['@type'] = wp_strip_all_tags( $data['reviewer-type'] );
$schema['author']['@type'] = wp_strip_all_tags( (string)$data['reviewer-type'] );
} else {
$schema['author']['@type'] = 'Person';
}
if ( isset( $data['author'] ) && ! empty( $data['author'] ) ) {
$schema['author']['name'] = wp_strip_all_tags( $data['author'] );
}
$schema['author']['name'] = ! empty( $data['author'] ) ? wp_strip_all_tags( (string)$data['author'] ) : NULL;
if ( isset( $data['description'] ) && ! empty( $data['description'] ) ) {
$schema['description'] = wp_strip_all_tags( $data['description'] );
}
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string)$data['description'] ) : NULL;
if ( isset( $data['preperation-time'] ) && ! empty( $data['preperation-time'] ) ) {
$schema['prepTime'] = wp_strip_all_tags( $data['preperation-time'] );
}
$schema['prepTime'] = ! empty( $data['preperation-time'] ) ? wp_strip_all_tags( (string)$data['preperation-time'] ) : NULL;
if ( isset( $data['cook-time'] ) && ! empty( $data['cook-time'] ) ) {
$schema['cookTime'] = wp_strip_all_tags( $data['cook-time'] );
}
$schema['cookTime'] = ! empty( $data['cook-time'] ) ? wp_strip_all_tags( (string)$data['cook-time'] ) : NULL;
if ( isset( $data['recipe-yield'] ) && ! empty( $data['recipe-yield'] ) ) {
$schema['recipeYield'] = esc_html( $data['recipe-yield'] );
}
if ( isset( $data['recipe-keywords'] ) && ! empty( $data['recipe-keywords'] ) ) {
$schema['keywords'] = wp_strip_all_tags( $data['recipe-keywords'] );
}
$schema['keywords'] = ! empty( $data['recipe-keywords'] ) ? wp_strip_all_tags( (string)$data['recipe-keywords'] ) : NULL;
if ( isset( $data['recipe-category'] ) && ! empty( $data['recipe-category'] ) ) {
$schema['recipeCategory'] = wp_strip_all_tags( $data['recipe-category'] );
}
$schema['recipeCategory'] = ! empty( $data['recipe-category'] ) ? wp_strip_all_tags( (string)$data['recipe-category'] ) : NULL;
if ( isset( $data['recipe-cuisine'] ) && ! empty( $data['recipe-cuisine'] ) ) {
$schema['recipeCuisine'] = wp_strip_all_tags( $data['recipe-cuisine'] );
}
$schema['recipeCuisine'] = ! empty( $data['recipe-cuisine'] ) ? wp_strip_all_tags( (string)$data['recipe-cuisine'] ) : NULL;
if ( ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) ||
( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) ) {
$schema['aggregateRating']['@type'] = 'AggregateRating';
if ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) {
$schema['aggregateRating']['ratingValue'] = wp_strip_all_tags( $data['rating'] );
}
if ( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) {
$schema['aggregateRating']['reviewCount'] = wp_strip_all_tags( $data['review-count'] );
}
$schema['aggregateRating']['ratingValue'] = ! empty( $data['rating'] ) ? wp_strip_all_tags( (string)$data['rating'] ) : NULL;
$schema['aggregateRating']['reviewCount'] = ! empty( $data['review-count'] ) ? wp_strip_all_tags( (string)$data['review-count'] ) : NULL;
}
if ( isset( $data['nutrition'] ) && ! empty( $data['nutrition'] ) ) {
$schema['nutrition']['@type'] = 'NutritionInformation';
$schema['nutrition']['calories'] = wp_strip_all_tags( $data['nutrition'] );
$schema['nutrition']['calories'] = wp_strip_all_tags( (string)$data['nutrition'] );
}
if ( isset( $data['ingredients'] ) && ! empty( $data['ingredients'] ) ) {
$recipe_ingredients = explode( ',', $data['ingredients'] );
foreach ( $recipe_ingredients as $key => $value ) {
$schema['recipeIngredient'][ $key ] = wp_strip_all_tags( $value );
$schema['recipeIngredient'][ $key ] = wp_strip_all_tags( (string)$value );
}
}
@@ -101,14 +81,9 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Recipe' ) ) {
if ( isset( $value['steps'] ) && ! empty( $value['steps'] ) ) {
$schema['recipeInstructions'][ $key ]['@type'] = 'HowToStep';
$schema['recipeInstructions'][ $key ]['text'] = wp_strip_all_tags( $value['steps'] );
if ( isset( $value['name'] ) && ! empty( $value['name'] ) ) {
$schema['recipeInstructions'][ $key ]['name'] = wp_strip_all_tags( $value['name'] );
}
if ( isset( $value['url'] ) && ! empty( $value['url'] ) ) {
$schema['recipeInstructions'][ $key ]['url'] = wp_strip_all_tags( $value['url'] );
}
$schema['recipeInstructions'][ $key ]['text'] = wp_strip_all_tags( (string)$value['steps'] );
$schema['recipeInstructions'][ $key ]['name'] = ! empty( $value['name'] ) ? wp_strip_all_tags( (string)$value['name'] ) : NULL;
$schema['recipeInstructions'][ $key ]['url'] = ! empty( $value['url'] ) ? wp_strip_all_tags( (string)$value['url'] ) : NULL;
if ( isset( $value['image'] ) && ! empty( $value['image'] ) ) {
$schema['recipeInstructions'][ $key ]['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $value['image'], 'URL' );
}
@@ -121,13 +96,8 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Recipe' ) ) {
foreach ( $data['recipe-video'] as $key => $value ) {
if ( isset( $value['video-name'] ) && ! empty( $value['video-name'] ) ) {
$schema['video'][ $key ]['@type'] = 'VideoObject';
if ( isset( $value['video-name'] ) && ! empty( $value['video-name'] ) ) {
$schema['video'][ $key ]['name'] = wp_strip_all_tags( $value['video-name'] );
}
if ( isset( $value['video-desc'] ) && ! empty( $value['video-desc'] ) ) {
$schema['video'][ $key ]['description'] = wp_strip_all_tags( $value['video-desc'] );
}
$schema['video'][ $key ]['name'] = wp_strip_all_tags( (string)$value['video-name'] );
$schema['video'][ $key ]['description'] = ! empty( $value['video-desc'] ) ? wp_strip_all_tags( (string)$value['video-desc'] ) : NULL;
if ( isset( $value['video-image'] ) && ! empty( $value['video-image'] ) ) {
$schema['video'][ $key ]['thumbnailUrl'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $value['video-image'], 'URL' );
}
@@ -137,16 +107,10 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Recipe' ) ) {
if ( isset( $value['recipe-video-embed-url'] ) && ! empty( $value['recipe-video-embed-url'] ) ) {
$schema['video'][ $key ]['embedUrl'] = esc_url( $value['recipe-video-embed-url'] );
}
if ( isset( $value['recipe-video-duration'] ) && ! empty( $value['recipe-video-duration'] ) ) {
$schema['video'][ $key ]['duration'] = wp_strip_all_tags( $value['recipe-video-duration'] );
}
if ( isset( $value['recipe-video-upload-date'] ) && ! empty( $value['recipe-video-upload-date'] ) ) {
$schema['video'][ $key ]['uploadDate'] = wp_strip_all_tags( $value['recipe-video-upload-date'] );
}
if ( isset( $value['recipe-video-interaction-count'] ) && ! empty( $value['recipe-video-interaction-count'] ) ) {
$schema['video'][ $key ]['interactionCount'] = wp_strip_all_tags( $value['recipe-video-interaction-count'] );
}
if ( isset( $value['recipe-video-expires-date'] ) && ! empty( $value['recipe-video-expires-date'] ) ) {
$schema['video'][ $key ]['duration'] = ! empty( $value['recipe-video-duration'] ) ? wp_strip_all_tags( (string)$value['recipe-video-duration'] ) : NULL;
$schema['video'][ $key ]['uploadDate'] = ! empty( $value['recipe-video-upload-date'] ) ? wp_strip_all_tags( (string)$value['recipe-video-upload-date'] ) : NULL;
$schema['video'][ $key ]['interactionCount'] = ! empty( $value['recipe-video-interaction-count'] ) ? wp_strip_all_tags( (string)$value['recipe-video-interaction-count'] ) : NULL;
if ( isset( $value['recipe-video-expires-date'] ) && ! empty( $value['recipe-video-expires-date'] ) && is_string( $value['recipe-video-expires-date'] ) ) {
$schema['video'][ $key ]['expires'] = wp_strip_all_tags( $value['recipe-video-expires-date'] );
}
}
@@ -34,23 +34,15 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Review' ) ) {
switch ( $data['schema-type'] ) {
case 'bsf-aiosrs-book':
$schema['itemReviewed']['@type'] = 'Book';
if ( isset( $data['bsf-aiosrs-book-name'] ) && ! empty( $data['bsf-aiosrs-book-name'] ) ) {
$schema['itemReviewed']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-book-name'] );
}
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-book-name'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-book-name'] ) : NULL;
if ( isset( $data['bsf-aiosrs-book-author'] ) && ! empty( $data['bsf-aiosrs-book-author'] ) ) {
$schema['itemReviewed']['author']['@type'] = 'Person';
$schema['itemReviewed']['author']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-book-author'] );
$schema['itemReviewed']['author']['sameAs'] = wp_strip_all_tags( $data['bsf-aiosrs-book-same-As'] );
$schema['itemReviewed']['author']['name'] = wp_strip_all_tags( (string)$data['bsf-aiosrs-book-author'] );
$schema['itemReviewed']['author']['sameAs'] = wp_strip_all_tags( (string)$data['bsf-aiosrs-book-same-As'] );
}
if ( isset( $data['bsf-aiosrs-book-serial-number'] ) && ! empty( $data['bsf-aiosrs-book-serial-number'] ) ) {
$schema['itemReviewed']['isbn'] = wp_strip_all_tags( $data['bsf-aiosrs-book-serial-number'] );
}
if ( isset( $data['bsf-aiosrs-book-description'] ) && ! empty( $data['bsf-aiosrs-book-description'] ) ) {
$schema['description'] = wp_strip_all_tags( $data['bsf-aiosrs-book-description'] );
}
$schema['itemReviewed']['isbn'] = ! empty( $data['bsf-aiosrs-book-serial-number'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-book-serial-number'] ) : NULL;
$schema['description'] = ! empty( $data['bsf-aiosrs-book-description'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-book-description'] ) : NULL;
$book_url = get_permalink( $post['ID'] );
if ( isset( $book_url ) && ! empty( $book_url ) ) {
$schema['url'] = esc_url( $book_url );
@@ -58,52 +50,34 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Review' ) ) {
break;
case 'bsf-aiosrs-course':
$schema['itemReviewed']['@type'] = 'Course';
if ( isset( $data['bsf-aiosrs-course-name'] ) && ! empty( $data['bsf-aiosrs-course-name'] ) ) {
$schema['itemReviewed']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-course-name'] );
}
if ( isset( $data['bsf-aiosrs-course-description'] ) && ! empty( $data['bsf-aiosrs-course-description'] ) ) {
$schema['itemReviewed']['description'] = wp_strip_all_tags( $data['bsf-aiosrs-course-description'] );
}
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-course-name'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-course-name'] ) : NULL;
$schema['itemReviewed']['description'] = ! empty( $data['bsf-aiosrs-course-description'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-course-description'] ) : NULL;
if ( isset( $data['bsf-aiosrs-course-orgnization-name'] ) && ! empty( $data['bsf-aiosrs-course-orgnization-name'] ) ) {
$schema['itemReviewed']['provider']['@type'] = 'Organization';
$schema['itemReviewed']['provider']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-course-orgnization-name'] );
$schema['itemReviewed']['provider']['name'] = wp_strip_all_tags( (string)$data['bsf-aiosrs-course-orgnization-name'] );
}
break;
case 'bsf-aiosrs-event':
$schema['itemReviewed']['@type'] = 'event';
if ( isset( $data['bsf-aiosrs-event-name'] ) && ! empty( $data['bsf-aiosrs-event-name'] ) ) {
$schema['itemReviewed']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-event-name'] );
}
if ( isset( $data['bsf-aiosrs-event-description'] ) && ! empty( $data['bsf-aiosrs-event-description'] ) ) {
$schema['itemReviewed']['description'] = wp_strip_all_tags( $data['bsf-aiosrs-event-description'] );
}
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-event-name'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-name'] ) : NULL;
$schema['itemReviewed']['description'] = ! empty( $data['bsf-aiosrs-event-description'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-description'] ) : NULL;
if ( isset( $data['bsf-aiosrs-event-image'] ) && ! empty( $data['bsf-aiosrs-event-image'] ) ) {
$schema['itemReviewed']['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['bsf-aiosrs-event-image'] );
}
if ( isset( $data['bsf-aiosrs-event-start-date'] ) && ! empty( $data['bsf-aiosrs-event-start-date'] ) ) {
if ( 'OfflineEventAttendanceMode' !== $data['bsf-aiosrs-event-event-attendance-mode'] ) {
$start_date = gmdate( DATE_ISO8601, strtotime( $data['bsf-aiosrs-event-start-date'] ) );
$schema['itemReviewed']['startDate'] = wp_strip_all_tags( $start_date );
$schema['itemReviewed']['startDate'] = wp_strip_all_tags( (string)$start_date );
} else {
$schema['itemReviewed']['startDate'] = wp_strip_all_tags( $data['bsf-aiosrs-event-start-date'] );
$schema['itemReviewed']['startDate'] = wp_strip_all_tags( (string)$data['bsf-aiosrs-event-start-date'] );
}
}
if ( isset( $data['bsf-aiosrs-event-end-date'] ) && ! empty( $data['bsf-aiosrs-event-end-date'] ) ) {
$schema['itemReviewed']['endDate'] = wp_strip_all_tags( $data['bsf-aiosrs-event-end-date'] );
}
if ( isset( $data['bsf-aiosrs-event-event-status'] ) && ! empty( $data['bsf-aiosrs-event-event-status'] ) ) {
$schema['itemReviewed']['eventStatus'] = wp_strip_all_tags( $data['bsf-aiosrs-event-event-status'] );
}
$schema['itemReviewed']['endDate'] = ! empty( $data['bsf-aiosrs-event-end-date'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-end-date'] ) : NULL;
$schema['itemReviewed']['eventStatus'] = ! empty( $data['bsf-aiosrs-event-event-status'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-event-status'] ) : NULL;
if ( isset( $data['bsf-aiosrs-event-event-attendance-mode'] ) && ! empty( $data['bsf-aiosrs-event-event-attendance-mode'] ) ) {
$schema['itemReviewed']['eventAttendanceMode'] = wp_strip_all_tags( $data['bsf-aiosrs-event-event-attendance-mode'] );
}
$schema['itemReviewed']['eventAttendanceMode'] = ! empty( $data['bsf-aiosrs-event-event-attendance-mode'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-event-attendance-mode'] ) : NULL;
if ( isset( $data['bsf-aiosrs-event-previous-date'] ) && ! empty( $data['bsf-aiosrs-event-previous-date'] ) && 'EventRescheduled' === $data['bsf-aiosrs-event-event-status'] ) {
$schema['itemReviewed']['previousStartDate'] = wp_strip_all_tags( $data['bsf-aiosrs-event-previous-date'] );
}
$schema['itemReviewed']['previousStartDate'] = ! empty( $data['bsf-aiosrs-event-previous-date'] ) && 'EventRescheduled' === $data['bsf-aiosrs-event-event-status'] ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-previous-date'] ) : NULL;
if ( isset( $data['bsf-aiosrs-event-online-location'] ) && ! empty( $data['bsf-aiosrs-event-online-location'] ) &&
( 'OfflineEventAttendanceMode' !== $data['bsf-aiosrs-event-event-attendance-mode'] ) ||
( 'MixedEventAttendanceMode' === $data['bsf-aiosrs-event-event-attendance-mode'] ) ) {
@@ -112,11 +86,11 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Review' ) ) {
}
if ( isset( $data['bsf-aiosrs-event-performer'] ) && ! empty( $data['bsf-aiosrs-event-performer'] ) ) {
$schema['itemReviewed']['performer']['@type'] = 'Person';
$schema['itemReviewed']['performer']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-event-performer'] );
$schema['itemReviewed']['performer']['name'] = wp_strip_all_tags( (string)$data['bsf-aiosrs-event-performer'] );
}
if ( isset( $data['bsf-aiosrs-event-location'] ) && ! empty( $data['bsf-aiosrs-event-location'] ) && 'OnlineEventAttendanceMode' !== $data['bsf-aiosrs-event-event-attendance-mode'] ) {
$schema['itemReviewed']['location']['@type'] = 'Place';
$schema['itemReviewed']['location']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-event-location'] );
$schema['itemReviewed']['location']['name'] = wp_strip_all_tags( (string)$data['bsf-aiosrs-event-location'] );
}
if ( ( ( isset( $data['bsf-aiosrs-event-location-street'] ) && ! empty( $data['bsf-aiosrs-event-location-street'] ) ) ||
( isset( $data['bsf-aiosrs-event-location-locality'] ) && ! empty( $data['bsf-aiosrs-event-location-locality'] ) ) ||
@@ -125,21 +99,11 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Review' ) ) {
( isset( $data['bsf-aiosrs-event-location-country'] ) && ! empty( $data['bsf-aiosrs-event-location-country'] ) ) ) && ( 'OnlineEventAttendanceMode' !== $data['bsf-aiosrs-event-event-attendance-mode'] ) ) {
$schema['itemReviewed']['location']['address']['@type'] = 'PostalAddress';
if ( isset( $data['bsf-aiosrs-event-location-street'] ) && ! empty( $data['bsf-aiosrs-event-location-street'] ) ) {
$schema['itemReviewed']['location']['address']['streetAddress'] = wp_strip_all_tags( $data['bsf-aiosrs-event-location-street'] );
}
if ( isset( $data['bsf-aiosrs-event-location-locality'] ) && ! empty( $data['bsf-aiosrs-event-location-locality'] ) ) {
$schema['itemReviewed']['location']['address']['addressLocality'] = wp_strip_all_tags( $data['bsf-aiosrs-event-location-locality'] );
}
if ( isset( $data['bsf-aiosrs-event-location-postal'] ) && ! empty( $data['bsf-aiosrs-event-location-postal'] ) ) {
$schema['itemReviewed']['location']['address']['postalCode'] = wp_strip_all_tags( $data['bsf-aiosrs-event-location-postal'] );
}
if ( isset( $data['bsf-aiosrs-event-location-region'] ) && ! empty( $data['bsf-aiosrs-event-location-region'] ) ) {
$schema['itemReviewed']['location']['address']['addressRegion'] = wp_strip_all_tags( $data['bsf-aiosrs-event-location-region'] );
}
if ( isset( $data['bsf-aiosrs-event-location-country'] ) && ! empty( $data['bsf-aiosrs-event-location-country'] ) ) {
$schema['itemReviewed']['location']['address']['addressCountry'] = wp_strip_all_tags( $data['bsf-aiosrs-event-location-country'] );
}
$schema['itemReviewed']['location']['address']['streetAddress'] = ! empty( $data['bsf-aiosrs-event-location-street'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-location-street'] ) : NULL;
$schema['itemReviewed']['location']['address']['addressLocality'] = ! empty( $data['bsf-aiosrs-event-location-locality'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-location-locality'] ) : NULL;
$schema['itemReviewed']['location']['address']['postalCode'] = ! empty( $data['bsf-aiosrs-event-location-postal'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-location-postal'] ) : NULL;
$schema['itemReviewed']['location']['address']['addressRegion'] = ! empty( $data['bsf-aiosrs-event-location-region'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-location-region'] ) : NULL;
$schema['itemReviewed']['location']['address']['addressCountry'] = ! empty( $data['bsf-aiosrs-event-location-country'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-location-country'] ) : NULL;
}
$schema['itemReviewed']['offers']['@type'] = 'Offer';
@@ -150,27 +114,17 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Review' ) ) {
if ( isset( $data['bsf-aiosrs-event-ticket-buy-url'] ) && ! empty( $data['bsf-aiosrs-event-ticket-buy-url'] ) ) {
$schema['itemReviewed']['offers']['url'] = esc_url( $data['bsf-aiosrs-event-ticket-buy-url'] );
}
if ( isset( $data['bsf-aiosrs-event-price'] ) && ! empty( $data['bsf-aiosrs-event-price'] ) ) {
$schema['itemReviewed']['offers']['price'] = wp_strip_all_tags( $data['bsf-aiosrs-event-price'] );
}
if ( isset( $data['bsf-aiosrs-event-avail'] ) && ! empty( $data['bsf-aiosrs-event-avail'] ) ) {
$schema['itemReviewed']['offers']['availability'] = wp_strip_all_tags( $data['bsf-aiosrs-event-avail'] );
}
if ( isset( $data['bsf-aiosrs-event-currency'] ) && ! empty( $data['bsf-aiosrs-event-currency'] ) ) {
$schema['itemReviewed']['offers']['priceCurrency'] = wp_strip_all_tags( $data['bsf-aiosrs-event-currency'] );
}
if ( isset( $data['bsf-aiosrs-event-valid-from'] ) && ! empty( $data['bsf-aiosrs-event-valid-from'] ) ) {
$schema['itemReviewed']['offers']['validFrom'] = wp_strip_all_tags( $data['bsf-aiosrs-event-valid-from'] );
}
$schema['itemReviewed']['offers']['price'] = ! empty( $data['bsf-aiosrs-event-price'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-price'] ) : NULL;
$schema['itemReviewed']['offers']['availability'] = ! empty( $data['bsf-aiosrs-event-avail'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-avail'] ) : NULL;
$schema['itemReviewed']['offers']['priceCurrency'] = ! empty( $data['bsf-aiosrs-event-currency'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-currency'] ) : NULL;
$schema['itemReviewed']['offers']['validFrom'] = ! empty( $data['bsf-aiosrs-event-valid-from'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-valid-from'] ) : NULL;
}
if ( ( isset( $data['bsf-aiosrs-event-event-organizer-name'] ) && ! empty( $data['bsf-aiosrs-event-event-organizer-name'] ) ) ||
( isset( $data['bsf-aiosrs-event-event-organizer-url'] ) && ! empty( $data['bsf-aiosrs-event-event-organizer-url'] ) ) ) {
$schema['itemReviewed']['organizer']['@type'] = 'Organization';
if ( isset( $data['bsf-aiosrs-event-event-organizer-name'] ) && ! empty( $data['bsf-aiosrs-event-event-organizer-name'] ) ) {
$schema['itemReviewed']['organizer']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-event-event-organizer-name'] );
}
$schema['itemReviewed']['organizer']['name'] = ! empty( $data['bsf-aiosrs-event-event-organizer-name'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-event-event-organizer-name'] ) : NULL;
if ( isset( $data['bsf-aiosrs-event-event-organizer-url'] ) && ! empty( $data['bsf-aiosrs-event-event-organizer-url'] ) ) {
$schema['itemReviewed']['organizer']['url'] = esc_url( $data['bsf-aiosrs-event-event-organizer-url'] );
}
@@ -178,16 +132,12 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Review' ) ) {
break;
case 'bsf-aiosrs-local-business':
$schema['itemReviewed']['@type'] = 'LocalBusiness';
if ( isset( $data['bsf-aiosrs-local-business-name'] ) && ! empty( $data['bsf-aiosrs-local-business-name'] ) ) {
$schema['itemReviewed']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-local-business-name'] );
}
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-local-business-name'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-local-business-name'] ) : NULL;
if ( isset( $data['bsf-aiosrs-local-business-image'] ) && ! empty( $data['bsf-aiosrs-local-business-image'] ) ) {
$schema['itemReviewed']['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['bsf-aiosrs-local-business-image'] );
}
if ( isset( $data['bsf-aiosrs-local-business-telephone'] ) && ! empty( $data['bsf-aiosrs-local-business-telephone'] ) ) {
$schema['itemReviewed']['telephone'] = wp_strip_all_tags( $data['bsf-aiosrs-local-business-telephone'] );
}
$schema['itemReviewed']['telephone'] = ! empty( $data['bsf-aiosrs-local-business-telephone'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-local-business-telephone'] ) : NULL;
if ( ( isset( $data['bsf-aiosrs-local-business-location-street'] ) && ! empty( $data['bsf-aiosrs-local-business-location-street'] ) ) ||
( isset( $data['bsf-aiosrs-local-business-location-locality'] ) && ! empty( $data['bsf-aiosrs-local-business-location-locality'] ) ) ||
( isset( $data['bsf-aiosrs-local-business-location-postal'] ) && ! empty( $data['bsf-aiosrs-local-business-location-postal'] ) ) ||
@@ -196,74 +146,44 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Review' ) ) {
$schema['itemReviewed']['address']['@type'] = 'PostalAddress';
if ( isset( $data['bsf-aiosrs-local-business-location-street'] ) && ! empty( $data['bsf-aiosrs-local-business-location-street'] ) ) {
$schema['itemReviewed']['address']['streetAddress'] = wp_strip_all_tags( $data['bsf-aiosrs-local-business-location-street'] );
}
if ( isset( $data['bsf-aiosrs-local-business-location-locality'] ) && ! empty( $data['bsf-aiosrs-local-business-location-locality'] ) ) {
$schema['itemReviewed']['address']['addressLocality'] = wp_strip_all_tags( $data['bsf-aiosrs-local-business-location-locality'] );
}
if ( isset( $data['bsf-aiosrs-local-business-location-postal'] ) && ! empty( $data['bsf-aiosrs-local-business-location-postal'] ) ) {
$schema['itemReviewed']['address']['postalCode'] = wp_strip_all_tags( $data['bsf-aiosrs-local-business-location-postal'] );
}
if ( isset( $data['bsf-aiosrs-local-business-location-region'] ) && ! empty( $data['bsf-aiosrs-local-business-location-region'] ) ) {
$schema['itemReviewed']['address']['addressRegion'] = wp_strip_all_tags( $data['bsf-aiosrs-local-business-location-region'] );
}
if ( isset( $data['bsf-aiosrs-local-business-location-country'] ) && ! empty( $data['bsf-aiosrs-local-business-location-country'] ) ) {
$schema['itemReviewed']['address']['addressCountry'] = wp_strip_all_tags( $data['bsf-aiosrs-local-business-location-country'] );
}
}
if ( isset( $data['bsf-aiosrs-local-business-price-range'] ) && ! empty( $data['bsf-aiosrs-local-business-price-range'] ) ) {
$schema['itemReviewed']['priceRange'] = wp_strip_all_tags( $data['bsf-aiosrs-local-business-price-range'] );
$schema['itemReviewed']['address']['streetAddress'] = ! empty( $data['bsf-aiosrs-local-business-location-street'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-local-business-location-street'] ) : NULL;
$schema['itemReviewed']['address']['addressLocality'] = ! empty( $data['bsf-aiosrs-local-business-location-locality'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-local-business-location-locality'] ) : NULL;
$schema['itemReviewed']['address']['postalCode'] = ! empty( $data['bsf-aiosrs-local-business-location-postal'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-local-business-location-postal'] ) : NULL;
$schema['itemReviewed']['address']['addressRegion'] = ! empty( $data['bsf-aiosrs-local-business-location-region'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-local-business-location-region'] ) : NULL;
$schema['itemReviewed']['address']['addressCountry'] = ! empty( $data['bsf-aiosrs-local-business-location-country'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-local-business-location-country'] ) : NULL;
}
$schema['itemReviewed']['priceRange'] = ! empty( $data['bsf-aiosrs-local-business-price-range'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-local-business-price-range'] ) : NULL;
break;
case 'bsf-aiosrs-recipe':
$schema['itemReviewed']['@type'] = 'Recipe';
if ( isset( $data['bsf-aiosrs-recipe-name'] ) && ! empty( $data['bsf-aiosrs-recipe-name'] ) ) {
$schema['itemReviewed']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-name'] );
}
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-recipe-name'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-name'] ) : NULL;
if ( isset( $data['bsf-aiosrs-recipe-image'] ) && ! empty( $data['bsf-aiosrs-recipe-image'] ) ) {
$schema['itemReviewed']['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['bsf-aiosrs-recipe-image'] );
}
if ( isset( $data['bsf-aiosrs-recipe-author'] ) && ! empty( $data['bsf-aiosrs-recipe-author'] ) ) {
$schema['itemReviewed']['author']['@type'] = 'Person';
$schema['itemReviewed']['author']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-author'] );
}
if ( isset( $data['bsf-aiosrs-recipe-description'] ) && ! empty( $data['bsf-aiosrs-recipe-description'] ) ) {
$schema['itemReviewed']['description'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-description'] );
}
if ( isset( $data['bsf-aiosrs-recipe-preperation-time'] ) && ! empty( $data['bsf-aiosrs-recipe-preperation-time'] ) ) {
$schema['itemReviewed']['prepTime'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-preperation-time'] );
}
if ( isset( $data['bsf-aiosrs-recipe-cook-time'] ) && ! empty( $data['bsf-aiosrs-recipe-cook-time'] ) ) {
$schema['itemReviewed']['cookTime'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-cook-time'] );
}
if ( isset( $data['bsf-aiosrs-recipe-recipe-keywords'] ) && ! empty( $data['bsf-aiosrs-recipe-recipe-keywords'] ) ) {
$schema['itemReviewed']['keywords'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-recipe-keywords'] );
}
if ( isset( $data['bsf-aiosrs-recipe-recipe-category'] ) && ! empty( $data['bsf-aiosrs-recipe-recipe-category'] ) ) {
$schema['itemReviewed']['recipeCategory'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-recipe-category'] );
}
if ( isset( $data['bsf-aiosrs-recipe-recipe-cuisine'] ) && ! empty( $data['bsf-aiosrs-recipe-recipe-cuisine'] ) ) {
$schema['itemReviewed']['recipeCuisine'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-recipe-cuisine'] );
$schema['itemReviewed']['author']['name'] = wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-author'] );
}
$schema['itemReviewed']['description'] = ! empty( $data['bsf-aiosrs-recipe-description'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-description'] ) : NULL;
$schema['itemReviewed']['prepTime'] = ! empty( $data['bsf-aiosrs-recipe-preperation-time'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-preperation-time'] ) : NULL;
$schema['itemReviewed']['cookTime'] = ! empty( $data['bsf-aiosrs-recipe-cook-time'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-cook-time'] ) : NULL;
$schema['itemReviewed']['keywords'] = ! empty( $data['bsf-aiosrs-recipe-recipe-keywords'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-recipe-keywords'] ) : NULL;
$schema['itemReviewed']['recipeCategory'] = ! empty( $data['bsf-aiosrs-recipe-recipe-category'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-recipe-category'] ) : NULL;
$schema['itemReviewed']['recipeCuisine'] = ! empty( $data['bsf-aiosrs-recipe-recipe-cuisine'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-recipe-cuisine'] ) : NULL;
if ( ( isset( $data['bsf-aiosrs-recipe-rating'] ) && ! empty( $data['bsf-aiosrs-recipe-rating'] ) ) ||
( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) ) {
$schema['itemReviewed']['aggregateRating']['@type'] = 'AggregateRating';
if ( isset( $data['bsf-aiosrs-recipe-rating'] ) && ! empty( $data['bsf-aiosrs-recipe-rating'] ) ) {
$schema['itemReviewed']['aggregateRating']['ratingValue'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-rating'] );
}
if ( isset( $data['bsf-aiosrs-recipe-review-count'] ) && ! empty( $data['bsf-aiosrs-recipe-review-count'] ) ) {
$schema['itemReviewed']['aggregateRating']['reviewCount'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-review-count'] );
}
$schema['itemReviewed']['aggregateRating']['ratingValue'] = ! empty( $data['bsf-aiosrs-recipe-rating'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-rating'] ) : NULL;
$schema['itemReviewed']['aggregateRating']['reviewCount'] = ! empty( $data['bsf-aiosrs-recipe-review-count'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-review-count'] ) : NULL;
}
if ( isset( $data['bsf-aiosrs-recipe-nutrition'] ) && ! empty( $data['bsf-aiosrs-recipe-nutrition'] ) ) {
$schema['itemReviewed']['nutrition']['@type'] = 'NutritionInformation';
$schema['itemReviewed']['nutrition']['calories'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-nutrition'] );
$schema['itemReviewed']['nutrition']['calories'] = wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-nutrition'] );
}
if ( isset( $data['bsf-aiosrs-recipe-ingredients'] ) && ! empty( $data['bsf-aiosrs-recipe-ingredients'] ) ) {
$recipe_ingredients = explode( ',', $data['bsf-aiosrs-recipe-ingredients'] );
foreach ( $recipe_ingredients as $key => $value ) {
$schema['itemReviewed']['recipeIngredient'][ $key ] = wp_strip_all_tags( $value );
$schema['itemReviewed']['recipeIngredient'][ $key ] = wp_strip_all_tags( (string)$value );
}
}
if ( isset( $data['bsf-aiosrs-recipe-recipe-instructions'] ) && ! empty( $data['bsf-aiosrs-recipe-recipe-instructions'] ) ) {
@@ -271,17 +191,15 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Review' ) ) {
foreach ( $recipe_instructions as $key => $value ) {
if ( isset( $value ) && ! empty( $value ) ) {
$schema['itemReviewed']['recipeInstructions'][ $key ]['@type'] = 'HowToStep';
$schema['itemReviewed']['recipeInstructions'][ $key ]['text'] = wp_strip_all_tags( $value );
$schema['itemReviewed']['recipeInstructions'][ $key ]['text'] = wp_strip_all_tags( (string)$value );
}
}
}
if ( isset( $data['bsf-aiosrs-recipe-video-name'] ) && ! empty( $data['bsf-aiosrs-recipe-video-name'] ) ) {
$schema['itemReviewed']['video']['@type'] = 'VideoObject';
$schema['itemReviewed']['video']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-video-name'] );
if ( isset( $data['bsf-aiosrs-recipe-video-desc'] ) && ! empty( $data['bsf-aiosrs-recipe-video-desc'] ) ) {
$schema['itemReviewed']['video']['description'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-video-desc'] );
}
$schema['itemReviewed']['video']['name'] = wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-video-name'] );
$schema['itemReviewed']['video']['description'] = ! empty( $data['bsf-aiosrs-recipe-video-desc'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-video-desc'] ) : NULL;
if ( isset( $data['bsf-aiosrs-recipe-video-image'] ) && ! empty( $data['bsf-aiosrs-recipe-video-image'] ) ) {
$schema['itemReviewed']['video']['thumbnailUrl'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['bsf-aiosrs-recipe-video-image'] );
}
@@ -291,81 +209,51 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Review' ) ) {
if ( isset( $data['bsf-aiosrs-recipe-recipe-video-embed-url'] ) && ! empty( $data['bsf-aiosrs-recipe-recipe-video-embed-url'] ) ) {
$schema['itemReviewed']['video']['embedUrl'] = esc_url( $data['bsf-aiosrs-recipe-recipe-video-embed-url'] );
}
if ( isset( $data['bsf-aiosrs-recipe-recipe-video-duration'] ) && ! empty( $data['bsf-aiosrs-recipe-recipe-video-duration'] ) ) {
$schema['itemReviewed']['video']['duration'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-recipe-video-duration'] );
}
if ( isset( $data['bsf-aiosrs-recipe-recipe-video-upload-date'] ) && ! empty( $data['bsf-aiosrs-recipe-recipe-video-upload-date'] ) ) {
$schema['itemReviewed']['video']['uploadDate'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-recipe-video-upload-date'] );
}
if ( isset( $data['bsf-aiosrs-recipe-recipe-video-interaction-count'] ) && ! empty( $data['bsf-aiosrs-recipe-recipe-video-interaction-count'] ) ) {
$schema['itemReviewed']['video']['interactionCount'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-recipe-video-interaction-count'] );
}
if ( isset( $data['bsf-aiosrs-recipe-recipe-video-expires-date'] ) && ! empty( $data['bsf-aiosrs-recipe-recipe-video-expires-date'] ) ) {
$schema['itemReviewed']['video']['expires'] = wp_strip_all_tags( $data['bsf-aiosrs-recipe-recipe-video-expires-date'] );
}
$schema['itemReviewed']['video']['duration'] = ! empty( $data['bsf-aiosrs-recipe-recipe-video-duration'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-recipe-video-duration'] ) : NULL;
$schema['itemReviewed']['video']['uploadDate'] = ! empty( $data['bsf-aiosrs-recipe-recipe-video-upload-date'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-recipe-video-upload-date'] ) : NULL;
$schema['itemReviewed']['video']['interactionCount'] = ! empty( $data['bsf-aiosrs-recipe-recipe-video-interaction-count'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-recipe-video-interaction-count'] ) : NULL;
$schema['itemReviewed']['video']['expires'] = ! empty( $data['bsf-aiosrs-recipe-recipe-video-expires-date'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-recipe-recipe-video-expires-date'] ) : NULL;
}
break;
case 'bsf-aiosrs-software-application':
$schema['itemReviewed']['@type'] = 'SoftwareApplication';
if ( isset( $data['bsf-aiosrs-software-application-name'] ) && ! empty( $data['bsf-aiosrs-software-application-name'] ) ) {
$schema['itemReviewed']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-software-application-name'] );
}
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-software-application-name'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-software-application-name'] ) : NULL;
if ( isset( $data['bsf-aiosrs-software-application-operating-system'] ) && ! empty( $data['bsf-aiosrs-software-application-operating-system'] ) ) {
$schema['itemReviewed']['operatingSystem'] = wp_strip_all_tags( $data['bsf-aiosrs-software-application-operating-system'] );
}
$schema['itemReviewed']['operatingSystem'] = ! empty( $data['bsf-aiosrs-software-application-operating-system'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-software-application-operating-system'] ) : NULL;
if ( isset( $data['bsf-aiosrs-software-application-category'] ) && ! empty( $data['bsf-aiosrs-software-application-category'] ) ) {
$schema['itemReviewed']['applicationCategory'] = wp_strip_all_tags( $data['bsf-aiosrs-software-application-category'] );
}
$schema['itemReviewed']['applicationCategory'] = ! empty( $data['bsf-aiosrs-software-application-category'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-software-application-category'] ) : NULL;
if ( ( isset( $data['bsf-aiosrs-software-application-rating'] ) && ! empty( $data['bsf-aiosrs-software-application-rating'] ) ) ||
( isset( $data['bsf-aiosrs-software-application-review-count'] ) && ! empty( $data['bsf-aiosrs-software-application-review-count'] ) ) ) {
$schema['itemReviewed']['aggregateRating']['@type'] = 'AggregateRating';
if ( isset( $data['bsf-aiosrs-software-application-rating'] ) && ! empty( $data['bsf-aiosrs-software-application-rating'] ) ) {
$schema['itemReviewed']['aggregateRating']['ratingValue'] = wp_strip_all_tags( $data['bsf-aiosrs-software-application-rating'] );
}
if ( isset( $data['bsf-aiosrs-software-application-review-count'] ) && ! empty( $data['bsf-aiosrs-software-application-review-count'] ) ) {
$schema['itemReviewed']['aggregateRating']['reviewCount'] = wp_strip_all_tags( $data['bsf-aiosrs-software-application-review-count'] );
}
$schema['itemReviewed']['aggregateRating']['ratingValue'] = ! empty( $data['bsf-aiosrs-software-application-rating'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-software-application-rating'] ) : NULL;
$schema['itemReviewed']['aggregateRating']['reviewCount'] = ! empty( $data['bsf-aiosrs-software-application-review-count'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-software-application-review-count'] ) : NULL;
}
if ( true === apply_filters( 'wp_schema_pro_remove_software_application_offers_review_type', true ) ) {
$schema['itemReviewed']['offers']['@type'] = 'Offer';
$schema['itemReviewed']['offers']['price'] = '0';
if ( isset( $data['bsf-aiosrs-software-application-price'] ) && ! empty( $data['bsf-aiosrs-software-application-price'] ) ) {
$schema['itemReviewed']['offers']['price'] = wp_strip_all_tags( $data['bsf-aiosrs-software-application-price'] );
}
$schema['itemReviewed']['offers']['price'] = ! empty( $data['bsf-aiosrs-software-application-price'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-software-application-price'] ) : NULL;
if ( isset( $data['bsf-aiosrs-software-application-currency'] ) && ! empty( $data['bsf-aiosrs-software-application-currency'] ) ) {
$schema['itemReviewed']['offers']['priceCurrency'] = wp_strip_all_tags( $data['bsf-aiosrs-software-application-currency'] );
}
$schema['itemReviewed']['offers']['priceCurrency'] = ! empty( $data['bsf-aiosrs-software-application-currency'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-software-application-currency'] ) : NULL;
}
break;
case 'bsf-aiosrs-product':
$schema['itemReviewed']['@type'] = 'product';
if ( isset( $data['bsf-aiosrs-product-name'] ) && ! empty( $data['bsf-aiosrs-product-name'] ) ) {
$schema['itemReviewed']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-product-name'] );
}
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-product-name'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-product-name'] ) : NULL;
if ( isset( $data['bsf-aiosrs-product-image'] ) && ! empty( $data['bsf-aiosrs-product-image'] ) ) {
$schema['itemReviewed']['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['bsf-aiosrs-product-image'] );
}
if ( isset( $data['bsf-aiosrs-product-description'] ) && ! empty( $data['bsf-aiosrs-product-description'] ) ) {
$schema['itemReviewed']['description'] = wp_strip_all_tags( $data['bsf-aiosrs-product-description'] );
}
$schema['itemReviewed']['description'] = ! empty( $data['bsf-aiosrs-product-description'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-product-description'] ) : NULL;
if ( isset( $data['bsf-aiosrs-product-sku'] ) && ! empty( $data['bsf-aiosrs-product-sku'] ) ) {
$schema['itemReviewed']['sku'] = wp_strip_all_tags( $data['bsf-aiosrs-product-sku'] );
}
if ( isset( $data['bsf-aiosrs-product-mpn'] ) && ! empty( $data['bsf-aiosrs-product-mpn'] ) ) {
$schema['itemReviewed']['mpn'] = wp_strip_all_tags( $data['bsf-aiosrs-product-mpn'] );
}
$schema['itemReviewed']['sku'] = ! empty( $data['bsf-aiosrs-product-sku'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-product-sku'] ) : NULL;
$schema['itemReviewed']['mpn'] = ! empty( $data['bsf-aiosrs-product-mpn'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-product-mpn'] ) : NULL;
if ( isset( $data['bsf-aiosrs-product-brand-name'] ) && ! empty( $data['bsf-aiosrs-product-brand-name'] ) ) {
$schema['itemReviewed']['brand']['@type'] = 'Organization';
$schema['itemReviewed']['brand']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-product-brand-name'] );
$schema['itemReviewed']['brand']['name'] = wp_strip_all_tags( (string)$data['bsf-aiosrs-product-brand-name'] );
}
if ( ( isset( $data['bsf-aiosrs-product-rating'] ) && ! empty( $data['bsf-aiosrs-product-rating'] ) ) ||
@@ -373,66 +261,44 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Review' ) ) {
$schema['itemReviewed']['aggregateRating']['@type'] = 'AggregateRating';
if ( isset( $data['bsf-aiosrs-product-rating'] ) && ! empty( $data['bsf-aiosrs-product-rating'] ) ) {
$schema['itemReviewed']['aggregateRating']['ratingValue'] = wp_strip_all_tags( $data['bsf-aiosrs-product-rating'] );
}
if ( isset( $data['bsf-aiosrs-product-review-count'] ) && ! empty( $data['bsf-aiosrs-product-review-count'] ) ) {
$schema['itemReviewed']['aggregateRating']['reviewCount'] = wp_strip_all_tags( $data['bsf-aiosrs-product-review-count'] );
}
$schema['itemReviewed']['aggregateRating']['ratingValue'] = ! empty( $data['bsf-aiosrs-product-rating'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-product-rating'] ) : NULL;
$schema['itemReviewed']['aggregateRating']['reviewCount'] = ! empty( $data['bsf-aiosrs-product-review-count'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-product-review-count'] ) : NULL;
}
if ( apply_filters( 'wp_schema_pro_remove_product_offers', true ) ) {
$schema['itemReviewed']['offers']['@type'] = 'Offer';
$schema['itemReviewed']['offers']['price'] = '0';
if ( isset( $data['bsf-aiosrs-product-price'] ) && ! empty( $data['bsf-aiosrs-product-price'] ) ) {
$schema['itemReviewed']['offers']['price'] = wp_strip_all_tags( $data['bsf-aiosrs-product-price'] );
}
if ( isset( $data['bsf-aiosrs-product-price-valid-until'] ) && ! empty( $data['bsf-aiosrs-product-price-valid-until'] ) ) {
$schema['itemReviewed']['offers']['priceValidUntil'] = wp_strip_all_tags( $data['bsf-aiosrs-product-price-valid-until'] );
}
$schema['itemReviewed']['offers']['price'] = ! empty( $data['bsf-aiosrs-product-price'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-product-price'] ) : NULL;
$schema['itemReviewed']['offers']['priceValidUntil'] = ! empty( $data['bsf-aiosrs-product-price-valid-until'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-product-price-valid-until'] ) : NULL;
$schema['itemReviewed']['offers']['url'] = get_permalink( $post['ID'] );
if ( ( isset( $data['bsf-aiosrs-product-currency'] ) && ! empty( $data['bsf-aiosrs-product-currency'] ) ) ||
( isset( $data['bsf-aiosrs-product-avail'] ) && ! empty( $data['bsf-aiosrs-product-avail'] ) ) ) {
if ( isset( $data['bsf-aiosrs-product-currency'] ) && ! empty( $data['bsf-aiosrs-product-currency'] ) ) {
$schema['itemReviewed']['offers']['priceCurrency'] = wp_strip_all_tags( $data['bsf-aiosrs-product-currency'] );
}
if ( isset( $data['bsf-aiosrs-product-avail'] ) && ! empty( $data['bsf-aiosrs-product-avail'] ) ) {
$schema['itemReviewed']['offers']['availability'] = wp_strip_all_tags( $data['bsf-aiosrs-product-avail'] );
}
$schema['itemReviewed']['offers']['priceCurrency'] = ! empty( $data['bsf-aiosrs-product-currency'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-product-currency'] ) : NULL;
$schema['itemReviewed']['offers']['availability'] = ! empty( $data['bsf-aiosrs-product-avail'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-product-avail'] ) : NULL;
}
}
break;
case 'bsf-aiosrs-movie':
$schema['itemReviewed']['@type'] = 'Movie';
if ( isset( $data['bsf-aiosrs-movie-name'] ) && ! empty( $data['bsf-aiosrs-movie-name'] ) ) {
$schema['itemReviewed']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-movie-name'] );
}
if ( isset( $data['bsf-aiosrs-movie-same-As'] ) && ! empty( $data['bsf-aiosrs-movie-same-As'] ) ) {
$schema['itemReviewed']['sameAs'] = wp_strip_all_tags( $data['bsf-aiosrs-movie-same-As'] );
}
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-movie-name'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-movie-name'] ) : NULL;
$schema['itemReviewed']['sameAs'] = ! empty( $data['bsf-aiosrs-movie-same-As'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-movie-same-As'] ) : NULL;
if ( isset( $data['bsf-aiosrs-movie-image'] ) && ! empty( $data['bsf-aiosrs-movie-image'] ) ) {
$schema['itemReviewed']['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['bsf-aiosrs-movie-image'] );
}
if ( isset( $data['bsf-aiosrs-movie-dateCreated'] ) && ! empty( $data['bsf-aiosrs-movie-dateCreated'] ) ) {
$schema['itemReviewed']['dateCreated'] = wp_strip_all_tags( $data['bsf-aiosrs-movie-dateCreated'] );
}
$schema['itemReviewed']['dateCreated'] = ! empty( $data['bsf-aiosrs-movie-dateCreated'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-movie-dateCreated'] ) : NULL;
if ( isset( $data['bsf-aiosrs-movie-director-name'] ) && ! empty( $data['bsf-aiosrs-movie-director-name'] ) ) {
$schema['itemReviewed']['director']['@type'] = 'Person';
$schema['itemReviewed']['director']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-movie-director-name'] );
}
if ( isset( $data['bsf-aiosrs-movie-description'] ) && ! empty( $data['bsf-aiosrs-movie-description'] ) ) {
$schema['description'] = wp_strip_all_tags( $data['bsf-aiosrs-movie-description'] );
$schema['itemReviewed']['director']['name'] = wp_strip_all_tags( (string)$data['bsf-aiosrs-movie-director-name'] );
}
$schema['description'] = ! empty( $data['bsf-aiosrs-movie-description'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-movie-description'] ) : NULL;
break;
case 'bsf-aiosrs-organization':
$schema['itemReviewed']['@type'] = 'Organization';
if ( isset( $data['bsf-aiosrs-organization-name'] ) && ! empty( $data['bsf-aiosrs-organization-name'] ) ) {
$schema['itemReviewed']['name'] = wp_strip_all_tags( $data['bsf-aiosrs-organization-name'] );
}
$schema['itemReviewed']['name'] = ! empty( $data['bsf-aiosrs-organization-name'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-organization-name'] ) : NULL;
if ( ( isset( $data['bsf-aiosrs-organization-location-street'] ) && ! empty( $data['bsf-aiosrs-organization-location-street'] ) ) ||
( isset( $data['bsf-aiosrs-organization-location-locality'] ) && ! empty( $data['bsf-aiosrs-organization-location-locality'] ) ) ||
( isset( $data['bsf-aiosrs-organization-location-postal'] ) && ! empty( $data['bsf-aiosrs-organization-location-postal'] ) ) ||
@@ -441,21 +307,11 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Review' ) ) {
$schema['itemReviewed']['address']['@type'] = 'PostalAddress';
if ( isset( $data['bsf-aiosrs-organization-location-street'] ) && ! empty( $data['bsf-aiosrs-organization-location-street'] ) ) {
$schema['itemReviewed']['address']['streetAddress'] = wp_strip_all_tags( $data['bsf-aiosrs-organization-location-street'] );
}
if ( isset( $data['bsf-aiosrs-organization-location-locality'] ) && ! empty( $data['bsf-aiosrs-organization-location-locality'] ) ) {
$schema['itemReviewed']['address']['addressLocality'] = wp_strip_all_tags( $data['bsf-aiosrs-organization-location-locality'] );
}
if ( isset( $data['bsf-aiosrs-organization-location-postal'] ) && ! empty( $data['bsf-aiosrs-organization-location-postal'] ) ) {
$schema['itemReviewed']['address']['postalCode'] = wp_strip_all_tags( $data['bsf-aiosrs-organization-location-postal'] );
}
if ( isset( $data['bsf-aiosrs-organization-location-region'] ) && ! empty( $data['bsf-aiosrs-organization-location-region'] ) ) {
$schema['itemReviewed']['address']['addressRegion'] = wp_strip_all_tags( $data['bsf-aiosrs-organization-location-region'] );
}
if ( isset( $data['bsf-aiosrs-organization-location-country'] ) && ! empty( $data['bsf-aiosrs-organization-location-country'] ) ) {
$schema['itemReviewed']['address']['addressCountry'] = wp_strip_all_tags( $data['bsf-aiosrs-organization-location-country'] );
}
$schema['itemReviewed']['address']['streetAddress'] = ! empty( $data['bsf-aiosrs-organization-location-street'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-organization-location-street'] ) : NULL;
$schema['itemReviewed']['address']['addressLocality'] = ! empty( $data['bsf-aiosrs-organization-location-locality'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-organization-location-locality'] ) : NULL;
$schema['itemReviewed']['address']['postalCode'] = ! empty( $data['bsf-aiosrs-organization-location-postal'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-organization-location-postal'] ) : NULL;
$schema['itemReviewed']['address']['addressRegion'] = ! empty( $data['bsf-aiosrs-organization-location-region'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-organization-location-region'] ) : NULL;
$schema['itemReviewed']['address']['addressCountry'] = ! empty( $data['bsf-aiosrs-organization-location-country'] ) ? wp_strip_all_tags( (string)$data['bsf-aiosrs-organization-location-country'] ) : NULL;
}
break;
default:
@@ -465,21 +321,13 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Review' ) ) {
if ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) {
$schema['reviewRating']['@type'] = 'Rating';
$schema['reviewRating']['ratingValue'] = wp_strip_all_tags( $data['rating'] );
}
if ( isset( $data['review-body'] ) && ! empty( $data['review-body'] ) ) {
$schema['reviewBody'] = wp_strip_all_tags( $data['review-body'] );
}
if ( isset( $data['date'] ) && ! empty( $data['date'] ) ) {
$schema['datePublished'] = wp_strip_all_tags( $data['date'] );
}
if ( isset( $data['reviewer-type'] ) && ! empty( $data['reviewer-type'] ) ) {
$schema['author']['@type'] = wp_strip_all_tags( $data['reviewer-type'] );
} else {
$schema['author']['@type'] = 'Person';
$schema['reviewRating']['ratingValue'] = wp_strip_all_tags( (string)$data['rating'] );
}
$schema['reviewBody'] = ! empty( $data['review-body'] ) ? wp_strip_all_tags( (string)$data['review-body'] ) : NULL;
$schema['datePublished'] = ! empty( $data['date'] ) ? wp_strip_all_tags( (string)$data['date'] ) : NULL;
$schema['author']['@type'] = ! empty( $data['reviewer-type'] ) ? wp_strip_all_tags( (string)$data['reviewer-type'] ) : 'Person';
if ( isset( $data['reviewer-name'] ) && ! empty( $data['reviewer-name'] ) ) {
$schema['author']['name'] = wp_strip_all_tags( $data['reviewer-name'] );
$schema['author']['name'] = wp_strip_all_tags( (string)$data['reviewer-name'] );
$author_data = get_userdata( $post['post_author'] );
$author_name = ( isset( $author_data->user_nicename ) ) ? $author_data->user_nicename : '';
$author_url = get_author_posts_url( $post['ID'] );
@@ -489,7 +337,7 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Review' ) ) {
}
if ( isset( $data['publisher-name'] ) && ! empty( $data['publisher-name'] ) ) {
$schema['publisher']['@type'] = 'Organization';
$schema['publisher']['name'] = wp_strip_all_tags( $data['publisher-name'] );
$schema['publisher']['name'] = wp_strip_all_tags( (string)$data['publisher-name'] );
$prg_url_value = get_bloginfo( 'url' );
$schema['publisher']['sameAs'] = esc_url( $prg_url_value );
}
@@ -28,13 +28,9 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Service' ) ) {
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'Service';
if ( isset( $data['name'] ) && ! empty( $data['name'] ) ) {
$schema['name'] = wp_strip_all_tags( $data['name'] );
}
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string)$data['name'] ) : NULL;
if ( isset( $data['type'] ) && ! empty( $data['type'] ) ) {
$schema['serviceType'] = wp_strip_all_tags( $data['type'] );
}
$schema['serviceType'] = ! empty( $data['type'] ) ? wp_strip_all_tags( (string)$data['type'] ) : NULL;
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
@@ -47,18 +43,12 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Service' ) ) {
$schema['provider']['@type'] = 'LocalBusiness';
if ( isset( $data['provider'] ) && ! empty( $data['provider'] ) ) {
$schema['provider']['name'] = wp_strip_all_tags( $data['provider'] );
}
$schema['provider']['name'] = ! empty( $data['provider'] ) ? wp_strip_all_tags( (string)$data['provider'] ) : NULL;
if ( isset( $data['location-image'] ) && ! empty( $data['location-image'] ) ) {
$schema['provider']['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['location-image'] );
}
if ( isset( $data['telephone'] ) && ! empty( $data['telephone'] ) ) {
$schema['provider']['telephone'] = wp_strip_all_tags( $data['telephone'] );
}
if ( isset( $data['price-range'] ) && ! empty( $data['price-range'] ) ) {
$schema['provider']['priceRange'] = wp_strip_all_tags( $data['price-range'] );
}
$schema['provider']['telephone'] = ! empty( $data['telephone'] ) ? wp_strip_all_tags( (string)$data['telephone'] ) : NULL;
$schema['provider']['priceRange'] = ! empty( $data['price-range'] ) ? wp_strip_all_tags( (string)$data['price-range'] ) : NULL;
}
if ( ( isset( $data['location-locality'] ) && ! empty( $data['location-locality'] ) ) ||
@@ -68,25 +58,17 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Service' ) ) {
$schema['provider']['@type'] = 'LocalBusiness';
$schema['provider']['address']['@type'] = 'PostalAddress';
if ( isset( $data['location-locality'] ) && ! empty( $data['location-locality'] ) ) {
$schema['provider']['address']['addressLocality'] = wp_strip_all_tags( $data['location-locality'] );
}
if ( isset( $data['location-region'] ) && ! empty( $data['location-region'] ) ) {
$schema['provider']['address']['addressRegion'] = wp_strip_all_tags( $data['location-region'] );
}
if ( isset( $data['location-street'] ) && ! empty( $data['location-street'] ) ) {
$schema['provider']['address']['streetAddress'] = wp_strip_all_tags( $data['location-street'] );
}
$schema['provider']['address']['addressLocality'] = ! empty( $data['location-locality'] ) ? wp_strip_all_tags( (string)$data['location-locality'] ) : NULL;
$schema['provider']['address']['addressRegion'] = ! empty( $data['location-region'] ) ? wp_strip_all_tags( (string)$data['location-region'] ) : NULL;
$schema['provider']['address']['streetAddress'] = ! empty( $data['location-street'] ) ? wp_strip_all_tags( (string)$data['location-street'] ) : NULL;
}
if ( isset( $data['area'] ) && ! empty( $data['area'] ) ) {
$schema['areaServed']['@type'] = 'State';
$schema['areaServed']['name'] = wp_strip_all_tags( $data['area'] );
$schema['areaServed']['name'] = wp_strip_all_tags( (string)$data['area'] );
}
if ( isset( $data['description'] ) && ! empty( $data['description'] ) ) {
$schema['description'] = wp_strip_all_tags( $data['description'] );
}
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string)$data['description'] ) : NULL;
return apply_filters( 'wp_schema_pro_schema_service', $schema, $data, $post );
}
@@ -28,17 +28,11 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Software_Application' ) ) {
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'SoftwareApplication';
if ( isset( $data['name'] ) && ! empty( $data['name'] ) ) {
$schema['name'] = wp_strip_all_tags( $data['name'] );
}
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string)$data['name'] ) : NULL;
if ( isset( $data['operating-system'] ) && ! empty( $data['operating-system'] ) ) {
$schema['operatingSystem'] = wp_strip_all_tags( $data['operating-system'] );
}
$schema['operatingSystem'] = ! empty( $data['operating-system'] ) ? wp_strip_all_tags( (string)$data['operating-system'] ) : NULL;
if ( isset( $data['category'] ) && ! empty( $data['category'] ) ) {
$schema['applicationCategory'] = wp_strip_all_tags( $data['category'] );
}
$schema['applicationCategory'] = ! empty( $data['category'] ) ? wp_strip_all_tags( (string)$data['category'] ) : NULL;
if ( isset( $data['image'] ) && ! empty( $data['image'] ) ) {
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'] );
@@ -49,24 +43,16 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Software_Application' ) ) {
$schema['aggregateRating']['@type'] = 'AggregateRating';
if ( isset( $data['rating'] ) && ! empty( $data['rating'] ) ) {
$schema['aggregateRating']['ratingValue'] = wp_strip_all_tags( $data['rating'] );
}
if ( isset( $data['review-count'] ) && ! empty( $data['review-count'] ) ) {
$schema['aggregateRating']['reviewCount'] = wp_strip_all_tags( $data['review-count'] );
}
$schema['aggregateRating']['ratingValue'] = ! empty( $data['rating'] ) ? wp_strip_all_tags( (string)$data['rating'] ) : NULL;
$schema['aggregateRating']['reviewCount'] = ! empty( $data['review-count'] ) ? wp_strip_all_tags( (string)$data['review-count'] ) : NULL;
}
$schema['offers']['@type'] = 'Offer';
$schema['offers']['price'] = '0';
if ( isset( $data['price'] ) && ! empty( $data['price'] ) ) {
$schema['offers']['price'] = wp_strip_all_tags( $data['price'] );
}
$schema['offers']['price'] = ! empty( $data['price'] ) ? wp_strip_all_tags( (string)$data['price'] ) : NULL;
if ( isset( $data['currency'] ) && ! empty( $data['currency'] ) ) {
$schema['offers']['priceCurrency'] = wp_strip_all_tags( $data['currency'] );
}
$schema['offers']['priceCurrency'] = ! empty( $data['currency'] ) ? wp_strip_all_tags( (string)$data['currency'] ) : NULL;
return apply_filters( 'wp_schema_pro_schema_software_application', $schema, $data, $post );
}
@@ -28,17 +28,13 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Video_Object' ) ) {
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'VideoObject';
if ( isset( $data['name'] ) && ! empty( $data['name'] ) ) {
$schema['name'] = wp_strip_all_tags( $data['name'] );
}
$schema['name'] = ! empty( $data['name'] ) ? wp_strip_all_tags( (string)$data['name'] ) : NULL;
if ( isset( $data['description'] ) && ! empty( $data['description'] ) ) {
$schema['description'] = wp_strip_all_tags( $data['description'] );
}
$schema['description'] = ! empty( $data['description'] ) ? wp_strip_all_tags( (string)$data['description'] ) : NULL;
if ( isset( $data['orgnization-name'] ) && ! empty( $data['orgnization-name'] ) ) {
$schema['publisher']['@type'] = 'Organization';
$schema['publisher']['name'] = wp_strip_all_tags( $data['orgnization-name'] );
$schema['publisher']['name'] = wp_strip_all_tags( (string)$data['orgnization-name'] );
}
if ( isset( $data['site-logo'] ) && ! empty( $data['site-logo'] ) ) {
@@ -50,13 +46,9 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Video_Object' ) ) {
$schema['thumbnailUrl'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $data['image'], 'URL' );
}
if ( isset( $data['upload-date'] ) && ! empty( $data['upload-date'] ) ) {
$schema['uploadDate'] = wp_strip_all_tags( $data['upload-date'] );
}
$schema['uploadDate'] = ! empty( $data['upload-date'] ) ? wp_strip_all_tags( (string)$data['upload-date'] ) : NULL;
if ( isset( $data['duration'] ) && ! empty( $data['duration'] ) ) {
$schema['duration'] = wp_strip_all_tags( $data['duration'] );
}
$schema['duration'] = ! empty( $data['duration'] ) ? wp_strip_all_tags( (string)$data['duration'] ) : NULL;
if ( isset( $data['content-url'] ) && ! empty( $data['content-url'] ) ) {
$schema['contentUrl'] = esc_url( $data['content-url'] );
@@ -66,12 +58,12 @@ if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Video_Object' ) ) {
$schema['embedUrl'] = esc_url( $data['embed-url'] );
}
if ( isset( $data['expires-date'] ) && ! empty( $data['expires-date'] ) ) {
$schema['expires'] = wp_strip_all_tags( $data['expires-date'] );
}
$schema['expires'] = ! empty( $data['expires-date'] ) ? wp_strip_all_tags( (string)$data['expires-date'] ) : NULL;
if ( isset( $data['interaction-count'] ) && ! empty( $data['interaction-count'] ) ) {
$schema['interactionCount'] = wp_strip_all_tags( $data['interaction-count'] );
$schema['interactionStatistic']['@type'] = 'InteractionCounter';
$schema['interactionStatistic']['interactionType']['@type'] = 'WatchAction';
$schema['interactionStatistic']['userInteractionCount'] = wp_strip_all_tags( (string)$data['interaction-count'] );
}
return apply_filters( 'wp_schema_pro_schema_video_object', $schema, $data, $post );
@@ -1,81 +1,81 @@
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.1.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_About_Page' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.1.0
*/
class BSF_AIOSRS_Pro_Schema_Global_About_Page {
/**
* Render Schema.
*
* @param array $post Current Post Array.
* @return array
*/
public static function render( $post ) {
$schema = array();
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'AboutPage';
$schema['mainEntityOfPage']['@type'] = 'WebPage';
$schema['mainEntityOfPage']['@id'] = esc_url( get_permalink( $post['ID'] ) );
$schema['headline'] = wp_strip_all_tags( $post['post_title'] );
$schema['description'] = BSF_AIOSRS_Pro_Schema_Template::strip_markup( $post['post_content'] );
$image_id = get_post_thumbnail_id( $post['ID'] );
if ( ! empty( $image_id ) ) {
$thumb_image = wp_get_attachment_image_src( $image_id, 'full' );
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $thumb_image );
}
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
if ( 'person' === $settings['site-represent'] || 'personblog' === $settings['site-represent'] ) {
$settings['site-represent'] = 'person';
}
if ( 'organization' === $settings['site-represent'] || 'Webshop' === $settings['site-represent'] || 'Smallbusiness' === $settings['site-represent'] || 'Otherbusiness' === $settings['site-represent'] ) {
$settings['site-represent'] = 'organization';
}
$schema['publisher']['@type'] = ( isset( $settings['site-represent'] ) && ! empty( $settings['site-represent'] ) ) ? $settings['site-represent'] : 'Organization';
if ( 'organization' === $settings['site-represent'] ) {
$schema['publisher']['name'] = ( isset( $settings['site-name'] ) && ! empty( $settings['site-name'] ) ) ? $settings['site-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
} else {
$schema['publisher']['name'] = ( isset( $settings['person-name'] ) && ! empty( $settings['person-name'] ) ) ? $settings['person-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
}
$schema['publisher']['url'] = wp_strip_all_tags( get_bloginfo( 'url' ) );
if ( 'organization' === $settings['site-represent'] ) {
$logo_id = get_theme_mod( 'custom_logo' );
if ( isset( $settings['site-logo'] ) && 'custom' === $settings['site-logo'] ) {
$logo_id = isset( $settings['site-logo-custom'] ) ? $settings['site-logo-custom'] : '';
}
if ( $logo_id ) {
// Add logo image size.
add_filter( 'intermediate_image_sizes_advanced', 'BSF_AIOSRS_Pro_Schema_Template::logo_image_sizes', 10, 2 );
$logo_image = wp_get_attachment_image_src( $logo_id, 'aiosrs-logo-size' );
if ( isset( $logo_image[3] ) && 1 !== $logo_image[3] ) {
BSF_AIOSRS_Pro_Schema_Template::generate_logo_by_width( $logo_id );
$logo_image = wp_get_attachment_image_src( $logo_id, 'aiosrs-logo-size' );
}
// Remove logo image size.
remove_filter( 'intermediate_image_sizes_advanced', 'BSF_AIOSRS_Pro_Schema_Template::logo_image_sizes', 10, 2 );
$schema['publisher']['logo'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $logo_image, 'ImageObject' );
}
}
return apply_filters( 'wp_schema_pro_global_schema_about_page', $schema, $post );
}
}
}
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.1.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_About_Page' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.1.0
*/
class BSF_AIOSRS_Pro_Schema_Global_About_Page {
/**
* Render Schema.
*
* @param array $post Current Post Array.
* @return array
*/
public static function render( $post ) {
$schema = array();
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'AboutPage';
$schema['mainEntityOfPage']['@type'] = 'WebPage';
$schema['mainEntityOfPage']['@id'] = esc_url( get_permalink( $post['ID'] ) );
$schema['headline'] = wp_strip_all_tags( $post['post_title'] );
$schema['description'] = BSF_AIOSRS_Pro_Schema_Template::strip_markup( $post['post_content'] );
$image_id = get_post_thumbnail_id( $post['ID'] );
if ( ! empty( $image_id ) ) {
$thumb_image = wp_get_attachment_image_src( $image_id, 'full' );
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $thumb_image );
}
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
if ( 'person' === $settings['site-represent'] || 'personblog' === $settings['site-represent'] ) {
$settings['site-represent'] = 'person';
}
if ( 'organization' === $settings['site-represent'] || 'Webshop' === $settings['site-represent'] || 'Smallbusiness' === $settings['site-represent'] || 'Otherbusiness' === $settings['site-represent'] ) {
$settings['site-represent'] = 'organization';
}
$schema['publisher']['@type'] = ( isset( $settings['site-represent'] ) && ! empty( $settings['site-represent'] ) ) ? $settings['site-represent'] : 'Organization';
if ( 'organization' === $settings['site-represent'] ) {
$schema['publisher']['name'] = ( isset( $settings['site-name'] ) && ! empty( $settings['site-name'] ) ) ? $settings['site-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
} else {
$schema['publisher']['name'] = ( isset( $settings['person-name'] ) && ! empty( $settings['person-name'] ) ) ? $settings['person-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
}
$schema['publisher']['url'] = wp_strip_all_tags( get_bloginfo( 'url' ) );
if ( 'organization' === $settings['site-represent'] ) {
$logo_id = get_theme_mod( 'custom_logo' );
if ( isset( $settings['site-logo'] ) && 'custom' === $settings['site-logo'] ) {
$logo_id = isset( $settings['site-logo-custom'] ) ? $settings['site-logo-custom'] : '';
}
if ( $logo_id ) {
// Add logo image size.
add_filter( 'intermediate_image_sizes_advanced', 'BSF_AIOSRS_Pro_Schema_Template::logo_image_sizes', 10, 2 );
$logo_image = wp_get_attachment_image_src( $logo_id, 'aiosrs-logo-size' );
if ( isset( $logo_image[3] ) && 1 !== $logo_image[3] ) {
BSF_AIOSRS_Pro_Schema_Template::generate_logo_by_width( $logo_id );
$logo_image = wp_get_attachment_image_src( $logo_id, 'aiosrs-logo-size' );
}
// Remove logo image size.
remove_filter( 'intermediate_image_sizes_advanced', 'BSF_AIOSRS_Pro_Schema_Template::logo_image_sizes', 10, 2 );
$schema['publisher']['logo'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $logo_image, 'ImageObject' );
}
}
return apply_filters( 'wp_schema_pro_global_schema_about_page', $schema, $post );
}
}
}
@@ -1,42 +1,42 @@
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.1.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Breadcrumb' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.1.0
*/
class BSF_AIOSRS_Pro_Schema_Global_Breadcrumb {
/**
* Render Schema.
*
* @param array $post Current Post Array.
* @return array
*/
public static function render( $post ) {
$schema = array();
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'BreadcrumbList';
$breadcrumb_list = BSF_AIOSRS_Pro_Schema_Template::get_breadcrumb_list();
foreach ( $breadcrumb_list as $key => $breadcrumb ) {
$schema['itemListElement'][ $key ]['@type'] = 'ListItem';
$schema['itemListElement'][ $key ]['position'] = $key + 1;
$schema['itemListElement'][ $key ]['item']['@id'] = $breadcrumb['url'];
$schema['itemListElement'][ $key ]['item']['name'] = $breadcrumb['title'];
}
return apply_filters( 'wp_schema_pro_global_schema_breadcrumb', $schema, $post );
}
}
}
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.1.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Breadcrumb' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.1.0
*/
class BSF_AIOSRS_Pro_Schema_Global_Breadcrumb {
/**
* Render Schema.
*
* @param array $post Current Post Array.
* @return array
*/
public static function render( $post ) {
$schema = array();
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'BreadcrumbList';
$breadcrumb_list = BSF_AIOSRS_Pro_Schema_Template::get_breadcrumb_list();
foreach ( $breadcrumb_list as $key => $breadcrumb ) {
$schema['itemListElement'][ $key ]['@type'] = 'ListItem';
$schema['itemListElement'][ $key ]['position'] = $key + 1;
$schema['itemListElement'][ $key ]['item']['@id'] = $breadcrumb['url'];
$schema['itemListElement'][ $key ]['item']['name'] = $breadcrumb['title'];
}
return apply_filters( 'wp_schema_pro_global_schema_breadcrumb', $schema, $post );
}
}
}
@@ -1,81 +1,81 @@
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.1.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Contact_Page' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.1.0
*/
class BSF_AIOSRS_Pro_Schema_Global_Contact_Page {
/**
* Render Schema.
*
* @param array $post Current Post Array.
* @return array
*/
public static function render( $post ) {
$schema = array();
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'ContactPage';
$schema['mainEntityOfPage']['@type'] = 'WebPage';
$schema['mainEntityOfPage']['@id'] = esc_url( get_permalink( $post['ID'] ) );
$schema['headline'] = wp_strip_all_tags( $post['post_title'] );
$schema['description'] = BSF_AIOSRS_Pro_Schema_Template::strip_markup( $post['post_content'] );
$image_id = get_post_thumbnail_id( $post['ID'] );
if ( ! empty( $image_id ) ) {
$thumb_image = wp_get_attachment_image_src( $image_id, 'full' );
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $thumb_image );
}
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
if ( 'person' === $settings['site-represent'] || 'personblog' === $settings['site-represent'] ) {
$settings['site-represent'] = 'person';
}
if ( 'organization' === $settings['site-represent'] || 'Webshop' === $settings['site-represent'] || 'Smallbusiness' === $settings['site-represent'] || 'Otherbusiness' === $settings['site-represent'] ) {
$settings['site-represent'] = 'organization';
}
$schema['publisher']['@type'] = ( isset( $settings['site-represent'] ) && ! empty( $settings['site-represent'] ) ) ? $settings['site-represent'] : 'Organization';
if ( 'organization' === $settings['site-represent'] ) {
$schema['publisher']['name'] = ( isset( $settings['site-name'] ) && ! empty( $settings['site-name'] ) ) ? $settings['site-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
} else {
$schema['publisher']['name'] = ( isset( $settings['person-name'] ) && ! empty( $settings['person-name'] ) ) ? $settings['person-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
}
$schema['publisher']['url'] = wp_strip_all_tags( get_bloginfo( 'url' ) );
if ( 'organization' === $settings['site-represent'] ) {
$logo_id = get_theme_mod( 'custom_logo' );
if ( isset( $settings['site-logo'] ) && 'custom' === $settings['site-logo'] ) {
$logo_id = isset( $settings['site-logo-custom'] ) ? $settings['site-logo-custom'] : '';
}
if ( $logo_id ) {
// Add logo image size.
add_filter( 'intermediate_image_sizes_advanced', 'BSF_AIOSRS_Pro_Schema_Template::logo_image_sizes', 10, 2 );
$logo_image = wp_get_attachment_image_src( $logo_id, 'aiosrs-logo-size' );
if ( isset( $logo_image[3] ) && 1 !== $logo_image[3] ) {
BSF_AIOSRS_Pro_Schema_Template::generate_logo_by_width( $logo_id );
$logo_image = wp_get_attachment_image_src( $logo_id, 'aiosrs-logo-size' );
}
// Remove logo image size.
remove_filter( 'intermediate_image_sizes_advanced', 'BSF_AIOSRS_Pro_Schema_Template::logo_image_sizes', 10, 2 );
$schema['publisher']['logo'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $logo_image, 'ImageObject' );
}
}
return apply_filters( 'wp_schema_pro_global_schema_contact_page', $schema, $post );
}
}
}
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.1.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Contact_Page' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.1.0
*/
class BSF_AIOSRS_Pro_Schema_Global_Contact_Page {
/**
* Render Schema.
*
* @param array $post Current Post Array.
* @return array
*/
public static function render( $post ) {
$schema = array();
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'ContactPage';
$schema['mainEntityOfPage']['@type'] = 'WebPage';
$schema['mainEntityOfPage']['@id'] = esc_url( get_permalink( $post['ID'] ) );
$schema['headline'] = wp_strip_all_tags( $post['post_title'] );
$schema['description'] = BSF_AIOSRS_Pro_Schema_Template::strip_markup( $post['post_content'] );
$image_id = get_post_thumbnail_id( $post['ID'] );
if ( ! empty( $image_id ) ) {
$thumb_image = wp_get_attachment_image_src( $image_id, 'full' );
$schema['image'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $thumb_image );
}
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
if ( 'person' === $settings['site-represent'] || 'personblog' === $settings['site-represent'] ) {
$settings['site-represent'] = 'person';
}
if ( 'organization' === $settings['site-represent'] || 'Webshop' === $settings['site-represent'] || 'Smallbusiness' === $settings['site-represent'] || 'Otherbusiness' === $settings['site-represent'] ) {
$settings['site-represent'] = 'organization';
}
$schema['publisher']['@type'] = ( isset( $settings['site-represent'] ) && ! empty( $settings['site-represent'] ) ) ? $settings['site-represent'] : 'Organization';
if ( 'organization' === $settings['site-represent'] ) {
$schema['publisher']['name'] = ( isset( $settings['site-name'] ) && ! empty( $settings['site-name'] ) ) ? $settings['site-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
} else {
$schema['publisher']['name'] = ( isset( $settings['person-name'] ) && ! empty( $settings['person-name'] ) ) ? $settings['person-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
}
$schema['publisher']['url'] = wp_strip_all_tags( get_bloginfo( 'url' ) );
if ( 'organization' === $settings['site-represent'] ) {
$logo_id = get_theme_mod( 'custom_logo' );
if ( isset( $settings['site-logo'] ) && 'custom' === $settings['site-logo'] ) {
$logo_id = isset( $settings['site-logo-custom'] ) ? $settings['site-logo-custom'] : '';
}
if ( $logo_id ) {
// Add logo image size.
add_filter( 'intermediate_image_sizes_advanced', 'BSF_AIOSRS_Pro_Schema_Template::logo_image_sizes', 10, 2 );
$logo_image = wp_get_attachment_image_src( $logo_id, 'aiosrs-logo-size' );
if ( isset( $logo_image[3] ) && 1 !== $logo_image[3] ) {
BSF_AIOSRS_Pro_Schema_Template::generate_logo_by_width( $logo_id );
$logo_image = wp_get_attachment_image_src( $logo_id, 'aiosrs-logo-size' );
}
// Remove logo image size.
remove_filter( 'intermediate_image_sizes_advanced', 'BSF_AIOSRS_Pro_Schema_Template::logo_image_sizes', 10, 2 );
$schema['publisher']['logo'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $logo_image, 'ImageObject' );
}
}
return apply_filters( 'wp_schema_pro_global_schema_contact_page', $schema, $post );
}
}
}
@@ -1,110 +1,110 @@
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.1.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Organization' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.1.0
*/
class BSF_AIOSRS_Pro_Schema_Global_Organization {
/**
* Render Schema.
*
* @param array $post Current Post Array.
* @return array
*/
public static function render( $post ) {
$schema = array();
$general_settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
$social_profiles = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-social-profiles'];
$contact_type = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-corporate-contact'];
$contact_hear = isset( $contact_type['contact-hear'] ) ? $contact_type['contact-hear'] : '';
$contact_toll = isset( $contact_type['contact-toll'] ) ? $contact_type['contact-toll'] : '';
$contactpoint = array( $contact_hear, $contact_toll );
$schema['@context'] = 'https://schema.org';
$schema['@type'] = ( isset( $general_settings['organization'] ) && ! empty( $general_settings['organization'] ) ) ? $general_settings['organization'] : 'organization';
$schema['name'] = ( isset( $general_settings['site-name'] ) && ! empty( $general_settings['site-name'] ) ) ? $general_settings['site-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
$schema['url'] = wp_strip_all_tags( get_bloginfo( 'url' ) );
if ( isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) || isset( $contact_type['telephone'] ) && ! empty( $contact_type['telephone'] ) || isset( $contact_type['contact-page-id'] ) && ! empty( $contact_type['contact-page-id'] ) ) {
$schema['ContactPoint']['@type'] = 'ContactPoint';
if ( isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) ) {
if ( 'other' === $contact_type['contact-type'] ) {
$schema ['ContactPoint']['contactType'] = $contact_type['contact-type-other'];
} else {
$schema ['ContactPoint']['contactType'] = $contact_type['contact-type'];
}
}
if ( isset( $contact_type['telephone'] ) && ! empty( $contact_type['telephone'] ) ) {
$schema ['ContactPoint']['telephone'] = $contact_type['telephone'];
}
if ( isset( $contact_type['contact-page-id'] ) && ! empty( $contact_type['contact-page-id'] ) ) {
$page_url = get_permalink( $contact_type['contact-page-id'] );
$schema ['ContactPoint']['url'] = $page_url;
} else {
$schema ['ContactPoint']['url'] = $contact_type['contact-page-id'];
}
if ( isset( $contact_type['email'] ) && ! empty( $contact_type['email'] ) ) {
$schema ['ContactPoint']['email'] = $contact_type['email'];
}
if ( isset( $contactpoint ) && ! empty( $contactpoint ) ) {
$schema ['ContactPoint']['contactOption'] = $contactpoint;
}
if ( isset( $contact_type['areaServed'] ) && ! empty( $contact_type['areaServed'] ) ) {
$language = explode( ',', $contact_type['areaServed'] );
foreach ( $language as $key => $value ) {
$schema ['ContactPoint']['areaServed'][ $key ] = wp_strip_all_tags( $value );
}
}
if ( isset( $contact_type['availableLanguage'] ) && ! empty( $contact_type['availableLanguage'] ) ) {
$language = explode( ',', $contact_type['availableLanguage'] );
foreach ( $language as $key => $value ) {
$schema ['ContactPoint']['availableLanguage'][ $key ] = wp_strip_all_tags( $value );
}
} else {
$schema ['ContactPoint']['availableLanguage'] = 'English';
}
}
$logo_id = get_post_thumbnail_id( $post['ID'] );
if ( isset( $general_settings['site-logo-custom'] ) ) {
$logo_id = isset( $general_settings['site-logo-custom'] ) ? $general_settings['site-logo-custom'] : '';
} elseif ( isset( $general_settings['site-logo'] ) && 'customizer-logo' === $general_settings['site-logo'] ) {
if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) {
$logo_id = get_theme_mod( 'custom_logo' );
}
}
if ( $logo_id ) {
$key = 'site-logo';
$logo_image = BSF_AIOSRS_Pro_Schema_Template::get_image_object( $logo_id, $key );
$schema['logo'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $logo_image, 'ImageObject' );
}
foreach ( $social_profiles as $type => $social_link ) {
if ( 'other' === $type ) {
foreach ( $social_link as $dynamic_social_link ) {
if ( ! empty( $dynamic_social_link ) ) {
$schema['sameAs'][] = $dynamic_social_link;
}
}
}
if ( ! empty( $social_link ) && ( ! is_array( $social_link ) ) ) {
$schema['sameAs'][] = $social_link;
}
}
return apply_filters( 'wp_schema_pro_global_schema_organization', $schema, $post );
}
}
}
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.1.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Organization' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.1.0
*/
class BSF_AIOSRS_Pro_Schema_Global_Organization {
/**
* Render Schema.
*
* @param array $post Current Post Array.
* @return array
*/
public static function render( $post ) {
$schema = array();
$general_settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
$social_profiles = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-social-profiles'];
$contact_type = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-corporate-contact'];
$contact_hear = isset( $contact_type['contact-hear'] ) ? $contact_type['contact-hear'] : '';
$contact_toll = isset( $contact_type['contact-toll'] ) ? $contact_type['contact-toll'] : '';
$contactpoint = array( $contact_hear, $contact_toll );
$schema['@context'] = 'https://schema.org';
$schema['@type'] = ( isset( $general_settings['organization'] ) && ! empty( $general_settings['organization'] ) ) ? $general_settings['organization'] : 'organization';
$schema['name'] = ( isset( $general_settings['site-name'] ) && ! empty( $general_settings['site-name'] ) ) ? $general_settings['site-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
$schema['url'] = wp_strip_all_tags( get_bloginfo( 'url' ) );
if ( isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) || isset( $contact_type['telephone'] ) && ! empty( $contact_type['telephone'] ) || isset( $contact_type['contact-page-id'] ) && ! empty( $contact_type['contact-page-id'] ) ) {
$schema['ContactPoint']['@type'] = 'ContactPoint';
if ( isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) ) {
if ( 'other' === $contact_type['contact-type'] ) {
$schema ['ContactPoint']['contactType'] = $contact_type['contact-type-other'];
} else {
$schema ['ContactPoint']['contactType'] = $contact_type['contact-type'];
}
}
if ( isset( $contact_type['telephone'] ) && ! empty( $contact_type['telephone'] ) ) {
$schema ['ContactPoint']['telephone'] = $contact_type['telephone'];
}
if ( isset( $contact_type['contact-page-id'] ) && ! empty( $contact_type['contact-page-id'] ) ) {
$page_url = get_permalink( $contact_type['contact-page-id'] );
$schema ['ContactPoint']['url'] = $page_url;
} else {
$schema ['ContactPoint']['url'] = $contact_type['contact-page-id'];
}
if ( isset( $contact_type['email'] ) && ! empty( $contact_type['email'] ) ) {
$schema ['ContactPoint']['email'] = $contact_type['email'];
}
if ( isset( $contactpoint ) && ! empty( $contactpoint ) ) {
$schema ['ContactPoint']['contactOption'] = $contactpoint;
}
if ( isset( $contact_type['areaServed'] ) && ! empty( $contact_type['areaServed'] ) ) {
$language = explode( ',', $contact_type['areaServed'] );
foreach ( $language as $key => $value ) {
$schema ['ContactPoint']['areaServed'][ $key ] = wp_strip_all_tags( $value );
}
}
if ( isset( $contact_type['availableLanguage'] ) && ! empty( $contact_type['availableLanguage'] ) ) {
$language = explode( ',', $contact_type['availableLanguage'] );
foreach ( $language as $key => $value ) {
$schema ['ContactPoint']['availableLanguage'][ $key ] = wp_strip_all_tags( $value );
}
} else {
$schema ['ContactPoint']['availableLanguage'] = 'English';
}
}
$logo_id = get_post_thumbnail_id( $post['ID'] );
if ( isset( $general_settings['site-logo-custom'] ) ) {
$logo_id = isset( $general_settings['site-logo-custom'] ) ? $general_settings['site-logo-custom'] : '';
} elseif ( isset( $general_settings['site-logo'] ) && 'customizer-logo' === $general_settings['site-logo'] ) {
if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) {
$logo_id = get_theme_mod( 'custom_logo' );
}
}
if ( $logo_id ) {
$key = 'site-logo';
$logo_image = BSF_AIOSRS_Pro_Schema_Template::get_image_object( $logo_id, $key );
$schema['logo'] = BSF_AIOSRS_Pro_Schema_Template::get_image_schema( $logo_image, 'ImageObject' );
}
foreach ( $social_profiles as $type => $social_link ) {
if ( 'other' === $type ) {
foreach ( $social_link as $dynamic_social_link ) {
if ( ! empty( $dynamic_social_link ) ) {
$schema['sameAs'][] = $dynamic_social_link;
}
}
}
if ( ! empty( $social_link ) && ( ! is_array( $social_link ) ) ) {
$schema['sameAs'][] = $social_link;
}
}
return apply_filters( 'wp_schema_pro_global_schema_organization', $schema, $post );
}
}
}
@@ -1,71 +1,71 @@
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.1.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Person' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.1.0
*/
class BSF_AIOSRS_Pro_Schema_Global_Person {
/**
* Render Schema.
*
* @param array $post Current Post Array.
* @return array
*/
public static function render( $post ) {
$schema = array();
$general_settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
$social_profiles = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-social-profiles'];
$contact_type = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-corporate-contact'];
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'Person';
$schema['name'] = ( isset( $general_settings['person-name'] ) && ! empty( $general_settings['person-name'] ) ) ? $general_settings['person-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
$schema['url'] = wp_strip_all_tags( get_bloginfo( 'url' ) );
if ( isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) || isset( $contact_type['telephone'] ) && ! empty( $contact_type['telephone'] ) || isset( $contact_type['contact-page-id'] ) && ! empty( $contact_type['contact-page-id'] ) ) {
$schema['ContactPoint']['@type'] = 'ContactPoint';
if ( isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) ) {
if ( 'other' === $contact_type['contact-type'] ) {
$schema ['ContactPoint']['contactType'] = $contact_type['contact-type-other'];
} else {
$schema ['ContactPoint']['contactType'] = $contact_type['contact-type'];
}
}
if ( isset( $contact_type['telephone'] ) && ! empty( $contact_type['telephone'] ) ) {
$schema ['ContactPoint']['telephone'] = $contact_type['telephone'];
}
if ( isset( $contact_type['contact-page-id'] ) && ! empty( $contact_type['contact-page-id'] ) ) {
$page_url = get_permalink( $contact_type['contact-page-id'] );
$schema ['ContactPoint']['url'] = $page_url;
} else {
$schema ['ContactPoint']['url'] = $contact_type['contact-page-id'];
}
}
foreach ( $social_profiles as $type => $social_link ) {
if ( 'other' === $type ) {
foreach ( $social_link as $dynamic_social_link ) {
if ( ! empty( $dynamic_social_link ) ) {
$schema['sameAs'][] = $dynamic_social_link;
}
}
} else {
if ( ! empty( $social_link ) && ( ! is_array( $social_link ) ) ) {
$schema['sameAs'][] = $social_link;
}
}
}
return apply_filters( 'wp_schema_pro_global_schema_person', $schema, $post );
}
}
}
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.1.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Person' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.1.0
*/
class BSF_AIOSRS_Pro_Schema_Global_Person {
/**
* Render Schema.
*
* @param array $post Current Post Array.
* @return array
*/
public static function render( $post ) {
$schema = array();
$general_settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
$social_profiles = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-social-profiles'];
$contact_type = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-corporate-contact'];
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'Person';
$schema['name'] = ( isset( $general_settings['person-name'] ) && ! empty( $general_settings['person-name'] ) ) ? $general_settings['person-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
$schema['url'] = wp_strip_all_tags( get_bloginfo( 'url' ) );
if ( isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) || isset( $contact_type['telephone'] ) && ! empty( $contact_type['telephone'] ) || isset( $contact_type['contact-page-id'] ) && ! empty( $contact_type['contact-page-id'] ) ) {
$schema['ContactPoint']['@type'] = 'ContactPoint';
if ( isset( $contact_type['contact-type'] ) && ! empty( $contact_type['contact-type'] ) ) {
if ( 'other' === $contact_type['contact-type'] ) {
$schema ['ContactPoint']['contactType'] = $contact_type['contact-type-other'];
} else {
$schema ['ContactPoint']['contactType'] = $contact_type['contact-type'];
}
}
if ( isset( $contact_type['telephone'] ) && ! empty( $contact_type['telephone'] ) ) {
$schema ['ContactPoint']['telephone'] = $contact_type['telephone'];
}
if ( isset( $contact_type['contact-page-id'] ) && ! empty( $contact_type['contact-page-id'] ) ) {
$page_url = get_permalink( $contact_type['contact-page-id'] );
$schema ['ContactPoint']['url'] = $page_url;
} else {
$schema ['ContactPoint']['url'] = $contact_type['contact-page-id'];
}
}
foreach ( $social_profiles as $type => $social_link ) {
if ( 'other' === $type ) {
foreach ( $social_link as $dynamic_social_link ) {
if ( ! empty( $dynamic_social_link ) ) {
$schema['sameAs'][] = $dynamic_social_link;
}
}
} else {
if ( ! empty( $social_link ) && ( ! is_array( $social_link ) ) ) {
$schema['sameAs'][] = $social_link;
}
}
}
return apply_filters( 'wp_schema_pro_global_schema_person', $schema, $post );
}
}
}
@@ -1,70 +1,70 @@
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.1.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Site_Navigation_Element' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.1.0
*/
class BSF_AIOSRS_Pro_Schema_Global_Site_Navigation_Element {
/**
* Render Schema.
*
* @param array $post Current Post Array.
* @return array
*/
public static function render( $post ) {
$schema = array();
$names = array();
$urls = array();
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-global-schemas'];
if ( isset( $settings['site-navigation-element'] ) && ! empty( $settings['site-navigation-element'] ) ) {
$navigation_links = wp_get_nav_menu_items( $settings['site-navigation-element'] );
if ( $navigation_links ) {
foreach ( $navigation_links as $link ) {
$names[] = wp_strip_all_tags( $link->title );
$urls[] = esc_url( $link->url );
}
}
}
/**
* Convert normal array into associative array
*/
$combine_array = array_combine( $names, $urls );
$new_arr[] = array();
$j = 0;
foreach ( $combine_array as $key => $value ) {
$new_arr[ $j ]['name'] = $key;
$new_arr[ $j ]['url'] = $value;
$j++;
}
$schema['@context'] = 'https://schema.org';
if ( isset( $new_arr ) && ! empty( $new_arr ) ) {
foreach ( $new_arr as $key2 => $value2 ) {
$schema['@graph'][ $key2 ]['@context'] = 'https://schema.org';
$schema['@graph'][ $key2 ]['@type'] = 'SiteNavigationElement';
$schema['@graph'][ $key2 ]['id'] = 'site-navigation';
$schema['@graph'][ $key2 ]['name'] = isset( $value2['name'] ) ? $value2['name'] : '';
$schema['@graph'][ $key2 ]['url'] = isset( $value2['url'] ) ? $value2['url'] : '';
}
}
return apply_filters( 'wp_schema_pro_global_schema_site_navigation_element', $schema, $post );
}
}
}
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.1.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Site_Navigation_Element' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.1.0
*/
class BSF_AIOSRS_Pro_Schema_Global_Site_Navigation_Element {
/**
* Render Schema.
*
* @param array $post Current Post Array.
* @return array
*/
public static function render( $post ) {
$schema = array();
$names = array();
$urls = array();
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-global-schemas'];
if ( isset( $settings['site-navigation-element'] ) && ! empty( $settings['site-navigation-element'] ) ) {
$navigation_links = wp_get_nav_menu_items( $settings['site-navigation-element'] );
if ( $navigation_links ) {
foreach ( $navigation_links as $link ) {
$names[] = wp_strip_all_tags( $link->title );
$urls[] = esc_url( $link->url );
}
}
}
/**
* Convert normal array into associative array
*/
$combine_array = array_combine( $names, $urls );
$new_arr[] = array();
$j = 0;
foreach ( $combine_array as $key => $value ) {
$new_arr[ $j ]['name'] = $key;
$new_arr[ $j ]['url'] = $value;
$j++;
}
$schema['@context'] = 'https://schema.org';
if ( isset( $new_arr ) && ! empty( $new_arr ) ) {
foreach ( $new_arr as $key2 => $value2 ) {
$schema['@graph'][ $key2 ]['@context'] = 'https://schema.org';
$schema['@graph'][ $key2 ]['@type'] = 'SiteNavigationElement';
$schema['@graph'][ $key2 ]['id'] = 'site-navigation';
$schema['@graph'][ $key2 ]['name'] = isset( $value2['name'] ) ? $value2['name'] : '';
$schema['@graph'][ $key2 ]['url'] = isset( $value2['url'] ) ? $value2['url'] : '';
}
}
return apply_filters( 'wp_schema_pro_global_schema_site_navigation_element', $schema, $post );
}
}
}
@@ -1,50 +1,50 @@
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.1.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Sitelink_Search_Box' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.1.0
*/
class BSF_AIOSRS_Pro_Schema_Global_Sitelink_Search_Box {
/**
* Render Schema.
*
* @param array $post Current Post Array.
* @return array
*/
public static function render( $post ) {
$schema = array();
$general_settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'WebSite';
$schema['name'] = ( isset( $general_settings['site-name'] ) && ! empty( $general_settings['site-name'] ) ) ? $general_settings['site-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
$schema['url'] = home_url();
$potential_action = array();
$template_urls = apply_filters( 'wp_schema_pro_sitelink_srearch_box_template_urls', array( site_url( '?s=' ) ) );
foreach ( $template_urls as $template_url ) {
$potential_action[] = array(
'@type' => 'SearchAction',
'target' => esc_url( $template_url ) . '{search_term_string}',
'query-input' => 'required name=search_term_string',
);
}
$schema['potentialAction'] = $potential_action;
return apply_filters( 'wp_schema_pro_global_schema_sitelink_search_box', $schema, $post );
}
}
}
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.1.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Global_Sitelink_Search_Box' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.1.0
*/
class BSF_AIOSRS_Pro_Schema_Global_Sitelink_Search_Box {
/**
* Render Schema.
*
* @param array $post Current Post Array.
* @return array
*/
public static function render( $post ) {
$schema = array();
$general_settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
$schema['@context'] = 'https://schema.org';
$schema['@type'] = 'WebSite';
$schema['name'] = ( isset( $general_settings['site-name'] ) && ! empty( $general_settings['site-name'] ) ) ? $general_settings['site-name'] : wp_strip_all_tags( get_bloginfo( 'name' ) );
$schema['url'] = home_url();
$potential_action = array();
$template_urls = apply_filters( 'wp_schema_pro_sitelink_srearch_box_template_urls', array( site_url( '?s=' ) ) );
foreach ( $template_urls as $template_url ) {
$potential_action[] = array(
'@type' => 'SearchAction',
'target' => esc_url( $template_url ) . '{search_term_string}',
'query-input' => 'required name=search_term_string',
);
}
$schema['potentialAction'] = $potential_action;
return apply_filters( 'wp_schema_pro_global_schema_sitelink_search_box', $schema, $post );
}
}
}
+1 -1
View File
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '0f9d4becdd85904cbbb5aeb7938b31c9');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '6f0debba0e036f55eb1407af3830bf1c');
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
(window.webpackJsonp_wp_schema_pro=window.webpackJsonp_wp_schema_pro||[]).push([[3],{79:function(e,t,n){"use strict";n.r(t);var o=n(0),c=n(2),s=n(3),p=n.n(s),r=n(1);t.default=p.a.memo((function(){return Object(o.createElement)(c.InspectorControls,null,(function(){return Object(o.createElement)("p",{className:"wpsp-settings-notice"},Object(r.__)("For the styling options please select the parent block from the Block Navigation."))}))}))}}]);
(window.webpackJsonp_wp_schema_pro=window.webpackJsonp_wp_schema_pro||[]).push([[3],{74:function(e,t,n){"use strict";n.r(t);var o=n(0),c=n(2),s=n(3),p=n.n(s),r=n(1);t.default=p.a.memo((function(){return Object(o.createElement)(c.InspectorControls,null,(function(){return Object(o.createElement)("p",{className:"wpsp-settings-notice"},Object(r.__)("For the styling options please select the parent block from the Block Navigation."))}))}))}}]);
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,14 +1,14 @@
# Copyright (C) 2022 Brainstorm Force
# Copyright (C) 2023 Brainstorm Force
# This file is distributed under the GPL2.
msgid ""
msgstr ""
"Project-Id-Version: Schema Pro 2.7.4\n"
"Project-Id-Version: Schema Pro 2.7.9\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-schema-pro\n"
"POT-Creation-Date: 2022-12-05 09:36:01+00:00\n"
"POT-Creation-Date: 2023-06-27 10:13:11+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2022-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: 2023-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: en\n"
@@ -143,23 +143,23 @@ msgstr ""
msgid "(0 Reviews)"
msgstr ""
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:245
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:249
#: classes/class-bsf-aiosrs-pro-schema.php:1058
msgid "Applicant Location"
msgstr ""
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:249
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:253
#: classes/class-bsf-aiosrs-pro-schema.php:1062
msgid ""
"The geographic location(s) in which employees may be located to be eligible "
"for the Remote job."
msgstr ""
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:793
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:797
msgid "Reset"
msgstr ""
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:809
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:813
#: classes/class-bsf-aiosrs-pro-markup.php:153
#: classes/class-bsf-aiosrs-pro-markup.php:299
#. translators: 1: number of reviews
@@ -168,18 +168,18 @@ msgid_plural "(%1s Reviews)"
msgstr[0] ""
msgstr[1] ""
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:846
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:850
#: classes/class-bsf-aiosrs-pro-schema.php:3689
#: classes/class-bsf-aiosrs-pro-setup-wizard.php:311 template/settings.php:93
#: template/wpsp-advanced-settings.php:127
msgid "Select Image"
msgstr ""
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:861
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:865
msgid "Add your snippet here..."
msgstr ""
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:914
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:918
msgid "By clicking on this, it will allow you to fill advanced data."
msgstr ""
@@ -2363,7 +2363,7 @@ msgid "AudioBook"
msgstr ""
#: classes/class-bsf-aiosrs-pro-schema.php:3848
#: classes/lib/class-bsf-custom-post-list-table.php:369
#: classes/lib/class-bsf-custom-post-list-table.php:377
msgid "Scheduled"
msgstr ""
@@ -4622,12 +4622,12 @@ msgid "No %s found"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:150
#: classes/lib/class-bsf-custom-post-list-table.php:259
#: classes/lib/class-bsf-custom-post-list-table.php:267
msgid "Restore"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:151
#: classes/lib/class-bsf-custom-post-list-table.php:276
#: classes/lib/class-bsf-custom-post-list-table.php:284
msgid "Delete Permanently"
msgstr ""
@@ -4640,84 +4640,84 @@ msgstr ""
msgid "Draft"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:247
#: classes/lib/class-bsf-custom-post-list-table.php:255
#. translators: %s: post title
msgid "Edit &#8220;%s&#8221;"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:248
#: classes/lib/class-bsf-custom-post-list-table.php:256
msgid "Edit"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:258
#. translators: %s: post title
msgid "Restore &#8220;%s&#8221; from the Trash"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:266
#. translators: %s: post title
msgid "Restore &#8220;%s&#8221; from the Trash"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:274
#. translators: %s: post title
msgid "Move &#8220;%s&#8221; to the Trash"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:275
#: classes/lib/class-bsf-custom-post-list-table.php:283
#. translators: %s: post title
msgid "Delete &#8220;%s&#8221; permanently"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:289
#: classes/lib/class-bsf-custom-post-list-table.php:297
#. translators: %s: post title
msgid "Preview &#8220;%s&#8221;"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:290
#: classes/lib/class-bsf-custom-post-list-table.php:298
msgid "Preview"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:298
#: classes/lib/class-bsf-custom-post-list-table.php:306
#. translators: %s: post title
msgid "View &#8220;%s&#8221;"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:299
#: classes/lib/class-bsf-custom-post-list-table.php:307
msgid "View"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:345
#: classes/lib/class-bsf-custom-post-list-table.php:346
#: classes/lib/class-bsf-custom-post-list-table.php:353
#: classes/lib/class-bsf-custom-post-list-table.php:354
msgid "Unpublished"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:349
#: classes/lib/class-bsf-custom-post-list-table.php:357
msgid "Y/m/d g:i:s a"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:357
#: classes/lib/class-bsf-custom-post-list-table.php:365
#. translators: 1: time
msgid "%s ago"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:359
#: classes/lib/class-bsf-custom-post-list-table.php:367
msgid "Y/m/d"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:364
#: classes/lib/class-bsf-custom-post-list-table.php:372
msgid "Published"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:367
#: classes/lib/class-bsf-custom-post-list-table.php:375
msgid "Missed schedule"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:372
#: classes/lib/class-bsf-custom-post-list-table.php:380
msgid "Last Modified"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:575
#: classes/lib/class-bsf-custom-post-list-table.php:583
#. translators: %s: search keywords
msgid "Search results for &#8220;%s&#8221;"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:593
#: classes/lib/class-bsf-custom-post-list-table.php:601
#. translators: %s: Post Label
msgid "Search %s"
msgstr ""
@@ -4918,6 +4918,11 @@ msgstr ""
msgid "Visit Knowledge Base"
msgstr ""
#: template/branding-settings.php:176 template/breadcrumb-settings.php:227
#: template/settings.php:623 template/wpsp-advanced-settings.php:305
msgid "Rollback Version"
msgstr ""
#: template/breadcrumb-settings.php:22
msgid "Configure Breadcrumbs"
msgstr ""
@@ -5309,7 +5314,7 @@ msgctxt "rating out of"
msgid "0/5"
msgstr ""
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:800
#: classes/class-bsf-aiosrs-pro-custom-fields-markup.php:804
#: classes/class-bsf-aiosrs-pro-markup.php:129
#: classes/class-bsf-aiosrs-pro-markup.php:148
#: classes/class-bsf-aiosrs-pro-markup.php:290
@@ -5328,12 +5333,12 @@ msgctxt "aiosrs-schemas singular name"
msgid "Schema"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:267
#: classes/lib/class-bsf-custom-post-list-table.php:275
msgctxt "verb"
msgid "Trash"
msgstr ""
#: classes/lib/class-bsf-custom-post-list-table.php:521
#: classes/lib/class-bsf-custom-post-list-table.php:529
#. translators: %s: count
msgctxt "posts"
msgid "All <span class=\"count\">(%s)</span>"
@@ -155,7 +155,7 @@ $setting_url = self::get_page_url( 'branding-settings' );
</div>
</div>
</div>
<div id="side-sortables" style="">
<div id="side-sortables" style="min-height: 0px;">
<div class="postbox">
<h2 class="hndle"><span><?php esc_html_e( 'Knowledge Base', 'wp-schema-pro' ); ?></span></h2>
<div class="inside">
@@ -168,6 +168,21 @@ $setting_url = self::get_page_url( 'branding-settings' );
</div>
</div>
</div>
<?php
if ( bsf_display_rollback_version_form( 'wp-schema-pro' ) ) {
?>
<div id="side-sortables" style="">
<div class="postbox">
<h2 class="hndle"><span><?php esc_html_e( 'Rollback Version', 'wp-schema-pro' ); ?></span></h2>
<div class="inside">
<?php
$product_id = 'wp-schema-pro';
bsf_get_version_rollback_form( $product_id );
?>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
@@ -205,7 +205,7 @@ $setting_url = self::get_page_url( 'breadcrumb-settings' );
</div>
</div>
<?php if ( 'disabled' === $sp_hide_label ) { ?>
<div id="side-sortables" style="">
<div id="side-sortables" style="min-height: 0px;">
<div class="postbox">
<h2 class="hndle"><span><?php esc_html_e( 'Knowledge Base', 'wp-schema-pro' ); ?></span></h2>
<div class="inside">
@@ -219,6 +219,21 @@ $setting_url = self::get_page_url( 'breadcrumb-settings' );
</div>
</div>
<?php } ?>
<?php
if ( bsf_display_rollback_version_form( 'wp-schema-pro' ) ) {
?>
<div id="side-sortables" style="">
<div class="postbox">
<h2 class="hndle"><span><?php esc_html_e( 'Rollback Version', 'wp-schema-pro' ); ?></span></h2>
<div class="inside">
<?php
$product_id = 'wp-schema-pro';
bsf_get_version_rollback_form( $product_id );
?>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
@@ -148,7 +148,7 @@ $current_section = isset( $_GET['section'] ) ? $_GET['section'] : 'genera
?>
</p>
</td>
</tr>
</tr>
<tr>
<th colspan="2">
<input type="submit" class="button-primary" value="<?php esc_html_e( 'Save Changes', 'wp-schema-pro' ); ?>" />
@@ -183,7 +183,7 @@ $current_section = isset( $_GET['section'] ) ? $_GET['section'] : 'genera
<form method="post" action="options.php">
<?php settings_fields( 'wp-schema-pro-social-profiles-group' ); ?>
<?php do_settings_sections( 'wp-schema-pro-social-profiles-group' ); ?>
<?php do_settings_sections( 'wp-schema-pro-social-profiles-group' ); ?>
<table id="repeatable-fieldset-one" class="form-table">
<tr>
<th><?php esc_html_e( 'Facebook', 'wp-schema-pro' ); ?></th>
@@ -228,7 +228,7 @@ $current_section = isset( $_GET['section'] ) ? $_GET['section'] : 'genera
<tr style="display:none">
<th><?php esc_html_e( 'Google+', 'wp-schema-pro' ); ?></th>
<td><input type="url" name="wp-schema-pro-social-profiles[google-plus]" value="<?php echo esc_attr( $settings['google-plus'] ); ?>" placeholder="<?php echo esc_attr( 'Enter URL' ); ?>" /></td>
</tr>
</tr>
<?php
if ( isset( $settings ) && ! empty( $settings ) && isset( $settings['other'] ) ) {
foreach ( $settings['other'] as $sub_social_profiles => $value ) {
@@ -255,7 +255,7 @@ $current_section = isset( $_GET['section'] ) ? $_GET['section'] : 'genera
<input type="submit" class="button-primary" value="<?php esc_html_e( 'Save Changes', 'wp-schema-pro' ); ?>" />
</th>
</tr>
</table>
</table>
</form>
</div>
</div>
@@ -308,7 +308,7 @@ $current_section = isset( $_GET['section'] ) ? $_GET['section'] : 'genera
<th><?php esc_html_e( 'Other Contact Type ', 'wp-schema-pro' ); ?>
</th>
<td><input type="text" name="wp-schema-pro-corporate-contact[contact-type-other]" value="<?php echo esc_attr( $contact_settings['contact-type-other'] ); ?>" /></td>
</tr>
</tr>
<tr>
<th><?php esc_html_e( 'Contact Page URL', 'wp-schema-pro' ); ?>
</th>
@@ -380,10 +380,10 @@ $current_section = isset( $_GET['section'] ) ? $_GET['section'] : 'genera
<input type="checkbox" name="wp-schema-pro-corporate-contact[cp-schema-type]" <?php checked( '1', $contact_settings ['cp-schema-type'] ); ?> value="1" /> <?php esc_html_e( 'Yes', 'wp-schema-pro' ); ?>
</label>
</td>
</tr>
</tr>
</tbody>
</table>
<table class="form-table .contact-form">
</table>
<table class="form-table .contact-form">
<tr>
<th colspan="2">
@@ -601,7 +601,7 @@ $current_section = isset( $_GET['section'] ) ? $_GET['section'] : 'genera
</div>
</div>
<?php if ( 'disabled' === $sp_hide_label ) { ?>
<div id="side-sortables" style="">
<div id="side-sortables" style="min-height: 0px;">
<div class="postbox">
<h2 class="hndle"><span><?php esc_html_e( 'Knowledge Base', 'wp-schema-pro' ); ?></span></h2>
<div class="inside">
@@ -615,6 +615,21 @@ $current_section = isset( $_GET['section'] ) ? $_GET['section'] : 'genera
</div>
</div>
<?php } ?>
<?php
if ( bsf_display_rollback_version_form( 'wp-schema-pro' ) ) {
?>
<div id="side-sortables" style="">
<div class="postbox">
<h2 class="hndle"><span><?php esc_html_e( 'Rollback Version', 'wp-schema-pro' ); ?></span></h2>
<div class="inside">
<?php
$product_id = 'wp-schema-pro';
bsf_get_version_rollback_form( $product_id );
?>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
@@ -27,7 +27,7 @@ $current_section = isset( $_GET['section'] ) ? $_GET['section'] : 'general';
<div id="poststuff">
<div id="post-body" class="columns-2">
<div id="post-body-content">
<!-- Plugin Settings -->
<!-- Plugin Settings -->
<div class="postbox wp-schema-pro-advanced-settings" >
<h2 class="hndle">
<span><?php esc_html_e( 'Plugin Settings', 'wp-schema-pro' ); ?></span>
@@ -283,7 +283,7 @@ $current_section = isset( $_GET['section'] ) ? $_GET['section'] : 'general';
</div>
</div>
<?php if ( 'disabled' === $sp_hide_label ) { ?>
<div id="side-sortables" style="">
<div id="side-sortables" style="min-height: 0px;">
<div class="postbox">
<h2 class="hndle"><span><?php esc_html_e( 'Knowledge Base', 'wp-schema-pro' ); ?></span></h2>
<div class="inside">
@@ -297,6 +297,21 @@ $current_section = isset( $_GET['section'] ) ? $_GET['section'] : 'general';
</div>
</div>
<?php } ?>
<?php
if ( bsf_display_rollback_version_form( 'wp-schema-pro' ) ) {
?>
<div id="side-sortables" style="">
<div class="postbox">
<h2 class="hndle"><span><?php esc_html_e( 'Rollback Version', 'wp-schema-pro' ); ?></span></h2>
<div class="inside">
<?php
$product_id = 'wp-schema-pro';
bsf_get_version_rollback_form( $product_id );
?>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
@@ -5,7 +5,7 @@
* Author: Brainstorm Force
* Author URI: https://www.brainstormforce.com
* Description: Schema Pro is the go-to plugin to adding Schema Markup on your website with ease. Enables you to display rich snippets on search engines and improve your overall page SEO.
* Version: 2.7.4
* Version: 2.7.9
* Text Domain: wp-schema-pro
* License: GPL2
*
@@ -70,7 +70,7 @@ define( 'BSF_AIOSRS_PRO_FILE', __FILE__ );
define( 'BSF_AIOSRS_PRO_BASE', plugin_basename( BSF_AIOSRS_PRO_FILE ) );
define( 'BSF_AIOSRS_PRO_DIR', plugin_dir_path( BSF_AIOSRS_PRO_FILE ) );
define( 'BSF_AIOSRS_PRO_URI', plugins_url( '/', BSF_AIOSRS_PRO_FILE ) );
define( 'BSF_AIOSRS_PRO_VER', '2.7.4' );
define( 'BSF_AIOSRS_PRO_VER', '2.7.9' );
define( 'BSF_AIOSRS_PRO_CACHE_KEY', 'wp_schema_pro_optimized_structured_data' );
define( 'BSF_AIOSRS_PRO_WEBSITE_URL', 'https://wpschema.com/' );
@@ -1 +1 @@
function WPSPslideUp(e,t){e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.boxSizing="border-box",e.style.height=e.offsetHeight+"px",e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,window.setTimeout(function(){e.style.display="none",e.style.removeProperty("height"),e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")},t)}function WPSPslideDown(e,t){e.style.removeProperty("display");let s=window.getComputedStyle(e).display;"none"===s&&(s="block"),e.style.display=s;var a=e.offsetHeight;e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,e.style.boxSizing="border-box",e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.height=a+"px",e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),window.setTimeout(function(){e.style.removeProperty("height"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")},t)}function setupFAQ(){const e=new RegExp("^[\\w\\-]+$");var t=window.location.hash.substring(1);const s=document.getElementsByClassName("wpsp-faq-expand-first-true"),a=document.getElementsByClassName("wpsp-faq-inactive-other-false");if(void 0!==document.getElementById(t)&&null!==document.getElementById(t)&&""!==document.getElementById(t)&&e.test(t)){const o=document.getElementById(t);void 0!==o.getElementsByClassName("wpsp-faq-item")[0]&&(o.getElementsByClassName("wpsp-faq-item")[0].classList.add("wpsp-faq-item-active"),o.getElementsByClassName("wpsp-faq-item")[0].setAttribute("aria-expanded",!0),WPSPslideDown(o.getElementsByClassName("wpsp-faq-content")[0],500))}else for(let e=0;e<s.length;e++)!0===s[e].classList.contains("wpsp-faq-layout-accordion")&&(s[e].querySelectorAll(".wpsp-faq-child__outer-wrap")[0].getElementsByClassName("wpsp-faq-item")[0].classList.add("wpsp-faq-item-active"),s[e].querySelectorAll(".wpsp-faq-child__outer-wrap")[0].getElementsByClassName("wpsp-faq-item")[0].setAttribute("aria-expanded",!0),s[e].querySelectorAll(".wpsp-faq-child__outer-wrap")[0].getElementsByClassName("wpsp-faq-item")[0].querySelectorAll(".wpsp-faq-content")[0].style.display="block");for(let e=0;e<a.length;e++)if(!0===a[e].classList.contains("wpsp-faq-layout-accordion")){const l=a[e].querySelectorAll(".wpsp-faq-child__outer-wrap");for(let e=0;e<l.length;e++)l[e].getElementsByClassName("wpsp-faq-item")[0].classList.add("wpsp-faq-item-active"),l[e].getElementsByClassName("wpsp-faq-item")[0].setAttribute("aria-expanded",!0),l[e].getElementsByClassName("wpsp-faq-item")[0].querySelectorAll(".wpsp-faq-content")[0].style.display="block"}}function WPSPfaqClick(t,s){if("A"!==t.target.tagName)if(t.preventDefault(),s.classList.contains("wpsp-faq-item-active"))s.classList.remove("wpsp-faq-item-active"),s.setAttribute("aria-expanded",!1),WPSPslideUp(s.getElementsByClassName("wpsp-faq-content")[0],500);else{const o=t.currentTarget.closest(".wp-block-wpsp-faq");let e="true";if(o.classList.contains("wp-block-wpsp-faq")&&(e=o.getAttribute("data-faqtoggle")),s.classList.add("wpsp-faq-item-active"),s.setAttribute("aria-expanded",!0),WPSPslideDown(s.getElementsByClassName("wpsp-faq-content")[0],500),"true"===e){var a=o.querySelectorAll(".wpsp-faq-questions-button");for(let e=0;e<a.length;e++){const l=a[e].parentElement;l!==s&&(l.classList.remove("wpsp-faq-item-active"),l.setAttribute("aria-expanded",!1),WPSPslideUp(l.getElementsByClassName("wpsp-faq-content")[0],500))}}}}window.addEventListener("load",function(){setupFAQ();const t=document.getElementsByClassName("wpsp-faq-layout-accordion");for(let e=0;e<t.length;e++){const s=t[e].querySelectorAll(".wpsp-faq-questions-button");for(let e=0;e<s.length;e++)s[e].parentElement.addEventListener("click",function(e){WPSPfaqClick(e,this)}),s[e].parentElement.addEventListener("keypress",function(e){WPSPfaqClick(e,this)})}});
function WPSPslideUp(e,t){e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.boxSizing="border-box",e.style.height=e.offsetHeight+"px",e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,window.setTimeout(function(){e.style.display="none",e.style.removeProperty("height"),e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")},t)}function WPSPslideDown(e,t){e.style.removeProperty("display");let s=window.getComputedStyle(e).display;"none"===s&&(s="block"),e.style.display=s;var a=e.offsetHeight;e.style.overflow="hidden",e.style.height=0,e.style.paddingTop=0,e.style.paddingBottom=0,e.style.marginTop=0,e.style.marginBottom=0,e.style.boxSizing="border-box",e.style.transitionProperty="height, margin, padding",e.style.transitionDuration=t+"ms",e.style.height=a+"px",e.style.removeProperty("padding-top"),e.style.removeProperty("padding-bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),window.setTimeout(function(){e.style.removeProperty("height"),e.style.removeProperty("overflow"),e.style.removeProperty("transition-duration"),e.style.removeProperty("transition-property")},t)}function setupFAQ(){var e=new RegExp("^[\\w\\-]+$"),t=window.location.hash.substring(1),s=document.getElementsByClassName("wpsp-faq-expand-first-true"),a=document.getElementsByClassName("wpsp-faq-inactive-other-false");if(void 0!==document.getElementById(t)&&null!==document.getElementById(t)&&""!==document.getElementById(t)&&e.test(t)){e=document.getElementById(t);void 0!==e.getElementsByClassName("wpsp-faq-item")[0]&&(e.getElementsByClassName("wpsp-faq-item")[0].classList.add("wpsp-faq-item-active"),e.getElementsByClassName("wpsp-faq-item")[0].setAttribute("aria-expanded",!0),WPSPslideDown(e.getElementsByClassName("wpsp-faq-content")[0],500))}else for(let e=0;e<s.length;e++)!0===s[e].classList.contains("wpsp-faq-layout-accordion")&&(s[e].querySelectorAll(".wpsp-faq-child__outer-wrap")[0].getElementsByClassName("wpsp-faq-item")[0].classList.add("wpsp-faq-item-active"),s[e].querySelectorAll(".wpsp-faq-child__outer-wrap")[0].getElementsByClassName("wpsp-faq-item")[0].setAttribute("aria-expanded",!0),s[e].querySelectorAll(".wpsp-faq-child__outer-wrap")[0].getElementsByClassName("wpsp-faq-item")[0].querySelectorAll(".wpsp-faq-content")[0].style.display="block");for(let e=0;e<a.length;e++)if(!0===a[e].classList.contains("wpsp-faq-layout-accordion")){var o=a[e].querySelectorAll(".wpsp-faq-child__outer-wrap");for(let e=0;e<o.length;e++)o[e].getElementsByClassName("wpsp-faq-item")[0].classList.add("wpsp-faq-item-active"),o[e].getElementsByClassName("wpsp-faq-item")[0].setAttribute("aria-expanded",!0),o[e].getElementsByClassName("wpsp-faq-item")[0].querySelectorAll(".wpsp-faq-content")[0].style.display="block"}}function WPSPfaqClick(t,s){if("A"!==t.target.tagName)if(t.preventDefault(),s.classList.contains("wpsp-faq-item-active"))s.classList.remove("wpsp-faq-item-active"),s.setAttribute("aria-expanded",!1),WPSPslideUp(s.getElementsByClassName("wpsp-faq-content")[0],500);else{t=t.currentTarget.closest(".wp-block-wpsp-faq");let e="true";if(t.classList.contains("wp-block-wpsp-faq")&&(e=t.getAttribute("data-faqtoggle")),s.classList.add("wpsp-faq-item-active"),s.setAttribute("aria-expanded",!0),WPSPslideDown(s.getElementsByClassName("wpsp-faq-content")[0],500),"true"===e){var a=t.querySelectorAll(".wpsp-faq-questions-button");for(let e=0;e<a.length;e++){var o=a[e].parentElement;o!==s&&(o.classList.remove("wpsp-faq-item-active"),o.setAttribute("aria-expanded",!1),WPSPslideUp(o.getElementsByClassName("wpsp-faq-content")[0],500))}}}}window.addEventListener("load",function(){setupFAQ();var t=document.getElementsByClassName("wpsp-faq-layout-accordion");for(let e=0;e<t.length;e++){var s=t[e].querySelectorAll(".wpsp-faq-questions-button");for(let e=0;e<s.length;e++)s[e].parentElement.addEventListener("click",function(e){WPSPfaqClick(e,this)}),s[e].parentElement.addEventListener("keypress",function(e){WPSPfaqClick(e,this)})}});