plugin updates

This commit is contained in:
Tony Volpe
2024-06-17 15:33:26 -04:00
parent 3751a5a1a6
commit e4e274a9a7
2674 changed files with 0 additions and 507851 deletions

View File

@@ -1,172 +0,0 @@
/* ========================================================================
* 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;
}
}

View File

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

View File

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

View File

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

View File

@@ -1,11 +0,0 @@
<?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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -1,32 +0,0 @@
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;
});

View File

@@ -1,105 +0,0 @@
(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);

View File

@@ -1,263 +0,0 @@
/* ========================================================================
* 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);

File diff suppressed because one or more lines are too long

View File

@@ -1,151 +0,0 @@
(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);

View File

@@ -1,16 +0,0 @@
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');
});
});

View File

@@ -1,61 +0,0 @@
(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 );

View File

@@ -1,413 +0,0 @@
<?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 ) );
}
}

View File

@@ -1,239 +0,0 @@
<?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 );
}
}
}

View File

@@ -1,2 +0,0 @@
/* Do not change otherwise you won't get updates */
ID:[bsf-core]

View File

@@ -1,18 +0,0 @@
### 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.

View File

@@ -1,449 +0,0 @@
<?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 );
}

View File

@@ -1,896 +0,0 @@
<?php
/**
* BSF License manager class file.
*
* @package bsf-core
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'BSF_License_Manager' ) ) {
/**
* Class BSF_License_Manager
*/
class BSF_License_Manager {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance = null;
/**
* Inline form products.
*
* @access private
* @var $inline_form_products Inline form products.
*/
private static $inline_form_products = array();
/**
* Instance.
*/
public static function instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Initiator
*/
public function __construct() {
add_action( 'admin_head', array( $this, 'admin_css' ), 100 );
add_action( 'admin_init', array( $this, 'bsf_activate_license' ) );
add_action( 'admin_init', array( $this, 'bsf_deactivate_license' ) );
add_action( 'bsf_product_update_registered', array( $this, 'refresh_products_on_license_activae' ) );
add_action( 'admin_footer', array( $this, 'render_popup_form_markup' ) );
$this->includes();
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
}
/**
* Refresh products on License activation.
*/
public function refresh_products_on_license_activae() {
update_site_option( 'bsf_force_check_extensions', true );
}
/**
* Includes.
*/
public function includes() {
require_once BSF_UPDATER_PATH . '/class-bsf-envato-activate.php';
}
/**
* Admin CSS.
*/
public function admin_css() {
?>
<style type="text/css">
.bsf-pre {
white-space: normal;
}
/* license consent */
.bsf-license-consent-container {
display: flex;
}
.bsf-license-consent-container label {
padding-top: 0;
}
.wp-admin p.bsf-license-consent-container input {
margin-top: 2px;
margin-right: 10px;
}
</style>
<?php
}
/**
* BSF Deactivate license.
*/
public function bsf_deactivate_license() {
if ( ! isset( $_POST['bsf_deactivate_license'] ) ) {
return;
}
if ( ! isset( $_POST['bsf_graupi_nonce'] ) || ( isset( $_POST['bsf_graupi_nonce'] ) && ! wp_verify_nonce( $_POST['bsf_graupi_nonce'], 'bsf_license_activation_deactivation_nonce' ) ) ) {
return;
}
if ( ! isset( $_POST['bsf_license_manager']['license_key'] ) || empty( $_POST['bsf_license_manager']['license_key'] ) ) {
return;
}
if ( ! isset( $_POST['bsf_license_manager']['product_id'] ) || empty( $_POST['bsf_license_manager']['product_id'] ) ) {
return;
}
$product_id = esc_attr( $_POST['bsf_license_manager']['product_id'] );
$license_key = $this->bsf_get_product_info( $product_id, 'purchase_key' );
// Check if the key is from EDD.
$is_edd = $this->is_edd( $license_key );
$path = bsf_get_api_url() . '?referer=deactivate-' . $product_id;
// Using Brainstorm API v2.
$data = array(
'action' => 'bsf_deactivate_license',
'purchase_key' => $license_key,
'product_id' => $product_id,
'site_url' => get_site_url(),
'is_edd' => $is_edd,
'referer' => 'customer',
);
$data = apply_filters( 'bsf_deactivate_license_args', $data );
$response = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '15',
)
);
if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
$result = json_decode( wp_remote_retrieve_body( $response ), true );
if ( isset( $result['success'] ) && ( true === $result['success'] || 'true' === $result['success'] ) ) {
// update license saus to the product.
$_POST['bsf_license_deactivation']['success'] = $result['success'];
$_POST['bsf_license_deactivation']['message'] = $result['message'];
unset( $result['success'] );
unset( $result['message'] );
$this->bsf_update_product_info( $product_id, $result );
do_action( 'bsf_deactivate_license_' . $product_id . '_after_success', $result, $response, $_POST );
} else {
$_POST['bsf_license_deactivation']['success'] = $result['success'];
$_POST['bsf_license_deactivation']['message'] = $result['message'];
}
} else {
// If there is an error, the status will not be changed. hence it's true.
$_POST['bsf_license_activation']['success'] = true;
$_POST['bsf_license_activation']['message'] = 'There was an error when connecting to our license API - <pre class="bsf-pre">' . $response->get_error_message() . '</pre>';
}
// Delete license key status transient.
delete_transient( $product_id . '_license_status' );
}
/**
* BSF Activate license.
*/
public function bsf_activate_license() {
if ( ! isset( $_POST['bsf_activate_license'] ) ) {
return;
}
if ( ! isset( $_POST['bsf_graupi_nonce'] ) || ( isset( $_POST['bsf_graupi_nonce'] ) && ! wp_verify_nonce( $_POST['bsf_graupi_nonce'], 'bsf_license_activation_deactivation_nonce' ) ) ) {
return;
}
if ( ! isset( $_POST['bsf_license_manager']['license_key'] ) || empty( $_POST['bsf_license_manager']['license_key'] ) ) {
return;
}
if ( ! isset( $_POST['bsf_license_manager']['product_id'] ) || empty( $_POST['bsf_license_manager']['product_id'] ) ) {
return;
}
$post_data = $_POST['bsf_license_manager'];
$_POST['bsf_license_activation'] = $this->bsf_process_license_activation( $post_data );
}
/**
* BSF Activate license processing.
*
* @param Array $post_data Post data.
*/
public function bsf_process_license_activation( $post_data ) {
$license_key = esc_attr( $post_data['license_key'] );
$product_id = esc_attr( $post_data['product_id'] );
$user_name = isset( $post_data['user_name'] ) ? esc_attr( $post_data['user_name'] ) : '';
$user_email = isset( $post_data['user_email'] ) ? esc_attr( $post_data['user_email'] ) : '';
$privacy_consent = ( isset( $post_data['privacy_consent'] ) && 'true' === $post_data['privacy_consent'] ) ? true : false;
$terms_conditions_consent = ( isset( $post_data['terms_conditions_consent'] ) && 'true' === $post_data['terms_conditions_consent'] ) ? true : false;
// Check if the key is from EDD.
$is_edd = $this->is_edd( $license_key );
// Server side check if the license key is valid.
$path = bsf_get_api_url() . '?referer=activate-' . $product_id;
// Using Brainstorm API v2.
$data = array(
'action' => 'bsf_activate_license',
'purchase_key' => $license_key,
'product_id' => $product_id,
'user_name' => $user_name,
'user_email' => $user_email,
'privacy_consent' => $privacy_consent,
'terms_conditions_consent' => $terms_conditions_consent,
'site_url' => get_site_url(),
'is_edd' => $is_edd,
'referer' => 'customer',
);
$data = apply_filters( 'bsf_activate_license_args', $data );
$response = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '15',
)
);
$res = array();
if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
$result = json_decode( wp_remote_retrieve_body( $response ), true );
if ( isset( $result['success'] ) && ( true === $result['success'] || 'true' === $result['success'] ) ) {
// update license saus to the product.
$res['success'] = $result['success'];
$res['message'] = $result['message'];
unset( $result['success'] );
// Update product key.
$result['purchase_key'] = $license_key;
$this->bsf_update_product_info( $product_id, $result );
do_action( 'bsf_activate_license_' . $product_id . '_after_success', $result, $response, $post_data );
} else {
$res['success'] = $result['success'];
$res['message'] = $result['message'];
}
} else {
$res['success'] = false;
$res['message'] = 'There was an error when connecting to our license API - <pre class="bsf-pre">' . $response->get_error_message() . '</pre>';
}
// Delete license key status transient.
delete_transient( $product_id . '_license_status' );
return $res;
}
/**
* Is EDD.
*
* @param string $license_key License key.
*/
public function is_edd( $license_key ) {
// Purchase key length for EDD is 32 characters.
if ( strlen( $license_key ) === 32 ) {
return true;
}
return false;
}
/**
* BSF Update product Info.
*
* @param int $product_id Product ID.
* @param array $args Arguments.
*/
public function bsf_update_product_info( $product_id, $args ) {
$brainstrom_products = get_option( 'brainstrom_products', array() );
foreach ( $brainstrom_products as $type => $products ) {
foreach ( $products as $id => $product ) {
if ( $id == $product_id ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
foreach ( $args as $key => $value ) {
$brainstrom_products[ $type ][ $id ][ $key ] = $value;
do_action( "bsf_product_update_{$value}", $product_id, $value );
}
}
}
}
update_option( 'brainstrom_products', $brainstrom_products );
}
/**
* BSF is active license.
*
* @param int $product_id Product ID.
*/
public static function bsf_is_active_license( $product_id ) {
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstorm_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$brainstorm_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
$all_products = $brainstorm_plugins + $brainstorm_themes;
// If a product is marked as free, it is considered as active.
$is_free = self::is_product_free( $product_id );
if ( 'true' === $is_free || true === $is_free ) {
return true;
}
$is_bundled = BSF_Update_Manager::bsf_is_product_bundled( $product_id );
// The product is not bundled.
if ( isset( $all_products[ $product_id ] ) ) {
if ( isset( $all_products[ $product_id ]['status'] ) && 'registered' === $all_products[ $product_id ]['status'] ) {
// If the purchase key is empty, Return false.
if ( ! isset( $all_products[ $product_id ]['purchase_key'] ) ) {
return false;
}
// Check if license is active on API.
if ( false === self::instance()->get_remote_license_status( $all_products[ $product_id ]['purchase_key'], $product_id ) ) {
return false;
}
return true;
}
}
// The product is bundled.
if ( ! empty( $is_bundled ) ) {
// If the bundled product does not require to activate the license then treat the license is active.
$product = get_brainstorm_product( $product_id );
if ( isset( $product['licence_require'] ) && 'false' === $product['licence_require'] ) {
return true;
}
foreach ( $is_bundled as $key => $value ) {
$product_id = $value;
if ( isset( $all_products[ $product_id ] ) ) {
if ( isset( $all_products[ $product_id ]['status'] ) && 'registered' === $all_products[ $product_id ]['status'] ) {
// If the purchase key is empty, Return false.
if ( ! isset( $all_products[ $product_id ]['purchase_key'] ) ) {
return false;
}
// Check if license is active on API.
if ( false === self::instance()->get_remote_license_status( $all_products[ $product_id ]['purchase_key'], $product_id ) ) {
return false;
}
return true;
}
}
}
}
// By default Return false.
return false;
}
/**
* Get remote license status.
*
* @param string $purchase_key Purchase Key.
* @param int $product_id Product ID.
*/
public function get_remote_license_status( $purchase_key, $product_id ) {
$transient_key = $product_id . '_license_status';
// Check if license status is cached.
if ( false !== get_transient( $transient_key ) ) {
return (bool) get_transient( $transient_key );
}
// Set default license to license status stored in the database.
$license_status = $this->bsf_get_product_info( $product_id, 'status' );
if ( 'registered' === $license_status ) {
$license_status = '1';
} else {
$license_status = '0';
}
$path = bsf_get_api_url() . '?referer=license-status-' . $product_id;
// Using Brainstorm API v2.
$data = array(
'action' => 'bsf_license_status',
'purchase_key' => $purchase_key,
'site_url' => get_site_url(),
);
$data = apply_filters( 'bsf_license_status_args', $data );
$response = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '10',
)
);
// Try to make a second request to unsecure URL.
if ( is_wp_error( $response ) && wp_remote_retrieve_response_code( $response ) !== 200 ) {
$path = bsf_get_api_url( true ) . '?referer=license-status-' . $product_id;
$response = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '8',
)
);
}
if ( ! is_wp_error( $response ) && wp_remote_retrieve_response_code( $response ) === 200 ) {
$response_body = json_decode( wp_remote_retrieve_body( $response ), true );
// Check if status received from API is true.
if ( isset( $response_body['status'] ) && true === $response_body['status'] ) {
$license_status = '1';
} else {
$license_status = '0';
}
}
// Save license status in transient which will expire in 6 hours.
set_transient( $transient_key, $license_status, 6 * HOUR_IN_SECONDS );
return (bool) $license_status;
}
/**
* Is product free.
*
* @param int $product_id Product ID.
*/
public static function is_product_free( $product_id ) {
$license_manager = self::instance();
$is_free = $license_manager->bsf_get_product_info( $product_id, 'is_product_free' );
return $is_free;
}
/**
* Get product info.
*
* @param int $product_id Product ID.
* @param string $key Key.
*/
public function bsf_get_product_info( $product_id, $key ) {
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstorm_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$brainstorm_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
$all_products = $brainstorm_plugins + $brainstorm_themes;
if ( isset( $all_products[ $product_id ][ $key ] ) && ! empty( $all_products[ $product_id ][ $key ] ) ) {
return $all_products[ $product_id ][ $key ];
}
}
/**
* For Popup License form check `popup_license_form` is `true`.
*
* @param array $args Arguments.
*/
public function license_activation_form( $args ) {
$html = '';
$product_id = ( isset( $args['product_id'] ) && ! is_null( $args['product_id'] ) ) ? $args['product_id'] : '';
// bail out if product id is missing.
if ( empty( $product_id ) ) {
esc_html_e( 'Product id is missing.', 'bsf' );
return;
}
$popup_license_form = ( isset( $args['popup_license_form'] ) ) ? $args['popup_license_form'] : false;
$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'] ) ) ? $args['button_text_activate'] : __( 'Activate License', '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..';
$placeholder_name = ( isset( $args['placeholder_name'] ) && ! is_null( $args['placeholder_name'] ) ) ? $args['placeholder_name'] : 'Your Name..';
$placeholder_email = ( isset( $args['placeholder_email'] ) && ! is_null( $args['placeholder_email'] ) ) ? $args['placeholder_email'] : 'Your Email..';
$bsf_license_allow_email = ( isset( $args['bsf_license_allow_email'] ) && ! is_null( $args['bsf_license_allow_email'] ) ) ? $args['bsf_license_allow_email'] : true;
$license_form_title = ( isset( $args['license_form_title'] ) && ! is_null( $args['license_form_title'] ) ) ? $args['license_form_title'] : 'Updates & Support Registration - ';
$is_active = self::bsf_is_active_license( $product_id );
$license_key = $this->bsf_get_product_info( $product_id, 'purchase_key' );
if ( true === $bsf_license_allow_email || 'true' === $bsf_license_allow_email ) {
$form_class .= ' license-form-allow-email ';
if ( ! $is_active ) {
$button_text_activate = 'Sign Up & Activate';
$submit_button_class .= ' button-primary button-hero ';
}
}
// Forcefully disable the subscribe options for uabb.
// This should be disabled from uabb and removed from graupi.
if ( 'uabb' === $product_id ) {
$bsf_license_allow_email = false;
}
$purchase_url = $this->bsf_get_product_info( $product_id, 'purchase_url' );
$product_name = apply_filters( "agency_updater_productname_{$product_id}", $this->bsf_get_product_info( $product_id, 'name' ) );
if ( empty( $product_name ) ) {
$product_name = apply_filters( "agency_updater_productname_{$product_id}", $this->bsf_get_product_info( $product_id, 'product_name' ) );
}
// License activation messages.
$current_status = '';
$current_message = '';
if ( isset( $_POST['bsf_license_activation']['success'] ) && isset( $_POST['bsf_license_manager']['product_id'] ) && $product_id === $_POST['bsf_license_manager']['product_id'] ) { // phpcs:ignore:WordPress.Security.NonceVerification.Missing
$current_status = esc_attr( $_POST['bsf_license_activation']['success'] );// phpcs:ignore:WordPress.Security.NonceVerification.Missing
if ( true === $current_status || 'true' === $current_status || '1' === $current_status ) {
$current_status = 'bsf-current-license-success bsf-current-license-success-' . $product_id;
$is_active = true;
} else {
$current_status = 'bsf-current-license-error bsf-current-license-error-' . $product_id;
$is_active = false;
}
}
if ( isset( $_POST['bsf_license_activation']['message'] ) ) { // phpcs:ignore:WordPress.Security.NonceVerification.Missing
$current_message = wp_kses_post( $_POST['bsf_license_activation']['message'] );// phpcs:ignore:WordPress.Security.NonceVerification.Missing
}
$license_status = 'Active!';
$license_status_class = 'bsf-license-active-' . $product_id;
$html .= '<div class="bsf-license-key-registration">';
// License not active message.
$form_heading_status = '';
if ( false === $is_active || 'false' === $is_active ) {
$license_status = 'Not Active!';
$license_status_class = 'bsf-license-not-active-' . $product_id;
$not_activate = '';
$html .= apply_filters( "bsf_license_not_activate_message_{$product_id}", $not_activate, $license_status_class, $license_not_activate_message );
if ( true === $bsf_license_allow_email || 'true' === $bsf_license_allow_email ) {
$popup_license_subtitle = apply_filters( "bsf_license_key_form_inactive_subtitle_{$product_id}", sprintf( '<p>%s</p>', __( 'Click on the button below to activate your license and subscribe to our newsletter.', 'bsf' ) ) );
} else {
$popup_license_subtitle = apply_filters( "bsf_license_key_form_inactive_subtitle_{$product_id}", sprintf( '<p>%s</p>', __( 'Enter your purchase key and activate automatic updates.', 'bsf' ) ) );
}
} else {
$form_class .= " form-submited-{$product_id}";
$popup_license_subtitle = apply_filters( "bsf_license_key_form_active_subtitle_{$product_id}", '' );
}
do_action( "bsf_before_license_activation_form_{$product_id}" );
$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 ( $popup_license_form ) {
$form_heading = '<h3 class="' . $license_status_class . ' ' . $license_form_heading_class . '">' . $product_name . '</h3>';
$form_heading .= $popup_license_subtitle;
} else {
$form_heading = '<h3 class="' . $license_status_class . ' ' . $license_form_heading_class . '">' . $license_form_title . '<span>' . $license_status . '</span></h3>';
}
$html .= apply_filters( "bsf_license_form_heading_{$product_id}", $form_heading, $license_status_class, $license_status );
if ( ! empty( $current_status ) && ! empty( $current_message ) ) {
$current_message = '<span class="' . $current_status . '">' . $current_message . '</span>';
$html .= apply_filters( "bsf_license_current_message_{$product_id}", $current_message );
}
if ( true === $is_active || 'true' === $is_active ) {
$licnse_active_message = __( 'Your license is active.', 'bsf' );
$licnse_active_message = apply_filters( 'bsf_license_active_message', $licnse_active_message );
$html .= '<span class="license-form-field">';
$html .= '<input type="text" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="bsf_license_manager[license_key]" value="' . esc_attr( $licnse_active_message ) . '"/>';
$html .= '</span>';
$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 ) ) . '"/>';
do_action( "bsf_before_license_activation_submit_button_{$product_id}" );
$html .= '<input type="submit" class="button ' . $submit_button_class . '" name="bsf_deactivate_license" value="' . esc_attr( $button_text_deactivate ) . '"/>';
} else {
if ( true === $bsf_license_allow_email || 'true' === $bsf_license_allow_email ) {
$html .= '<span class="license-form-field">';
$html .= '<h4>Your Name</h4>';
$html .= '<input type="text" class="' . $size . '-text" id="bsf_license_manager[user_name]" name="bsf_license_manager[user_name]" value=""/>';
$html .= '</span>';
$html .= '<span class="license-form-field">';
$html .= '<h4>Your Email Address</h4>';
$html .= '<input type="email" class="' . $size . '-text" id="bsf_license_manager[user_email]" name="bsf_license_manager[user_email]" value=""/>';
$html .= '</span>';
$html .= '<span class="license-form-field">';
$html .= '<h4>Your License Key</h4>';
$html .= '<input type="text" class="' . $size . '-text" id="bsf_license_manager[license_key]" name="bsf_license_manager[license_key]" value="" autocomplete="off" required/>';
$html .= '</span>';
$html .= '<span class="license-form-field">';
$html .= '</span>';
} else {
$html .= '<span class="license-form-field">';
$html .= '<input type="text" placeholder="' . esc_attr( $placeholder ) . '" class="' . $size . '-text" id="bsf_license_manager[license_key]" name="bsf_license_manager[license_key]" value="" autocomplete="off"/>';
$html .= '</span>';
}
$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 ) ) . '"/>';
do_action( "bsf_before_license_activation_submit_button_{$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="submit" class="button ' . $submit_button_class . '" name="bsf_activate_license" value="' . esc_attr( $button_text_activate ) . '"/>';
if ( true === $bsf_license_allow_email || 'true' === $bsf_license_allow_email ) {
$get_license_message = "<p class='purchase-license'><a target='_blank' href='$purchase_url'>Purchase License »</a></p>";
} else {
$get_license_message = "<p>If you don't have a license, you can <a target='_blank' href='$purchase_url'>get it here »</a></p>";
}
$html .= apply_filters( "bsf_get_license_message_{$product_id}", $get_license_message, $purchase_url );
$html .= '</div>';
}
$html .= '</form>';
do_action( "bsf_after_license_activation_form_{$product_id}" );
$html = apply_filters( 'bsf_inlne_license_envato_after_form', $html, $product_id );
$html .= '</div> <!-- envato-license-registration -->';
if ( isset( $_GET['debug'] ) ) { // phpcs:ignore:WordPress.Security.NonceVerification.Recommended
$html .= get_bsf_systeminfo();
}
// Output the license activation/deactivation form.
return apply_filters( "bsf_core_license_activation_form_{$product_id}", $html, $args );
}
/**
* Load Scripts
*
* @since 1.0.0
*
* @param string $hook Current Hook.
* @return void
*/
public function load_scripts( $hook = '' ) {
if ( 'plugins.php' === $hook ) {
wp_register_script( 'bsf-core-jquery-history', bsf_core_url( '/assets/js/jquery-history.js' ), array( 'jquery' ), BSF_UPDATER_VERSION, true );
wp_enqueue_style( 'bsf-core-license-form', bsf_core_url( '/assets/css/license-form-popup.css' ), array(), BSF_UPDATER_VERSION, 'all' );
wp_enqueue_script( 'bsf-core-license-form', bsf_core_url( '/assets/js/license-form-popup.js' ), array( 'jquery', 'bsf-core-jquery-history' ), BSF_UPDATER_VERSION, true );
}
}
/**
* Get BSF inline license form.
*
* @param array $links Links.
* @param array $args Arguments.
* @param string $license_from_type license form type.
*/
public function get_bsf_inline_license_form( $links, $args, $license_from_type ) {
$product_id = $args['product_id'];
if ( ! isset( $product_id ) ) {
return $links;
}
if ( is_multisite() && ! is_network_admin() && false === apply_filters( "bsf_core_popup_license_form_per_network_site_{$product_id}", false ) ) {
return $links;
}
$status = 'inactive';
$license_string = __( 'Activate License', 'bsf-core' );
if ( self::bsf_is_active_license( $product_id ) ) {
$status = 'active';
$license_string = __( 'License', 'bsf-core' );
}
$product_id = $args['product_id'];
// Render the license form only once on a page.
if ( array_key_exists( $product_id, self::$inline_form_products ) ) {
return $links;
}
$form_args = array(
'product_id' => $product_id,
'button_text_activate' => esc_html__( 'Activate License', 'bsf-core' ),
'button_text_deactivate' => esc_html__( 'Deactivate License', 'bsf-core' ),
'license_form_title' => '',
'license_deactivate_status' => esc_html__( 'Your license is not active!', 'bsf-core' ),
'license_activate_status' => esc_html__( 'Your license is activated!', 'bsf-core' ),
'submit_button_class' => 'bsf-product-license button-default',
'form_class' => 'form-wrap bsf-license-register-' . esc_attr( $product_id ),
'bsf_license_form_heading_class' => 'bsf-license-heading',
'bsf_license_active_class' => 'success-message',
'bsf_license_not_activate_message' => 'license-error',
'size' => 'regular',
'bsf_license_allow_email' => false,
'popup_license_form' => ( isset( $args['popup_license_form'] ) ) ? $args['popup_license_form'] : false,
'license_from_type' => $license_from_type,
);
$form_args = wp_parse_args( $args, $form_args );
self::$inline_form_products[ $product_id ] = $form_args;
$action_links = array(
'license' => '<a plugin-slug="' . esc_attr( $product_id ) . '" class="bsf-core-plugin-link bsf-core-license-form-btn ' . esc_attr( $status ) . '" aria-label="' . esc_attr( $license_string ) . '">' . esc_html( $license_string ) . '</a>',
);
return array_merge( $links, $action_links );
}
/**
* Render the markup for popup form.
*/
public function render_popup_form_markup() {
$current_screen = get_current_screen();
// Bail if not on plugins.php screen.
if ( ! is_object( $current_screen ) && null === $current_screen ) {
return;
}
if ( 'plugins' !== $current_screen->id && 'plugins-network' !== $current_screen->id ) {
return;
}
foreach ( self::$inline_form_products as $product_id => $product ) {
?>
<div plugin-slug="<?php echo esc_attr( $product_id ); ?>" class="bsf-core-license-form" style="display: none;">
<div class="bsf-core-license-form-overlay"></div>
<div class="bsf-core-license-form-inner">
<button type="button" class="bsf-core-license-form-close-btn">
<span class="screen-reader-text"><?php esc_html_e( 'Close', 'bsf-core' ); ?></span>
<span class="dashicons dashicons-no-alt"></span>
</button>
<?php
$licence_form_method = isset( $_GET['license-form-method'] ) ? sanitize_text_field( $_GET['license-form-method'] ) : ''; // phpcs:ignore:WordPress.Security.NonceVerification.Recommended
$allowed_html = array(
'a' => array(
'href' => array(),
'title' => array(),
'target' => array(),
),
'br' => array(),
'em' => array(),
'strong' => array(),
'div' => array(
'class' => array(),
'id' => array(),
),
'span' => array(
'class' => array(),
'id' => array(),
),
'input' => array(
'class' => array(),
'id' => array(),
'type' => array(),
'name' => array(),
'value' => array(),
'autocomplete' => array(),
),
'p' => array(
'class' => array(),
),
'h1' => array(),
'h2' => array(),
'h3' => array(),
'h4' => array(),
'h5' => array(),
'h6' => array(),
'i' => array(),
'form' => array(
'method' => array(),
'action' => array(),
'class' => array(),
'id' => array(),
),
);
if ( 'edd' === $product['license_from_type'] || 'license-key' === $licence_form_method ) {
echo wp_kses( bsf_license_activation_form( $product ), $allowed_html );
} elseif ( 'envato' === $product['license_from_type'] || 'oauth' === $licence_form_method ) {
echo wp_kses( bsf_envato_register( $product ), $allowed_html );
}
do_action( "bsf_inlne_license_form_footer_{$product[ 'license_from_type' ]}", $product_id );
do_action( 'bsf_inlne_license_form_footer', $product_id );
// Avoid rendering the markup twice as admin_footer can be called multiple times.
unset( self::$inline_form_products[ $product_id ] );
?>
</div>
</div>
<?php
}
}
} // Class BSF_License_Manager
new BSF_License_Manager();
}
/**
* BSF License activation form.
*
* @param array $args Arguments.
*/
function bsf_license_activation_form( $args ) {
$license_manager = BSF_License_Manager::instance();
return $license_manager->license_activation_form( $args );
}
/**
* Get BSF inline license form.
*
* @param array $links Links.
* @param array $bsf_product_id BSF Product ID.
* @param string $license_from_type license form type.
*/
function get_bsf_inline_license_form( $links, $bsf_product_id, $license_from_type ) {
$license_manager = BSF_License_Manager::instance();
return $license_manager->get_bsf_inline_license_form( $links, $bsf_product_id, $license_from_type );
}

