first commit

This commit is contained in:
Rachit Bhargava
2023-07-21 17:12:10 -04:00
parent d0fe47dde4
commit 5d0f0734d8
14003 changed files with 2829464 additions and 0 deletions

View File

@@ -0,0 +1,619 @@
.bsf-aiosrs-schema-row td .bsf-aiosrs-schema-custom-text-wrap {
vertical-align: top;
}
.bsf-aiosrs-schema-custom-text-wrap .time-duration-wrap input,
.aiosrs-pro-meta-fields-wrapper .time-duration-wrap input {
width: 55px;
font-size: 12px;
padding-right: 0;
margin-right: 0;
margin-left: 0;
}
.bsf-aiosrs-schema-custom-text-wrap .aiosrs-pro-custom-field-rating input.bsf-rating-field,
.aiosrs-pro-meta-fields-wrapper .aiosrs-pro-custom-field-rating input {
width: 50px;
}
.aiosrs-pro-repeater-table .aiosrs-pro-custom-field-rating input.bsf-rating-field {
width: 25% !important;
padding-right: 0;
}
.bsf-aiosrs-schema-custom-text-wrap .aiosrs-star-rating-wrap,
.aiosrs-pro-meta-fields-wrapper .aiosrs-star-rating-wrap {
display: inline-block;
vertical-align: top;
padding: 3px;
}
.bsf-aiosrs-schema-custom-text-wrap .image-field-wrap,
.aiosrs-pro-meta-fields-wrapper .image-field-wrap {
position: relative;
display: inline-block;
}
.bsf-aiosrs-schema-custom-text-wrap .aiosrs-image-select .dashicons {
font-size: 1.2em;
width: 1em;
height: 1em;
line-height: 1;
margin-right: 5px;
}
.bsf-aiosrs-schema-custom-text-wrap .aiosrs-image-remove,
.aiosrs-pro-meta-fields-wrapper .aiosrs-image-remove {
display: none;
position: absolute;
background: rgba(255, 255, 255, 0.7);
right: 0;
}
.bsf-aiosrs-schema-custom-text-wrap .aiosrs-image-remove {
font-size: 15px;
width: 1em;
height: 1em;
}
.bsf-aiosrs-schema-custom-text-wrap .bsf-custom-image-selected .aiosrs-image-select,
.aiosrs-pro-meta-fields-wrapper .bsf-custom-image-selected .aiosrs-image-select {
display: none;
}
.bsf-aiosrs-schema-custom-text-wrap .bsf-custom-image-selected .aiosrs-image-remove,
.aiosrs-pro-meta-fields-wrapper .bsf-custom-image-selected .aiosrs-image-remove {
display: inline-block;
}
.bsf-aiosrs-schema-custom-text-wrap .bsf-custom-image-selected .aiosrs-image-select.img,
.aiosrs-pro-meta-fields-wrapper .bsf-custom-image-selected .aiosrs-image-select.img {
max-width: 100%;
display: inline-block;
}
.bsf-aiosrs-schema-custom-text-wrap .bsf-custom-image-selected .aiosrs-image-select.img img {
max-height: 50px;
}
.aiosrs-pro-meta-fields-wrapper .bsf-custom-image-selected .aiosrs-image-select.img img {
vertical-align: middle;
max-width: 50px;
}
.aiosrs-pro-meta-fields-wrapper .inside,
.aiosrs-pro-meta-fields-wrapper {
margin-top: 0;
padding: 0;
}
.aiosrs-pro-meta-fields-wrapper th,
.aiosrs-pro-meta-fields-wrapper td {
padding: 10px 12px;
border-bottom: 1px solid #eee;
width: 33%;
}
.aiosrs-pro-meta-fields-wrapper .aiosrs-pro-custom-fields-dropdown-content th,
.aiosrs-pro-meta-fields-wrapper .aiosrs-pro-custom-fields-dropdown-content td {
border-top: 0;
}
.aiosrs-pro-meta-fields-wrapper th {
border-right: 1px solid #eee;
vertical-align: middle;
}
.bsf-aiosrs-schema-fixed-text-wrap input:not([type="checkbox"]),
.bsf-aiosrs-schema-custom-text-wrap input:not([type="checkbox"]),
.aiosrs-pro-meta-fields-wrapper input:not([type="checkbox"]),
.bsf-aiosrs-schema-custom-text-wrap textarea,
.aiosrs-pro-meta-fields-wrapper textarea {
width: 100%;
}
/* Tooltips */
.bsf-aiosrs-schema-heading-help {
color: #0073aa;
font-size: 18px;
cursor: help;
float: right;
vertical-align: middle;
}
.ui-widget-content.bsf-aiosrs-schema-ui-tooltip {
background: #333;
border-width: 1px;
border-color: #333;
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 1px 0 2px 0 rgba(214, 214, 214, 0.5);
box-shadow: 1px 0 2px 0 rgba(214, 214, 214, 0.5);
color: #dedede;
max-width: 250px;
text-align: center;
padding: 7px;
text-rendering: optimizeLegibility;
text-shadow: none;
z-index: 9999;
}
/* New Style Verticle Tabs */
.aiosrs-pro-meta-fields-tabs-wrapper {
display: inline-block;
width: 15%;
vertical-align: top;
}
.aiosrs-pro-meta-fields-tabs-wrapper .aiosrs-pro-meta-fields-tab {
padding: 8px 12px;
border-bottom: 1px solid #eee;
border-right: 1px solid #eee;
margin-right: -1px;
cursor: pointer;
font-weight: 700;
background: #fff;
color: #666;
}
.aiosrs-pro-meta-fields-tabs-wrapper .aiosrs-pro-meta-fields-tab.active {
background: #f1f1f1;
color: inherit;
}
.aiosrs-pro-meta-fields-wrapper {
width: 100%;
vertical-align: top;
}
.aiosrs-pro-meta-fields-tabs-wrapper ~ .aiosrs-pro-meta-fields-wrapper {
display: inline-block;
width: calc(85% - 1px);
border-left: 1px solid #eee;
}
#aiosrs-pro-custom-fields .inside {
padding: unset;
border: 1px solid #e2e4e7;
}
#aiosrs-pro-custom-fields h2.hndle.ui-sortable-handle {
border-bottom: unset;
}
.aiosrs-pro-meta-fields-wrapper .form-table {
margin: 0;
}
.aiosrs-pro-meta-fields-wrap {
display: none;
}
.aiosrs-pro-meta-fields-wrap.open {
display: block;
}
.bsf-aiosrs-schema-custom-text-wrap .multi-select-wrap select,
.aiosrs-pro-meta-fields-wrapper .multi-select-wrap select {
width: 100%;
}
.bsf-aiosrs-schema-custom-text-wrap .aiosrs-star-rating-wrap:not(.disabled) .aiosrs-star-rating,
.aiosrs-pro-meta-fields-wrapper .aiosrs-star-rating-wrap:not(.disabled) .aiosrs-star-rating {
cursor: pointer;
}
.aiosrs-pro-meta-fields-wrapper .aiosrs-star-rating-wrap.disabled {
padding: 0 0 5px;
}
.aiosrs-pro-meta-fields-wrapper .aiosrs-reset-rating {
margin-left: 5px;
line-height: 1.7;
}
.aiosrs-pro-custom-field-rating .spinner {
float: none;
margin: 0 5px;
}
.aiosrs-pro-custom-field-rating .aiosrs-reset-rating.reset-disabled {
display: none;
}
.ui-timepicker-div .ui-widget-header {
margin-bottom: 8px;
}
.ui-timepicker-div dl {
text-align: left;
}
.ui-timepicker-div dl dt {
float: left;
clear: left;
padding: 0 0 0 15px;
}
.ui-timepicker-div dl dd {
margin: 15px 15px 12px 35%;
}
.ui-timepicker-div td {
font-size: 90%;
}
.ui-tpicker-grid-label {
background: none;
border: none;
margin: 0;
padding: 0;
}
.ui-timepicker-div .ui_tpicker_unit_hide {
display: none;
}
.ui-timepicker-div .ui_tpicker_time .ui_tpicker_time_input {
background: none;
color: inherit;
border: none;
outline: none;
border-bottom: solid 1px #555;
width: 95%;
}
.ui-timepicker-div .ui_tpicker_time .ui_tpicker_time_input:focus {
border-bottom-color: #aaa;
}
.ui-timepicker-rtl {
direction: rtl;
}
.ui-timepicker-rtl dl {
text-align: right;
padding: 0 5px 0 0;
}
.ui-timepicker-rtl dl dt {
float: right;
clear: right;
}
.ui-timepicker-rtl dl dd {
margin: 0 40% 10px 10px;
}
.ui-timepicker-div.ui-timepicker-oneLine {
padding-right: 2px;
}
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time,
.ui-timepicker-div.ui-timepicker-oneLine dt {
display: none;
}
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time_label {
display: block;
padding-top: 2px;
}
.ui-timepicker-div.ui-timepicker-oneLine dl {
text-align: right;
}
.ui-timepicker-div.ui-timepicker-oneLine dl dd,
.ui-timepicker-div.ui-timepicker-oneLine dl dd > div {
display: inline-block;
margin: 0;
}
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_minute::before,
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_second::before {
content: ":";
display: inline-block;
}
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_millisec::before,
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_microsec::before {
content: ".";
display: inline-block;
}
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide,
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide::before {
display: none;
}
input.wpsp-time-duration-field,
input.wpsp-date-field,
input.wpsp-datetime-local-field {
background-color: #fff;
}
.wpsp-connected-icon {
display: flex;
justify-content: center;
padding: 0.375rem 0.75rem;
margin-bottom: 0;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
white-space: nowrap;
background-color: #e9ecef;
border: 1px solid #ced4da;
border-color: #7e8993;
border-bottom-left-radius: 2px;
border-top-left-radius: 2px;
box-sizing: unset;
}
.wpsp-connected-field {
display: flex;
}
.wpsp-connected-group {
display: flex;
}
.wpsp-connected-group > select {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-left: none;
margin: 0;
border-color: #7e8993 !important;
}
.wpsp-field-close,
.wpsp-custom-field-connect,
.wpsp-specific-field-connect {
align-items: center;
color: #999;
cursor: pointer;
display: inline-flex;
font-size: 18px;
justify-content: center;
position: absolute;
right: 28px;
top: 7.5px;
width: 5px;
}
.wpsp-custom-field-connect {
top: 6.5px;
}
.wpsp-specific-field-connect {
top: 5.5px;
}
.wpsp-parent-field {
position: relative;
}
.wpsp-required-error-field {
color: #f00 !important;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-heading,
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-content {
display: table-cell;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type td.bsf-aiosrs-schema-row-heading {
width: 16%;
padding: 10px 12px;
vertical-align: middle;
border-right: 1px solid #eee;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type td {
width: 27%;
padding: 10px 12px;
margin-bottom: unset;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type:first-child td {
padding-top: 30px;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater table.aiosrs-pro-repeater-table {
border-collapse: collapse;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater table.aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type {
border: 1px solid #eee;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-heading,
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-content {
display: table-cell;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type td.bsf-aiosrs-schema-row-heading {
width: 5%;
padding: 10px 12px;
vertical-align: middle;
border-right: 1px solid #eee;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type td {
width: 25%;
padding: 10px 12px;
margin-bottom: unset;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target table.aiosrs-pro-repeater-table {
border-collapse: collapse;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target table.aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type {
border: 1px solid #eee;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table-wrap tr.bsf-aiosrs-schema-row td.bsf-aiosrs-schema-row-content .aiosrs-pro-custom-field input {
width: 96%;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table-wrap tr.bsf-aiosrs-schema-row td.bsf-aiosrs-schema-row-content .aiosrs-pro-custom-field textarea {
width: 96%;
}
.bsf-aiosrs-schema-heading-help.wpsp-show-repeater-field,
.bsf-aiosrs-schema-heading-help.wpsp-hide-repeater-field,
.bsf-aiosrs-schema-heading-help.wpsp-show-repeater-target-field,
.bsf-aiosrs-schema-heading-help.wpsp-hide-repeater-target-field {
cursor: pointer;
padding: 5px;
font-size: 20px;
}
select[disabled] {
background-image: none !important;
}
.aiosrs-pro-meta-fields-wrap .wpsp-field-label {
width: 17%;
font-size: 13px;
line-height: 1.4;
font-weight: 700;
color: #333;
border-right: 1px solid #eee;
}
/* Added close button disable for repeater fields */
#aiosrs-pro-custom-fields .bsf-repeater-close {
display: inline-block;
}
.wpsp-local-fields .aiosrs-pro-custom-field input {
min-height: 33px;
padding-right: 18%;
border-radius: 3px;
}
.wpsp-parent-field.wpsp-custom-field.wpsp-custom-field-image .wpsp-custom-field-connect {
top: 0.5px;
}
.wpsp-parent-field.wpsp-custom-field.wpsp-custom-field-textarea .wpsp-custom-field-connect {
top: 12px;
}
/*Toggle CSS for the Enable Schema Markup */
.wpsp-enable-schema-markup {
display: block;
font-size: 13px;
}
.wpsp-enable-schema-markup__field {
margin-top: 8px;
line-height: normal;
align-items: center;
}
.wpsp-enable-schema-toggle {
position: relative;
display: inline-block;
}
.wpsp-enable-schema-toggle input.wpsp-enable-schema-toggle__input[type="checkbox"] {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
margin: 0;
padding: 0;
z-index: 1;
border: none;
}
.wpsp-enable-schema-toggle .wpsp-enable-schema-toggle__track {
content: "";
display: inline-block;
box-sizing: border-box;
vertical-align: top;
background-color: #fff;
border: 2px solid #6c7781;
width: 36px;
height: 18px;
border-radius: 9px;
transition: background 0.2s ease;
}
.wpsp-enable-schema-toggle .wpsp-enable-schema-toggle__thumb {
display: block;
position: absolute;
box-sizing: border-box;
top: 4px;
left: 4px;
width: 10px;
height: 10px;
border-radius: 50%;
transition: transform 0.1s ease;
background-color: #6c7781;
border: 5px solid #6c7781;
}
.wpsp-enable-schema-toggle.is-checked .wpsp-enable-schema-toggle__track {
background-color: #11a0d2;
border: 9px solid transparent;
}
.wpsp-enable-schema-toggle.is-checked .wpsp-enable-schema-toggle__thumb {
background-color: #fff;
border-width: 0;
transform: translateX(18px);
}
.aiosrs-pro-meta-fields-wrap.is-enable-schema-markup {
opacity: 0.2;
pointer-events: none;
}
.rtl .wpsp-parent-field .wpsp-field-close {
position: relative;
right: -35px;
}
.rtl .wpsp-specific-field-connect,
.rtl .wpsp-parent-field .wpsp-custom-field-connect {
position: absolute;
right: 90%;
}
.rtl .wpsp-parent-field .bsf-aiosrs-schema-meta-field {
border-left: 1px solid #eee;
}
.rtl .wpsp-local-fields .aiosrs-pro-custom-field input {
padding-left: 18%;
padding-right: 5%;
}
@-moz-document url-prefix() {
.aiosrs-pro-meta-fields-wrapper th,
.aiosrs-pro-meta-fields-wrapper td {
width: 36%;
}
.aiosrs-pro-meta-fields-wrap .wpsp-field-label {
width: 14%;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type td.bsf-aiosrs-schema-row-heading {
width: 14%;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type td {
width: 36%;
}
}

View File

@@ -0,0 +1,21 @@
.aiosrs-rating-wrap .aiosrs-star-rating-wrap {
display: inline-block;
vertical-align: middle;
}
.aiosrs-rating-wrap .aiosrs-star-rating-wrap ~ .aiosrs-star-rating-wrap {
float: right;
}
.aiosrs-rating-wrap .aiosrs-star-rating-wrap .aiosrs-star-rating {
color: #ffd700;
}
.aiosrs-rating-wrap .aiosrs-star-rating-wrap:not(.disabled) .aiosrs-star-rating {
cursor: pointer;
}
.aiosrs-rating-wrap .success-msg {
color: #0f0;
margin-left: 5px;
}

View File

@@ -0,0 +1,98 @@
body.aiosrs-pro-license-form-open {
overflow: hidden;
}
#aiosrs-pro-license-form p {
padding: 5px 0 5px 0;
}
#aiosrs-pro-license-form .aiosrs-pro-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;
}
#aiosrs-pro-license-form .aiosrs-pro-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);
}
#aiosrs-pro-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 0.1s ease-in-out, background 0.1s ease-in-out;
-webkit-transform: translateX(100%);
transform: translateX(100%);
transition: color 0.1s ease-in-out, background 0.1s ease-in-out;
color: #eee;
}
#aiosrs-pro-license-form-close-btn:hover {
color: #00a0d2;
}
#aiosrs-pro-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;
}
#aiosrs-pro-license-form .license-form-field input.regular-text {
margin-right: 10px;
}
/** Validation Messages */
.bsf-current-license-error-wp-schema-pro,
.bsf-current-license-success-wp-schema-pro {
display: block;
margin-bottom: 0.5em;
}
.bsf-current-license-error-wp-schema-pro {
color: #f44336;
}
.bsf-current-license-success-wp-schema-pro {
color: #008000;
}
/** License link */
#aiosrs-pro-license-form-btn.active {
color: #3db634;
}
#aiosrs-pro-license-form-btn.inactive {
color: #f44336;
}

View File

@@ -0,0 +1,460 @@
.bsf-aiosrs-pro {
max-width: 1200px;
}
.bsf-aiosrs-pro .aiosrs-help-link {
font-size: 1.2em;
}
.bsf-aiosrs-pro .aiosrs-help-link:focus {
box-shadow: none;
}
.bsf-aiosrs-pro .form-table th {
width: 280px;
}
.bsf-aiosrs-pro .form-table td.schema-contact-type-option {
display: block;
}
.bsf-aiosrs-pro .form-table td.schema-contact-type-option-change {
margin-bottom: unset;
padding-bottom: 0;
}
.sp-required {
color: #dc3232;
font-size: 14px;
margin-left: 2px;
}
.bsf-aiosrs-pro .select2-selection__choice {
line-height: 1.7;
}
.bsf-aiosrs-pro .select2-container * {
vertical-align: middle;
}
.bsf-aiosrs-pro .select2-container .select2-selection__choice__remove {
vertical-align: initial;
}
.wp-schema-pro-global-schemas .form-table select,
.wp-schema-pro-general-settings .form-table input[type="text"],
.wp-schema-pro-general-settings .form-table select,
.wp-schema-pro-breadcrumb-setting .form-table select,
.wp-schema-pro-advanced-settings .form-table select,
.wp-schema-pro-social-profiles .form-table input[type="url"] {
min-width: 50%;
}
.wp-schema-pro-corporate-contact .form-table input[type="url"],
.wp-schema-pro-corporate-contact .form-table input[type="text"],
.wp-schema-pro-corporate-contact .form-table input[type="email"],
.wp-schema-pro-corporate-contact .form-table select {
min-width: 64%;
}
#wp-schema-pro-setting-links {
margin-top: 10px;
margin-left: 5px;
}
#wp-schema-pro-setting-links a {
text-decoration: none;
box-shadow: none;
}
#wp-schema-pro-setting-links a.active {
color: inherit;
pointer-events: none;
font-weight: 600;
}
.wp-schema-pro-general-settings .custom-field-wrapper {
display: inline-block;
width: 48%;
vertical-align: middle;
}
.wp-schema-pro-general-settings .site-logo-custom-wrap {
vertical-align: top;
}
/**
* Custom Image Select
*/
.wp-schema-pro-general-settings .image-field-wrap,
.wp-schema-pro-advanced-settings .image-field-wrap {
position: relative;
display: inline-block;
}
.wp-schema-pro-general-settings .aiosrs-image-select .dashicons,
.wp-schema-pro-advanced-settings .aiosrs-image-select .dashicons {
font-size: 1.2em;
width: 1em;
height: 1em;
line-height: 16px;
margin-right: 5px;
vertical-align: middle;
}
.wp-schema-pro-general-settings .aiosrs-image-remove,
.wp-schema-pro-advanced-settings .aiosrs-image-remove {
display: none;
position: absolute;
background: rgba(255, 255, 255, 0.7);
right: 0;
font-size: 15px;
width: 1em;
height: 1em;
}
.wp-schema-pro-general-settings .bsf-custom-image-selected .aiosrs-image-select,
.wp-schema-pro-advanced-settings .bsf-custom-image-selected .aiosrs-image-select {
display: none;
}
.wp-schema-pro-general-settings .bsf-custom-image-selected .aiosrs-image-remove,
.wp-schema-pro-advanced-settings .bsf-custom-image-selected .aiosrs-image-remove {
display: inline-block;
}
.wp-schema-pro-general-settings .bsf-custom-image-selected .aiosrs-image-select.img,
.wp-schema-pro-advanced-settings .bsf-custom-image-selected .aiosrs-image-select.img {
max-width: 100%;
display: inline-block;
}
.wp-schema-pro-general-settings .bsf-custom-image-selected .aiosrs-image-select.img img {
max-height: 75px;
}
.wp-schema-pro-general-settings .bsf-custom-image-selected .aiosrs-image-select.img img,
.wp-schema-pro-advanced-settings .bsf-custom-image-selected .aiosrs-image-select.img img {
vertical-align: middle;
max-width: 300px;
}
/**
* Default Image
*/
.wp-schema-pro-advanced-settings .bsf-custom-image-selected .aiosrs-image-select.img img,
.wp-schema-pro-general-settings .bsf-custom-image-selected .aiosrs-image-select.default-image.img img {
max-height: 150px;
}
/**
* Repeater Style
*/
.aiosrs-pro-repeater-table-wrap {
position: relative;
margin-bottom: 1em;
border: 1px solid #f1f1f1;
padding: 10px;
}
.aiosrs-pro-repeater-table-wrap .bsf-repeater-close {
position: absolute;
top: 0;
right: 0;
padding: 2px;
border: 1px solid #f1f1f1;
}
.bsf-repeater-add-new-btn {
float: right;
width: 100px;
}
.aiosrs-pro-repeater-table-wrap .form-table th,
.aiosrs-pro-repeater-table-wrap .form-table td {
border: 0;
padding: 0;
width: 100%;
display: inline-block;
}
.aiosrs-pro-repeater-table-wrap .form-table td input,
.aiosrs-pro-repeater-table-wrap .form-table td select {
min-width: 70%;
}
.bsf-aiosrs-schema-type-wrap .aiosrs-pro-repeater-table-wrap:first-of-type:last-of-type .bsf-repeater-close {
opacity: 0.3;
filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
pointer-events: none;
}
/**
* Tooltip
*/
.wp-schema-pro-tooltip-wrapper {
position: relative;
display: inline-block;
}
.wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-description {
opacity: 0;
visibility: hidden;
transition: 0.3s;
position: absolute;
background: #333;
color: #dedede;
left: calc(100% - 2.4em);
bottom: calc(100% - 0.75em);
border-radius: 3px;
box-shadow: 0 0 1px 0 #333;
font-weight: 400;
min-width: 300px;
z-index: 9999;
}
.wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-icon {
cursor: pointer;
font-size: 18px;
}
.wp-schema-pro-tooltip-wrapper.activate .wp-schema-pro-tooltip-icon {
pointer-events: none;
}
.wp-schema-pro-tooltip-wrapper .dashicons.dashicons-arrow-down {
position: absolute;
font-size: 3em;
top: calc(100% - 0.5em);
left: 0;
color: #333;
line-height: initial;
z-index: -1;
}
.wp-schema-pro-tooltip-wrapper.activate .wp-schema-pro-tooltip-description {
opacity: 1;
visibility: visible;
bottom: calc(100% + 0.75em);
}
.wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-content {
padding: 8px 12px;
}
.wp-schema-pro-tooltip-wrapper h2.wp-schema-pro-tooltip-heading ~ .wp-schema-pro-tooltip-content {
min-height: 50px;
}
.wp-schema-pro-tooltip-wrapper h2.wp-schema-pro-tooltip-heading {
color: #dedede;
font-weight: 600;
border-bottom: 1px solid #eee;
}
.wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-content a {
text-decoration: none;
box-shadow: none;
font-size: inherit;
}
.wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-content img {
max-width: 100%;
}
.wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-content .tooltip-image {
margin-top: 10px;
}
.tooltip-with-image-wrapper .wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-description {
min-width: 400px;
}
.rtl .wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-description {
right: calc(100% - 2.4em);
left: 0;
}
.rtl .wp-schema-pro-tooltip-wrapper .dashicons.dashicons-arrow-down {
right: 0;
}
.hndle .wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-icon {
color: #f00;
}
.hndle .wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-icon::before {
content: "\f534";
}
.wp-schema-pro-yoast-compatibilty-wrap th {
display: flex;
}
.wp-schema-pro-yoast-compatibilty-wrap td {
vertical-align: top;
padding-top: 20px;
}
.wp-schema-pro-tooltip-content ol {
margin-top: 0.5em;
}
.schema-branding input::placeholder,
.contact-form input::placeholder {
font-style: italic;
}
.aiosrs-menu-page-wrapper #aiosrs-menu-page .wrap .wpsp-pro-logo {
vertical-align: middle;
}
.aiosrs-menu-page-wrapper #aiosrs-menu-page .wrap .wpsp-pro-title {
display: inline-block;
font-size: 20px;
}
.aiosrs-menu-page-wrapper #aiosrs-menu-page .wrap .wpsp-pro-logo img {
max-width: 12%;
margin: 20px 3px 20px 0;
}
#aiosrs-menu-page .schema-version {
font-size: 13px;
background-color: #fff;
padding: 2px;
}
.form-table td.breadcrumb-title {
padding: 0;
}
.wpsp-required-error-field {
color: #f00 !important;
}
.bsf-aiosrs-pro .wp-schema-pro-social-profiles table.form-table tr {
width: 50%;
display: inline-block;
}
.bsf-aiosrs-pro .wp-schema-pro-social-profiles table.form-table tr td input {
width: 135%;
}
.bsf-aiosrs-pro .wp-schema-pro-social-profiles table.form-table tr th {
width: 34%;
}
.bsf-aiosrs-pro .wp-schema-pro-social-profiles table.form-table tr:last-child {
width: auto;
display: block;
}
.wpsp-text-strong {
font-weight: 700;
}
.bsf-aiosrs-pro .postbox.wp-schema-pro-general-settings .hndle,
.bsf-aiosrs-pro .postbox.wp-schema-pro-breadcrumb-setting .hndle,
.bsf-aiosrs-pro .postbox.wp-schema-pro-advanced-settings .hndle,
.bsf-aiosrs-pro .postbox.wp-schema-pro-branding-settings .hndle,
.bsf-aiosrs-pro .postbox.wp-schema-pro-social-profiles .hndle,
.bsf-aiosrs-pro .postbox.wp-schema-pro-corporate-contact .hndle,
.bsf-aiosrs-pro .postbox.wp-schema-pro-global-schemas .hndle,
.bsf-aiosrs-pro .postbox-container .postbox .hndle {
border-bottom: 1px solid #ccd0d4;
}
.wp-schema-pro-general-settings .select2-container--default .select2-selection--single {
box-shadow: 0 0 0 transparent;
border-radius: 4px;
padding: 0.5em;
font-size: 14px;
height: 33px;
border: 1px solid #7e8993;
background-color: #fff;
color: #32373c;
}
.wp-schema-pro-general-settings .select2.select2-container.select2-container--default {
width: 50% !important;
}
.wp-schema-pro-general-settings .select2-container--default .select2-selection--single .select2-selection__rendered {
color: unset;
line-height: unset;
}
.wp-schema-pro-general-settings .select2-container--default .select2-selection--single .select2-selection__arrow {
top: 4px;
}
.select2-container--default .select2-selection.select2-selection--single:focus {
border-color: #007cba;
box-shadow: 0 0 0 1px #007cba;
outline: 2px solid transparent;
}
/**
* dynamic social profile repeater.
*/
.bsf-aiosrs-pro .wp-schema-pro-social-profiles table.form-table tr th.wpsp-other-th {
width: 33% !important;
}
a#add-row {
float: right;
margin-right: 30px;
}
.bsf-aiosrs-pro .wp-schema-pro-social-profiles table.form-table tr td input.wpsp-other {
width: 132% !important;
}
span.wpsp-field-close.dashicons.dashicons-dismiss {
color: #999;
cursor: pointer;
display: inline-flex;
font-size: 18px;
justify-content: center;
position: relative;
top: -22px;
left: 140%;
width: 5px;
}
@media screen and ( min-width: 783px) {
.wp-schema-pro-tooltip-wrapper {
float: right;
}
.rtl .wp-schema-pro-tooltip-wrapper {
float: left;
}
.hndle .wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-description {
min-width: 400px;
}
.hndle .wp-schema-pro-tooltip-wrapper {
float: none;
}
}
@-moz-document url-prefix() {
.bsf-aiosrs-pro .wp-schema-pro-social-profiles table.form-table tr {
width: 50%;
float: left;
}
}

