: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
function wp_review_yelp_review_schema( $review, $business ) {
'@context' => 'http://schema.org',
'reviewBody' => $review['text'],
'name' => $review['user']['name'],
'image' => $review['user']['image_url'],
'@type' => 'LocalBusiness',
'name' => $business['name'],
'url' => $business['url'],
'image' => $business['image_url'],
'address' => implode( ', ', $business['location']['display_address'] ),
'priceRange' => $business['price'],
'telephone' => $business['phone'],
'ratingValue' => $review['rating'],
* Allow changing schema markup for Yelp review.
* @param array $markup Schema markup.
* @param array $review Review data.
* @param array $business Business data.
$markup = apply_filters( 'wp_review_yelp_review_schema_markup', $markup, $review, $business );
printf( '<script type="application/ld+json">%s</script>', wp_json_encode( $markup ) );
* Shows Facebook page schema.
* @param array $page Page data.
function wp_review_facebook_page_schema( $page ) {
if ( empty( $page->overall_star_rating ) ) {
'@context' => 'http://schema.org',
'@type' => 'LocalBusiness',
'url' => "https://facebook.com/{$page->id}",
'aggregateRating' => array(
'@type' => 'AggregateRating',
'ratingValue' => $page->overall_star_rating,
'ratingCount' => $page->rating_count,
* Allow changing schema markup for Facebook page.
* @param array $markup Schema markup.
* @param array $page Page data.
$markup = apply_filters( 'wp_review_facebook_page_schema_markup', $markup, $page );
printf( '<script type="application/ld+json">%s</script>', wp_json_encode( $markup ) );
* Shows Facebook page review schema.
* @param object $review Review data.
* @param array $page Page data.
function wp_review_facebook_page_review_schema( $review, $page ) {
'@context' => 'http://schema.org',
'reviewBody' => $review->review_text,
'name' => ! empty( $review->reviewer ) ? $review->reviewer->name : '',
'image' => ! empty( $review->reviewer ) ? wp_review_fb_user_avatar_url( $review->reviewer->id ) : '',
'@type' => 'LocalBusiness',
'url' => "https://facebook.com/{$page->id}",
'ratingValue' => $review->rating,
* Allow changing schema markup for Facebook page review.
* @param array $markup Schema markup.
* @param array $review Review data.
* @param array $page Page data.
$markup = apply_filters( 'wp_review_facebook_page_review_schema_markup', $markup, $review, $page );
printf( '<script type="application/ld+json">%s</script>', wp_json_encode( $markup ) );
* Normalizes the rating value base on rating type.
* @param float $value Rating value.
* @param string $type Rating type.
function wp_review_normalize_rating_value( $value, $type = 'star' ) {
$rating_type = wp_review_get_rating_type_data( $type );
return round( floatval( $value ), $rating_type['decimals'] );
* Enqueues rating type scripts.
* @param string $type Type of script. Accepts `output` or `input`.
* @param array $rating_types Rating types.
function wp_review_enqueue_rating_type_scripts( $type = 'output', array $rating_types = array() ) {
$rating_types = wp_review_get_rating_types();
$rating_types = array_keys( $rating_types );
if ( ! empty( $rating_types ) && is_array( $rating_types ) ) {
foreach ( $rating_types as $rating_type ) {
wp_enqueue_script( "wp-review-{$rating_type}-{$type}" );
// GDPR Compliant - Export User Information.
if ( ! function_exists( 'wp_review_data_exporter' ) ) {
* @param string $email_address Email address.
* @param int $page Page number.
function wp_review_data_exporter( $email_address, $page = 1 ) {
// Limit us to 500 comments at a time to avoid timing out.
$data_to_export = array();
$comments = get_comments(
'author_email' => $email_address,
'order_by' => 'comment_ID',
'update_comment_meta_cache' => false,
$comment_prop_to_export = array(
'comment_rating' => __( 'Comment Rating', 'wp-review' ),
'features_rating' => __( 'Features Ratings', 'wp-review' ),
'comment_title' => __( 'Comment Title', 'wp-review' ),
foreach ( (array) $comments as $comment ) {
$comment_data_to_export = array();
foreach ( $comment_prop_to_export as $key => $name ) {
$comment_id = $comment->comment_ID;
$value = get_comment_meta( $comment_id, 'wp_review_' . $key, true );
if ( ! empty( $value ) ) {
if ( 'features_rating' !== $key ) {
$comment_data_to_export[] = array(
$post_id = $comment->comment_post_ID;
$type = wp_review_get_post_user_review_type( $post_id );
$rating_type = wp_review_get_rating_type_data( $type );
$items = wp_review_get_review_items( $post_id );
$rating_items = get_comment_meta( $comment_id, WP_REVIEW_COMMENT_FEATURES_RATING_METAKEY, true );
$review_ratings = array();
foreach ( $items as $item_id => $item ) {
if ( isset( $rating_items[ $item_id ] ) ) {
$review_ratings[ $item['wp_review_item_title'] ] = $rating_items[ $item_id ] . ' of ' . $rating_type['max'];
if ( ! empty( $review_ratings ) ) {
foreach ( $review_ratings as $review_title => $review_value ) {
$comment_data_to_export[] = array(
'value' => $review_value,
$data_to_export[] = array(
'group_id' => 'comments',
'group_label' => __( 'Comments', 'wp-review' ),
'item_id' => "comment-{$comment->comment_ID}",
'data' => $comment_data_to_export,
$done = count( $comments ) < $number;
'data' => $data_to_export,
// Filter function to register data exporter.
if ( ! function_exists( 'wp_review_register_data_exporter' ) ) {
* Registers data exporter.
* @param array $exporters Exporters.
function wp_review_register_data_exporter( $exporters ) {
$exporters['wp-review'] = array(
'exporter_friendly_name' => apply_filters( 'wp_review_exporter_friendly_name', __( 'WordPress Comments', 'wp-review' ) ),
'callback' => 'wp_review_data_exporter',
add_filter( 'wp_privacy_personal_data_exporters', 'wp_review_register_data_exporter', 9 );
* Switches to the main network site.
* Function to switch to Network site, if global option is disabled in sub-site.
* @param string $option Option name.
function wp_review_switch_to_main( $option = '' ) {
if ( is_multisite() && ! is_main_site() ) {
$site_id = get_current_blog_id();
switch_to_blog( get_network()->site_id );
$options = get_option( 'wp_review_options' );
$hide_options = isset( $options[ 'hide_global_options_' . $site_id ] ) ? $options[ 'hide_global_options_' . $site_id ] : false;
$hide_options = isset( $options[ $option . $site_id ] ) ? $options[ $option . $site_id ] : false;
* Function to get option value from main-network site.
* @param string $key Option key.
function wp_review_network_option( $key ) {
if ( is_multisite() && ! is_main_site() ) {
$site_id = get_current_blog_id();
switch_to_blog( get_network()->site_id );
$options = get_option( 'wp_review_options' );
$value = isset( $options[ $key . $site_id ] ) ? $options[ $key . $site_id ] : '';
function wp_review_get_capabilities() {
'wp_review_global_options' => esc_html__( 'Global Options', 'wp-review' ),
'wp_review_import_reviews' => esc_html__( 'Import Reviews', 'wp-review' ),
'wp_review_single_page' => esc_html__( 'Single Page Settings', 'wp-review' ),
'wp_review_features' => esc_html__( 'Review Features', 'wp-review' ),
'wp_review_links' => esc_html__( 'Review Links', 'wp-review' ),
'wp_review_description' => esc_html__( 'Review Description, Pros/Cons and Total Rating', 'wp-review' ),
'wp_review_user_reviews' => esc_html__( 'User Reviews', 'wp-review' ),
'wp_review_purge_visitor_ratings' => esc_html__( 'Purge Visitor Ratings', 'wp-review' ),
'wp_review_purge_comment_ratings' => esc_html__( 'Purge Comment Ratings', 'wp-review' ),
'option_page_capability_wpreview-settings-group',
return 'wp_review_global_options';
'members_register_cap_groups',
members_register_cap_group(
'label' => __( 'WP Review', 'wp-review' ),
'icon' => 'dashicons-star-filled',
foreach ( wp_review_get_capabilities() as $key => $cap ) {
$wpr_compatibility = get_option( 'wp_review_compatibility' );
if ( ! $wpr_compatibility ) {
$role = get_role( 'administrator' );
foreach ( wp_review_get_capabilities() as $key => $cap ) {
$role = get_role( 'editor' );
'wp_review_notification_bar',
'wp_review_user_reviews',
'wp_review_purge_visitor_ratings',
'wp_review_purge_comment_ratings',
foreach ( $editor_caps as $cap ) {
update_option( 'wp_review_compatibility', true );
* Checks if is in amp page.
function wp_review_is_amp_page() {
if ( function_exists( 'is_amp_endpoint' ) ) {
return is_amp_endpoint();
if ( function_exists( 'ampforwp_is_amp_endpoint' ) ) {
return ampforwp_is_amp_endpoint();
function wp_review_get_current_url() {
return home_url( $wp->request );
* Gets the current non-AMP URL.
function wp_review_get_current_non_amp_url() {
$current_url = wp_review_get_current_url();
if ( function_exists( 'amp_remove_endpoint' ) ) {
return amp_remove_endpoint( $current_url );
function wp_review_add_amp_css() {
if ( file_exists( WP_REVIEW_DIR . 'public/css/amp.css' ) ) {
echo file_get_contents( WP_REVIEW_DIR . 'public/css/amp.css' );
add_action( 'amp_post_template_css', 'wp_review_add_amp_css' );
* Adds AMP template data.
* @param array $data Template data.
function wp_review_add_amp_template_data( $data ) {
$data['font_urls']['FontAwesome'] = 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css';
add_filter( 'amp_post_template_data', 'wp_review_add_amp_template_data' );
* Adds custom styles for better-amp plugin.
function wp_review_add_better_amp_custom_styles() {
if ( ! file_exists( WP_REVIEW_DIR . 'public/css/amp.css' ) ) {
better_amp_add_inline_style( file_get_contents( WP_REVIEW_DIR . 'public/css/amp.css' ), 'wp_review_css' );
add_action( 'better-amp/template/enqueue-scripts', 'wp_review_add_better_amp_custom_styles', 100 );
* Adds custom styles for weeblramp plugin.
function wp_review_weeblramp_theme_css( $css ) {
if ( ! file_exists( WP_REVIEW_DIR . 'public/css/amp.css' ) ) {
$css .= file_get_contents( WP_REVIEW_DIR . 'public/css/amp.css' );
add_filter( 'weeblramp_theme_css', 'wp_review_weeblramp_theme_css' );
add_filter( 'weeblramp_the_content', 'wp_review_inject_data' );
// add_filter( 'weeblramp_wpautop_function', '__return_false' );