| 1 |
jQuery(document).ready(function () { |
| 2 |
|
| 3 |
// Show review popup |
| 4 |
jQuery("#bbpc_notify_review a").on("click", function () { |
| 5 |
const thisElement = this; |
| 6 |
const fieldValue = jQuery(thisElement).attr("data"); |
| 7 |
const freeLink = "https://wordpress.org/support/plugin/bbp-core/reviews/#new-post"; |
| 8 |
let hidePopup = false; |
| 9 |
if (fieldValue == "rateNow") { |
| 10 |
window.open(freeLink, "_blank"); |
| 11 |
} else { |
| 12 |
hidePopup = true; |
| 13 |
} |
| 14 |
|
| 15 |
jQuery |
| 16 |
.ajax({ |
| 17 |
dataType: 'json', |
| 18 |
url: bbp_core_local_object.ajaxurl, |
| 19 |
type: "post", |
| 20 |
data: { |
| 21 |
action: "bbpc_notify_save_review", |
| 22 |
field: fieldValue, |
| 23 |
nonce: bbp_core_local_object.nonce, |
| 24 |
}, |
| 25 |
}) |
| 26 |
.done(function (result) { |
| 27 |
if (hidePopup == true) { |
| 28 |
jQuery( "#bbpc_notify_review .notice-dismiss" ).trigger( "click" ); |
| 29 |
} |
| 30 |
}) |
| 31 |
.fail(function (res) { |
| 32 |
if (hidePopup == true) { |
| 33 |
console.log(res.responseText); |
| 34 |
jQuery( "#bbpc_notify_review .notice-dismiss" ).trigger( "click" ); |
| 35 |
} |
| 36 |
}); |
| 37 |
}) |
| 38 |
}) |