View File

@@ -0,0 +1,589 @@
body {
margin: 100px auto 100px auto;
box-shadow: none;
background: #f1f1f1;
padding: 0;
max-width: 800px;
border: unset;
}
a {
text-decoration: none;
}
#aiosrs-pro-logo {
border: 0;
margin: 0 0 24px;
padding: 0;
text-align: center;
}
#aiosrs-pro-logo a,
#aiosrs-pro-logo a:active,
#aiosrs-pro-logo a:focus {
box-shadow: none;
}
#aiosrs-pro-logo img {
max-width: 30%;
}
/* Wizard Steps */
.aiosrs-pro-setup-wizard-steps,
.aiosrs-pro-setup-steps {
padding: 5px 0 24px;
margin: 0;
list-style: none;
overflow: hidden;
color: #ccc;
width: 100%;
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
display: inline-flex;
}
.aiosrs-pro-setup-wizard-steps li,
.aiosrs-pro-setup-steps li {
width: 33%;
float: left;
padding: 0 0 0.8em;
margin: 0;
text-align: center;
position: relative;
border-bottom: 4px solid #ccc;
line-height: 22px;
}
.aiosrs-pro-setup-wizard-steps li::before,
.aiosrs-pro-setup-steps li::before {
content: "";
border: 4px solid #ccc;
border-radius: 100%;
width: 4px;
height: 4px;
position: absolute;
bottom: 0;
left: 50%;
margin-left: -6px;
margin-bottom: -8px;
background: #fff;
}
.aiosrs-pro-setup-wizard-steps li.active,
.aiosrs-pro-setup-steps li.active {
border-color: #0085ba;
color: #0085ba;
}
.aiosrs-pro-setup-wizard-steps li.active::before,
.aiosrs-pro-setup-steps li.active::before {
border-color: #0085ba;
}
.aiosrs-pro-setup-wizard-steps li.done,
.aiosrs-pro-setup-steps li.done {
border-color: #0085ba;
color: #0085ba;
}
.aiosrs-pro-setup-wizard-steps li.done::before,
.aiosrs-pro-setup-steps li.done::before {
border-color: #0085ba;
background: #0085ba;
}
.aiosrs-pro-setup-wizard-content a,
.aiosrs-pro-setup-content a {
color: #0085ba;
}
.aiosrs-pro-setup-wizard-content a:focus,
.aiosrs-pro-setup-content a:focus,
.aiosrs-pro-setup-wizard-content a:hover,
.aiosrs-pro-setup-content a:hover {
color: #111;
}
/* Wizard Content */
.aiosrs-pro-setup-wizard-content,
.aiosrs-pro-setup-content {
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
padding: 24px 24px 0;
background: #fff;
overflow: hidden;
zoom: 1;
}
.aiosrs-pro-setup-wizard-content h1,
.aiosrs-pro-setup-content h1,
.aiosrs-pro-setup-wizard-content h2,
.aiosrs-pro-setup-content h2,
.aiosrs-pro-setup-wizard-content h3,
.aiosrs-pro-setup-content h3,
.aiosrs-pro-setup-wizard-content table,
.aiosrs-pro-setup-content table {
margin: 0 0 24px;
border: 0;
padding: 0;
color: #666;
clear: none;
}
.aiosrs-pro-setup-wizard-content p,
.aiosrs-pro-setup-content p {
margin: 0 0 24px;
}
.aiosrs-pro-setup-wizard-content p,
.aiosrs-pro-setup-content p,
.aiosrs-pro-setup-wizard-content table,
.aiosrs-pro-setup-content table {
font-size: 1em;
line-height: 1.75;
color: #666;
}
.aiosrs-pro-setup-wizard-content .form-table th,
.aiosrs-pro-setup-content .form-table th {
width: 40%;
vertical-align: top;
font-weight: 400;
}
.aiosrs-pro-setup-wizard-content .form-table td,
.aiosrs-pro-setup-content .form-table td {
vertical-align: top;
}
.aiosrs-pro-setup-wizard-content .form-table td input,
.aiosrs-pro-setup-content .form-table td input,
.aiosrs-pro-setup-wizard-content .form-table td select,
.aiosrs-pro-setup-content .form-table td select {
box-sizing: border-box;
color: inherit;
}
.aiosrs-pro-setup-wizard-content .form-table td input:not([type="checkbox"]),
.aiosrs-pro-setup-wizard-content .form-table td select {
width: 50%;
}
.aiosrs-pro-setup-wizard-content .form-table td .description,
.aiosrs-pro-setup-content .form-table td .description {
line-height: 1.5;
display: block;
margin-top: 0.25em;
color: #999;
font-style: italic;
}
.aiosrs-pro-setup-wizard-content .form-table td .input-checkbox,
.aiosrs-pro-setup-content .form-table td .input-checkbox,
.aiosrs-pro-setup-wizard-content .form-table td .input-radio,
.aiosrs-pro-setup-content .form-table td .input-radio {
width: auto;
box-sizing: inherit;
padding: inherit;
margin: 0 0.5em 0 0;
box-shadow: none;
}
/* Content Bottom Buttons */
.aiosrs-pro-setup-wizard .aiosrs-pro-setup-wizard-actions,
.aiosrs-pro-setup .aiosrs-pro-setup-actions {
overflow: hidden;
}
.aiosrs-pro-setup-wizard .aiosrs-pro-setup-wizard-actions .button,
.aiosrs-pro-setup .aiosrs-pro-setup-actions .button {
float: right;
font-size: 1em;
padding: 0.5em 1em;
line-height: 16px;
margin-right: 0.5em;
margin-bottom: 2px;
height: auto;
border-radius: 4px;
}
.aiosrs-pro-setup-wizard .aiosrs-pro-setup-wizard-actions .skip-button,
.aiosrs-pro-setup .aiosrs-pro-setup-actions .skip-button {
margin-left: 10px;
margin-right: 0;
}
.aiosrs-pro-setup-wizard .aiosrs-pro-setup-wizard-actions .button-primary,
.aiosrs-pro-setup .aiosrs-pro-setup-actions .button-primary {
float: right;
margin: 0;
opacity: 1;
}
.aiosrs-pro-return-to-dashboard {
font-size: 0.85em;
color: #b5b5b5;
margin: 1.18em 0;
display: block;
text-align: center;
}
/* Theme Config Page */
.wp-core-ui .aiosrs-pro-basic-config input.ast-color-picker {
vertical-align: top;
margin-right: 7px;
}
.wp-core-ui .aiosrs-pro-basic-config input.wp-picker-clear {
width: 70px;
}
/* Ready Page */
.aiosrs-pro-setup-wizard-content .twitter-share-button,
.aiosrs-pro-setup-content .twitter-share-button {
float: right;
}
/**
* Site Identity
*/
.aiosrs-pro-setup-wizard-content select,
.aiosrs-pro-setup-content select,
.aiosrs-pro-setup-wizard-content input,
.aiosrs-pro-setup-content input {
border: 1px solid #f1f1f1;
padding: 0.5em;
border-radius: 3px;
font-size: 14px;
}
.aiosrs-pro-setup-wizard-content .select2-container--default .select2-selection--single {
border: 1px solid #f1f1f1;
padding: 0.5em;
border-radius: 3px;
font-size: 14px;
height: 33px;
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
}
.aiosrs-pro-setup-wizard-content .select2.select2-container.select2-container--default {
width: 50% !important;
}
.aiosrs-pro-setup-wizard-content .select2-container--default .select2-selection--single .select2-selection__rendered {
color: unset;
line-height: unset;
}
.aiosrs-pro-setup-wizard-content .select2-container--default .select2-selection--single .select2-selection__arrow {
top: 4px;
}
.select2-container--default .select2-selection.select2-selection--single:focus {
border-color: #007cba;
box-shadow: 0 0 0 1px #007cba;
outline: 2px solid transparent;
}
.wp-picker-active .wp-picker-holder {
position: absolute;
z-index: 9;
}
.aiosrs-pro-setup-wizard-next-steps .button-hero:last-child,
.aiosrs-pro-setup-next-steps .button-hero:last-child {
margin-bottom: 0;
}
.aiosrs-pro-setup-wizard-next-steps .button-hero,
.aiosrs-pro-setup-next-steps .button-hero {
width: 100%;
margin-bottom: 1em;
}
/**
* Step: Last
*/
.aiosrs-pro-setup-wizard-next-steps-last ul,
.aiosrs-pro-setup-next-steps-last ul {
padding: 0;
}
.aiosrs-pro-setup-wizard-next-steps-last li i,
.aiosrs-pro-setup-next-steps-last li i {
padding-right: 10px;
}
.aiosrs-pro-setup-wizard-next-steps-last li,
.aiosrs-pro-setup-next-steps-last li {
list-style-type: none;
padding: 0;
margin-bottom: 0.5em;
}
/**
* Schema template
*/
.aiosrs-pro-basic-config .aiosrs-pro-schema-temp-wrap {
display: inline-block;
background: #f1f1f1;
border: 1px solid #d8d8d8;
padding: 10px 5px;
width: calc(33% - 8px);
text-align: center;
margin-right: 10px;
margin-bottom: 10px;
cursor: pointer;
box-sizing: border-box;
overflow: hidden;
vertical-align: middle;
font-size: 16px;
}
.aiosrs-pro-basic-config .aiosrs-pro-schema-temp-wrap:nth-child(3n) {
margin-right: 0;
}
.aiosrs-pro-basic-config .aiosrs-pro-schema-temp-wrap.selected,
.aiosrs-pro-basic-config .aiosrs-pro-schema-temp-wrap:hover {
background: #d6d6d6;
border-color: #b9b9b9;
}
.aiosrs-pro-basic-config .aiosrs-pro-schema-temp-wrap i {
font-size: 18px;
height: 18px;
display: block;
margin: auto;
}
.aiosrs-pro-basic-config td {
padding: 0;
}
.aiosrs-pro-setup-wizard-content table.bsf-aiosrs-schema-table,
.aiosrs-pro-setup-content table.bsf-aiosrs-schema-table {
border: 1px solid #e1e1e1;
border-collapse: collapse;
width: 100%;
}
.aiosrs-pro-setup-wizard-content table.form-table th,
.aiosrs-pro-setup-content table.aiosrs-pro-schema-ready th,
.aiosrs-pro-setup-wizard-content table.form-table td,
.aiosrs-pro-setup-content table.aiosrs-pro-schema-ready td,
.aiosrs-pro-setup-wizard-content table.form-table .button-hero,
.aiosrs-pro-setup-content table.aiosrs-pro-schema-ready .button-hero {
font-size: 16px;
font-size: 1rem;
}
.aiosrs-pro-setup-wizard-content table.aiosrs-pro-schema-ready td,
.aiosrs-pro-setup-content table.aiosrs-pro-schema-ready td {
padding-right: 0;
}
.aiosrs-pro-setup-wizard .wizard-close-link,
.aiosrs-pro-setup .wizard-close-link {
color: #ccc;
box-shadow: none;
}
/**
* Hide tooltip text
*/
.aiosrs-pro-setup-wizard .ui-helper-hidden-accessible,
.aiosrs-pro-setup .ui-helper-hidden-accessible {
display: none;
}
.aiosrs-pro-setup-wizard .ui-widget-content.bsf-aiosrs-schema-ui-tooltip,
.aiosrs-pro-setup .ui-widget-content.bsf-aiosrs-schema-ui-tooltip {
font-size: 14px;
}
.aiosrs-pro-schema-ready .button-primary.button-hero {
text-align: center;
}
/**
* Schema Pro On-Boarding
*/
.aiosrs-pro-setup-wizard .aiosrs-pro-setup-wizard-content .button-next,
.aiosrs-pro-setup-wizard-content.welcome-content-wrap .button-close {
margin-left: 10px;
}
.aiosrs-pro-setup-wizard-content.social-profiles-content-wrap input[type="text"] {
width: 100%;
}
.aiosrs-pro-setup-wizard-content.success-content-wrap .form-table td {
width: 45%;
text-align: center;
padding-right: 0;
}
.aiosrs-pro-setup-wizard-content.success-content-wrap .form-table td.space {
width: 10%;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .form-table select {
min-width: 53%;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .custom-field-wrapper {
display: inline-block;
width: 48%;
vertical-align: middle;
}
/**
* Custom Image Select
*/
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .image-field-wrap {
position: relative;
display: inline-block;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .aiosrs-image-select .dashicons {
font-size: 1.2em;
width: 1em;
height: 1em;
line-height: 22px;
margin-right: 5px;
vertical-align: middle;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .aiosrs-image-remove {
display: none;
position: absolute;
background: rgba(255, 255, 255, 0.7);
right: 0;
font-size: 15px;
width: 1em;
height: 1em;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .bsf-custom-image-selected .aiosrs-image-select {
display: none;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .bsf-custom-image-selected .aiosrs-image-remove {
display: inline-block;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .bsf-custom-image-selected .aiosrs-image-select.img {
max-width: 100%;
display: inline-block;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .bsf-custom-image-selected .aiosrs-image-select.img img {
max-height: 75px;
vertical-align: middle;
max-width: 300px;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .bsf-custom-image-selected .aiosrs-image-select.default-image.img img {
max-height: 150px;
}
.close-button-wrapper {
text-align: center;
margin: 1em 0;
}
.close-button-wrapper a.button-close .dashicons {
vertical-align: middle;
font-size: 1.3em;
line-height: 0.9;
width: 1em;
height: 1em;
}
.close-button-wrapper .button {
font-size: 1em;
padding: 5px 15px;
height: auto;
background: #fff;
}
.aiosrs-pro-setup-wizard-content.welcome-content-wrap ul {
margin-top: 0;
}
.aiosrs-pro-setup-wizard-content.welcome-content-wrap ul li {
font-size: inherit;
color: #666;
}
.aiosrs-pro-setup-wizard-content .no-margin {
margin: 0 auto;
}
.aiosrs-pro-setup-wizard-content.global-schemas-content-wrap {
overflow: initial;
}
.aiosrs-pro-setup-wizard-content.global-schemas-content-wrap .aiosrs-pro-setup-wizard-actions {
padding-bottom: 24px;
margin-bottom: 0;
}
.aiosrs-pro-setup-wizard-content.social-profiles-content-wrap .form-table tr {
display: inline-block;
width: 50%;
}
.aiosrs-pro-setup-wizard-content.social-profiles-content-wrap .form-table tr th {
vertical-align: middle;
font-weight: 600;
}
.aiosrs-pro-setup-wizard-content.social-profiles-content-wrap .form-table tr td input {
width: 120%;
}
.aiosrs-pro-field-description {
font-style: italic;
}
.aiosrs-pro-setup-wizard #aiosrs-pro-logo .wpsp-setup-pro-title,
.aiosrs-pro-setup #aiosrs-pro-logo .wpsp-setup-pro-title {
color: #000;
font-size: 26px;
padding: 0;
font-weight: 600;
display: inline-block;
vertical-align: top;
border: unset;
}
@-moz-document url-prefix() {
.aiosrs-pro-setup-wizard-content.social-profiles-content-wrap .form-table tr {
width: 50%;
float: left;
}
}

View File

@@ -0,0 +1,388 @@
/* Meta Box Heading
------------------------------------------------------*/
#aiosrs-schema-settings .inside {
margin: 0;
padding: 0;
}
#aiosrs-schema-settings .nav-tab-wrapper {
border-bottom: 0;
}
#aiosrs-schema-settings .nav-tab-wrapper ul {
margin: 0;
}
/* Tooltips */
.bsf-aiosrs-schema-heading-help {
color: #0073aa;
float: unset;
font-size: 18px;
cursor: help;
}
.ui-widget-content.bsf-aiosrs-schema-ui-tooltip {
background: #333;
border-width: 1px;
border-color: #333;
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 1px 0 2px 0 rgba(214, 214, 214, 0.5);
box-shadow: 1px 0 2px 0 rgba(214, 214, 214, 0.5);
color: #dedede;
max-width: 250px;
text-align: center;
padding: 7px;
text-rendering: optimizeLegibility;
text-shadow: none;
z-index: 9999;
}
/* Table */
.bsf-aiosrs-schema-table {
border: none;
border-bottom: 5px solid #f0f0f0;
}
.bsf-aiosrs-schema-table:last-of-type {
border-bottom-width: 0;
}
.bsf-aiosrs-schema-table.widefat {
border-width: 0;
border-bottom-width: 2px;
}
.bsf-aiosrs-schema-table.widefat:last-child {
border-bottom-width: 1px;
}
/* Rows */
.bsf-aiosrs-schema-row td::before,
.bsf-aiosrs-schema-row td::after {
display: table;
content: " ";
}
.bsf-aiosrs-schema-row td::after {
clear: both;
}
.bsf-aiosrs-schema-row td {
zoom: 1;
vertical-align: middle;
}
.bsf-aiosrs-schema-row td * {
vertical-align: middle;
}
.bsf-aiosrs-schema-row:last-child td {
border-bottom: none;
}
/* Row Heading */
.bsf-aiosrs-schema-row-heading {
border-right: 1px solid #e1e1e1;
padding: 15px;
width: 25%;
vertical-align: middle;
}
.bsf-aiosrs-schema-row td.bsf-aiosrs-schema-row-heading.title {
padding-bottom: 0;
border-bottom: 0;
}
.bsf-aiosrs-schema-row-heading label {
display: inline-block;
font-size: 13px;
line-height: 22px;
font-weight: 700;
padding: 0;
margin: 0 0 3px;
color: #333;
}
/* Row Content */
.bsf-aiosrs-schema-table .bsf-aiosrs-schema-row-content {
padding: 15px 10px;
position: relative;
width: 75%;
}
.bsf-aiosrs-schema-row-content p:last-child {
margin-bottom: 0;
}
.bsf-aiosrs-schema-padding {
width: 110px;
}
.bsf-aiosrs-schema-padding-bottom-wrap {
margin-top: 5px;
}
/* Row Inputs */
.bsf-aiosrs-schema-row-content select {
width: 100%;
}
.bsf-aiosrs-schema-row-content .bsf-aiosrs-schema-action-desc.ast-no-desc {
margin-top: 0;
}
.bsf-aiosrs-schema-row-content .bsf-aiosrs-schema-action-desc {
margin-top: 10px;
}
/*Title CSS for the Enable on*/
.bsf-aiosrs-schema-row-select-target h2.bsf-aiosrs-schema-row-heading-select-target {
border-bottom: 1px solid #ccd0d4;
font-weight: 600 !important;
padding: 10px 12px !important;
}
.bsf-aiosrs-schema-row-select-target h2.bsf-aiosrs-schema-row-heading-select-target label {
vertical-align: initial;
}
/* Settings Meta Box
------------------------------------------------------*/
#bsf-aiosrs-schema-settings .inside {
margin: 0;
padding: 0;
}
/* Builder Buttons Meta Box
------------------------------------------------------*/
#bsf-aiosrs-schema-buttons .inside {
margin: 0;
padding: 15px;
}
#bsf-aiosrs-schema-buttons .button {
margin-right: 5px;
}
/* Rule Settings
------------------------------------------------------*/
/* Rule Forms */
.bsf-aiosrs-schema-saved-rule {
-js-display: flex;
display: -webkit-box;
display: -webkit-flex;
display: -moz-box;
display: -ms-flexbox;
display: flex;
padding: 0 0 8px 0;
}
.bsf-aiosrs-schema-saved-rule-select {
width: 100%;
}
.bsf-aiosrs-schema-rule-objects {
display: none;
}
.bsf-aiosrs-schema-rule-objects-visible {
-js-display: flex;
display: -webkit-box;
display: -webkit-flex;
display: -moz-box;
display: -ms-flexbox;
display: flex;
}
.bsf-aiosrs-schema-row-content .bsf-aiosrs-schema-rule-objects-visible select {
width: 50%;
}
.bsf-aiosrs-schema-rule-objects-visible .bsf-aiosrs-schema-rule-objects {
display: inline;
margin-left: 7px;
}
.bsf-aiosrs-schema-remove-rule-button {
display: none;
margin-top: 5px;
text-align: right;
width: 33px;
}
.bsf-aiosrs-schema-remove-rule {
color: #000;
cursor: pointer;
opacity: 0.2;
}
.bsf-aiosrs-schema-remove-rule:hover {
color: #d54e21;
opacity: 1;
}
.bsf-aiosrs-schema-add-rule {
float: left;
margin-right: 8px;
min-width: 150px;
}
.bsf-aiosrs-schema-add-rule .button {
text-align: center;
width: 100%;
}
/* Location Rules */
.bsf-aiosrs-schema-locations-form {
display: none;
}
/* Exclusion Rules */
.bsf-aiosrs-schema-exclusion-rules {
display: none;
}
/* Color Picker */
.bsf-aiosrs-schema-row .wp-picker-holder {
position: absolute;
z-index: 1;
}
.bsf-aiosrs-schema-row .iris-border .iris-picker-inner {
right: 0;
}
.bsf-aiosrs-schema-row-content .bsf-aiosrs-schema-type {
width: auto;
}
.bsf-aiosrs-schema-table .bsf-aiosrs-schema-fixed-text-wrap,
.bsf-aiosrs-schema-table .bsf-aiosrs-schema-custom-text-wrap {
width: calc(55% - 5px);
display: inline-block;
}
.bsf-aiosrs-schema-table .bsf-aiosrs-schema-meta-field {
width: calc(45% - 5px);
display: inline-block;
}
.bsf-aiosrs-schema-table .bsf-aiosrs-schema-custom-text-wrap input {
width: 100%;
}
.bsf-aiosrs-schema-table .bsf-custom-remove-image,
.bsf-aiosrs-schema-table .update-custom-image,
.bsf-aiosrs-schema-table .bsf-hidden-field,
.bsf-custom-image-selected button.bsf-custom-select-image {
display: none;
}
.bsf-custom-image-selected .bsf-custom-remove-image {
display: inline-block;
}
.select-custom-image,
.bsf-custom-image-selected .update-custom-image {
display: block;
}
.bsf-custom-remove-image .dashicons {
padding: 0;
}
.bsf-custom-image-label {
margin-left: 5px;
display: inline-block;
}
.bsf-aiosrs-schema-specific-field-wrap {
display: inline-block;
width: 50%;
}
.bsf-aiosrs-guideline-link i {
font-size: 1rem;
width: auto;
}
/**
* Repeater Style
*/
.aiosrs-pro-repeater-table {
width: 100%;
border: 1px solid #f1f1f1;
padding: 10px;
}
.aiosrs-pro-repeater-table-wrap {
position: relative;
margin-bottom: 1em;
}
.bsf-aiosrs-schema-row:first-child {
line-height: 0;
height: 0;
}
.bsf-repeater-close {
position: absolute;
top: 0;
right: 0;
padding: 2px;
border: 1px solid #f1f1f1;
}
.bsf-repeater-add-new-btn {
float: right;
width: 100px;
}
.aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-heading,
.aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-content {
border: 0;
padding: 0;
width: 100%;
display: inline-block;
}
.aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-heading label,
.aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-content {
line-height: 1;
}
.aiosrs-pro-repeater-table .bsf-aiosrs-schema-row td::before,
.aiosrs-pro-repeater-table .bsf-aiosrs-schema-row td::after {
display: none;
}
.bsf-aiosrs-schema-type-wrap .aiosrs-pro-repeater-table-wrap:first-of-type:last-of-type .bsf-repeater-close {
opacity: 0.3;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
pointer-events: none;
}
.bsf-aiosrs-schema-row-repeater-type > .bsf-aiosrs-schema-row-heading {
vertical-align: top;
padding-top: 25px;
}
.wp-schema-pro-tooltip-wrapper {
font-size: 14px;
line-height: 18px;
}
.wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-icon {
line-height: 1.5;
vertical-align: middle;
}
.aiosrs-pro-setup-wizard-content.advanced-settings-content-wrap .label-wrapper {
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

@@ -0,0 +1,704 @@
/* eslint-env jquery */
(function ($) {
$(window).on('load', function () {
$(
'.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table-wrap'
).hide();
$(
'.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .bsf-repeater-add-new-btn'
).hide();
$(
'.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table-wrap'
).hide();
$(
'.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .bsf-repeater-add-new-btn'
).hide();
});
$(document).ready(function () {
const { __ } = wp.i18n;
$('#wpsp-reset-dialog-confirmation').dialog({
dialogClass: 'wp-dialog',
autoOpen: false,
modal: true,
});
// Added support to repeater validation.
$(
'.wpsp-custom-field-connect, .wpsp-field-close, .bsf-aiosrs-schema-meta-field, image-field-wrap, .aiosrs-pro-custom-field, .wpsp-custom-field-connect'
).on('click focus change', function () {
$('.wpsp-local-fields').each(function (index, repeater) {
let fieldValue = $(repeater)
.find('.wpsp-default-hidden-value')
.val();
const requiredPath = $(repeater)
.parents('.bsf-aiosrs-schema-row-content')
.prev();
fieldValue = fieldValue.trim();
if (fieldValue) {
if ($('body').hasClass('block-editor-page')) {
if (
!$(repeater).find('.wpsp-required-error-field')
.length
) {
let metaField;
switch (fieldValue) {
case 'post_title':
metaField = $(
'.editor-post-title__input'
).val();
break;
case 'post_content':
metaField =
$(
'p.block-editor-rich-text__editable'
).text().length > 1
? $(
'p.block-editor-rich-text__editable'
).text()
: '';
break;
case 'post_excerpt':
metaField = $(
'.components-textarea-control__input'
).val();
break;
case 'featured_img':
if (
'Set featured image' ===
$(
'.editor-post-featured-image__toggle'
).text()
) {
metaField = '';
} else {
metaField = $(
'.components-responsive-wrapper__content'
).attr('src');
}
break;
default:
requiredPath.removeClass(
'wpsp-required-error-field'
);
}
if (undefined !== metaField) {
if ('' !== metaField) {
requiredPath.removeClass(
'wpsp-required-error-field'
);
} else if (
requiredPath.find('.required').length
) {
requiredPath.addClass(
'wpsp-required-error-field'
);
}
}
}
} else {
requiredPath.removeClass('wpsp-required-error-field');
}
} else if (requiredPath.find('.required').length) {
requiredPath.addClass('wpsp-required-error-field');
}
});
});
$('.wpsp-show-repeater-field').click(function () {
const parent = $(this).parents(
'.aiosrs-pro-custom-field-repeater'
);
parent.find('.aiosrs-pro-repeater-table-wrap').show();
parent.find('.bsf-repeater-add-new-btn').show();
parent.find('.wpsp-show-repeater-field').addClass('bsf-hidden');
parent
.find('.wpsp-hide-repeater-field')
.removeClass('bsf-hidden');
});
$('.wpsp-hide-repeater-field').click(function () {
const parent = $(this).parents(
'.aiosrs-pro-custom-field-repeater'
);
parent.find('.aiosrs-pro-repeater-table-wrap').hide();
parent.find('.bsf-repeater-add-new-btn').hide();
parent.find('.wpsp-hide-repeater-field').addClass('bsf-hidden');
parent
.find('.wpsp-show-repeater-field')
.removeClass('bsf-hidden');
});
$('.wpsp-show-repeater-target-field').click(function () {
const parent = $(this).parents(
'.aiosrs-pro-custom-field-repeater-target'
);
parent.find('.aiosrs-pro-repeater-table-wrap').show();
parent.find('.bsf-repeater-add-new-btn').show();
parent
.find('.wpsp-show-repeater-target-field')
.addClass('bsf-hidden');
parent
.find('.wpsp-hide-repeater-target-field')
.removeClass('bsf-hidden');
});
$('.wpsp-hide-repeater-target-field').click(function () {
const parent = $(this).parents(
'.aiosrs-pro-custom-field-repeater-target'
);
parent.find('.aiosrs-pro-repeater-table-wrap').hide();
parent.find('.bsf-repeater-add-new-btn').hide();
parent
.find('.wpsp-hide-repeater-target-field')
.addClass('bsf-hidden');
parent
.find('.wpsp-show-repeater-target-field')
.removeClass('bsf-hidden');
});
$('input[type="checkbox"].wpsp-enable-schema-toggle__input').on(
'click',
function () {
const parent = $(this).parents(
'.wpsp-enable-schema-markup'
);
const thisVal = $(this).val();
const togglebtn = parent.find('.wpsp-enable-schema-toggle');
const togglehid = parent.find(
'.wpsp-enable-schema-toggle__input-hidden'
);
const isChecked = togglebtn.hasClass('is-checked');
if (!isChecked && '1' === thisVal) {
togglehid.attr('value', '1');
togglebtn.addClass('is-checked');
} else {
togglehid.attr('value', 'disabled');
togglebtn.removeClass('is-checked');
}
}
);
$(document).on('change click', function () {
$('.wpsp-local-fields')
.find('select, textarea, input')
.on('change keyup', function (event) {
if (
event.isTrigger &&
!$(this).hasClass('wpsp-specific-field') &&
!$(this).hasClass('wpsp-date-field')
) {
return false;
}
const parent = $(this).parents('.wpsp-local-fields');
parent
.find('.wpsp-default-hidden-value')
.val($(this).val());
parent
.find('.wpsp-default-hidden-fieldtype')
.val(
$(this)
.parents('.wpsp-parent-field')
.attr('data-type')
);
if (
$(this).is('select') &&
$(this).parent().hasClass('wpsp-connect-field')
) {
const selectedOption = $(this).val();
if (
'create-field' === selectedOption ||
'specific-field' === selectedOption
) {
if ('create-field' === selectedOption) {
displayCustomField(parent);
parent
.find('.wpsp-default-hidden-fieldtype')
.val('custom-field');
}
if ('specific-field' === selectedOption) {
displaySpecificField(parent);
parent
.find('.wpsp-default-hidden-fieldtype')
.val('specific-field');
}
parent
.find('.wpsp-default-hidden-value')
.val('');
}
}
});
$('select.bsf-aiosrs-schema-meta-field').change(function () {
const parent = $(this).parents('.wpsp-local-fields');
const label = parent.find('select option:selected').html();
const selectedOption = $(this).val();
if (
'none' === selectedOption ||
'create-field' === selectedOption ||
'specific-field' === selectedOption
) {
parent
.find('.bsf-aiosrs-schema-heading-help')
.attr(
'title',
'Please connect any field to apply in the Schema Markup!'
);
} else {
parent
.find('.bsf-aiosrs-schema-heading-help')
.attr(
'title',
'The ' +
label +
' value in this field will be added to the schema markup of this particular post/page.'
);
}
});
function displaySpecificField(parent) {
parent.find('.wpsp-connect-field,.wpsp-custom-field').hide();
parent
.find('.wpsp-specific-field')
.removeClass('bsf-hidden')
.show()
.find('select, textarea, input')
.val('');
}
function displayCustomField(parent) {
parent
.find('.wpsp-connect-field,.wpsp-specific-field')
.hide();
parent
.find('.wpsp-custom-field')
.removeClass('bsf-hidden')
.show()
.find('select, textarea, input')
.val('');
}
$(document).on('click', '.wpsp-field-close', function () {
const parent = $(this).parents('.wpsp-local-fields');
const select = parent
.find('.wpsp-connect-field')
.removeClass('bsf-hidden')
.show()
.find('select')
.removeAttr('disabled');
const selectVal = select.val();
if ('specific-field' === selectVal) {
parent.find('.wpsp-default-hidden-value').val('');
parent
.find('.wpsp-default-hidden-fieldtype')
.val('specific-field');
displaySpecificField(parent);
return;
}
parent.find('.wpsp-default-hidden-value').val('');
parent
.find('.wpsp-default-hidden-fieldtype')
.val('custom-field');
displayCustomField(parent);
});
$(document).on(
'click',
'.wpsp-specific-field-connect, .wpsp-custom-field-connect',
function () {
const parent = $(this).parents('.wpsp-local-fields');
const select = parent
.find('.wpsp-connect-field')
.removeClass('bsf-hidden')
.show()
.find('select')
.removeAttr('disabled');
let selectVal = select.val();
if (
'create-field' === selectVal ||
'specific-field' === selectVal
) {
selectVal = 'none';
}
parent
.find('.wpsp-default-hidden-value')
.val(selectVal);
parent
.find('.wpsp-default-hidden-fieldtype')
.val('global-field');
parent
.find('.wpsp-custom-field, .wpsp-specific-field')
.hide();
}
);
});
$(document).on('change input', '.bsf-rating-field', function () {
const starWrap = $(this).next('.aiosrs-star-rating-wrap'),
value = $(this).val();
let filled = value > 5 ? 5 : parseInt(value);
if (value > 5) {
filled = 5;
} else if (value < 0) {
filled = 0;
} else {
filled = parseInt(value);
}
const half = value === filled || value > 5 || value < 0 ? 0 : 1;
starWrap.find('span').each(function (index) {
$(this).removeClass(
'dashicons-star-filled dashicons-star-half dashicons-star-empty'
);
if (index < filled) {
$(this).addClass('dashicons-star-filled');
} else if (index === filled && half === 1) {
$(this).addClass('dashicons-star-half');
} else {
$(this).addClass('dashicons-star-empty');
}
});
});
$(document).on(
'click',
'.aiosrs-star-rating-wrap:not(.disabled) > .aiosrs-star-rating',
function (e) {
e.preventDefault();
const index = $(this).data('index');
const starWrap = $(this).parent();
const parent = $(this).parents('.wpsp-local-fields');
starWrap.prev('.bsf-rating-field').val(index);
parent.find('.wpsp-default-hidden-value').val(index);
starWrap.find('.aiosrs-star-rating').each(function (i) {
$(this).removeClass(
'dashicons-star-filled dashicons-star-half dashicons-star-empty'
);
if (i < index) {
$(this).addClass('dashicons-star-filled');
} else {
$(this).addClass('dashicons-star-empty');
}
});
}
);
$(document).on(
'change',
'#aiosrs-pro-custom-fields .aiosrs-pro-custom-field-checkbox input[type="checkbox"]',
function (e) {
e.preventDefault();
const siblings = $(this)
.closest('tr.row')
.siblings('tr.row');
if ($(this).prop('checked')) {
siblings.show();
} else {
siblings.hide();
}
}
);
$(
'#aiosrs-pro-custom-fields .aiosrs-pro-custom-field-checkbox input[type="checkbox"]'
).trigger('change');
$(document.body).on(
'change',
'#aiosrs-pro-custom-fields .wpsp-enable-schema-markup input[type="checkbox"].wpsp-enable-schema-toggle__input',
function (e) {
e.preventDefault();
const parent = $(this).parents(
'.wpsp-enable-schema-markup'
);
if ($(this).prop('checked')) {
parent
.find('.wpsp-enable-schema-toggle')
.addClass('is-checked');
parent
.find('.wpsp-enable-schema-toggle__input-hidden')
.attr('value', '1');
} else {
parent
.find('.wpsp-enable-schema-toggle')
.removeClass('is-checked');
parent
.find('.wpsp-enable-schema-toggle__input-hidden')
.attr('value', 'disabled');
}
}
);
$(
'#aiosrs-pro-custom-fields .wpsp-enable-schema-markup input[type="checkbox"].wpsp-enable-schema-toggle__input'
).trigger('change');
$(document).on('click', '.aiosrs-reset-rating', function (e) {
e.preventDefault();
const thisObj = $(this);
const parent = thisObj.closest('.aiosrs-pro-custom-field-rating');
const ajaxData = {
action: 'aiosrs_reset_post_rating',
post_id: thisObj.data('post-id'),
schema_id: thisObj.data('schema-id'),
nonce: thisObj.data('nonce'),
};
$('#wpsp-reset-dialog-confirmation').dialog({
resizable: false,
title: __('Confirmation Required!', 'wp-schema-pro'),
height: 'auto',
width: 400,
modal: true,
open() {
$(this)
.closest('.ui-dialog')
.find('.ui-dialog-titlebar-close')
.hide();
const markup =
'<p><span class="dashicons dashicons-trash"></span> Do you really want to reset current post rating?</p>';
$(this).html(markup);
},
buttons: {
Yes() {
thisObj.addClass('reset-disabled');
parent.find('.spinner').addClass('is-active');
jQuery
.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: ajaxData,
})
.success(function (response) {
if (
'undefined' !== typeof response.success &&
response.success === true
) {
const avgRating = response['rating-avg'],
reviewCount =
response['review-count'];
parent
.find('.aiosrs-rating')
.text(avgRating);
parent
.find('.aiosrs-rating-count')
.text(reviewCount);
parent
.find(
'.aiosrs-star-rating-wrap > .aiosrs-star-rating'
)
.removeClass(
'dashicons-star-filled dashicons-star-half dashicons-star-empty'
)
.addClass('dashicons-star-empty');
} else {
thisObj.removeClass('reset-disabled');
}
parent
.find('.spinner')
.removeClass('is-active');
});
$(this).dialog('close');
},
Cancel() {
$(this).dialog('close');
},
},
});
$('#wpsp-reset-dialog-confirmation').dialog('open');
});
$(document).on('change', '.multi-select-wrap select', function () {
const multiselectWrap = $(this).closest('.multi-select-wrap'),
selectWrap = multiselectWrap.find('select'),
inputField = multiselectWrap.find('input[type="hidden"]'),
value = selectWrap.val();
if (
'undefined' !== typeof value &&
null !== value &&
value.length > 0
) {
inputField.val(value.join(','));
} else {
inputField.val('');
}
});
// Verticle Tabs
$(document).on(
'click',
'.aiosrs-pro-meta-fields-tab',
function (e) {
e.preventDefault();
const id = $(this).data('tab-id');
$(this)
.siblings('.aiosrs-pro-meta-fields-tab')
.removeClass('active');
$(this).addClass('active');
$('#aiosrs-pro-custom-fields')
.find('.aiosrs-pro-meta-fields-wrap')
.removeClass('open');
$('#aiosrs-pro-custom-fields')
.find('.' + id)
.addClass('open');
}
);
// Toggle Js for Enable Schema Markup.
$(document.body).on(
'change',
'#aiosrs-pro-custom-fields .wpsp-enable-schema-markup .wpsp-enable-schema-toggle',
function () {
const parent = $(this).parents(
'.aiosrs-pro-meta-fields-tab'
);
const parents = $(this).parents('.inside');
const id = parent.data('tab-id');
const hasClass = parents
.find('.aiosrs-pro-meta-fields-wrapper')
.find('.' + id)
.hasClass('is-enable-schema-markup');
const isChecked = parent
.find('.wpsp-enable-schema-toggle')
.hasClass('is-checked');
if (!hasClass && !isChecked) {
parents
.find('.aiosrs-pro-meta-fields-wrapper')
.find('.' + id)
.addClass('is-enable-schema-markup');
}
}
);
$(
'#aiosrs-pro-custom-fields .wpsp-enable-schema-markup .wpsp-enable-schema-toggle'
).trigger('change');
$('.wpsp-enable-schema-toggle').on('click', function () {
const parent = $(this).parents('.aiosrs-pro-meta-fields-tab');
const parents = $(this).parents('.inside');
const id = parent.data('tab-id');
parents
.find('.aiosrs-pro-meta-fields-wrapper')
.find('.' + id)
.toggleClass('is-enable-schema-markup');
});
// Call Tooltip
$('.bsf-aiosrs-schema-heading-help').tooltip({
content() {
return $(this).prop('title');
},
tooltipClass: 'bsf-aiosrs-schema-ui-tooltip',
position: {
my: 'center top',
at: 'center bottom+10',
},
hide: {
duration: 200,
},
show: {
duration: 200,
},
});
let fileFrame;
window.inputWrapper = '';
$(document.body).on(
'click',
'.image-field-wrap .aiosrs-image-select',
function (e) {
e.preventDefault();
window.inputWrapper = $(this).closest(
'.bsf-aiosrs-schema-custom-text-wrap, .aiosrs-pro-custom-field-image'
);
// Create the media frame.
fileFrame = wp.media({
button: {
text: 'Select Image',
close: false,
},
states: [
new wp.media.controller.Library({
title: __('Select Custom Image', 'wp-schema-pro'),
library: wp.media.query({ type: 'image' }),
multiple: false,
}),
],
});
// When an image is selected, run a callback.
fileFrame.on('select', function () {
const attachment = fileFrame
.state()
.get('selection')
.first()
.toJSON();
const image = window.inputWrapper.find(
'.image-field-wrap img'
);
if (image.length === 0) {
window.inputWrapper
.find('.image-field-wrap')
.append(
'<a href="#" class="aiosrs-image-select img"><img src="' +
attachment.url +
'" /></a>'
);
} else {
image.attr('src', attachment.url);
}
window.inputWrapper
.find('.image-field-wrap')
.addClass('bsf-custom-image-selected');
window.inputWrapper
.find('.single-image-field')
.val(attachment.id);
const parent = window.inputWrapper.parents(
'.wpsp-local-fields'
);
parent
.find('.wpsp-default-hidden-value')
.val(attachment.id);
parent
.find('.wpsp-default-hidden-fieldtype')
.val(
window.inputWrapper
.parents('.wpsp-parent-field')
.attr('data-type')
);
fileFrame.close();
});
fileFrame.open();
}
);
$(document).on('click', '.aiosrs-image-remove', function (e) {
e.preventDefault();
const parent = $(this).closest(
'.bsf-aiosrs-schema-custom-text-wrap, .aiosrs-pro-custom-field-image'
);
parent
.find('.image-field-wrap')
.removeClass('bsf-custom-image-selected');
parent.find('.single-image-field').val('');
parent.find('.image-field-wrap img').removeAttr('src');
});
window.inputWrapper = '';
});
})(jQuery);

View File

@@ -0,0 +1,147 @@
/* eslint-env jquery */
(function ($) {
/**
* AIOSRS Frontend
*
* @class WPSchemaProFrontend
* @since 1.0
*/
const WPSchemaProFrontend = {
/**
* Initializes a AIOSRS Frontend.
*
* @since 1.0
* @function init
*/
container: '',
init() {
const self = this;
jQuery(document).on(
'click',
'.aiosrs-rating-wrap .aiosrs-star-rating',
function (e) {
e.preventDefault();
self.star_rating(this);
}
);
jQuery(document).on(
'mouseover',
'.aiosrs-rating-wrap .aiosrs-star-rating',
function (e) {
e.preventDefault();
self.hover_star_rating(this);
}
);
jQuery(document).on(
'mouseout',
'.aiosrs-rating-wrap .aiosrs-star-rating-wrap',
function (e) {
e.preventDefault();
if (!$(this).hasClass('disabled')) {
const index = $(this)
.parent()
.find('.aiosrs-rating')
.text();
self.update_stars($(this), index);
}
}
);
},
hover_star_rating(field) {
const self = this,
parent = $(field).closest('.aiosrs-star-rating-wrap'),
index = $(field).data('index');
if (!parent.hasClass('disabled')) {
self.update_stars(parent, index);
}
},
update_stars(wrap, rating) {
let filled = rating > 5 ? 5 : parseInt(rating);
if (rating > 5) {
filled = 5;
} else if (rating < 0) {
filled = 0;
} else {
filled = parseInt(rating);
}
const half = rating === filled || rating > 5 || rating < 0 ? 0 : 1;
wrap.find('span').each(function (index) {
$(this).removeClass(
'dashicons-star-filled dashicons-star-half dashicons-star-empty'
);
if (index < filled) {
$(this).addClass('dashicons-star-filled');
} else if (index === filled && half === 1) {
$(this).addClass('dashicons-star-empty');
} else {
$(this).addClass('dashicons-star-empty');
}
});
},
star_rating(field) {
const self = this,
schemaId = $(field)
.closest('.aiosrs-rating-wrap')
.data('schema-id'),
parent = $(field).closest('.aiosrs-star-rating-wrap'),
index = $(field).data('index');
if (!parent.hasClass('disabled')) {
self.update_stars(parent, index);
parent.addClass('disabled');
$.ajax({
url: AIOSRS_Frontend.ajaxurl,
type: 'POST',
data: {
action: 'aiosrs_user_rating',
rating: index,
schemaId,
post_id: AIOSRS_Frontend.post_id,
nonce: AIOSRS_Frontend.user_rating_nonce,
},
}).success(function (response) {
if (response.success === true) {
const summaryWrap = parent.next(
'.aiosrs-rating-summary-wrap'
),
rating = response.rating,
avgRating = response['rating-avg'],
reviewCount = response['review-count'];
summaryWrap.find('.aiosrs-rating').text(avgRating);
summaryWrap
.find('.aiosrs-rating-count')
.text(reviewCount);
if (parent.next('.success-msg').length === 0) {
parent.after(
'<span class="success-msg">' +
AIOSRS_Frontend.success_msg +
'</span>'
);
}
setTimeout(function () {
parent.parent().find('.success-msg').remove();
parent.removeClass('disabled');
}, 5000);
self.update_stars(parent, rating);
}
});
}
},
};
/* Initializes the AIOSRS Frontend. */
$(function () {
WPSchemaProFrontend.init();
});
})(jQuery);

View File

@@ -0,0 +1,26 @@
/* eslint-env jquery */
jQuery( document ).ready( function () {
jQuery( '#aiosrs-pro-license-form-btn' ).on( 'click', function ( e ) {
e.preventDefault();
jQuery( '#aiosrs-pro-license-form' ).show();
jQuery( 'body' ).addClass( 'aiosrs-pro-license-form-open' );
} );
jQuery( '#aiosrs-pro-license-form-close-btn' ).on( 'click', function ( e ) {
e.preventDefault();
jQuery( '#aiosrs-pro-license-form' ).hide();
jQuery( 'body' ).removeClass( 'aiosrs-pro-license-form-open' );
} );
jQuery( '#aiosrs-pro-license-form .aiosrs-pro-license-form-overlay' ).on(
'click',
function ( e ) {
e.preventDefault();
jQuery( '#aiosrs-pro-license-form' ).hide();
jQuery( 'body' ).removeClass( 'aiosrs-pro-license-form-open' );
}
);
} );

View File

@@ -0,0 +1,778 @@
/* eslint-env jquery */
(function ($) {
/**
* AIOSRS Schema
*
* @class AIOSRSSchema
* @since 1.0
*/
const AIOSRSSchema = {
/**
* Initializes a AIOSRS Schema.
*
* @since 1.0
* @function init
*/
container: '',
init() {
const self = this;
self.container = $(
'#aiosrs-schema-settings, #aiosrs-pro-custom-fields'
);
// Init backgrounds.
$(document).ready(function () {
$('.select2-class').select2();
const selectOption = ['Site Meta', 'Post Meta (Basic Fields)'];
const customOptionGroup = $('#bsf-aiosrs-schema-type').val();
if ('custom-markup' === customOptionGroup) {
for (let i = 0; i < selectOption.length; i++) {
$(
'#bsf-aiosrs-custom-markup-custom-markup optgroup[label="' +
selectOption[i] +
'"]'
).remove();
}
}
const customMarkupSchemId = $(
'#custom-schema-schema-field'
).val();
if (customMarkupSchemId) {
for (let i = 0; i < selectOption.length; i++) {
$(
'#custom-markup-' +
customMarkupSchemId +
'-custom-markup-connected optgroup[label="' +
selectOption[i] +
'"]'
).remove();
}
}
});
self.container.on(
'change',
'select.bsf-aiosrs-schema-meta-field',
function () {
const selfFun = $(this),
parent = selfFun.parent(),
value = selfFun.val();
const textwrapperCustom = parent.find(
'.bsf-aiosrs-schema-custom-text-wrap'
);
if ('custom-text' === value) {
textwrapperCustom.removeClass('bsf-hidden-field');
} else if (
!textwrapperCustom.hasClass('bsf-hidden-field')
) {
textwrapperCustom.addClass('bsf-hidden-field');
}
const textWrapperFixed = parent.find(
'.bsf-aiosrs-schema-fixed-text-wrap'
);
if ('fixed-text' === value) {
textWrapperFixed.removeClass('bsf-hidden-field');
} else if (!textWrapperFixed.hasClass('bsf-hidden-field')) {
textWrapperFixed.addClass('bsf-hidden-field');
}
const specificMetaWrapper = parent.find(
'.bsf-aiosrs-schema-specific-field-wrap'
);
if ('specific-field' === value) {
specificMetaWrapper.removeClass('bsf-hidden-field');
} else if (
!specificMetaWrapper.hasClass('bsf-hidden-field')
) {
specificMetaWrapper.addClass('bsf-hidden-field');
}
}
);
self.container.on(
'change',
'.bsf-aiosrs-schema-row-rating-type select.bsf-aiosrs-schema-meta-field',
function (e) {
e.preventDefault();
$(this)
.closest('.bsf-aiosrs-schema-table')
.find('.bsf-aiosrs-schema-row')
.css('display', '');
if ('accept-user-rating' === $(this).val()) {
const reviewCountWrap = $(this)
.closest('.bsf-aiosrs-schema-row')
.next('.bsf-aiosrs-schema-row'),
name = reviewCountWrap
.find('.bsf-aiosrs-schema-meta-field')
.attr('name');
const selectedSchemaType = jQuery(
'.bsf-aiosrs-review-schema-type'
).val();
if (selectedSchemaType) {
const prepareName =
'bsf-aiosrs-review[' +
selectedSchemaType +
'-review-count]';
if (name.indexOf(prepareName) >= 0) {
reviewCountWrap.hide();
}
}
if (name.indexOf('[review-count]') >= 0) {
reviewCountWrap.hide();
}
}
}
);
self.container
.find('select.bsf-aiosrs-schema-meta-field')
.trigger('change');
$('select.bsf-aiosrs-schema-select2').each(function (index, el) {
self.init_target_rule_select2(el);
});
self.container.on(
'click',
'.bsf-repeater-add-new-btn',
function (event) {
event.preventDefault();
self.add_new_repeater($(this));
self.prepare_event_schmea_fields();
}
);
self.container.on('click', '.bsf-repeater-close', function (event) {
event.preventDefault();
self.add_remove_repeater($(this));
});
self.schemaTypeDependency();
self.bindTooltip();
if (!$('body').hasClass('post-type-aiosrs-schema')) {
self.field_validation();
}
},
field_validation() {
$(
'.wpsp-custom-field-connect, .wpsp-field-close, .bsf-aiosrs-schema-meta-field, image-field-wrap, .aiosrs-pro-custom-field, .wpsp-custom-field-connect'
).on('click focus change', function () {
$('.bsf-aiosrs-schema-type-wrap').each(function (
index,
repeater
) {
let fieldValue = $(repeater)
.find('.wpsp-default-hidden-value')
.val();
const requiredPath = $(repeater)
.parents('.bsf-aiosrs-schema-row-content')
.prev();
if (undefined !== fieldValue) {
fieldValue = fieldValue.trim();
if (fieldValue) {
if ($('body').hasClass('block-editor-page')) {
if (
!$(repeater).find(
'.wpsp-required-error-field'
).length
) {
let metaField;
switch (fieldValue) {
case 'post_title':
metaField = $(
'.editor-post-title__input'
).val();
break;
case 'post_content':
metaField =
$(
'p.block-editor-rich-text__editable'
).text().length > 1
? $(
'p.block-editor-rich-text__editable'
).text()
: '';
break;
case 'post_excerpt':
metaField = $(
'.components-textarea-control__input'
).val();
break;
case 'featured_img':
if (
'Set featured image' ===
$(
'.editor-post-featured-image__toggle'
).text()
) {
metaField = '';
} else {
metaField = $(
'.components-responsive-wrapper__content'
).attr('src');
}
break;
default:
requiredPath.removeClass(
'wpsp-required-error-field'
);
requiredPath
.find('label')
.removeClass(
'wpsp-required-error-field'
);
}
if (undefined !== metaField) {
if ('' !== metaField) {
requiredPath.removeClass(
'wpsp-required-error-field'
);
requiredPath
.find('label')
.removeClass(
'wpsp-required-error-field'
);
} else if (
requiredPath.find('.required')
.length
) {
requiredPath
.find('label')
.addClass(
'wpsp-required-error-field'
);
}
}
} else {
requiredPath.removeClass(
'wpsp-required-error-field'
);
requiredPath
.find('label')
.removeClass(
'wpsp-required-error-field'
);
}
} else {
requiredPath.removeClass(
'wpsp-required-error-field'
);
requiredPath
.find('label')
.removeClass('wpsp-required-error-field');
}
} else if (requiredPath.find('.required').length) {
requiredPath
.find('label')
.addClass('wpsp-required-error-field');
}
}
});
});
},
hide_review_count() {
$(this)
.closest('.bsf-aiosrs-schema-table')
.find('.bsf-aiosrs-schema-row')
.css('display', '');
if ('accept-user-rating' === $(this).val()) {
const reviewCountWrap = $(this)
.closest('.bsf-aiosrs-schema-row')
.next('.bsf-aiosrs-schema-row'),
name = reviewCountWrap
.find('.bsf-aiosrs-schema-meta-field')
.attr('name');
const selectedSchemaType = jQuery(
'.bsf-aiosrs-review-schema-type'
).val();
if (selectedSchemaType) {
const prepareName =
'bsf-aiosrs-review[' +
selectedSchemaType +
'-review-count]';
if (name.indexOf(prepareName) >= 0) {
reviewCountWrap.hide();
}
}
if (name.indexOf('[review-count]') >= 0) {
reviewCountWrap.hide();
}
}
},
add_new_repeater(selector) {
const self = this,
parentWrap = selector.closest('.bsf-aiosrs-schema-type-wrap'),
totalCount = parentWrap.find('.aiosrs-pro-repeater-table-wrap')
.length,
template = parentWrap
.find('.aiosrs-pro-repeater-table-wrap')
.first()
.clone();
template
.find(
'.bsf-aiosrs-schema-custom-text-wrap, .bsf-aiosrs-schema-specific-field-wrap'
)
.each(function () {
if (!$(this).hasClass('bsf-hidden-field')) {
$(this).addClass('bsf-hidden-field');
}
});
template
.find('select.bsf-aiosrs-schema-meta-field')
.each(function () {
$(this).val('none');
const fieldName =
'undefined' !== typeof $(this).attr('name')
? $(this)
.attr('name')
.replace('[0]', '[' + totalCount + ']')
: '',
fieldClass =
'undefined' !== typeof $(this).attr('class')
? $(this)
.attr('class')
.replace('-0-', '-' + totalCount + '-')
: '',
fieldId =
'undefined' !== typeof $(this).attr('id')
? $(this)
.attr('id')
.replace('-0-', '-' + totalCount + '-')
: '';
$(this).attr('name', fieldName);
$(this).attr('class', fieldClass);
$(this).attr('id', fieldId);
});
template
.find(
'input, textarea, select:not(.bsf-aiosrs-schema-meta-field)'
)
.each(function () {
$(this).val('');
const fieldName =
'undefined' !== typeof $(this).attr('name')
? $(this)
.attr('name')
.replace('[0]', '[' + totalCount + ']')
: '',
fieldClass =
'undefined' !== typeof $(this).attr('class')
? $(this)
.attr('class')
.replace('-0-', '-' + totalCount + '-')
: '',
fieldId =
'undefined' !== typeof $(this).attr('id')
? $(this)
.attr('id')
.replace('-0-', '-' + totalCount + '-')
: '';
$(this).attr('name', fieldName);
$(this).attr('class', fieldClass);
$(this).attr('id', fieldId);
});
template.find('span.select2-container').each(function () {
$(this).remove();
});
template.insertBefore(selector);
template
.find('select.bsf-aiosrs-schema-select2')
.each(function (index, el) {
self.init_target_rule_select2(el);
});
AIOSRSSchema.init_date_time_fields();
},
add_remove_repeater(selector) {
const parentWrap = selector.closest('.bsf-aiosrs-schema-type-wrap'),
repeaterCount = parentWrap.find(
'> .aiosrs-pro-repeater-table-wrap'
).length;
if (repeaterCount > 1) {
selector.closest('.aiosrs-pro-repeater-table-wrap').remove();
if ('aiosrs-pro-custom-fields' === this.container.attr('id')) {
// Reset index to avoid duplicate names.
parentWrap
.find('> .aiosrs-pro-repeater-table-wrap')
.each(function (wrapIndex, repeaterWap) {
$(repeaterWap).each(function (
elementIndex,
element
) {
$(element)
.find(
'input, textarea, select:not(.bsf-aiosrs-schema-meta-field)'
)
.each(function (elIndex, el) {
const fieldName =
'undefined' !==
typeof $(el).attr('name')
? $(el)
.attr('name')
.replace(
/\[\d+]/,
'[' +
wrapIndex +
']'
)
: '';
$(el).attr('name', fieldName);
});
});
});
}
}
},
bindTooltip() {
// Call Tooltip
$('.bsf-aiosrs-schema-heading-help').tooltip({
content() {
return $(this).prop('title');
},
tooltipClass: 'bsf-aiosrs-schema-ui-tooltip',
position: {
my: 'center top',
at: 'center bottom+10',
},
hide: {
duration: 200,
},
show: {
duration: 200,
},
});
},
schemaTypeDependency() {
const container = this.container;
this.container.on(
'change',
'select[name="bsf-aiosrs-schema-type"]',
function () {
container
.find('.bsf-aiosrs-schema-meta-wrap')
.css('display', 'none');
const schemaType = $(this).val();
if (
'undefined' !== typeof schemaType &&
'' !== schemaType
) {
container
.find('#bsf-' + schemaType + '-schema-meta-wrap')
.css('display', '');
}
}
);
},
init_target_rule_select2(selector) {
$(selector).select2({
placeholder: 'Search Fields...',
ajax: {
url: ajaxurl,
dataType: 'json',
method: 'post',
delay: 250,
data(params) {
return {
nonce_ajax: AIOSRS_Rating.specified_field,
q: params.term, // search term
page: params.page,
action: 'bsf_get_specific_meta_fields',
};
},
processResults(data) {
return {
results: data,
};
},
cache: true,
},
minimumInputLength: 2,
});
},
get_review_item_type_html(itemType) {
jQuery
.post({
url: ajaxurl,
data: {
action: 'fetch_item_type_html',
itemType,
nonce: AIOSRS_Rating.security,
post_id: jQuery('#post_ID').val(),
},
})
.done(function (response) {
$('.bsf-review-item-type-field').remove();
$(response).insertAfter(
jQuery('#bsf-aiosrs-review-schema-type')
.parent()
.parent()
.closest('tr')
);
$('select.bsf-aiosrs-schema-select2').each(function (
index,
el
) {
AIOSRSSchema.init_target_rule_select2(el);
});
const itemSpecificType =
'.bsf-aiosrs-review-' + itemType + '-rating';
$(itemSpecificType).each(function () {
$(this)
.closest('.bsf-aiosrs-schema-table')
.find('.bsf-aiosrs-schema-row')
.css('display', '');
if ('accept-user-rating' === $(this).val()) {
const reviewCountWrap = $(this)
.closest('.bsf-aiosrs-schema-row')
.next('.bsf-aiosrs-schema-row'),
name = reviewCountWrap
.find('.bsf-aiosrs-schema-meta-field')
.attr('name');
const selectedSchemaType = jQuery(
'.bsf-aiosrs-review-schema-type'
).val();
if (selectedSchemaType) {
const prepareName =
'bsf-aiosrs-review[' +
selectedSchemaType +
'-review-count]';
if (name.indexOf(prepareName) >= 0) {
reviewCountWrap.hide();
}
}
if (name.indexOf('[review-count]') >= 0) {
reviewCountWrap.hide();
}
}
});
AIOSRSSchema.init_date_time_fields();
AIOSRSSchema.prepare_event_schmea_fields();
})
.fail(function () { });
},
prepare_event_schmea_fields() {
$(
'.wpsp-dropdown-event-status, .wpsp-dropdown-bsf-aiosrs-event-event-status'
).change(function () {
const parent = $(this).parents(
'.bsf-aiosrs-schema-meta-wrap, .aiosrs-pro-meta-fields-wrap'
);
parent
.find(
'td.wpsp-event-status-rescheduled, td.bsf-aiosrs-review-bsf-aiosrs-event-previous-date'
)
.hide();
if (!this.value) {
this.value = 'EventScheduled';
}
if ('EventRescheduled' === this.value) {
parent
.find(
'td.wpsp-event-status-rescheduled, td.bsf-aiosrs-review-bsf-aiosrs-event-previous-date'
)
.show();
}
const eventStatus = $(
'.wpsp-dropdown-event-attendance-mode, .wpsp-dropdown-bsf-aiosrs-event-event-attendance-mode'
).val();
if (
'EventMovedOnline' === this.value ||
'OfflineEventAttendanceMode' !== eventStatus
) {
parent.find('td.wpsp-event-status-offline').hide();
parent.find('td.wpsp-event-status-online').show();
parent
.find(
'.wpsp-dropdown-event-attendance-mode, .wpsp-dropdown-bsf-aiosrs-event-event-attendance-mode'
)
.val('OnlineEventAttendanceMode');
} else {
parent.find('td.wpsp-event-status-offline').show();
parent.find('td.wpsp-event-status-online').hide();
}
});
$(
'.wpsp-dropdown-event-attendance-mode, .wpsp-dropdown-bsf-aiosrs-event-event-attendance-mode'
).change(function () {
const parent = $(this).parents(
'.bsf-aiosrs-schema-meta-wrap, .aiosrs-pro-meta-fields-wrap'
);
parent.find('td.wpsp-event-status-rescheduled').hide();
const eventStatus = $(
'.wpsp-dropdown-event-status, .wpsp-dropdown-bsf-aiosrs-event-event-status'
).val();
if ('EventMovedOnline' !== eventStatus) {
parent.find('td.wpsp-event-status-offline').show();
parent.find('td.wpsp-event-status-online').hide();
}
if ('OfflineEventAttendanceMode' !== this.value) {
parent.find('td.wpsp-event-status-offline').hide();
parent.find('td.wpsp-event-status-online').show();
}
if ('MixedEventAttendanceMode' === this.value) {
parent.find('td.wpsp-event-status-offline').show();
parent.find('td.wpsp-event-status-online').show();
}
});
$(
'.wpsp-dropdown-event-attendance-mode, .wpsp-dropdown-bsf-aiosrs-event-event-attendance-mode'
).trigger('change');
},
init_date_time_fields() {
$(
'.wpsp-datetime-local-field, .wpsp-date-field, .wpsp-time-duration-field'
).each(function () {
$(this).removeClass('hasDatepicker');
});
const startDateSelectors =
'.wpsp-date-published-date, .wpsp-datetime-local-event-start-date, .wpsp-date-start-date, .wpsp-datetime-local-start-date';
const endDateSelectors =
'.wpsp-date-modified-date, .wpsp-datetime-local-event-end-date, .wpsp-date-end-date, .wpsp-datetime-local-end-date';
$(document).on('focus', '.wpsp-time-duration-field', function () {
$(this).timepicker({
timeFormat: 'HH:mm:ss',
hourMin: 0,
hourMax: 99,
oneLine: true,
currentText: 'Clear',
onSelect() {
updateTimeFormat(this);
},
});
});
$(document).on(
'focus',
'.wpsp-datetime-local-field, .wpsp-date-field',
function () {
$(this).datetimepicker({
dateFormat: 'yy-mm-dd',
timeFormat: 'hh:mm TT',
changeMonth: true,
changeYear: true,
showOn: 'focus',
showButtonPanel: true,
closeText: 'Done',
currentText: 'Clear',
yearRange: '-100:+10', // last hundred year
onClose(dateText, inst) {
const thisEle = '#' + inst.id;
if (jQuery(thisEle).is(startDateSelectors)) {
$(endDateSelectors).datetimepicker(
'option',
'minDate',
new Date(dateText)
);
} else if (jQuery(thisEle).is(endDateSelectors)) {
$(startDateSelectors).datetimepicker(
'option',
'maxDate',
new Date(dateText)
);
}
jQuery(thisEle)
.parents('.wpsp-local-fields')
.find('.wpsp-default-hidden-value')
.val(dateText);
},
});
}
);
$.datepicker._gotoToday = function (id) {
$(id).datepicker('setDate', '').datepicker('hide').blur();
};
function updateTimeFormat(thisEle) {
const durationWrap = $(thisEle).closest(
'.aiosrs-pro-custom-field-time-duration'
);
const inputField = durationWrap.find('.time-duration-field');
let value = $(thisEle).val();
value = value.replace(/:/, 'H');
value = value.replace(/:/, 'M');
value = 'PT' + value + 'S';
inputField.val(value);
// Post/pages related support.
const parent = $(thisEle).parents('.wpsp-local-fields');
parent.find('.wpsp-default-hidden-value').val(value);
}
},
};
/* Initializes the AIOSRS Schema. */
$(function () {
AIOSRSSchema.init();
if (!$('body').hasClass('aiosrs-pro-setup')) {
AIOSRSSchema.init_date_time_fields();
}
});
$(document).ready(function () {
let parent = $('.aiosrs-pro-meta-fields-wrap');
parent.each(function (index, value) {
let labelMarkup = $(value).find('.wpsp-field-label');
let label = labelMarkup.text();
if ('Image License' === label.trim()) {
labelMarkup.attr('style', 'width:6%');
}
});
$('#bsf-aiosrs-review-schema-type').change(function () {
const itemVal = $(this).val().trim();
if (!itemVal) {
$('.bsf-review-item-type-field').remove();
return;
}
AIOSRSSchema.get_review_item_type_html(itemVal);
});
$('#bsf-aiosrs-review-schema-type').change();
AIOSRSSchema.prepare_event_schmea_fields();
});
})(jQuery);

View File

@@ -0,0 +1,415 @@
/* eslint-env jquery */
(function ($) {
const { __ } = wp.i18n;
const temp = {
person: __('Website Owner Name'),
organization: __('Organization Name', 'wp-schema-pro'),
Webshop: __('Webshop Name', 'wp-schema-pro'),
personblog: __('Website Owner Name', 'wp-schema-pro'),
Smallbusiness: __('Blog Website Name', 'wp-schema-pro'),
Otherbusiness: __('Business Name', 'wp-schema-pro'),
};
/**
* AIOSRS Frontend
*
* @class WPSchemaProSettings
* @since 1.0
*/
const WPSchemaProSettings = {
init() {
const self = this;
this.customFieldDependecy();
this.customImageSelect();
this.initRepeater();
this.toolTips();
this.regenerateSchema();
$('select.wp-select2').each(function (index, el) {
self.init_target_rule_select2(el);
});
},
regenerateSchema() {
$('#wpsp-regenerate-schema').click(function () {
$(this).next('span.spinner').addClass('is-active');
jQuery
.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: {
action: 'regenerate_schema',
nonce: $(this).data('nonce'),
},
})
.success(function () {
$('#wpsp-regenerate-schema')
.next('span.spinner')
.removeClass('is-active');
$('#wpsp-regenerate-notice')
.show()
.delay(2000)
.fadeOut();
});
});
},
toolTips() {
$(document).on(
'click',
'.wp-schema-pro-tooltip-icon',
function (e) {
e.preventDefault();
$('.wp-schema-pro-tooltip-wrapper').removeClass('activate');
$(this).parent().addClass('activate');
}
);
$(document).on('click', function (e) {
if (
!$(e.target).hasClass(
'wp-schema-pro-tooltip-description'
) &&
!$(e.target).hasClass('wp-schema-pro-tooltip-icon') &&
$(e.target).closest('.wp-schema-pro-tooltip-description')
.length === 0
) {
$('.wp-schema-pro-tooltip-wrapper').removeClass('activate');
}
});
},
customImageSelect() {
let fileFrame;
window.inputWrapper = '';
$(document.body).on(
'click',
'.image-field-wrap .aiosrs-image-select',
function (e) {
e.preventDefault();
window.inputWrapper = $(this).closest('td');
// Create the media frame.
fileFrame = wp.media({
button: {
text: 'Select Image',
close: false,
},
states: [
new wp.media.controller.Library({
title: 'Select Custom Image',
library: wp.media.query({ type: 'image' }),
multiple: false,
}),
],
});
// When an image is selected, run a callback.
fileFrame.on('select', function () {
const attachment = fileFrame
.state()
.get('selection')
.first()
.toJSON();
const image = window.inputWrapper.find(
'.image-field-wrap img'
);
if (image.length === 0) {
window.inputWrapper
.find('.image-field-wrap')
.append(
'<a href="#" class="aiosrs-image-select img"><img src="' +
attachment.url +
'" /></a>'
);
} else {
image.attr('src', attachment.url);
}
window.inputWrapper
.find('.image-field-wrap')
.addClass('bsf-custom-image-selected');
window.inputWrapper
.find('.single-image-field')
.val(attachment.id);
fileFrame.close();
});
fileFrame.open();
}
);
$(document).on('click', '.aiosrs-image-remove', function (e) {
e.preventDefault();
const parent = $(this).closest('td');
parent
.find('.image-field-wrap')
.removeClass('bsf-custom-image-selected');
parent.find('.single-image-field').val('');
parent.find('.image-field-wrap img').removeAttr('src');
});
window.inputWrapper = '';
},
customFieldDependecy() {
jQuery(document).on(
'change',
'#post-body-content .wp-schema-pro-custom-option-select, .aiosrs-pro-setup-wizard-content.general-setting-content-wrap .wp-schema-pro-custom-option-select',
function () {
const customWrap = jQuery(this).next(
'.custom-field-wrapper'
);
customWrap.css('display', 'none');
if ('custom' === jQuery(this).val()) {
customWrap.css('display', '');
}
}
);
jQuery(document).on(
'change',
'select[name="wp-schema-pro-general-settings[site-represent]"]',
function () {
const wrapper = jQuery(this).closest('table'),
logoWrap = wrapper.find(
'.wp-schema-pro-site-logo-wrap'
),
companyNameWrap = wrapper.find(
'.wp-schema-pro-site-name-wrap'
),
personNameWrap = wrapper.find(
'.wp-schema-pro-person-name-wrap'
);
companyNameWrap.css('display', 'none');
personNameWrap.css('display', 'none');
if ('' !== jQuery(this).val()) {
if (
'organization' === jQuery(this).val() ||
'Webshop' === jQuery(this).val() ||
'Smallbusiness' === jQuery(this).val() ||
'Otherbusiness' === jQuery(this).val()
) {
logoWrap.css('display', '');
companyNameWrap.css('display', '');
} else {
personNameWrap.css('display', '');
logoWrap.css('display', '');
}
}
}
);
jQuery(document).on(
'change',
'select[name="wp-schema-pro-general-settings[site-represent]"]',
function () {
const organizationType = jQuery(this).val();
if ('' !== jQuery(this).val()) {
if (organizationType in temp) {
$('.wpsp-organization-label').text(
temp[organizationType]
);
}
}
}
);
jQuery(document).on(
'change',
'select[name="wp-schema-pro-corporate-contact[contact-type]"]',
function () {
const wrapper = jQuery(this).closest('table'),
contactPointWrap = wrapper.find(
'.wp-schema-pro-other-wrap'
);
contactPointWrap.css('display', 'none');
if ('' !== jQuery(this).val()) {
if ('other' === jQuery(this).val()) {
contactPointWrap.css('display', '');
}
}
}
);
$('#add-row').on('click', function () {
const row = $('.empty-row.screen-reader-text').clone(true);
row.removeClass('empty-row screen-reader-text');
row.insertBefore('#repeatable-fieldset-one >tr:last');
return false;
});
$('.remove-row').on('click', function () {
$(this).parents('tr').remove();
return false;
});
},
initRepeater() {
$(document).on(
'click',
'.bsf-repeater-add-new-btn',
function (event) {
event.preventDefault();
const selector = $(this),
parentWrap = selector.closest(
'.bsf-aiosrs-schema-type-wrap'
),
totalCount = parentWrap.find(
'.aiosrs-pro-repeater-table-wrap'
).length,
template = parentWrap
.find('.aiosrs-pro-repeater-table-wrap')
.first()
.clone();
template.find('input, textarea, select').each(function () {
$(this).val('');
const fieldName =
'undefined' !== typeof $(this).attr('name')
? $(this)
.attr('name')
.replace(
'[0]',
'[' + totalCount + ']'
)
: '',
fieldClass =
'undefined' !== typeof $(this).attr('class')
? $(this)
.attr('class')
.replace(
'-0-',
'-' + totalCount + '-'
)
: '',
fieldId =
'undefined' !== typeof $(this).attr('id')
? $(this)
.attr('id')
.replace(
'-0-',
'-' + totalCount + '-'
)
: '';
$(this).attr('name', fieldName);
$(this).attr('class', fieldClass);
$(this).attr('id', fieldId);
});
template.insertBefore(selector);
}
);
$(document).on('click', '.bsf-repeater-close', function (event) {
event.preventDefault();
const selector = $(this),
parentWrap = selector.closest(
'.bsf-aiosrs-schema-type-wrap'
),
repeaterCount = parentWrap.find(
'> .aiosrs-pro-repeater-table-wrap'
).length;
if (repeaterCount > 1) {
selector
.closest('.aiosrs-pro-repeater-table-wrap')
.remove();
}
});
},
init_target_rule_select2(selector) {
$(selector).select2({
placeholder: 'Search Fields...',
ajax: {
url: ajaxurl,
dataType: 'json',
method: 'post',
delay: 250,
data(params) {
return {
nonce_ajax: AIOSRS_search.search_field,
q: params.term, // search term
page: params.page,
action: 'bsf_get_specific_pages',
};
},
processResults(data) {
return {
results: data,
};
},
cache: true,
},
minimumInputLength: 2,
});
},
};
const loadDefaultValues = function () {
const field = jQuery(
'select[name="wp-schema-pro-general-settings[site-represent]"]'
),
wrapper = field.closest('table'),
logoWrap = wrapper.find('.wp-schema-pro-site-logo-wrap'),
companyNameWrap = wrapper.find('.wp-schema-pro-site-name-wrap'),
personNameWrap = wrapper.find('.wp-schema-pro-person-name-wrap');
companyNameWrap.css('display', 'none');
personNameWrap.css('display', 'none');
if ('' !== field.val()) {
if (
'organization' === field.val() ||
'Webshop' === field.val() ||
'Smallbusiness' === field.val() ||
'Otherbusiness' === field.val()
) {
logoWrap.css('display', '');
companyNameWrap.css('display', '');
} else {
personNameWrap.css('display', '');
logoWrap.css('display', '');
}
}
};
const loadDefaultOrganizationLabel = function () {
const field = jQuery(
'select[name="wp-schema-pro-general-settings[site-represent]"]'
),
organizationType = field.val();
if ('' !== field) {
if (organizationType in temp) {
$('.wpsp-organization-label').text(temp[organizationType]);
}
}
};
$(document).ready(function () {
$('.wp-select2').select2();
$('.wpsp-setup-configuration-settings').select2();
loadDefaultValues();
loadDefaultOrganizationLabel();
$('#add-row').on('click', function () {
const row = $('.empty-row.screen-reader-text').clone(true);
row.removeClass('empty-row screen-reader-text');
row.insertBefore('#repeatable-fieldset-one tbody>tr:last');
return false;
});
$('.remove-row').on('click', function () {
$(this).parents('tr').remove();
return false;
});
});
/* Initializes the AIOSRS Frontend. */
$(function () {
WPSchemaProSettings.init();
});
})(jQuery);

