: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Plugin URI: http://mythemeshop.com/plugins/wp-review/
* Description: Create reviews! Choose from Stars, Percentages, Circles or Points for review scores. Supports Retina Display, WPMU & Unlimited Color Schemes.
* Author URI: http://mythemeshop.com/
var wpreview = window.wpreview = window.wpreview || {};
wpreview.initSelect2 = function() {
if ( 'function' !== typeof $.fn.select2 ) {
function addIcon( option ) {
if ( $( option.element ).attr( 'data-icon' ) ) {
return $( '<span><i class="' + $( option.element ).attr( 'data-icon' ) + '"></i> ' + option.text + '</span>' );
$( '.js-select2' ).select2({
templateSelection: addIcon
wpreview.tabs = function( options ) {
title: '[data-tab-title]',
content: '[data-tab-content]',
options = $.extend( {}, defaults, options );
$( options.wrapper + ' ' + options.title ).on( 'click', function( ev ) {
href = $( this ).attr( 'href' );
$tab = $( this ).closest( options.wrapper );
$tab.find( options.content ).hide();
if ( ! options.activeElement || options.activeElement == options.title ) {
$tab.find( options.title ).removeClass( options.activeClass );
$( this ).addClass( options.activeClass );
$tab.find( options.activeElement ).removeClass( options.activeClass );
$( this ).closest( options.activeElement ).addClass( options.activeClass );
if ( typeof options.activate == 'function' ) {
options.activate.call( $( this ), href );
$tab.find( href ).fadeIn();
$( options.wrapper ).find( options.title + '[href="' + options.active + '"]' ).click();
$( options.wrapper ).find( options.title + ':eq(0)' ).click();
wpreview.initTabs = function() {
activeClass: 'nav-tab-active'
wrapper: '[data-vertical-tabs]',
active: $( '#setting-error-settings_updated' ).length && 'undefined' !== typeof Cookies ? Cookies.get( 'wpr-last-vtab' ) : '',
activate: function( tab ) {
if ( 'undefined' === typeof Cookies ) {
Cookies.set( 'wpr-last-vtab', tab );
wrapper: '[data-nav-tabs]',
activeClass: 'nav-tab-active',
active: $( '#setting-error-settings_updated' ).length && 'undefined' !== typeof Cookies ? Cookies.get( 'wpr-last-htab' ) : '',
activate: function( tab ) {
if ( ! $( '#wpr-global-options' ).length ) {
if ( 'undefined' === typeof Cookies ) {
Cookies.set( 'wpr-last-htab', tab );
wpreview.pluginOptions = function() {
wpreview.pluginMetaBoxes = function() {
$( '#wp_review_custom_location' ).on( 'switch-on', function() {
$('.wp-review-location-options').show();
$( '#wp_review_custom_location' ).on( 'switch-off', function() {
$('.wp-review-location-options').hide();
$( '#wp_review_custom_colors' ).on( 'switch-on', function() {
$('.wp-review-color-options').show();
$( '#wp_review_custom_colors' ).on( 'switch-off', function() {
$('.wp-review-color-options').hide();
$( '#wp_review_custom_author' ).on( 'switch-on', function() {
$('.wp-review-author-options').show();
$( '#wp_review_custom_author' ).on( 'switch-off', function() {
$('.wp-review-author-options').hide();
$( '#wp_review_disable_features' ).on( 'switch-on', function() {
$( '#wpr-review-items-app' ).fadeOut();
$( '#wp_review_disable_features' ).on( 'switch-off', function() {
$( '#wpr-review-items-app' ).fadeIn();
$( document ).on( 'change', 'select#wp_review_schema', function() {
targetSelector = '#wp_review_schema_type_' + value,
notice = $( '#wpr-deprecated-schema-notice' );
$( '.wp_review_schema_type_options' ).hide();
$( '#wp_review_schema_type_options_wrap' ).hide();
$( targetSelector ).show();
if ( 'none' !== value ) {
$( '#wp_review_schema_type_options_wrap' ).show();
notice.toggle( -1 !== [ 'Thing', 'Article', 'Painting', 'Place', 'WebSite' ].indexOf( value ) );
$( document ).on( 'change', '#wp_review_rating_schema', function() {
var value = $( this ).val();
if ( 'author' === value ) {
$( '#wp_review_schema_author_wrapper' ).show();
$( '#wp_review_schema_author_wrapper' ).hide();
$( '#wp-review-userReview-disable' ).on( 'change', function() {
var $postbox = $( this ).closest( '.postbox' );
if ( $(this)[0].checked ) {
$postbox.find( '.show-if-comment, .show-if-visitor, .show-if-both' ).hide();
$postbox.find( '.show-if-disabled' ).show();
$( '#wp-review-userReview-visitor' ).on( 'change', function() {
var $postbox = $( this ).closest( '.postbox' );
if ( $(this)[0].checked ) {
$postbox.find( '.show-if-comment, .show-if-disabled' ).hide();
$postbox.find( '.show-if-visitor, .show-if-both' ).show();
$( document ).on( 'change', '#wp_review_rating_schema', function() {
var value = $( this ).val();
if ( 'author' === value ) {
$( '#wp_review_schema_author_wrapper' ).show();
$( '#wp_review_schema_author_wrapper' ).hide();
$( document ).on( 'change', '#wp-review-userReview-disable', function() {
if ( $( this ).prop( 'checked' ) ) {
$( '#wp_review_rating_schema' ).val( 'author' ).trigger( 'change' );
$( '#wp-review-metabox-item' ).hide();
$( '#wp-review-metabox-heading' ).hide();
$( '#wp-review-metabox-desc' ).hide();
$( '#wp-review-metabox-userReview' ).hide();
$( '#wp_review_shortcode_hint_field' ).hide();
$( '#wp_review_id_hint' ).hide();
$( '#wp_review_heading_group' ).hide();
$( '#wp-review-metabox-reviewLinks' ).hide();
$( '#wp_review_schema_options_wrapper' ).hide();
//$( '#wp_review_schema_rating_group' ).hide();
$( '#wp_review_type' ).on( 'change', function() {
var selected_val = $( this ).val();
var type = wprVars.reviewTypes[ wprVars.globalReviewType ];
var $selected_option = $( this ).find( 'option:selected' );
show = selected_val ? selected_val != none : wprVars.globalReviewType;
$( '#wp-review-metabox-item' ).toggle( show );
$( '#wp-review-metabox-heading' ).toggle( show );
$( '#wp-review-metabox-desc' ).toggle( show );
$( '#wp-review-metabox-userReview' ).toggle( show );
$( '#wp_review_id_hint' ).toggle( show );
$( '#wp_review_schema_options_wrapper' ).toggle( show );
$( '#wp-review-metabox-reviewLinks' ).toggle( show );
$( '#wp_review_heading_group' ).toggle( show );
$( '#wp_review_embed_options_wrapper' ).toggle( show );
$( '#wp_review_show_schema_data_wrapper' ).toggle( show );
if ( $( this ).attr( 'data-changed' ) != 1 ) {
$( this ).attr( 'data-changed', 1 );
if ( ! $( this ).next( 'input[name="wp_review_type"]' ).length ) {
$( this ).after( '<input type="hidden" name="wp_review_type" value="' + selected_val + '">' );
$( this ).next( 'input[name="wp_review_type"]' ).val( selected_val );
wpreview.linkChoices = function( options ) {
options = $.extend( {}, defaults, options );
$( '.wpr-link-choice' ).on( 'click', function( ev ) {
target = $( this ).attr( 'data-target' );
value = $( this ).attr( 'data-value' );
if ( ! $( target ).length ) {
$( target ).val( value );
$( this ).closest( '.wpr-link-choices' ).find( '.wpr-link-choice' ).removeClass( 'active' );
$( this ).addClass( 'active' );
if ( typeof options.callback == 'function' ) {
options.callback.call( $( this ), value );
wpreview.boxTemplatesSelect = function() {
if ( 'function' !== typeof $.fn.select2 ) {
var $select = $( 'select#wp_review_box_template' ),
globalColor = $( '#wpr-review-global-color-value' ).val(),
globalInactiveColor = $( '#wpr-review-global-inactive-color-value' ).val(),
postColor, postInactiveColor;
function onSwitchColor( color ) {
$( '.wpr-review-item .input-color' ).each( function() {
oldVal = $( this ).val();
if ( oldVal === globalColor || oldVal === postColor ) {
$( this ).iris( 'color', color );
function onSwitchInactiveColor( color ) {
$( '.wpr-review-item .input-inactive-color' ).each( function() {
oldVal = $( this ).val();
if ( oldVal === globalInactiveColor || oldVal === postInactiveColor ) {
$( this ).iris( 'color', color );
function onChange( value ) {
var templates = wprVars.boxTemplates,
template = templates[ value ] || templates['default'];
postColor = $( '#wp_review_color' ).val();
postInactiveColor = $( '#wp_review_inactive_color' ).val();
$( '#wp_review_box_template_img' ).attr( 'src', template.image );
$( '#wp_review_color' ).iris( 'color', template.color );
$( '#wp_review_fontcolor' ).iris( 'color', template.fontcolor );
$( '#wp_review_bgcolor1' ).iris( 'color', template.bgcolor1 );
$( '#wp_review_bgcolor2' ).iris( 'color', template.bgcolor2 );
$( '#wp_review_bordercolor' ).iris( 'color', template.bordercolor );
wpreview.turnSwitch( $( '#wp_review_custom_width' ), template.width != 100 );
$( '#wp_review_width' ).val( template.width ).trigger( 'change' );
$( '#wp-review-align-' + template.align ).prop( 'checked', true );
wpreview.turnSwitch( $( '#wp_review_custom_comment_colors' ), template.custom_comment_colors );
$( '#wp_review_comment_color' ).iris( 'color', template.comment_color );
$( '#wp_review_rating_icon' ).val( template.rating_icon ).trigger( 'change' );
$( '#wp_review_inactive_color' ).iris( 'color', template.inactive_color );
$( '#wp_review_comment_inactive_color' ).iris( 'color', template.comment_inactive_color );
$( '#wpr-review-color-value' ).val( template.color );
$( '#wpr-review-inactive-color-value' ).val( template.inactive_color );
onSwitchColor( template.color );
onSwitchInactiveColor( template.inactive_color );
$( '#wp_review_custom_colors' ).on( 'switch-on', function() {
postColor = $( '#wp_review_color' ).val();
postInactiveColor = $( '#wp_review_inactive_color' ).val();
onSwitchColor( $( '#wp_review_color' ).val() );
onSwitchInactiveColor( $( '#wp_review_inactive_color' ).val() );
$( '#wp_review_custom_colors' ).on( 'switch-off', function() {
postColor = $( '#wp_review_color' ).val();
postInactiveColor = $( '#wp_review_inactive_color' ).val();
onSwitchColor( $( '#wpr-review-global-color-value' ).val() );
onSwitchInactiveColor( $( '#wpr-review-global-inactive-color-value' ).val() );
$( '#wp_review_color' ).on( 'color-change', function( ev, colorEvent, ui ) {
postColor = $( '#wp_review_color' ).val();
onSwitchColor( ui.color.toString() );
$( '#wp_review_inactive_color' ).on( 'color-change', function( ev, colorEvent, ui ) {
postInactiveColor = $( '#wp_review_inactive_color' ).val();
onSwitchInactiveColor( ui.color.toString() );
templateResult: function( option ) {
if ( ! option.element ) {
var value = option.element.value,
templates = wprVars.boxTemplates,
template = templates[ value ] || templates['default'];
return $( '<span data-img="' + template.image + '">' + option.text + '</span>' );
$select.on( 'change', function( ev ) {
onChange( ev.target.value );
$( document ).on( 'mouseenter', '#select2-wp_review_box_template-results li', function() {
$( '#wp_review_box_template_preview' ).addClass( 'loading' ).show();
$( '#wp_review_box_template_preview_img' ).attr( 'src', $( this ).find( 'span' ).attr( 'data-img' ) );
$( '#wp_review_box_template_preview_img' ).imagesLoaded().progress( function( instance, image ) {
$( '#wp_review_box_template_preview' ).removeClass( 'loading' );
$select.on( 'select2:close', function() {
$( '#wp_review_box_template_preview' ).hide();
wpreview.formSwitchEvents = function() {
$( document ).on( 'change', '.wpr-switch__on', function() {
if ( $( this )[0].checked ) {
$( this ).closest( '.wpr-switch' ).trigger( 'switch-on' );
$( document ).on( 'change', '.wpr-switch__off', function() {
if ( $( this )[0].checked ) {
$( this ).closest( '.wpr-switch' ).trigger( 'switch-off' );
wpreview.turnSwitch = function( $switch, on ) {
$switch.find( '.wpr-switch__on' ).prop( 'checked', true ).trigger( 'change' );
$switch.find( '.wpr-switch__off' ).prop( 'checked', true ).trigger( 'change' );
wpreview.importDemo = function() {
$( '#wp-review-import-demo-button' ).on( 'click', function() {
var check = confirm( wprVars.importDemoConfirm ),
$button.prop( 'disabled', true );
src: '#wp-review-demo-importer-popup',
$( '#wp-review-demo-importer-modal-footer-button' ).on( 'click', function() {
action: 'wp-review-import-demo',
nonce: $button.attr( 'data-nonce' )
$.post( ajaxurl, data, function( response ) {
$( '#wp-review-demo-importer-modal-content' ).html( response );
$( '#wp-review-demo-importer-modal-footer-info' ).text( wprVars.importDemoDone );
$( '#wp-review-demo-importer-modal-header h2' ).text( wprVars.importDemoDone );
$( '#wp-review-demo-importer-modal-footer-button' ).show();
$button.prop( 'disabled', false );
$( document ).ready( function() {
wpreview.pluginOptions();
wpreview.pluginMetaBoxes();
wpreview.boxTemplatesSelect();
wpreview.formSwitchEvents();
$( '[data-remove-ratings]' ).on( 'click', function() {
var check = confirm( wprVars.confirmPurgeRatings );
options = $button.data(),
btnText = $button.text();
$button.text( options.processingText );
options.action = 'wpr-purge-ratings';
options.nonce = wprVars.purgeRatingsNonce;
success: function( res ) {
$button.text( res.data );