: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Fix conflicts with Blogging theme. See https://github.com/MyThemeShopTeam/wp-review-pro/issues/277.
$( document ).off( 'mousewheel', '**' );
$( document ).on( 'DOMMouseScroll mousewheel', '.select2-results', function( ev ) {
if ( $( this ).children( '#select2-wp_review_box_template-results' ).length ) {
if ( $( this ).children( '#select2-wp_review_popup_animation_in-results' ).length ) {
if ( $( this ).children( '#select2-wp_review_popup_animation_out-results' ).length ) {
scrollTop = this.scrollTop,
scrollHeight = this.scrollHeight,
delta = ev.type == 'DOMMouseScroll' ? ev.originalEvent.detail * -40 : ev.originalEvent.wheelDelta,
var prevent = function() {
if ( ! up && -delta > scrollHeight - height - scrollTop ) {
// Scrolling down, but this will take us past the bottom.
$this.scrollTop( scrollHeight );
} else if ( up && delta > scrollTop ) {
// Scrolling up, but this will take us past the top.
function showProPopup() {
src: '#wp-review-pro-popup-notice',
$( document ).on( 'click', '#select2-wp_review_box_template-results li[aria-disabled="true"]', function() {
$( '#wp_review_box_template' ).select2( 'close' );
$( document ).on( 'click', '#select2-wp_review_rating_icon-results li[aria-disabled="true"]', function() {
$( '#wp_review_rating_icon' ).select2( 'close' );
$( document ).on( 'click', '.wp-review-disabled, option[disabled]', function( ev ) {
$( 'select:not(.select2-hidden-accessible)' ).each( function() {
$( this ).attr( 'data-old-val', $( this ).val() );
$( document ).on( 'change', 'select:not(.select2-hidden-accessible)', function() {
var selectedIndex = $( this ).prop( 'selectedIndex' ),
selectedOption = $( this ).find( 'option:eq(' + selectedIndex + ')' ),
oldVal = $( this ).attr( 'data-old-val' );
if ( selectedOption.hasClass( 'disabled' ) ) {
$( this ).attr( 'data-old-val', $( this ).val() );
// Fix conflict with color picker in Avada theme.
if ( $( '.pyre_field.avada-color' ).length ) {
$( '.wp-review-color' ).closest( '.wp-review-field-option' ).addClass( 'pyre_field' );
$( '.input-color, .input-inactive-color' ).closest( '.col-2' ).addClass( 'pyre_field' );
$( window ).on( 'load', function() {
// WYSIWYG saving issue when using Gutenberg.
if ( $( 'body.block-editor-page' ).length ) {
window.tinyMCE.editors.forEach( function( editor ) {
editor.on( 'change', function() {
$( '#wp_review_type' ).trigger( 'change' );
jQuery(document).ready(function($) {
$('.add-row').on('click', function(e) {
var $target = $($(this).data('target'));
var row = $target.find('.empty-row').clone(true);
var input = row.find('input');
if (typeof input.data('name') !== 'undefined' && input.data('name')) input.prop('name', input.data('name'));
input.filter('[name="wp_review_item_star[]"]').addClass('review-star');
row.removeClass('empty-row screen-reader-text');
row.insertBefore($target.find('tbody>tr:last'));
row.find(".focus-on-add").focus();
$('.remove-row').on('click', function(e) {
$(this).closest('tr').remove();
$('#wp-review-metabox-item tbody').sortable({ handle: '.handle', revert: 100, containment: '#wp-review-metabox-item' });
$('#wp-review-metabox-reviewLinks tbody').sortable({ handle: '.handle', revert: 100, containment: '#wp-review-metabox-reviewLinks' });
// $('#wp-wp_review_desc-wrap').toggle(! $('#wp_review_hide_desc').is(':checked'));
$('#wp_review_location').on('change', function() {
$('#wp_review_shortcode_hint_field').toggle($(this).val() == 'custom');
if ($('#wp_review_location').val() == 'custom') {
$('#wp_review_shortcode_hint_field').show();
$( '#wp-review-width-slider' ).slider({
value: $( '#wp_review_width' ).val(),
$('.wp-review-userReview-options').change(function(event) {
$('#wp-review-through-comment-option').toggle(!!parseInt($(this).val()));
$('.wp-review-color').wpColorPicker({
change: function( event, ui ) {
$( event.target ).trigger( 'color-change', [ event, ui ] );
$('.wp-review-theme-defaults-msg .close-notice').click(function() {
$('.wp-review-theme-defaults-msg').remove();
$('.wp-review-theme-defaults-msg a.button').click(function() {
return confirm('Are you sure? This may override the current settings.');
$('[name=wp_review_userReview]').change(function(e){
var $type = $('#wp_review_comment_rating_type');
if(wprVars.ratingPermissionsCommentOnly === val || wprVars.ratingPermissionsBoth === val){
if ($('#wp-review-migrate-log').length) {
var $migrate_log = $('#wp-review-migrate-log');
var migrate_started = false;
var rows_left = parseInt($('#migrate-items-num').text());
var migrated_rows = $('#start-migrate').data('start');
var migrate_finished = false;
var updatelog = function( text ) {
$migrate_log.css('display', 'block').val(function(index, old) { return text + "\n" + old });
var ajax_migrate = function( startindex ) {
data: { action: 'wp_review_migrate_ratings', start: startindex },
$('#migrate-items-num').text(data.rowsleft);
updatelog( 'Imported ratings: ' + (startindex + 1) + ' - ' + data.lastrow + '...' );
ajax_migrate( data.lastrow );
updatelog('Import complete.');
$('#start-migrate').click(function(event) {
updatelog('Import started, please wait...');
ajax_migrate(migrated_rows);
uploader : function( id ) {
title : wprVars.imgframe_title,
library : { type : 'image' },
button : { text : wprVars.imgbutton_title }
frame.on( 'insert', function(selection) {
var state = frame.state();
selection = selection || state.get('selection');
// We set multiple to false so only get one image from the uploader
var attachment = selection.first();
var display = state.display(attachment).toJSON(); // <-- additional properties
attachment = attachment.toJSON();
// Do something with attachment.id and/or attachment.url here
var imgurl = attachment.sizes[display.size].url;
var attachments = frame.state().get( 'selection' ).toJSON();
$( '#' + id + '-preview' ).html( '<img src="' + imgurl + '" class="wpr_image_upload_img" />' );
$( '#' + id + '-id' ).val( attachments[0].id );
$( '#' + id + '-url' ).val( imgurl );
if ( $( '#' + id + '-upload+.clear-image' ).length == 0 ) {
$( '#' + id + '-upload' ).after( '<a href="#" class="button button-link clear-image">' + wprVars.imgremove_title + '</a>' );
$( document ).on( 'click', '.clear-image', function( e ) {
id = $this.prev().data( 'id' );
$( '#' + id + '-preview' ).html( '' );
$( '#' + id + '-id' ).val( '' );
$( '#' + id + '-url' ).val( '' );
$( '.wpr-datepicker' ).datepicker({
if ( typeof wp !== 'undefined' && wp.media && wp.media.editor) {
$(document).on('click', '.wp-review-rating-image .set_rating_image, .wp-review-rating-image .img-wrapper i', function(e) {
var button = $('.wp-review-rating-image .set_rating_image'),
custom_uploader = wp.media({
}).on('select', function() {
var attachment = custom_uploader.state().get('selection').first().toJSON();
$(button).parent().find('.img-wrapper').removeClass('hide').find('img').attr('src', attachment.url);
$(button).removeClass('button').prev().val(attachment.id).next().show();
if($(document).find('#multisite_settings').length > 0) {
$(document).on('change', '#wp-review-select-site', function(){
var site = $(this).val();
$('.wp-review-subsite-wrapper').hide();
$(document).find('#wp-review-site-'+site+'-fields').show();
// Multisite general settings.
$( '.wp-review-multisite-general-settings div.wpr-switch' ).on( 'switch-on', function() {
$('.wp-review-multisite-global-options').fadeOut();
$( '.wp-review-multisite-general-settings div.wpr-switch' ).on( 'switch-off', function() {
$('.wp-review-multisite-global-options').fadeIn();
// Multisite post settings.
$( '.wp-review-multisite-posts-options div.wpr-switch' ).on( 'switch-on', function() {
$(this).parents('.wp-review-multisite-posts-options').next('#wp-review-multisite-posts-options').fadeOut();
$( '.wp-review-multisite-posts-options div.wpr-switch' ).on( 'switch-off', function() {
$(this).parents('.wp-review-multisite-posts-options').next('#wp-review-multisite-posts-options').fadeIn();