View File

@@ -0,0 +1,32 @@
/* eslint-env jquery */
/**
* File setup-wizard.js
*
* Handles Color Picker
*
* @package
*/
( function ( $ ) {
jQuery( document ).ready( function () {
$( document ).on(
'click',
'.aiosrs-pro-schema-temp-wrap',
function ( e ) {
e.preventDefault();
$( '.aiosrs-pro-schema-temp-wrap' ).removeClass( 'selected' );
$( '.aiosrs-pro-setup-actions' )
.find( '.button-next' )
.removeAttr( 'disabled' );
$( this ).addClass( 'selected' );
const type = $( this ).data( 'schema-type' ),
title = $( this ).data( 'schema-title' );
$( document ).find( '.bsf-aiosrs-schema-type' ).val( type );
$( document ).find( '.bsf-aiosrs-schema-title' ).val( title );
}
);
} );
} )( jQuery );

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
.aiosrs-rating-wrap .aiosrs-star-rating-wrap{display:inline-block;vertical-align:middle}.aiosrs-rating-wrap .aiosrs-star-rating-wrap~.aiosrs-star-rating-wrap{float:right}.aiosrs-rating-wrap .aiosrs-star-rating-wrap .aiosrs-star-rating{color:gold}.aiosrs-rating-wrap .aiosrs-star-rating-wrap:not(.disabled) .aiosrs-star-rating{cursor:pointer}.aiosrs-rating-wrap .success-msg{color:#0f0;margin-left:5px}

View File

@@ -0,0 +1 @@
body.aiosrs-pro-license-form-open{overflow:hidden}#aiosrs-pro-license-form p{padding:5px 0}#aiosrs-pro-license-form .aiosrs-pro-license-form-overlay{background:#000;opacity:.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}#aiosrs-pro-license-form .aiosrs-pro-license-form-inner{background:#fff;position:fixed;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,.3);box-shadow:0 3px 6px rgba(0,0,0,.3)}#aiosrs-pro-license-form-close-btn{position:absolute;left:auto;right:0;top:0;width:29px;height:29px;border:0;padding:0;background:0 0;cursor:pointer;outline:0;-webkit-transition:color .1s ease-in-out,background .1s ease-in-out;-webkit-transform:translateX(100%);transform:translateX(100%);transition:color .1s ease-in-out,background .1s ease-in-out;color:#eee}#aiosrs-pro-license-form-close-btn:hover{color:#00a0d2}#aiosrs-pro-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}#aiosrs-pro-license-form .license-form-field input.regular-text{margin-right:10px}.bsf-current-license-error-wp-schema-pro,.bsf-current-license-success-wp-schema-pro{display:block;margin-bottom:.5em}.bsf-current-license-error-wp-schema-pro{color:#f44336}.bsf-current-license-success-wp-schema-pro{color:green}#aiosrs-pro-license-form-btn.active{color:#3db634}#aiosrs-pro-license-form-btn.inactive{color:#f44336}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
!function(r){const s={container:"",init(){const a=this;jQuery(document).on("click",".aiosrs-rating-wrap .aiosrs-star-rating",function(s){s.preventDefault(),a.star_rating(this)}),jQuery(document).on("mouseover",".aiosrs-rating-wrap .aiosrs-star-rating",function(s){s.preventDefault(),a.hover_star_rating(this)}),jQuery(document).on("mouseout",".aiosrs-rating-wrap .aiosrs-star-rating-wrap",function(s){s.preventDefault(),r(this).hasClass("disabled")||(s=r(this).parent().find(".aiosrs-rating").text(),a.update_stars(r(this),s))})},hover_star_rating(s){const a=r(s).closest(".aiosrs-star-rating-wrap"),t=r(s).data("index");a.hasClass("disabled")||this.update_stars(a,t)},update_stars(s,a){let t=5<a?5:parseInt(a);t=5<a?5:a<0?0:parseInt(a);const n=a===t||5<a||a<0?0:1;s.find("span").each(function(s){r(this).removeClass("dashicons-star-filled dashicons-star-half dashicons-star-empty"),s<t?r(this).addClass("dashicons-star-filled"):(s===t&&n,r(this).addClass("dashicons-star-empty"))})},star_rating(s){const i=this,a=r(s).closest(".aiosrs-rating-wrap").data("schema-id"),e=r(s).closest(".aiosrs-star-rating-wrap"),t=r(s).data("index");e.hasClass("disabled")||(i.update_stars(e,t),e.addClass("disabled"),r.ajax({url:AIOSRS_Frontend.ajaxurl,type:"POST",data:{action:"aiosrs_user_rating",rating:t,schemaId:a,post_id:AIOSRS_Frontend.post_id,nonce:AIOSRS_Frontend.user_rating_nonce}}).success(function(s){if(!0===s.success){const a=e.next(".aiosrs-rating-summary-wrap"),t=s.rating,n=s["rating-avg"],r=s["review-count"];a.find(".aiosrs-rating").text(n),a.find(".aiosrs-rating-count").text(r),0===e.next(".success-msg").length&&e.after('<span class="success-msg">'+AIOSRS_Frontend.success_msg+"</span>"),setTimeout(function(){e.parent().find(".success-msg").remove(),e.removeClass("disabled")},5e3),i.update_stars(e,t)}}))}};r(function(){s.init()})}(jQuery);

View File

@@ -0,0 +1 @@
jQuery(document).ready(function(){jQuery("#aiosrs-pro-license-form-btn").on("click",function(e){e.preventDefault(),jQuery("#aiosrs-pro-license-form").show(),jQuery("body").addClass("aiosrs-pro-license-form-open")}),jQuery("#aiosrs-pro-license-form-close-btn").on("click",function(e){e.preventDefault(),jQuery("#aiosrs-pro-license-form").hide(),jQuery("body").removeClass("aiosrs-pro-license-form-open")}),jQuery("#aiosrs-pro-license-form .aiosrs-pro-license-form-overlay").on("click",function(e){e.preventDefault(),jQuery("#aiosrs-pro-license-form").hide(),jQuery("body").removeClass("aiosrs-pro-license-form-open")})});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
!function(s){jQuery(document).ready(function(){s(document).on("click",".aiosrs-pro-schema-temp-wrap",function(e){e.preventDefault(),s(".aiosrs-pro-schema-temp-wrap").removeClass("selected"),s(".aiosrs-pro-setup-actions").find(".button-next").removeAttr("disabled"),s(this).addClass("selected");var t=s(this).data("schema-type"),e=s(this).data("schema-title");s(document).find(".bsf-aiosrs-schema-type").val(t),s(document).find(".bsf-aiosrs-schema-title").val(e)})})}(jQuery);

View File

@@ -0,0 +1 @@
[ID*="-optin-notice"]{padding:1px 12px;border-right-color:#007cba}[ID*="-optin-notice"] .notice-container{padding-top:10px;padding-bottom:12px}[ID*="-optin-notice"] .notice-content{margin:0}[ID*="-optin-notice"] .notice-heading{padding:0 0 12px 20px}[ID*="-optin-notice"] .button-primary{margin-left:5px}

View File

@@ -0,0 +1 @@
[ID*="-optin-notice"]{padding:1px 12px;border-left-color:#007cba}[ID*="-optin-notice"] .notice-container{padding-top:10px;padding-bottom:12px}[ID*="-optin-notice"] .notice-content{margin:0}[ID*="-optin-notice"] .notice-heading{padding:0 20px 12px 0}[ID*="-optin-notice"] .button-primary{margin-right:5px}

View File

@@ -0,0 +1,21 @@
[ID*="-optin-notice"] {
padding: 1px 12px;
border-right-color: #007cba;
}
[ID*="-optin-notice"] .notice-container {
padding-top: 10px;
padding-bottom: 12px;
}
[ID*="-optin-notice"] .notice-content {
margin: 0;
}
[ID*="-optin-notice"] .notice-heading {
padding: 0 0 12px 20px;
}
[ID*="-optin-notice"] .button-primary {
margin-left: 5px;
}

View File

@@ -0,0 +1,21 @@
[ID*="-optin-notice"] {
padding: 1px 12px;
border-left-color: #007cba;
}
[ID*="-optin-notice"] .notice-container {
padding-top: 10px;
padding-bottom: 12px;
}
[ID*="-optin-notice"] .notice-content {
margin: 0;
}
[ID*="-optin-notice"] .notice-heading {
padding: 0 20px 12px 0;
}
[ID*="-optin-notice"] .button-primary {
margin-right: 5px;
}

View File

@@ -0,0 +1,118 @@
<?php
/**
* BSF analytics loader file.
*
* @version 1.0.0
*
* @package bsf-analytics
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
/**
* Class BSF_Analytics_Loader.
*/
class BSF_Analytics_Loader {
/**
* Analytics Entities.
*
* @access private
* @var array Entities array.
*/
private $entities = array();
/**
* Analytics Version.
*
* @access private
* @var float analytics version.
*/
private $analytics_version = '';
/**
* Analytics path.
*
* @access private
* @var string path array.
*/
private $analytics_path = '';
/**
* Instance
*
* @access private
* @var object Class object.
*/
private static $instance = null;
/**
* Get instace of class.
*
* @return object
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
add_action( 'init', array( $this, 'load_analytics' ) );
}
/**
* Set entity for analytics.
*
* @param string $data Entity attributes data.
* @return void
*/
public function set_entity( $data ) {
array_push( $this->entities, $data );
}
/**
* Load Analytics library.
*
* @return void
*/
public function load_analytics() {
$unique_entities = array();
if ( ! empty( $this->entities ) ) {
foreach ( $this->entities as $entity ) {
foreach ( $entity as $key => $data ) {
if ( isset( $data['path'] ) ) {
if ( file_exists( $data['path'] . '/version.json' ) ) {
$file_contents = file_get_contents( $data['path'] . '/version.json' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
$analytics_version = json_decode( $file_contents, 1 );
$analytics_version = $analytics_version['bsf-analytics-ver'];
if ( version_compare( $analytics_version, $this->analytics_version, '>' ) ) {
$this->analytics_version = $analytics_version;
$this->analytics_path = $data['path'];
}
}
}
if ( ! isset( $unique_entities[ $key ] ) ) {
$unique_entities[ $key ] = $data;
}
}
}
if ( file_exists( $this->analytics_path ) && ! class_exists( 'BSF_Analytics' ) ) {
require_once $this->analytics_path . '/class-bsf-analytics.php';
new BSF_Analytics( $unique_entities, $this->analytics_path, $this->analytics_version );
}
}
}
}

View File

@@ -0,0 +1,258 @@
<?php
/**
* BSF analytics stat class file.
*
* @package bsf-analytics
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'BSF_Analytics_Stats' ) ) {
/**
* BSF analytics stat class.
*/
class BSF_Analytics_Stats {
/**
* Active plugins.
*
* Holds the sites active plugins list.
*
* @var array
*/
private $plugins;
/**
* Instance of BSF_Analytics_Stats.
*
* Holds only the first object of class.
*
* @var object
*/
private static $instance = null;
/**
* Create only once instance of a class.
*
* @return object
* @since 1.0.0
*/
public static function instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Get stats.
*
* @return array stats data.
* @since 1.0.0
*/
public function get_stats() {
return apply_filters( 'bsf_core_stats', $this->get_default_stats() );
}
/**
* Retrieve stats for site.
*
* @return array stats data.
* @since 1.0.0
*/
private function get_default_stats() {
return array(
'graupi_version' => defined( 'BSF_UPDATER_VERSION' ) ? BSF_UPDATER_VERSION : false,
'domain_name' => get_site_url(),
'php_os' => PHP_OS,
'server_software' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? filter_var( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ), FILTER_SANITIZE_STRING ) : '',
'mysql_version' => $this->get_mysql_version(),
'php_version' => $this->get_php_version(),
'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' ),
'zip_installed' => extension_loaded( 'zip' ),
'imagick_availabile' => extension_loaded( 'imagick' ),
'xmlreader_exists' => class_exists( 'XMLReader' ),
'gd_available' => extension_loaded( 'gd' ),
'curl_version' => $this->get_curl_version(),
'curl_ssl_version' => $this->get_curl_ssl_version(),
'is_writable' => $this->is_content_writable(),
'wp_version' => get_bloginfo( 'version' ),
'user_count' => $this->get_user_count(),
'posts_count' => wp_count_posts()->publish,
'page_count' => wp_count_posts( 'page' )->publish,
'site_language' => get_locale(),
'timezone' => wp_timezone_string(),
'is_ssl' => is_ssl(),
'is_multisite' => is_multisite(),
'network_url' => network_site_url(),
'external_object_cache' => (bool) wp_using_ext_object_cache(),
'wp_debug' => WP_DEBUG,
'wp_debug_display' => WP_DEBUG_DISPLAY,
'script_debug' => SCRIPT_DEBUG,
'active_plugins' => $this->get_active_plugins(),
'active_theme' => get_template(),
'active_stylesheet' => get_stylesheet(),
);
}
/**
* Get installed PHP version.
*
* @return float PHP version.
* @since 1.0.0
*/
private function 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();
}
/**
* User count on site.
*
* @return int User count.
* @since 1.0.0
*/
private function get_user_count() {
if ( is_multisite() ) {
$user_count = get_user_count();
} else {
$count = count_users();
$user_count = $count['total_users'];
}
return $user_count;
}
/**
* Get active plugin's data.
*
* @return array active plugin's list.
* @since 1.0.0
*/
private function get_active_plugins() {
if ( ! $this->plugins ) {
// Ensure get_plugin_data function is loaded.
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = wp_get_active_and_valid_plugins();
$plugins = array_map( 'get_plugin_data', $plugins );
$this->plugins = array_map( array( $this, 'format_plugin' ), $plugins );
}
return $this->plugins;
}
/**
* Format plugin data.
*
* @param string $plugin plugin.
* @return array formatted plugin data.
* @since 1.0.0
*/
public function format_plugin( $plugin ) {
return array(
'name' => html_entity_decode( $plugin['Name'], ENT_COMPAT, 'UTF-8' ),
'url' => $plugin['PluginURI'],
'version' => $plugin['Version'],
'slug' => $plugin['TextDomain'],
'author_name' => html_entity_decode( wp_strip_all_tags( $plugin['Author'] ), ENT_COMPAT, 'UTF-8' ),
'author_url' => $plugin['AuthorURI'],
);
}
/**
* Curl SSL version.
*
* @return float SSL version.
* @since 1.0.0
*/
private function get_curl_ssl_version() {
$curl = array();
if ( function_exists( 'curl_version' ) ) {
$curl = curl_version(); // phpcs:ignore WordPress.WP.AlternativeFunctions.curl_curl_version
}
return isset( $curl['ssl_version'] ) ? $curl['ssl_version'] : false;
}
/**
* Get cURL version.
*
* @return float cURL version.
* @since 1.0.0
*/
private function get_curl_version() {
if ( function_exists( 'curl_version' ) ) {
$curl = curl_version(); // phpcs:ignore WordPress.WP.AlternativeFunctions.curl_curl_version
}
return isset( $curl['version'] ) ? $curl['version'] : false;
}
/**
* Get MySQL version.
*
* @return float MySQL version.
* @since 1.0.0
*/
private function get_mysql_version() {
global $wpdb;
return $wpdb->db_version();
}
/**
* Check if content directory is writable.
*
* @return bool
* @since 1.0.0
*/
private function is_content_writable() {
$upload_dir = wp_upload_dir();
return wp_is_writable( $upload_dir['basedir'] );
}
}
}
/**
* Polyfill for sites using WP version less than 5.3
*/
if ( ! function_exists( 'wp_timezone_string' ) ) {
/**
* Get timezone string.
*
* @return string timezone string.
* @since 1.0.0
*/
function wp_timezone_string() {
$timezone_string = get_option( 'timezone_string' );
if ( $timezone_string ) {
return $timezone_string;
}
$offset = (float) get_option( 'gmt_offset' );
$hours = (int) $offset;
$minutes = ( $offset - $hours );
$sign = ( $offset < 0 ) ? '-' : '+';
$abs_hour = abs( $hours );
$abs_mins = abs( $minutes * 60 );
$tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins );
return $tz_offset;
}
}