View File

@@ -1,180 +0,0 @@
<?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 );
}

View File

@@ -1,720 +0,0 @@
<?php
/**
* BSF Analytics Stats
*
* @package BSF_Core
*/
/**
* Delete these transients/options for debugging
* set_site_transient( 'update_plugins', null );
* set_site_transient( 'update_themes', null );
* delete_option( 'brainstrom_products' );
*/
if ( ! class_exists( 'BSF_Update_Manager' ) ) {
/**
* Update Manager Class
*
* @class BSF_Update_Manager
*/
class BSF_Update_Manager {
/**
* Constructor function that initializes required sections
*/
public function __construct() {
// update data to WordPress's transient.
add_filter(
'pre_set_site_transient_update_plugins',
array(
$this,
'brainstorm_update_plugins_transient',
)
);
add_filter( 'pre_set_site_transient_update_themes', array( $this, 'brainstorm_update_themes_transient' ) );
// display changelog in update details.
add_filter( 'plugins_api', array( $this, 'bsf_get_plugin_information' ), 10, 3 );
// display correct error messages.
add_action( 'load-plugins.php', array( $this, 'bsf_update_display_license_link' ) );
add_filter( 'upgrader_pre_download', array( $this, 'modify_download_package_message' ), 20, 3 );
add_action( 'bsf_get_plugin_information', array( $this, 'plugin_information' ) );
}
/**
* Function to update plugin's transient.
*
* @param obj $_transient_data Transient Data.
* @return $_transient_data.
*/
public function brainstorm_update_plugins_transient( $_transient_data ) {
global $pagenow;
if ( ! is_object( $_transient_data ) ) {
$_transient_data = new stdClass();
}
$update_data = $this->bsf_update_transient_data( 'plugins' );
foreach ( $update_data as $key => $product ) {
if ( isset( $product['template'] ) && '' !== $product['template'] ) {
$template = $product['template'];
} elseif ( isset( $product['init'] ) && '' !== $product['init'] ) {
$template = $product['init'];
}
if ( isset( $_transient_data->response[ $template ] ) ) {
continue;
}
if ( false === $this->enable_auto_updates( $product['id'] ) ) {
continue;
}
$plugin = new stdClass();
$plugin->id = isset( $product['id'] ) ? $product['id'] : '';
$plugin->slug = $this->bsf_get_plugin_slug( $template );
$plugin->plugin = isset( $template ) ? $template : '';
$plugin->upgrade_notice = '';
if ( $this->use_beta_version( $plugin->id ) ) {
$plugin->new_version = isset( $product['version_beta'] ) ? $product['version_beta'] : '';
$plugin->upgrade_notice .= 'It is recommended to use the beta version on a staging enviornment only.';
} else {
$plugin->new_version = isset( $product['remote'] ) ? $product['remote'] : '';
}
$plugin->url = isset( $product['purchase_url'] ) ? $product['purchase_url'] : '';
if ( BSF_License_Manager::bsf_is_active_license( $product['id'] ) === true ) {
$plugin->package = $this->bsf_get_package_uri( $product['id'] );
} else {
$plugin->package = '';
$bundled = self::bsf_is_product_bundled( $plugin->id );
if ( ! empty( $bundled ) ) {
$parent_id = $bundled[0];
$parent_name = brainstrom_product_name( $parent_id );
$plugin->upgrade_notice = 'This plugin is came bundled with the ' . $parent_name . '. For receiving updates, you need to register license of ' . $parent_name . '.';
} else {
$plugin->upgrade_notice .= ' Please activate your license to receive automatic updates.';
}
}
$plugin->tested = isset( $product['tested'] ) ? $product['tested'] : '';
$plugin->requires_php = isset( $product['php_version'] ) ? $product['php_version'] : '';
$plugin->icons = apply_filters(
"bsf_product_icons_{$product['id']}",
array(
'1x' => ( isset( $product['product_image'] ) ) ? $product['product_image'] : '',
'2x' => ( isset( $product['product_image'] ) ) ? $product['product_image'] : '',
'default' => ( isset( $product['product_image'] ) ) ? $product['product_image'] : '',
)
);
$_transient_data->last_checked = time();
$_transient_data->response[ $template ] = $plugin;
}
return $_transient_data;
}
/**
* Function to update theme's transient.
*
* @param obj $_transient_data Transient Data.
* @return $_transient_data.
*/
public function brainstorm_update_themes_transient( $_transient_data ) {
global $pagenow;
if ( ! is_object( $_transient_data ) ) {
$_transient_data = new stdClass();
}
if ( 'themes.php' !== $pagenow && 'update-core.php' !== $pagenow ) {
return $_transient_data;
}
$update_data = $this->bsf_update_transient_data( 'themes' );
foreach ( $update_data as $key => $product ) {
if ( false === $this->enable_auto_updates( $product['id'] ) ) {
continue;
}
if ( isset( $product['template'] ) && '' !== $product['template'] ) {
$template = $product['template'];
}
$themes = array();
$themes['theme'] = isset( $template ) ? $template : '';
if ( $this->use_beta_version( $product['id'] ) ) {
$themes['new_version'] = isset( $product['version_beta'] ) ? $product['version_beta'] : '';
} else {
$themes['new_version'] = isset( $product['remote'] ) ? $product['remote'] : '';
}
$themes['url'] = isset( $product['purchase_url'] ) ? $product['purchase_url'] : '';
if ( BSF_License_Manager::bsf_is_active_license( $product['id'] ) === true ) {
$themes['package'] = $this->bsf_get_package_uri( $product['id'] );
} else {
$themes['package'] = '';
$themes['upgrade_notice'] = 'Please activate your license to receive automatic updates.';
}
$_transient_data->last_checked = time();
if ( isset( $template ) ) {
$_transient_data->response[ $template ] = $themes;
}
}
return $_transient_data;
}
/**
* Allow autoupdates to be enabled/disabled per product basis.
*
* @param String $product_id - Product ID.
* @return boolean True - IF updates are to be enabled. False if updates are to be disabled.
*/
private function enable_auto_updates( $product_id ) {
return apply_filters( "bsf_enable_product_autoupdates_{$product_id}", true );
}
/**
*
* Updates information on the "View version x.x details" page with custom data.
*
* @uses api_request()
*
* @param mixed $_data Data.
* @param string $_action Action.
* @param object $_args Arguments.
*
* @return object $_data
*/
public function bsf_get_plugin_information( $_data, $_action = '', $_args = null ) {
if ( 'plugin_information' !== $_action ) {
return $_data;
}
$brainstrom_products = apply_filters( 'bsf_get_plugin_information', get_option( 'brainstrom_products', array() ) );
$plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
$all_products = $plugins + $themes;
foreach ( $all_products as $key => $product ) {
$product_slug = isset( $product['slug'] ) ? $product['slug'] : '';
if ( $product_slug === $_args->slug ) {
$id = isset( $product['id'] ) ? $product['id'] : '';
$info = new stdClass();
if ( $this->use_beta_version( $id ) ) {
$info->new_version = isset( $product['version_beta'] ) ? $product['version_beta'] : '';
} else {
$info->new_version = isset( $product['remote'] ) ? $product['remote'] : '';
}
$product_name = isset( $product['name'] ) ? $product['name'] : '';
$info->name = bsf_get_white_lable_product_name( $id, $product_name );
$info->slug = $product_slug;
$info->version = isset( $product['remote'] ) ? $product['remote'] : '';
$info->author = apply_filters( "bsf_product_author_{$id}", 'Brainstorm Force' );
$info->url = isset( $product['changelog_url'] ) ? apply_filters( "bsf_product_url_{$id}", $product['changelog_url'] ) : apply_filters( "bsf_product_url_{$id}", '' );
$info->homepage = isset( $product['purchase_url'] ) ? apply_filters( "bsf_product_homepage_{$id}", $product['purchase_url'] ) : apply_filters( "bsf_product_homepage_{$id}", '' );
if ( BSF_License_Manager::bsf_is_active_license( $id ) === true ) {
$package_url = $this->bsf_get_package_uri( $id );
$info->package = $package_url;
$info->download_link = $package_url;
}
$info->sections = array();
$product_decription = isset( $product['description'] ) ? $product['description'] : '';
$info->sections['description'] = apply_filters( "bsf_product_description_{$id}", $product_decription );
$product_changelog = 'Thank you for using ' . $info->name . '. </br></br>To make your experience using ' . $info->name . ' better we release updates regularly, you can view the full changelog <a href="' . $info->url . '">here</a>';
$info->sections['changelog'] = apply_filters( "bsf_product_changelog_{$id}", $product_changelog );
$_data = $info;
}
}
return $_data;
}
/**
* Check if product is bundled.
*
* @param array $bsf_product Product.
* @param string $search_by Search By.
* @return $product_parent.
*/
public static function bsf_is_product_bundled( $bsf_product, $search_by = 'id' ) {
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
$product_parent = array();
foreach ( $brainstrom_bundled_products as $parent => $products ) {
foreach ( $products as $key => $product ) {
if ( 'init' === $search_by ) {
if ( $product->init === $bsf_product ) {
$product_parent[] = $parent;
}
} elseif ( 'id' === $search_by ) {
if ( $product->id === $bsf_product ) {
$product_parent[] = $parent;
}
} elseif ( 'name' === $search_by ) {
if ( strcasecmp( $product->name, $bsf_product ) === 0 ) {
$product_parent[] = $parent;
}
}
}
}
$product_parent = apply_filters( 'bsf_is_product_bundled', array_unique( $product_parent ), $bsf_product, $search_by );
return $product_parent;
}
/**
* Get package URL
*
* @param int $product_id Product Id.
* @return string $download_path.
*/
public function bsf_get_package_uri( $product_id ) {
$product = get_brainstorm_product( $product_id );
$status = BSF_License_Manager::bsf_is_active_license( $product_id );
$download_path = '';
$parent_product = isset( $product['parent'] ) ? $product['parent'] : '';
if ( $this->use_beta_version( $product_id ) ) {
$version = isset( $product['version_beta'] ) ? $product['version_beta'] : '';
} else {
$version = isset( $product['remote'] ) ? $product['remote'] : '';
}
if ( '' !== $version && false !== $status ) {
$bundled_product = self::bsf_is_product_bundled( $product_id );
$purchase_key = $this->get_purchse_key( $product_id );
$is_bundled = ( ! empty( $bundled_product ) ) ? '1' : '0';
$download_params = array(
'version_no' => $version,
'purchase_key' => $purchase_key,
'site_url' => get_site_url(),
'is_bundled' => $is_bundled,
'parent_product' => $parent_product,
);
$download_path = bsf_get_api_site( false, true ) . 'download/' . $product_id . '?' . http_build_query( $download_params );
// Clear Product versions from transient after update.
bsf_clear_versions_cache( $product_id );
return $download_path;
}
return $download_path;
}
/**
* Update transient Data.
*
* @param string $product_type Product Type.
* @return $update_required.
*/
public function bsf_update_transient_data( $product_type ) {
$this->maybe_force_check_bsf_product_updates();
$all_products = array();
$update_required = array();
if ( 'plugins' === $product_type ) {
$all_products = $this->prepare_plugins_for_update( brainstorm_get_all_products( false, true, false ) );
}
if ( 'themes' === $product_type ) {
$all_products = brainstorm_get_all_products( true, false, true );
}
foreach ( $all_products as $key => $product ) {
$product_id = isset( $product['id'] ) ? $product['id'] : '';
$constant = strtoupper( str_replace( '-', '_', $product_id ) );
$constant = 'BSF_' . $constant . '_CHECK_UPDATES';
if ( defined( $constant ) && ( constant( $constant ) === 'false' || constant( $constant ) === false ) ) {
continue;
}
$remote = isset( $product['remote'] ) ? $product['remote'] : '';
$local = isset( $product['version'] ) ? $product['version'] : '';
$version_beta = isset( $product['version_beta'] ) ? $product['version_beta'] : $remote;
if ( $this->use_beta_version( $product_id ) ) {
$remote = $version_beta;
}
if ( version_compare( $remote, $local, '>' ) ) {
array_push( $update_required, $product );
}
}
return $update_required;
}
/**
* Remove plugins from the updates array which are not installed.
*
* @param Array $plugins Plugins.
* @return Array of plugins.
*/
public static function prepare_plugins_for_update( $plugins ) {
foreach ( $plugins as $key => $plugin ) {
if ( isset( $plugin['template'] ) && ! file_exists( dirname( realpath( WP_PLUGIN_DIR . '/' . $plugin['template'] ) ) ) ) {
unset( $plugins[ $key ] );
}
if ( isset( $plugin['init'] ) && ! file_exists( dirname( realpath( WP_PLUGIN_DIR . '/' . $plugin['init'] ) ) ) ) {
unset( $plugins[ $key ] );
}
}
return $plugins;
}
/**
* Force check BSF Product updates.
*/
public function maybe_force_check_bsf_product_updates() {
if ( true === bsf_time_since_last_versioncheck( 2, 'bsf_last_update_check' ) ) {
global $ultimate_referer;
$ultimate_referer = 'on-transient-delete-2-hours';
bsf_check_product_update();
update_option( 'bsf_last_update_check', (string) current_time( 'timestamp' ) );
}
}
/**
* Use Beta version.
*
* @param int $product_id Product ID.
* @return bool.
*/
public function use_beta_version( $product_id ) {
$product = get_brainstorm_product( $product_id );
$stable = isset( $product['remote'] ) ? $product['remote'] : '';
$beta = isset( $product['version_beta'] ) ? $product['version_beta'] : '';
// If beta version is not set, return.
if ( '' === $beta ) {
return false;
}
if ( version_compare( $stable, $beta, '<' ) &&
self::bsf_allow_beta_updates( $product_id ) ) {
return true;
}
return false;
}
/**
* Beta version normalized.
*
* @param array $beta Beta.
* @return $version.
*/
public function beta_version_normalized( $beta ) {
$beta_explode = explode( '-', $beta );
$version = $beta_explode[0] . '.' . str_replace( 'beta', '', $beta_explode[1] );
return $version;
}
/**
* Allow Beta updates.
*
* @param array $product_id Product ID.
* @return bool.
*/
public static function bsf_allow_beta_updates( $product_id ) {
return apply_filters( "bsf_allow_beta_updates_{$product_id}", false );
}
/**
* Get Plugin's slug.
*
* @param array $template Template.
* @return $slug.
*/
public function bsf_get_plugin_slug( $template ) {
$slug = explode( '/', $template );
if ( isset( $slug[0] ) ) {
return $slug[0];
}
return '';
}
/**
* Update display license link.
*/
public function bsf_update_display_license_link() {
$brainstorm_all_products = $this->brainstorm_all_products();
foreach ( $brainstorm_all_products as $key => $product ) {
if ( isset( $product['id'] ) ) {
$id = $product['id'];
if ( isset( $product['template'] ) && '' !== $product['template'] ) {
$template = $product['template'];
} elseif ( isset( $product['init'] ) && '' !== $product['init'] ) {
$template = $product['init'];
}
if ( BSF_License_Manager::bsf_is_active_license( $id ) === false ) {
if ( is_plugin_active( $template ) ) {
add_action(
"in_plugin_update_message-$template",
array(
$this,
'bsf_add_registration_message',
),
9,
2
);
}
} else {
add_action(
"in_plugin_update_message-$template",
array(
$this,
'add_beta_update_message',
),
9,
2
);
}
}
}
}
/**
* Brainstorm All Products.
*/
public function brainstorm_all_products() {
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstrom_products_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$brainstrom_products_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
$bundled = array();
foreach ( $brainstrom_bundled_products as $parent => $children ) {
foreach ( $children as $key => $product ) {
$bundled[ $product->id ] = (array) $product;
}
}
// array of all the products.
$all_products = $brainstrom_products_plugins + $brainstrom_products_themes + $bundled;
return $all_products;
}
/**
* Add Registration message.
*
* @param array $plugin_data Plugin data.
* @param array $response Response.
*/
public function bsf_add_registration_message( $plugin_data, $response ) {
$plugin_init = isset( $plugin_data['plugin'] ) ? $plugin_data['plugin'] : '';
if ( '' !== $plugin_init ) {
$product_id = brainstrom_product_id_by_init( $plugin_init );
$bundled = self::bsf_is_product_bundled( $plugin_init, 'init' );
$registration_page = bsf_registration_page_url( '', $product_id );
} else {
$plugin_name = isset( $plugin_data['name'] ) ? $plugin_data['name'] : '';
$product_id = brainstrom_product_id_by_name( $plugin_name );
$bundled = self::bsf_is_product_bundled( $plugin_name, 'name' );
$registration_page = bsf_registration_page_url( '', $product_id );
}
if ( ! empty( $bundled ) ) {
$parent_id = $bundled[0];
$registration_page = bsf_registration_page_url( '', $parent_id );
$parent_name = bsf_get_white_lable_product_name( $parent_id, brainstrom_product_name( $parent_id ) );
/* translators: %1$s: $parent_name %2%s: $registration_page */
$message = sprintf( __( ' <br>This plugin is came bundled with the <i>%1$s</i>. For receiving updates, you need to register license of <i>%2$s</i> <a href="%3$s">here</a>.', 'bsf' ), $parent_name, $parent_name, $registration_page );
} else {
/* translators: %1$s: $registration_page %2%s: search term */
$message = sprintf( ' <i>%s</i>', sprintf( __( 'Please <a href="%1$s">activate your license</a> to update the plugin.', 'bsf' ), $registration_page ) );
}
if ( true === self::bsf_allow_beta_updates( $product_id ) && $this->is_beta_version( $plugin_data['new_version'] ) ) {
$message = $message . ' <i>It is recommended to use the beta version on a staging enviornment only.</i>';
}
echo wp_kses_post( $message );
}
/**
* Add Beta update message.
*
* @param array $plugin_data plugin data.
* @param array $response Response.
*/
public function add_beta_update_message( $plugin_data, $response ) {
$plugin_init = isset( $plugin_data['plugin'] ) ? $plugin_data['plugin'] : '';
if ( '' !== $plugin_init ) {
$product_id = brainstrom_product_id_by_init( $plugin_init );
} else {
$product_id = brainstrom_product_id_by_name( $plugin_name );
}
if ( true === self::bsf_allow_beta_updates( $product_id ) && $this->is_beta_version( $plugin_data['new_version'] ) ) {
echo ' <i>It is recommended to use the beta version on a staging enviornment only.</i>';
}
}
/**
* Is Beta version
*
* @param string $version Version.
* @return bool.
*/
private function is_beta_version( $version ) {
return strpos( $version, 'beta' ) ||
strpos( $version, 'alpha' );
}
/**
* Modify download package message to hide download URL.
*
* @param string $reply Reply.
* @param string $package Package.
* @param string $current Current.
* @return string $reply.
*/
public function modify_download_package_message( $reply, $package, $current ) {
// Read atts into separate veriables so that easy to reference below.
$strings = $current->strings;
if ( isset( $current->skin->plugin_info ) ) {
$plugin_info = $current->skin->plugin_info;
if ( ( isset( $plugin_info['author'] ) && 'Brainstorm Force' === $plugin_info['author'] ) || ( isset( $plugin_info['AuthorName'] ) && 'Brainstorm Force' === $plugin_info['AuthorName'] ) ) {
$strings['downloading_package'] = __( 'Downloading the update...', 'bsf-core' );
}
} elseif ( isset( $current->skin->theme_info ) ) {
$theme_info = $current->skin->theme_info;
$theme_author = $theme_info->get( 'Author' );
if ( 'Brainstorm Force' === $theme_author ) {
$strings['downloading_package'] = __( 'Downloading the update...', 'bsf-core' );
}
} elseif ( isset( $_GET['action'] ) && 'bsf_rollback' === $_GET['action'] && check_admin_referer( 'bsf_rollback' ) ) {
// In case of rollback version.
$strings['downloading_package'] = __( 'Downloading the update...', 'bsf-core' );
}
// restore the strings back to WP_Upgrader.
$current->strings = $strings;
// We are not changing teh return parameter.
return $reply;
}
/**
* Install Pluigns Filter
*
* Add brainstorm bundle products in plugin installer list though filter.
*
* @since 1.0.0
*
* @param array $brainstrom_products Brainstorm Products.
* @return array Brainstorm Products merged with Brainstorm Bundle Products.
*/
public function plugin_information( $brainstrom_products = array() ) {
$main_products = (array) get_option( 'brainstrom_bundled_products', array() );
foreach ( $main_products as $single_product_key => $single_product ) {
foreach ( $single_product as $bundle_product_key => $bundle_product ) {
if ( is_object( $bundle_product ) ) {
$type = $bundle_product->type;
$slug = $bundle_product->slug;
} else {
$type = $bundle_product['type'];
$slug = $bundle_product['slug'];
}
// Add bundled plugin in installer list.
if ( 'plugin' === $type ) {
$brainstrom_products['plugins'][ $slug ] = (array) $bundle_product;
}
}
}
return $brainstrom_products;
}
/**
* Get the prurchase key for product download API.
* If the product is bundeled then return it's parent product purchase key.
*
* @param string $product_id Product ID.
* @return string Purchase Key.
*/
public function get_purchse_key( $product_id ) {
$all_products = brainstorm_get_all_products();
$is_bundled = self::bsf_is_product_bundled( $product_id );
$product = isset( $all_products[ $product_id ] ) ? $all_products[ $product_id ] : array();
if ( ! empty( $is_bundled ) ) {
$product = isset( $all_products[ $product['parent'] ] ) ? $all_products[ $product['parent'] ] : array();
}
return isset( $product['purchase_key'] ) ? $product['purchase_key'] : '';
}
} // class BSF_Update_Manager
new BSF_Update_Manager();
}

