WP Review - Version 5.0.7

Version Description

Download this release

Release Info

Developer MyThemeShop
Plugin Icon 128x128 WP Review
Version 5.0.7
Comparing to
See all releases

Code changes from version 5.0.6 to 5.0.7

admin/assets/js/admin.js CHANGED
@@ -237,6 +237,12 @@
237
}
238
});
239
240
/**
241
* Toggle meta box
242
*/
237
}
238
});
239
240
+ $( document ).on( 'change', '#wp-review-userReview-disable', function() {
241
+ if ( $( this ).prop( 'checked' ) ) {
242
+ $( '#wp_review_rating_schema' ).val( 'author' ).trigger( 'change' );
243
+ }
244
+ });
245
+
246
/**
247
* Toggle meta box
248
*/
includes/functions.php CHANGED
@@ -749,10 +749,10 @@ add_filter( 'admin_comment_types_dropdown', 'wp_review_add_to_comment_table_drop
749
*/
750
function wp_review_get_user_rating_setup( $post_id ) {
751
$default = wp_review_option( 'default_user_review_type', WP_REVIEW_REVIEW_DISABLED );
752
- $user_reviews = (int) get_post_meta( $post_id, 'wp_review_userReview', true );
753
- $enabled = ! $user_reviews ? $default : $user_reviews;
754
if ( is_array( $user_reviews ) ) {
755
- $enabled = $user_reviews[0];
756
}
757
758
// Reviews through comments: enabled by default.
@@ -1503,7 +1503,7 @@ function wp_review_get_review_data( $post_id = null, $args = array() ) {
1503
1504
$data['show_schema_data'] = get_post_meta( $post_id, 'wp_review_show_schema_data', true );
1505
1506
- $data['rating_schema'] = get_post_meta( $post_id, 'wp_review_rating_schema', true );
1507
1508
$data['links'] = wp_review_get_review_links( $post_id );
1509
@@ -1903,40 +1903,40 @@ function wp_review_get_schema( $review ) {
1903
1904
$output = '';
1905
1906
- $nesting_mode = apply_filters( 'wp_review_schema_nesting_mode', 'type' );// type, rating, none
1907
1908
- // Force rating nesting in certain types ( weird results in testing tool otherwise )
1909
if ( in_array( $review['schema'], apply_filters( 'wp_review_schema_force_nested_rating_types', array( 'Movie', 'Book' ) ) ) ) {
1910
$nesting_mode = 'rating';
1911
}
1912
1913
- // If type requires nested aggregateRating don't nest it in aggregateRating
1914
- if ( in_array( $review['schema'], apply_filters( 'wp_review_schema_force_nested_user_rating_types', array('SoftwareApplication', 'Recipe') ) ) && in_array( $review['rating_schema'], array( 'visitors' ) ) ) {
1915
$nesting_mode = 'rating';
1916
}
1917
1918
switch ( $nesting_mode ) {
1919
1920
- case 'type': // schema.org typed element ( Movie, Recipe, etc) nested in review/aggregateRating type
1921
if ( in_array( $review['rating_schema'], array( 'visitors' ) ) ) {
1922
$output .= wp_review_get_schema_user_rating( $review, true );
1923
} else {
1924
$output .= wp_review_get_schema_review_rating( $review, true );
1925
}
1926
- break;
1927
1928
- case 'rating': // review/aggregateRating type nested in specific type ( Movie, Recipe, etc)
1929
$output .= wp_review_get_schema_type( $review, true );
1930
- break;
1931
1932
- case 'none': // separated reviewed item type ( Movie, Recipe, etc) and review/aggregateRating
1933
$output .= wp_review_get_schema_type( $review );
1934
if ( in_array( $review['rating_schema'], array( 'visitors' ) ) ) {
1935
$output .= wp_review_get_schema_user_rating( $review );
1936
} else {
1937
$output .= wp_review_get_schema_review_rating( $review );
1938
}
1939
- break;
1940
}
1941
1942
return apply_filters( 'wp_review_get_schema', $output, $review );
@@ -1945,11 +1945,11 @@ function wp_review_get_schema( $review ) {
1945
1946
function wp_review_get_schema_type( $review, $nested_rating = false ) {
1947
1948
- if ( empty( $review['schema'] ) || 'Thing' === $review['schema'] || !isset( $review['schema_data'] ) ) return;
1949
1950
$args = array(
1951
- "@context" => "http://schema.org",
1952
- "@type" => $review['schema'],
1953
);
1954
1955
$ldjson_data = wp_review_get_ldjson_data( $review['schema'], $review['schema_data'][ $review['schema'] ], $review );
@@ -1963,16 +1963,16 @@ function wp_review_get_schema_type( $review, $nested_rating = false ) {
1963
if ( ! empty( $data['omit'] ) ) {
1964
continue;
1965
}
1966
- if ( isset( $review['schema_data'][ $review['schema'] ][ $data['name'] ] ) && !empty( $review['schema_data'][ $review['schema'] ][ $data['name'] ] ) ) {
1967
if ( isset( $data['multiline'] ) && $data['multiline'] ) {
1968
- $review['schema_data'][ $review['schema'] ][ $data['name'] ] = preg_split('/\r\n|[\r\n]/', $review['schema_data'][ $review['schema'] ][ $data['name'] ] );
1969
}
1970
if ( isset( $data['part_of'] ) ) {
1971
$args[ $data['part_of'] ]["@type"] = $data['@type'];
1972
if ( 'image' === $data['type'] ) {
1973
$args[ $data['part_of'] ][ $data['name'] ] = $review['schema_data'][ $review['schema'] ][ $data['name'] ]['url'];
1974
} elseif ( in_array( $data['name'], apply_filters( 'wp_reviev_schema_ISO_8601_duration_items', array( 'prepTime', 'cookTime', 'totalTime', 'duration' ) ) ) ) {
1975
- $args[ $data['part_of'] ][ $data['name'] ] = 'PT'.$review['schema_data'][ $review['schema'] ][ $data['name'] ];
1976
} else {
1977
$args[ $data['part_of'] ][ $data['name'] ] = $review['schema_data'][ $review['schema'] ][ $data['name'] ];
1978
}
@@ -1980,7 +1980,7 @@ function wp_review_get_schema_type( $review, $nested_rating = false ) {
1980
if ( 'image' === $data['type'] ) {
1981
$args[ $data['name'] ] = $review['schema_data'][ $review['schema'] ][ $data['name'] ]['url'];
1982
} elseif ( in_array( $data['name'], apply_filters( 'wp_reviev_schema_ISO_8601_duration_items', array( 'prepTime', 'cookTime', 'totalTime', 'duration' ) ) ) ) {
1983
- $args[ $data['name'] ] = 'PT'.$review['schema_data'][ $review['schema'] ][ $data['name'] ];
1984
} else {
1985
$args[ $data['name'] ] = $review['schema_data'][ $review['schema'] ][ $data['name'] ];
1986
}
@@ -2033,25 +2033,25 @@ function wp_review_get_schema_review_rating( $review, $nested_item = false ) {
2033
$item_reviewed = wp_review_get_schema_nested_item_args( $review );
2034
} else {
2035
$item_reviewed = array(
2036
- "@type" => "Thing",
2037
- "name" => esc_html( wp_review_get_reviewed_item_name( $review ) )
2038
);
2039
}
2040
2041
$args = array(
2042
- "@context" => "http://schema.org",
2043
- "@type" => "Review",
2044
- "itemReviewed" => $item_reviewed,
2045
- "reviewRating" => array(
2046
- "@type" => "Rating",
2047
- "ratingValue" => $review['total'],
2048
- "bestRating" => $wp_review_rating_types[ $review['type'] ]['max']
2049
),
2050
- "author" => array(
2051
- "@type" => "Person",
2052
- "name" => esc_html( $review['author'] )
2053
),
2054
- "reviewBody" => esc_html( $review['desc'] )
2055
);
2056
2057
$args = apply_filters( 'wp_review_get_schema_review_rating_args', $args, $review );
@@ -2087,7 +2087,7 @@ function wp_review_get_schema_user_rating( $review, $nested_item = false ) {
2087
'@context' => 'http://schema.org',
2088
'@type' => 'aggregateRating',
2089
'itemReviewed' => $item_reviewed,
2090
- 'ratingValue' => wp_review_normalize_rating_value( $total, $review['type'] ),
2091
'bestRating' => $wp_review_rating_types[ $review['user_review_type'] ]['max'],
2092
'ratingCount' => $count,
2093
);
@@ -2126,9 +2126,9 @@ function wp_review_get_schema_nested_user_rating_args( $review ) {
2126
if ( 0 < (int) $review['user_review_count'] ) {
2127
$args = array(
2128
'@type' => 'aggregateRating',
2129
- 'ratingValue' => wp_review_normalize_rating_value( $review['user_review_total'], $review['type'] ),
2130
'bestRating' => $wp_review_rating_types[ $review['user_review_type'] ]['max'],
2131
- 'ratingCount' => $review['user_review_count']
2132
);
2133
}
2134
@@ -2139,17 +2139,17 @@ function wp_review_get_schema_nested_review_args( $review ) {
2139
global $wp_review_rating_types;
2140
2141
$args = array(
2142
- "@type" => "Review",
2143
- "reviewRating" => array(
2144
- "@type" => "Rating",
2145
- "ratingValue" => $review['total'],
2146
- "bestRating" => $wp_review_rating_types[ $review['type'] ]['max'],
2147
),
2148
- "author" => array(
2149
- "@type" => "Person",
2150
- "name" => esc_html( $review['author'] )
2151
),
2152
- "reviewBody" => esc_html( $review['desc'] )
2153
);
2154
2155
return apply_filters( 'wp_review_get_schema_nested_review_args', $args, $review );
@@ -2327,7 +2327,10 @@ function wp_review_is_enable( $post_id = null ) {
2327
function wp_review_get_rating_schema( $post_id ) {
2328
$value = get_post_meta( $post_id, 'wp_review_rating_schema', true );
2329
if ( '' === $value ) {
2330
- $value = 'visitors';
2331
}
2332
return $value;
2333
}
@@ -2955,9 +2958,7 @@ function wp_review_normalize_rating_value( $value, $type ) {
2955
if ( ! $rating_type ) {
2956
return $value;
2957
}
2958
- $value = floatval( $value );
2959
- $num = pow( 10, $rating_type['decimals'] );
2960
- return round( $value * $num ) / $num;
2961
}
2962
2963
749
*/
750
function wp_review_get_user_rating_setup( $post_id ) {
751
$default = wp_review_option( 'default_user_review_type', WP_REVIEW_REVIEW_DISABLED );
752
+ $user_reviews = get_post_meta( $post_id, 'wp_review_userReview', true );
753
+ $enabled = '' === $user_reviews ? $default : (int) $user_reviews;
754
if ( is_array( $user_reviews ) ) {
755
+ $enabled = (int) $user_reviews[0];
756
}
757
758
// Reviews through comments: enabled by default.
1503
1504
$data['show_schema_data'] = get_post_meta( $post_id, 'wp_review_show_schema_data', true );
1505
1506
+ $data['rating_schema'] = wp_review_get_rating_schema( $post_id );
1507
1508
$data['links'] = wp_review_get_review_links( $post_id );
1509
1903
1904
$output = '';
1905
1906
+ $nesting_mode = apply_filters( 'wp_review_schema_nesting_mode', 'type' ); // type, rating, none.
1907
1908
+ // Force rating nesting in certain types ( weird results in testing tool otherwise ).
1909
if ( in_array( $review['schema'], apply_filters( 'wp_review_schema_force_nested_rating_types', array( 'Movie', 'Book' ) ) ) ) {
1910
$nesting_mode = 'rating';
1911
}
1912
1913
+ // If type requires nested aggregateRating don't nest it in aggregateRating.
1914
+ if ( in_array( $review['schema'], apply_filters( 'wp_review_schema_force_nested_user_rating_types', array( 'SoftwareApplication', 'Recipe' ) ) ) && in_array( $review['rating_schema'], array( 'visitors' ) ) ) {
1915
$nesting_mode = 'rating';
1916
}
1917
1918
switch ( $nesting_mode ) {
1919
1920
+ case 'type': // schema.org typed element ( Movie, Recipe, etc) nested in review/aggregateRating type.
1921
if ( in_array( $review['rating_schema'], array( 'visitors' ) ) ) {
1922
$output .= wp_review_get_schema_user_rating( $review, true );
1923
} else {
1924
$output .= wp_review_get_schema_review_rating( $review, true );
1925
}
1926
+ break;
1927
1928
+ case 'rating': // review/aggregateRating type nested in specific type ( Movie, Recipe, etc).
1929
$output .= wp_review_get_schema_type( $review, true );
1930
+ break;
1931
1932
+ case 'none': // separated reviewed item type ( Movie, Recipe, etc) and review/aggregateRating.
1933
$output .= wp_review_get_schema_type( $review );
1934
if ( in_array( $review['rating_schema'], array( 'visitors' ) ) ) {
1935
$output .= wp_review_get_schema_user_rating( $review );
1936
} else {
1937
$output .= wp_review_get_schema_review_rating( $review );
1938
}
1939
+ break;
1940
}
1941
1942
return apply_filters( 'wp_review_get_schema', $output, $review );
1945
1946
function wp_review_get_schema_type( $review, $nested_rating = false ) {
1947
1948
+ if ( empty( $review['schema'] ) || 'Thing' === $review['schema'] || ! isset( $review['schema_data'] ) ) return;
1949
1950
$args = array(
1951
+ '@context' => 'http://schema.org',
1952
+ '@type' => $review['schema'],
1953
);
1954
1955
$ldjson_data = wp_review_get_ldjson_data( $review['schema'], $review['schema_data'][ $review['schema'] ], $review );
1963
if ( ! empty( $data['omit'] ) ) {
1964
continue;
1965
}
1966
+ if ( isset( $review['schema_data'][ $review['schema'] ][ $data['name'] ] ) && ! empty( $review['schema_data'][ $review['schema'] ][ $data['name'] ] ) ) {
1967
if ( isset( $data['multiline'] ) && $data['multiline'] ) {
1968
+ $review['schema_data'][ $review['schema'] ][ $data['name'] ] = preg_split( '/\r\n|[\r\n]/', $review['schema_data'][ $review['schema'] ][ $data['name'] ] );
1969
}
1970
if ( isset( $data['part_of'] ) ) {
1971
$args[ $data['part_of'] ]["@type"] = $data['@type'];
1972
if ( 'image' === $data['type'] ) {
1973
$args[ $data['part_of'] ][ $data['name'] ] = $review['schema_data'][ $review['schema'] ][ $data['name'] ]['url'];
1974
} elseif ( in_array( $data['name'], apply_filters( 'wp_reviev_schema_ISO_8601_duration_items', array( 'prepTime', 'cookTime', 'totalTime', 'duration' ) ) ) ) {
1975
+ $args[ $data['part_of'] ][ $data['name'] ] = 'PT' . $review['schema_data'][ $review['schema'] ][ $data['name'] ];
1976
} else {
1977
$args[ $data['part_of'] ][ $data['name'] ] = $review['schema_data'][ $review['schema'] ][ $data['name'] ];
1978
}
1980
if ( 'image' === $data['type'] ) {
1981
$args[ $data['name'] ] = $review['schema_data'][ $review['schema'] ][ $data['name'] ]['url'];
1982
} elseif ( in_array( $data['name'], apply_filters( 'wp_reviev_schema_ISO_8601_duration_items', array( 'prepTime', 'cookTime', 'totalTime', 'duration' ) ) ) ) {
1983
+ $args[ $data['name'] ] = 'PT' . $review['schema_data'][ $review['schema'] ][ $data['name'] ];
1984
} else {
1985
$args[ $data['name'] ] = $review['schema_data'][ $review['schema'] ][ $data['name'] ];
1986
}
2033
$item_reviewed = wp_review_get_schema_nested_item_args( $review );
2034
} else {
2035
$item_reviewed = array(
2036
+ '@type' => 'Thing',
2037
+ 'name' => esc_html( wp_review_get_reviewed_item_name( $review ) ),
2038
);
2039
}
2040
2041
$args = array(
2042
+ '@context' => 'http://schema.org',
2043
+ '@type' => 'Review',
2044
+ 'itemReviewed' => $item_reviewed,
2045
+ 'reviewRating' => array(
2046
+ '@type' => 'Rating',
2047
+ 'ratingValue' => (string) wp_review_normalize_rating_value( $review['total'], $review['type'] ),
2048
+ 'bestRating' => $wp_review_rating_types[ $review['type'] ]['max'],
2049
),
2050
+ 'author' => array(
2051
+ '@type' => 'Person',
2052
+ 'name' => esc_html( $review['author'] ),
2053
),
2054
+ 'reviewBody' => esc_html( $review['desc'] ),
2055
);
2056
2057
$args = apply_filters( 'wp_review_get_schema_review_rating_args', $args, $review );
2087
'@context' => 'http://schema.org',
2088
'@type' => 'aggregateRating',
2089
'itemReviewed' => $item_reviewed,
2090
+ 'ratingValue' => (string) wp_review_normalize_rating_value( $total, $review['type'] ),
2091
'bestRating' => $wp_review_rating_types[ $review['user_review_type'] ]['max'],
2092
'ratingCount' => $count,
2093
);
2126
if ( 0 < (int) $review['user_review_count'] ) {
2127
$args = array(
2128
'@type' => 'aggregateRating',
2129
+ 'ratingValue' => (string) wp_review_normalize_rating_value( $review['user_review_total'], $review['type'] ),
2130
'bestRating' => $wp_review_rating_types[ $review['user_review_type'] ]['max'],
2131
+ 'ratingCount' => $review['user_review_count'],
2132
);
2133
}
2134
2139
global $wp_review_rating_types;
2140
2141
$args = array(
2142
+ '@type' => 'Review',
2143
+ 'reviewRating' => array(
2144
+ '@type' => 'Rating',
2145
+ 'ratingValue' => (string) wp_review_normalize_rating_value( $review['total'], $review['type'] ),
2146
+ 'bestRating' => $wp_review_rating_types[ $review['type'] ]['max'],
2147
),
2148
+ 'author' => array(
2149
+ '@type' => 'Person',
2150
+ 'name' => esc_html( $review['author'] ),
2151
),
2152
+ 'reviewBody' => esc_html( $review['desc'] ),
2153
);
2154
2155
return apply_filters( 'wp_review_get_schema_nested_review_args', $args, $review );
2327
function wp_review_get_rating_schema( $post_id ) {
2328
$value = get_post_meta( $post_id, 'wp_review_rating_schema', true );
2329
if ( '' === $value ) {
2330
+ $value = 'author';
2331
+ }
2332
+ if ( wp_review_get_user_rating_setup( $post_id ) == WP_REVIEW_REVIEW_DISABLED ) {
2333
+ $value = 'author';
2334
}
2335
return $value;
2336
}
2958
if ( ! $rating_type ) {
2959
return $value;
2960
}
2961
+ return round( floatval( $value ), $rating_type['decimals'] );
2962
}
2963
2964
readme.txt CHANGED
@@ -4,7 +4,7 @@ Creator's website link: http://mythemeshop.com/plugins/wp-review/
4
Tags: review, wp review, rating, wp rating, user rating, google rating, star rating, product review
5
Requires at least: 4.0
6
Tested up to: 4.9.8
7
- Stable tag: 5.0.6
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -103,10 +103,14 @@ Please disable all plugins and check if rating is working properly. Then you can
103
104
== Changelog ==
105
106
= v5.0.6 (Sep 24, 2018) =
107
* Fixed few global settings were getting applied in the single post
108
* Changed rating color to yellow for all the backend data
109
- * Fixed small bug related to extra semicolon
110
111
= v5.0.5 (Sep 19, 2018) =
112
* Fixed colorpicker conflict with Avada theme
4
Tags: review, wp review, rating, wp rating, user rating, google rating, star rating, product review
5
Requires at least: 4.0
6
Tested up to: 4.9.8
7
+ Stable tag: 5.0.7
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
103
104
== Changelog ==
105
106
+ = v5.0.7 (Sep 29, 2018) =
107
+ * Fixed decimal issue in the total rating value of schema data
108
+ * Fixed author rating schema issue in the old posts (if visitor rating is disabled)
109
+
110
= v5.0.6 (Sep 24, 2018) =
111
* Fixed few global settings were getting applied in the single post
112
* Changed rating color to yellow for all the backend data
113
+ * Fixed small bug related to extra semicolon
114
115
= v5.0.5 (Sep 19, 2018) =
116
* Fixed colorpicker conflict with Avada theme
wp-review.php CHANGED
@@ -3,7 +3,7 @@
3
* Plugin Name: WP Review
4
* Plugin URI: http://mythemeshop.com/plugins/wp-review/
5
* Description: Create reviews! Choose from stars, percentages or points for review scores. Supports Retina Display, WPMU and Unlimited Color Schemes.
6
- * Version: 5.0.6
7
* Author: MyThemeShop
8
* Author URI: http://mythemeshop.com/
9
* Text Domain: wp-review
@@ -45,7 +45,7 @@ if ( version_compare( phpversion(), '5.6', '<' ) ) {
45
}
46
47
/* Plugin version */
48
- define( 'WP_REVIEW_PLUGIN_VERSION', '5.0.6' );
49
50
/* Sets the custom db table name. */
51
define( 'MTS_WP_REVIEW_DB_TABLE', 'mts_wp_reviews' );
3
* Plugin Name: WP Review
4
* Plugin URI: http://mythemeshop.com/plugins/wp-review/
5
* Description: Create reviews! Choose from stars, percentages or points for review scores. Supports Retina Display, WPMU and Unlimited Color Schemes.
6
+ * Version: 5.0.7
7
* Author: MyThemeShop
8
* Author URI: http://mythemeshop.com/
9
* Text Domain: wp-review
45
}
46
47
/* Plugin version */
48
+ define( 'WP_REVIEW_PLUGIN_VERSION', '5.0.7' );
49
50
/* Sets the custom db table name. */
51
define( 'MTS_WP_REVIEW_DB_TABLE', 'mts_wp_reviews' );