: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* File for registering meta box.
* @copyright Copyright (c) 2013, MyThemesShop
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
/* Adds a box to the Posts edit screens. */
add_action( 'add_meta_boxes', 'wp_review_add_meta_boxes' );
/* Saves the meta box custom data. */
add_action( 'save_post', 'wp_review_save_postdata', 10, 2 );
add_action( 'save_post', 'wp_review_clear_query_cache', 10, 2 );
require_once plugin_dir_path( __FILE__ ) . 'review-options-meta-box.php';
* Adds a box to the Post edit screens.
function wp_review_add_meta_boxes() {
$post_types = get_post_types( array( 'public' => true ), 'names' );
$excluded_post_types = apply_filters( 'wp_review_excluded_post_types', array( 'attachment' ) );
$hide_review_box = wp_review_network_option( 'hide_ratings_in_posts_' );
$hide_review_links = wp_review_network_option( 'hide_review_links_' );
$hide_review_desc = wp_review_network_option( 'hide_review_description_' );
$hide_review_features = wp_review_network_option( 'hide_features_' );
$hide_user_reviews = wp_review_network_option( 'hide_user_reviews_' );
if ( ! $hide_review_box && current_user_can( 'wp_review_single_page' ) ) {
foreach ( $post_types as $post_type ) {
if ( ! in_array( $post_type, $excluded_post_types, true ) ) {
'wp-review-metabox-review',
__( 'Review', 'wp-review' ),
'wp_review_render_meta_box_review_options',
if ( ! $hide_review_features && current_user_can( 'wp_review_features' ) ) {
'wp-review-metabox-item',
__( 'Review Item', 'wp-review' ),
'wp_review_render_meta_box_item',
if ( ! $hide_review_links && current_user_can( 'wp_review_links' ) ) {
'wp-review-metabox-reviewLinks',
__( 'Review Links', 'wp-review' ),
'wp_review_render_meta_box_review_links',
if ( ! $hide_review_desc && current_user_can( 'wp_review_description' ) ) {
'wp-review-metabox-desc',
__( 'Review Description', 'wp-review' ),
'wp_review_render_meta_box_desc',
if ( ! $hide_user_reviews && current_user_can( 'wp_review_user_reviews' ) ) {
'wp-review-metabox-userReview',
__( 'User Reviews', 'wp-review' ),
'wp_review_render_meta_box_user_review',
* @param WP_Post $post Post object.
function wp_review_render_meta_box_item( $post ) {
$form_field = new WP_Review_Form_Field();
$options = get_option( 'wp_review_options' );
$default_location = wp_review_get_default_location();
$default_criteria = wp_review_get_default_criteria();
$default_items = array();
foreach ( $default_criteria as $index => $item ) {
$default_items[ $index ] = array(
'wp_review_item_title' => $item,
'wp_review_item_star' => '',
$global_colors = wp_review_get_global_colors();
$global_color = $global_colors['color'];
$global_inactive_color = $global_colors['inactive_color'];
/* Retrieve an existing value from the database. */
$custom_colors = get_post_meta( $post->ID, 'wp_review_custom_colors', true );
$custom_location = get_post_meta( $post->ID, 'wp_review_custom_location', true );
$items = wp_review_get_review_items( $post->ID );
$items = array_values( $items );
$total = get_post_meta( $post->ID, 'wp_review_total', true );
$post_color = get_post_meta( $post->ID, 'wp_review_color', true );
$post_inactive_color = get_post_meta( $post->ID, 'wp_review_inactive_color', true );
$inactive_color = $post_inactive_color;
$location = get_post_meta( $post->ID, 'wp_review_location', true );
$fontcolor = get_post_meta( $post->ID, 'wp_review_fontcolor', true );
$bgcolor1 = get_post_meta( $post->ID, 'wp_review_bgcolor1', true );
$bgcolor2 = get_post_meta( $post->ID, 'wp_review_bgcolor2', true );
$bordercolor = get_post_meta( $post->ID, 'wp_review_bordercolor', true );
if ( ! $inactive_color ) {
$inactive_color = $global_inactive_color;
if ( '' === $location ) {
$location = ! empty( $options['location'] ) ? $options['location'] : $default_location;
if ( '' === $fontcolor ) {
$fontcolor = $global_colors['fontcolor'];
if ( '' === $bgcolor1 ) {
$bgcolor1 = $global_colors['bgcolor1'];
if ( '' === $bgcolor2 ) {
$bgcolor2 = $global_colors['bgcolor2'];
if ( '' === $bordercolor ) {
$bordercolor = $global_colors['bordercolor'];
'inactive_color' => true,
'custom_location' => true,
'disable_features' => true,
$displayed_fields = apply_filters( 'wp_review_metabox_item_fields', $fields );
$review_templates = wp_review_get_box_templates();
$box_template = get_post_meta( $post->ID, 'wp_review_box_template', true );
if ( ! $box_template || ! in_array( $box_template, array( 'default', 'aqua' ), true ) ) {
$box_template = wp_review_option( 'box_template', 'default' );
$box_template_img = ! empty( $review_templates[ $box_template ] ) ? $review_templates[ $box_template ]['image'] : WP_REVIEW_ASSETS . 'images/largethumb.png';
/* Add an nonce field so we can check for it later. */
wp_nonce_field( basename( __FILE__ ), 'wp-review-item-nonce' );
<input type="hidden" id="wpr-review-color-value" value="<?php echo esc_attr( $color ); ?>">
<input type="hidden" id="wpr-review-inactive-color-value" value="<?php echo esc_attr( $inactive_color ); ?>">
<input type="hidden" id="wpr-review-global-color-value" value="<?php echo esc_attr( $global_color ); ?>">
<input type="hidden" id="wpr-review-global-inactive-color-value" value="<?php echo esc_attr( $global_inactive_color ); ?>">
<input type="hidden" id="wpr-review-items-data" value="<?php echo esc_attr( wp_json_encode( $items ) ); ?>">
<div id="wpr-review-items-app">
<input type="hidden" id="wpr-review-type-2" value="">
<div class="wpr-review-items"></div>
<div class="setting-row final-row" style="padding-right: 10px;">
<button type="button" class="button add-item"><?php esc_html_e( 'Add item', 'wp-review' ); ?></button>
<div class="col-2"></div>
<div class="wpr-review-items-total">
<input type="text" class="input-total" name="wp_review_total" value="<?php echo floatval( $total ); ?>" size="4">
<label><?php esc_html_e( 'Total', 'wp-review' ); ?></label>
<script type="text/html" id="tmpl-wpr-review-item">
<span class="wpr-icon-move dashicons dashicons-menu"></span>
{{{ data.itemNameSetting }}}
{{{ data.itemRatingSetting }}}
{{{ data.itemColorSetting }}}
{{{ data.itemInactiveColorSetting }}}
<input type="hidden" name="wp_review_item_id[]" value="{{ data.item_id }}">
<button type="button" class="button delete-item"><?php esc_html_e( 'Delete', 'wp-review' ); ?></button>
<script type="text/html" id="tmpl-wpr-review-item-name">
<div class="setting-row">
<label for="wpr-review-item-title-{{ data.id }}"><?php esc_html_e( 'Feature Name', 'wp-review' ); ?></label>
<input type="text" id="wpr-review-item-title-{{ data.id }}" name="wp_review_item_title[]" class="input-title" value="{{ data.wp_review_item_title }}">
<script type="text/html" id="tmpl-wpr-review-item-color">
<div class="setting-row">
<div class="wp-review-disabled col-1">
<label for="wpr-review-item-color-{{ data.id }}"><?php esc_html_e( 'Feature Color', 'wp-review' ); ?></label>
<?php wp_review_print_pro_text(); ?>
<span class="wp-review-disabled inline-block has-bg">
<input type="text" id="wpr-review-item-color-{{ data.id }}" name="wp_review_item_color[]" class="input-color" value="{{ data.wp_review_item_color }}" data-default-color="{{ data.wp_review_item_color }}" disabled>
<script type="text/html" id="tmpl-wpr-review-item-inactive-color">
<div class="setting-row">
<div class="wp-review-disabled col-1">
<label for="wpr-review-item-inactive-color-{{ data.id }}"><?php esc_html_e( 'Inactive Color', 'wp-review' ); ?></label>
<?php wp_review_print_pro_text(); ?>
<span class="wp-review-disabled inline-block has-bg">
<input type="text" id="wpr-review-item-inactive-color-{{ data.id }}" name="wp_review_item_inactive_color[]" class="input-inactive-color" value="{{ data.wp_review_item_inactive_color }}" data-default-color="{{ data.wp_review_item_inactive_color }}" disabled>
<script type="text/html" id="tmpl-wpr-review-item-rating">
<div class="setting-row">
<label for="wpr-review-item-star-{{ data.id }}"><?php esc_html_e( 'Feature Score', 'wp-review' ); ?></label>
<input type="text" id="wpr-review-item-star-{{ data.id }}" name="wp_review_item_star[]" class="input-star" value="{{ data.wp_review_item_star }}" data-type="{{ data.type }}" data-color="{{ data.wp_review_item_color }}" data-inactive-color="{{ data.wp_review_item_inactive_color }}" size="4">
<div class="col-3"></div>
<div class="wp-review-field"<?php if ( empty( $displayed_fields['disable_features'] ) ) echo ' style="display: none;"'; // phpcs:ignore ?>>
<div class="wp-review-disabled wp-review-field-label">
<label><?php esc_html_e( 'Hide Features', 'wp-review' ); ?></label>
<?php wp_review_print_pro_text(); ?>
<div class="wp-review-field-option">
$form_field->render_switch(
'id' => 'wp_review_disable_features',
'name' => 'wp_review_disable_features',
<div class="wp-review-field"<?php if ( empty( $displayed_fields['custom_location'] ) ) echo ' style="display: none;"'; // phpcs:ignore ?>>
<div class="wp-review-field-label">
<label><?php esc_html_e( 'Custom Location', 'wp-review' ); ?></label>
<div class="wp-review-field-option">
$form_field->render_switch(
'id' => 'wp_review_custom_location',
'name' => 'wp_review_custom_location',
'value' => $custom_location,
<div class="wp-review-location-options"<?php if ( empty( $custom_location ) || empty( $displayed_fields['location'] ) ) echo ' style="display: none;"'; // phpcs:ignore ?>>
<div class="wp-review-field">
<div class="wp-review-field-label">
<label for="wp_review_location"><?php esc_html_e( 'Review Location', 'wp-review' ); ?></label>
<div class="wp-review-field-option">
<select name="wp_review_location" id="wp_review_location">
<option value="bottom" <?php selected( $location, 'bottom' ); ?>><?php esc_html_e( 'After Content', 'wp-review' ); ?></option>
<option value="top" <?php selected( $location, 'top' ); ?>><?php esc_html_e( 'Before Content', 'wp-review' ); ?></option>
<option value="custom" <?php selected( $location, 'custom' ); ?>><?php esc_html_e( 'Custom (use shortcode)', 'wp-review' ); ?></option>
<p id="wp_review_shortcode_hint_field">
<!-- <label for="wp_review_shortcode_hint"></label> -->
<input id="wp_review_shortcode_hint" type="text" value='[wp-review id="<?php echo intval( trim( $post->ID ) ); ?>"]' readonly="readonly" />
<span class="description"><?php esc_html_e( 'Copy & paste this shortcode in the content.', 'wp-review' ); ?></span>
<div class="wp-review-field"<?php if ( empty( $displayed_fields['custom_colors'] ) ) echo ' style="display: none;"'; // phpcs:ignore ?>>
<div class="wp-review-field-label">
<label><?php esc_html_e( 'Custom Layout', 'wp-review' ); ?></label>
<div class="wp-review-field-option">
$form_field->render_switch(
'id' => 'wp_review_custom_colors',
'name' => 'wp_review_custom_colors',
'value' => $custom_colors,
<div class="wp-review-color-options"<?php if ( empty( $custom_colors ) ) echo ' style="display: none;"'; // phpcs:ignore ?>>
<div class="wp-review-field vertical">
<div class="wp-review-field-label">
<label for="wp_review_box_template"><?php esc_html_e( 'Default', 'wp-review' ); ?></label>
<div class="wp-review-field-option">
<div id="wp_review_box_template_wrapper">
<select name="wp_review_box_template" id="wp_review_box_template">
foreach ( $review_templates as $key => $value ) {
$disabled = 'default' !== $key && 'aqua' !== $key;
'<option value="%1$s" %2$s %3$s>%4$s</option>',
selected( $key, $box_template, false ),
$disabled ? 'disabled' : '',
esc_html( $value['title'] )
<div id="wp_review_box_template_preview" style="display: none;">
<img src="#" alt="" id="wp_review_box_template_preview_img">
<div style="margin-top: 10px;">
<img src="<?php echo esc_url( $box_template_img ); ?>" alt="" id="wp_review_box_template_img">
<div class="wp-review-field"<?php if ( empty( $displayed_fields['color'] ) ) echo ' style="display: none;"'; // phpcs:ignore ?>>
<div class="wp-review-field-label">
<label for="wp_review_color"><?php esc_html_e( 'Review Color', 'wp-review' ); ?></label>
<div class="wp-review-field-option">
<input type="text" id="wp_review_color" class="wp-review-color" name="wp_review_color" value="<?php echo esc_attr( $color ); ?>" data-default-color="<?php echo esc_attr( $color ); ?>">
<div class="wp-review-field"<?php if ( empty( $displayed_fields['inactive_color'] ) ) echo ' style="display: none;"'; // phpcs:ignore ?>>
<div class="wp-review-field-label">
<label for="wp_review_inactive_color"><?php esc_html_e( 'Inactive Review Color', 'wp-review' ); ?></label>
<div class="wp-review-field-option">
<input type="text" id="wp_review_inactive_color" class="wp-review-color" name="wp_review_inactive_color" value="<?php echo esc_attr( $inactive_color ); ?>" data-default-color="<?php echo esc_attr( $inactive_color ); ?>">
<div class="wp-review-field"<?php if ( empty( $displayed_fields['fontcolor'] ) ) echo ' style="display: none;"'; // phpcs:ignore ?>>
<div class="wp-review-field-label">
<label for="wp_review_fontcolor"><?php esc_html_e( 'Font Color', 'wp-review' ); ?></label>
<div class="wp-review-field-option">
<input type="text" class="wp-review-color" name="wp_review_fontcolor" id ="wp_review_fontcolor" value="<?php echo esc_attr( $fontcolor ); ?>" data-default-color="<?php echo esc_attr( $fontcolor ); ?>">
<div class="wp-review-field"<?php if ( empty( $displayed_fields['bgcolor1'] ) ) echo ' style="display: none;"'; // phpcs:ignore ?>>
<div class="wp-review-field-label">
<label for="wp_review_bgcolor1"><?php esc_html_e( 'Heading Background Color', 'wp-review' ); ?></label>
<div class="wp-review-field-option">
<input type="text" class="wp-review-color" name="wp_review_bgcolor1" id ="wp_review_bgcolor1" value="<?php echo esc_attr( $bgcolor1 ); ?>" data-default-color="<?php echo esc_attr( $bgcolor1 ); ?>">
<div class="wp-review-field"<?php if ( empty( $displayed_fields['bgcolor2'] ) ) echo ' style="display: none;"'; // phpcs:ignore ?>>
<div class="wp-review-field-label">
<label for="wp_review_bgcolor2"><?php esc_html_e( 'Background Color', 'wp-review' ); ?></label>
<div class="wp-review-field-option">
<input type="text" class="wp-review-color" name="wp_review_bgcolor2" id="wp_review_bgcolor2" value="<?php echo esc_attr( $bgcolor2 ); ?>" data-default-color="<?php echo esc_attr( $bgcolor2 ); ?>">
<div class="wp-review-field"<?php if ( empty( $displayed_fields['bordercolor'] ) ) echo ' style="display: none;"'; // phpcs:ignore ?>>
<div class="wp-review-field-label">
<label for="wp_review_bordercolor"><?php esc_html_e( 'Border Color', 'wp-review' ); ?></label>
<div class="wp-review-field-option">
<input type="text" class="wp-review-color" name="wp_review_bordercolor" id="wp_review_bordercolor" value="<?php echo esc_attr( $bordercolor ); ?>" data-default-color="<?php echo esc_attr( $bordercolor ); ?>">
<div class="wp-review-field"<?php if ( empty( $displayed_fields['fontfamily'] ) ) echo ' style="display: none;"'; // phpcs:ignore ?>>
<div class="wp-review-disabled wp-review-field-label">
<label><?php esc_html_e( 'Google Font', 'wp-review' ); ?></label>
<?php wp_review_print_pro_text(); ?>
<div class="wp-review-field-option">
$form_field->render_switch(
'id' => 'wp_review_fontfamily',
'name' => 'wp_review_fontfamily',
<div class="wp-review-field">
<div class="wp-review-disabled wp-review-field-label">
<label><?php esc_html_e( 'Custom Width', 'wp-review' ); ?></label>
<?php wp_review_print_pro_text(); ?>
<div class="wp-review-field-option">
$form_field->render_switch(
'id' => 'wp_review_custom_width',
'name' => 'wp_review_custom_width',