View File

@@ -1,113 +0,0 @@
<?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' );
}

View File

@@ -1,117 +0,0 @@
<?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();

View File

@@ -1,98 +0,0 @@
<?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();

View File

@@ -1,89 +0,0 @@
<?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();

View File

@@ -1,242 +0,0 @@
<?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;
}
}

View File

@@ -1,26 +0,0 @@
{
"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"
}
}

View File

@@ -1,403 +0,0 @@
<?php
/**
* Helper functions for BSF Core.
*
* @author Brainstorm Force
* @package bsf-core
*/
/**
* BSF get API site.
*
* @param bool $prefer_unsecure Prefer unsecure.
* @param bool $is_rest_api use rest api base URL.
* @return $bsf_api_site.
*/
function bsf_get_api_site( $prefer_unsecure = false, $is_rest_api = false ) {
$rest_api_endoint = ( true === $is_rest_api ) ? 'wp-json/bsf-products/v1/' : '';
if ( defined( 'BSF_API_URL' ) ) {
$bsf_api_site = BSF_API_URL . $rest_api_endoint;
} else {
$bsf_api_site = 'http://support.brainstormforce.com/' . $rest_api_endoint;
if ( false === $prefer_unsecure && wp_http_supports( array( 'ssl' ) ) ) {
$bsf_api_site = set_url_scheme( $bsf_api_site, 'https' );
}
}
return $bsf_api_site;
}
/**
* BSF get API URL.
*
* @param bool $prefer_unsecure Prefer unsecure.
* @return $url.
*/
function bsf_get_api_url( $prefer_unsecure = false ) {
$url = bsf_get_api_site( $prefer_unsecure ) . 'wp-admin/admin-ajax.php';
return $url;
}
/**
* BSF time since last version check.
*
* @param int $hours_completed Hours completed.
* @param string $option Option.
* @return $url.
*/
function bsf_time_since_last_versioncheck( $hours_completed, $option ) {
$seconds = $hours_completed * HOUR_IN_SECONDS;
$status = false;
$last_update_timestamp = (int) get_option( $option, false );
if ( false !== $last_update_timestamp ) {
// Find seconds passed since the last timestamp update (i.e. last request made).
$elapsed_seconds = (int) current_time( 'timestamp' ) - $last_update_timestamp;
// IF time is more than the required seconds allow a new HTTP request.
if ( $elapsed_seconds > $seconds ) {
$status = true;
}
} else {
// If timestamp is not yet set - allow the HTTP request.
$status = true;
}
return $status;
}
if ( ! function_exists( 'bsf_convert_core_path_to_relative' ) ) {
/**
* Depracate bsf_convert_core_path_to_relative() to in favour of bsf_core_url()
*
* @param $path $path deprecated.
* @return String URL of bsf-core directory.
*/
function bsf_convert_core_path_to_relative( $path ) {
_deprecated_function( __FUNCTION__, '1.22.46', 'bsf_core_url' );
return bsf_core_url( '' );
}
}
if ( ! function_exists( 'bsf_core_url' ) ) {
/**
* BSF Core URL
*
* @param string $append Append.
* @return String URL of bsf-core directory.
*/
function bsf_core_url( $append = '' ) {
$path = wp_normalize_path( BSF_UPDATER_PATH );
$theme_dir = wp_normalize_path( get_template_directory() );
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
if ( strpos( $path, $theme_dir ) !== false ) {
return rtrim( get_template_directory_uri() . '/admin/bsf-core/', '/' ) . $append;
} elseif ( strpos( $path, $plugin_dir ) !== false ) {
return rtrim( plugin_dir_url( BSF_UPDATER_FILE ), '/' ) . $append;
} elseif ( strpos( $path, dirname( plugin_basename( BSF_UPDATER_FILE ) ) ) !== false ) {
return rtrim( plugin_dir_url( BSF_UPDATER_FILE ), '/' ) . $append;
}
return false;
}
}
if ( ! function_exists( 'get_brainstorm_product' ) ) {
/**
* Get BSF product.
*
* @param string $product_id Product ID.
* @return array Product.
*/
function get_brainstorm_product( $product_id = '' ) {
$all_products = brainstorm_get_all_products();
foreach ( $all_products as $key => $product ) {
$product_id_bsf = isset( $product['id'] ) ? ( is_numeric( $product['id'] ) ? (int) $product['id'] : $product['id'] ) : '';
if ( $product_id === $product_id_bsf ) {
return $product;
}
}
return array();
}
}
if ( ! function_exists( 'brainstorm_get_all_products' ) ) {
/**
* Get BSF all products.
*
* @param bool $skip_plugins Skip plugins.
* @param bool $skip_themes Skip themes.
* @param bool $skip_bundled Skip bundled.
*
* @return array All Products.
*/
function brainstorm_get_all_products( $skip_plugins = false, $skip_themes = false, $skip_bundled = false ) {
$all_products = array();
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
$brainstorm_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$brainstorm_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
if ( true === $skip_plugins ) {
$all_products = $brainstorm_themes;
} elseif ( true === $skip_themes ) {
$all_products = $brainstorm_plugins;
} else {
$all_products = $brainstorm_plugins + $brainstorm_themes;
}
if ( false === $skip_bundled ) {
foreach ( $brainstrom_bundled_products as $parent_id => $parent ) {
foreach ( $parent as $key => $product ) {
if ( isset( $all_products[ $product->id ] ) ) {
$all_products[ $product->id ] = array_merge( $all_products[ $product->id ], (array) $product );
} else {
$all_products[ $product->id ] = (array) $product;
}
}
}
}
return $all_products;
}
}
if ( ! function_exists( 'bsf_extension_nag' ) ) {
/**
* Generate's markup to generate notice to ask users to install required extensions.
*
* @since Graupi 1.9
*
* @param string $product_id (string) Product ID of the brainstorm product.
* @param bool $mu_updater (bool) If True - give nag to separately install brainstorm updater multisite plugin.
*/
function bsf_extension_nag( $product_id = '', $mu_updater = false ) {
$display_nag = get_user_meta( get_current_user_id(), $product_id . '-bsf_nag_dismiss', true );
if ( true === $mu_updater ) {
bsf_nag_brainstorm_updater_multisite();
}
if ( '1' === $display_nag ||
! user_can( get_current_user_id(), 'activate_plugins' ) ||
! user_can( get_current_user_id(), 'install_plugins' ) ) {
return;
}
$bsf_installed_plugins = '';
$bsf_not_installed_plugins = '';
$bsf_not_activated_plugins = '';
$installer = '';
$bsf_install = false;
$bsf_activate = false;
$bsf_bundled_products = bsf_bundled_plugins( $product_id );
$bsf_product_name = brainstrom_product_name( $product_id );
foreach ( $bsf_bundled_products as $key => $plugin ) {
if ( ! isset( $plugin->id ) || '' === $plugin->id || ! isset( $plugin->must_have_extension ) || 'false' === $plugin->must_have_extension ) {
continue;
}
$plugin_abs_path = WP_PLUGIN_DIR . '/' . $plugin->init;
if ( is_file( $plugin_abs_path ) ) {
if ( ! is_plugin_active( $plugin->init ) ) {
$bsf_not_activated_plugins .= $bsf_bundled_products[ $key ]->name . ', ';
}
} else {
$bsf_not_installed_plugins .= $bsf_bundled_products[ $key ]->name . ', ';
}
}
$bsf_not_activated_plugins = rtrim( $bsf_not_activated_plugins, ', ' );
$bsf_not_installed_plugins = rtrim( $bsf_not_installed_plugins, ', ' );
if ( '' !== $bsf_not_activated_plugins || '' !== $bsf_not_installed_plugins ) {
echo '<div class="updated notice is-dismissible"><p></p>';
if ( '' !== $bsf_not_activated_plugins ) {
echo '<p>';
echo esc_html( $bsf_product_name ) . esc_html__( ' requires following plugins to be active : ', 'bsf' );
echo '<strong><em>';
echo esc_html( $bsf_not_activated_plugins );
echo '</strong></em>';
echo '</p>';
$bsf_activate = true;
}
if ( '' !== $bsf_not_installed_plugins ) {
echo '<p>';
echo esc_html( $bsf_product_name ) . esc_html__( ' requires following plugins to be installed and activated : ', 'bsf' );
echo '<strong><em>';
echo esc_html( $bsf_not_installed_plugins );
echo '</strong></em>';
echo '</p>';
$bsf_install = true;
}
if ( true === $bsf_activate ) {
$installer .= '<a href="' . get_admin_url() . 'plugins.php?plugin_status=inactive">' . __( 'Begin activating plugins', 'bsf' ) . '</a> | ';
}
if ( true === $bsf_install ) {
$installer .= '<a href="' . bsf_exension_installer_url( $product_id ) . '">' . __( 'Begin installing plugins', 'bsf' ) . '</a> | ';
}
$installer .= '<a href="' . esc_url( add_query_arg( 'bsf-dismiss-notice', $product_id ) ) . '">' . __( 'Dismiss This Notice', 'bsf' ) . '</a>';
$installer = ltrim( $installer, '| ' );
wp_nonce_field( 'bsf-extension-nag', 'bsf-extension-nag-nonce', true, 1 );
echo '<p><strong>';
echo esc_html( rtrim( $installer, ' |' ) );
echo '</p></strong>';
echo '<p></p></div>';
}
}
}
if ( ! function_exists( 'bsf_nag_brainstorm_updater_multisite' ) ) {
/**
* BSF Updater multisite.
*/
function bsf_nag_brainstorm_updater_multisite() {
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
if ( ! is_multisite() || is_plugin_active_for_network( 'brainstorm-updater/index.php' ) ) {
return;
}
echo '<div class="notice notice-error uct-notice is-dismissible"><p>';
/* translators: %1$s: strong tag %2%s: strong tag %3%s: anchor tag %4%s: closing anchor tag */
sprintf( __( 'Looks like you are on a WordPress Multisite, you will need to install and network activate %1$s Brainstorm Updater for Multisite %2$s plugin. Download it from %3$s here %4$s', 'bsf' ), '<strong><em>', '<strong><em>', '<a href="http://bsf.io/bsf-updater-mu" target="_blank">', '</a>' );
echo '</p>';
echo '</div>';
}
}
/**
* Get product name from BSF core is loaded.
*/
function bsf_get_loaded_bsf_core_name() {
$path = wp_normalize_path( BSF_UPDATER_PATH );
$theme_dir = wp_normalize_path( WP_CONTENT_DIR . '/themes/' );
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
$product_name = '';
if ( false !== strpos( $path, $theme_dir ) ) {
// This is a theme path.
$product_slug = str_replace( array( $theme_dir, '/admin/bsf-core' ), '', $path );
} elseif ( false !== strpos( $path, $plugin_dir ) ) {
// This is plugin path.
$product_slug = str_replace( array( $plugin_dir . '/', '/admin/bsf-core' ), '', $path );
}
$brainstrom_products = get_option( 'brainstrom_products', array() );
foreach ( $brainstrom_products as $type => $products ) {
foreach ( $products as $product ) {
if ( $product['slug'] === $product_slug ) {
$product_name = $product['name'];
}
}
}
return $product_name;
}
/**
* Clear versions form trasinent.
*
* @param string $product_id Product ID.
*/
function bsf_clear_versions_cache( $product_id ) {
if ( false !== get_transient( 'bsf-product-versions-' . $product_id ) ) {
delete_transient( 'bsf-product-versions-' . $product_id );
}
}
/**
* Get white labled for product name.
*
* @param string $product_id Product ID.
* @param string $product_name Product Name.
*
* @return string Product name.
*/
function bsf_get_white_lable_product_name( $product_id, $product_name ) {
$white_label_name = apply_filters( "bsf_product_name_{$product_id}", $product_name );
return ! empty( $white_label_name ) ? $white_label_name : $product_name;
}
/**
* Get installed version of the product.
*
* @param string $type plugins/themes.
* @param string $product_id Product ID.
*/
function bsf_get_product_current_version( $type, $product_id ) {
$brainstrom_products = get_option( 'brainstrom_products' );
return isset( $brainstrom_products[ $type ][ $product_id ]['version'] ) ? $brainstrom_products[ $type ][ $product_id ]['version'] : '';
}
/**
* Check is user has permisson to view the product rollback version form.
*
* @param string $product_id Product ID.
*
* @return bool
*/
function bsf_display_rollback_version_form( $product_id ) {
if ( ! BSF_License_Manager::bsf_is_active_license( $product_id ) ) {
return false;
}
if ( is_multisite() && ! current_user_can( 'manage_network_plugins' ) ) {
return false;
}
if ( ! current_user_can( 'update_plugins' ) ) {
return false;
}
return true;
}
/**
* Get installed PHP version.
*
* @return float|false PHP version.
* @since 1.0.0
*/
function bsf_get_php_version() {
if ( defined( 'PHP_MAJOR_VERSION' ) && defined( 'PHP_MINOR_VERSION' ) && defined( 'PHP_RELEASE_VERSION' ) ) { // phpcs:ignore
return PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
}
return phpversion();
}

