plugin updates
This commit is contained in:
@@ -1,172 +1,172 @@
|
||||
/* ========================================================================
|
||||
* Frosty.js
|
||||
* https://owensbla.github.com/frosty
|
||||
* by Blake Owens (http://blakeowens.com/)
|
||||
* ======================================================================== */
|
||||
.bsf-has-tip,
|
||||
.has-tip {
|
||||
cursor: help;
|
||||
}
|
||||
.tip {
|
||||
background-color: black;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
color: #eeeeee;
|
||||
font-size: 11px;
|
||||
line-height: 1.5em;
|
||||
max-width: 200px;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
.tip.success {
|
||||
background-color: #47fe42;
|
||||
background-color: rgba(71, 254, 66, 0.8);
|
||||
color: #025600;
|
||||
}
|
||||
.tip.error {
|
||||
background-color: #ff7f86;
|
||||
background-color: rgba(255, 127, 134, 0.8);
|
||||
color: #7f0006;
|
||||
}
|
||||
.tip.light {
|
||||
background-color: #ebebeb;
|
||||
background-color: rgba(235, 235, 235, 0.8);
|
||||
color: #222222;
|
||||
}
|
||||
.tip[class*="arrow"]:before {
|
||||
content: ' ';
|
||||
position: absolute;
|
||||
border: solid transparent;
|
||||
width: 0px;
|
||||
height: 0px;
|
||||
border-width: 5px;
|
||||
border-color: black;
|
||||
border-color: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
.success[class*="arrow"]:before {
|
||||
border-color: #47fe42;
|
||||
border-color: rgba(71, 254, 66, 0.8);
|
||||
}
|
||||
.error[class*="arrow"]:before {
|
||||
border-color: #ff7f86;
|
||||
border-color: rgba(255, 127, 134, 0.8);
|
||||
}
|
||||
.light[class*="arrow"]:before {
|
||||
border-color: #ebebeb;
|
||||
border-color: rgba(235, 235, 235, 0.8);
|
||||
}
|
||||
.tip.arrow-right:before {
|
||||
border-right-color: transparent;
|
||||
border-top-color: transparent;
|
||||
border-bottom-color: transparent;
|
||||
margin-top: -5px;
|
||||
top: 50%;
|
||||
left: 100%;
|
||||
}
|
||||
.tip.arrow-left:before {
|
||||
border-left-color: transparent;
|
||||
border-top-color: transparent;
|
||||
border-bottom-color: transparent;
|
||||
margin-top: -5px;
|
||||
top: 50%;
|
||||
right: 100%;
|
||||
}
|
||||
.tip.arrow-top:before {
|
||||
border-top-color: transparent;
|
||||
border-left-color: transparent;
|
||||
border-right-color: transparent;
|
||||
margin-left: -5px;
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
}
|
||||
.tip.arrow-bottom:before {
|
||||
border-bottom-color: transparent;
|
||||
border-left-color: transparent;
|
||||
border-right-color: transparent;
|
||||
margin-left: -5px;
|
||||
top: 100%;
|
||||
left: 50%;
|
||||
}
|
||||
|
||||
/* Customizer Tooltip */
|
||||
.customize-support .tip {
|
||||
background-color: rgba(0, 148, 221, 0.95);
|
||||
color: #FFF;
|
||||
font-size: 13px;
|
||||
line-height: 1.5em;
|
||||
max-width: 200px;
|
||||
padding: 5px 11px;
|
||||
border: 1px solid #0094DD;
|
||||
border-radius: 1px;
|
||||
}
|
||||
.customize-support .tip[class*="arrow"]:before {
|
||||
border-width: 5px;
|
||||
border-color: #0094DD;
|
||||
border-color: rgba(0, 148, 221, 0.95);
|
||||
}
|
||||
.customize-support .tip.arrow-right:before {
|
||||
border-right-color: transparent;
|
||||
border-top-color: transparent;
|
||||
border-bottom-color: transparent;
|
||||
margin-top: -5px;
|
||||
top: 50%;
|
||||
left: 100%;
|
||||
}
|
||||
.customize-support .tip.arrow-left:before {
|
||||
border-left-color: transparent;
|
||||
border-top-color: transparent;
|
||||
border-bottom-color: transparent;
|
||||
margin-top: -5px;
|
||||
top: 50%;
|
||||
right: 100%;
|
||||
}
|
||||
.customize-support .tip.arrow-top:before {
|
||||
border-top-color: transparent;
|
||||
border-left-color: transparent;
|
||||
border-right-color: transparent;
|
||||
margin-left: -5px;
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
}
|
||||
.customize-support .tip.arrow-bottom:before {
|
||||
border-bottom-color: transparent;
|
||||
border-left-color: transparent;
|
||||
border-right-color: transparent;
|
||||
margin-left: -5px;
|
||||
top: 100%;
|
||||
left: 50%;
|
||||
}
|
||||
/*---close button tooltip--------*/
|
||||
.tip[class*="close-tip-content"]{
|
||||
border-radius:7px;
|
||||
max-width:300px;
|
||||
padding: 15px 30px;
|
||||
}
|
||||
.tip[class*="close-tip-content"]:before{
|
||||
border-width: 8px!important;
|
||||
margin-top: -8px!important;
|
||||
}
|
||||
|
||||
.tip[class*="close-tip-content"][class*="arrow-bottom"]{
|
||||
/* margin-top:-10px; */
|
||||
}
|
||||
.tip[class*="close-tip-content"][class*="arrow-bottom"]:before{
|
||||
margin-top: -1px!important;
|
||||
}
|
||||
.tip[class*="close-tip-content"][class*="arrow-right"]:before {
|
||||
left: 100%;
|
||||
left: calc(100% - 1px);
|
||||
}
|
||||
.cp-innertip.tip[class*="close-tip-content"][class*="arrow"]{
|
||||
margin-top: 30px!important;
|
||||
}
|
||||
@media (max-width:768px) {
|
||||
.tip[class*="close-tip-content"]{
|
||||
border-radius:7px;
|
||||
max-width:200px;
|
||||
padding: 5px 20px;
|
||||
}
|
||||
}
|
||||
@media (max-width:610px) {
|
||||
.tip[class*="close-tip-content"]{
|
||||
max-width:170px;
|
||||
}
|
||||
/* ========================================================================
|
||||
* Frosty.js
|
||||
* https://owensbla.github.com/frosty
|
||||
* by Blake Owens (http://blakeowens.com/)
|
||||
* ======================================================================== */
|
||||
.bsf-has-tip,
|
||||
.has-tip {
|
||||
cursor: help;
|
||||
}
|
||||
.tip {
|
||||
background-color: black;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
color: #eeeeee;
|
||||
font-size: 11px;
|
||||
line-height: 1.5em;
|
||||
max-width: 200px;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
.tip.success {
|
||||
background-color: #47fe42;
|
||||
background-color: rgba(71, 254, 66, 0.8);
|
||||
color: #025600;
|
||||
}
|
||||
.tip.error {
|
||||
background-color: #ff7f86;
|
||||
background-color: rgba(255, 127, 134, 0.8);
|
||||
color: #7f0006;
|
||||
}
|
||||
.tip.light {
|
||||
background-color: #ebebeb;
|
||||
background-color: rgba(235, 235, 235, 0.8);
|
||||
color: #222222;
|
||||
}
|
||||
.tip[class*="arrow"]:before {
|
||||
content: ' ';
|
||||
position: absolute;
|
||||
border: solid transparent;
|
||||
width: 0px;
|
||||
height: 0px;
|
||||
border-width: 5px;
|
||||
border-color: black;
|
||||
border-color: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
.success[class*="arrow"]:before {
|
||||
border-color: #47fe42;
|
||||
border-color: rgba(71, 254, 66, 0.8);
|
||||
}
|
||||
.error[class*="arrow"]:before {
|
||||
border-color: #ff7f86;
|
||||
border-color: rgba(255, 127, 134, 0.8);
|
||||
}
|
||||
.light[class*="arrow"]:before {
|
||||
border-color: #ebebeb;
|
||||
border-color: rgba(235, 235, 235, 0.8);
|
||||
}
|
||||
.tip.arrow-right:before {
|
||||
border-right-color: transparent;
|
||||
border-top-color: transparent;
|
||||
border-bottom-color: transparent;
|
||||
margin-top: -5px;
|
||||
top: 50%;
|
||||
left: 100%;
|
||||
}
|
||||
.tip.arrow-left:before {
|
||||
border-left-color: transparent;
|
||||
border-top-color: transparent;
|
||||
border-bottom-color: transparent;
|
||||
margin-top: -5px;
|
||||
top: 50%;
|
||||
right: 100%;
|
||||
}
|
||||
.tip.arrow-top:before {
|
||||
border-top-color: transparent;
|
||||
border-left-color: transparent;
|
||||
border-right-color: transparent;
|
||||
margin-left: -5px;
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
}
|
||||
.tip.arrow-bottom:before {
|
||||
border-bottom-color: transparent;
|
||||
border-left-color: transparent;
|
||||
border-right-color: transparent;
|
||||
margin-left: -5px;
|
||||
top: 100%;
|
||||
left: 50%;
|
||||
}
|
||||
|
||||
/* Customizer Tooltip */
|
||||
.customize-support .tip {
|
||||
background-color: rgba(0, 148, 221, 0.95);
|
||||
color: #FFF;
|
||||
font-size: 13px;
|
||||
line-height: 1.5em;
|
||||
max-width: 200px;
|
||||
padding: 5px 11px;
|
||||
border: 1px solid #0094DD;
|
||||
border-radius: 1px;
|
||||
}
|
||||
.customize-support .tip[class*="arrow"]:before {
|
||||
border-width: 5px;
|
||||
border-color: #0094DD;
|
||||
border-color: rgba(0, 148, 221, 0.95);
|
||||
}
|
||||
.customize-support .tip.arrow-right:before {
|
||||
border-right-color: transparent;
|
||||
border-top-color: transparent;
|
||||
border-bottom-color: transparent;
|
||||
margin-top: -5px;
|
||||
top: 50%;
|
||||
left: 100%;
|
||||
}
|
||||
.customize-support .tip.arrow-left:before {
|
||||
border-left-color: transparent;
|
||||
border-top-color: transparent;
|
||||
border-bottom-color: transparent;
|
||||
margin-top: -5px;
|
||||
top: 50%;
|
||||
right: 100%;
|
||||
}
|
||||
.customize-support .tip.arrow-top:before {
|
||||
border-top-color: transparent;
|
||||
border-left-color: transparent;
|
||||
border-right-color: transparent;
|
||||
margin-left: -5px;
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
}
|
||||
.customize-support .tip.arrow-bottom:before {
|
||||
border-bottom-color: transparent;
|
||||
border-left-color: transparent;
|
||||
border-right-color: transparent;
|
||||
margin-left: -5px;
|
||||
top: 100%;
|
||||
left: 50%;
|
||||
}
|
||||
/*---close button tooltip--------*/
|
||||
.tip[class*="close-tip-content"]{
|
||||
border-radius:7px;
|
||||
max-width:300px;
|
||||
padding: 15px 30px;
|
||||
}
|
||||
.tip[class*="close-tip-content"]:before{
|
||||
border-width: 8px!important;
|
||||
margin-top: -8px!important;
|
||||
}
|
||||
|
||||
.tip[class*="close-tip-content"][class*="arrow-bottom"]{
|
||||
/* margin-top:-10px; */
|
||||
}
|
||||
.tip[class*="close-tip-content"][class*="arrow-bottom"]:before{
|
||||
margin-top: -1px!important;
|
||||
}
|
||||
.tip[class*="close-tip-content"][class*="arrow-right"]:before {
|
||||
left: 100%;
|
||||
left: calc(100% - 1px);
|
||||
}
|
||||
.cp-innertip.tip[class*="close-tip-content"][class*="arrow"]{
|
||||
margin-top: 30px!important;
|
||||
}
|
||||
@media (max-width:768px) {
|
||||
.tip[class*="close-tip-content"]{
|
||||
border-radius:7px;
|
||||
max-width:200px;
|
||||
padding: 5px 20px;
|
||||
}
|
||||
}
|
||||
@media (max-width:610px) {
|
||||
.tip[class*="close-tip-content"]{
|
||||
max-width:170px;
|
||||
}
|
||||
}
|
||||
@@ -1,138 +1,138 @@
|
||||
.bsf-core-license-form p {
|
||||
padding: 5px 0px 5px 0px;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.license-form-allow-email .submit-button-wrap > input,
|
||||
.license-form-allow-email .submit-button-wrap > p {
|
||||
display: inline-block;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.bsf-core-license-form .license-form-allow-email .purchase-license a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.license-form-allow-email {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.license-form-allow-email .license-form-external-links {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.license-form-field input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.bsf-core-license-form .license-form-allow-email h3 {
|
||||
font-size: 2em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.bsf-core-license-form .license-form-allow-email .purchase-license {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.bsf-core-license-form .license-form-allow-email .submit-button-wrap {
|
||||
padding: 20px 0px 10px 0px;
|
||||
}
|
||||
|
||||
.license-form-allow-email .bsf-core-license-form-inner, {
|
||||
padding: 10px 30px 30px;
|
||||
}
|
||||
|
||||
.bsf-core-license-form .bsf-core-license-form-overlay {
|
||||
background: #000;
|
||||
opacity: 0.7;
|
||||
filter: alpha(opacity=70);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 100050;
|
||||
}
|
||||
|
||||
.bsf-core-license-form .bsf-core-license-form-inner {
|
||||
background: #fcfcfc;
|
||||
position: fixed;
|
||||
background-color: #fff;
|
||||
z-index: 999999999;
|
||||
padding: 2px 20px 20px;
|
||||
text-align: left;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
-webkit-transform: translateX(-50%) translateY(-50%);
|
||||
transform: translateX(-50%) translateY(-50%);
|
||||
-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
|
||||
box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
|
||||
}
|
||||
|
||||
.bsf-core-license-form-close-btn {
|
||||
position: absolute;
|
||||
left: auto;
|
||||
right: 0;
|
||||
top: 0;
|
||||
width: 29px;
|
||||
height: 29px;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
-webkit-transition: color .1s ease-in-out, background .1s ease-in-out;
|
||||
-webkit-transform: translateX(100%) translateY(-100%);
|
||||
transform: translateX(100%) translateY(-100%);
|
||||
transition: color .1s ease-in-out, background .1s ease-in-out;
|
||||
color: #eee;
|
||||
}
|
||||
.bsf-core-license-form-close-btn:hover {
|
||||
color: #00a0d2;
|
||||
}
|
||||
.bsf-core-license-form-close-btn .dashicons {
|
||||
display: block;
|
||||
text-align: center;
|
||||
line-height: 29px;
|
||||
width: 29px;
|
||||
height: 29px;
|
||||
font-size: 29px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.bsf-core-license-form .license-form-field input.regular-text {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/** License link */
|
||||
.bsf-core-license-form-btn.inactive {
|
||||
color: #3db634;
|
||||
font-weight: 500;
|
||||
}
|
||||
.bsf-core-license-form-btn {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.bsf-license-message.license-success {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bsf-system-info-wrapper {
|
||||
overflow: scroll;
|
||||
max-height: 60vh;
|
||||
}
|
||||
|
||||
.bsf-license-heading {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.bsf-license-not-active-astra-portfolio.bsf-license-heading {
|
||||
margin: 1em 0 0 0;
|
||||
}
|
||||
|
||||
.envato-license-registration form {
|
||||
margin-bottom: 1em;
|
||||
.bsf-core-license-form p {
|
||||
padding: 5px 0px 5px 0px;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.license-form-allow-email .submit-button-wrap > input,
|
||||
.license-form-allow-email .submit-button-wrap > p {
|
||||
display: inline-block;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.bsf-core-license-form .license-form-allow-email .purchase-license a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.license-form-allow-email {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.license-form-allow-email .license-form-external-links {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.license-form-field input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.bsf-core-license-form .license-form-allow-email h3 {
|
||||
font-size: 2em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.bsf-core-license-form .license-form-allow-email .purchase-license {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.bsf-core-license-form .license-form-allow-email .submit-button-wrap {
|
||||
padding: 20px 0px 10px 0px;
|
||||
}
|
||||
|
||||
.license-form-allow-email .bsf-core-license-form-inner, {
|
||||
padding: 10px 30px 30px;
|
||||
}
|
||||
|
||||
.bsf-core-license-form .bsf-core-license-form-overlay {
|
||||
background: #000;
|
||||
opacity: 0.7;
|
||||
filter: alpha(opacity=70);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 100050;
|
||||
}
|
||||
|
||||
.bsf-core-license-form .bsf-core-license-form-inner {
|
||||
background: #fcfcfc;
|
||||
position: fixed;
|
||||
background-color: #fff;
|
||||
z-index: 999999999;
|
||||
padding: 2px 20px 20px;
|
||||
text-align: left;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
-webkit-transform: translateX(-50%) translateY(-50%);
|
||||
transform: translateX(-50%) translateY(-50%);
|
||||
-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
|
||||
box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
|
||||
}
|
||||
|
||||
.bsf-core-license-form-close-btn {
|
||||
position: absolute;
|
||||
left: auto;
|
||||
right: 0;
|
||||
top: 0;
|
||||
width: 29px;
|
||||
height: 29px;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
-webkit-transition: color .1s ease-in-out, background .1s ease-in-out;
|
||||
-webkit-transform: translateX(100%) translateY(-100%);
|
||||
transform: translateX(100%) translateY(-100%);
|
||||
transition: color .1s ease-in-out, background .1s ease-in-out;
|
||||
color: #eee;
|
||||
}
|
||||
.bsf-core-license-form-close-btn:hover {
|
||||
color: #00a0d2;
|
||||
}
|
||||
.bsf-core-license-form-close-btn .dashicons {
|
||||
display: block;
|
||||
text-align: center;
|
||||
line-height: 29px;
|
||||
width: 29px;
|
||||
height: 29px;
|
||||
font-size: 29px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.bsf-core-license-form .license-form-field input.regular-text {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/** License link */
|
||||
.bsf-core-license-form-btn.inactive {
|
||||
color: #3db634;
|
||||
font-weight: 500;
|
||||
}
|
||||
.bsf-core-license-form-btn {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.bsf-license-message.license-success {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.bsf-system-info-wrapper {
|
||||
overflow: scroll;
|
||||
max-height: 60vh;
|
||||
}
|
||||
|
||||
.bsf-license-heading {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.bsf-license-not-active-astra-portfolio.bsf-license-heading {
|
||||
margin: 1em 0 0 0;
|
||||
}
|
||||
|
||||
.envato-license-registration form {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
@@ -1,84 +1,84 @@
|
||||
.bsf-core-rollback-overlay {
|
||||
background: #000;
|
||||
opacity: 0.7;
|
||||
filter: alpha(opacity=70);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 100050;
|
||||
}
|
||||
.bsf-confirm-rollback-popup-content {
|
||||
background: #fcfcfc;
|
||||
position: fixed;
|
||||
/* background-color: #fff; */
|
||||
z-index: 999999999;
|
||||
padding: 2px 20px 0px;
|
||||
text-align: left;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
-webkit-transform: translateX(-50%) translateY(-50%);
|
||||
transform: translateX(-50%) translateY(-50%);
|
||||
-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
|
||||
box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
|
||||
border-radius: 2px;
|
||||
}
|
||||
.bsf-confirm-rollback-popup-buttons-wrapper .bsf-confirm-cancel{
|
||||
padding: 0px 16px;
|
||||
margin-right: 149px;
|
||||
}
|
||||
.bsf-confirm-text{
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
.bsf-confirm-rollback-popup-buttons-wrapper .bsf-confirm-ok{
|
||||
margin-right: 0px;
|
||||
padding: 0px 16px;
|
||||
float: right;
|
||||
}
|
||||
.bsf-rollback-heading{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.bsf-confirm-rollback-popup-header {
|
||||
font-size: 15px;
|
||||
color: #495157;
|
||||
padding: 30px 0 10px;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
}
|
||||
.bsf-confirm-rollback-popup-message {
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
min-height: 50px;
|
||||
text-align: center;
|
||||
}
|
||||
.bsf-confirm-rollback-popup-buttons-wrapper {
|
||||
border-top: 1px solid #e4e4e4;
|
||||
width: 100%;
|
||||
padding: 9px 0px 9px 0px
|
||||
}
|
||||
.bsf-confirm-rollback-popup-button {
|
||||
font-family: Roboto, Arial, Helvetica, Verdana, sans-serif;
|
||||
width: 50%;
|
||||
border: none;
|
||||
background: none;
|
||||
color: #6d7882;
|
||||
font-size: 15px;
|
||||
cursor: pointer;
|
||||
padding: 13px 0;
|
||||
outline: 0;
|
||||
}
|
||||
.bsf-confirm-rollback-popup-button:hover {
|
||||
background:#e6e9ec6b
|
||||
}
|
||||
.bsf-confirm-rollback-popup-button.confirm-cancel {
|
||||
border-right: 1px solid #e6e9ec;
|
||||
}
|
||||
.bsf-confirm-rollback-popup-button.confirm-ok {
|
||||
color: rgb(74, 0, 224);
|
||||
}
|
||||
.bsf-confirm-rollback-popup.show {
|
||||
display: block;
|
||||
.bsf-core-rollback-overlay {
|
||||
background: #000;
|
||||
opacity: 0.7;
|
||||
filter: alpha(opacity=70);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 100050;
|
||||
}
|
||||
.bsf-confirm-rollback-popup-content {
|
||||
background: #fcfcfc;
|
||||
position: fixed;
|
||||
/* background-color: #fff; */
|
||||
z-index: 999999999;
|
||||
padding: 2px 20px 0px;
|
||||
text-align: left;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
-webkit-transform: translateX(-50%) translateY(-50%);
|
||||
transform: translateX(-50%) translateY(-50%);
|
||||
-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
|
||||
box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
|
||||
border-radius: 2px;
|
||||
}
|
||||
.bsf-confirm-rollback-popup-buttons-wrapper .bsf-confirm-cancel{
|
||||
padding: 0px 16px;
|
||||
margin-right: 149px;
|
||||
}
|
||||
.bsf-confirm-text{
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
.bsf-confirm-rollback-popup-buttons-wrapper .bsf-confirm-ok{
|
||||
margin-right: 0px;
|
||||
padding: 0px 16px;
|
||||
float: right;
|
||||
}
|
||||
.bsf-rollback-heading{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.bsf-confirm-rollback-popup-header {
|
||||
font-size: 15px;
|
||||
color: #495157;
|
||||
padding: 30px 0 10px;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
}
|
||||
.bsf-confirm-rollback-popup-message {
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
min-height: 50px;
|
||||
text-align: center;
|
||||
}
|
||||
.bsf-confirm-rollback-popup-buttons-wrapper {
|
||||
border-top: 1px solid #e4e4e4;
|
||||
width: 100%;
|
||||
padding: 9px 0px 9px 0px
|
||||
}
|
||||
.bsf-confirm-rollback-popup-button {
|
||||
font-family: Roboto, Arial, Helvetica, Verdana, sans-serif;
|
||||
width: 50%;
|
||||
border: none;
|
||||
background: none;
|
||||
color: #6d7882;
|
||||
font-size: 15px;
|
||||
cursor: pointer;
|
||||
padding: 13px 0;
|
||||
outline: 0;
|
||||
}
|
||||
.bsf-confirm-rollback-popup-button:hover {
|
||||
background:#e6e9ec6b
|
||||
}
|
||||
.bsf-confirm-rollback-popup-button.confirm-cancel {
|
||||
border-right: 1px solid #e6e9ec;
|
||||
}
|
||||
.bsf-confirm-rollback-popup-button.confirm-ok {
|
||||
color: rgb(74, 0, 224);
|
||||
}
|
||||
.bsf-confirm-rollback-popup.show {
|
||||
display: block;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,146 +1,146 @@
|
||||
input.form-control.smile-switch.switch + label.bsf-switch-btn:before {
|
||||
display: none;
|
||||
}
|
||||
input.form-control.smile-input.bsf-switch-input {
|
||||
display: none;
|
||||
}
|
||||
.switch-wrapper {
|
||||
width: 95px;
|
||||
}
|
||||
.shadow_type .onoffswitch-switch {
|
||||
width: 45px;
|
||||
}
|
||||
.shadow_type .onoffswitch-inactive .onoffswitch-switch:before {
|
||||
right: 45px;
|
||||
}
|
||||
.shadow_type .onoffswitch-active .onoffswitch-switch:before {
|
||||
left: 45px;
|
||||
}
|
||||
.ios-toggle, .ios-toggle:active {
|
||||
position:absolute;
|
||||
top:-5000px;
|
||||
height:0;
|
||||
width:0;
|
||||
opacity:0;
|
||||
border:none;
|
||||
outline:none;
|
||||
}
|
||||
|
||||
.checkbox-label {
|
||||
display:block;
|
||||
position:relative;
|
||||
padding:0px;
|
||||
margin: 0px;
|
||||
margin-bottom:20px;
|
||||
font-size:12px;
|
||||
line-height:16px;
|
||||
width:40px;
|
||||
height:20px;
|
||||
-webkit-border-radius:18px;
|
||||
-moz-border-radius:18px;
|
||||
border-radius:18px;
|
||||
background:#f8f8f8;
|
||||
cursor:pointer;
|
||||
-webkit-transition:.25s ease-in-out;
|
||||
-moz-transition:.25s ease-in-out;
|
||||
-o-transition:.25s ease-in-out;
|
||||
transition:.25s ease-in-out;
|
||||
}
|
||||
.checkbox-label:before {
|
||||
content:'';
|
||||
display:block;
|
||||
position:absolute;
|
||||
z-index:1;
|
||||
line-height:34px;
|
||||
text-indent:40px;
|
||||
height:20px;
|
||||
width:20px;
|
||||
-webkit-border-radius:100%;
|
||||
-moz-border-radius:100%;
|
||||
border-radius:100%;
|
||||
top:0px;
|
||||
left:0px;
|
||||
right:auto;
|
||||
background:white;
|
||||
-webkit-box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
|
||||
-moz-box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
|
||||
box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
|
||||
-webkit-transition:.25s ease-in-out;
|
||||
-moz-transition:.25s ease-in-out;
|
||||
-o-transition:.25s ease-in-out;
|
||||
transition:.25s ease-in-out;
|
||||
}
|
||||
.checkbox-label:after {
|
||||
content: attr(data-off);
|
||||
font-size: 13px;
|
||||
display: block;
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
top: 0;
|
||||
left: 50px;
|
||||
padding: 0;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
width: 36px;
|
||||
text-align: left;
|
||||
color: #BFBFBF;
|
||||
white-space: nowrap;
|
||||
-webkit-transition: .25s ease-in-out;
|
||||
-moz-transition: .25s ease-in-out;
|
||||
-o-transition: .25s ease-in-out;
|
||||
transition: .25s ease-in-out;
|
||||
}
|
||||
/* Switch CHECKBOX */
|
||||
.switch-checkbox + .checkbox-label {
|
||||
-webkit-box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
|
||||
-moz-box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
|
||||
box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
|
||||
background: #dddddd;
|
||||
}
|
||||
.switch-checkbox:checked + .checkbox-label {
|
||||
-webkit-box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
|
||||
-moz-box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
|
||||
box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
|
||||
background: #0094DD;
|
||||
}
|
||||
.switch-checkbox:checked + .checkbox-label:after {
|
||||
color:#0094DD;
|
||||
-webkit-transition:.25s ease-in-out;
|
||||
-moz-transition:.25s ease-in-out;
|
||||
-o-transition:.25s ease-in-out;
|
||||
transition:.25s ease-in-out;
|
||||
}
|
||||
|
||||
/* Toggle Checkbox */
|
||||
.ios-toggle:checked + .checkbox-label {
|
||||
-webkit-box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
|
||||
-moz-box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
|
||||
box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
|
||||
}
|
||||
.ios-toggle:checked + .checkbox-label:before {
|
||||
left:calc(100% - 21px);
|
||||
-webkit-box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
|
||||
-moz-box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
|
||||
box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
|
||||
-webkit-transition:.25s ease-in-out;
|
||||
-moz-transition:.25s ease-in-out;
|
||||
-o-transition:.25s ease-in-out;
|
||||
transition:.25s ease-in-out;
|
||||
}
|
||||
.ios-toggle:checked + .checkbox-label:after {
|
||||
content:attr(data-on);
|
||||
-webkit-transition:.25s ease-in-out;
|
||||
-moz-transition:.25s ease-in-out;
|
||||
-o-transition:.25s ease-in-out;
|
||||
transition:.25s ease-in-out;
|
||||
}
|
||||
.ios-toggle[type=checkbox] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.brainstorm-updater-switch {
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
input.form-control.smile-switch.switch + label.bsf-switch-btn:before {
|
||||
display: none;
|
||||
}
|
||||
input.form-control.smile-input.bsf-switch-input {
|
||||
display: none;
|
||||
}
|
||||
.switch-wrapper {
|
||||
width: 95px;
|
||||
}
|
||||
.shadow_type .onoffswitch-switch {
|
||||
width: 45px;
|
||||
}
|
||||
.shadow_type .onoffswitch-inactive .onoffswitch-switch:before {
|
||||
right: 45px;
|
||||
}
|
||||
.shadow_type .onoffswitch-active .onoffswitch-switch:before {
|
||||
left: 45px;
|
||||
}
|
||||
.ios-toggle, .ios-toggle:active {
|
||||
position:absolute;
|
||||
top:-5000px;
|
||||
height:0;
|
||||
width:0;
|
||||
opacity:0;
|
||||
border:none;
|
||||
outline:none;
|
||||
}
|
||||
|
||||
.checkbox-label {
|
||||
display:block;
|
||||
position:relative;
|
||||
padding:0px;
|
||||
margin: 0px;
|
||||
margin-bottom:20px;
|
||||
font-size:12px;
|
||||
line-height:16px;
|
||||
width:40px;
|
||||
height:20px;
|
||||
-webkit-border-radius:18px;
|
||||
-moz-border-radius:18px;
|
||||
border-radius:18px;
|
||||
background:#f8f8f8;
|
||||
cursor:pointer;
|
||||
-webkit-transition:.25s ease-in-out;
|
||||
-moz-transition:.25s ease-in-out;
|
||||
-o-transition:.25s ease-in-out;
|
||||
transition:.25s ease-in-out;
|
||||
}
|
||||
.checkbox-label:before {
|
||||
content:'';
|
||||
display:block;
|
||||
position:absolute;
|
||||
z-index:1;
|
||||
line-height:34px;
|
||||
text-indent:40px;
|
||||
height:20px;
|
||||
width:20px;
|
||||
-webkit-border-radius:100%;
|
||||
-moz-border-radius:100%;
|
||||
border-radius:100%;
|
||||
top:0px;
|
||||
left:0px;
|
||||
right:auto;
|
||||
background:white;
|
||||
-webkit-box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
|
||||
-moz-box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
|
||||
box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
|
||||
-webkit-transition:.25s ease-in-out;
|
||||
-moz-transition:.25s ease-in-out;
|
||||
-o-transition:.25s ease-in-out;
|
||||
transition:.25s ease-in-out;
|
||||
}
|
||||
.checkbox-label:after {
|
||||
content: attr(data-off);
|
||||
font-size: 13px;
|
||||
display: block;
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
top: 0;
|
||||
left: 50px;
|
||||
padding: 0;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
width: 36px;
|
||||
text-align: left;
|
||||
color: #BFBFBF;
|
||||
white-space: nowrap;
|
||||
-webkit-transition: .25s ease-in-out;
|
||||
-moz-transition: .25s ease-in-out;
|
||||
-o-transition: .25s ease-in-out;
|
||||
transition: .25s ease-in-out;
|
||||
}
|
||||
/* Switch CHECKBOX */
|
||||
.switch-checkbox + .checkbox-label {
|
||||
-webkit-box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
|
||||
-moz-box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
|
||||
box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
|
||||
background: #dddddd;
|
||||
}
|
||||
.switch-checkbox:checked + .checkbox-label {
|
||||
-webkit-box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
|
||||
-moz-box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
|
||||
box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
|
||||
background: #0094DD;
|
||||
}
|
||||
.switch-checkbox:checked + .checkbox-label:after {
|
||||
color:#0094DD;
|
||||
-webkit-transition:.25s ease-in-out;
|
||||
-moz-transition:.25s ease-in-out;
|
||||
-o-transition:.25s ease-in-out;
|
||||
transition:.25s ease-in-out;
|
||||
}
|
||||
|
||||
/* Toggle Checkbox */
|
||||
.ios-toggle:checked + .checkbox-label {
|
||||
-webkit-box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
|
||||
-moz-box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
|
||||
box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
|
||||
}
|
||||
.ios-toggle:checked + .checkbox-label:before {
|
||||
left:calc(100% - 21px);
|
||||
-webkit-box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
|
||||
-moz-box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
|
||||
box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
|
||||
-webkit-transition:.25s ease-in-out;
|
||||
-moz-transition:.25s ease-in-out;
|
||||
-o-transition:.25s ease-in-out;
|
||||
transition:.25s ease-in-out;
|
||||
}
|
||||
.ios-toggle:checked + .checkbox-label:after {
|
||||
content:attr(data-on);
|
||||
-webkit-transition:.25s ease-in-out;
|
||||
-moz-transition:.25s ease-in-out;
|
||||
-o-transition:.25s ease-in-out;
|
||||
transition:.25s ease-in-out;
|
||||
}
|
||||
.ios-toggle[type=checkbox] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.brainstorm-updater-switch {
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>Generated by IcoMoon</metadata>
|
||||
<defs>
|
||||
<font id="icomoon" horiz-adv-x="1024">
|
||||
<font-face units-per-em="1024" ascent="960" descent="-64" />
|
||||
<missing-glyph horiz-adv-x="1024" />
|
||||
<glyph unicode=" " d="" horiz-adv-x="512" />
|
||||
<glyph unicode="" d="M467.577-21.5c-2.284 7.369-0.104 15.762 7.18 20.556 10.155 6.679 25.5 20.586 84.534 27.952 35.525 4.396-8.694-54.877-3.142-34.181 1.955 7.287-25.91 1.952-25.91 1.952s-46.553-8.773-58.643-24.894c0 0-1.733 2.227-4.019 8.615zM138.271 557.027c0 0 15.887 237.492 368.384 222.11 0 0 146.319-12.099 215.165-56.96 0 0-293.96 10.546-583.551-165.149zM181.807 507.887c0 0 203.521 128.399 558.772 144.239 0 0 48.21-0.329 72.158-35.208 0 0 14.367-31.64 14.086-88.5 0 0-48.229-1.442-85.408-2.723 0 0-355.977-11.586-537.674-199.511 12.648 44.529-121.089 119.532-21.934 181.703zM255.72 238.57c0 0-14.079 43.451 43.498 69.493 54.329 24.572 127.831 96.191 426.625 133.305 0 0 124.558 25.427 48.884-54.439-84.28-88.948-100.337-111.947-100.337-111.947s-22.41-25.55-14.155 5.204c8.255 30.756-120.967 22.15-120.967 22.15s-201.788-45.676-252.733-113.604c0 0-21.178 22.924-30.816 49.839zM369.409 146.887c0 0 106.32 73.825 227.492 55.88 0 0 29.174-1.921-1.115-22.419-30.29-20.503-226.376-33.461-226.376-33.461zM418.719 53.659c0 0-11.482 30.506 7.413 36.941s36.903 30.834 136.907 41.988c40.619-4.038 1.169-110.607-7.296-79.135 2.763 10.295-10.126 9.762-10.126 9.762s-93.985-18.303-111.035-41.039c0 0-12.635 22.476-15.862 31.483zM899.013 687.749c92.851-208.867-26.868-487.037-271.661-536.994 233.968 65.7 273.711 363.944 218.284 497.451-81.853 197.157-343.286 268.698-505.34 206.428-162.056-62.269-203.018-122.175-238.522-224.811 32.087 89.126 91.171 209.056 273.127 278.972 181.958 69.917 431.262-12.179 524.112-221.047z" />
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>Generated by IcoMoon</metadata>
|
||||
<defs>
|
||||
<font id="icomoon" horiz-adv-x="1024">
|
||||
<font-face units-per-em="1024" ascent="960" descent="-64" />
|
||||
<missing-glyph horiz-adv-x="1024" />
|
||||
<glyph unicode=" " d="" horiz-adv-x="512" />
|
||||
<glyph unicode="" d="M467.577-21.5c-2.284 7.369-0.104 15.762 7.18 20.556 10.155 6.679 25.5 20.586 84.534 27.952 35.525 4.396-8.694-54.877-3.142-34.181 1.955 7.287-25.91 1.952-25.91 1.952s-46.553-8.773-58.643-24.894c0 0-1.733 2.227-4.019 8.615zM138.271 557.027c0 0 15.887 237.492 368.384 222.11 0 0 146.319-12.099 215.165-56.96 0 0-293.96 10.546-583.551-165.149zM181.807 507.887c0 0 203.521 128.399 558.772 144.239 0 0 48.21-0.329 72.158-35.208 0 0 14.367-31.64 14.086-88.5 0 0-48.229-1.442-85.408-2.723 0 0-355.977-11.586-537.674-199.511 12.648 44.529-121.089 119.532-21.934 181.703zM255.72 238.57c0 0-14.079 43.451 43.498 69.493 54.329 24.572 127.831 96.191 426.625 133.305 0 0 124.558 25.427 48.884-54.439-84.28-88.948-100.337-111.947-100.337-111.947s-22.41-25.55-14.155 5.204c8.255 30.756-120.967 22.15-120.967 22.15s-201.788-45.676-252.733-113.604c0 0-21.178 22.924-30.816 49.839zM369.409 146.887c0 0 106.32 73.825 227.492 55.88 0 0 29.174-1.921-1.115-22.419-30.29-20.503-226.376-33.461-226.376-33.461zM418.719 53.659c0 0-11.482 30.506 7.413 36.941s36.903 30.834 136.907 41.988c40.619-4.038 1.169-110.607-7.296-79.135 2.763 10.295-10.126 9.762-10.126 9.762s-93.985-18.303-111.035-41.039c0 0-12.635 22.476-15.862 31.483zM899.013 687.749c92.851-208.867-26.868-487.037-271.661-536.994 233.968 65.7 273.711 363.944 218.284 497.451-81.853 197.157-343.286 268.698-505.34 206.428-162.056-62.269-203.018-122.175-238.522-224.811 32.087 89.126 91.171 209.056 273.127 278.972 181.958 69.917 431.262-12.179 524.112-221.047z" />
|
||||
</font></defs></svg>
|
||||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
@@ -1,32 +1,32 @@
|
||||
jQuery( document ).on('click', '.bsf-envato-form-activation', function(event) {
|
||||
submitButton = jQuery( this ).parent('.submit-button-wrap');
|
||||
console.log(submitButton);
|
||||
product_id = submitButton.siblings( 'form input[name="product_id"]' ).val();
|
||||
url = submitButton.siblings( 'form input[name="url"]' ).val();
|
||||
redirect = submitButton.siblings( 'form input[name="redirect"]' ).val();
|
||||
privacyConsent = submitButton.siblings( 'input#bsf-license-privacy-consent').val();
|
||||
termsConditionConsent = submitButton.siblings( 'input#bsf-license-terms-conditions-consent').val();
|
||||
envato_activation_nonce = bsf_core.envato_activation_nonce;
|
||||
jQuery.ajax({
|
||||
url: ajaxurl,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
action: 'bsf_envato_redirect_url',
|
||||
product_id: product_id,
|
||||
url: url,
|
||||
redirect: redirect,
|
||||
privacy_consent: privacyConsent,
|
||||
terms_conditions_consent: termsConditionConsent,
|
||||
envato_activation_nonce: envato_activation_nonce,
|
||||
}
|
||||
})
|
||||
.done(function( response ) {
|
||||
window.location = response.data.url;
|
||||
return true;
|
||||
})
|
||||
.fail(function(e) {
|
||||
return false;
|
||||
});
|
||||
|
||||
return false;
|
||||
jQuery( document ).on('click', '.bsf-envato-form-activation', function(event) {
|
||||
submitButton = jQuery( this ).parent('.submit-button-wrap');
|
||||
console.log(submitButton);
|
||||
product_id = submitButton.siblings( 'form input[name="product_id"]' ).val();
|
||||
url = submitButton.siblings( 'form input[name="url"]' ).val();
|
||||
redirect = submitButton.siblings( 'form input[name="redirect"]' ).val();
|
||||
privacyConsent = submitButton.siblings( 'input#bsf-license-privacy-consent').val();
|
||||
termsConditionConsent = submitButton.siblings( 'input#bsf-license-terms-conditions-consent').val();
|
||||
envato_activation_nonce = bsf_core.envato_activation_nonce;
|
||||
jQuery.ajax({
|
||||
url: ajaxurl,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
action: 'bsf_envato_redirect_url',
|
||||
product_id: product_id,
|
||||
url: url,
|
||||
redirect: redirect,
|
||||
privacy_consent: privacyConsent,
|
||||
terms_conditions_consent: termsConditionConsent,
|
||||
envato_activation_nonce: envato_activation_nonce,
|
||||
}
|
||||
})
|
||||
.done(function( response ) {
|
||||
window.location = response.data.url;
|
||||
return true;
|
||||
})
|
||||
.fail(function(e) {
|
||||
return false;
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
@@ -1,105 +1,105 @@
|
||||
(function ($) {
|
||||
|
||||
var BSFExtensionInstaller = {
|
||||
|
||||
init: function () {
|
||||
$(document).on('click', '.bsf-install-button', BSFExtensionInstaller._installNow);
|
||||
$( document ).on('wp-plugin-installing' , BSFExtensionInstaller._pluginInstalling);
|
||||
$( document ).on('wp-plugin-install-error' , BSFExtensionInstaller._installError);
|
||||
$( document ).on('wp-plugin-install-success' , BSFExtensionInstaller._installSuccess);
|
||||
},
|
||||
|
||||
/**
|
||||
* Install Now
|
||||
*/
|
||||
_installNow: function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var $button = jQuery(event.target),
|
||||
$document = jQuery(document);
|
||||
|
||||
if ( $button.hasClass('updating-message') || $button.hasClass('button-disabled') ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wp.updates.shouldRequestFilesystemCredentials && !wp.updates.ajaxLocked) {
|
||||
wp.updates.requestFilesystemCredentials(event);
|
||||
|
||||
$document.on('credential-modal-cancel', function () {
|
||||
var $message = $('.install-now.updating-message');
|
||||
|
||||
$message
|
||||
.removeClass('updating-message')
|
||||
.text(wp.updates.l10n.installNow);
|
||||
|
||||
wp.a11y.speak(wp.updates.l10n.updateCancel, 'polite');
|
||||
});
|
||||
}
|
||||
|
||||
wp.updates.installPlugin({
|
||||
slug: $button.data('slug')
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Install Success
|
||||
*/
|
||||
_installSuccess: function( event, response ) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// Transform the 'Install' button into an 'Activate' button.
|
||||
var $init = $( '.bsf-extension-' + response.slug ).data('init');
|
||||
var nonce = $( '#bsf_activate_extension_nonce' ).val();
|
||||
|
||||
// WordPress adds "Activate" button after waiting for 1000ms. So we will run our activation after that.
|
||||
setTimeout( function() {
|
||||
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
'action' : 'bsf-extention-activate',
|
||||
'init' : $init,
|
||||
'security' : nonce
|
||||
},
|
||||
})
|
||||
.done(function (result) {
|
||||
|
||||
if( result.success ) {
|
||||
$ext = $('.bsf-extension-' + response.slug );
|
||||
$ext.addClass('bsf-plugin-installed');
|
||||
$ext.find('.bsf-install-button').addClass('bsf-plugin-installed-button').html('Installed <i class="dashicons dashicons-yes"></i>');
|
||||
$ext.find('.bsf-extension-start-install').removeClass('show-install');
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}, 1200 );
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Plugin Installation Error.
|
||||
*/
|
||||
_installError: function( event, response ) {
|
||||
var $card = $( '.bsf-extension-' + response.slug + ' .bsf-extension-start-install-content')
|
||||
$card.html( '<h2>' + response.errorMessage + '</h2>' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Installing Plugin
|
||||
*/
|
||||
_pluginInstalling: function(event, args) {
|
||||
event.preventDefault();
|
||||
$('.bsf-extension-' + args.slug + ' .bsf-extension-start-install').addClass('show-install');
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize BSFExtensionInstaller
|
||||
*/
|
||||
$(function () {
|
||||
BSFExtensionInstaller.init();
|
||||
});
|
||||
(function ($) {
|
||||
|
||||
var BSFExtensionInstaller = {
|
||||
|
||||
init: function () {
|
||||
$(document).on('click', '.bsf-install-button', BSFExtensionInstaller._installNow);
|
||||
$( document ).on('wp-plugin-installing' , BSFExtensionInstaller._pluginInstalling);
|
||||
$( document ).on('wp-plugin-install-error' , BSFExtensionInstaller._installError);
|
||||
$( document ).on('wp-plugin-install-success' , BSFExtensionInstaller._installSuccess);
|
||||
},
|
||||
|
||||
/**
|
||||
* Install Now
|
||||
*/
|
||||
_installNow: function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var $button = jQuery(event.target),
|
||||
$document = jQuery(document);
|
||||
|
||||
if ( $button.hasClass('updating-message') || $button.hasClass('button-disabled') ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wp.updates.shouldRequestFilesystemCredentials && !wp.updates.ajaxLocked) {
|
||||
wp.updates.requestFilesystemCredentials(event);
|
||||
|
||||
$document.on('credential-modal-cancel', function () {
|
||||
var $message = $('.install-now.updating-message');
|
||||
|
||||
$message
|
||||
.removeClass('updating-message')
|
||||
.text(wp.updates.l10n.installNow);
|
||||
|
||||
wp.a11y.speak(wp.updates.l10n.updateCancel, 'polite');
|
||||
});
|
||||
}
|
||||
|
||||
wp.updates.installPlugin({
|
||||
slug: $button.data('slug')
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Install Success
|
||||
*/
|
||||
_installSuccess: function( event, response ) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// Transform the 'Install' button into an 'Activate' button.
|
||||
var $init = $( '.bsf-extension-' + response.slug ).data('init');
|
||||
var nonce = $( '#bsf_activate_extension_nonce' ).val();
|
||||
|
||||
// WordPress adds "Activate" button after waiting for 1000ms. So we will run our activation after that.
|
||||
setTimeout( function() {
|
||||
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
'action' : 'bsf-extention-activate',
|
||||
'init' : $init,
|
||||
'security' : nonce
|
||||
},
|
||||
})
|
||||
.done(function (result) {
|
||||
|
||||
if( result.success ) {
|
||||
$ext = $('.bsf-extension-' + response.slug );
|
||||
$ext.addClass('bsf-plugin-installed');
|
||||
$ext.find('.bsf-install-button').addClass('bsf-plugin-installed-button').html('Installed <i class="dashicons dashicons-yes"></i>');
|
||||
$ext.find('.bsf-extension-start-install').removeClass('show-install');
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}, 1200 );
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Plugin Installation Error.
|
||||
*/
|
||||
_installError: function( event, response ) {
|
||||
var $card = $( '.bsf-extension-' + response.slug + ' .bsf-extension-start-install-content')
|
||||
$card.html( '<h2>' + response.errorMessage + '</h2>' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Installing Plugin
|
||||
*/
|
||||
_pluginInstalling: function(event, args) {
|
||||
event.preventDefault();
|
||||
$('.bsf-extension-' + args.slug + ' .bsf-extension-start-install').addClass('show-install');
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize BSFExtensionInstaller
|
||||
*/
|
||||
$(function () {
|
||||
BSFExtensionInstaller.init();
|
||||
});
|
||||
})(jQuery);
|
||||
@@ -1,263 +1,263 @@
|
||||
/* ========================================================================
|
||||
* Frosty.js v1.0
|
||||
* https://github.com/owensbla/frosty
|
||||
* http://labs.blakeowens.com/frosty
|
||||
*
|
||||
* Plugin boilerplate provied by: http://jqueryboilerplate.com/
|
||||
* ========================================================================
|
||||
* Copyright 2013 Blake Owens
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* ======================================================================== */
|
||||
;(function ($, window, document, undefined) {
|
||||
|
||||
var pluginName = "frosty";
|
||||
var defaults = {
|
||||
attribute: 'title',
|
||||
className: 'tip',
|
||||
content: '',
|
||||
delay: 0,
|
||||
hasArrow: true,
|
||||
html: false,
|
||||
offset: 30,
|
||||
position: 'left',
|
||||
removeTitle: true,
|
||||
selector: false,
|
||||
trigger: 'hover,focus',
|
||||
onHidden: function() {},
|
||||
onShown: function() {},
|
||||
|
||||
};
|
||||
|
||||
|
||||
function Frosty(anchor, options) {
|
||||
this.anchor = anchor;
|
||||
this.$anchor = $(anchor);
|
||||
this.options = $.extend({}, defaults, options, this.$anchor.data());
|
||||
this._defaults = defaults;
|
||||
this._name = pluginName;
|
||||
this.init();
|
||||
}
|
||||
|
||||
Frosty.prototype = {
|
||||
init: function () {
|
||||
this._createTip();
|
||||
this._bindEvents();
|
||||
},
|
||||
|
||||
show: function() {
|
||||
var _this = this,
|
||||
delay = typeof this.options.delay === 'object' ? parseInt(this.options.delay.show) : parseInt(this.options.delay);
|
||||
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = delay === 0 ?
|
||||
this._setState('visible') :
|
||||
setTimeout(function() { _this._setState('visible'); }, delay);
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
var _this = this
|
||||
delay = typeof this.options.delay === 'object' ? parseInt(this.options.delay.hide) : parseInt(this.options.delay);
|
||||
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = delay === 0 ?
|
||||
this._setState('hidden') :
|
||||
setTimeout(function() { _this._setState('hidden'); }, delay);
|
||||
},
|
||||
|
||||
toggle: function() {
|
||||
this.state === 'visible' ? this.hide() : this.show();
|
||||
},
|
||||
|
||||
addClass: function(klass) {
|
||||
console.log("in");
|
||||
if (typeof klass === 'string') { this.$el.addClass(klass); }
|
||||
},
|
||||
|
||||
removeClass: function(klass) {
|
||||
if (typeof klass === 'string') { this.$el.removeClass(klass); }
|
||||
},
|
||||
|
||||
_setState: function(state) {
|
||||
this.state = state;
|
||||
switch (state) {
|
||||
case 'visible':
|
||||
this.$el.appendTo('body');
|
||||
this._checkContent();
|
||||
this._setPosition();
|
||||
this.options.onShown.call(this);
|
||||
this.$anchor.trigger('shown');
|
||||
break;
|
||||
case 'hidden':
|
||||
this.$el.detach();
|
||||
this.options.onHidden.call(this);
|
||||
this.$anchor.trigger('hidden');
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
_checkContent: function() {
|
||||
if (this.options.selector) {
|
||||
this.tipContent = $(this.options.selector).html();
|
||||
this.$el.html(this.tipContent);
|
||||
}
|
||||
},
|
||||
|
||||
_createTip: function() {
|
||||
if (this.options.html) {
|
||||
this.tipContent = this.options.content;
|
||||
} else if (this.options.selector) {
|
||||
this.tipContent = $(this.options.selector).html();
|
||||
} else {
|
||||
this.tipContent = this.$anchor.attr(this.options.attribute);
|
||||
if (this.options.attribute === 'title' && this.options.removeTitle) {
|
||||
this.$anchor.attr('data-original-title', this.tipContent);
|
||||
this.$anchor.removeAttr('title');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.$el = $('<div />', {
|
||||
'class': this.options.className,
|
||||
html: '<span class="cp_tooltip_text">'+this.tipContent+'</span>'
|
||||
}).css({
|
||||
'z-index': '9999999999',
|
||||
'left': '-9999px',
|
||||
'position': 'absolute',
|
||||
|
||||
});
|
||||
|
||||
this.$el.appendTo('body');
|
||||
var coords = this.getPosition();
|
||||
this.$el.detach().css(coords);
|
||||
|
||||
if (this.options.hasArrow) { this._addArrowClass(); }
|
||||
},
|
||||
|
||||
_addArrowClass: function() {
|
||||
switch (this.options.position) {
|
||||
case 'left':
|
||||
this.$el.addClass('arrow-right');
|
||||
break;
|
||||
case 'right':
|
||||
this.$el.addClass('arrow-left');
|
||||
break;
|
||||
case 'bottom':
|
||||
this.$el.addClass('arrow-top');
|
||||
break;
|
||||
default:
|
||||
this.$el.addClass('arrow-bottom');
|
||||
}
|
||||
},
|
||||
|
||||
_bindEvents: function() {
|
||||
switch (this.options.trigger) {
|
||||
case 'click':
|
||||
this.$anchor.click($.proxy(this.toggle, this));
|
||||
break
|
||||
case 'manual':
|
||||
break;
|
||||
case 'focus':
|
||||
this.$anchor.focus($.proxy(this.show, this));
|
||||
this.$anchor.blur($.proxy(this.hide, this));
|
||||
break;
|
||||
default:
|
||||
this.$anchor.hover($.proxy(this.show, this), $.proxy(this.hide, this));
|
||||
}
|
||||
|
||||
//$(window).resize($.proxy(this._setPosition, this));
|
||||
},
|
||||
|
||||
getPosition: function () {
|
||||
var coords = this.$anchor.offset();
|
||||
switch (this.options.position) {
|
||||
case 'left':
|
||||
coords.left = coords.left - this.$el.outerWidth() - this.options.offset;
|
||||
coords.top = coords.top + (this.$anchor.outerHeight() / 2) - (this.$el.outerHeight() / 2);
|
||||
break;
|
||||
case 'right':
|
||||
coords.left = coords.left + this.$anchor.outerWidth() + this.options.offset;
|
||||
coords.top = coords.top + (this.$anchor.outerHeight() / 2) - (this.$el.outerHeight() / 2);
|
||||
break;
|
||||
case 'bottom':
|
||||
coords.top = coords.top + this.$anchor.outerHeight() + this.options.offset;
|
||||
coords.left = coords.left + (this.$anchor.outerWidth() / 2) - (this.$el.outerWidth() / 2);
|
||||
break;
|
||||
default:
|
||||
coords.top = coords.top - this.$el.outerHeight() - this.options.offset;
|
||||
var left = coords.left + (this.$anchor.outerWidth() / 2) - (this.$el.outerWidth() / 2);
|
||||
if( left < 0 )
|
||||
left = 0;
|
||||
coords.left = left;
|
||||
}
|
||||
//console.log(coords);
|
||||
return coords;
|
||||
},
|
||||
|
||||
_setPosition: function() {
|
||||
this.$el.css(this.getPosition());
|
||||
}
|
||||
};
|
||||
|
||||
$.fn[pluginName] = function (options, args) {
|
||||
//console.log($.data(this, "plugin_" + pluginName));
|
||||
if (typeof options === 'string') {
|
||||
//console.log(options);
|
||||
switch (options) {
|
||||
case 'show':
|
||||
this.each(function() { $.data(this, "plugin_" + pluginName)['show'](); });
|
||||
break;
|
||||
case 'hide':
|
||||
this.each(function() { $.data(this, "plugin_" + pluginName)['hide'](); });
|
||||
break;
|
||||
case 'toggle':
|
||||
this.each(function() { $.data(this, "plugin_" + pluginName)['toggle'](); });
|
||||
break;
|
||||
case 'addClass':
|
||||
this.each(function() { $.data(this, "plugin_" + pluginName)['addClass'](args); });
|
||||
break;
|
||||
case 'removeClass':
|
||||
this.each(function() { $.data(this, "plugin_" + pluginName)['removeClass'](args); });
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this.each(function () {
|
||||
if (!$.data(this, "plugin_" + pluginName)) {
|
||||
$.data(this, "plugin_" + pluginName, new Frosty(this, options));
|
||||
}
|
||||
});
|
||||
};
|
||||
})(jQuery, window, document);
|
||||
|
||||
(function($){
|
||||
$(document).ready(function(){
|
||||
$('.bsf-has-tip, .has-tip').each(function(i,tip){
|
||||
$tip = $(tip);
|
||||
var attribute = (typeof $tip.attr('data-attribute') != 'undefined') ? $tip.attr('data-attribute') : 'title';
|
||||
var offset = (typeof $tip.attr('data-offset') != 'undefined') ? $tip.attr('data-offset') : 10;
|
||||
var position = (typeof $tip.attr('data-position') != 'undefined') ? $tip.attr('data-position') : 'top';
|
||||
var trigger = (typeof $tip.attr('data-trigger')) ? $tip.attr('data-trigger') : 'hover,focus';
|
||||
var className = (typeof $tip.attr('data-classes') != 'undefined') ? 'tip '+$tip.attr('data-classes') : 'tip';
|
||||
$tip.frosty({
|
||||
className : className,
|
||||
attribute: attribute,
|
||||
offset: offset,
|
||||
position: position,
|
||||
trigger: trigger
|
||||
});
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
/* ========================================================================
|
||||
* Frosty.js v1.0
|
||||
* https://github.com/owensbla/frosty
|
||||
* http://labs.blakeowens.com/frosty
|
||||
*
|
||||
* Plugin boilerplate provied by: http://jqueryboilerplate.com/
|
||||
* ========================================================================
|
||||
* Copyright 2013 Blake Owens
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* ======================================================================== */
|
||||
;(function ($, window, document, undefined) {
|
||||
|
||||
var pluginName = "frosty";
|
||||
var defaults = {
|
||||
attribute: 'title',
|
||||
className: 'tip',
|
||||
content: '',
|
||||
delay: 0,
|
||||
hasArrow: true,
|
||||
html: false,
|
||||
offset: 30,
|
||||
position: 'left',
|
||||
removeTitle: true,
|
||||
selector: false,
|
||||
trigger: 'hover,focus',
|
||||
onHidden: function() {},
|
||||
onShown: function() {},
|
||||
|
||||
};
|
||||
|
||||
|
||||
function Frosty(anchor, options) {
|
||||
this.anchor = anchor;
|
||||
this.$anchor = $(anchor);
|
||||
this.options = $.extend({}, defaults, options, this.$anchor.data());
|
||||
this._defaults = defaults;
|
||||
this._name = pluginName;
|
||||
this.init();
|
||||
}
|
||||
|
||||
Frosty.prototype = {
|
||||
init: function () {
|
||||
this._createTip();
|
||||
this._bindEvents();
|
||||
},
|
||||
|
||||
show: function() {
|
||||
var _this = this,
|
||||
delay = typeof this.options.delay === 'object' ? parseInt(this.options.delay.show) : parseInt(this.options.delay);
|
||||
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = delay === 0 ?
|
||||
this._setState('visible') :
|
||||
setTimeout(function() { _this._setState('visible'); }, delay);
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
var _this = this
|
||||
delay = typeof this.options.delay === 'object' ? parseInt(this.options.delay.hide) : parseInt(this.options.delay);
|
||||
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = delay === 0 ?
|
||||
this._setState('hidden') :
|
||||
setTimeout(function() { _this._setState('hidden'); }, delay);
|
||||
},
|
||||
|
||||
toggle: function() {
|
||||
this.state === 'visible' ? this.hide() : this.show();
|
||||
},
|
||||
|
||||
addClass: function(klass) {
|
||||
console.log("in");
|
||||
if (typeof klass === 'string') { this.$el.addClass(klass); }
|
||||
},
|
||||
|
||||
removeClass: function(klass) {
|
||||
if (typeof klass === 'string') { this.$el.removeClass(klass); }
|
||||
},
|
||||
|
||||
_setState: function(state) {
|
||||
this.state = state;
|
||||
switch (state) {
|
||||
case 'visible':
|
||||
this.$el.appendTo('body');
|
||||
this._checkContent();
|
||||
this._setPosition();
|
||||
this.options.onShown.call(this);
|
||||
this.$anchor.trigger('shown');
|
||||
break;
|
||||
case 'hidden':
|
||||
this.$el.detach();
|
||||
this.options.onHidden.call(this);
|
||||
this.$anchor.trigger('hidden');
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
_checkContent: function() {
|
||||
if (this.options.selector) {
|
||||
this.tipContent = $(this.options.selector).html();
|
||||
this.$el.html(this.tipContent);
|
||||
}
|
||||
},
|
||||
|
||||
_createTip: function() {
|
||||
if (this.options.html) {
|
||||
this.tipContent = this.options.content;
|
||||
} else if (this.options.selector) {
|
||||
this.tipContent = $(this.options.selector).html();
|
||||
} else {
|
||||
this.tipContent = this.$anchor.attr(this.options.attribute);
|
||||
if (this.options.attribute === 'title' && this.options.removeTitle) {
|
||||
this.$anchor.attr('data-original-title', this.tipContent);
|
||||
this.$anchor.removeAttr('title');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.$el = $('<div />', {
|
||||
'class': this.options.className,
|
||||
html: '<span class="cp_tooltip_text">'+this.tipContent+'</span>'
|
||||
}).css({
|
||||
'z-index': '9999999999',
|
||||
'left': '-9999px',
|
||||
'position': 'absolute',
|
||||
|
||||
});
|
||||
|
||||
this.$el.appendTo('body');
|
||||
var coords = this.getPosition();
|
||||
this.$el.detach().css(coords);
|
||||
|
||||
if (this.options.hasArrow) { this._addArrowClass(); }
|
||||
},
|
||||
|
||||
_addArrowClass: function() {
|
||||
switch (this.options.position) {
|
||||
case 'left':
|
||||
this.$el.addClass('arrow-right');
|
||||
break;
|
||||
case 'right':
|
||||
this.$el.addClass('arrow-left');
|
||||
break;
|
||||
case 'bottom':
|
||||
this.$el.addClass('arrow-top');
|
||||
break;
|
||||
default:
|
||||
this.$el.addClass('arrow-bottom');
|
||||
}
|
||||
},
|
||||
|
||||
_bindEvents: function() {
|
||||
switch (this.options.trigger) {
|
||||
case 'click':
|
||||
this.$anchor.click($.proxy(this.toggle, this));
|
||||
break
|
||||
case 'manual':
|
||||
break;
|
||||
case 'focus':
|
||||
this.$anchor.focus($.proxy(this.show, this));
|
||||
this.$anchor.blur($.proxy(this.hide, this));
|
||||
break;
|
||||
default:
|
||||
this.$anchor.hover($.proxy(this.show, this), $.proxy(this.hide, this));
|
||||
}
|
||||
|
||||
//$(window).resize($.proxy(this._setPosition, this));
|
||||
},
|
||||
|
||||
getPosition: function () {
|
||||
var coords = this.$anchor.offset();
|
||||
switch (this.options.position) {
|
||||
case 'left':
|
||||
coords.left = coords.left - this.$el.outerWidth() - this.options.offset;
|
||||
coords.top = coords.top + (this.$anchor.outerHeight() / 2) - (this.$el.outerHeight() / 2);
|
||||
break;
|
||||
case 'right':
|
||||
coords.left = coords.left + this.$anchor.outerWidth() + this.options.offset;
|
||||
coords.top = coords.top + (this.$anchor.outerHeight() / 2) - (this.$el.outerHeight() / 2);
|
||||
break;
|
||||
case 'bottom':
|
||||
coords.top = coords.top + this.$anchor.outerHeight() + this.options.offset;
|
||||
coords.left = coords.left + (this.$anchor.outerWidth() / 2) - (this.$el.outerWidth() / 2);
|
||||
break;
|
||||
default:
|
||||
coords.top = coords.top - this.$el.outerHeight() - this.options.offset;
|
||||
var left = coords.left + (this.$anchor.outerWidth() / 2) - (this.$el.outerWidth() / 2);
|
||||
if( left < 0 )
|
||||
left = 0;
|
||||
coords.left = left;
|
||||
}
|
||||
//console.log(coords);
|
||||
return coords;
|
||||
},
|
||||
|
||||
_setPosition: function() {
|
||||
this.$el.css(this.getPosition());
|
||||
}
|
||||
};
|
||||
|
||||
$.fn[pluginName] = function (options, args) {
|
||||
//console.log($.data(this, "plugin_" + pluginName));
|
||||
if (typeof options === 'string') {
|
||||
//console.log(options);
|
||||
switch (options) {
|
||||
case 'show':
|
||||
this.each(function() { $.data(this, "plugin_" + pluginName)['show'](); });
|
||||
break;
|
||||
case 'hide':
|
||||
this.each(function() { $.data(this, "plugin_" + pluginName)['hide'](); });
|
||||
break;
|
||||
case 'toggle':
|
||||
this.each(function() { $.data(this, "plugin_" + pluginName)['toggle'](); });
|
||||
break;
|
||||
case 'addClass':
|
||||
this.each(function() { $.data(this, "plugin_" + pluginName)['addClass'](args); });
|
||||
break;
|
||||
case 'removeClass':
|
||||
this.each(function() { $.data(this, "plugin_" + pluginName)['removeClass'](args); });
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this.each(function () {
|
||||
if (!$.data(this, "plugin_" + pluginName)) {
|
||||
$.data(this, "plugin_" + pluginName, new Frosty(this, options));
|
||||
}
|
||||
});
|
||||
};
|
||||
})(jQuery, window, document);
|
||||
|
||||
(function($){
|
||||
$(document).ready(function(){
|
||||
$('.bsf-has-tip, .has-tip').each(function(i,tip){
|
||||
$tip = $(tip);
|
||||
var attribute = (typeof $tip.attr('data-attribute') != 'undefined') ? $tip.attr('data-attribute') : 'title';
|
||||
var offset = (typeof $tip.attr('data-offset') != 'undefined') ? $tip.attr('data-offset') : 10;
|
||||
var position = (typeof $tip.attr('data-position') != 'undefined') ? $tip.attr('data-position') : 'top';
|
||||
var trigger = (typeof $tip.attr('data-trigger')) ? $tip.attr('data-trigger') : 'hover,focus';
|
||||
var className = (typeof $tip.attr('data-classes') != 'undefined') ? 'tip '+$tip.attr('data-classes') : 'tip';
|
||||
$tip.frosty({
|
||||
className : className,
|
||||
attribute: attribute,
|
||||
offset: offset,
|
||||
position: position,
|
||||
trigger: trigger
|
||||
});
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
@@ -1,151 +1,151 @@
|
||||
(function($){
|
||||
|
||||
BSFCoreLicenseForm = {
|
||||
|
||||
/**
|
||||
* Init
|
||||
*/
|
||||
init: function()
|
||||
{
|
||||
this._showFormOnLoad();
|
||||
this._bind();
|
||||
},
|
||||
|
||||
/**
|
||||
* Binds events
|
||||
*/
|
||||
_bind: function()
|
||||
{
|
||||
$( document ).on('click', '.bsf-core-license-form-btn', BSFCoreLicenseForm._showFormOnClick);
|
||||
$( document ).on('click', '.bsf-core-license-form-close-btn', BSFCoreLicenseForm._closeForm);
|
||||
$( document ).on('click', '.bsf-core-license-form .bsf-core-license-form-overlay', BSFCoreLicenseForm._closeForm);
|
||||
},
|
||||
|
||||
_changeURL: function( url )
|
||||
{
|
||||
History.pushState(null, null, url);
|
||||
},
|
||||
|
||||
/**
|
||||
* Show form on Load
|
||||
*/
|
||||
_showFormOnLoad: function( e )
|
||||
{
|
||||
if( BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
|
||||
var slug = BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form');
|
||||
BSFCoreLicenseForm._showForm( slug );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Show form on Click
|
||||
*/
|
||||
_showFormOnClick: function( e )
|
||||
{
|
||||
// don't override click action if the link is not from the popup form.
|
||||
var licenseFormURl = $( this ).attr('href') || '';
|
||||
|
||||
if ( null !== BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form', licenseFormURl) ||
|
||||
true === $( this ).hasClass('bsf-core-plugin-link') ) {
|
||||
e.preventDefault();
|
||||
var slug = $( this ).attr('plugin-slug') || '';
|
||||
var url_params = {'bsf-inline-license-form':slug};
|
||||
BSFCoreLicenseForm._showForm( slug );
|
||||
|
||||
// Change URL.
|
||||
if( ! BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
|
||||
var current_url = window.location.href;
|
||||
var current_url_separator = ( window.location.href.indexOf( "?" ) === -1 ) ? "?" : "&";
|
||||
|
||||
var new_url = current_url + current_url_separator + decodeURIComponent( $.param( url_params ) );
|
||||
|
||||
BSFCoreLicenseForm._changeURL( new_url );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Show form by slug
|
||||
*/
|
||||
_showForm: function( slug )
|
||||
{
|
||||
if( $(".bsf-core-license-form[plugin-slug='"+slug+"']").length ) {
|
||||
$(".bsf-core-license-form[plugin-slug='"+slug+"']").show();
|
||||
$('body').addClass('bsf-core-license-form-open');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Close form.
|
||||
*/
|
||||
_closeForm: function( e )
|
||||
{
|
||||
e.preventDefault();
|
||||
|
||||
$('.bsf-core-license-form').hide();
|
||||
$('body').removeClass('bsf-core-license-form-open');
|
||||
|
||||
if( BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
|
||||
|
||||
var url_params = BSFCoreLicenseForm._getQueryStrings();
|
||||
delete url_params['bsf-inline-license-form'];
|
||||
delete url_params['bsf-inline-license-form'];
|
||||
delete url_params['license_action'];
|
||||
delete url_params['token'];
|
||||
delete url_params['product_id'];
|
||||
delete url_params['purchase_key'];
|
||||
delete url_params['success'];
|
||||
delete url_params['status'];
|
||||
delete url_params['message'];
|
||||
delete url_params['debug'];
|
||||
delete url_params['activation_method'];
|
||||
|
||||
var current_url = window.location.href;
|
||||
var root_url = current_url.substr(0, current_url.indexOf('?'));
|
||||
if( jQuery.isEmptyObject( url_params ) ) {
|
||||
var new_url = root_url + decodeURIComponent( $.param( url_params ) );
|
||||
} else {
|
||||
var current_url_separator = ( root_url.indexOf( "?" ) === -1 ) ? "?" : "&";
|
||||
var new_url = root_url + current_url_separator + decodeURIComponent( $.param( url_params ) );
|
||||
}
|
||||
|
||||
// Change URL.
|
||||
BSFCoreLicenseForm._changeURL( new_url );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Get URL param.
|
||||
*/
|
||||
_getParamFromURL: function(name, url)
|
||||
{
|
||||
if (!url) url = window.location.href;
|
||||
name = name.replace(/[\[\]]/g, "\\$&");
|
||||
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
|
||||
results = regex.exec(url);
|
||||
if (!results) return null;
|
||||
if (!results[2]) return '';
|
||||
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
||||
},
|
||||
|
||||
/**
|
||||
* Get query strings.
|
||||
*/
|
||||
_getQueryStrings( str )
|
||||
{
|
||||
return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialization
|
||||
*/
|
||||
$(function(){
|
||||
BSFCoreLicenseForm.init();
|
||||
});
|
||||
|
||||
(function($){
|
||||
|
||||
BSFCoreLicenseForm = {
|
||||
|
||||
/**
|
||||
* Init
|
||||
*/
|
||||
init: function()
|
||||
{
|
||||
this._showFormOnLoad();
|
||||
this._bind();
|
||||
},
|
||||
|
||||
/**
|
||||
* Binds events
|
||||
*/
|
||||
_bind: function()
|
||||
{
|
||||
$( document ).on('click', '.bsf-core-license-form-btn', BSFCoreLicenseForm._showFormOnClick);
|
||||
$( document ).on('click', '.bsf-core-license-form-close-btn', BSFCoreLicenseForm._closeForm);
|
||||
$( document ).on('click', '.bsf-core-license-form .bsf-core-license-form-overlay', BSFCoreLicenseForm._closeForm);
|
||||
},
|
||||
|
||||
_changeURL: function( url )
|
||||
{
|
||||
History.pushState(null, null, url);
|
||||
},
|
||||
|
||||
/**
|
||||
* Show form on Load
|
||||
*/
|
||||
_showFormOnLoad: function( e )
|
||||
{
|
||||
if( BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
|
||||
var slug = BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form');
|
||||
BSFCoreLicenseForm._showForm( slug );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Show form on Click
|
||||
*/
|
||||
_showFormOnClick: function( e )
|
||||
{
|
||||
// don't override click action if the link is not from the popup form.
|
||||
var licenseFormURl = $( this ).attr('href') || '';
|
||||
|
||||
if ( null !== BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form', licenseFormURl) ||
|
||||
true === $( this ).hasClass('bsf-core-plugin-link') ) {
|
||||
e.preventDefault();
|
||||
var slug = $( this ).attr('plugin-slug') || '';
|
||||
var url_params = {'bsf-inline-license-form':slug};
|
||||
BSFCoreLicenseForm._showForm( slug );
|
||||
|
||||
// Change URL.
|
||||
if( ! BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
|
||||
var current_url = window.location.href;
|
||||
var current_url_separator = ( window.location.href.indexOf( "?" ) === -1 ) ? "?" : "&";
|
||||
|
||||
var new_url = current_url + current_url_separator + decodeURIComponent( $.param( url_params ) );
|
||||
|
||||
BSFCoreLicenseForm._changeURL( new_url );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Show form by slug
|
||||
*/
|
||||
_showForm: function( slug )
|
||||
{
|
||||
if( $(".bsf-core-license-form[plugin-slug='"+slug+"']").length ) {
|
||||
$(".bsf-core-license-form[plugin-slug='"+slug+"']").show();
|
||||
$('body').addClass('bsf-core-license-form-open');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Close form.
|
||||
*/
|
||||
_closeForm: function( e )
|
||||
{
|
||||
e.preventDefault();
|
||||
|
||||
$('.bsf-core-license-form').hide();
|
||||
$('body').removeClass('bsf-core-license-form-open');
|
||||
|
||||
if( BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
|
||||
|
||||
var url_params = BSFCoreLicenseForm._getQueryStrings();
|
||||
delete url_params['bsf-inline-license-form'];
|
||||
delete url_params['bsf-inline-license-form'];
|
||||
delete url_params['license_action'];
|
||||
delete url_params['token'];
|
||||
delete url_params['product_id'];
|
||||
delete url_params['purchase_key'];
|
||||
delete url_params['success'];
|
||||
delete url_params['status'];
|
||||
delete url_params['message'];
|
||||
delete url_params['debug'];
|
||||
delete url_params['activation_method'];
|
||||
|
||||
var current_url = window.location.href;
|
||||
var root_url = current_url.substr(0, current_url.indexOf('?'));
|
||||
if( jQuery.isEmptyObject( url_params ) ) {
|
||||
var new_url = root_url + decodeURIComponent( $.param( url_params ) );
|
||||
} else {
|
||||
var current_url_separator = ( root_url.indexOf( "?" ) === -1 ) ? "?" : "&";
|
||||
var new_url = root_url + current_url_separator + decodeURIComponent( $.param( url_params ) );
|
||||
}
|
||||
|
||||
// Change URL.
|
||||
BSFCoreLicenseForm._changeURL( new_url );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Get URL param.
|
||||
*/
|
||||
_getParamFromURL: function(name, url)
|
||||
{
|
||||
if (!url) url = window.location.href;
|
||||
name = name.replace(/[\[\]]/g, "\\$&");
|
||||
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
|
||||
results = regex.exec(url);
|
||||
if (!results) return null;
|
||||
if (!results[2]) return '';
|
||||
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
||||
},
|
||||
|
||||
/**
|
||||
* Get query strings.
|
||||
*/
|
||||
_getQueryStrings( str )
|
||||
{
|
||||
return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialization
|
||||
*/
|
||||
$(function(){
|
||||
BSFCoreLicenseForm.init();
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
@@ -1,16 +1,16 @@
|
||||
jQuery(document).ready(function(){
|
||||
var switch_btn = jQuery(".bsf-switch-btn");
|
||||
jQuery(document).on('click', '.bsf-switch-btn', function(e){
|
||||
var id = jQuery(this).data('id');
|
||||
var value = jQuery(this).parents(".switch-wrapper").find("#"+id).val();
|
||||
|
||||
if( value == 1 || value == '1' ) {
|
||||
jQuery(this).parents(".switch-wrapper").find("#"+id).attr('value','0');
|
||||
} else {
|
||||
jQuery(this).parents(".switch-wrapper").find("#"+id).attr('value','1');
|
||||
}
|
||||
|
||||
jQuery(this).parents(".switch-wrapper").find(".bsf-switch-input").trigger('change');
|
||||
|
||||
});
|
||||
jQuery(document).ready(function(){
|
||||
var switch_btn = jQuery(".bsf-switch-btn");
|
||||
jQuery(document).on('click', '.bsf-switch-btn', function(e){
|
||||
var id = jQuery(this).data('id');
|
||||
var value = jQuery(this).parents(".switch-wrapper").find("#"+id).val();
|
||||
|
||||
if( value == 1 || value == '1' ) {
|
||||
jQuery(this).parents(".switch-wrapper").find("#"+id).attr('value','0');
|
||||
} else {
|
||||
jQuery(this).parents(".switch-wrapper").find("#"+id).attr('value','1');
|
||||
}
|
||||
|
||||
jQuery(this).parents(".switch-wrapper").find(".bsf-switch-input").trigger('change');
|
||||
|
||||
});
|
||||
});
|
||||
@@ -1,61 +1,61 @@
|
||||
|
||||
(function($){
|
||||
var currentRollbackButton;
|
||||
|
||||
rollbackVersion = {
|
||||
init: function() {
|
||||
$( document ).on('change', '.bsf-rollback-version-select' , rollbackVersion.onSelectVersion );
|
||||
$( document ).on('click', '.bsf-rollback-button' , rollbackVersion.onRollbackClick );
|
||||
$( document ).on('click', '.bsf-confirm-cancel' , rollbackVersion.closeRollbackPopup );
|
||||
$( document ).on('click', '.bsf-confirm-ok' , rollbackVersion.onRollbackOk );
|
||||
},
|
||||
|
||||
onSelectVersion:function() {
|
||||
var selectRollback = jQuery( this );
|
||||
rollbackButton = selectRollback.next( '.bsf-rollback-button' )
|
||||
placeholderText = rollbackButton.data( 'placeholder-text' );
|
||||
placeholderUrl = rollbackButton.data( 'placeholder-url' );
|
||||
|
||||
rollbackButton.attr( 'href', placeholderUrl.replace( 'VERSION', selectRollback.val() ) );
|
||||
},
|
||||
|
||||
onRollbackClick: function ( e ) {
|
||||
e.preventDefault();
|
||||
var rollbackButton = jQuery( this );
|
||||
// This will update the current rollback button object.
|
||||
currentRollbackButton = rollbackButton;
|
||||
rollbackHeading = $('.bsf-confirm-heading');
|
||||
rollbackConfirmText = $('.bsf-rollback-text');
|
||||
closestDiv = rollbackButton.closest('.bsf-rollback-version');
|
||||
versionNumber = closestDiv.find('.bsf-rollback-version-select').val();
|
||||
selectProductName = closestDiv.find('#bsf-product-name').val();
|
||||
|
||||
// Rollback Heading text.
|
||||
rollbackHeadingdata = rollbackHeading.data('text').replace( '#PRODUCT_NAME#', selectProductName );
|
||||
rollbackHeading.html( rollbackHeadingdata );
|
||||
// Rollback Confirmation text.
|
||||
rollbackConfirmdata = rollbackConfirmText.data('text').replace( '#PRODUCT_NAME#', selectProductName );
|
||||
rollbackConfirmdata = rollbackConfirmdata.replace( '#VERSION#', versionNumber )
|
||||
rollbackConfirmText.html( rollbackConfirmdata );
|
||||
|
||||
document.querySelector('.bsf-confirm-rollback-popup').style.display = 'block';
|
||||
},
|
||||
|
||||
closeRollbackPopup: function ( e ) {
|
||||
document.querySelector('.bsf-confirm-rollback-popup').style.display = 'none';
|
||||
},
|
||||
|
||||
onRollbackOk:function ( e ) {
|
||||
e.preventDefault();
|
||||
if( currentRollbackButton ){
|
||||
var redirectUrl = currentRollbackButton.closest('.bsf-rollback-version').find('.bsf-rollback-button').attr('href');
|
||||
location.href = redirectUrl;
|
||||
}
|
||||
rollbackVersion.closeRollbackPopup( e );
|
||||
}
|
||||
}
|
||||
|
||||
$( document ).ready(function() {
|
||||
rollbackVersion.init();
|
||||
});
|
||||
})( jQuery );
|
||||
|
||||
(function($){
|
||||
var currentRollbackButton;
|
||||
|
||||
rollbackVersion = {
|
||||
init: function() {
|
||||
$( document ).on('change', '.bsf-rollback-version-select' , rollbackVersion.onSelectVersion );
|
||||
$( document ).on('click', '.bsf-rollback-button' , rollbackVersion.onRollbackClick );
|
||||
$( document ).on('click', '.bsf-confirm-cancel' , rollbackVersion.closeRollbackPopup );
|
||||
$( document ).on('click', '.bsf-confirm-ok' , rollbackVersion.onRollbackOk );
|
||||
},
|
||||
|
||||
onSelectVersion:function() {
|
||||
var selectRollback = jQuery( this );
|
||||
rollbackButton = selectRollback.next( '.bsf-rollback-button' )
|
||||
placeholderText = rollbackButton.data( 'placeholder-text' );
|
||||
placeholderUrl = rollbackButton.data( 'placeholder-url' );
|
||||
|
||||
rollbackButton.attr( 'href', placeholderUrl.replace( 'VERSION', selectRollback.val() ) );
|
||||
},
|
||||
|
||||
onRollbackClick: function ( e ) {
|
||||
e.preventDefault();
|
||||
var rollbackButton = jQuery( this );
|
||||
// This will update the current rollback button object.
|
||||
currentRollbackButton = rollbackButton;
|
||||
rollbackHeading = $('.bsf-confirm-heading');
|
||||
rollbackConfirmText = $('.bsf-rollback-text');
|
||||
closestDiv = rollbackButton.closest('.bsf-rollback-version');
|
||||
versionNumber = closestDiv.find('.bsf-rollback-version-select').val();
|
||||
selectProductName = closestDiv.find('#bsf-product-name').val();
|
||||
|
||||
// Rollback Heading text.
|
||||
rollbackHeadingdata = rollbackHeading.data('text').replace( '#PRODUCT_NAME#', selectProductName );
|
||||
rollbackHeading.html( rollbackHeadingdata );
|
||||
// Rollback Confirmation text.
|
||||
rollbackConfirmdata = rollbackConfirmText.data('text').replace( '#PRODUCT_NAME#', selectProductName );
|
||||
rollbackConfirmdata = rollbackConfirmdata.replace( '#VERSION#', versionNumber )
|
||||
rollbackConfirmText.html( rollbackConfirmdata );
|
||||
|
||||
document.querySelector('.bsf-confirm-rollback-popup').style.display = 'block';
|
||||
},
|
||||
|
||||
closeRollbackPopup: function ( e ) {
|
||||
document.querySelector('.bsf-confirm-rollback-popup').style.display = 'none';
|
||||
},
|
||||
|
||||
onRollbackOk:function ( e ) {
|
||||
e.preventDefault();
|
||||
if( currentRollbackButton ){
|
||||
var redirectUrl = currentRollbackButton.closest('.bsf-rollback-version').find('.bsf-rollback-button').attr('href');
|
||||
location.href = redirectUrl;
|
||||
}
|
||||
rollbackVersion.closeRollbackPopup( e );
|
||||
}
|
||||
}
|
||||
|
||||
$( document ).ready(function() {
|
||||
rollbackVersion.init();
|
||||
});
|
||||
})( jQuery );
|
||||
|
||||
@@ -1,413 +1,413 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin functions.
|
||||
*
|
||||
* @package BSF core
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'bsf_generate_rand_token' ) ) {
|
||||
/**
|
||||
* Generate 32 characters random token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function bsf_generate_rand_token() {
|
||||
$valid_characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||
$token = '';
|
||||
$length = 32;
|
||||
for ( $n = 1; $n < $length; $n++ ) {
|
||||
$which_character = wp_rand( 0, strlen( $valid_characters ) - 1 );
|
||||
$token .= $valid_characters[ $which_character ];
|
||||
}
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update version numbers of all the brainstorm products in options `brainstorm_products` and `brainstrom_bundled_products`
|
||||
*
|
||||
* @todo Current version numbers can be fetched from WordPress at runtime whenever ruquired,
|
||||
* Remote version can only be required when transient for update data is deleted (i hope)
|
||||
*/
|
||||
if ( ! function_exists( 'bsf_update_all_product_version' ) ) {
|
||||
|
||||
/**
|
||||
* Updates all product versions.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function bsf_update_all_product_version() {
|
||||
|
||||
$brainstrom_products = get_option( 'brainstrom_products', array() );
|
||||
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
|
||||
$bsf_product_themes = array();
|
||||
|
||||
if ( ! empty( $brainstrom_products ) ) :
|
||||
$bsf_product_plugins = ( isset( $brainstrom_products['plugins'] ) ) ? $brainstrom_products['plugins'] : array();
|
||||
$bsf_product_themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
|
||||
endif;
|
||||
|
||||
$bundled_product_updated = false;
|
||||
|
||||
if ( ! empty( $bsf_product_plugins ) ) {
|
||||
|
||||
foreach ( $bsf_product_plugins as $key => $plugin ) {
|
||||
if ( ! isset( $plugin['id'] ) || empty( $plugin['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! isset( $plugin['template'] ) || empty( $plugin['template'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! isset( $plugin['type'] ) || empty( $plugin['type'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$version = ( isset( $plugin['version'] ) ) ? $plugin['version'] : '';
|
||||
$current_version = bsf_get_current_version( $plugin['template'], $plugin['type'] );
|
||||
$name = bsf_get_current_name( $plugin['template'], $plugin['type'] );
|
||||
if ( '' !== $name ) {
|
||||
$brainstrom_products['plugins'][ $key ]['product_name'] = $name;
|
||||
}
|
||||
if ( '' !== $current_version ) {
|
||||
if ( version_compare( $version, $current_version ) === - 1 || 1 === version_compare( $version, $current_version ) ) {
|
||||
$brainstrom_products['plugins'][ $key ]['version'] = $current_version;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $bsf_product_themes ) ) {
|
||||
|
||||
foreach ( $bsf_product_themes as $key => $theme ) {
|
||||
if ( ! isset( $theme['id'] ) || empty( $theme['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! isset( $theme['template'] ) || empty( $theme['template'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! isset( $theme['type'] ) || empty( $theme['type'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$version = ( isset( $theme['version'] ) ) ? $theme['version'] : '';
|
||||
$current_version = bsf_get_current_version( $theme['template'], $theme['type'] );
|
||||
$name = bsf_get_current_name( $theme['template'], $theme['type'] );
|
||||
if ( '' !== $name ) {
|
||||
$brainstrom_products['themes'][ $key ]['product_name'] = $name;
|
||||
}
|
||||
if ( '' !== $current_version || false !== $current_version ) {
|
||||
if ( version_compare( $version, $current_version ) === - 1 || 1 === version_compare( $version, $current_version ) ) {
|
||||
$brainstrom_products['themes'][ $key ]['version'] = $current_version;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $brainstrom_bundled_products ) ) {
|
||||
|
||||
foreach ( $brainstrom_bundled_products as $keys => $bps ) {
|
||||
$version = '';
|
||||
if ( strlen( $keys ) > 1 ) {
|
||||
foreach ( $bps as $key => $bp ) {
|
||||
if ( ! isset( $bp->id ) || '' === $bp->id ) {
|
||||
continue;
|
||||
}
|
||||
$version = $bp->version;
|
||||
$current_version = bsf_get_current_version( $bp->init, $bp->type );
|
||||
|
||||
if ( '' !== $current_version && false !== $current_version ) {
|
||||
if ( 1 === - version_compare( $version, $current_version ) || 1 === version_compare( $version, $current_version ) ) {
|
||||
if ( is_object( $brainstrom_bundled_products ) ) {
|
||||
$brainstrom_bundled_products = array( $brainstrom_bundled_products );
|
||||
}
|
||||
$single_bp = $brainstrom_bundled_products[ $keys ];
|
||||
$single_bp[ $key ]->version = $current_version;
|
||||
$bundled_product_updated = true;
|
||||
$brainstrom_bundled_products[ $keys ] = $single_bp;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( ! isset( $bps->id ) || '' === $bps->id ) {
|
||||
continue;
|
||||
}
|
||||
$version = $bps->version;
|
||||
$current_version = bsf_get_current_version( $bps->init, $bps->type );
|
||||
if ( '' !== $current_version || false !== $current_version ) {
|
||||
if ( - 1 === version_compare( $version, $current_version ) || 1 === version_compare( $version, $current_version ) ) {
|
||||
$brainstrom_bundled_products[ $keys ]->version = $current_version;
|
||||
$bundled_product_updated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'brainstrom_products', $brainstrom_products );
|
||||
|
||||
if ( $bundled_product_updated ) {
|
||||
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'admin_init', 'bsf_update_all_product_version', 1000 );
|
||||
|
||||
if ( ! function_exists( 'bsf_get_current_version' ) ) {
|
||||
/**
|
||||
* Get current version of plugin / theme.
|
||||
*
|
||||
* @param string $template plugin template/slug.
|
||||
* @param string $type type of product.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
function bsf_get_current_version( $template, $type ) {
|
||||
if ( '' === $template ) {
|
||||
return false;
|
||||
}
|
||||
if ( 'theme' === $type || 'themes' === $type ) {
|
||||
$theme = wp_get_theme( $template );
|
||||
$version = $theme->get( 'Version' );
|
||||
} elseif ( 'plugin' === $type || 'plugins' === $type ) {
|
||||
$plugin_file = rtrim( WP_PLUGIN_DIR, '/' ) . '/' . $template;
|
||||
if ( ! is_file( $plugin_file ) ) {
|
||||
return false;
|
||||
}
|
||||
$plugin = get_plugin_data( $plugin_file );
|
||||
$version = $plugin['Version'];
|
||||
}
|
||||
return $version;
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'bsf_get_current_name' ) ) {
|
||||
/**
|
||||
* Get name of plugin / theme.
|
||||
*
|
||||
* @param string $template plugin template/slug.
|
||||
* @param string $type type of product.
|
||||
* @return string
|
||||
*/
|
||||
function bsf_get_current_name( $template, $type ) {
|
||||
if ( '' === $template ) {
|
||||
return false;
|
||||
}
|
||||
if ( 'theme' === $type || 'themes' === $type ) {
|
||||
$theme = wp_get_theme( $template );
|
||||
$name = $theme->get( 'Name' );
|
||||
} elseif ( 'plugin' === $type || 'plugins' === $type ) {
|
||||
$plugin_file = rtrim( WP_PLUGIN_DIR, '/' ) . '/' . $template;
|
||||
if ( ! is_file( $plugin_file ) ) {
|
||||
return false;
|
||||
}
|
||||
$plugin = get_plugin_data( $plugin_file );
|
||||
$name = $plugin['Name'];
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
add_action( 'admin_notices', 'bsf_notices', 1000 );
|
||||
add_action( 'network_admin_notices', 'bsf_notices', 1000 );
|
||||
if ( ! function_exists( 'bsf_notices' ) ) {
|
||||
/**
|
||||
* Display admin notices.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function bsf_notices() {
|
||||
global $pagenow;
|
||||
|
||||
if ( 'update-core.php' === $pagenow || 'plugins.php' === $pagenow || 'post-new.php' === $pagenow || 'edit.php' === $pagenow || 'post.php' === $pagenow ) {
|
||||
$brainstrom_products = get_option( 'brainstrom_products' );
|
||||
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
|
||||
|
||||
if ( empty( $brainstrom_products ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$brainstrom_bundled_products_keys = array();
|
||||
|
||||
if ( ! empty( $brainstrom_bundled_products ) ) :
|
||||
foreach ( $brainstrom_bundled_products as $bps ) {
|
||||
foreach ( $bps as $key => $bp ) {
|
||||
array_push( $brainstrom_bundled_products_keys, $bp->id );
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
$mix = array();
|
||||
|
||||
$plugins = ( isset( $brainstrom_products['plugins'] ) ) ? $brainstrom_products['plugins'] : array();
|
||||
$themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
|
||||
|
||||
$mix = array_merge( $plugins, $themes );
|
||||
|
||||
if ( empty( $mix ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ( defined( 'BSF_PRODUCTS_NOTICES' ) && ( 'false' === BSF_PRODUCTS_NOTICES || false === BSF_PRODUCTS_NOTICES ) ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$is_multisite = is_multisite();
|
||||
$is_network_admin = is_network_admin();
|
||||
|
||||
foreach ( $mix as $product ) :
|
||||
if ( ! isset( $product['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( false === apply_filters( "bsf_display_product_activation_notice_{$product['id']}", true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $product['is_product_free'] ) && ( 'true' === $product['is_product_free'] || true === $product['is_product_free'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
|
||||
$constant_nag = 'BSF_' . $constant . '_NAG';
|
||||
$constant_notice = 'BSF_' . $constant . '_NOTICES';
|
||||
|
||||
if ( defined( $constant_nag ) && ( 'false' === constant( $constant_nag ) || false === constant( $constant_nag ) ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( defined( $constant_notice ) && ( 'false' === constant( $constant_notice ) || false === constant( $constant_notice ) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$status = ( isset( $product['status'] ) ) ? $product['status'] : false;
|
||||
$type = ( isset( $product['type'] ) ) ? $product['type'] : false;
|
||||
|
||||
if ( ! $type ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( 'plugin' === $type ) {
|
||||
if ( ! is_plugin_active( $product['template'] ) ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( 'theme' === $type ) {
|
||||
$theme = wp_get_theme();
|
||||
if ( $product['template'] !== $theme->template ) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( BSF_Update_Manager::bsf_is_product_bundled( $product['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( 'registered' !== $status ) :
|
||||
|
||||
$url = bsf_registration_page_url( '', $product['id'] );
|
||||
|
||||
$message = __( 'Please', 'bsf' ) . ' <a href="' . esc_url( $url ) . '" class="bsf-core-license-form-btn" plugin-slug="' . esc_html( $product['id'] ) . '">' . __( 'activate', 'bsf' ) . '</a> ' . __( 'your copy of the', 'bsf' ) . ' <i>' . esc_html( $product['product_name'] ) . '</i> ' . __( 'to get update notifications, access to support features & other resources!', 'bsf' );
|
||||
$message = apply_filters( "bsf_product_activation_notice_{$product['id']}", $message, $url, $product['product_name'] );
|
||||
|
||||
$allowed_html = array(
|
||||
'a' => array(
|
||||
'href' => array(),
|
||||
'class' => array(),
|
||||
'title' => array(),
|
||||
'plugin-slug' => array(),
|
||||
),
|
||||
'br' => array(),
|
||||
'em' => array(),
|
||||
'strong' => array(),
|
||||
'i' => array(),
|
||||
);
|
||||
|
||||
if ( ( $is_multisite && $is_network_admin ) || ! $is_multisite ) {
|
||||
echo '<div class="notice notice-warning"><p>' . wp_kses( $message, $allowed_html ) . '</p></div>';
|
||||
}
|
||||
endif;
|
||||
endforeach;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// delete bundled products after switch theme.
|
||||
if ( ! function_exists( 'bsf_theme_deactivation' ) ) {
|
||||
/**
|
||||
* Delete transients while switching theme.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function bsf_theme_deactivation() {
|
||||
update_option( 'bsf_force_check_extensions', false );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'switch_theme', 'bsf_theme_deactivation' );
|
||||
add_action( 'deactivated_plugin', 'bsf_theme_deactivation' );
|
||||
|
||||
if ( ! function_exists( 'bsf_get_free_menu_position' ) ) {
|
||||
/**
|
||||
* Get free theme position.
|
||||
*
|
||||
* @param int $start menu position priority index.
|
||||
* @param float $increment increment number for menu position.
|
||||
* @return int
|
||||
*/
|
||||
function bsf_get_free_menu_position( $start, $increment = 0.3 ) {
|
||||
foreach ( $GLOBALS['menu'] as $key => $menu ) {
|
||||
$menus_positions[] = $key;
|
||||
}
|
||||
|
||||
if ( ! in_array( $start, $menus_positions, true ) ) {
|
||||
return $start;
|
||||
}
|
||||
|
||||
/* the position is already reserved find the closet one */
|
||||
while ( in_array( $start, $menus_positions, true ) ) {
|
||||
$start += $increment;
|
||||
}
|
||||
return $start;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'bsf_get_option' ) ) {
|
||||
/**
|
||||
* Get free theme position.
|
||||
*
|
||||
* @param bool $request return complete option data OR a single variable.
|
||||
* @return array
|
||||
*/
|
||||
function bsf_get_option( $request = false ) {
|
||||
$bsf_options = get_option( 'bsf_options' );
|
||||
if ( ! $request ) {
|
||||
return $bsf_options;
|
||||
} else {
|
||||
return ( isset( $bsf_options[ $request ] ) ) ? $bsf_options[ $request ] : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'bsf_update_option' ) ) {
|
||||
/**
|
||||
* Update bsf option with key and value.
|
||||
*
|
||||
* @param string $request variable key.
|
||||
* @param string $value variable value.
|
||||
* @return bool
|
||||
*/
|
||||
function bsf_update_option( $request, $value ) {
|
||||
$bsf_options = get_option( 'bsf_options' );
|
||||
$bsf_options[ $request ] = $value;
|
||||
return update_option( 'bsf_options', $bsf_options );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'bsf_sort' ) ) {
|
||||
/**
|
||||
* Sort array of objects.
|
||||
*
|
||||
* @param string $a The first string.
|
||||
* @param string $b The second string.
|
||||
* @return int
|
||||
*/
|
||||
function bsf_sort( $a, $b ) {
|
||||
return strcmp( strtolower( $a->short_name ), strtolower( $b->short_name ) );
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* Admin functions.
|
||||
*
|
||||
* @package BSF core
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'bsf_generate_rand_token' ) ) {
|
||||
/**
|
||||
* Generate 32 characters random token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function bsf_generate_rand_token() {
|
||||
$valid_characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||
$token = '';
|
||||
$length = 32;
|
||||
for ( $n = 1; $n < $length; $n++ ) {
|
||||
$which_character = wp_rand( 0, strlen( $valid_characters ) - 1 );
|
||||
$token .= $valid_characters[ $which_character ];
|
||||
}
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update version numbers of all the brainstorm products in options `brainstorm_products` and `brainstrom_bundled_products`
|
||||
*
|
||||
* @todo Current version numbers can be fetched from WordPress at runtime whenever ruquired,
|
||||
* Remote version can only be required when transient for update data is deleted (i hope)
|
||||
*/
|
||||
if ( ! function_exists( 'bsf_update_all_product_version' ) ) {
|
||||
|
||||
/**
|
||||
* Updates all product versions.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function bsf_update_all_product_version() {
|
||||
|
||||
$brainstrom_products = get_option( 'brainstrom_products', array() );
|
||||
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
|
||||
$bsf_product_themes = array();
|
||||
|
||||
if ( ! empty( $brainstrom_products ) ) :
|
||||
$bsf_product_plugins = ( isset( $brainstrom_products['plugins'] ) ) ? $brainstrom_products['plugins'] : array();
|
||||
$bsf_product_themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
|
||||
endif;
|
||||
|
||||
$bundled_product_updated = false;
|
||||
|
||||
if ( ! empty( $bsf_product_plugins ) ) {
|
||||
|
||||
foreach ( $bsf_product_plugins as $key => $plugin ) {
|
||||
if ( ! isset( $plugin['id'] ) || empty( $plugin['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! isset( $plugin['template'] ) || empty( $plugin['template'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! isset( $plugin['type'] ) || empty( $plugin['type'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$version = ( isset( $plugin['version'] ) ) ? $plugin['version'] : '';
|
||||
$current_version = bsf_get_current_version( $plugin['template'], $plugin['type'] );
|
||||
$name = bsf_get_current_name( $plugin['template'], $plugin['type'] );
|
||||
if ( '' !== $name ) {
|
||||
$brainstrom_products['plugins'][ $key ]['product_name'] = $name;
|
||||
}
|
||||
if ( '' !== $current_version ) {
|
||||
if ( version_compare( $version, $current_version ) === - 1 || 1 === version_compare( $version, $current_version ) ) {
|
||||
$brainstrom_products['plugins'][ $key ]['version'] = $current_version;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $bsf_product_themes ) ) {
|
||||
|
||||
foreach ( $bsf_product_themes as $key => $theme ) {
|
||||
if ( ! isset( $theme['id'] ) || empty( $theme['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! isset( $theme['template'] ) || empty( $theme['template'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! isset( $theme['type'] ) || empty( $theme['type'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$version = ( isset( $theme['version'] ) ) ? $theme['version'] : '';
|
||||
$current_version = bsf_get_current_version( $theme['template'], $theme['type'] );
|
||||
$name = bsf_get_current_name( $theme['template'], $theme['type'] );
|
||||
if ( '' !== $name ) {
|
||||
$brainstrom_products['themes'][ $key ]['product_name'] = $name;
|
||||
}
|
||||
if ( '' !== $current_version || false !== $current_version ) {
|
||||
if ( version_compare( $version, $current_version ) === - 1 || 1 === version_compare( $version, $current_version ) ) {
|
||||
$brainstrom_products['themes'][ $key ]['version'] = $current_version;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $brainstrom_bundled_products ) ) {
|
||||
|
||||
foreach ( $brainstrom_bundled_products as $keys => $bps ) {
|
||||
$version = '';
|
||||
if ( strlen( $keys ) > 1 ) {
|
||||
foreach ( $bps as $key => $bp ) {
|
||||
if ( ! isset( $bp->id ) || '' === $bp->id ) {
|
||||
continue;
|
||||
}
|
||||
$version = $bp->version;
|
||||
$current_version = bsf_get_current_version( $bp->init, $bp->type );
|
||||
|
||||
if ( '' !== $current_version && false !== $current_version ) {
|
||||
if ( 1 === - version_compare( $version, $current_version ) || 1 === version_compare( $version, $current_version ) ) {
|
||||
if ( is_object( $brainstrom_bundled_products ) ) {
|
||||
$brainstrom_bundled_products = array( $brainstrom_bundled_products );
|
||||
}
|
||||
$single_bp = $brainstrom_bundled_products[ $keys ];
|
||||
$single_bp[ $key ]->version = $current_version;
|
||||
$bundled_product_updated = true;
|
||||
$brainstrom_bundled_products[ $keys ] = $single_bp;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( ! isset( $bps->id ) || '' === $bps->id ) {
|
||||
continue;
|
||||
}
|
||||
$version = $bps->version;
|
||||
$current_version = bsf_get_current_version( $bps->init, $bps->type );
|
||||
if ( '' !== $current_version || false !== $current_version ) {
|
||||
if ( - 1 === version_compare( $version, $current_version ) || 1 === version_compare( $version, $current_version ) ) {
|
||||
$brainstrom_bundled_products[ $keys ]->version = $current_version;
|
||||
$bundled_product_updated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'brainstrom_products', $brainstrom_products );
|
||||
|
||||
if ( $bundled_product_updated ) {
|
||||
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'admin_init', 'bsf_update_all_product_version', 1000 );
|
||||
|
||||
if ( ! function_exists( 'bsf_get_current_version' ) ) {
|
||||
/**
|
||||
* Get current version of plugin / theme.
|
||||
*
|
||||
* @param string $template plugin template/slug.
|
||||
* @param string $type type of product.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
function bsf_get_current_version( $template, $type ) {
|
||||
if ( '' === $template ) {
|
||||
return false;
|
||||
}
|
||||
if ( 'theme' === $type || 'themes' === $type ) {
|
||||
$theme = wp_get_theme( $template );
|
||||
$version = $theme->get( 'Version' );
|
||||
} elseif ( 'plugin' === $type || 'plugins' === $type ) {
|
||||
$plugin_file = rtrim( WP_PLUGIN_DIR, '/' ) . '/' . $template;
|
||||
if ( ! is_file( $plugin_file ) ) {
|
||||
return false;
|
||||
}
|
||||
$plugin = get_plugin_data( $plugin_file );
|
||||
$version = $plugin['Version'];
|
||||
}
|
||||
return $version;
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'bsf_get_current_name' ) ) {
|
||||
/**
|
||||
* Get name of plugin / theme.
|
||||
*
|
||||
* @param string $template plugin template/slug.
|
||||
* @param string $type type of product.
|
||||
* @return string
|
||||
*/
|
||||
function bsf_get_current_name( $template, $type ) {
|
||||
if ( '' === $template ) {
|
||||
return false;
|
||||
}
|
||||
if ( 'theme' === $type || 'themes' === $type ) {
|
||||
$theme = wp_get_theme( $template );
|
||||
$name = $theme->get( 'Name' );
|
||||
} elseif ( 'plugin' === $type || 'plugins' === $type ) {
|
||||
$plugin_file = rtrim( WP_PLUGIN_DIR, '/' ) . '/' . $template;
|
||||
if ( ! is_file( $plugin_file ) ) {
|
||||
return false;
|
||||
}
|
||||
$plugin = get_plugin_data( $plugin_file );
|
||||
$name = $plugin['Name'];
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
add_action( 'admin_notices', 'bsf_notices', 1000 );
|
||||
add_action( 'network_admin_notices', 'bsf_notices', 1000 );
|
||||
if ( ! function_exists( 'bsf_notices' ) ) {
|
||||
/**
|
||||
* Display admin notices.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function bsf_notices() {
|
||||
global $pagenow;
|
||||
|
||||
if ( 'update-core.php' === $pagenow || 'plugins.php' === $pagenow || 'post-new.php' === $pagenow || 'edit.php' === $pagenow || 'post.php' === $pagenow ) {
|
||||
$brainstrom_products = get_option( 'brainstrom_products' );
|
||||
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
|
||||
|
||||
if ( empty( $brainstrom_products ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$brainstrom_bundled_products_keys = array();
|
||||
|
||||
if ( ! empty( $brainstrom_bundled_products ) ) :
|
||||
foreach ( $brainstrom_bundled_products as $bps ) {
|
||||
foreach ( $bps as $key => $bp ) {
|
||||
array_push( $brainstrom_bundled_products_keys, $bp->id );
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
$mix = array();
|
||||
|
||||
$plugins = ( isset( $brainstrom_products['plugins'] ) ) ? $brainstrom_products['plugins'] : array();
|
||||
$themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
|
||||
|
||||
$mix = array_merge( $plugins, $themes );
|
||||
|
||||
if ( empty( $mix ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ( defined( 'BSF_PRODUCTS_NOTICES' ) && ( 'false' === BSF_PRODUCTS_NOTICES || false === BSF_PRODUCTS_NOTICES ) ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$is_multisite = is_multisite();
|
||||
$is_network_admin = is_network_admin();
|
||||
|
||||
foreach ( $mix as $product ) :
|
||||
if ( ! isset( $product['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( false === apply_filters( "bsf_display_product_activation_notice_{$product['id']}", true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $product['is_product_free'] ) && ( 'true' === $product['is_product_free'] || true === $product['is_product_free'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
|
||||
$constant_nag = 'BSF_' . $constant . '_NAG';
|
||||
$constant_notice = 'BSF_' . $constant . '_NOTICES';
|
||||
|
||||
if ( defined( $constant_nag ) && ( 'false' === constant( $constant_nag ) || false === constant( $constant_nag ) ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( defined( $constant_notice ) && ( 'false' === constant( $constant_notice ) || false === constant( $constant_notice ) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$status = ( isset( $product['status'] ) ) ? $product['status'] : false;
|
||||
$type = ( isset( $product['type'] ) ) ? $product['type'] : false;
|
||||
|
||||
if ( ! $type ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( 'plugin' === $type ) {
|
||||
if ( ! is_plugin_active( $product['template'] ) ) {
|
||||
continue;
|
||||
}
|
||||
} elseif ( 'theme' === $type ) {
|
||||
$theme = wp_get_theme();
|
||||
if ( $product['template'] !== $theme->template ) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( BSF_Update_Manager::bsf_is_product_bundled( $product['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( 'registered' !== $status ) :
|
||||
|
||||
$url = bsf_registration_page_url( '', $product['id'] );
|
||||
|
||||
$message = __( 'Please', 'bsf' ) . ' <a href="' . esc_url( $url ) . '" class="bsf-core-license-form-btn" plugin-slug="' . esc_html( $product['id'] ) . '">' . __( 'activate', 'bsf' ) . '</a> ' . __( 'your copy of the', 'bsf' ) . ' <i>' . esc_html( $product['product_name'] ) . '</i> ' . __( 'to get update notifications, access to support features & other resources!', 'bsf' );
|
||||
$message = apply_filters( "bsf_product_activation_notice_{$product['id']}", $message, $url, $product['product_name'] );
|
||||
|
||||
$allowed_html = array(
|
||||
'a' => array(
|
||||
'href' => array(),
|
||||
'class' => array(),
|
||||
'title' => array(),
|
||||
'plugin-slug' => array(),
|
||||
),
|
||||
'br' => array(),
|
||||
'em' => array(),
|
||||
'strong' => array(),
|
||||
'i' => array(),
|
||||
);
|
||||
|
||||
if ( ( $is_multisite && $is_network_admin ) || ! $is_multisite ) {
|
||||
echo '<div class="notice notice-warning"><p>' . wp_kses( $message, $allowed_html ) . '</p></div>';
|
||||
}
|
||||
endif;
|
||||
endforeach;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// delete bundled products after switch theme.
|
||||
if ( ! function_exists( 'bsf_theme_deactivation' ) ) {
|
||||
/**
|
||||
* Delete transients while switching theme.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function bsf_theme_deactivation() {
|
||||
update_option( 'bsf_force_check_extensions', false );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'switch_theme', 'bsf_theme_deactivation' );
|
||||
add_action( 'deactivated_plugin', 'bsf_theme_deactivation' );
|
||||
|
||||
if ( ! function_exists( 'bsf_get_free_menu_position' ) ) {
|
||||
/**
|
||||
* Get free theme position.
|
||||
*
|
||||
* @param int $start menu position priority index.
|
||||
* @param float $increment increment number for menu position.
|
||||
* @return int
|
||||
*/
|
||||
function bsf_get_free_menu_position( $start, $increment = 0.3 ) {
|
||||
foreach ( $GLOBALS['menu'] as $key => $menu ) {
|
||||
$menus_positions[] = $key;
|
||||
}
|
||||
|
||||
if ( ! in_array( $start, $menus_positions, true ) ) {
|
||||
return $start;
|
||||
}
|
||||
|
||||
/* the position is already reserved find the closet one */
|
||||
while ( in_array( $start, $menus_positions, true ) ) {
|
||||
$start += $increment;
|
||||
}
|
||||
return $start;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'bsf_get_option' ) ) {
|
||||
/**
|
||||
* Get free theme position.
|
||||
*
|
||||
* @param bool $request return complete option data OR a single variable.
|
||||
* @return array
|
||||
*/
|
||||
function bsf_get_option( $request = false ) {
|
||||
$bsf_options = get_option( 'bsf_options' );
|
||||
if ( ! $request ) {
|
||||
return $bsf_options;
|
||||
} else {
|
||||
return ( isset( $bsf_options[ $request ] ) ) ? $bsf_options[ $request ] : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'bsf_update_option' ) ) {
|
||||
/**
|
||||
* Update bsf option with key and value.
|
||||
*
|
||||
* @param string $request variable key.
|
||||
* @param string $value variable value.
|
||||
* @return bool
|
||||
*/
|
||||
function bsf_update_option( $request, $value ) {
|
||||
$bsf_options = get_option( 'bsf_options' );
|
||||
$bsf_options[ $request ] = $value;
|
||||
return update_option( 'bsf_options', $bsf_options );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'bsf_sort' ) ) {
|
||||
/**
|
||||
* Sort array of objects.
|
||||
*
|
||||
* @param string $a The first string.
|
||||
* @param string $b The second string.
|
||||
* @return int
|
||||
*/
|
||||
function bsf_sort( $a, $b ) {
|
||||
return strcmp( strtolower( $a->short_name ), strtolower( $b->short_name ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,239 +1,239 @@
|
||||
<?php
|
||||
/**
|
||||
* Product update functions.
|
||||
*
|
||||
* @package BSF core
|
||||
*/
|
||||
|
||||
// Alternative function for wp_remote_get.
|
||||
if ( ! function_exists( 'bsf_get_remote_version' ) ) {
|
||||
/**
|
||||
* Get remote version for product
|
||||
*
|
||||
* @param array $product_list products data.
|
||||
* @param array $products products data (deprecated).
|
||||
* @return array
|
||||
*/
|
||||
function bsf_get_remote_version( $product_list, $products ) {
|
||||
global $ultimate_referer;
|
||||
|
||||
$path = bsf_get_api_url() . '?referer=' . $ultimate_referer;
|
||||
|
||||
$data = array(
|
||||
'action' => 'bsf_get_product_versions',
|
||||
'ids' => $products,
|
||||
'products' => $product_list,
|
||||
'site_url' => get_site_url(),
|
||||
'php_version' => bsf_get_php_version(),
|
||||
'wp_version' => get_bloginfo( 'version' ),
|
||||
'locale' => get_locale(),
|
||||
'bsf_core_version' => BSF_UPDATER_VERSION,
|
||||
'active_theme' => get_template(),
|
||||
'active_stylesheet' => get_stylesheet(),
|
||||
'php_max_input_vars' => ini_get( 'max_input_vars' ), // phpcs:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound
|
||||
'php_post_max_size' => ini_get( 'post_max_size' ),
|
||||
'php_max_execution_time' => ini_get( 'max_execution_time' ),
|
||||
'php_memory_limit' => ini_get( 'memory_limit' ),
|
||||
);
|
||||
|
||||
$request = wp_remote_post(
|
||||
$path,
|
||||
array(
|
||||
'body' => $data,
|
||||
'timeout' => '10',
|
||||
)
|
||||
);
|
||||
|
||||
// Request http URL if the https version fails.
|
||||
if ( is_wp_error( $request ) && 200 !== wp_remote_retrieve_response_code( $request ) ) {
|
||||
$path = bsf_get_api_url( true ) . '?referer=' . $ultimate_referer;
|
||||
$request = wp_remote_post(
|
||||
$path,
|
||||
array(
|
||||
'body' => $data,
|
||||
'timeout' => '8',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! is_wp_error( $request ) || 200 === wp_remote_retrieve_response_code( $request ) ) {
|
||||
$result = json_decode( wp_remote_retrieve_body( $request ) );
|
||||
if ( ! empty( $result ) ) {
|
||||
if ( empty( $result->error ) ) {
|
||||
return $result->updated_versions;
|
||||
} else {
|
||||
return $result->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'bsf_check_product_update' ) ) {
|
||||
/**
|
||||
* Check product updates.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function bsf_check_product_update() {
|
||||
$is_update = true;
|
||||
$registered = array(); // This list will be deprecated in favor of $product_list.
|
||||
$product_list = array();
|
||||
$all_products = brainstorm_get_all_products( false, false, true );
|
||||
$brainstrom_products = get_option( 'brainstrom_products', array() );
|
||||
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
|
||||
|
||||
foreach ( $all_products as $key => $product ) {
|
||||
if ( ! isset( $product['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
|
||||
$constant = 'BSF_' . $constant . '_CHECK_UPDATES';
|
||||
if ( defined( $constant ) && ( 'false' === constant( $constant ) || false === constant( $constant ) ) ) {
|
||||
continue;
|
||||
}
|
||||
$registered[] = $product['id'];
|
||||
$product_list[ $product['id'] ] = array(
|
||||
'id' => $product['id'],
|
||||
'installed_version' => $product['version'],
|
||||
);
|
||||
|
||||
// Add bundled products to the list.
|
||||
if ( isset( $brainstrom_bundled_products[ $product['id'] ] ) ) {
|
||||
$bundled_products = $brainstrom_bundled_products[ $product['id'] ];
|
||||
$bundled_product_data = array();
|
||||
|
||||
foreach ( $bundled_products as $bundled_product ) {
|
||||
$bundled_product_data[ $bundled_product->id ] = array(
|
||||
'id' => $bundled_product->id,
|
||||
'installed_version' => $bundled_product->version,
|
||||
);
|
||||
}
|
||||
|
||||
$product_list[ $product['id'] ]['bundled_products'] = $bundled_product_data;
|
||||
}
|
||||
}
|
||||
|
||||
$remote_versions = bsf_get_remote_version( $product_list, $registered );
|
||||
|
||||
$bsf_product_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
|
||||
$bsf_product_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
|
||||
|
||||
if ( false !== $remote_versions ) {
|
||||
if ( ! empty( $remote_versions ) ) {
|
||||
$is_bundled_update = false;
|
||||
foreach ( $remote_versions as $rkey => $remote_data ) {
|
||||
$rid = ( isset( $remote_data->id ) ) ? (string) $remote_data->id : '';
|
||||
$remote_version = ( isset( $remote_data->remote_version ) ) ? $remote_data->remote_version : '';
|
||||
$in_house = ( isset( $remote_data->in_house ) ) ? $remote_data->in_house : '';
|
||||
$on_market = ( isset( $remote_data->on_market ) ) ? $remote_data->on_market : '';
|
||||
$is_product_free = ( isset( $remote_data->is_product_free ) ) ? $remote_data->is_product_free : '';
|
||||
$short_name = ( isset( $remote_data->short_name ) ) ? $remote_data->short_name : '';
|
||||
$changelog_url = ( isset( $remote_data->changelog_url ) ) ? $remote_data->changelog_url : '';
|
||||
$purchase_url = ( isset( $remote_data->purchase_url ) ) ? $remote_data->purchase_url : '';
|
||||
$version_beta = ( isset( $remote_data->version_beta ) ) ? $remote_data->version_beta : '';
|
||||
$download_url = ( isset( $remote_data->download_url ) ) ? $remote_data->download_url : '';
|
||||
$download_url_beta = ( isset( $remote_data->download_url_beta ) ) ? $remote_data->download_url_beta : '';
|
||||
$tested_upto = ( isset( $remote_data->tested ) ) ? $remote_data->tested : '';
|
||||
foreach ( $bsf_product_plugins as $key => $plugin ) {
|
||||
if ( ! isset( $plugin['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$pid = (string) $plugin['id'];
|
||||
if ( $pid === $rid ) {
|
||||
$brainstrom_products['plugins'][ $key ]['remote'] = $remote_version;
|
||||
$brainstrom_products['plugins'][ $key ]['in_house'] = $in_house;
|
||||
$brainstrom_products['plugins'][ $key ]['on_market'] = $on_market;
|
||||
$brainstrom_products['plugins'][ $key ]['is_product_free'] = $is_product_free;
|
||||
$brainstrom_products['plugins'][ $key ]['short_name'] = $short_name;
|
||||
$brainstrom_products['plugins'][ $key ]['changelog_url'] = $changelog_url;
|
||||
$brainstrom_products['plugins'][ $key ]['purchase_url'] = $purchase_url;
|
||||
$brainstrom_products['plugins'][ $key ]['version_beta'] = $version_beta;
|
||||
$brainstrom_products['plugins'][ $key ]['download_url_beta'] = $download_url_beta;
|
||||
$brainstrom_products['plugins'][ $key ]['download_url'] = $download_url;
|
||||
$brainstrom_products['plugins'][ $key ]['tested'] = $tested_upto;
|
||||
|
||||
// Deregister status for plugin.
|
||||
if ( isset( $remote_data->status ) && 0 === $remote_data->status ) {
|
||||
$brainstrom_products['plugins'][ $key ]['status'] = 'not-registered';
|
||||
} else {
|
||||
$brainstrom_products['plugins'][ $key ]['status'] = 'registered';
|
||||
}
|
||||
|
||||
$is_update = true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $bsf_product_themes as $key => $theme ) {
|
||||
if ( ! isset( $theme['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$pid = $theme['id'];
|
||||
if ( $pid === $rid ) {
|
||||
$brainstrom_products['themes'][ $key ]['remote'] = $remote_version;
|
||||
$brainstrom_products['themes'][ $key ]['in_house'] = $in_house;
|
||||
$brainstrom_products['themes'][ $key ]['on_market'] = $on_market;
|
||||
$brainstrom_products['themes'][ $key ]['is_product_free'] = $is_product_free;
|
||||
$brainstrom_products['themes'][ $key ]['short_name'] = $short_name;
|
||||
$brainstrom_products['themes'][ $key ]['changelog_url'] = $changelog_url;
|
||||
$brainstrom_products['themes'][ $key ]['purchase_url'] = $purchase_url;
|
||||
$brainstrom_products['themes'][ $key ]['version_beta'] = $version_beta;
|
||||
$brainstrom_products['themes'][ $key ]['download_url'] = $download_url;
|
||||
$brainstrom_products['themes'][ $key ]['download_url_beta'] = $download_url_beta;
|
||||
$is_update = true;
|
||||
|
||||
// Deregister status for theme.
|
||||
if ( isset( $remote_data->status ) && 0 === $remote_data->status ) {
|
||||
$brainstrom_products['themes'][ $key ]['status'] = 'not-registered';
|
||||
} else {
|
||||
$brainstrom_products['themes'][ $key ]['status'] = 'registered';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $remote_data->bundled_products ) && ! empty( $remote_data->bundled_products ) ) {
|
||||
if ( ! empty( $brainstrom_bundled_products ) && is_array( $brainstrom_bundled_products ) ) {
|
||||
foreach ( $brainstrom_bundled_products as $bkeys => $bps ) {
|
||||
foreach ( $bps as $bkey => $bp ) {
|
||||
if ( ! isset( $bp->id ) ) {
|
||||
continue;
|
||||
}
|
||||
foreach ( $remote_data->bundled_products as $rbp ) {
|
||||
if ( ! isset( $rbp->id ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( $rbp->id === $bp->id ) {
|
||||
$bprd = $brainstrom_bundled_products[ $bkeys ];
|
||||
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->remote = $rbp->remote_version;
|
||||
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->parent = $rbp->parent;
|
||||
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->short_name = $rbp->short_name;
|
||||
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->changelog_url = $rbp->changelog_url;
|
||||
|
||||
if ( isset( $rbp->download_url ) ) {
|
||||
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->download_url = $rbp->download_url;
|
||||
}
|
||||
|
||||
if ( isset( $rbp->download_url_beta ) ) {
|
||||
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->download_url_beta = $rbp->download_url_beta;
|
||||
}
|
||||
|
||||
$is_bundled_update = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $is_bundled_update ) {
|
||||
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $is_update ) {
|
||||
update_option( 'brainstrom_products', $brainstrom_products );
|
||||
}
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* Product update functions.
|
||||
*
|
||||
* @package BSF core
|
||||
*/
|
||||
|
||||
// Alternative function for wp_remote_get.
|
||||
if ( ! function_exists( 'bsf_get_remote_version' ) ) {
|
||||
/**
|
||||
* Get remote version for product
|
||||
*
|
||||
* @param array $product_list products data.
|
||||
* @param array $products products data (deprecated).
|
||||
* @return array
|
||||
*/
|
||||
function bsf_get_remote_version( $product_list, $products ) {
|
||||
global $ultimate_referer;
|
||||
|
||||
$path = bsf_get_api_url() . '?referer=' . $ultimate_referer;
|
||||
|
||||
$data = array(
|
||||
'action' => 'bsf_get_product_versions',
|
||||
'ids' => $products,
|
||||
'products' => $product_list,
|
||||
'site_url' => get_site_url(),
|
||||
'php_version' => bsf_get_php_version(),
|
||||
'wp_version' => get_bloginfo( 'version' ),
|
||||
'locale' => get_locale(),
|
||||
'bsf_core_version' => BSF_UPDATER_VERSION,
|
||||
'active_theme' => get_template(),
|
||||
'active_stylesheet' => get_stylesheet(),
|
||||
'php_max_input_vars' => ini_get( 'max_input_vars' ), // phpcs:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound
|
||||
'php_post_max_size' => ini_get( 'post_max_size' ),
|
||||
'php_max_execution_time' => ini_get( 'max_execution_time' ),
|
||||
'php_memory_limit' => ini_get( 'memory_limit' ),
|
||||
);
|
||||
|
||||
$request = wp_remote_post(
|
||||
$path,
|
||||
array(
|
||||
'body' => $data,
|
||||
'timeout' => '10',
|
||||
)
|
||||
);
|
||||
|
||||
// Request http URL if the https version fails.
|
||||
if ( is_wp_error( $request ) && 200 !== wp_remote_retrieve_response_code( $request ) ) {
|
||||
$path = bsf_get_api_url( true ) . '?referer=' . $ultimate_referer;
|
||||
$request = wp_remote_post(
|
||||
$path,
|
||||
array(
|
||||
'body' => $data,
|
||||
'timeout' => '8',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! is_wp_error( $request ) || 200 === wp_remote_retrieve_response_code( $request ) ) {
|
||||
$result = json_decode( wp_remote_retrieve_body( $request ) );
|
||||
if ( ! empty( $result ) ) {
|
||||
if ( empty( $result->error ) ) {
|
||||
return $result->updated_versions;
|
||||
} else {
|
||||
return $result->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'bsf_check_product_update' ) ) {
|
||||
/**
|
||||
* Check product updates.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function bsf_check_product_update() {
|
||||
$is_update = true;
|
||||
$registered = array(); // This list will be deprecated in favor of $product_list.
|
||||
$product_list = array();
|
||||
$all_products = brainstorm_get_all_products( false, false, true );
|
||||
$brainstrom_products = get_option( 'brainstrom_products', array() );
|
||||
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
|
||||
|
||||
foreach ( $all_products as $key => $product ) {
|
||||
if ( ! isset( $product['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
|
||||
$constant = 'BSF_' . $constant . '_CHECK_UPDATES';
|
||||
if ( defined( $constant ) && ( 'false' === constant( $constant ) || false === constant( $constant ) ) ) {
|
||||
continue;
|
||||
}
|
||||
$registered[] = $product['id'];
|
||||
$product_list[ $product['id'] ] = array(
|
||||
'id' => $product['id'],
|
||||
'installed_version' => $product['version'],
|
||||
);
|
||||
|
||||
// Add bundled products to the list.
|
||||
if ( isset( $brainstrom_bundled_products[ $product['id'] ] ) ) {
|
||||
$bundled_products = $brainstrom_bundled_products[ $product['id'] ];
|
||||
$bundled_product_data = array();
|
||||
|
||||
foreach ( $bundled_products as $bundled_product ) {
|
||||
$bundled_product_data[ $bundled_product->id ] = array(
|
||||
'id' => $bundled_product->id,
|
||||
'installed_version' => $bundled_product->version,
|
||||
);
|
||||
}
|
||||
|
||||
$product_list[ $product['id'] ]['bundled_products'] = $bundled_product_data;
|
||||
}
|
||||
}
|
||||
|
||||
$remote_versions = bsf_get_remote_version( $product_list, $registered );
|
||||
|
||||
$bsf_product_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
|
||||
$bsf_product_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
|
||||
|
||||
if ( false !== $remote_versions ) {
|
||||
if ( ! empty( $remote_versions ) ) {
|
||||
$is_bundled_update = false;
|
||||
foreach ( $remote_versions as $rkey => $remote_data ) {
|
||||
$rid = ( isset( $remote_data->id ) ) ? (string) $remote_data->id : '';
|
||||
$remote_version = ( isset( $remote_data->remote_version ) ) ? $remote_data->remote_version : '';
|
||||
$in_house = ( isset( $remote_data->in_house ) ) ? $remote_data->in_house : '';
|
||||
$on_market = ( isset( $remote_data->on_market ) ) ? $remote_data->on_market : '';
|
||||
$is_product_free = ( isset( $remote_data->is_product_free ) ) ? $remote_data->is_product_free : '';
|
||||
$short_name = ( isset( $remote_data->short_name ) ) ? $remote_data->short_name : '';
|
||||
$changelog_url = ( isset( $remote_data->changelog_url ) ) ? $remote_data->changelog_url : '';
|
||||
$purchase_url = ( isset( $remote_data->purchase_url ) ) ? $remote_data->purchase_url : '';
|
||||
$version_beta = ( isset( $remote_data->version_beta ) ) ? $remote_data->version_beta : '';
|
||||
$download_url = ( isset( $remote_data->download_url ) ) ? $remote_data->download_url : '';
|
||||
$download_url_beta = ( isset( $remote_data->download_url_beta ) ) ? $remote_data->download_url_beta : '';
|
||||
$tested_upto = ( isset( $remote_data->tested ) ) ? $remote_data->tested : '';
|
||||
foreach ( $bsf_product_plugins as $key => $plugin ) {
|
||||
if ( ! isset( $plugin['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$pid = (string) $plugin['id'];
|
||||
if ( $pid === $rid ) {
|
||||
$brainstrom_products['plugins'][ $key ]['remote'] = $remote_version;
|
||||
$brainstrom_products['plugins'][ $key ]['in_house'] = $in_house;
|
||||
$brainstrom_products['plugins'][ $key ]['on_market'] = $on_market;
|
||||
$brainstrom_products['plugins'][ $key ]['is_product_free'] = $is_product_free;
|
||||
$brainstrom_products['plugins'][ $key ]['short_name'] = $short_name;
|
||||
$brainstrom_products['plugins'][ $key ]['changelog_url'] = $changelog_url;
|
||||
$brainstrom_products['plugins'][ $key ]['purchase_url'] = $purchase_url;
|
||||
$brainstrom_products['plugins'][ $key ]['version_beta'] = $version_beta;
|
||||
$brainstrom_products['plugins'][ $key ]['download_url_beta'] = $download_url_beta;
|
||||
$brainstrom_products['plugins'][ $key ]['download_url'] = $download_url;
|
||||
$brainstrom_products['plugins'][ $key ]['tested'] = $tested_upto;
|
||||
|
||||
// Deregister status for plugin.
|
||||
if ( isset( $remote_data->status ) && 0 === $remote_data->status ) {
|
||||
$brainstrom_products['plugins'][ $key ]['status'] = 'not-registered';
|
||||
} else {
|
||||
$brainstrom_products['plugins'][ $key ]['status'] = 'registered';
|
||||
}
|
||||
|
||||
$is_update = true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $bsf_product_themes as $key => $theme ) {
|
||||
if ( ! isset( $theme['id'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$pid = $theme['id'];
|
||||
if ( $pid === $rid ) {
|
||||
$brainstrom_products['themes'][ $key ]['remote'] = $remote_version;
|
||||
$brainstrom_products['themes'][ $key ]['in_house'] = $in_house;
|
||||
$brainstrom_products['themes'][ $key ]['on_market'] = $on_market;
|
||||
$brainstrom_products['themes'][ $key ]['is_product_free'] = $is_product_free;
|
||||
$brainstrom_products['themes'][ $key ]['short_name'] = $short_name;
|
||||
$brainstrom_products['themes'][ $key ]['changelog_url'] = $changelog_url;
|
||||
$brainstrom_products['themes'][ $key ]['purchase_url'] = $purchase_url;
|
||||
$brainstrom_products['themes'][ $key ]['version_beta'] = $version_beta;
|
||||
$brainstrom_products['themes'][ $key ]['download_url'] = $download_url;
|
||||
$brainstrom_products['themes'][ $key ]['download_url_beta'] = $download_url_beta;
|
||||
$is_update = true;
|
||||
|
||||
// Deregister status for theme.
|
||||
if ( isset( $remote_data->status ) && 0 === $remote_data->status ) {
|
||||
$brainstrom_products['themes'][ $key ]['status'] = 'not-registered';
|
||||
} else {
|
||||
$brainstrom_products['themes'][ $key ]['status'] = 'registered';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $remote_data->bundled_products ) && ! empty( $remote_data->bundled_products ) ) {
|
||||
if ( ! empty( $brainstrom_bundled_products ) && is_array( $brainstrom_bundled_products ) ) {
|
||||
foreach ( $brainstrom_bundled_products as $bkeys => $bps ) {
|
||||
foreach ( $bps as $bkey => $bp ) {
|
||||
if ( ! isset( $bp->id ) ) {
|
||||
continue;
|
||||
}
|
||||
foreach ( $remote_data->bundled_products as $rbp ) {
|
||||
if ( ! isset( $rbp->id ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( $rbp->id === $bp->id ) {
|
||||
$bprd = $brainstrom_bundled_products[ $bkeys ];
|
||||
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->remote = $rbp->remote_version;
|
||||
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->parent = $rbp->parent;
|
||||
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->short_name = $rbp->short_name;
|
||||
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->changelog_url = $rbp->changelog_url;
|
||||
|
||||
if ( isset( $rbp->download_url ) ) {
|
||||
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->download_url = $rbp->download_url;
|
||||
}
|
||||
|
||||
if ( isset( $rbp->download_url_beta ) ) {
|
||||
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->download_url_beta = $rbp->download_url_beta;
|
||||
}
|
||||
|
||||
$is_bundled_update = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $is_bundled_update ) {
|
||||
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $is_update ) {
|
||||
update_option( 'brainstrom_products', $brainstrom_products );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
/* Do not change otherwise you won't get updates */
|
||||
/* Do not change otherwise you won't get updates */
|
||||
ID:[bsf-core]
|
||||
@@ -1,18 +1,18 @@
|
||||
### Version - 1.21
|
||||
# Support for beta updates of the products.
|
||||
|
||||
### Version - 1.19
|
||||
|
||||
- License Manager v2.0 - Allow plugins to individually set the license form.
|
||||
- Update themes and plugins with WordPress's transients. so support for WP-CLI and any other website management tools.
|
||||
- New License manager API.
|
||||
- Improvement: Force check product update now works when WordPress updates are force checked.
|
||||
- Slight redesign of help and debug settings screens.
|
||||
- Support for white label with filters.
|
||||
- Option to move Brainstorm registration menu in settings.
|
||||
- Hide purchase key when it is validated.
|
||||
- Remove use of deprecated 'mysql_' functions.
|
||||
- Allow users to skip brainstorm account registration.
|
||||
- Allow plugins/themes to completely hide the screen for Brainstorm Registration.
|
||||
- Allow using staging API server for development.
|
||||
### Version - 1.21
|
||||
# Support for beta updates of the products.
|
||||
|
||||
### Version - 1.19
|
||||
|
||||
- License Manager v2.0 - Allow plugins to individually set the license form.
|
||||
- Update themes and plugins with WordPress's transients. so support for WP-CLI and any other website management tools.
|
||||
- New License manager API.
|
||||
- Improvement: Force check product update now works when WordPress updates are force checked.
|
||||
- Slight redesign of help and debug settings screens.
|
||||
- Support for white label with filters.
|
||||
- Option to move Brainstorm registration menu in settings.
|
||||
- Hide purchase key when it is validated.
|
||||
- Remove use of deprecated 'mysql_' functions.
|
||||
- Allow users to skip brainstorm account registration.
|
||||
- Allow plugins/themes to completely hide the screen for Brainstorm Registration.
|
||||
- Allow using staging API server for development.
|
||||
- Fix: Occasional PHP fatal errors when using the child theme.
|
||||
@@ -1,449 +1,449 @@
|
||||
<?php
|
||||
/**
|
||||
* BSf Evato Activation Class file.
|
||||
*
|
||||
* @package bsf-core
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* BSF_Envato_Activate setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class BSF_Envato_Activate {
|
||||
|
||||
/**
|
||||
* Instance
|
||||
*
|
||||
* @var BSF_Envato_Activate
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Reference to the License manager class.
|
||||
*
|
||||
* @var BSF_License_Manager
|
||||
*/
|
||||
private $license_manager;
|
||||
|
||||
/**
|
||||
* Stores temporary response messsages from the API validations.
|
||||
*
|
||||
* @var array()
|
||||
*/
|
||||
private $message_box;
|
||||
|
||||
/**
|
||||
* Initiator.
|
||||
*/
|
||||
public static function instance() {
|
||||
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new BSF_Envato_Activate();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor function that initializes required actions and hooks
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->license_manager = new BSF_License_Manager();
|
||||
|
||||
$action = isset( $_GET['license_action'] ) ? esc_attr( $_GET['license_action'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
|
||||
if ( 'activate_license' === $action ) {
|
||||
$this->process_envato_activation();
|
||||
}
|
||||
|
||||
add_filter( 'update_footer', array( $this, 'alternate_method_link' ), 20 );
|
||||
add_action( 'bsf_inlne_license_envato_after_form', array( $this, 'inline_alternate_method_link' ), 20, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Envato Register.
|
||||
*
|
||||
* @param array $args Arguments.
|
||||
*/
|
||||
public function envato_register( $args ) {
|
||||
|
||||
// Check if alternate method is to be used.
|
||||
$method = ( isset( $_GET['activation_method'] ) && isset( $_GET['bsf_activation_nonce'] ) && wp_verify_nonce( $_GET['bsf_activation_nonce'], 'bsf_activation_nonce' ) ) ? esc_attr( $_GET['activation_method'] ) : 'oauth';
|
||||
|
||||
$html = '';
|
||||
$product_id = isset( $args['product_id'] ) ? $args['product_id'] : '';
|
||||
$is_active = $this->license_manager->bsf_is_active_license( $product_id );
|
||||
$product_name = $this->license_manager->bsf_get_product_info( $product_id, 'name' );
|
||||
$purchase_url = $this->license_manager->bsf_get_product_info( $product_id, 'purchase_url' );
|
||||
|
||||
$bundled = BSF_Update_Manager::bsf_is_product_bundled( $product_id );
|
||||
|
||||
if ( ! empty( $bundled ) ) {
|
||||
$parent_id = $bundled[0];
|
||||
$is_active = $this->license_manager->bsf_is_active_license( $parent_id );
|
||||
$parent_name = brainstrom_product_name( $parent_id );
|
||||
$registration_page = bsf_registration_page_url( '', $parent_id );
|
||||
|
||||
$html .= '<div class="bundled-product-license-registration">';
|
||||
$html .= '<span>';
|
||||
|
||||
if ( $is_active ) {
|
||||
|
||||
$html .= '<h3>License Active!</h3>';
|
||||
|
||||
$html .= '<p>' . sprintf(
|
||||
'Your license is activated, you will receive updates for <i>%s</i> when they are available.',
|
||||
$product_name
|
||||
) . '</p>';
|
||||
} else {
|
||||
|
||||
$html .= '<h3>Updates Unavailable!</h3>';
|
||||
$html .= '<p>' . sprintf(
|
||||
'This plugin is came bundled with the <i>%1$s</i>. For receiving updates, you need to activate license of <i>%2$s</i> <a href="%3$s">here</a>.',
|
||||
$parent_name,
|
||||
$parent_name,
|
||||
$registration_page
|
||||
) . '</p>';
|
||||
}
|
||||
|
||||
$html .= '</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
if ( 'license-key' === $method ) {
|
||||
$html .= bsf_license_activation_form( $args );
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
// Licence activation button.
|
||||
$form_action = ( isset( $args['form_action'] ) && ! is_null( $args['form_action'] ) ) ? $args['form_action'] : '';
|
||||
$form_class = ( isset( $args['form_class'] ) && ! is_null( $args['form_class'] ) ) ? $args['form_class'] : "bsf-license-form-{$product_id}";
|
||||
$submit_button_class = ( isset( $args['submit_button_class'] ) && ! is_null( $args['submit_button_class'] ) ) ? $args['submit_button_class'] : '';
|
||||
$license_form_heading_class = ( isset( $args['bsf_license_form_heading_class'] ) && ! is_null( $args['bsf_license_form_heading_class'] ) ) ? $args['bsf_license_form_heading_class'] : '';
|
||||
$license_active_class = ( isset( $args['bsf_license_active_class'] ) && ! is_null( $args['bsf_license_active_class'] ) ) ? $args['bsf_license_active_class'] : '';
|
||||
$license_not_activate_message = ( isset( $args['bsf_license_not_activate_message'] ) && ! is_null( $args['bsf_license_not_activate_message'] ) ) ? $args['bsf_license_not_activate_message'] : '';
|
||||
|
||||
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
||||
$button_text_activate = ( isset( $args['button_text_activate'] ) && ! is_null( $args['button_text_activate'] ) ) ? __( 'Sign Up & Activate', 'bsf' ) : __( 'Sign Up & Activate', 'bsf' );
|
||||
$button_text_deactivate = ( isset( $args['button_text_deactivate'] ) && ! is_null( $args['button_text_deactivate'] ) ) ? $args['button_text_deactivate'] : __( 'Deactivate License', 'bsf' );
|
||||
$placeholder = ( isset( $args['placeholder'] ) && ! is_null( $args['placeholder'] ) ) ? $args['placeholder'] : 'Enter your license key..';
|
||||
$popup_license_form = ( isset( $args['popup_license_form'] ) ) ? $args['popup_license_form'] : false;
|
||||
$bsf_license_allow_email = ( isset( $args['bsf_license_allow_email'] ) && ! is_null( $args['bsf_license_allow_email'] ) ) ? $args['bsf_license_allow_email'] : true;
|
||||
|
||||
if ( true === $bsf_license_allow_email ) {
|
||||
$form_class .= ' license-form-allow-email ';
|
||||
|
||||
if ( ! $is_active ) {
|
||||
$submit_button_class .= ' button-primary button-hero bsf-envato-form-activation ';
|
||||
}
|
||||
}
|
||||
|
||||
if ( true !== $is_active ) {
|
||||
$form_action = bsf_get_api_site() . 'envato-validation-callback/?wp-envato-validate';
|
||||
} else {
|
||||
$form_action = bsf_registration_page_url( '', $product_id );
|
||||
}
|
||||
|
||||
$html .= '<div class="envato-license-registration">';
|
||||
|
||||
$html .= '<form method="post" class="' . $form_class . '" action="' . $form_action . '">';
|
||||
|
||||
$html .= wp_nonce_field( 'bsf_license_activation_deactivation_nonce', 'bsf_graupi_nonce', true, false );
|
||||
|
||||
if ( $this->get_message( 'message' ) !== '' ) {
|
||||
$html .= '<span class="bsf-license-message license-' . $this->get_message( 'status' ) . '">';
|
||||
$html .= $this->get_message( 'message' );
|
||||
$html .= '</span>';
|
||||
}
|
||||
|
||||
if ( $is_active ) {
|
||||
|
||||
$envato_active_oauth_title = apply_filters( "envato_active_oauth_title_{$product_id}", 'Updates & Support Registration - <span class="active">Active!</span>' );
|
||||
$envato_active_oauth_subtitle = '<span class="active">' . sprintf(
|
||||
'Your license is active.',
|
||||
$product_name
|
||||
) . '</span>';
|
||||
|
||||
$envato_active_oauth_subtitle = apply_filters( "envato_active_oauth_subtitle_{$product_id}", $envato_active_oauth_subtitle );
|
||||
|
||||
if ( $popup_license_form ) {
|
||||
$html .= '<div class="bsf-wrap-title">';
|
||||
$html .= '<h3 class="envato-oauth-heading">' . $product_name . '</h2>';
|
||||
$html .= '<p class="envato-oauth-subheading">' . $envato_active_oauth_subtitle . '</p>';
|
||||
$html .= '</div>';
|
||||
|
||||
} else {
|
||||
$html .= '<div class="bsf-wrap-title">';
|
||||
$html .= '<h3 class="envato-oauth-heading">' . $envato_active_oauth_title . '</h2>';
|
||||
$html .= '<p class="envato-oauth-subheading">' . $envato_active_oauth_subtitle . '</p>';
|
||||
$html .= '</div>';
|
||||
}
|
||||
|
||||
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="bsf_license_manager[license_key]" value="License Validated"/>';
|
||||
$html .= '<input type="hidden" class="' . $size . '-text" id="bsf_license_manager[product_id]" name="bsf_license_manager[product_id]" value="' . esc_attr( stripslashes( $product_id ) ) . '"/>';
|
||||
|
||||
$html .= '<input type="submit" class="button ' . $submit_button_class . '" name="bsf_deactivate_license" value="' . esc_attr( $button_text_deactivate ) . '"/>';
|
||||
|
||||
} else {
|
||||
|
||||
$envato_not_active_oauth_title = apply_filters( "envato_not_active_oauth_title_{$product_id}", __( 'Updates & Support Registration - <span class="not-active">Not Active!</span>', 'bsf' ) );
|
||||
$envato_not_active_oauth_subtitle = apply_filters( "envato_not_active_oauth_subtitle_{$product_id}", __( 'Click on the button below to activate your license and subscribe to our newsletter.', 'bsf' ) );
|
||||
|
||||
if ( $popup_license_form ) {
|
||||
$html .= '<div class="bsf-wrap-title">';
|
||||
$html .= '<h3 class="envato-oauth-heading">' . $product_name . '</h2>';
|
||||
$html .= '<p class="envato-oauth-subheading">' . $envato_not_active_oauth_subtitle . '</p>';
|
||||
$html .= '</div>';
|
||||
} else {
|
||||
$html .= '<div class="bsf-wrap-title">';
|
||||
$html .= '<h3 class="envato-oauth-heading">' . $envato_not_active_oauth_title . '</h2>';
|
||||
$html .= '<p class="envato-oauth-subheading">' . $envato_not_active_oauth_subtitle . '</p>';
|
||||
$html .= '</div>';
|
||||
}
|
||||
|
||||
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="url" value="' . get_site_url() . '"/>';
|
||||
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="redirect" value="' . $this->get_redirect_url( $product_id ) . '"/>';
|
||||
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="product_id" value="' . $product_id . '"/>';
|
||||
|
||||
$html .= '<input id="bsf-license-privacy-consent" name="bsf_license_manager[privacy_consent]" type="hidden" value="true" />';
|
||||
$html .= '<input id="bsf-license-terms-conditions-consent" name="bsf_license_manager[terms_conditions_consent]" type="hidden" value="true" />';
|
||||
|
||||
$html .= '<div class="submit-button-wrap">';
|
||||
$html .= '<input type="button" class="button ' . $submit_button_class . '" name="bsf_activate_license" value="' . esc_attr( $button_text_activate ) . '"/>';
|
||||
$html .= "<p class='purchase-license'><a target='_blank' href='$purchase_url'>Purchase License »</a></p>";
|
||||
$html .= '</div>';
|
||||
}
|
||||
|
||||
$html .= '</form>';
|
||||
|
||||
$html = apply_filters( 'bsf_inlne_license_envato_after_form', $html, $product_id );
|
||||
|
||||
$html .= '</div> <!-- envato-license-registration -->';
|
||||
|
||||
if ( isset( $_GET['debug'] ) ) {
|
||||
$html .= get_bsf_systeminfo();
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Envato activation URL.
|
||||
*
|
||||
* @param array $form_data Form data.
|
||||
* @return $envato_activation_url.
|
||||
*/
|
||||
public function envato_activation_url( $form_data ) {
|
||||
$product_id = isset( $form_data['product_id'] ) ? esc_attr( $form_data['product_id'] ) : '';
|
||||
|
||||
$form_data['token'] = sha1( $this->create_token( $product_id ) );
|
||||
$url = bsf_get_api_site() . 'envato-validation-callback/?wp-envato-validate';
|
||||
|
||||
$envato_activation_url = add_query_arg(
|
||||
$form_data,
|
||||
$url
|
||||
);
|
||||
|
||||
return $envato_activation_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get redirect URL.
|
||||
*
|
||||
* @param int $product_id Product ID.
|
||||
* @return $current_url.
|
||||
*/
|
||||
protected function get_redirect_url( $product_id = '' ) {
|
||||
|
||||
if ( is_ssl() ) {
|
||||
$current_url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
} else {
|
||||
$current_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
}
|
||||
|
||||
$current_url = esc_url( remove_query_arg( array( 'license_action', 'token', 'product_id', 'purchase_key', 'success', 'status', 'message' ), $current_url ) );
|
||||
|
||||
if ( '' !== $product_id ) {
|
||||
$current_url = add_query_arg(
|
||||
array(
|
||||
'bsf-inline-license-form' => $product_id,
|
||||
),
|
||||
$current_url
|
||||
);
|
||||
}
|
||||
|
||||
return $current_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Token.
|
||||
*
|
||||
* @param int $product_id Product ID.
|
||||
* @return $token.
|
||||
*/
|
||||
protected function create_token( $product_id ) {
|
||||
$token = $product_id . '|' . current_time( 'timestamp' ) . '|' . bsf_generate_rand_token();
|
||||
update_site_option( "bsf_envato_token_$product_id", $token );
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate Token.
|
||||
*
|
||||
* @param string $token Token.
|
||||
* @param int $product_id Product ID.
|
||||
* @return bool.
|
||||
*/
|
||||
protected function validate_token( $token, $product_id ) {
|
||||
|
||||
$stored_token = get_site_option( "bsf_envato_token_$product_id", '' );
|
||||
|
||||
if ( sha1( $stored_token ) === $token ) {
|
||||
$token_atts = explode( '|', $stored_token );
|
||||
|
||||
$stored_id = $token_atts[0];
|
||||
|
||||
if ( $stored_id !== $product_id ) {
|
||||
// Token is invalid.
|
||||
return false;
|
||||
}
|
||||
|
||||
$timestamp = (int) $token_atts[1];
|
||||
$valid_ultil = $timestamp + 900;
|
||||
|
||||
if ( current_time( 'timestamp' ) > $valid_ultil ) {
|
||||
// Timestamp has expired.
|
||||
return false;
|
||||
}
|
||||
|
||||
// If above conditions did not meet, the token is valid.
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Process envato activation.
|
||||
*/
|
||||
protected function process_envato_activation() {
|
||||
$token = isset( $_GET['token'] ) ? esc_attr( $_GET['token'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$product_id = isset( $_GET['product_id'] ) ? esc_attr( $_GET['product_id'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
|
||||
if ( $this->validate_token( $token, $product_id ) ) {
|
||||
$args = array();
|
||||
$args['purchase_key'] = isset( $_GET['purchase_key'] ) ? esc_attr( $_GET['purchase_key'] ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$args['status'] = isset( $_GET['status'] ) ? esc_attr( $_GET['status'] ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$this->license_manager->bsf_update_product_info( $product_id, $args );
|
||||
|
||||
$this->set_message(
|
||||
array(
|
||||
'status' => 'success',
|
||||
'message' => 'License successfully activated!',
|
||||
)
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
$this->set_message(
|
||||
array(
|
||||
'status' => 'error',
|
||||
'message' => 'The token is invalid or is expired, please try again.',
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set message.
|
||||
*
|
||||
* @param array $message Message.
|
||||
*/
|
||||
protected function set_message( $message = array() ) {
|
||||
$this->message_box = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get message.
|
||||
*
|
||||
* @param string $key key.
|
||||
* @return $mesage
|
||||
*/
|
||||
protected function get_message( $key ) {
|
||||
$message = $this->message_box;
|
||||
|
||||
return isset( $message[ $key ] ) ? $message[ $key ] : '';
|
||||
}
|
||||
/**
|
||||
* Inline alternate method link.
|
||||
*
|
||||
* @param string $html HTML.
|
||||
* @param int $bsf_product_id Product ID.
|
||||
* @return $html.
|
||||
*/
|
||||
public function inline_alternate_method_link( $html, $bsf_product_id ) {
|
||||
$privacy_policy_link = $this->license_manager->bsf_get_product_info( $bsf_product_id, 'privacy_policy' );
|
||||
$terms_conditions_link = $this->license_manager->bsf_get_product_info( $bsf_product_id, 'terms_conditions' );
|
||||
|
||||
if ( isset( $privacy_policy_link ) ) {
|
||||
$html .= sprintf(
|
||||
'<a class="license-form-external-links" target="_blank" href="%s">Privacy Policy</a> | ',
|
||||
$privacy_policy_link
|
||||
);
|
||||
}
|
||||
|
||||
if ( isset( $terms_conditions_link ) ) {
|
||||
$html .= sprintf(
|
||||
'<a class="license-form-external-links" target="_blank" href="%s">Terms & Conditions</a>',
|
||||
$terms_conditions_link
|
||||
);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
/**
|
||||
* ALternate method link.
|
||||
*
|
||||
* @param string $content Content.
|
||||
* @return $content.
|
||||
*/
|
||||
public function alternate_method_link( $content ) {
|
||||
|
||||
$bsf_activation_nonce = wp_create_nonce( 'bsf_activation_nonce' );
|
||||
$content = sprintf(
|
||||
'<a href="%s">Activate license using purchase key</a>',
|
||||
add_query_arg(
|
||||
array(
|
||||
'activation_method' => 'license-key',
|
||||
'bsf_activation_nonce' => $bsf_activation_nonce,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* BSF envato register.
|
||||
*
|
||||
* @param string $args Arguments..
|
||||
* @return envato_register().
|
||||
*/
|
||||
function bsf_envato_register( $args ) {
|
||||
$bsf_envato_activate = BSF_Envato_Activate::instance();
|
||||
|
||||
return $bsf_envato_activate->envato_register( $args );
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* BSf Evato Activation Class file.
|
||||
*
|
||||
* @package bsf-core
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* BSF_Envato_Activate setup
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
class BSF_Envato_Activate {
|
||||
|
||||
/**
|
||||
* Instance
|
||||
*
|
||||
* @var BSF_Envato_Activate
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Reference to the License manager class.
|
||||
*
|
||||
* @var BSF_License_Manager
|
||||
*/
|
||||
private $license_manager;
|
||||
|
||||
/**
|
||||
* Stores temporary response messsages from the API validations.
|
||||
*
|
||||
* @var array()
|
||||
*/
|
||||
private $message_box;
|
||||
|
||||
/**
|
||||
* Initiator.
|
||||
*/
|
||||
public static function instance() {
|
||||
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new BSF_Envato_Activate();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor function that initializes required actions and hooks
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->license_manager = new BSF_License_Manager();
|
||||
|
||||
$action = isset( $_GET['license_action'] ) ? esc_attr( $_GET['license_action'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
|
||||
if ( 'activate_license' === $action ) {
|
||||
$this->process_envato_activation();
|
||||
}
|
||||
|
||||
add_filter( 'update_footer', array( $this, 'alternate_method_link' ), 20 );
|
||||
add_action( 'bsf_inlne_license_envato_after_form', array( $this, 'inline_alternate_method_link' ), 20, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Envato Register.
|
||||
*
|
||||
* @param array $args Arguments.
|
||||
*/
|
||||
public function envato_register( $args ) {
|
||||
|
||||
// Check if alternate method is to be used.
|
||||
$method = ( isset( $_GET['activation_method'] ) && isset( $_GET['bsf_activation_nonce'] ) && wp_verify_nonce( $_GET['bsf_activation_nonce'], 'bsf_activation_nonce' ) ) ? esc_attr( $_GET['activation_method'] ) : 'oauth';
|
||||
|
||||
$html = '';
|
||||
$product_id = isset( $args['product_id'] ) ? $args['product_id'] : '';
|
||||
$is_active = $this->license_manager->bsf_is_active_license( $product_id );
|
||||
$product_name = $this->license_manager->bsf_get_product_info( $product_id, 'name' );
|
||||
$purchase_url = $this->license_manager->bsf_get_product_info( $product_id, 'purchase_url' );
|
||||
|
||||
$bundled = BSF_Update_Manager::bsf_is_product_bundled( $product_id );
|
||||
|
||||
if ( ! empty( $bundled ) ) {
|
||||
$parent_id = $bundled[0];
|
||||
$is_active = $this->license_manager->bsf_is_active_license( $parent_id );
|
||||
$parent_name = brainstrom_product_name( $parent_id );
|
||||
$registration_page = bsf_registration_page_url( '', $parent_id );
|
||||
|
||||
$html .= '<div class="bundled-product-license-registration">';
|
||||
$html .= '<span>';
|
||||
|
||||
if ( $is_active ) {
|
||||
|
||||
$html .= '<h3>License Active!</h3>';
|
||||
|
||||
$html .= '<p>' . sprintf(
|
||||
'Your license is activated, you will receive updates for <i>%s</i> when they are available.',
|
||||
$product_name
|
||||
) . '</p>';
|
||||
} else {
|
||||
|
||||
$html .= '<h3>Updates Unavailable!</h3>';
|
||||
$html .= '<p>' . sprintf(
|
||||
'This plugin is came bundled with the <i>%1$s</i>. For receiving updates, you need to activate license of <i>%2$s</i> <a href="%3$s">here</a>.',
|
||||
$parent_name,
|
||||
$parent_name,
|
||||
$registration_page
|
||||
) . '</p>';
|
||||
}
|
||||
|
||||
$html .= '</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
if ( 'license-key' === $method ) {
|
||||
$html .= bsf_license_activation_form( $args );
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
// Licence activation button.
|
||||
$form_action = ( isset( $args['form_action'] ) && ! is_null( $args['form_action'] ) ) ? $args['form_action'] : '';
|
||||
$form_class = ( isset( $args['form_class'] ) && ! is_null( $args['form_class'] ) ) ? $args['form_class'] : "bsf-license-form-{$product_id}";
|
||||
$submit_button_class = ( isset( $args['submit_button_class'] ) && ! is_null( $args['submit_button_class'] ) ) ? $args['submit_button_class'] : '';
|
||||
$license_form_heading_class = ( isset( $args['bsf_license_form_heading_class'] ) && ! is_null( $args['bsf_license_form_heading_class'] ) ) ? $args['bsf_license_form_heading_class'] : '';
|
||||
$license_active_class = ( isset( $args['bsf_license_active_class'] ) && ! is_null( $args['bsf_license_active_class'] ) ) ? $args['bsf_license_active_class'] : '';
|
||||
$license_not_activate_message = ( isset( $args['bsf_license_not_activate_message'] ) && ! is_null( $args['bsf_license_not_activate_message'] ) ) ? $args['bsf_license_not_activate_message'] : '';
|
||||
|
||||
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
||||
$button_text_activate = ( isset( $args['button_text_activate'] ) && ! is_null( $args['button_text_activate'] ) ) ? __( 'Sign Up & Activate', 'bsf' ) : __( 'Sign Up & Activate', 'bsf' );
|
||||
$button_text_deactivate = ( isset( $args['button_text_deactivate'] ) && ! is_null( $args['button_text_deactivate'] ) ) ? $args['button_text_deactivate'] : __( 'Deactivate License', 'bsf' );
|
||||
$placeholder = ( isset( $args['placeholder'] ) && ! is_null( $args['placeholder'] ) ) ? $args['placeholder'] : 'Enter your license key..';
|
||||
$popup_license_form = ( isset( $args['popup_license_form'] ) ) ? $args['popup_license_form'] : false;
|
||||
$bsf_license_allow_email = ( isset( $args['bsf_license_allow_email'] ) && ! is_null( $args['bsf_license_allow_email'] ) ) ? $args['bsf_license_allow_email'] : true;
|
||||
|
||||
if ( true === $bsf_license_allow_email ) {
|
||||
$form_class .= ' license-form-allow-email ';
|
||||
|
||||
if ( ! $is_active ) {
|
||||
$submit_button_class .= ' button-primary button-hero bsf-envato-form-activation ';
|
||||
}
|
||||
}
|
||||
|
||||
if ( true !== $is_active ) {
|
||||
$form_action = bsf_get_api_site() . 'envato-validation-callback/?wp-envato-validate';
|
||||
} else {
|
||||
$form_action = bsf_registration_page_url( '', $product_id );
|
||||
}
|
||||
|
||||
$html .= '<div class="envato-license-registration">';
|
||||
|
||||
$html .= '<form method="post" class="' . $form_class . '" action="' . $form_action . '">';
|
||||
|
||||
$html .= wp_nonce_field( 'bsf_license_activation_deactivation_nonce', 'bsf_graupi_nonce', true, false );
|
||||
|
||||
if ( $this->get_message( 'message' ) !== '' ) {
|
||||
$html .= '<span class="bsf-license-message license-' . $this->get_message( 'status' ) . '">';
|
||||
$html .= $this->get_message( 'message' );
|
||||
$html .= '</span>';
|
||||
}
|
||||
|
||||
if ( $is_active ) {
|
||||
|
||||
$envato_active_oauth_title = apply_filters( "envato_active_oauth_title_{$product_id}", 'Updates & Support Registration - <span class="active">Active!</span>' );
|
||||
$envato_active_oauth_subtitle = '<span class="active">' . sprintf(
|
||||
'Your license is active.',
|
||||
$product_name
|
||||
) . '</span>';
|
||||
|
||||
$envato_active_oauth_subtitle = apply_filters( "envato_active_oauth_subtitle_{$product_id}", $envato_active_oauth_subtitle );
|
||||
|
||||
if ( $popup_license_form ) {
|
||||
$html .= '<div class="bsf-wrap-title">';
|
||||
$html .= '<h3 class="envato-oauth-heading">' . $product_name . '</h2>';
|
||||
$html .= '<p class="envato-oauth-subheading">' . $envato_active_oauth_subtitle . '</p>';
|
||||
$html .= '</div>';
|
||||
|
||||
} else {
|
||||
$html .= '<div class="bsf-wrap-title">';
|
||||
$html .= '<h3 class="envato-oauth-heading">' . $envato_active_oauth_title . '</h2>';
|
||||
$html .= '<p class="envato-oauth-subheading">' . $envato_active_oauth_subtitle . '</p>';
|
||||
$html .= '</div>';
|
||||
}
|
||||
|
||||
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="bsf_license_manager[license_key]" value="License Validated"/>';
|
||||
$html .= '<input type="hidden" class="' . $size . '-text" id="bsf_license_manager[product_id]" name="bsf_license_manager[product_id]" value="' . esc_attr( stripslashes( $product_id ) ) . '"/>';
|
||||
|
||||
$html .= '<input type="submit" class="button ' . $submit_button_class . '" name="bsf_deactivate_license" value="' . esc_attr( $button_text_deactivate ) . '"/>';
|
||||
|
||||
} else {
|
||||
|
||||
$envato_not_active_oauth_title = apply_filters( "envato_not_active_oauth_title_{$product_id}", __( 'Updates & Support Registration - <span class="not-active">Not Active!</span>', 'bsf' ) );
|
||||
$envato_not_active_oauth_subtitle = apply_filters( "envato_not_active_oauth_subtitle_{$product_id}", __( 'Click on the button below to activate your license and subscribe to our newsletter.', 'bsf' ) );
|
||||
|
||||
if ( $popup_license_form ) {
|
||||
$html .= '<div class="bsf-wrap-title">';
|
||||
$html .= '<h3 class="envato-oauth-heading">' . $product_name . '</h2>';
|
||||
$html .= '<p class="envato-oauth-subheading">' . $envato_not_active_oauth_subtitle . '</p>';
|
||||
$html .= '</div>';
|
||||
} else {
|
||||
$html .= '<div class="bsf-wrap-title">';
|
||||
$html .= '<h3 class="envato-oauth-heading">' . $envato_not_active_oauth_title . '</h2>';
|
||||
$html .= '<p class="envato-oauth-subheading">' . $envato_not_active_oauth_subtitle . '</p>';
|
||||
$html .= '</div>';
|
||||
}
|
||||
|
||||
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="url" value="' . get_site_url() . '"/>';
|
||||
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="redirect" value="' . $this->get_redirect_url( $product_id ) . '"/>';
|
||||
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="product_id" value="' . $product_id . '"/>';
|
||||
|
||||
$html .= '<input id="bsf-license-privacy-consent" name="bsf_license_manager[privacy_consent]" type="hidden" value="true" />';
|
||||
$html .= '<input id="bsf-license-terms-conditions-consent" name="bsf_license_manager[terms_conditions_consent]" type="hidden" value="true" />';
|
||||
|
||||
$html .= '<div class="submit-button-wrap">';
|
||||
$html .= '<input type="button" class="button ' . $submit_button_class . '" name="bsf_activate_license" value="' . esc_attr( $button_text_activate ) . '"/>';
|
||||
$html .= "<p class='purchase-license'><a target='_blank' href='$purchase_url'>Purchase License »</a></p>";
|
||||
$html .= '</div>';
|
||||
}
|
||||
|
||||
$html .= '</form>';
|
||||
|
||||
$html = apply_filters( 'bsf_inlne_license_envato_after_form', $html, $product_id );
|
||||
|
||||
$html .= '</div> <!-- envato-license-registration -->';
|
||||
|
||||
if ( isset( $_GET['debug'] ) ) {
|
||||
$html .= get_bsf_systeminfo();
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Envato activation URL.
|
||||
*
|
||||
* @param array $form_data Form data.
|
||||
* @return $envato_activation_url.
|
||||
*/
|
||||
public function envato_activation_url( $form_data ) {
|
||||
$product_id = isset( $form_data['product_id'] ) ? esc_attr( $form_data['product_id'] ) : '';
|
||||
|
||||
$form_data['token'] = sha1( $this->create_token( $product_id ) );
|
||||
$url = bsf_get_api_site() . 'envato-validation-callback/?wp-envato-validate';
|
||||
|
||||
$envato_activation_url = add_query_arg(
|
||||
$form_data,
|
||||
$url
|
||||
);
|
||||
|
||||
return $envato_activation_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get redirect URL.
|
||||
*
|
||||
* @param int $product_id Product ID.
|
||||
* @return $current_url.
|
||||
*/
|
||||
protected function get_redirect_url( $product_id = '' ) {
|
||||
|
||||
if ( is_ssl() ) {
|
||||
$current_url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
} else {
|
||||
$current_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
}
|
||||
|
||||
$current_url = esc_url( remove_query_arg( array( 'license_action', 'token', 'product_id', 'purchase_key', 'success', 'status', 'message' ), $current_url ) );
|
||||
|
||||
if ( '' !== $product_id ) {
|
||||
$current_url = add_query_arg(
|
||||
array(
|
||||
'bsf-inline-license-form' => $product_id,
|
||||
),
|
||||
$current_url
|
||||
);
|
||||
}
|
||||
|
||||
return $current_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Token.
|
||||
*
|
||||
* @param int $product_id Product ID.
|
||||
* @return $token.
|
||||
*/
|
||||
protected function create_token( $product_id ) {
|
||||
$token = $product_id . '|' . current_time( 'timestamp' ) . '|' . bsf_generate_rand_token();
|
||||
update_site_option( "bsf_envato_token_$product_id", $token );
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate Token.
|
||||
*
|
||||
* @param string $token Token.
|
||||
* @param int $product_id Product ID.
|
||||
* @return bool.
|
||||
*/
|
||||
protected function validate_token( $token, $product_id ) {
|
||||
|
||||
$stored_token = get_site_option( "bsf_envato_token_$product_id", '' );
|
||||
|
||||
if ( sha1( $stored_token ) === $token ) {
|
||||
$token_atts = explode( '|', $stored_token );
|
||||
|
||||
$stored_id = $token_atts[0];
|
||||
|
||||
if ( $stored_id !== $product_id ) {
|
||||
// Token is invalid.
|
||||
return false;
|
||||
}
|
||||
|
||||
$timestamp = (int) $token_atts[1];
|
||||
$valid_ultil = $timestamp + 900;
|
||||
|
||||
if ( current_time( 'timestamp' ) > $valid_ultil ) {
|
||||
// Timestamp has expired.
|
||||
return false;
|
||||
}
|
||||
|
||||
// If above conditions did not meet, the token is valid.
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Process envato activation.
|
||||
*/
|
||||
protected function process_envato_activation() {
|
||||
$token = isset( $_GET['token'] ) ? esc_attr( $_GET['token'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$product_id = isset( $_GET['product_id'] ) ? esc_attr( $_GET['product_id'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
|
||||
if ( $this->validate_token( $token, $product_id ) ) {
|
||||
$args = array();
|
||||
$args['purchase_key'] = isset( $_GET['purchase_key'] ) ? esc_attr( $_GET['purchase_key'] ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$args['status'] = isset( $_GET['status'] ) ? esc_attr( $_GET['status'] ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$this->license_manager->bsf_update_product_info( $product_id, $args );
|
||||
|
||||
$this->set_message(
|
||||
array(
|
||||
'status' => 'success',
|
||||
'message' => 'License successfully activated!',
|
||||
)
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
$this->set_message(
|
||||
array(
|
||||
'status' => 'error',
|
||||
'message' => 'The token is invalid or is expired, please try again.',
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set message.
|
||||
*
|
||||
* @param array $message Message.
|
||||
*/
|
||||
protected function set_message( $message = array() ) {
|
||||
$this->message_box = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get message.
|
||||
*
|
||||
* @param string $key key.
|
||||
* @return $mesage
|
||||
*/
|
||||
protected function get_message( $key ) {
|
||||
$message = $this->message_box;
|
||||
|
||||
return isset( $message[ $key ] ) ? $message[ $key ] : '';
|
||||
}
|
||||
/**
|
||||
* Inline alternate method link.
|
||||
*
|
||||
* @param string $html HTML.
|
||||
* @param int $bsf_product_id Product ID.
|
||||
* @return $html.
|
||||
*/
|
||||
public function inline_alternate_method_link( $html, $bsf_product_id ) {
|
||||
$privacy_policy_link = $this->license_manager->bsf_get_product_info( $bsf_product_id, 'privacy_policy' );
|
||||
$terms_conditions_link = $this->license_manager->bsf_get_product_info( $bsf_product_id, 'terms_conditions' );
|
||||
|
||||
if ( isset( $privacy_policy_link ) ) {
|
||||
$html .= sprintf(
|
||||
'<a class="license-form-external-links" target="_blank" href="%s">Privacy Policy</a> | ',
|
||||
$privacy_policy_link
|
||||
);
|
||||
}
|
||||
|
||||
if ( isset( $terms_conditions_link ) ) {
|
||||
$html .= sprintf(
|
||||
'<a class="license-form-external-links" target="_blank" href="%s">Terms & Conditions</a>',
|
||||
$terms_conditions_link
|
||||
);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
/**
|
||||
* ALternate method link.
|
||||
*
|
||||
* @param string $content Content.
|
||||
* @return $content.
|
||||
*/
|
||||
public function alternate_method_link( $content ) {
|
||||
|
||||
$bsf_activation_nonce = wp_create_nonce( 'bsf_activation_nonce' );
|
||||
$content = sprintf(
|
||||
'<a href="%s">Activate license using purchase key</a>',
|
||||
add_query_arg(
|
||||
array(
|
||||
'activation_method' => 'license-key',
|
||||
'bsf_activation_nonce' => $bsf_activation_nonce,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* BSF envato register.
|
||||
*
|
||||
* @param string $args Arguments..
|
||||
* @return envato_register().
|
||||
*/
|
||||
function bsf_envato_register( $args ) {
|
||||
$bsf_envato_activate = BSF_Envato_Activate::instance();
|
||||
|
||||
return $bsf_envato_activate->envato_register( $args );
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,180 +1,180 @@
|
||||
<?php
|
||||
/**
|
||||
* BSF Rollback Version manager class file.
|
||||
*
|
||||
* @package bsf-core
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* BSF Rollback Version manager.
|
||||
*/
|
||||
class BSF_Rollback_Version_Manager {
|
||||
|
||||
/**
|
||||
* This is set for page reload cache.
|
||||
*
|
||||
* @var $reload_page_cache
|
||||
*/
|
||||
public static $reload_page_cache = 1;
|
||||
/**
|
||||
* Constructor function that initializes required sections.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_notices', array( $this, 'bsf_download_rollback_version' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Rollback to privious versions form.
|
||||
*
|
||||
* @param string $product_id Product ID.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function render_rollback_version_form( $product_id ) {
|
||||
add_action( 'admin_footer', array( $this, 'rollback_version_popup' ) );
|
||||
|
||||
// Enqueue scripts only when this function is called.
|
||||
wp_enqueue_script( 'bsf-core-version-rollback' );
|
||||
wp_enqueue_style( 'bsf-core-version-rollback-css' );
|
||||
|
||||
$product_details = get_brainstorm_product( $product_id );
|
||||
$installed_version = isset( $product_details['version'] ) ? $product_details['version'] : '';
|
||||
$product_versions = BSF_Rollback_Version::bsf_get_product_versions( $product_id ); // Get Remote versions
|
||||
// Show versions above than latest install version of the product.
|
||||
$sorted_versions = BSF_Rollback_Version::sort_product_versions( $product_versions, $installed_version );
|
||||
|
||||
if ( empty( $sorted_versions ) ) {
|
||||
echo esc_html__( 'No Versions Found! ', 'bsf-core' );
|
||||
return;
|
||||
}
|
||||
|
||||
$product_name = isset( $product_details['name'] ) ? $product_details['name'] : '';
|
||||
$white_label_name = bsf_get_white_lable_product_name( $product_id, $product_name );
|
||||
?>
|
||||
<div class="bsf-rollback-version">
|
||||
<input type="hidden" name="product-name" id="bsf-product-name" value="<?php echo esc_attr( $white_label_name ); ?>">
|
||||
<select class="bsf-rollback-version-select">
|
||||
<?php
|
||||
foreach ( $sorted_versions as $version ) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $version ); ?>"><?php echo esc_html( $version ); ?> </option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<a data-placeholder-text=" <?php echo esc_html__( 'Rollback', 'bsf-core' ); ?>" href="<?php echo esc_url( add_query_arg( 'version_no', $sorted_versions[0], wp_nonce_url( admin_url( 'index.php?action=bsf_rollback&product_id=' . $product_id ), 'bsf_rollback' ) ) ); ?>"
|
||||
data-placeholder-url="<?php echo esc_url( wp_nonce_url( admin_url( 'index.php?action=bsf_rollback&version_no=VERSION&product_id=' . $product_id ), 'bsf_rollback' ) ); ?>" class="button bsf-rollback-button"><?php echo esc_html__( 'Rollback', 'bsf-core' ); ?> </a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Download Product Version.
|
||||
*/
|
||||
public function bsf_download_rollback_version() {
|
||||
|
||||
if ( ! current_user_can( 'update_plugins' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $_GET['version_no'] ) || empty( $_GET['product_id'] ) || ! isset( $_GET['action'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
check_admin_referer( 'bsf_rollback' );
|
||||
|
||||
$bsf_update_manager = new BSF_Update_Manager();
|
||||
$version_no = sanitize_text_field( $_GET['version_no'] );
|
||||
$product_id = sanitize_text_field( $_GET['product_id'] );
|
||||
$product_details = get_brainstorm_product( $product_id );
|
||||
$plugin_slug = ! empty( $product_details['slug'] ) ? $product_details['slug'] : '';
|
||||
$plugin_name = ! empty( $product_details['template'] ) ? $product_details['template'] : '';
|
||||
$bundled_plugin_name = ! empty( $product_details['init'] ) ? $product_details['init'] : '';
|
||||
$purchase_key = $bsf_update_manager->get_purchse_key( $product_id );
|
||||
$product_title = ! empty( $product_details['name'] ) ? $product_details['name'] : '';
|
||||
$plugin_name = ! empty( $plugin_name ) ? $plugin_name : $bundled_plugin_name;
|
||||
|
||||
$download_params = array(
|
||||
'version_no' => $version_no,
|
||||
'purchase_key' => $purchase_key,
|
||||
'site_url' => get_site_url(),
|
||||
);
|
||||
|
||||
$download_url = bsf_get_api_site( false, true ) . 'download/' . $product_id . '?' . http_build_query( $download_params );
|
||||
|
||||
$rollback = new BSF_Rollback_Version(
|
||||
array(
|
||||
'version' => $version_no,
|
||||
'plugin_name' => $plugin_name,
|
||||
'plugin_slug' => $plugin_slug,
|
||||
'package_url' => $download_url,
|
||||
'product_title' => $product_title,
|
||||
'product_id' => $product_id,
|
||||
)
|
||||
);
|
||||
$rollback->run();
|
||||
// Delete product versions transient data after update.
|
||||
bsf_clear_versions_cache( $product_id );
|
||||
wp_die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Scripts
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param string $hook Current Hook.
|
||||
* @return void
|
||||
*/
|
||||
public function load_scripts( $hook = '' ) {
|
||||
wp_register_script( 'bsf-core-version-rollback', bsf_core_url( '/assets/js/version-rollback.js' ), array( 'jquery' ), BSF_UPDATER_VERSION, true );
|
||||
wp_register_style( 'bsf-core-version-rollback-css', bsf_core_url( '/assets/css/rollback-version.css' ), array(), BSF_UPDATER_VERSION );
|
||||
}
|
||||
|
||||
/**
|
||||
* Version rollback Confirmation popup.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function rollback_version_popup() {
|
||||
// This is set to fix the duplicate markup on page load.
|
||||
if ( 1 !== self::$reload_page_cache ) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::$reload_page_cache = 0;
|
||||
?>
|
||||
<div class="bsf-confirm-rollback-popup" style="display:none;">
|
||||
<div class="bsf-core-rollback-overlay"></div>
|
||||
<div class="bsf-confirm-rollback-popup-content">
|
||||
<h3 class="bsf-rollback-heading bsf-confirm-heading" data-text="<?php esc_html_e( 'Rollback #PRODUCT_NAME# Version', 'bsf-core' ); ?>"></h3>
|
||||
<p class="bsf-confirm-text bsf-rollback-text" data-text="<?php esc_html_e( 'Are you sure you want to rollback #PRODUCT_NAME# to version #VERSION#?', 'bsf-core' ); ?>" ></p>
|
||||
<div class="bsf-confirm-rollback-popup-buttons-wrapper">
|
||||
<button class="button bsf-product-license button-default bsf-confirm-cancel"><?php esc_html_e( 'Cancel', 'bsf-core' ); ?></button>
|
||||
<button class="button button-primary bsf-confirm-ok"><?php esc_html_e( 'Continue', 'bsf-core' ); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new BSF_Rollback_Version_Manager();
|
||||
|
||||
/**
|
||||
* Render Rollback versoin form.
|
||||
*
|
||||
* @param string $product_id Product ID.
|
||||
*/
|
||||
function bsf_get_version_rollback_form( $product_id ) {
|
||||
if ( ! bsf_display_rollback_version_form( $product_id ) ) {
|
||||
return false;
|
||||
}
|
||||
$instance = new BSF_Rollback_Version_Manager();
|
||||
$instance->render_rollback_version_form( $product_id );
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* BSF Rollback Version manager class file.
|
||||
*
|
||||
* @package bsf-core
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* BSF Rollback Version manager.
|
||||
*/
|
||||
class BSF_Rollback_Version_Manager {
|
||||
|
||||
/**
|
||||
* This is set for page reload cache.
|
||||
*
|
||||
* @var $reload_page_cache
|
||||
*/
|
||||
public static $reload_page_cache = 1;
|
||||
/**
|
||||
* Constructor function that initializes required sections.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_notices', array( $this, 'bsf_download_rollback_version' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Rollback to privious versions form.
|
||||
*
|
||||
* @param string $product_id Product ID.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function render_rollback_version_form( $product_id ) {
|
||||
add_action( 'admin_footer', array( $this, 'rollback_version_popup' ) );
|
||||
|
||||
// Enqueue scripts only when this function is called.
|
||||
wp_enqueue_script( 'bsf-core-version-rollback' );
|
||||
wp_enqueue_style( 'bsf-core-version-rollback-css' );
|
||||
|
||||
$product_details = get_brainstorm_product( $product_id );
|
||||
$installed_version = isset( $product_details['version'] ) ? $product_details['version'] : '';
|
||||
$product_versions = BSF_Rollback_Version::bsf_get_product_versions( $product_id ); // Get Remote versions
|
||||
// Show versions above than latest install version of the product.
|
||||
$sorted_versions = BSF_Rollback_Version::sort_product_versions( $product_versions, $installed_version );
|
||||
|
||||
if ( empty( $sorted_versions ) ) {
|
||||
echo esc_html__( 'No Versions Found! ', 'bsf-core' );
|
||||
return;
|
||||
}
|
||||
|
||||
$product_name = isset( $product_details['name'] ) ? $product_details['name'] : '';
|
||||
$white_label_name = bsf_get_white_lable_product_name( $product_id, $product_name );
|
||||
?>
|
||||
<div class="bsf-rollback-version">
|
||||
<input type="hidden" name="product-name" id="bsf-product-name" value="<?php echo esc_attr( $white_label_name ); ?>">
|
||||
<select class="bsf-rollback-version-select">
|
||||
<?php
|
||||
foreach ( $sorted_versions as $version ) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $version ); ?>"><?php echo esc_html( $version ); ?> </option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<a data-placeholder-text=" <?php echo esc_html__( 'Rollback', 'bsf-core' ); ?>" href="<?php echo esc_url( add_query_arg( 'version_no', $sorted_versions[0], wp_nonce_url( admin_url( 'index.php?action=bsf_rollback&product_id=' . $product_id ), 'bsf_rollback' ) ) ); ?>"
|
||||
data-placeholder-url="<?php echo esc_url( wp_nonce_url( admin_url( 'index.php?action=bsf_rollback&version_no=VERSION&product_id=' . $product_id ), 'bsf_rollback' ) ); ?>" class="button bsf-rollback-button"><?php echo esc_html__( 'Rollback', 'bsf-core' ); ?> </a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Download Product Version.
|
||||
*/
|
||||
public function bsf_download_rollback_version() {
|
||||
|
||||
if ( ! current_user_can( 'update_plugins' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $_GET['version_no'] ) || empty( $_GET['product_id'] ) || ! isset( $_GET['action'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
check_admin_referer( 'bsf_rollback' );
|
||||
|
||||
$bsf_update_manager = new BSF_Update_Manager();
|
||||
$version_no = sanitize_text_field( $_GET['version_no'] );
|
||||
$product_id = sanitize_text_field( $_GET['product_id'] );
|
||||
$product_details = get_brainstorm_product( $product_id );
|
||||
$plugin_slug = ! empty( $product_details['slug'] ) ? $product_details['slug'] : '';
|
||||
$plugin_name = ! empty( $product_details['template'] ) ? $product_details['template'] : '';
|
||||
$bundled_plugin_name = ! empty( $product_details['init'] ) ? $product_details['init'] : '';
|
||||
$purchase_key = $bsf_update_manager->get_purchse_key( $product_id );
|
||||
$product_title = ! empty( $product_details['name'] ) ? $product_details['name'] : '';
|
||||
$plugin_name = ! empty( $plugin_name ) ? $plugin_name : $bundled_plugin_name;
|
||||
|
||||
$download_params = array(
|
||||
'version_no' => $version_no,
|
||||
'purchase_key' => $purchase_key,
|
||||
'site_url' => get_site_url(),
|
||||
);
|
||||
|
||||
$download_url = bsf_get_api_site( false, true ) . 'download/' . $product_id . '?' . http_build_query( $download_params );
|
||||
|
||||
$rollback = new BSF_Rollback_Version(
|
||||
array(
|
||||
'version' => $version_no,
|
||||
'plugin_name' => $plugin_name,
|
||||
'plugin_slug' => $plugin_slug,
|
||||
'package_url' => $download_url,
|
||||
'product_title' => $product_title,
|
||||
'product_id' => $product_id,
|
||||
)
|
||||
);
|
||||
$rollback->run();
|
||||
// Delete product versions transient data after update.
|
||||
bsf_clear_versions_cache( $product_id );
|
||||
wp_die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Scripts
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @param string $hook Current Hook.
|
||||
* @return void
|
||||
*/
|
||||
public function load_scripts( $hook = '' ) {
|
||||
wp_register_script( 'bsf-core-version-rollback', bsf_core_url( '/assets/js/version-rollback.js' ), array( 'jquery' ), BSF_UPDATER_VERSION, true );
|
||||
wp_register_style( 'bsf-core-version-rollback-css', bsf_core_url( '/assets/css/rollback-version.css' ), array(), BSF_UPDATER_VERSION );
|
||||
}
|
||||
|
||||
/**
|
||||
* Version rollback Confirmation popup.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function rollback_version_popup() {
|
||||
// This is set to fix the duplicate markup on page load.
|
||||
if ( 1 !== self::$reload_page_cache ) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::$reload_page_cache = 0;
|
||||
?>
|
||||
<div class="bsf-confirm-rollback-popup" style="display:none;">
|
||||
<div class="bsf-core-rollback-overlay"></div>
|
||||
<div class="bsf-confirm-rollback-popup-content">
|
||||
<h3 class="bsf-rollback-heading bsf-confirm-heading" data-text="<?php esc_html_e( 'Rollback #PRODUCT_NAME# Version', 'bsf-core' ); ?>"></h3>
|
||||
<p class="bsf-confirm-text bsf-rollback-text" data-text="<?php esc_html_e( 'Are you sure you want to rollback #PRODUCT_NAME# to version #VERSION#?', 'bsf-core' ); ?>" ></p>
|
||||
<div class="bsf-confirm-rollback-popup-buttons-wrapper">
|
||||
<button class="button bsf-product-license button-default bsf-confirm-cancel"><?php esc_html_e( 'Cancel', 'bsf-core' ); ?></button>
|
||||
<button class="button button-primary bsf-confirm-ok"><?php esc_html_e( 'Continue', 'bsf-core' ); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new BSF_Rollback_Version_Manager();
|
||||
|
||||
/**
|
||||
* Render Rollback versoin form.
|
||||
*
|
||||
* @param string $product_id Product ID.
|
||||
*/
|
||||
function bsf_get_version_rollback_form( $product_id ) {
|
||||
if ( ! bsf_display_rollback_version_form( $product_id ) ) {
|
||||
return false;
|
||||
}
|
||||
$instance = new BSF_Rollback_Version_Manager();
|
||||
$instance->render_rollback_version_form( $product_id );
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,113 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* WP CLI Commands to manage Brainstorm Force products.
|
||||
*
|
||||
* @package bsf-core
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class BSF_WP_CLI_Command
|
||||
*/
|
||||
class BSF_WP_CLI_Command extends WP_CLI_Command {
|
||||
|
||||
/**
|
||||
* BSF_License Manager instance.
|
||||
*
|
||||
* @var $license_manager
|
||||
*/
|
||||
private $license_manager = '';
|
||||
|
||||
/**
|
||||
* Initiator.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->license_manager = new BSF_License_Manager();
|
||||
}
|
||||
|
||||
/**
|
||||
* WP CLI Command to activate and deactivate licenses for brainstormforce products.
|
||||
*
|
||||
* ## OPTIONS
|
||||
*
|
||||
* <action>
|
||||
* activate or deactivate
|
||||
*
|
||||
* <priduct-id>
|
||||
* Product id is unique for each brainstorm product, it can be found in the file <product-root-directory>/admin/.bsf.yml
|
||||
*
|
||||
* <license-key>
|
||||
* Your purchase key.
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* 1. wp brainstormforce license activate uabb <purchase-key>
|
||||
* - This will activate the license for plugin Ultimate Addons for beaver builder with purchase key <purchase-key>
|
||||
* 2. wp brainstormforce license deactivate uabb <purchase-key>
|
||||
* - This will deactivate the license for plugin Ultimate Addons for beaver builder with purchase key <purchase-key>
|
||||
*
|
||||
* @param array $args Arguments.
|
||||
* @param array $assoc_args Associative Arguments.
|
||||
*/
|
||||
public function license( $args, $assoc_args ) {
|
||||
|
||||
if ( isset( $args[0] ) && 'activate' === $args[0] || 'deactivate' === $args[0] ) {
|
||||
$action = $args[0];
|
||||
} else {
|
||||
WP_CLI::error( 'Please enter the correct action.' );
|
||||
}
|
||||
|
||||
if ( isset( $args[1] ) ) {
|
||||
$poduct_id = $args[1];
|
||||
} else {
|
||||
WP_CLI::error( 'Please enter a product id.' );
|
||||
}
|
||||
|
||||
if ( isset( $args[2] ) ) {
|
||||
$purchase_key = $args[2];
|
||||
} else {
|
||||
WP_CLI::error( 'Please enter the purchase key.' );
|
||||
}
|
||||
|
||||
// Setup brainstorm_products data.
|
||||
init_bsf_core();
|
||||
|
||||
$_POST = array(
|
||||
'bsf_license_manager' => array(
|
||||
'license_key' => $purchase_key,
|
||||
'product_id' => $poduct_id,
|
||||
),
|
||||
);
|
||||
|
||||
$bsf_action = '';
|
||||
|
||||
if ( 'activate' === $action ) {
|
||||
$bsf_action = 'bsf_license_activation';
|
||||
$_POST['bsf_activate_license'] = true;
|
||||
$_POST['bsf_graupi_nonce'] = wp_create_nonce( 'bsf_license_activation_deactivation_nonce' );
|
||||
$this->license_manager->bsf_activate_license();
|
||||
} else {
|
||||
$bsf_action = 'bsf_license_deactivation';
|
||||
$_POST['bsf_deactivate_license'] = true;
|
||||
$_POST['bsf_graupi_nonce'] = wp_create_nonce( 'bsf_license_activation_deactivation_nonce' );
|
||||
$this->license_manager->bsf_deactivate_license();
|
||||
}
|
||||
|
||||
if ( '' !== $bsf_action ) {
|
||||
if ( isset( $_POST[ $bsf_action ]['success'] ) && ( true === $_POST[ $bsf_action ]['success'] || 'true' === $_POST[ $bsf_action ]['success'] ) && isset( $_POST['bsf_graupi_nonce'] ) && wp_verify_nonce( $_POST['bsf_graupi_nonce'], 'bsf_license_activation_deactivation_nonce' ) ) {
|
||||
|
||||
$success_message = esc_attr( $_POST[ $bsf_action ]['message'] );
|
||||
|
||||
WP_CLI::success( $success_message );
|
||||
} else {
|
||||
$error_message = esc_attr( $_POST[ $bsf_action ]['message'] );
|
||||
|
||||
WP_CLI::error( $error_message );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_CLI' ) ) {
|
||||
WP_CLI::add_command( 'brainstormforce', 'BSF_WP_CLI_Command' );
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* WP CLI Commands to manage Brainstorm Force products.
|
||||
*
|
||||
* @package bsf-core
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class BSF_WP_CLI_Command
|
||||
*/
|
||||
class BSF_WP_CLI_Command extends WP_CLI_Command {
|
||||
|
||||
/**
|
||||
* BSF_License Manager instance.
|
||||
*
|
||||
* @var $license_manager
|
||||
*/
|
||||
private $license_manager = '';
|
||||
|
||||
/**
|
||||
* Initiator.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->license_manager = new BSF_License_Manager();
|
||||
}
|
||||
|
||||
/**
|
||||
* WP CLI Command to activate and deactivate licenses for brainstormforce products.
|
||||
*
|
||||
* ## OPTIONS
|
||||
*
|
||||
* <action>
|
||||
* activate or deactivate
|
||||
*
|
||||
* <priduct-id>
|
||||
* Product id is unique for each brainstorm product, it can be found in the file <product-root-directory>/admin/.bsf.yml
|
||||
*
|
||||
* <license-key>
|
||||
* Your purchase key.
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* 1. wp brainstormforce license activate uabb <purchase-key>
|
||||
* - This will activate the license for plugin Ultimate Addons for beaver builder with purchase key <purchase-key>
|
||||
* 2. wp brainstormforce license deactivate uabb <purchase-key>
|
||||
* - This will deactivate the license for plugin Ultimate Addons for beaver builder with purchase key <purchase-key>
|
||||
*
|
||||
* @param array $args Arguments.
|
||||
* @param array $assoc_args Associative Arguments.
|
||||
*/
|
||||
public function license( $args, $assoc_args ) {
|
||||
|
||||
if ( isset( $args[0] ) && 'activate' === $args[0] || 'deactivate' === $args[0] ) {
|
||||
$action = $args[0];
|
||||
} else {
|
||||
WP_CLI::error( 'Please enter the correct action.' );
|
||||
}
|
||||
|
||||
if ( isset( $args[1] ) ) {
|
||||
$poduct_id = $args[1];
|
||||
} else {
|
||||
WP_CLI::error( 'Please enter a product id.' );
|
||||
}
|
||||
|
||||
if ( isset( $args[2] ) ) {
|
||||
$purchase_key = $args[2];
|
||||
} else {
|
||||
WP_CLI::error( 'Please enter the purchase key.' );
|
||||
}
|
||||
|
||||
// Setup brainstorm_products data.
|
||||
init_bsf_core();
|
||||
|
||||
$_POST = array(
|
||||
'bsf_license_manager' => array(
|
||||
'license_key' => $purchase_key,
|
||||
'product_id' => $poduct_id,
|
||||
),
|
||||
);
|
||||
|
||||
$bsf_action = '';
|
||||
|
||||
if ( 'activate' === $action ) {
|
||||
$bsf_action = 'bsf_license_activation';
|
||||
$_POST['bsf_activate_license'] = true;
|
||||
$_POST['bsf_graupi_nonce'] = wp_create_nonce( 'bsf_license_activation_deactivation_nonce' );
|
||||
$this->license_manager->bsf_activate_license();
|
||||
} else {
|
||||
$bsf_action = 'bsf_license_deactivation';
|
||||
$_POST['bsf_deactivate_license'] = true;
|
||||
$_POST['bsf_graupi_nonce'] = wp_create_nonce( 'bsf_license_activation_deactivation_nonce' );
|
||||
$this->license_manager->bsf_deactivate_license();
|
||||
}
|
||||
|
||||
if ( '' !== $bsf_action ) {
|
||||
if ( isset( $_POST[ $bsf_action ]['success'] ) && ( true === $_POST[ $bsf_action ]['success'] || 'true' === $_POST[ $bsf_action ]['success'] ) && isset( $_POST['bsf_graupi_nonce'] ) && wp_verify_nonce( $_POST['bsf_graupi_nonce'], 'bsf_license_activation_deactivation_nonce' ) ) {
|
||||
|
||||
$success_message = esc_attr( $_POST[ $bsf_action ]['message'] );
|
||||
|
||||
WP_CLI::success( $success_message );
|
||||
} else {
|
||||
$error_message = esc_attr( $_POST[ $bsf_action ]['message'] );
|
||||
|
||||
WP_CLI::error( $error_message );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_CLI' ) ) {
|
||||
WP_CLI::add_command( 'brainstormforce', 'BSF_WP_CLI_Command' );
|
||||
}
|
||||
|
||||
@@ -1,117 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* BSF Core REST API
|
||||
*
|
||||
* @package bsf-core
|
||||
*/
|
||||
|
||||
/**
|
||||
* License Activation/Deactivation REST API.
|
||||
*/
|
||||
class Bsf_Core_Rest {
|
||||
|
||||
/**
|
||||
* Member Variable
|
||||
*
|
||||
* @var instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* The namespace of this controller's route.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $namespace;
|
||||
|
||||
/**
|
||||
* The base of this controller's route.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $rest_base;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->namespace = 'bsf-core/v1';
|
||||
$this->rest_base = '/license';
|
||||
|
||||
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the routes for the objects of the controller.
|
||||
*/
|
||||
public function register_routes() {
|
||||
register_rest_route(
|
||||
$this->namespace,
|
||||
$this->rest_base . '/activate',
|
||||
array(
|
||||
'methods' => WP_REST_Server::CREATABLE,
|
||||
'callback' => array( $this, 'activate_license' ),
|
||||
'permission_callback' => array( $this, 'get_items_permissions_check' ),
|
||||
'args' => array(
|
||||
'product-id' => array(
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
),
|
||||
'license-key' => array(
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given request has access to activate license.
|
||||
*
|
||||
* @param WP_REST_Request $request Full details about the request.
|
||||
* @return WP_Error|boolean
|
||||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( current_user_can( 'manage_options' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate License Key.
|
||||
*
|
||||
* @param WP_REST_Request $request Full details about the request.
|
||||
* @return WP_REST_Response Rest Response with access key.
|
||||
*/
|
||||
public function activate_license( $request ) {
|
||||
$product_id = $request->get_param( 'product-id' );
|
||||
$license_key = $request->get_param( 'license-key' );
|
||||
|
||||
$data = array(
|
||||
'privacy_consent' => true,
|
||||
'terms_conditions_consent' => true,
|
||||
'product_id' => $product_id,
|
||||
'license_key' => $license_key,
|
||||
);
|
||||
|
||||
return rest_ensure_response( BSF_License_Manager::instance()->bsf_process_license_activation( $data ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Bsf_Core_Rest::get_instance();
|
||||
<?php
|
||||
/**
|
||||
* BSF Core REST API
|
||||
*
|
||||
* @package bsf-core
|
||||
*/
|
||||
|
||||
/**
|
||||
* License Activation/Deactivation REST API.
|
||||
*/
|
||||
class Bsf_Core_Rest {
|
||||
|
||||
/**
|
||||
* Member Variable
|
||||
*
|
||||
* @var instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* The namespace of this controller's route.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $namespace;
|
||||
|
||||
/**
|
||||
* The base of this controller's route.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $rest_base;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->namespace = 'bsf-core/v1';
|
||||
$this->rest_base = '/license';
|
||||
|
||||
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the routes for the objects of the controller.
|
||||
*/
|
||||
public function register_routes() {
|
||||
register_rest_route(
|
||||
$this->namespace,
|
||||
$this->rest_base . '/activate',
|
||||
array(
|
||||
'methods' => WP_REST_Server::CREATABLE,
|
||||
'callback' => array( $this, 'activate_license' ),
|
||||
'permission_callback' => array( $this, 'get_items_permissions_check' ),
|
||||
'args' => array(
|
||||
'product-id' => array(
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
),
|
||||
'license-key' => array(
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given request has access to activate license.
|
||||
*
|
||||
* @param WP_REST_Request $request Full details about the request.
|
||||
* @return WP_Error|boolean
|
||||
*/
|
||||
public function get_items_permissions_check( $request ) {
|
||||
if ( current_user_can( 'manage_options' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate License Key.
|
||||
*
|
||||
* @param WP_REST_Request $request Full details about the request.
|
||||
* @return WP_REST_Response Rest Response with access key.
|
||||
*/
|
||||
public function activate_license( $request ) {
|
||||
$product_id = $request->get_param( 'product-id' );
|
||||
$license_key = $request->get_param( 'license-key' );
|
||||
|
||||
$data = array(
|
||||
'privacy_consent' => true,
|
||||
'terms_conditions_consent' => true,
|
||||
'product_id' => $product_id,
|
||||
'license_key' => $license_key,
|
||||
);
|
||||
|
||||
return rest_ensure_response( BSF_License_Manager::instance()->bsf_process_license_activation( $data ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Bsf_Core_Rest::get_instance();
|
||||
|
||||
@@ -1,98 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* BSF Core Update
|
||||
*
|
||||
* @package Astra
|
||||
* @author Astra
|
||||
* @copyright Copyright (c) 2020, Astra
|
||||
* @link http://wpastra.com/
|
||||
* @since Astra 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_Core_Update' ) ) {
|
||||
|
||||
/**
|
||||
* BSF_Core_Update initial setup
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_Core_Update {
|
||||
|
||||
/**
|
||||
* Class instance.
|
||||
*
|
||||
* @access private
|
||||
* @var $instance Class instance.
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Theme Updates.
|
||||
add_action( 'admin_init', __CLASS__ . '::init', 0 );
|
||||
add_filter( 'all_plugins', array( $this, 'update_products_slug' ), 10, 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement theme update logic.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function init() {
|
||||
do_action( 'astra_update_before' );
|
||||
|
||||
// Get auto saved version number.
|
||||
$saved_version = get_option( 'bsf-updater-version', false );
|
||||
|
||||
// If equals then return.
|
||||
if ( version_compare( $saved_version, BSF_UPDATER_VERSION, '=' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// // Update auto saved version number.
|
||||
update_option( 'bsf-updater-version', BSF_UPDATER_VERSION );
|
||||
|
||||
do_action( 'astra_update_after' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update bsf product slug in WP installed plugins data which will be used in enable/disablestaged updates products.
|
||||
*
|
||||
* @param array $plugins All installed plugins.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function update_products_slug( $plugins ) {
|
||||
$bsf_products = bsf_get_brainstorm_products( true );
|
||||
|
||||
foreach ( $bsf_products as $product => $data ) {
|
||||
$plugin_file = isset( $data['template'] ) ? sanitize_text_field( $data['template'] ) : '';
|
||||
if ( isset( $plugins[ $plugin_file ] ) && ! empty( $data['slug'] ) ) {
|
||||
$plugins[ $plugin_file ]['slug'] = $data['slug'];
|
||||
}
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicking this off by calling 'get_instance()' method
|
||||
*/
|
||||
BSF_Core_Update::get_instance();
|
||||
<?php
|
||||
/**
|
||||
* BSF Core Update
|
||||
*
|
||||
* @package Astra
|
||||
* @author Astra
|
||||
* @copyright Copyright (c) 2020, Astra
|
||||
* @link http://wpastra.com/
|
||||
* @since Astra 1.0.0
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'BSF_Core_Update' ) ) {
|
||||
|
||||
/**
|
||||
* BSF_Core_Update initial setup
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class BSF_Core_Update {
|
||||
|
||||
/**
|
||||
* Class instance.
|
||||
*
|
||||
* @access private
|
||||
* @var $instance Class instance.
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
// Theme Updates.
|
||||
add_action( 'admin_init', __CLASS__ . '::init', 0 );
|
||||
add_filter( 'all_plugins', array( $this, 'update_products_slug' ), 10, 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement theme update logic.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function init() {
|
||||
do_action( 'astra_update_before' );
|
||||
|
||||
// Get auto saved version number.
|
||||
$saved_version = get_option( 'bsf-updater-version', false );
|
||||
|
||||
// If equals then return.
|
||||
if ( version_compare( $saved_version, BSF_UPDATER_VERSION, '=' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// // Update auto saved version number.
|
||||
update_option( 'bsf-updater-version', BSF_UPDATER_VERSION );
|
||||
|
||||
do_action( 'astra_update_after' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update bsf product slug in WP installed plugins data which will be used in enable/disablestaged updates products.
|
||||
*
|
||||
* @param array $plugins All installed plugins.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function update_products_slug( $plugins ) {
|
||||
$bsf_products = bsf_get_brainstorm_products( true );
|
||||
|
||||
foreach ( $bsf_products as $product => $data ) {
|
||||
$plugin_file = isset( $data['template'] ) ? sanitize_text_field( $data['template'] ) : '';
|
||||
if ( isset( $plugins[ $plugin_file ] ) && ! empty( $data['slug'] ) ) {
|
||||
$plugins[ $plugin_file ]['slug'] = $data['slug'];
|
||||
}
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicking this off by calling 'get_instance()' method
|
||||
*/
|
||||
BSF_Core_Update::get_instance();
|
||||
|
||||
@@ -1,89 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* BSF extension installer class file.
|
||||
*
|
||||
* @package bsf-core
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* BSF_Extension_Installer Extension installer.
|
||||
*/
|
||||
class BSF_Extension_Installer {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
|
||||
add_action( 'wp_ajax_bsf-extention-activate', array( $this, 'activate_plugin' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Load scripts needed for extension installer.
|
||||
*
|
||||
* @param hook $hook current page hook.
|
||||
* @return void
|
||||
*/
|
||||
public function load_scripts( $hook ) {
|
||||
$bsf_ext_inst = apply_filters( 'bsf_extension_installer_screens', array( 'bsf-extensions' ), $hook );
|
||||
|
||||
foreach ( $bsf_ext_inst as $key => $value ) {
|
||||
if ( false !== strpos( $hook, $value ) ) {
|
||||
wp_register_script( 'bsf-extension-installer', bsf_core_url( '/assets/js/extension-installer.js' ), array( 'jquery', 'wp-util', 'updates' ), BSF_UPDATER_VERSION, true );
|
||||
wp_enqueue_script( 'bsf-extension-installer' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates plugin.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function activate_plugin() {
|
||||
|
||||
if ( ! wp_verify_nonce( $_POST['security'], 'bsf_activate_extension_nonce' ) ) {
|
||||
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'success' => false,
|
||||
'message' => __( 'You are not authorized to perform this action.', 'bsf' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'install_plugins' ) || ! isset( $_POST['init'] ) || ! $_POST['init'] ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'success' => false,
|
||||
'message' => __( 'No plugin specified', 'bsf' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$plugin_init = ( isset( $_POST['init'] ) ) ? esc_attr( $_POST['init'] ) : '';
|
||||
$activate = activate_plugin( $plugin_init, '', false, true );
|
||||
|
||||
if ( is_wp_error( $activate ) ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'success' => false,
|
||||
'message' => $activate->get_error_message(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
'success' => true,
|
||||
'message' => __( 'Plugin Activated', 'bsf' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
new BSF_Extension_Installer();
|
||||
<?php
|
||||
/**
|
||||
* BSF extension installer class file.
|
||||
*
|
||||
* @package bsf-core
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* BSF_Extension_Installer Extension installer.
|
||||
*/
|
||||
class BSF_Extension_Installer {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
|
||||
add_action( 'wp_ajax_bsf-extention-activate', array( $this, 'activate_plugin' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Load scripts needed for extension installer.
|
||||
*
|
||||
* @param hook $hook current page hook.
|
||||
* @return void
|
||||
*/
|
||||
public function load_scripts( $hook ) {
|
||||
$bsf_ext_inst = apply_filters( 'bsf_extension_installer_screens', array( 'bsf-extensions' ), $hook );
|
||||
|
||||
foreach ( $bsf_ext_inst as $key => $value ) {
|
||||
if ( false !== strpos( $hook, $value ) ) {
|
||||
wp_register_script( 'bsf-extension-installer', bsf_core_url( '/assets/js/extension-installer.js' ), array( 'jquery', 'wp-util', 'updates' ), BSF_UPDATER_VERSION, true );
|
||||
wp_enqueue_script( 'bsf-extension-installer' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates plugin.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function activate_plugin() {
|
||||
|
||||
if ( ! wp_verify_nonce( $_POST['security'], 'bsf_activate_extension_nonce' ) ) {
|
||||
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'success' => false,
|
||||
'message' => __( 'You are not authorized to perform this action.', 'bsf' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'install_plugins' ) || ! isset( $_POST['init'] ) || ! $_POST['init'] ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'success' => false,
|
||||
'message' => __( 'No plugin specified', 'bsf' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$plugin_init = ( isset( $_POST['init'] ) ) ? esc_attr( $_POST['init'] ) : '';
|
||||
$activate = activate_plugin( $plugin_init, '', false, true );
|
||||
|
||||
if ( is_wp_error( $activate ) ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'success' => false,
|
||||
'message' => $activate->get_error_message(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
'success' => true,
|
||||
'message' => __( 'Plugin Activated', 'bsf' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
new BSF_Extension_Installer();
|
||||
|
||||
@@ -1,242 +1,242 @@
|
||||
<?php
|
||||
/**
|
||||
* BSF Rollback Version
|
||||
*
|
||||
* @package bsf-core
|
||||
* @author Brainstorm Force
|
||||
* @link http://wpastra.com/
|
||||
*/
|
||||
|
||||
/**
|
||||
* BSF_Core_Update initial setup
|
||||
*/
|
||||
class BSF_Rollback_Version {
|
||||
/**
|
||||
* Package URL.
|
||||
*
|
||||
* Holds the package URL.
|
||||
* This will be the actual download URL od zip file.
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @var string Package URL.
|
||||
*/
|
||||
protected $package_url;
|
||||
|
||||
/**
|
||||
* Product URL.
|
||||
*
|
||||
* @access protected
|
||||
* @var string Product URL.
|
||||
*/
|
||||
protected $product_url;
|
||||
|
||||
/**
|
||||
* Version.
|
||||
*
|
||||
* Holds the version.
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @var string Package URL.
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
/**
|
||||
* Plugin name.
|
||||
*
|
||||
* Holds the plugin name.
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @var string Plugin name.
|
||||
*/
|
||||
protected $plugin_name;
|
||||
|
||||
/**
|
||||
* Plugin slug.
|
||||
*
|
||||
* Holds the plugin slug.
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @var string Plugin slug.
|
||||
*/
|
||||
protected $plugin_slug;
|
||||
|
||||
/**
|
||||
* Product Title.
|
||||
*
|
||||
* Holds the Product Title.
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @var string Plugin Title.
|
||||
*/
|
||||
protected $product_title;
|
||||
|
||||
/**
|
||||
* HOlds the Product ID.
|
||||
*
|
||||
* @access protected
|
||||
* @var string Product ID.
|
||||
*/
|
||||
protected $product_id;
|
||||
|
||||
/**
|
||||
*
|
||||
* Initializing Rollback.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param array $args Optional.Rollback arguments. Default is an empty array.
|
||||
*/
|
||||
public function __construct( $args = array() ) {
|
||||
foreach ( $args as $key => $value ) {
|
||||
$this->{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply package.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
*/
|
||||
protected function apply_package() {
|
||||
$update_products = get_site_transient( 'update_plugins' );
|
||||
if ( ! is_object( $update_products ) ) {
|
||||
$update_products = new stdClass();
|
||||
}
|
||||
|
||||
$product_info = new stdClass();
|
||||
$product_info->new_version = $this->version;
|
||||
$product_info->slug = $this->plugin_slug;
|
||||
$product_info->package = $this->package_url; // This will be the actual download URL of zip file..
|
||||
$product_info->url = $this->product_url;
|
||||
|
||||
$update_products->response[ $this->plugin_name ] = $product_info;
|
||||
|
||||
set_site_transient( 'update_plugins', $update_products );
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade.
|
||||
*
|
||||
* Run WordPress upgrade to Rollback to previous version.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
*/
|
||||
protected function upgrade() {
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
$upgrader_args = array(
|
||||
'url' => 'update.php?action=upgrade-plugin&plugin=' . rawurlencode( $this->plugin_name ),
|
||||
'plugin' => $this->plugin_name,
|
||||
'nonce' => 'upgrade-plugin_' . $this->plugin_name,
|
||||
'title' => apply_filters( 'bsf_rollback_' . $this->product_id . '_title', '<h1>Rollback ' . bsf_get_white_lable_product_name( $this->product_id, $this->product_title ) . ' to version ' . $this->version . ' </h1>' ),
|
||||
);
|
||||
|
||||
$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( $upgrader_args ) );
|
||||
$upgrader->upgrade( $this->plugin_name );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Rollback to previous versions.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
public function run() {
|
||||
$this->apply_package();
|
||||
$this->upgrade();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get All versions of product.
|
||||
*
|
||||
* @param string $product_id Product ID.
|
||||
*/
|
||||
public static function bsf_get_product_versions( $product_id ) {
|
||||
if ( empty( $product_id ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// Check is transient is expire or User has Enalbed/Disabled the beta version.
|
||||
$versions_transient = get_site_transient( 'bsf-product-versions-' . $product_id );
|
||||
if ( false !== $versions_transient && false === self::is_beta_enabled_rollback( $product_id ) ) {
|
||||
return $versions_transient;
|
||||
}
|
||||
|
||||
$per_page = apply_filters( 'bsf_show_versions_to_rollback_' . $product_id, 10 );
|
||||
$path = bsf_get_api_site( false, true ) . 'versions/' . $product_id . '?per_page=' . $per_page;
|
||||
if ( BSF_Update_Manager::bsf_allow_beta_updates( $product_id ) ) {
|
||||
$path = add_query_arg( 'include_beta', 'true', $path );
|
||||
}
|
||||
|
||||
$response = wp_remote_get(
|
||||
$path,
|
||||
array(
|
||||
'timeout' => '10',
|
||||
)
|
||||
);
|
||||
|
||||
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$response_versions = json_decode( wp_remote_retrieve_body( $response ), true );
|
||||
// Cache product version for 24 hrs.
|
||||
set_site_transient( 'bsf-product-versions-' . $product_id, $response_versions, 24 * HOUR_IN_SECONDS );
|
||||
|
||||
return $response_versions;
|
||||
}
|
||||
/**
|
||||
* This will filter the versions and return the versions less than current installed version.
|
||||
*
|
||||
* @param array $version_arr array of versions.
|
||||
* @param string $current_version Current install version.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function sort_product_versions( $version_arr, $current_version ) {
|
||||
$rollback_versions = array();
|
||||
|
||||
foreach ( $version_arr as $version ) {
|
||||
if ( version_compare( $version, $current_version, '>=' ) ) {
|
||||
continue;
|
||||
}
|
||||
$rollback_versions[] = $version;
|
||||
}
|
||||
|
||||
return $rollback_versions;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is added to update the trasient data of product version on beta update enabled/disabled action.
|
||||
* This will set the flag in db options that should beta versions include/removed in the rollback versions list based on enabled/disabled beta updates for the product.
|
||||
*
|
||||
* @param string $product_id Product ID.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_beta_enabled_rollback( $product_id ) {
|
||||
$allow_beta_update = BSF_Update_Manager::bsf_allow_beta_updates( $product_id );
|
||||
$is_beta_enable = ( false === $allow_beta_update ) ? '0' : '1';
|
||||
|
||||
// Set the initial flag for is beta enelbled/ disabled.
|
||||
if ( false === get_option( 'is_beta_enable_rollback_' . $product_id ) ) {
|
||||
update_option( 'is_beta_enable_rollback_' . $product_id, $is_beta_enable );
|
||||
return false;
|
||||
}
|
||||
|
||||
// If user has enalbed/ disabled beta update then upadate the rollback version transient data.
|
||||
if ( get_option( 'is_beta_enable_rollback_' . $product_id ) !== $is_beta_enable ) {
|
||||
update_option( 'is_beta_enable_rollback_' . $product_id, $is_beta_enable );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* BSF Rollback Version
|
||||
*
|
||||
* @package bsf-core
|
||||
* @author Brainstorm Force
|
||||
* @link http://wpastra.com/
|
||||
*/
|
||||
|
||||
/**
|
||||
* BSF_Core_Update initial setup
|
||||
*/
|
||||
class BSF_Rollback_Version {
|
||||
/**
|
||||
* Package URL.
|
||||
*
|
||||
* Holds the package URL.
|
||||
* This will be the actual download URL od zip file.
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @var string Package URL.
|
||||
*/
|
||||
protected $package_url;
|
||||
|
||||
/**
|
||||
* Product URL.
|
||||
*
|
||||
* @access protected
|
||||
* @var string Product URL.
|
||||
*/
|
||||
protected $product_url;
|
||||
|
||||
/**
|
||||
* Version.
|
||||
*
|
||||
* Holds the version.
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @var string Package URL.
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
/**
|
||||
* Plugin name.
|
||||
*
|
||||
* Holds the plugin name.
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @var string Plugin name.
|
||||
*/
|
||||
protected $plugin_name;
|
||||
|
||||
/**
|
||||
* Plugin slug.
|
||||
*
|
||||
* Holds the plugin slug.
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @var string Plugin slug.
|
||||
*/
|
||||
protected $plugin_slug;
|
||||
|
||||
/**
|
||||
* Product Title.
|
||||
*
|
||||
* Holds the Product Title.
|
||||
*
|
||||
* @access protected
|
||||
*
|
||||
* @var string Plugin Title.
|
||||
*/
|
||||
protected $product_title;
|
||||
|
||||
/**
|
||||
* HOlds the Product ID.
|
||||
*
|
||||
* @access protected
|
||||
* @var string Product ID.
|
||||
*/
|
||||
protected $product_id;
|
||||
|
||||
/**
|
||||
*
|
||||
* Initializing Rollback.
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param array $args Optional.Rollback arguments. Default is an empty array.
|
||||
*/
|
||||
public function __construct( $args = array() ) {
|
||||
foreach ( $args as $key => $value ) {
|
||||
$this->{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply package.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
*/
|
||||
protected function apply_package() {
|
||||
$update_products = get_site_transient( 'update_plugins' );
|
||||
if ( ! is_object( $update_products ) ) {
|
||||
$update_products = new stdClass();
|
||||
}
|
||||
|
||||
$product_info = new stdClass();
|
||||
$product_info->new_version = $this->version;
|
||||
$product_info->slug = $this->plugin_slug;
|
||||
$product_info->package = $this->package_url; // This will be the actual download URL of zip file..
|
||||
$product_info->url = $this->product_url;
|
||||
|
||||
$update_products->response[ $this->plugin_name ] = $product_info;
|
||||
|
||||
set_site_transient( 'update_plugins', $update_products );
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade.
|
||||
*
|
||||
* Run WordPress upgrade to Rollback to previous version.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
*/
|
||||
protected function upgrade() {
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
$upgrader_args = array(
|
||||
'url' => 'update.php?action=upgrade-plugin&plugin=' . rawurlencode( $this->plugin_name ),
|
||||
'plugin' => $this->plugin_name,
|
||||
'nonce' => 'upgrade-plugin_' . $this->plugin_name,
|
||||
'title' => apply_filters( 'bsf_rollback_' . $this->product_id . '_title', '<h1>Rollback ' . bsf_get_white_lable_product_name( $this->product_id, $this->product_title ) . ' to version ' . $this->version . ' </h1>' ),
|
||||
);
|
||||
|
||||
$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( $upgrader_args ) );
|
||||
$upgrader->upgrade( $this->plugin_name );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Rollback to previous versions.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
public function run() {
|
||||
$this->apply_package();
|
||||
$this->upgrade();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get All versions of product.
|
||||
*
|
||||
* @param string $product_id Product ID.
|
||||
*/
|
||||
public static function bsf_get_product_versions( $product_id ) {
|
||||
if ( empty( $product_id ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// Check is transient is expire or User has Enalbed/Disabled the beta version.
|
||||
$versions_transient = get_site_transient( 'bsf-product-versions-' . $product_id );
|
||||
if ( false !== $versions_transient && false === self::is_beta_enabled_rollback( $product_id ) ) {
|
||||
return $versions_transient;
|
||||
}
|
||||
|
||||
$per_page = apply_filters( 'bsf_show_versions_to_rollback_' . $product_id, 10 );
|
||||
$path = bsf_get_api_site( false, true ) . 'versions/' . $product_id . '?per_page=' . $per_page;
|
||||
if ( BSF_Update_Manager::bsf_allow_beta_updates( $product_id ) ) {
|
||||
$path = add_query_arg( 'include_beta', 'true', $path );
|
||||
}
|
||||
|
||||
$response = wp_remote_get(
|
||||
$path,
|
||||
array(
|
||||
'timeout' => '10',
|
||||
)
|
||||
);
|
||||
|
||||
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$response_versions = json_decode( wp_remote_retrieve_body( $response ), true );
|
||||
// Cache product version for 24 hrs.
|
||||
set_site_transient( 'bsf-product-versions-' . $product_id, $response_versions, 24 * HOUR_IN_SECONDS );
|
||||
|
||||
return $response_versions;
|
||||
}
|
||||
/**
|
||||
* This will filter the versions and return the versions less than current installed version.
|
||||
*
|
||||
* @param array $version_arr array of versions.
|
||||
* @param string $current_version Current install version.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function sort_product_versions( $version_arr, $current_version ) {
|
||||
$rollback_versions = array();
|
||||
|
||||
foreach ( $version_arr as $version ) {
|
||||
if ( version_compare( $version, $current_version, '>=' ) ) {
|
||||
continue;
|
||||
}
|
||||
$rollback_versions[] = $version;
|
||||
}
|
||||
|
||||
return $rollback_versions;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is added to update the trasient data of product version on beta update enabled/disabled action.
|
||||
* This will set the flag in db options that should beta versions include/removed in the rollback versions list based on enabled/disabled beta updates for the product.
|
||||
*
|
||||
* @param string $product_id Product ID.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_beta_enabled_rollback( $product_id ) {
|
||||
$allow_beta_update = BSF_Update_Manager::bsf_allow_beta_updates( $product_id );
|
||||
$is_beta_enable = ( false === $allow_beta_update ) ? '0' : '1';
|
||||
|
||||
// Set the initial flag for is beta enelbled/ disabled.
|
||||
if ( false === get_option( 'is_beta_enable_rollback_' . $product_id ) ) {
|
||||
update_option( 'is_beta_enable_rollback_' . $product_id, $is_beta_enable );
|
||||
return false;
|
||||
}
|
||||
|
||||
// If user has enalbed/ disabled beta update then upadate the rollback version transient data.
|
||||
if ( get_option( 'is_beta_enable_rollback_' . $product_id ) !== $is_beta_enable ) {
|
||||
update_option( 'is_beta_enable_rollback_' . $product_id, $is_beta_enable );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
{
|
||||
"name": "brainstormforce/bsf-core",
|
||||
"type": "wordpress-plugin",
|
||||
"description": "WordPress updater for Premium Products from Brainstorm Force",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Brainstorm Force",
|
||||
"email": "hello@bsf.io"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"composer/installers": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
||||
"phpcompatibility/phpcompatibility-wp": "*",
|
||||
"wp-cli/dist-archive-command": "^2.0",
|
||||
"wp-coding-standards/wpcs": "dev-master"
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"scripts": {
|
||||
"format": "vendor/bin/phpcbf --standard=phpcs.xml.dist",
|
||||
"lint": "vendor/bin/phpcs --standard=phpcs.xml.dist"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "brainstormforce/bsf-core",
|
||||
"type": "wordpress-plugin",
|
||||
"description": "WordPress updater for Premium Products from Brainstorm Force",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Brainstorm Force",
|
||||
"email": "hello@bsf.io"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"composer/installers": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
||||
"phpcompatibility/phpcompatibility-wp": "*",
|
||||
"wp-cli/dist-archive-command": "^2.0",
|
||||
"wp-coding-standards/wpcs": "dev-master"
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"scripts": {
|
||||
"format": "vendor/bin/phpcbf --standard=phpcs.xml.dist",
|
||||
"lint": "vendor/bin/phpcs --standard=phpcs.xml.dist"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,403 +1,403 @@
|
||||
<?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();
|
||||
}
|
||||
<?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();
|
||||
}
|
||||
|
||||
@@ -1,292 +1,292 @@
|
||||
<?php
|
||||
/**
|
||||
* System Info File.
|
||||
*
|
||||
* @author Brainstorm Force
|
||||
* @package bsf-core
|
||||
*/
|
||||
|
||||
/**
|
||||
* Display system info.
|
||||
*/
|
||||
function bsf_systeminfo() {
|
||||
|
||||
?>
|
||||
|
||||
<table class="wp-list-table widefat fixed bsf-sys-info">
|
||||
<tbody>
|
||||
<tr class="alternate">
|
||||
<th colspan="2"><?php esc_html_e( 'WordPress Environment', 'bsf' ); ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Home URL</td>
|
||||
<td><?php echo esc_url( site_url() ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Site URL</td>
|
||||
<td><?php echo esc_url( site_url() ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php global $wp_version; ?>
|
||||
<td>WP Version</td>
|
||||
<td><?php echo floatval( $wp_version ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Multisite</td>
|
||||
<td><?php echo ( is_multisite() ) ? 'Yes' : 'No'; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$limit = (int) ini_get( 'memory_limit' );
|
||||
$usage = function_exists( 'memory_get_usage' ) ? round( memory_get_usage() / 1024 / 1024, 2 ) : 0;
|
||||
?>
|
||||
<tr>
|
||||
<td>Memory Usage</td>
|
||||
<td>
|
||||
<?php echo floatval( $usage ); ?>
|
||||
MB of
|
||||
<?php echo intval( $limit ); ?>
|
||||
MB
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>WP Memory Limit</td>
|
||||
<td>
|
||||
<?php echo intval( WP_MEMORY_LIMIT ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>WP Debug</td>
|
||||
<td><?php echo ( WP_DEBUG ) ? 'Enabled' : 'Disabled'; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>WP Lang</td>
|
||||
<?php $currentlang = get_bloginfo( 'language' ); ?>
|
||||
<td><?php echo esc_html( $currentlang ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>WP Uploads Directory</td>
|
||||
<td>
|
||||
<?php
|
||||
$wp_up = wp_upload_dir();
|
||||
echo ( is_writable( $wp_up['basedir'] ) ) ? 'Writable' : 'Readable';
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>BSF Updater Path</td>
|
||||
<td>
|
||||
<?php echo '(v' . esc_attr( BSF_UPDATER_VERSION ) . ') ' . esc_attr( BSF_UPDATER_PATH ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ( defined( 'WPB_VC_VERSION' ) ) : ?>
|
||||
<tr>
|
||||
<td>vc_shortcode_output Filter</td>
|
||||
<td>
|
||||
<?php echo ( has_filter( 'vc_shortcode_output' ) ) ? 'Available' : 'Not Available'; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
$mix = bsf_get_brainstorm_products( true );
|
||||
$temp_constant = '';
|
||||
if ( ! empty( $mix ) ) :
|
||||
foreach ( $mix as $key => $product ) :
|
||||
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
|
||||
$constant = 'BSF_' . $constant . '_CHECK_UPDATES';
|
||||
if ( defined( $constant ) && ( constant( $constant ) === 'false' || constant( $constant ) === false ) ) {
|
||||
$temp_constant .= $constant . '<br/>';
|
||||
continue;
|
||||
}
|
||||
endforeach;
|
||||
endif;
|
||||
if ( defined( 'BSF_CHECK_PRODUCT_UPDATES' ) && false === BSF_CHECK_PRODUCT_UPDATES ) {
|
||||
$temp_constant .= 'BSF_CHECK_PRODUCT_UPDATES';
|
||||
}
|
||||
if ( '' !== $temp_constant ) {
|
||||
if ( ! defined( 'BSF_RESTRICTED_UPDATES' ) ) {
|
||||
define( 'BSF_RESTRICTED_UPDATES', $temp_constant );
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php if ( defined( 'BSF_RESTRICTED_UPDATES' ) ) : ?>
|
||||
<tr>
|
||||
<td>Restrited Updates Filter</td>
|
||||
<td>
|
||||
<?php echo esc_html( BSF_RESTRICTED_UPDATES ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="wp-list-table widefat fixed bsf-sys-info">
|
||||
<tbody>
|
||||
<tr class="alternate">
|
||||
<th colspan="2"><?php esc_html_e( 'Server Environment', 'bsf' ); ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Server Info</td>
|
||||
<td><?php echo esc_html( $_SERVER['SERVER_SOFTWARE'] ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PHP Version</td>
|
||||
<td><?php echo ( function_exists( 'phpversion' ) ) ? floatval( phpversion() ) : 'Not sure'; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>MYSQL Version</td>
|
||||
<td>
|
||||
<?php
|
||||
global $wpdb;
|
||||
echo floatval( $wpdb->db_version() );
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PHP Post Max Size</td>
|
||||
<td><?php echo esc_attr( ini_get( 'post_max_size' ) ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PHP Max Execution Time</td>
|
||||
<td><?php echo esc_attr( ini_get( 'max_execution_time' ) ); ?> Seconds</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PHP Max Input Vars</td>
|
||||
<td><?php echo intval( ini_get( 'max_input_vars' ) ); // PHPCS:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Max Upload Size</td>
|
||||
<td><?php echo intval( ini_get( 'upload_max_filesize' ) ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Default Time Zone</td>
|
||||
<td>
|
||||
<?php
|
||||
if ( date_default_timezone_get() ) {
|
||||
echo esc_html( date_default_timezone_get() );
|
||||
}
|
||||
if ( ini_get( 'date.timezone' ) ) {
|
||||
echo ' ' . esc_html( ini_get( 'date.timezone' ) );
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="<?php echo ( ! function_exists( 'curl_version' ) ) ? 'bsf-alert' : ''; ?>">
|
||||
<td>SimpleXML</td>
|
||||
<td>
|
||||
<?php
|
||||
if ( extension_loaded( 'simplexml' ) ) {
|
||||
echo 'SimpleXML extension is installed';
|
||||
} else {
|
||||
echo 'SimpleXML extension is not enabled.';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="<?php echo ( ! function_exists( 'curl_version' ) ) ? 'bsf-alert' : ''; ?>">
|
||||
<td>cURL</td>
|
||||
<td>
|
||||
<?php
|
||||
if ( function_exists( 'curl_version' ) ) {
|
||||
$curl_info = curl_version();
|
||||
?>
|
||||
|
||||
<div>Version : <strong><?php echo floatval( $curl_info['version'] ); ?></strong></div>
|
||||
<div>SSL Version : <strong><?php echo floatval( $curl_info['ssl_version'] ); ?></strong></div>
|
||||
<div>Host : <strong><?php echo esc_html( $curl_info['host'] ); ?></strong></div>
|
||||
|
||||
<?php
|
||||
} else {
|
||||
echo 'Not Enabled';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$connection = wp_remote_get( bsf_get_api_site() );
|
||||
$support_class = ( is_wp_error( $connection ) || 200 !== wp_remote_retrieve_response_code( $connection ) ) ? 'bsf-alert' : '';
|
||||
|
||||
?>
|
||||
<tr class="<?php echo esc_attr( $support_class ); ?>">
|
||||
<td>Connection to Support API</td>
|
||||
<td>
|
||||
<?php
|
||||
if ( is_wp_error( $connection ) || 200 !== wp_remote_retrieve_response_code( $connection ) ) {
|
||||
echo 'Connection to Support API has error';
|
||||
echo '<p class="description">Status Code: ' . esc_attr( wp_remote_retrieve_response_code( $connection ) ) . '</p>';
|
||||
echo '<p class="description">Error Message: ' . esc_attr( $connection->get_error_message() ) . '</p>';
|
||||
} else {
|
||||
echo 'Connecion to Support API was successful';
|
||||
echo '<p class="description">Status Code: ' . esc_attr( wp_remote_retrieve_response_code( $connection ) ) . '</p>';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="wp-list-table widefat fixed bsf-sys-info">
|
||||
<tbody>
|
||||
<tr class="alternate">
|
||||
<th colspan="2"><?php esc_html_e( 'Theme Information', 'bsf' ); ?></th>
|
||||
</tr>
|
||||
<?php $theme_data = wp_get_theme(); ?>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td><?php echo esc_html( $theme_data->Name ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Version</td>
|
||||
<td><?php echo floatval( $theme_data->Version ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Author</td>
|
||||
<td>
|
||||
<?php echo wp_kses_post( $theme_data->Author ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="wp-list-table widefat fixed bsf-sys-info bsf-table-active-plugin">
|
||||
<tbody>
|
||||
<tr class="alternate">
|
||||
<th colspan="4"><?php esc_html_e( 'Installed Plugins', 'bsf' ); ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
$plugins = get_plugins();
|
||||
asort( $plugins );
|
||||
foreach ( $plugins as $plugin_file => $plugin_data ) {
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo esc_html( str_pad( $plugin_data['Title'], 30 ) ); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
if ( is_plugin_active( $plugin_file ) ) {
|
||||
echo esc_html( str_pad( 'Active', 10 ) );
|
||||
} else {
|
||||
echo esc_html( str_pad( 'Inactive', 10 ) );
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo esc_html( str_pad( $plugin_data['Version'], 10 ) ); ?></td>
|
||||
<td><?php echo esc_html( $plugin_data['Author'] ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Get BSF systeminfo.
|
||||
*/
|
||||
function get_bsf_systeminfo() {
|
||||
$table = '<div class="bsf-system-info-wrapper">';
|
||||
ob_start();
|
||||
bsf_systeminfo();
|
||||
$table .= ob_get_clean();
|
||||
$table .= '</div>';
|
||||
|
||||
return $table;
|
||||
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* System Info File.
|
||||
*
|
||||
* @author Brainstorm Force
|
||||
* @package bsf-core
|
||||
*/
|
||||
|
||||
/**
|
||||
* Display system info.
|
||||
*/
|
||||
function bsf_systeminfo() {
|
||||
|
||||
?>
|
||||
|
||||
<table class="wp-list-table widefat fixed bsf-sys-info">
|
||||
<tbody>
|
||||
<tr class="alternate">
|
||||
<th colspan="2"><?php esc_html_e( 'WordPress Environment', 'bsf' ); ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Home URL</td>
|
||||
<td><?php echo esc_url( site_url() ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Site URL</td>
|
||||
<td><?php echo esc_url( site_url() ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php global $wp_version; ?>
|
||||
<td>WP Version</td>
|
||||
<td><?php echo floatval( $wp_version ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Multisite</td>
|
||||
<td><?php echo ( is_multisite() ) ? 'Yes' : 'No'; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$limit = (int) ini_get( 'memory_limit' );
|
||||
$usage = function_exists( 'memory_get_usage' ) ? round( memory_get_usage() / 1024 / 1024, 2 ) : 0;
|
||||
?>
|
||||
<tr>
|
||||
<td>Memory Usage</td>
|
||||
<td>
|
||||
<?php echo floatval( $usage ); ?>
|
||||
MB of
|
||||
<?php echo intval( $limit ); ?>
|
||||
MB
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>WP Memory Limit</td>
|
||||
<td>
|
||||
<?php echo intval( WP_MEMORY_LIMIT ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>WP Debug</td>
|
||||
<td><?php echo ( WP_DEBUG ) ? 'Enabled' : 'Disabled'; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>WP Lang</td>
|
||||
<?php $currentlang = get_bloginfo( 'language' ); ?>
|
||||
<td><?php echo esc_html( $currentlang ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>WP Uploads Directory</td>
|
||||
<td>
|
||||
<?php
|
||||
$wp_up = wp_upload_dir();
|
||||
echo ( is_writable( $wp_up['basedir'] ) ) ? 'Writable' : 'Readable';
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>BSF Updater Path</td>
|
||||
<td>
|
||||
<?php echo '(v' . esc_attr( BSF_UPDATER_VERSION ) . ') ' . esc_attr( BSF_UPDATER_PATH ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ( defined( 'WPB_VC_VERSION' ) ) : ?>
|
||||
<tr>
|
||||
<td>vc_shortcode_output Filter</td>
|
||||
<td>
|
||||
<?php echo ( has_filter( 'vc_shortcode_output' ) ) ? 'Available' : 'Not Available'; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
$mix = bsf_get_brainstorm_products( true );
|
||||
$temp_constant = '';
|
||||
if ( ! empty( $mix ) ) :
|
||||
foreach ( $mix as $key => $product ) :
|
||||
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
|
||||
$constant = 'BSF_' . $constant . '_CHECK_UPDATES';
|
||||
if ( defined( $constant ) && ( constant( $constant ) === 'false' || constant( $constant ) === false ) ) {
|
||||
$temp_constant .= $constant . '<br/>';
|
||||
continue;
|
||||
}
|
||||
endforeach;
|
||||
endif;
|
||||
if ( defined( 'BSF_CHECK_PRODUCT_UPDATES' ) && false === BSF_CHECK_PRODUCT_UPDATES ) {
|
||||
$temp_constant .= 'BSF_CHECK_PRODUCT_UPDATES';
|
||||
}
|
||||
if ( '' !== $temp_constant ) {
|
||||
if ( ! defined( 'BSF_RESTRICTED_UPDATES' ) ) {
|
||||
define( 'BSF_RESTRICTED_UPDATES', $temp_constant );
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php if ( defined( 'BSF_RESTRICTED_UPDATES' ) ) : ?>
|
||||
<tr>
|
||||
<td>Restrited Updates Filter</td>
|
||||
<td>
|
||||
<?php echo esc_html( BSF_RESTRICTED_UPDATES ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="wp-list-table widefat fixed bsf-sys-info">
|
||||
<tbody>
|
||||
<tr class="alternate">
|
||||
<th colspan="2"><?php esc_html_e( 'Server Environment', 'bsf' ); ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Server Info</td>
|
||||
<td><?php echo esc_html( $_SERVER['SERVER_SOFTWARE'] ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PHP Version</td>
|
||||
<td><?php echo ( function_exists( 'phpversion' ) ) ? floatval( phpversion() ) : 'Not sure'; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>MYSQL Version</td>
|
||||
<td>
|
||||
<?php
|
||||
global $wpdb;
|
||||
echo floatval( $wpdb->db_version() );
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PHP Post Max Size</td>
|
||||
<td><?php echo esc_attr( ini_get( 'post_max_size' ) ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PHP Max Execution Time</td>
|
||||
<td><?php echo esc_attr( ini_get( 'max_execution_time' ) ); ?> Seconds</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PHP Max Input Vars</td>
|
||||
<td><?php echo intval( ini_get( 'max_input_vars' ) ); // PHPCS:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Max Upload Size</td>
|
||||
<td><?php echo intval( ini_get( 'upload_max_filesize' ) ); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Default Time Zone</td>
|
||||
<td>
|
||||
<?php
|
||||
if ( date_default_timezone_get() ) {
|
||||
echo esc_html( date_default_timezone_get() );
|
||||
}
|
||||
if ( ini_get( 'date.timezone' ) ) {
|
||||
echo ' ' . esc_html( ini_get( 'date.timezone' ) );
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="<?php echo ( ! function_exists( 'curl_version' ) ) ? 'bsf-alert' : ''; ?>">
|
||||
<td>SimpleXML</td>
|
||||
<td>
|
||||
<?php
|
||||
if ( extension_loaded( 'simplexml' ) ) {
|
||||
echo 'SimpleXML extension is installed';
|
||||
} else {
|
||||
echo 'SimpleXML extension is not enabled.';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="<?php echo ( ! function_exists( 'curl_version' ) ) ? 'bsf-alert' : ''; ?>">
|
||||
<td>cURL</td>
|
||||
<td>
|
||||
<?php
|
||||
if ( function_exists( 'curl_version' ) ) {
|
||||
$curl_info = curl_version();
|
||||
?>
|
||||
|
||||
<div>Version : <strong><?php echo floatval( $curl_info['version'] ); ?></strong></div>
|
||||
<div>SSL Version : <strong><?php echo floatval( $curl_info['ssl_version'] ); ?></strong></div>
|
||||
<div>Host : <strong><?php echo esc_html( $curl_info['host'] ); ?></strong></div>
|
||||
|
||||
<?php
|
||||
} else {
|
||||
echo 'Not Enabled';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$connection = wp_remote_get( bsf_get_api_site() );
|
||||
$support_class = ( is_wp_error( $connection ) || 200 !== wp_remote_retrieve_response_code( $connection ) ) ? 'bsf-alert' : '';
|
||||
|
||||
?>
|
||||
<tr class="<?php echo esc_attr( $support_class ); ?>">
|
||||
<td>Connection to Support API</td>
|
||||
<td>
|
||||
<?php
|
||||
if ( is_wp_error( $connection ) || 200 !== wp_remote_retrieve_response_code( $connection ) ) {
|
||||
echo 'Connection to Support API has error';
|
||||
echo '<p class="description">Status Code: ' . esc_attr( wp_remote_retrieve_response_code( $connection ) ) . '</p>';
|
||||
echo '<p class="description">Error Message: ' . esc_attr( $connection->get_error_message() ) . '</p>';
|
||||
} else {
|
||||
echo 'Connecion to Support API was successful';
|
||||
echo '<p class="description">Status Code: ' . esc_attr( wp_remote_retrieve_response_code( $connection ) ) . '</p>';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="wp-list-table widefat fixed bsf-sys-info">
|
||||
<tbody>
|
||||
<tr class="alternate">
|
||||
<th colspan="2"><?php esc_html_e( 'Theme Information', 'bsf' ); ?></th>
|
||||
</tr>
|
||||
<?php $theme_data = wp_get_theme(); ?>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td><?php echo esc_html( $theme_data->Name ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Version</td>
|
||||
<td><?php echo floatval( $theme_data->Version ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Author</td>
|
||||
<td>
|
||||
<?php echo wp_kses_post( $theme_data->Author ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="wp-list-table widefat fixed bsf-sys-info bsf-table-active-plugin">
|
||||
<tbody>
|
||||
<tr class="alternate">
|
||||
<th colspan="4"><?php esc_html_e( 'Installed Plugins', 'bsf' ); ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
$plugins = get_plugins();
|
||||
asort( $plugins );
|
||||
foreach ( $plugins as $plugin_file => $plugin_data ) {
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo esc_html( str_pad( $plugin_data['Title'], 30 ) ); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
if ( is_plugin_active( $plugin_file ) ) {
|
||||
echo esc_html( str_pad( 'Active', 10 ) );
|
||||
} else {
|
||||
echo esc_html( str_pad( 'Inactive', 10 ) );
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo esc_html( str_pad( $plugin_data['Version'], 10 ) ); ?></td>
|
||||
<td><?php echo esc_html( $plugin_data['Author'] ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Get BSF systeminfo.
|
||||
*/
|
||||
function get_bsf_systeminfo() {
|
||||
$table = '<div class="bsf-system-info-wrapper">';
|
||||
ob_start();
|
||||
bsf_systeminfo();
|
||||
$table .= ob_get_clean();
|
||||
$table .= '</div>';
|
||||
|
||||
return $table;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,84 +1,84 @@
|
||||
<?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>
|
||||
<?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>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,300 +1,300 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin functions for bsf core.
|
||||
*
|
||||
* @package BSF core
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prevent direct access.
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit();
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'check_bsf_product_status' ) ) {
|
||||
/**
|
||||
* Get status of product.
|
||||
*
|
||||
* @param int $id product id.
|
||||
* @return bool
|
||||
*/
|
||||
function check_bsf_product_status( $id ) {
|
||||
$brainstrom_products = ( get_option( 'brainstrom_products' ) ) ? get_option( 'brainstrom_products' ) : array();
|
||||
$bsf_product_themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
|
||||
|
||||
if ( empty( $brainstrom_products ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$status = false;
|
||||
foreach ( $brainstrom_products as $products ) {
|
||||
foreach ( $products as $key => $product ) {
|
||||
if ( $product['id'] === $id ) {
|
||||
$status = ( isset( $product['status'] ) ) ? $product['status'] : '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'get_bundled_plugins' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves bundled plugin data.
|
||||
*
|
||||
* @param string $template product template.
|
||||
* @return void
|
||||
*/
|
||||
function get_bundled_plugins( $template = '' ) {
|
||||
|
||||
global $ultimate_referer;
|
||||
|
||||
$brainstrom_products = get_option( 'brainstrom_products', array() );
|
||||
|
||||
$prd_ids = array();
|
||||
|
||||
// If brainstrom_products is not yet set, call bsf core init.
|
||||
if ( is_array( $brainstrom_products ) ) {
|
||||
init_bsf_core();
|
||||
$brainstrom_products = get_option( 'brainstrom_products', array() );
|
||||
}
|
||||
|
||||
foreach ( $brainstrom_products as $key => $value ) {
|
||||
foreach ( $value as $key => $value2 ) {
|
||||
array_push( $prd_ids, $key );
|
||||
}
|
||||
}
|
||||
|
||||
$path = bsf_get_api_url() . '?referer=' . $ultimate_referer;
|
||||
|
||||
$data = array(
|
||||
'action' => 'bsf_fetch_brainstorm_products',
|
||||
'id' => $prd_ids,
|
||||
);
|
||||
|
||||
$request = wp_remote_post(
|
||||
$path,
|
||||
array(
|
||||
'body' => $data,
|
||||
'timeout' => '10',
|
||||
)
|
||||
);
|
||||
|
||||
// Request http URL if the https version fails.
|
||||
if ( is_wp_error( $request ) && wp_remote_retrieve_response_code( $request ) !== 200 ) {
|
||||
$path = bsf_get_api_url( true ) . '?referer=' . $ultimate_referer;
|
||||
$request = wp_remote_post(
|
||||
$path,
|
||||
array(
|
||||
'body' => $data,
|
||||
'timeout' => '8',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) === 200 ) {
|
||||
$result = json_decode( $request['body'] );
|
||||
$bundled = array();
|
||||
$simple = array();
|
||||
|
||||
if ( ! empty( $result ) ) {
|
||||
if ( ! empty( $result->bundled ) ) {
|
||||
$bundled = $result->bundled;
|
||||
}
|
||||
if ( ! empty( $result->simple ) ) {
|
||||
$simple = $result->simple;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $bundled as $key => $value ) {
|
||||
if ( empty( $value ) ) {
|
||||
unset( $bundled->$key );
|
||||
}
|
||||
}
|
||||
|
||||
$brainstrom_bundled_products = (array) $bundled;
|
||||
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
|
||||
|
||||
// update 'brainstorm_products'.
|
||||
$simple = json_decode( wp_json_encode( $simple ), 1 );
|
||||
|
||||
foreach ( $brainstrom_products as $type => $products ) {
|
||||
|
||||
foreach ( $products as $key => $product ) {
|
||||
$old_id = isset( $product['id'] ) ? $product['id'] : '';
|
||||
|
||||
$simple[ $type ][ $old_id ]['template'] = isset( $brainstrom_products[ $type ][ $old_id ]['template'] ) ? $brainstrom_products[ $type ][ $old_id ]['template'] : '';
|
||||
$simple[ $type ][ $old_id ]['remote'] = isset( $simple[ $type ][ $old_id ]['version'] ) ? $simple[ $type ][ $old_id ]['version'] : '';
|
||||
$simple[ $type ][ $old_id ]['version'] = isset( $brainstrom_products[ $type ][ $old_id ]['version'] ) ? $brainstrom_products[ $type ][ $old_id ]['version'] : '';
|
||||
$simple[ $type ][ $old_id ]['purchase_key'] = isset( $brainstrom_products[ $type ][ $old_id ]['purchase_key'] ) ? $brainstrom_products[ $type ][ $old_id ]['purchase_key'] : '';
|
||||
$simple[ $type ][ $old_id ]['status'] = isset( $brainstrom_products[ $type ][ $old_id ]['status'] ) ? $brainstrom_products[ $type ][ $old_id ]['status'] : '';
|
||||
$simple[ $type ][ $old_id ]['message'] = isset( $brainstrom_products[ $type ][ $old_id ]['message'] ) ? $brainstrom_products[ $type ][ $old_id ]['message'] : '';
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'brainstrom_products', $simple );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays bundled product list for product.
|
||||
*
|
||||
* @param string $product_id Product ID.
|
||||
* @param bool $installed Show installed products?.
|
||||
* @return string
|
||||
*/
|
||||
function bsf_render_bundled_products( $product_id, $installed ) {
|
||||
|
||||
$product_status = check_bsf_product_status( $product_id );
|
||||
|
||||
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
|
||||
|
||||
if ( isset( $brainstrom_bundled_products[ $product_id ] ) ) {
|
||||
$brainstrom_bundled_products = $brainstrom_bundled_products[ $product_id ];
|
||||
}
|
||||
|
||||
usort( $brainstrom_bundled_products, 'bsf_sort' );
|
||||
|
||||
$global_plugin_installed = 0;
|
||||
$global_plugin_activated = 0;
|
||||
$total_bundled_plugins = count( $brainstrom_bundled_products );
|
||||
foreach ( $brainstrom_bundled_products as $key => $product ) {
|
||||
if ( ! isset( $product->id ) || empty( $product->id ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( isset( $request_product_id ) && $request_product_id !== $product->id ) {
|
||||
continue;
|
||||
}
|
||||
$plugin_abs_path = WP_PLUGIN_DIR . '/' . $product->init;
|
||||
if ( is_file( $plugin_abs_path ) ) {
|
||||
$global_plugin_installed++;
|
||||
|
||||
if ( is_plugin_active( $product->init ) ) {
|
||||
$global_plugin_activated++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ob_start();
|
||||
if ( $total_bundled_plugins === $global_plugin_installed ) {
|
||||
?>
|
||||
<div class="bsf-extensions-no-active">
|
||||
<div class="bsf-extensions-title-icon"><span class="dashicons dashicons-smiley"></span></div>
|
||||
<p class="bsf-text-light"><em><?php esc_html_e( 'All available extensions have been installed!', 'bsf' ); ?></em></p>
|
||||
</div>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
if ( empty( $brainstrom_bundled_products ) ) {
|
||||
?>
|
||||
|
||||
<div class="bsf-extensions-no-active">
|
||||
<div class="bsf-extensions-title-icon"><span class="dashicons dashicons-download"></span></div>
|
||||
<p class="bsf-text-light"><em><?php esc_html_e( 'No extensions available yet!', 'bsf' ); ?></em></p>
|
||||
|
||||
<div class="bsf-cp-rem-bundle" style="margin-top: 30px;">
|
||||
<a class="button-primary" href="<?php echo esc_url( $reset_bundled_url ); ?>"><?php esc_html_e( 'Refresh Bundled Products', 'bsf' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
foreach ( $brainstrom_bundled_products as $key => $product ) {
|
||||
|
||||
if ( ! isset( $product->id ) || empty( $product->id ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $request_product_id ) && $request_product_id !== $product->id ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$is_plugin_installed = false;
|
||||
$is_plugin_activated = false;
|
||||
|
||||
$plugin_abs_path = WP_PLUGIN_DIR . '/' . $product->init;
|
||||
if ( is_file( $plugin_abs_path ) ) {
|
||||
$is_plugin_installed = true;
|
||||
|
||||
if ( is_plugin_active( $product->init ) ) {
|
||||
$is_plugin_activated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( $is_plugin_installed && ! $installed ) || ( ! $is_plugin_installed && $installed ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $is_plugin_installed && $is_plugin_activated ) {
|
||||
$class = 'active-plugin';
|
||||
} elseif ( $is_plugin_installed && ! $is_plugin_activated ) {
|
||||
$class = 'inactive-plugin';
|
||||
} else {
|
||||
$class = 'plugin-not-installed';
|
||||
}
|
||||
?>
|
||||
<li id="ext-<?php echo esc_attr( $key ); ?>" class="bsf-extension <?php echo esc_attr( $class ); ?> bsf-extension-<?php echo esc_attr( $product->slug ); ?>" data-init="<?php echo esc_attr( $product->init ); ?>">
|
||||
<?php if ( ! $is_plugin_installed ) { ?>
|
||||
<div class="bsf-extension-start-install">
|
||||
<div class="bsf-extension-start-install-content">
|
||||
<h2><?php esc_html_e( 'Downloading', 'bsf' ); ?><div class="bsf-css-loader"></div></h2>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="top-section">
|
||||
<?php if ( ! empty( $product->product_image ) ) { ?>
|
||||
<div class="bsf-extension-product-image">
|
||||
<div class="bsf-extension-product-image-stick">
|
||||
<img src="<?php echo esc_url( $product->product_image ); ?>" class="img" alt="image"/>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="bsf-extension-info">
|
||||
<?php $name = ( isset( $product->short_name ) ) ? $product->short_name : $product->name; ?>
|
||||
<h4 class="title"><?php echo esc_html( $name ); ?></h4>
|
||||
<p class="desc"><?php echo esc_html( $product->description ); ?><span class="author"><cite>By <?php echo esc_html( $product->author ); ?></cite></span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom-section">
|
||||
<?php
|
||||
$button_class = '';
|
||||
if ( ! $is_plugin_installed ) {
|
||||
if ( ( ! $product->licence_require || 'false' === $product->licence_require ) || 'registered' === $product_status ) {
|
||||
|
||||
$installer_url = bsf_exension_installer_url( $product_id );
|
||||
$button = __( 'Install', 'bsf' );
|
||||
$button_class = 'bsf-install-button install-now';
|
||||
} elseif ( ( $product->licence_require || 'true' === $product->licence_require ) && 'registered' !== $product_status ) {
|
||||
|
||||
$installer_url = bsf_registration_page_url( '&id=' . $product_id, $product_id );
|
||||
$button = __( 'Validate Purchase', 'bsf' );
|
||||
$button_class = 'bsf-validate-licence-button';
|
||||
}
|
||||
} else {
|
||||
$current_name = strtolower( bsf_get_current_name( $product->init, $product->type ) );
|
||||
$current_name = preg_replace( '![^a-z0-9]+!i', '-', $current_name );
|
||||
if ( is_multisite() ) {
|
||||
$installer_url = network_admin_url( 'plugins.php#' . $current_name );
|
||||
} else {
|
||||
$installer_url = admin_url( 'plugins.php#' . $current_name );
|
||||
}
|
||||
$button = __( 'Installed', 'bsf' );
|
||||
}
|
||||
|
||||
?>
|
||||
<a class="button button-primary extension-button <?php echo esc_attr( $button_class ); ?>" href="<?php echo esc_url( $installer_url ); ?>" data-slug="<?php echo esc_html( $product->slug ); ?>" data-ext="<?php echo esc_attr( $key ); ?>" data-pid="<?php echo esc_attr( $product->id ); ?>" data-bundled="true" data-action="install"><?php echo esc_html( $button ); ?></a>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* Admin functions for bsf core.
|
||||
*
|
||||
* @package BSF core
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prevent direct access.
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit();
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'check_bsf_product_status' ) ) {
|
||||
/**
|
||||
* Get status of product.
|
||||
*
|
||||
* @param int $id product id.
|
||||
* @return bool
|
||||
*/
|
||||
function check_bsf_product_status( $id ) {
|
||||
$brainstrom_products = ( get_option( 'brainstrom_products' ) ) ? get_option( 'brainstrom_products' ) : array();
|
||||
$bsf_product_themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
|
||||
|
||||
if ( empty( $brainstrom_products ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$status = false;
|
||||
foreach ( $brainstrom_products as $products ) {
|
||||
foreach ( $products as $key => $product ) {
|
||||
if ( $product['id'] === $id ) {
|
||||
$status = ( isset( $product['status'] ) ) ? $product['status'] : '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'get_bundled_plugins' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves bundled plugin data.
|
||||
*
|
||||
* @param string $template product template.
|
||||
* @return void
|
||||
*/
|
||||
function get_bundled_plugins( $template = '' ) {
|
||||
|
||||
global $ultimate_referer;
|
||||
|
||||
$brainstrom_products = get_option( 'brainstrom_products', array() );
|
||||
|
||||
$prd_ids = array();
|
||||
|
||||
// If brainstrom_products is not yet set, call bsf core init.
|
||||
if ( is_array( $brainstrom_products ) ) {
|
||||
init_bsf_core();
|
||||
$brainstrom_products = get_option( 'brainstrom_products', array() );
|
||||
}
|
||||
|
||||
foreach ( $brainstrom_products as $key => $value ) {
|
||||
foreach ( $value as $key => $value2 ) {
|
||||
array_push( $prd_ids, $key );
|
||||
}
|
||||
}
|
||||
|
||||
$path = bsf_get_api_url() . '?referer=' . $ultimate_referer;
|
||||
|
||||
$data = array(
|
||||
'action' => 'bsf_fetch_brainstorm_products',
|
||||
'id' => $prd_ids,
|
||||
);
|
||||
|
||||
$request = wp_remote_post(
|
||||
$path,
|
||||
array(
|
||||
'body' => $data,
|
||||
'timeout' => '10',
|
||||
)
|
||||
);
|
||||
|
||||
// Request http URL if the https version fails.
|
||||
if ( is_wp_error( $request ) && wp_remote_retrieve_response_code( $request ) !== 200 ) {
|
||||
$path = bsf_get_api_url( true ) . '?referer=' . $ultimate_referer;
|
||||
$request = wp_remote_post(
|
||||
$path,
|
||||
array(
|
||||
'body' => $data,
|
||||
'timeout' => '8',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) === 200 ) {
|
||||
$result = json_decode( $request['body'] );
|
||||
$bundled = array();
|
||||
$simple = array();
|
||||
|
||||
if ( ! empty( $result ) ) {
|
||||
if ( ! empty( $result->bundled ) ) {
|
||||
$bundled = $result->bundled;
|
||||
}
|
||||
if ( ! empty( $result->simple ) ) {
|
||||
$simple = $result->simple;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $bundled as $key => $value ) {
|
||||
if ( empty( $value ) ) {
|
||||
unset( $bundled->$key );
|
||||
}
|
||||
}
|
||||
|
||||
$brainstrom_bundled_products = (array) $bundled;
|
||||
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
|
||||
|
||||
// update 'brainstorm_products'.
|
||||
$simple = json_decode( wp_json_encode( $simple ), 1 );
|
||||
|
||||
foreach ( $brainstrom_products as $type => $products ) {
|
||||
|
||||
foreach ( $products as $key => $product ) {
|
||||
$old_id = isset( $product['id'] ) ? $product['id'] : '';
|
||||
|
||||
$simple[ $type ][ $old_id ]['template'] = isset( $brainstrom_products[ $type ][ $old_id ]['template'] ) ? $brainstrom_products[ $type ][ $old_id ]['template'] : '';
|
||||
$simple[ $type ][ $old_id ]['remote'] = isset( $simple[ $type ][ $old_id ]['version'] ) ? $simple[ $type ][ $old_id ]['version'] : '';
|
||||
$simple[ $type ][ $old_id ]['version'] = isset( $brainstrom_products[ $type ][ $old_id ]['version'] ) ? $brainstrom_products[ $type ][ $old_id ]['version'] : '';
|
||||
$simple[ $type ][ $old_id ]['purchase_key'] = isset( $brainstrom_products[ $type ][ $old_id ]['purchase_key'] ) ? $brainstrom_products[ $type ][ $old_id ]['purchase_key'] : '';
|
||||
$simple[ $type ][ $old_id ]['status'] = isset( $brainstrom_products[ $type ][ $old_id ]['status'] ) ? $brainstrom_products[ $type ][ $old_id ]['status'] : '';
|
||||
$simple[ $type ][ $old_id ]['message'] = isset( $brainstrom_products[ $type ][ $old_id ]['message'] ) ? $brainstrom_products[ $type ][ $old_id ]['message'] : '';
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'brainstrom_products', $simple );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays bundled product list for product.
|
||||
*
|
||||
* @param string $product_id Product ID.
|
||||
* @param bool $installed Show installed products?.
|
||||
* @return string
|
||||
*/
|
||||
function bsf_render_bundled_products( $product_id, $installed ) {
|
||||
|
||||
$product_status = check_bsf_product_status( $product_id );
|
||||
|
||||
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
|
||||
|
||||
if ( isset( $brainstrom_bundled_products[ $product_id ] ) ) {
|
||||
$brainstrom_bundled_products = $brainstrom_bundled_products[ $product_id ];
|
||||
}
|
||||
|
||||
usort( $brainstrom_bundled_products, 'bsf_sort' );
|
||||
|
||||
$global_plugin_installed = 0;
|
||||
$global_plugin_activated = 0;
|
||||
$total_bundled_plugins = count( $brainstrom_bundled_products );
|
||||
foreach ( $brainstrom_bundled_products as $key => $product ) {
|
||||
if ( ! isset( $product->id ) || empty( $product->id ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( isset( $request_product_id ) && $request_product_id !== $product->id ) {
|
||||
continue;
|
||||
}
|
||||
$plugin_abs_path = WP_PLUGIN_DIR . '/' . $product->init;
|
||||
if ( is_file( $plugin_abs_path ) ) {
|
||||
$global_plugin_installed++;
|
||||
|
||||
if ( is_plugin_active( $product->init ) ) {
|
||||
$global_plugin_activated++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ob_start();
|
||||
if ( $total_bundled_plugins === $global_plugin_installed ) {
|
||||
?>
|
||||
<div class="bsf-extensions-no-active">
|
||||
<div class="bsf-extensions-title-icon"><span class="dashicons dashicons-smiley"></span></div>
|
||||
<p class="bsf-text-light"><em><?php esc_html_e( 'All available extensions have been installed!', 'bsf' ); ?></em></p>
|
||||
</div>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
if ( empty( $brainstrom_bundled_products ) ) {
|
||||
?>
|
||||
|
||||
<div class="bsf-extensions-no-active">
|
||||
<div class="bsf-extensions-title-icon"><span class="dashicons dashicons-download"></span></div>
|
||||
<p class="bsf-text-light"><em><?php esc_html_e( 'No extensions available yet!', 'bsf' ); ?></em></p>
|
||||
|
||||
<div class="bsf-cp-rem-bundle" style="margin-top: 30px;">
|
||||
<a class="button-primary" href="<?php echo esc_url( $reset_bundled_url ); ?>"><?php esc_html_e( 'Refresh Bundled Products', 'bsf' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
foreach ( $brainstrom_bundled_products as $key => $product ) {
|
||||
|
||||
if ( ! isset( $product->id ) || empty( $product->id ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( isset( $request_product_id ) && $request_product_id !== $product->id ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$is_plugin_installed = false;
|
||||
$is_plugin_activated = false;
|
||||
|
||||
$plugin_abs_path = WP_PLUGIN_DIR . '/' . $product->init;
|
||||
if ( is_file( $plugin_abs_path ) ) {
|
||||
$is_plugin_installed = true;
|
||||
|
||||
if ( is_plugin_active( $product->init ) ) {
|
||||
$is_plugin_activated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( $is_plugin_installed && ! $installed ) || ( ! $is_plugin_installed && $installed ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $is_plugin_installed && $is_plugin_activated ) {
|
||||
$class = 'active-plugin';
|
||||
} elseif ( $is_plugin_installed && ! $is_plugin_activated ) {
|
||||
$class = 'inactive-plugin';
|
||||
} else {
|
||||
$class = 'plugin-not-installed';
|
||||
}
|
||||
?>
|
||||
<li id="ext-<?php echo esc_attr( $key ); ?>" class="bsf-extension <?php echo esc_attr( $class ); ?> bsf-extension-<?php echo esc_attr( $product->slug ); ?>" data-init="<?php echo esc_attr( $product->init ); ?>">
|
||||
<?php if ( ! $is_plugin_installed ) { ?>
|
||||
<div class="bsf-extension-start-install">
|
||||
<div class="bsf-extension-start-install-content">
|
||||
<h2><?php esc_html_e( 'Downloading', 'bsf' ); ?><div class="bsf-css-loader"></div></h2>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="top-section">
|
||||
<?php if ( ! empty( $product->product_image ) ) { ?>
|
||||
<div class="bsf-extension-product-image">
|
||||
<div class="bsf-extension-product-image-stick">
|
||||
<img src="<?php echo esc_url( $product->product_image ); ?>" class="img" alt="image"/>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="bsf-extension-info">
|
||||
<?php $name = ( isset( $product->short_name ) ) ? $product->short_name : $product->name; ?>
|
||||
<h4 class="title"><?php echo esc_html( $name ); ?></h4>
|
||||
<p class="desc"><?php echo esc_html( $product->description ); ?><span class="author"><cite>By <?php echo esc_html( $product->author ); ?></cite></span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom-section">
|
||||
<?php
|
||||
$button_class = '';
|
||||
if ( ! $is_plugin_installed ) {
|
||||
if ( ( ! $product->licence_require || 'false' === $product->licence_require ) || 'registered' === $product_status ) {
|
||||
|
||||
$installer_url = bsf_exension_installer_url( $product_id );
|
||||
$button = __( 'Install', 'bsf' );
|
||||
$button_class = 'bsf-install-button install-now';
|
||||
} elseif ( ( $product->licence_require || 'true' === $product->licence_require ) && 'registered' !== $product_status ) {
|
||||
|
||||
$installer_url = bsf_registration_page_url( '&id=' . $product_id, $product_id );
|
||||
$button = __( 'Validate Purchase', 'bsf' );
|
||||
$button_class = 'bsf-validate-licence-button';
|
||||
}
|
||||
} else {
|
||||
$current_name = strtolower( bsf_get_current_name( $product->init, $product->type ) );
|
||||
$current_name = preg_replace( '![^a-z0-9]+!i', '-', $current_name );
|
||||
if ( is_multisite() ) {
|
||||
$installer_url = network_admin_url( 'plugins.php#' . $current_name );
|
||||
} else {
|
||||
$installer_url = admin_url( 'plugins.php#' . $current_name );
|
||||
}
|
||||
$button = __( 'Installed', 'bsf' );
|
||||
}
|
||||
|
||||
?>
|
||||
<a class="button button-primary extension-button <?php echo esc_attr( $button_class ); ?>" href="<?php echo esc_url( $installer_url ); ?>" data-slug="<?php echo esc_html( $product->slug ); ?>" data-ext="<?php echo esc_attr( $key ); ?>" data-pid="<?php echo esc_attr( $product->id ); ?>" data-bundled="true" data-action="install"><?php echo esc_html( $button ); ?></a>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin installer.
|
||||
*
|
||||
* @package bsf-core
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prevent direct access.
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit();
|
||||
}
|
||||
|
||||
require_once BSF_UPDATER_PATH . '/includes/views/list-bundled-products.php';
|
||||
<?php
|
||||
/**
|
||||
* Plugin installer.
|
||||
*
|
||||
* @package bsf-core
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prevent direct access.
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit();
|
||||
}
|
||||
|
||||
require_once BSF_UPDATER_PATH . '/includes/views/list-bundled-products.php';
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.29.9
|
||||
1.29.9
|
||||
|
||||
Reference in New Issue
Block a user