View File

@@ -0,0 +1,514 @@
<?php
/**
* BSF analytics class file.
*
* @version 1.0.0
*
* @package bsf-analytics
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'BSF_Analytics' ) ) {
/**
* BSF analytics
*/
class BSF_Analytics {
/**
* Member Variable
*
* @var array Entities data.
*/
private $entities;
/**
* Member Variable
*
* @var string Usage tracking document URL
*/
public $usage_doc_link = 'https://store.brainstormforce.com/usage-tracking/?utm_source=wp_dashboard&utm_medium=general_settings&utm_campaign=usage_tracking';
/**
* Setup actions, load files.
*
* @param array $args entity data for analytics.
* @param string $analytics_path directory path to analytics library.
* @param float $analytics_version analytics library version.
* @since 1.0.0
*/
public function __construct( $args, $analytics_path, $analytics_version ) {
// Bail when no analytics entities are registered.
if ( empty( $args ) ) {
return;
}
$this->entities = $args;
define( 'BSF_ANALYTICS_VERSION', $analytics_version );
define( 'BSF_ANALYTICS_URI', $this->get_analytics_url( $analytics_path ) );
add_action( 'admin_init', array( $this, 'handle_optin_optout' ) );
add_action( 'admin_init', array( $this, 'option_notice' ) );
add_action( 'init', array( $this, 'maybe_track_analytics' ), 99 );
$this->set_actions();
add_action( 'admin_init', array( $this, 'register_usage_tracking_setting' ) );
$this->includes();
}
/**
* Setup actions for admin notice style and analytics cron event.
*
* @since 1.0.4
*/
public function set_actions() {
foreach ( $this->entities as $key => $data ) {
add_action( 'astra_notice_before_markup_' . $key . '-optin-notice', array( $this, 'enqueue_assets' ) );
add_action( 'update_option_' . $key . '_analytics_optin', array( $this, 'update_analytics_option_callback' ), 10, 3 );
add_action( 'add_option_' . $key . '_analytics_optin', array( $this, 'add_analytics_option_callback' ), 10, 2 );
}
}
/**
* BSF Analytics URL
*
* @param string $analytics_path directory path to analytics library.
* @return String URL of bsf-analytics directory.
* @since 1.0.0
*/
public function get_analytics_url( $analytics_path ) {
$content_dir_path = wp_normalize_path( WP_CONTENT_DIR );
$analytics_path = wp_normalize_path( $analytics_path );
return str_replace( $content_dir_path, content_url(), $analytics_path );
}
/**
* Get API URL for sending analytics.
*
* @return string API URL.
* @since 1.0.0
*/
private function get_api_url() {
return defined( 'BSF_API_URL' ) ? BSF_API_URL : 'https://support.brainstormforce.com/';
}
/**
* Enqueue Scripts.
*
* @since 1.0.0
* @return void
*/
public function enqueue_assets() {
/**
* Load unminified if SCRIPT_DEBUG is true.
*
* Directory and Extensions.
*/
$dir_name = ( SCRIPT_DEBUG ) ? 'unminified' : 'minified';
$file_rtl = ( is_rtl() ) ? '-rtl' : '';
$css_ext = ( SCRIPT_DEBUG ) ? '.css' : '.min.css';
$css_uri = BSF_ANALYTICS_URI . '/assets/css/' . $dir_name . '/style' . $file_rtl . $css_ext;
wp_enqueue_style( 'bsf-analytics-admin-style', $css_uri, false, BSF_ANALYTICS_VERSION, 'all' );
}
/**
* Send analytics API call.
*
* @since 1.0.0
*/
public function send() {
wp_remote_post(
$this->get_api_url() . 'wp-json/bsf-core/v1/analytics/',
array(
'body' => BSF_Analytics_Stats::instance()->get_stats(),
'timeout' => 5,
'blocking' => false,
)
);
}
/**
* Check if usage tracking is enabled.
*
* @return bool
* @since 1.0.0
*/
public function is_tracking_enabled() {
foreach ( $this->entities as $key => $data ) {
$is_enabled = get_site_option( $key . '_analytics_optin' ) === 'yes' ? true : false;
$is_enabled = $this->is_white_label_enabled( $key ) ? false : $is_enabled;
if ( apply_filters( $key . '_tracking_enabled', $is_enabled ) ) {
return true;
}
}
return false;
}
/**
* Check if WHITE label is enabled for BSF products.
*
* @param string $source source of analytics.
* @return bool
* @since 1.0.0
*/
public function is_white_label_enabled( $source ) {
$options = apply_filters( $source . '_white_label_options', array() );
$is_enabled = false;
if ( is_array( $options ) ) {
foreach ( $options as $option ) {
if ( true === $option ) {
$is_enabled = true;
break;
}
}
}
return $is_enabled;
}
/**
* Display admin notice for usage tracking.
*
* @since 1.0.0
*/
public function option_notice() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
foreach ( $this->entities as $key => $data ) {
$time_to_display = isset( $data['time_to_display'] ) ? $data['time_to_display'] : '+24 hours';
$usage_doc_link = isset( $data['usage_doc_link'] ) ? $data['usage_doc_link'] : $this->usage_doc_link;
// Don't display the notice if tracking is disabled or White Label is enabled for any of our plugins.
if ( false !== get_site_option( $key . '_analytics_optin', false ) || $this->is_white_label_enabled( $key ) ) {
continue;
}
// Show tracker consent notice after 24 hours from installed time.
if ( strtotime( $time_to_display, $this->get_analytics_install_time( $key ) ) > time() ) {
continue;
}
/* translators: %s product name */
$notice_string = __( 'Want to help make <strong>%1s</strong> even more awesome? Allow us to collect non-sensitive diagnostic data and usage information. ', 'wp-schema-pro' );
if ( is_multisite() ) {
$notice_string .= __( 'This will be applicable for all sites from the network.', 'wp-schema-pro' );
}
$language_dir = is_rtl() ? 'rtl' : 'ltr';
Astra_Notices::add_notice(
array(
'id' => $key . '-optin-notice',
'type' => '',
'message' => sprintf(
'<div class="notice-content">
<div class="notice-heading">
%1$s
</div>
<div class="astra-notices-container">
<a href="%2$s" class="astra-notices button-primary">
%3$s
</a>
<a href="%4$s" data-repeat-notice-after="%5$s" class="astra-notices button-secondary">
%6$s
</a>
</div>
</div>',
/* translators: %s usage doc link */
sprintf( $notice_string . '<span dir="%2s"><a href="%3s" target="_blank" rel="noreferrer noopener">%4s</a><span>', esc_html( $data['product_name'] ), $language_dir, esc_url( $usage_doc_link ), __( ' Know More.', 'wp-schema-pro' ) ),
esc_url(
add_query_arg(
array(
$key . '_analytics_optin' => 'yes',
$key . '_analytics_nonce' => wp_create_nonce( $key . '_analytics_optin' ),
'bsf_analytics_source' => $key,
)
)
),
__( 'Yes! Allow it', 'wp-schema-pro' ),
esc_url(
add_query_arg(
array(
$key . '_analytics_optin' => 'no',
$key . '_analytics_nonce' => wp_create_nonce( $key . '_analytics_optin' ),
'bsf_analytics_source' => $key,
)
)
),
MONTH_IN_SECONDS,
__( 'No Thanks', 'wp-schema-pro' )
),
'show_if' => true,
'repeat-notice-after' => false,
'priority' => 18,
'display-with-other-notices' => true,
)
);
}
}
/**
* Process usage tracking opt out.
*
* @since 1.0.0
*/
public function handle_optin_optout() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$source = isset( $_GET['bsf_analytics_source'] ) ? sanitize_text_field( wp_unslash( $_GET['bsf_analytics_source'] ) ) : '';
if ( ! isset( $_GET[ $source . '_analytics_nonce' ] ) ) {
return;
}
if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET[ $source . '_analytics_nonce' ] ) ), $source . '_analytics_optin' ) ) {
return;
}
$optin_status = isset( $_GET[ $source . '_analytics_optin' ] ) ? sanitize_text_field( wp_unslash( $_GET[ $source . '_analytics_optin' ] ) ) : '';
if ( 'yes' === $optin_status ) {
$this->optin( $source );
} elseif ( 'no' === $optin_status ) {
$this->optout( $source );
}
wp_safe_redirect(
esc_url_raw(
remove_query_arg(
array(
$source . '_analytics_optin',
$source . '_analytics_nonce',
'bsf_analytics_source',
)
)
)
);
}
/**
* Opt in to usage tracking.
*
* @param string $source source of analytics.
* @since 1.0.0
*/
private function optin( $source ) {
update_site_option( $source . '_analytics_optin', 'yes' );
}
/**
* Opt out to usage tracking.
*
* @param string $source source of analytics.
* @since 1.0.0
*/
private function optout( $source ) {
update_site_option( $source . '_analytics_optin', 'no' );
}
/**
* Load analytics stat class.
*
* @since 1.0.0
*/
private function includes() {
require_once __DIR__ . '/class-bsf-analytics-stats.php';
}
/**
* Register usage tracking option in General settings page.
*
* @since 1.0.0
*/
public function register_usage_tracking_setting() {
foreach ( $this->entities as $key => $data ) {
if ( ! apply_filters( $key . '_tracking_enabled', true ) || $this->is_white_label_enabled( $key ) ) {
return;
}
$usage_doc_link = isset( $data['usage_doc_link'] ) ? $data['usage_doc_link'] : $this->usage_doc_link;
$author = isset( $data['author'] ) ? $data['author'] : 'Brainstorm Force';
register_setting(
'general', // Options group.
$key . '_analytics_optin', // Option name/database.
array( 'sanitize_callback' => array( $this, 'sanitize_option' ) ) // sanitize callback function.
);
add_settings_field(
$key . '-analytics-optin', // Field ID.
__( 'Usage Tracking', 'wp-schema-pro' ), // Field title.
array( $this, 'render_settings_field_html' ), // Field callback function.
'general',
'default', // Settings page slug.
array(
'type' => 'checkbox',
'title' => $author,
'name' => $key . '_analytics_optin',
'label_for' => $key . '-analytics-optin',
'id' => $key . '-analytics-optin',
'usage_doc_link' => $usage_doc_link,
)
);
}
}
/**
* Sanitize Callback Function
*
* @param bool $input Option value.
* @since 1.0.0
*/
public function sanitize_option( $input ) {
if ( ! $input || 'no' === $input ) {
return 'no';
}
return 'yes';
}
/**
* Print settings field HTML.
*
* @param array $args arguments to field.
* @since 1.0.0
*/
public function render_settings_field_html( $args ) {
?>
<fieldset>
<label for="<?php echo esc_attr( $args['label_for'] ); ?>">
<input id="<?php echo esc_attr( $args['id'] ); ?>" type="checkbox" value="1" name="<?php echo esc_attr( $args['name'] ); ?>" <?php checked( get_site_option( $args['name'], 'no' ), 'yes' ); ?>>
<?php
/* translators: %s Product title */
echo esc_html( sprintf( __( 'Allow %s products to track non-sensitive usage tracking data.', 'wp-schema-pro' ), $args['title'] ) );// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
if ( is_multisite() ) {
esc_html_e( ' This will be applicable for all sites from the network.', 'wp-schema-pro' );
}
?>
</label>
<?php
echo wp_kses_post( sprintf( '<a href="%1s" target="_blank" rel="noreferrer noopener">%2s</a>', esc_url( $args['usage_doc_link'] ), __( 'Learn More.', 'wp-schema-pro' ) ) );
?>
</fieldset>
<?php
}
/**
* Set analytics installed time in option.
*
* @param string $source source of analytics.
* @return string $time analytics installed time.
* @since 1.0.0
*/
private function get_analytics_install_time( $source ) {
$time = get_site_option( $source . '_analytics_installed_time' );
if ( ! $time ) {
$time = time();
update_site_option( $source . '_analytics_installed_time', time() );
}
return $time;
}
/**
* Schedule/unschedule cron event on updation of option.
*
* @param string $old_value old value of option.
* @param string $value value of option.
* @param string $option Option name.
* @since 1.0.0
*/
public function update_analytics_option_callback( $old_value, $value, $option ) {
if ( is_multisite() ) {
$this->add_option_to_network( $option, $value );
}
}
/**
* Analytics option add callback.
*
* @param string $option Option name.
* @param string $value value of option.
* @since 1.0.0
*/
public function add_analytics_option_callback( $option, $value ) {
if ( is_multisite() ) {
$this->add_option_to_network( $option, $value );
}
}
/**
* Send analaytics track event if tracking is enabled.
*
* @since 1.0.0
*/
public function maybe_track_analytics() {
if ( ! $this->is_tracking_enabled() ) {
return;
}
$analytics_track = get_site_transient( 'bsf_analytics_track' );
// If the last data sent is 2 days old i.e. transient is expired.
if ( ! $analytics_track ) {
$this->send();
set_site_transient( 'bsf_analytics_track', true, 2 * DAY_IN_SECONDS );
}
}
/**
* Save analytics option to network.
*
* @param string $option name of option.
* @param string $value value of option.
* @since 1.0.0
*/
public function add_option_to_network( $option, $value ) {
// If action coming from general settings page.
if ( isset( $_POST['option_page'] ) && 'general' === $_POST['option_page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
if ( get_site_option( $option ) ) {
update_site_option( $option, $value );
} else {
add_site_option( $option, $value );
}
}
}
}
}