View File

@@ -1,292 +0,0 @@
<?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;
}

View File

@@ -1,84 +0,0 @@
<?php
/**
* Plugin installer.
*
* @package bsf-core
*/
/**
* Prevent direct access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
$current_page = '';
if ( isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$current_page = sanitize_text_field( $_GET['page'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$arr = explode( 'bsf-extensions-', $current_page );
$product_id = $arr[1];
}
$redirect_url = network_admin_url( 'admin.php?page=' . $current_page );
$extensions_installer_heading = apply_filters( "bsf_extinstaller_heading_{$product_id}", 'iMedica Extensions' );
$extensions_installer_subheading = apply_filters( "bsf_extinstaller_subheading_{$product_id}", 'iMedica is already very flexible & feature rich theme. It further aims to be all-in-one solution for your WordPress needs. Install any necessary extensions you like from below and take it on the steroids.' );
$reset_bundled_url = bsf_exension_installer_url( $product_id . '&remove-bundled-products&redirect=' . $redirect_url );
?>
<div class="clear"></div>
<div class="wrap about-wrap bsf-sp-screen bend <?php echo 'extension-installer-' . sanitize_html_class( $product_id ); ?>">
<div class="bend-heading-section extension-about-header">
<h1><?php echo esc_html( $extensions_installer_heading ); ?></h1>
<h3><?php echo esc_html( $extensions_installer_subheading ); ?></h3>
<div class="bend-head-logo">
<div class="bend-product-ver"><?php esc_html_e( 'Extensions ', 'bsf' ); ?></div>
</div>
</div> <!--heading section-->
<div class="bend-content-wrap">
<hr class="bsf-extensions-lists-separator">
<h3 class="bf-ext-sub-title"><?php esc_html_e( 'Available Extensions', 'bsf' ); ?></h3>
<?php $nonce = wp_create_nonce( 'bsf_activate_extension_nonce' ); ?>
<input type="hidden" id="bsf_activate_extension_nonce" value="<?php echo esc_attr( $nonce ); ?>" >
<?php
$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' );
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( htmlentities( $reset_bundled_url, ENT_QUOTES, 'utf-8' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>"><?php esc_html_e( 'Refresh Bundled Products', 'bsf' ); ?></a>
</div>
</div>
<?php
} else {
?>
<ul class="bsf-extensions-list">
<?php echo wp_kses_post( bsf_render_bundled_products( $product_id, false ) ); ?>
</ul>
<hr class="bsf-extensions-lists-separator">
<h3 class="bf-ext-sub-title"><?php esc_html_e( 'Installed Extensions', 'bsf' ); ?></h3>
<ul class="bsf-extensions-list">
<?php echo wp_kses_post( bsf_render_bundled_products( $product_id, true ) ); ?>
</ul>
<?php
}
?>
</div>
</div>

View File

@@ -1,931 +0,0 @@
<?php
/**
* Plugin Name: Brainstorm Core
* Plugin URI: https://brainstormforce.com
* Author: Brainstorm Force
* Author URI: https://brainstormforce.com
* Version: 1.0
* Description: Brainstorm Core
*
* @package BSF_Core
* Text Domain: bsf
*/
/*
Instrunctions - Product Registration & Updater
# Copy "auto-upadater" folder to admin folder
# Change "include_once" and "require_once" directory path as per your "auto-updater" path (Line no. 72, 78, 79)
*/
defined( 'ABSPATH' ) || exit;
// abspath of groupi.
if ( ! defined( 'BSF_UPDATER_PATH' ) ) {
define( 'BSF_UPDATER_PATH', dirname( __FILE__ ) );
}
if ( ! defined( 'BSF_UPDATER_FILE' ) ) {
define( 'BSF_UPDATER_FILE', __FILE__ );
}
if ( ! defined( 'BSF_UPDATER_FULLNAME' ) ) {
define( 'BSF_UPDATER_FULLNAME', apply_filters( 'agency_updater_fullname', 'Brainstorm Force' ) );
}
if ( ! defined( 'BSF_UPDATER_SHORTNAME' ) ) {
define( 'BSF_UPDATER_SHORTNAME', apply_filters( 'agency_updater_shortname', 'Brainstorm' ) );
}
if ( ! defined( 'BSF_UPDATER_VERSION' ) ) {
global $bsf_core_version;
define( 'BSF_UPDATER_VERSION', sanitize_text_field( $bsf_core_version ) );
}
// Do not initialize graupi in the customizer.
if ( is_customize_preview() ) {
return;
}
/* product registration */
require_once 'includes/helpers.php';
require_once 'includes/system-info.php';
require_once 'auto-update/admin-functions.php';
require_once 'auto-update/updater.php';
require_once 'class-bsf-update-manager.php';
require_once 'class-bsf-rollback-version-manager.php';
require_once 'class-bsf-license-manager.php';
require_once 'classes/class-bsf-extension-installer.php';
require_once 'classes/class-bsf-core-update.php';
require_once 'classes/class-bsf-core-rest.php';
require_once 'classes/class-bsf-rollback-version.php';
if ( defined( 'WP_CLI' ) ) {
require 'class-bsf-wp-cli-command.php';
}
add_action( 'admin_init', 'set_bsf_core_constant', 1 );
if ( ! function_exists( 'set_bsf_core_constant' ) ) {
/**
* Set BSF Core constant.
*/
function set_bsf_core_constant() {
if ( ! defined( 'BSF_CORE' ) ) {
define( 'BSF_CORE', true );
}
}
}
/*
Instrunctions - Plugin Installer
# Copy "plugin-installer" folder to theme's admin folder
# Change "include_once" and "require_once" directory path as per your "plugin-installer" path (Line no. 101, 113)
*/
if ( ! function_exists( 'init_bsf_plugin_installer' ) ) {
/**
* BSF Plugin installer.
*/
function init_bsf_plugin_installer() {
require_once 'plugin-installer/admin-functions.php';
/**
* Action will run after plugin installer is loaded
*/
do_action( 'bsf_after_plugin_installer' );
}
}
add_action( 'admin_init', 'init_bsf_plugin_installer', 0 );
add_action( 'network_admin_init', 'init_bsf_plugin_installer', 0 );
if ( ! is_multisite() ) {
add_action( 'admin_menu', 'register_bsf_extension_page', 999 );
} else {
add_action( 'network_admin_menu', 'register_bsf_extension_page_network', 999 );
}
if ( ! function_exists( 'register_bsf_extension_page' ) ) {
/**
* Register BSF extension Page.
*/
function register_bsf_extension_page() {
add_submenu_page(
'imedica_options',
__( 'Extensions', 'bsf' ),
__( 'Extensions', 'bsf' ),
'manage_options',
'bsf-extensions-10395942',
'bsf_extensions_callback'
);
}
}
if ( ! function_exists( '_bsf_maybe_add_dashboard_menu' ) ) {
/**
* Check if the dashboard menu for installer should be added.
* Checks if theme or plugin is active, if it is not active, the menu for installer should not be registered.
*
* @param int $product_id Product if of brainstorm product.
*
* @return boolean true - If menu is to be shown | false - if menu is not to be displayed.
*/
function _bsf_maybe_add_dashboard_menu( $product_id ) {
$brainstrom_products = ( get_option( 'brainstrom_products' ) ) ? get_option( 'brainstrom_products' ) : array();
$template_plugin = '';
$template_theme = '';
$is_theme = false;
if ( is_multisite() ) {
// Do not register menu if we are on multisite, multisite menu will be registered below the brainstorm menu.
return false;
}
if ( ! empty( $brainstrom_products ) ) {
if ( isset( $brainstrom_products['plugins'] ) && isset( $brainstrom_products['plugins'][ $product_id ] ) ) {
$template_plugin = $brainstrom_products['plugins'][ $product_id ]['template'];
}
if ( isset( $brainstrom_products['themes'] ) && isset( $brainstrom_products['themes'][ $product_id ] ) ) {
$template_theme = $brainstrom_products['themes'][ $product_id ]['product_name'];
$is_theme = true;
}
if ( true === $is_theme && '' !== $template_theme ) {
$themes = wp_get_theme();
$theme_name = '';
$parent = $themes->parent();
if ( empty( $parent ) ) {
$theme_name = $themes->get( 'Name' );
} else {
$theme_name = $themes->parent()->get( 'Name' );
}
if ( $theme_name === $template_theme ) {
// Theme / Parent theme is active, hence display menu.
return true;
}
// don't display menu if theme/parent theme does not need extension installer.
return false;
} elseif ( false === $is_theme && '' !== $template_plugin ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( is_plugin_active( $template_plugin ) || is_plugin_active_for_network( $template_plugin ) ) {
// Plugin is active, hence display menu.
return true;
}
// don't display menu if plugin does not need extension installer.
return false;
}
}
// do not register menu if all conditions fail.
return false;
}
}
if ( ! function_exists( 'register_bsf_extension_page_network' ) ) {
/**
* Register BSF extension page Network
*/
function register_bsf_extension_page_network() {
$themes = wp_get_themes( array( 'allowed' => 'network' ) );
$parent_slug = 'bsf-registration';
if ( defined( 'BSF_REG_MENU_TO_SETTINGS' ) && ( BSF_REG_MENU_TO_SETTINGS === true || BSF_REG_MENU_TO_SETTINGS === 'true' ) ) {
$parent_slug = 'settings.php';
}
foreach ( $themes as $theme ) {
if ( 'iMedica' === $theme->Name ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
add_submenu_page( $parent_slug, __( 'iMedica Extensions', 'bsf' ), __( 'iMedica Extensions', 'bsf' ), 'manage_options', 'bsf-extensions-10395942', 'bsf_extensions_callback' );
break;
}
}
}
}
if ( ! function_exists( 'bsf_extensions_callback' ) ) {
/**
* BSF extensions callback
*/
function bsf_extensions_callback() {
include_once 'plugin-installer/index.php';
}
}
if ( ! function_exists( 'bsf_extract_product_id' ) ) {
/**
* BSF extract Product ID.
*
* @param string $path Path.
*/
function bsf_extract_product_id( $path ) {
$id = false;
$file = rtrim( $path, '/' ) . '/admin/bsf.yml';
$file_fallback = rtrim( $path, '/' ) . '/bsf.yml';
if ( is_file( $file ) ) {
$file = $file;
} elseif ( is_file( $file_fallback ) ) {
$file = $file_fallback;
} else {
return apply_filters( 'bsf_extract_product_id', $id, $path );
}
// Use of file_get_contents() - https://github.com/WordPress/WordPress-Coding-Standards/pull/1374/files#diff-400e43bc09c24262b43f26fce487fdabR43-R52.
$filelines = file_get_contents( $file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Reading local file is OK.
if ( stripos( $filelines, 'ID:[' ) !== false ) {
preg_match_all( '/ID:\[(.*?)\]/', $filelines, $matches );
if ( isset( $matches[1] ) ) {
$id = ( isset( $matches[1][0] ) ) ? $matches[1][0] : '';
}
}
return apply_filters( 'bsf_extract_product_id', $id, $path );
}
}
if ( ! function_exists( 'init_bsf_core' ) ) {
/**
* Init BSF Core
*/
function init_bsf_core() {
$plugins = get_plugins();
$themes = wp_get_themes();
$theme_directories = search_theme_directories();
$bsf_products = array();
$bsf_authors = apply_filters(
'bsf_authors_list',
array(
'Brainstorm Force',
)
);
foreach ( $plugins as $plugin => $plugin_data ) {
if ( in_array( trim( $plugin_data['Author'] ), $bsf_authors, true ) ) {
$plugin_data['type'] = 'plugin';
$plugin_data['template'] = $plugin;
$plugin_data['path'] = dirname( realpath( WP_PLUGIN_DIR . '/' . $plugin ) );
$id = bsf_extract_product_id( $plugin_data['path'] );
if ( false !== $id ) {
$plugin_data['id'] = $id;
} // without readme.txt filename
array_push( $bsf_products, $plugin_data );
}
}
foreach ( $themes as $theme => $theme_data ) {
$temp = array();
$theme_author = trim( $theme_data->display( 'Author', false ) );
if ( 'Brainstorm Force' === $theme_author ) {
$temp['Name'] = $theme_data->get( 'Name' );
$temp['ThemeURI'] = $theme_data->get( 'ThemeURI' );
$temp['Description'] = $theme_data->get( 'Description' );
$temp['Author'] = $theme_data->get( 'Author' );
$temp['AuthorURI'] = $theme_data->get( 'AuthorURI' );
$temp['Version'] = $theme_data->get( 'Version' );
$temp['type'] = 'theme';
$temp['template'] = $theme;
$temp['path'] = realpath( get_theme_root() . '/' . $theme );
$id = bsf_extract_product_id( $temp['path'] );
if ( false !== $id ) {
$temp['id'] = $id;
} // without readme.txt filename
array_push( $bsf_products, $temp );
}
}
$brainstrom_products = get_option( 'brainstrom_products', array() );
$bundled_products = get_option( 'brainstrom_bundled_products', array() );
if ( ! empty( $brainstrom_products ) ) {
if ( isset( $brainstrom_products['plugins'] ) ) {
foreach ( $brainstrom_products['plugins'] as $key => $value ) {
if ( ! array_key_exists( $value['template'], $plugins ) ) {
unset( $brainstrom_products['plugins'][ $key ] );
}
}
}
if ( isset( $brainstrom_products['themes'] ) ) {
foreach ( $brainstrom_products['themes'] as $key => $value ) {
if ( ! array_key_exists( $value['template'], $theme_directories ) ) {
unset( $brainstrom_products['themes'][ $key ] );
}
}
}
}
// Update newly added brainstorm_products.
if ( ! empty( $bsf_products ) ) {
foreach ( $bsf_products as $key => $product ) {
if ( ! ( isset( $product['id'] ) ) || '' === $product['id'] ) {
continue;
}
if ( isset( $brainstrom_products[ $product['type'] . 's' ][ $product['id'] ] ) ) {
$bsf_product_info = $brainstrom_products[ $product['type'] . 's' ][ $product['id'] ];
} else {
$bsf_product_info = array();
do_action( 'brainstorm_updater_new_product_added' );
}
$bsf_product_info['template'] = $product['template'];
$bsf_product_info['type'] = $product['type'];
$bsf_product_info['id'] = $product['id'];
$brainstrom_products[ $product['type'] . 's' ][ $product['id'] ] = $bsf_product_info;
}
}
// Update bundled products.
foreach ( $bundled_products as $key => $product ) {
$bsf_product = get_brainstorm_product( $key );
if ( empty( $bsf_product ) ) {
unset( $bundled_products[ $key ] );
}
}
update_option( 'brainstrom_products', $brainstrom_products );
update_option( 'brainstrom_bundled_products', $bundled_products );
}
}
add_action( 'admin_init', 'init_bsf_core' );
// assets.
add_action( 'admin_enqueue_scripts', 'register_bsf_core_admin_styles', 1 );
if ( ! function_exists( 'register_bsf_core_admin_styles' ) ) {
/**
* Register BSF Core Admin Styles
*
* @param string $hook Hook.
*/
function register_bsf_core_admin_styles( $hook ) {
// bsf core style.
$hook_array = array(
'toplevel_page_bsf-registration',
'update-core.php',
'dashboard_page_bsf-registration',
'index_page_bsf-registration',
'admin_page_bsf-extensions',
'settings_page_bsf-registration',
'admin_page_bsf-registration',
'plugins.php',
'imedica_page_product-license',
);
$hook_array = apply_filters( 'bsf_core_style_screens', $hook_array );
if ( in_array( $hook, $hook_array, true ) || strpos( $hook, 'bsf-extensions' ) !== false ) {
$envato_activation_nonce = wp_create_nonce( 'envato_activation_nonce' );
wp_register_style( 'bsf-core-admin', bsf_core_url( '/assets/css/style.css' ), array(), BSF_UPDATER_VERSION );
wp_enqueue_style( 'bsf-core-admin' );
wp_register_style( 'brainstorm-switch', bsf_core_url( '/assets/css/switch.css' ), array(), BSF_UPDATER_VERSION );
wp_enqueue_style( 'brainstorm-switch' );
wp_register_script( 'brainstorm-switch', bsf_core_url( '/assets/js/switch.js' ), array( 'jquery' ), BSF_UPDATER_VERSION, true );
wp_enqueue_script( 'brainstorm-switch' );
wp_register_script( 'bsf-core', bsf_core_url( '/assets/js/bsf-core.js' ), array( 'jquery' ), BSF_UPDATER_VERSION, true );
wp_localize_script( 'bsf-core', 'bsf_core', array( 'envato_activation_nonce' => $envato_activation_nonce ) );
wp_enqueue_script( 'bsf-core' );
}
// frosty script.
$hook_frosty_array = array();
$hook_frosty_array = apply_filters( 'bsf_core_frosty_screens', $hook_frosty_array );
if ( in_array( $hook, $hook_frosty_array, true ) ) {
wp_register_script( 'bsf-core-frosty', bsf_core_url( '/assets/js/frosty.js' ), array(), BSF_UPDATER_VERSION, false );
wp_enqueue_script( 'bsf-core-frosty' );
wp_register_style( 'bsf-core-frosty-style', bsf_core_url( '/assets/css/frosty.css' ), array(), BSF_UPDATER_VERSION );
wp_enqueue_style( 'bsf-core-frosty-style' );
}
}
}
if ( is_multisite() ) {
add_action( 'admin_print_scripts', 'print_bsf_styles' );
if ( ! function_exists( 'print_bsf_styles' ) ) {
/**
* Print BSF styles.
*/
function print_bsf_styles() {
$path = bsf_core_url( '/assets/fonts' );
echo "<style>
@font-face {
font-family: 'brainstorm';
src:url('" . esc_url( $path ) . "/brainstorm.eot');
src:url('" . esc_url( $path ) . "/brainstorm.eot') format('embedded-opentype'),
url('" . esc_url( $path ) . "/brainstorm.woff') format('woff'),
url('" . esc_url( $path ) . "/brainstorm.ttf') format('truetype'),
url('" . esc_url( $path ) . "/brainstorm.svg') format('svg');
font-weight: normal;
font-style: normal;
}
.toplevel_page_bsf-registration > div.wp-menu-image:before {
content: \"\\e603\" !important;
font-family: 'brainstorm' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
</style>";
}
}
}
if ( ! function_exists( 'bsf_flush_bundled_products' ) ) {
/**
* BSF flush Bundled products.
*/
function bsf_flush_bundled_products() {
$bsf_force_check_extensions = (bool) get_site_option( 'bsf_force_check_extensions', false );
if ( $bsf_force_check_extensions ) {
delete_site_option( 'brainstrom_bundled_products' );
global $ultimate_referer;
if ( empty( $ultimate_referer ) ) {
$ultimate_referer = 'on-flush-bundled-products';
}
get_bundled_plugins();
update_site_option( 'bsf_force_check_extensions', false );
}
}
}
add_action( 'bsf_after_plugin_installer', 'bsf_flush_bundled_products' );
add_action( 'deleted_plugin', 'bsf_flush_bundled_products' );
/**
* Return array of bundled plugins for a specific
*
* @since Graupi 1.9
*/
if ( ! function_exists( 'bsf_bundled_plugins' ) ) {
/**
* BSF bundled plugins.
*
* @param int $product_id Product ID.
*/
function bsf_bundled_plugins( $product_id = '' ) {
$products = array();
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', '' );
if ( '' !== $brainstrom_bundled_products ) {
if ( array_key_exists( $product_id, $brainstrom_bundled_products ) ) {
$products = $brainstrom_bundled_products[ $product_id ];
}
}
return $products;
}
}
/**
* Get product name from product ID
*
* @since Graupi 1.9
*/
if ( ! function_exists( 'brainstrom_product_name' ) ) {
/**
* Brainstorm product name.
*
* @param int $product_id Product ID.
*/
function brainstrom_product_name( $product_id = '' ) {
$product_name = '';
$brainstrom_products = get_option( 'brainstrom_products', array() );
foreach ( $brainstrom_products as $key => $value ) {
foreach ( $value as $key => $product ) {
if ( $product_id === $key ) {
$product_name = isset( $product['product_name'] ) ? $product['product_name'] : '';
}
}
}
return $product_name;
}
}
/**
* Get product id from product name
*
* @since Graupi 1.19
*/
if ( ! function_exists( 'brainstrom_product_id_by_name' ) ) {
/**
* Brainstorm product ID by name.
*
* @param int $product_name Product name.
*/
function brainstrom_product_id_by_name( $product_name ) {
$product_id = '';
$brainstrom_products = get_option( 'brainstrom_products', array() );
foreach ( $brainstrom_products as $key => $value ) {
foreach ( $value as $key => $product ) {
if ( isset( $product['product_name'] ) && strcasecmp( $product['product_name'], $product_name ) === 0 ) {
$product_id = isset( $product['id'] ) ? $product['id'] : '';
}
}
}
return $product_id;
}
}
if ( ! function_exists( 'brainstrom_product_id_by_init' ) ) {
/**
* BrainstormProduct Id by init.
*
* @param string $plugin_init Plugin init.
*/
function brainstrom_product_id_by_init( $plugin_init ) {
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstorm_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$brainstorm_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
$all_products = $brainstorm_plugins + $brainstorm_themes;
foreach ( $all_products as $key => $product ) {
$template = isset( $product['template'] ) ? $product['template'] : '';
if ( $plugin_init === $template ) {
return isset( $product['id'] ) ? $product['id'] : false;
}
}
}
}
/**
* Dismiss Extension installer nag
*
* @since Graupi 1.9
*/
if ( ! function_exists( 'bsf_dismiss_extension_nag' ) ) {
/**
* BSF dismiss extension nag.
*/
function bsf_dismiss_extension_nag() {
if ( isset( $_REQUEST['bsf-extension-nag-nonce'] ) && wp_verify_nonce( $_REQUEST['bsf-extension-nag-nonce'], 'bsf-extension-nag' ) && isset( $_GET['bsf-dismiss-notice'] ) ) {
$product_id = sanitize_text_field( $_GET['bsf-dismiss-notice'] );
update_user_meta( get_current_user_id(), $product_id . '-bsf_nag_dismiss', true );
}
}
}
add_action( 'admin_head', 'bsf_dismiss_extension_nag' );
// For debugging uncomment line below and remove query var &bsf-dismiss-notice from url and nag will be restored.
// delete_user_meta( get_current_user_id(), 'bsf-next-bsf_nag_dismiss');.
/*
* Load BSF core frosty scripts on front end
*/
add_action( 'wp_enqueue_scripts', 'register_bsf_core_styles', 1 );
/**
* Register BSF Core styles
*
* @param string $hook Hook.
*/
function register_bsf_core_styles( $hook ) {
// Register Frosty script and style.
wp_register_script( 'bsf-core-frosty', bsf_core_url( '/assets/js/frosty.js' ), array(), BSF_UPDATER_VERSION, false );
wp_register_style( 'bsf-core-frosty-style', bsf_core_url( '/assets/css/frosty.css' ), array(), BSF_UPDATER_VERSION );
}
/**
* Add link to debug settings for braisntorm updater on license registration page
*/
if ( ! function_exists( 'bsf_core_debug_link' ) ) {
/**
* Register BSF Core styles
*
* @param string $text Text.
*/
function bsf_core_debug_link( $text ) {
$screen = get_current_screen();
$screens = array(
'dashboard_page_bsf-registration',
'toplevel_page_bsf-registration-network',
'settings_page_bsf-registration',
'settings_page_bsf-registration-network',
);
$screens = apply_filters( 'bsf_core_debug_link_screens', $screens );
if ( ! in_array( $screen->id, $screens, true ) ) {
return $text;
}
$url = bsf_registration_page_url( '&author' );
$link = '<a href="' . $url . '">' . BSF_UPDATER_SHORTNAME . ' Updater debug settings</a>';
$text = $link . ' | ' . $text;
return $text;
}
}
add_filter( 'update_footer', 'bsf_core_debug_link', 999 );
/**
* Return brainstorm registration page URL
*
* @param $append (string) - Append at string at the end of the url
*/
if ( ! function_exists( 'bsf_registration_page_url' ) ) {
/**
* BSF Registration Page URL
*
* @param string $append Append.
* @param int $product_id Product ID.
*/
function bsf_registration_page_url( $append = '', $product_id = '' ) {
$bsf_updater_options = get_option( 'bsf_updater_options', array() );
$option = false;
$constant = false;
$skip_brainstorm_menu = get_site_option( 'bsf_skip_braisntorm_menu', false );
$product_registration_link = apply_filters( "bsf_registration_page_url_{$product_id}", '' );
// If Brainstorm meu is not registered.
if ( ( defined( 'BSF_UNREG_MENU' ) && ( BSF_UNREG_MENU === true || BSF_UNREG_MENU === 'true' ) ) ||
true === $skip_brainstorm_menu
) {
if ( '&author' === $append ) {
return admin_url( 'options.php?page=bsf-registration' . $append );
}
}
if ( isset( $bsf_updater_options['brainstorm_menu'] ) && '1' === $bsf_updater_options['brainstorm_menu'] ) {
$option = true;
}
if ( defined( 'BSF_REG_MENU_TO_SETTINGS' ) && 'BSF_REG_MENU_TO_SETTINGS' === true || 'BSF_REG_MENU_TO_SETTINGS' === 'true' ) {
$constant = true;
}
if ( '' !== $product_registration_link ) {
return $product_registration_link . '' . $append;
} else {
if ( true === $option || true === $constant ) {
// bsf menu in settings.
if ( is_multisite() ) {
return network_admin_url( 'settings.php?page=bsf-registration' . $append );
} else {
return admin_url( 'options-general.php?page=bsf-registration' . $append );
}
} else {
if ( is_multisite() ) {
return network_admin_url( 'admin.php?page=bsf-registration' . $append );
} else {
return admin_url( 'index.php?page=bsf-registration' . $append );
}
}
}
}
}
/**
* Return extension installer page URL
*/
if ( ! function_exists( 'bsf_exension_installer_url' ) ) {
/**
* BSF extension installer URL
*
* @param int $priduct_id Product ID.
* @return string URL.
*/
function bsf_exension_installer_url( $priduct_id ) {
if ( is_multisite() ) {
if ( defined( 'BSF_REG_MENU_TO_SETTINGS' ) && ( BSF_REG_MENU_TO_SETTINGS === true || BSF_REG_MENU_TO_SETTINGS === 'true' ) ) {
return network_admin_url( 'settings.php?page=bsf-extensions-' . $priduct_id );
} else {
return network_admin_url( 'admin.php?page=bsf-extensions-' . $priduct_id );
}
} else {
return admin_url( 'admin.php?page=bsf-extensions-' . $priduct_id );
}
}
}
if ( ! function_exists( 'bsf_set_options' ) ) {
/**
* Set options based on reading $_GET parameters and $_POST parameters
*
* 1. force Check updates
* 2. Skip Brainstorm Account Registration
* 3. Reset Brainstorm Registration data
*/
function bsf_set_options() {
// Force check updates.
if ( isset( $_GET['force-check-update'] ) || isset( $_GET['force-check'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
global $pagenow;
global $ultimate_referer;
if ( 'update-core.php' === $pagenow && '1' === $_GET['force-check'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$ultimate_referer = 'on-force-check-update-update-core';
} else {
$ultimate_referer = 'on-force-check-update';
}
bsf_check_product_update();
update_option( 'bsf_last_update_check', current_time( 'timestamp' ) );
}
// Skip Author registration.
$skip_author_products = apply_filters( 'bsf_skip_author_registration', $products = array() );
$ids = array();
$skip_author_option = get_site_option( 'bsf_skip_author', false );
$brainstorm_products = bsf_get_brainstorm_products( true );
foreach ( $brainstorm_products as $key => $product ) {
if ( isset( $product['id'] ) && ! in_array( $product['id'], $skip_author_products, true ) ) {
$ids[] = $product['id'];
}
}
if ( isset( $_REQUEST['bsf-skip-author-nonce'] ) && wp_verify_nonce( $_REQUEST['bsf-skip-author-nonce'], 'bsf-skip-author' ) && isset( $_GET['bsf-skip-author'] ) || empty( $ids ) && '' === $skip_author_option ) {
update_site_option( 'bsf_skip_author', true );
} elseif ( ! empty( $ids ) && '1' === $skip_author_option ) {
update_site_option( 'bsf_skip_author', false );
}
// Skip Brainstorm Menu.
$default_skip_brainstorm_menu = array(
'uabb',
'convertpro',
'astra-addon',
'astra-pro-sites',
'wp-schema-pro',
'6892199', // UAVC.
'10395942', // iMedica.
'14058953', // Convert Plus.
'5159016', // Baslider.
'imedica-mu-companion',
'astra-sites-showcase',
'uael',
'brainstorm-updater',
'astra-portfolio',
'7155037', // VC Modal Popups.
'astra',
);
$skip_brainstorm_menu_products = apply_filters( 'bsf_skip_braisntorm_menu', $default_skip_brainstorm_menu );
$ids = array();
$skip_brainstorm_menu = get_site_option( 'bsf_skip_braisntorm_menu', false );
foreach ( $brainstorm_products as $key => $product ) {
if ( isset( $product['id'] ) && ! in_array( $product['id'], $skip_brainstorm_menu_products, true ) ) {
$ids[] = $product['id'];
}
}
if ( empty( $ids ) && '' === $skip_brainstorm_menu ) {
update_site_option( 'bsf_skip_braisntorm_menu', true );
} elseif ( ! empty( $ids ) && '1' === $skip_brainstorm_menu ) {
update_site_option( 'bsf_skip_braisntorm_menu', false );
}
// Reset Brainstorm Registration.
if ( isset( $_GET['reset-bsf-users'] ) ) {
delete_option( 'brainstrom_users' );
delete_option( 'brainstrom_products' );
delete_option( 'brainstrom_bundled_products' );
delete_site_option( 'bsf_skip_author' );
}
// Reset Bundled products.
if ( isset( $_GET['remove-bundled-products'] ) ) {
global $ultimate_referer;
$ultimate_referer = 'on-refresh-bundled-products';
delete_option( 'brainstrom_bundled_products' );
get_bundled_plugins();
$redirect = isset( $_GET['redirect'] ) ? esc_url_raw( urldecode( esc_attr( $_GET['redirect'] ) ) ) : '';
if ( '' !== $redirect && filter_var( $redirect, FILTER_VALIDATE_URL ) ) {
$redirect = add_query_arg( 'bsf-reload-page', '', $redirect );
wp_safe_redirect( $redirect );
exit;
}
}
}
}
add_action( 'admin_init', 'bsf_set_options', 0 );
add_action( 'network_admin_init', 'bsf_set_options', 0 );
/**
* Flush skip registration option when any new brainstorm product is installed on the site.
*/
function bsf_flush_skip_registration() {
delete_site_option( 'bsf_skip_author' );
}
add_action( 'brainstorm_updater_new_product_added', 'bsf_flush_skip_registration' );
/**
* Return site option brainstorm_products
*
* Brainstorm_options option saves the data related to all the brainstorm products required for license management and updates.
*
* @param (boolean) $mix true: the output will be combined array of themes and plugins.
* @return (array) $brainstorm_products
*/
if ( ! function_exists( 'bsf_get_brainstorm_products' ) ) {
/**
* BSF Get Brainstorm products.
*
* @param bool $mix Mix.
* @return array $brainstorm_products.
*/
function bsf_get_brainstorm_products( $mix = false ) {
$brainstorm_products = get_option( 'brainstrom_products', array() );
if ( true === $mix ) {
$plugins = ( isset( $brainstorm_products['plugins'] ) ) ? $brainstorm_products['plugins'] : array();
$themes = ( isset( $brainstorm_products['themes'] ) ) ? $brainstorm_products['themes'] : array();
$brainstorm_products = array_merge( $plugins, $themes );
}
return $brainstorm_products;
}
}
/**
* BSF envatoredirect URL callback.
*/
function bsf_envato_redirect_url_callback() {
check_ajax_referer( 'envato_activation_nonce', 'envato_activation_nonce' );
// bail if current user cannot manage_options.
if ( ! current_user_can( 'manage_options' ) ) {
return false;
}
$envato_activate = new BSF_Envato_Activate();
$form_data = array();
$form_data['product_id'] = isset( $_GET['product_id'] ) ? esc_attr( $_GET['product_id'] ) : '';
$form_data['url'] = isset( $_GET['url'] ) ? esc_url_raw( $_GET['url'] ) : '';
$form_data['redirect'] = isset( $_GET['redirect'] ) ? rawurlencode( $_GET['redirect'] ) : '';
$form_data['privacy_consent'] = ( isset( $_GET['privacy_consent'] ) && 'true' === $_GET['privacy_consent'] ) ? true : false;
$form_data['terms_conditions_consent'] = ( isset( $_GET['terms_conditions_consent'] ) && 'true' === $_GET['terms_conditions_consent'] ) ? true : false;
$url = $envato_activate->envato_activation_url( $form_data );
$data = array(
'url' => esc_url_raw( $url ),
);
return wp_send_json_success( $data );
}
add_action( 'wp_ajax_bsf_envato_redirect_url', 'bsf_envato_redirect_url_callback' );

View File

@@ -1,300 +0,0 @@
<?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();
}

View File

@@ -1,15 +0,0 @@
<?php
/**
* Plugin installer.
*
* @package bsf-core
*/
/**
* Prevent direct access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
require_once BSF_UPDATER_PATH . '/includes/views/list-bundled-products.php';