View File

@@ -0,0 +1,4 @@
{
"bsf-analytics-ver": "1.1.3"
}

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Generated by IcoMoon</metadata>
<defs>
<font id="icomoon" horiz-adv-x="1024">
<font-face units-per-em="1024" ascent="960" descent="-64" />
<missing-glyph horiz-adv-x="1024" />
<glyph unicode="&#x20;" d="" horiz-adv-x="512" />
<glyph unicode="&#xe603;" d="M467.577-21.5c-2.284 7.369-0.104 15.762 7.18 20.556 10.155 6.679 25.5 20.586 84.534 27.952 35.525 4.396-8.694-54.877-3.142-34.181 1.955 7.287-25.91 1.952-25.91 1.952s-46.553-8.773-58.643-24.894c0 0-1.733 2.227-4.019 8.615zM138.271 557.027c0 0 15.887 237.492 368.384 222.11 0 0 146.319-12.099 215.165-56.96 0 0-293.96 10.546-583.551-165.149zM181.807 507.887c0 0 203.521 128.399 558.772 144.239 0 0 48.21-0.329 72.158-35.208 0 0 14.367-31.64 14.086-88.5 0 0-48.229-1.442-85.408-2.723 0 0-355.977-11.586-537.674-199.511 12.648 44.529-121.089 119.532-21.934 181.703zM255.72 238.57c0 0-14.079 43.451 43.498 69.493 54.329 24.572 127.831 96.191 426.625 133.305 0 0 124.558 25.427 48.884-54.439-84.28-88.948-100.337-111.947-100.337-111.947s-22.41-25.55-14.155 5.204c8.255 30.756-120.967 22.15-120.967 22.15s-201.788-45.676-252.733-113.604c0 0-21.178 22.924-30.816 49.839zM369.409 146.887c0 0 106.32 73.825 227.492 55.88 0 0 29.174-1.921-1.115-22.419-30.29-20.503-226.376-33.461-226.376-33.461zM418.719 53.659c0 0-11.482 30.506 7.413 36.941s36.903 30.834 136.907 41.988c40.619-4.038 1.169-110.607-7.296-79.135 2.763 10.295-10.126 9.762-10.126 9.762s-93.985-18.303-111.035-41.039c0 0-12.635 22.476-15.862 31.483zM899.013 687.749c92.851-208.867-26.868-487.037-271.661-536.994 233.968 65.7 273.711 363.944 218.284 497.451-81.853 197.157-343.286 268.698-505.34 206.428-162.056-62.269-203.018-122.175-238.522-224.811 32.087 89.126 91.171 209.056 273.127 278.972 181.958 69.917 431.262-12.179 524.112-221.047z" />
</font></defs></svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +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.
- Fix: Occasional PHP fatal errors when using the child theme.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +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';

View File

@@ -0,0 +1 @@
1.29.9

View File

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