Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-revie.../includes
File: functions.php
$reviews[ $key ]['total'] += $value;
[500] Fix | Delete
if ( 100 == $value ) {
[501] Fix | Delete
$reviews[ $key ]['positive']++;
[502] Fix | Delete
} else {
[503] Fix | Delete
$reviews[ $key ]['negative']++;
[504] Fix | Delete
}
[505] Fix | Delete
$reviews[ $key ]['count']++;
[506] Fix | Delete
}
[507] Fix | Delete
}
[508] Fix | Delete
[509] Fix | Delete
update_post_meta( $post_id, $post_meta_key, $reviews );
[510] Fix | Delete
return $reviews;
[511] Fix | Delete
}
[512] Fix | Delete
[513] Fix | Delete
[514] Fix | Delete
/**
[515] Fix | Delete
* Clears cached when modify comment.
[516] Fix | Delete
*
[517] Fix | Delete
* @since 3.0.0
[518] Fix | Delete
*
[519] Fix | Delete
* @param WP_Comment $comment Comment object.
[520] Fix | Delete
*/
[521] Fix | Delete
function wp_review_clear_cached_reviews( $comment ) {
[522] Fix | Delete
delete_post_meta( $comment->comment_post_ID, 'wp_review_comment_feature_reviews' );
[523] Fix | Delete
delete_post_meta( $comment->comment_post_ID, 'wp_review_comments_rating_value' );
[524] Fix | Delete
delete_post_meta( $comment->comment_post_ID, 'wp_review_comments_rating_count' );
[525] Fix | Delete
delete_post_meta( $comment->comment_post_ID, 'wp_review_user_feature_reviews' );
[526] Fix | Delete
delete_post_meta( $comment->comment_post_ID, 'wp_review_user_reviews' );
[527] Fix | Delete
delete_post_meta( $comment->comment_post_ID, 'wp_review_review_count' );
[528] Fix | Delete
}
[529] Fix | Delete
[530] Fix | Delete
[531] Fix | Delete
/**
[532] Fix | Delete
* Runs something when change comment status.
[533] Fix | Delete
*
[534] Fix | Delete
* @since 3.0.0
[535] Fix | Delete
*
[536] Fix | Delete
* @param string $new_status New status.
[537] Fix | Delete
* @param string $old_status Old status.
[538] Fix | Delete
* @param WP_Comment $comment Comment object.
[539] Fix | Delete
*/
[540] Fix | Delete
function wp_review_on_change_comment_status( $new_status, $old_status, $comment ) {
[541] Fix | Delete
wp_review_clear_cached_reviews( $comment );
[542] Fix | Delete
}
[543] Fix | Delete
add_action( 'transition_comment_status', 'wp_review_on_change_comment_status', 10, 3 );
[544] Fix | Delete
[545] Fix | Delete
/**
[546] Fix | Delete
* Comments rating callback for array_reduce().
[547] Fix | Delete
*
[548] Fix | Delete
* @param float $carry Rating.
[549] Fix | Delete
* @param object $comment Comment object.
[550] Fix | Delete
* @return float
[551] Fix | Delete
*/
[552] Fix | Delete
function wpreview_comment_ratings_callback( $carry, $comment ) {
[553] Fix | Delete
$rating = get_comment_meta( $comment->comment_ID, WP_REVIEW_COMMENT_RATING_METAKEY, true );
[554] Fix | Delete
$carry += floatval( $rating );
[555] Fix | Delete
return $carry;
[556] Fix | Delete
}
[557] Fix | Delete
[558] Fix | Delete
/**
[559] Fix | Delete
* Visitors rating callback for array_reduce().
[560] Fix | Delete
*
[561] Fix | Delete
* @param float $carry Rating.
[562] Fix | Delete
* @param object $comment Comment object.
[563] Fix | Delete
* @return float
[564] Fix | Delete
*/
[565] Fix | Delete
function wpreview_visitor_ratings_callback( $carry, $comment ) {
[566] Fix | Delete
$rating = get_comment_meta( $comment->comment_ID, WP_REVIEW_VISITOR_RATING_METAKEY, true );
[567] Fix | Delete
$carry += floatval( $rating );
[568] Fix | Delete
return $carry;
[569] Fix | Delete
}
[570] Fix | Delete
[571] Fix | Delete
[572] Fix | Delete
/**
[573] Fix | Delete
* Check if user has reviewed this post previously.
[574] Fix | Delete
*
[575] Fix | Delete
* @param int $post_id Post ID.
[576] Fix | Delete
* @param int $user_id User ID.
[577] Fix | Delete
* @param string $ip User IP.
[578] Fix | Delete
* @param string $type Rating type.
[579] Fix | Delete
* @return bool
[580] Fix | Delete
*/
[581] Fix | Delete
function hasPreviousReview( $post_id, $user_id, $ip, $type = 'any' ) { // phpcs:ignore
[582] Fix | Delete
_deprecated_function( __FUNCTION__, '3.0.0', 'wp_review_has_reviewed' );
[583] Fix | Delete
return wp_review_has_reviewed( $post_id, $user_id, $ip, $type );
[584] Fix | Delete
}
[585] Fix | Delete
[586] Fix | Delete
[587] Fix | Delete
/**
[588] Fix | Delete
* Check if user has reviewed this post previously.
[589] Fix | Delete
*
[590] Fix | Delete
* @since 3.0.0
[591] Fix | Delete
*
[592] Fix | Delete
* @param int $post_id Post ID.
[593] Fix | Delete
* @param int $user_id User ID.
[594] Fix | Delete
* @param string $ip User IP.
[595] Fix | Delete
* @param string $type Rating type.
[596] Fix | Delete
* @return bool
[597] Fix | Delete
*/
[598] Fix | Delete
function wp_review_has_reviewed( $post_id, $user_id, $ip = null, $type = 'any' ) {
[599] Fix | Delete
if ( ! $ip ) {
[600] Fix | Delete
$ip = wp_review_get_user_ip();
[601] Fix | Delete
}
[602] Fix | Delete
[603] Fix | Delete
if ( is_user_logged_in() && wp_review_option( 'multi_reviews_per_account' ) ) {
[604] Fix | Delete
return false; // Allow multiple reviews per account.
[605] Fix | Delete
}
[606] Fix | Delete
[607] Fix | Delete
if ( is_user_logged_in() ) {
[608] Fix | Delete
return wp_review_has_reviewed_by_user_id( $post_id, $user_id, $ip, $type );
[609] Fix | Delete
}
[610] Fix | Delete
[611] Fix | Delete
return wp_review_has_reviewed_by_ip( $post_id, $user_id, $ip, $type );
[612] Fix | Delete
}
[613] Fix | Delete
[614] Fix | Delete
[615] Fix | Delete
/**
[616] Fix | Delete
* Check if user has reviewed this post previously by user id.
[617] Fix | Delete
*
[618] Fix | Delete
* @since 3.0.0
[619] Fix | Delete
*
[620] Fix | Delete
* @param int $post_id Post ID.
[621] Fix | Delete
* @param int $user_id User ID.
[622] Fix | Delete
* @param string $ip User IP.
[623] Fix | Delete
* @param string $type Rating type.
[624] Fix | Delete
* @return bool
[625] Fix | Delete
*/
[626] Fix | Delete
function wp_review_has_reviewed_by_user_id( $post_id, $user_id, $ip, $type = 'any' ) {
[627] Fix | Delete
if ( ! $user_id ) {
[628] Fix | Delete
return false;
[629] Fix | Delete
}
[630] Fix | Delete
$args = array(
[631] Fix | Delete
'post_id' => $post_id,
[632] Fix | Delete
'count' => true,
[633] Fix | Delete
'user_id' => $user_id,
[634] Fix | Delete
);
[635] Fix | Delete
if ( 'any' === $type ) {
[636] Fix | Delete
$args['type_in'] = array( WP_REVIEW_COMMENT_TYPE_COMMENT, WP_REVIEW_COMMENT_TYPE_VISITOR );
[637] Fix | Delete
} else {
[638] Fix | Delete
$args['type'] = $type;
[639] Fix | Delete
}
[640] Fix | Delete
$count = intval( get_comments( $args ) );
[641] Fix | Delete
return $count > 0;
[642] Fix | Delete
}
[643] Fix | Delete
[644] Fix | Delete
[645] Fix | Delete
/**
[646] Fix | Delete
* Check if user has reviewed this post previously by ip address.
[647] Fix | Delete
*
[648] Fix | Delete
* @since 3.0.0
[649] Fix | Delete
*
[650] Fix | Delete
* @param int $post_id Post ID.
[651] Fix | Delete
* @param int $user_id User ID.
[652] Fix | Delete
* @param string $ip User IP.
[653] Fix | Delete
* @param string $type Rating type.
[654] Fix | Delete
* @return bool
[655] Fix | Delete
*/
[656] Fix | Delete
function wp_review_has_reviewed_by_ip( $post_id, $user_id, $ip, $type = 'any' ) {
[657] Fix | Delete
$args = array(
[658] Fix | Delete
'post_id' => $post_id,
[659] Fix | Delete
'count' => true,
[660] Fix | Delete
);
[661] Fix | Delete
if ( 'any' === $type ) {
[662] Fix | Delete
$args['type_in'] = array( WP_REVIEW_COMMENT_TYPE_COMMENT, WP_REVIEW_COMMENT_TYPE_VISITOR );
[663] Fix | Delete
} else {
[664] Fix | Delete
$args['type'] = $type;
[665] Fix | Delete
}
[666] Fix | Delete
set_query_var( 'wp_review_ip', $ip );
[667] Fix | Delete
add_filter( 'comments_clauses', 'wp_review_filter_comment_by_ip' );
[668] Fix | Delete
$count = intval( get_comments( $args ) );
[669] Fix | Delete
remove_filter( 'comments_clauses', 'wp_review_filter_comment_by_ip' );
[670] Fix | Delete
return $count > 0;
[671] Fix | Delete
}
[672] Fix | Delete
[673] Fix | Delete
[674] Fix | Delete
/**
[675] Fix | Delete
* Gets previous review comment.
[676] Fix | Delete
*
[677] Fix | Delete
* @since 3.0.0
[678] Fix | Delete
*
[679] Fix | Delete
* @param WP_Comment $comment Comment object.
[680] Fix | Delete
* @return WP_Comment|false
[681] Fix | Delete
*/
[682] Fix | Delete
function wp_review_get_previous_review_comment( $comment ) {
[683] Fix | Delete
$post_id = $comment->comment_post_ID;
[684] Fix | Delete
$query_args = array(
[685] Fix | Delete
'post_id' => $post_id,
[686] Fix | Delete
'type_in' => array( WP_REVIEW_COMMENT_TYPE_COMMENT ),
[687] Fix | Delete
'meta_key' => WP_REVIEW_COMMENT_RATING_METAKEY,
[688] Fix | Delete
'meta_value' => 0,
[689] Fix | Delete
'meta_compare' => '>',
[690] Fix | Delete
);
[691] Fix | Delete
[692] Fix | Delete
if ( intval( $comment->user_id ) ) {
[693] Fix | Delete
$query_args['user_id'] = $comment->user_id;
[694] Fix | Delete
} else {
[695] Fix | Delete
set_query_var( 'wp_review_ip', $comment->comment_author_IP );
[696] Fix | Delete
add_filter( 'comments_clauses', 'wp_review_filter_comment_by_ip' );
[697] Fix | Delete
}
[698] Fix | Delete
[699] Fix | Delete
$comments = get_comments( $query_args );
[700] Fix | Delete
[701] Fix | Delete
remove_filter( 'comments_clauses', 'wp_review_filter_comment_by_ip' );
[702] Fix | Delete
[703] Fix | Delete
if ( ! $comments ) {
[704] Fix | Delete
return false;
[705] Fix | Delete
}
[706] Fix | Delete
return $comments[0];
[707] Fix | Delete
}
[708] Fix | Delete
[709] Fix | Delete
[710] Fix | Delete
/**
[711] Fix | Delete
* Add the comment type to comment query.
[712] Fix | Delete
*
[713] Fix | Delete
* @param WP_Comment_Query $query Comment query.
[714] Fix | Delete
* @return WP_Comment_Query
[715] Fix | Delete
*/
[716] Fix | Delete
function wp_review_add_comment_type_to_query( WP_Comment_Query $query ) {
[717] Fix | Delete
$commenttype = get_query_var( 'wp_review_commenttype' );
[718] Fix | Delete
if ( 'any' === $commenttype ) {
[719] Fix | Delete
$query->query_vars['type__in'] = array( WP_REVIEW_COMMENT_TYPE_COMMENT, WP_REVIEW_COMMENT_TYPE_VISITOR );
[720] Fix | Delete
} else {
[721] Fix | Delete
$query->query_vars['type'] = $commenttype;
[722] Fix | Delete
}
[723] Fix | Delete
return $query;
[724] Fix | Delete
}
[725] Fix | Delete
[726] Fix | Delete
/**
[727] Fix | Delete
* Add a conditional to filter the comment query by IP.
[728] Fix | Delete
*
[729] Fix | Delete
* @param array $clauses Where clauses.
[730] Fix | Delete
* @return array
[731] Fix | Delete
*/
[732] Fix | Delete
function wp_review_filter_comment_by_ip( array $clauses ) {
[733] Fix | Delete
global $wpdb;
[734] Fix | Delete
$clauses['where'] .= $wpdb->prepare( ' AND comment_author_IP = %s', get_query_var( 'wp_review_ip' ) );
[735] Fix | Delete
return $clauses;
[736] Fix | Delete
}
[737] Fix | Delete
[738] Fix | Delete
/**
[739] Fix | Delete
* Gets previous preview.
[740] Fix | Delete
*
[741] Fix | Delete
* @param int $post_id Post ID.
[742] Fix | Delete
* @param int $user_id User ID.
[743] Fix | Delete
* @param string $ip IP Address.
[744] Fix | Delete
* @param string $type Review type.
[745] Fix | Delete
* @return bool
[746] Fix | Delete
*/
[747] Fix | Delete
function getPreviousReview( $post_id, $user_id, $ip, $type = 'any' ) { // phpcs:ignore
[748] Fix | Delete
if ( is_numeric( $post_id ) && $post_id > 0 ) {
[749] Fix | Delete
$args = array(
[750] Fix | Delete
'post_id' => $post_id,
[751] Fix | Delete
'user_id' => 0,
[752] Fix | Delete
);
[753] Fix | Delete
set_query_var( 'wp_review_commenttype', $type );
[754] Fix | Delete
add_filter( 'pre_get_comments', 'wp_review_add_comment_type_to_query' );
[755] Fix | Delete
if ( $user_id ) {
[756] Fix | Delete
$args['user_id'] = array( $user_id );
[757] Fix | Delete
} else {
[758] Fix | Delete
set_query_var( 'wp_review_ip', $ip );
[759] Fix | Delete
add_filter( 'comments_clauses', 'wp_review_filter_comment_by_ip' );
[760] Fix | Delete
}
[761] Fix | Delete
[762] Fix | Delete
$comment = get_comments( $args );
[763] Fix | Delete
remove_filter( 'pre_get_comments', 'wp_review_add_comment_type_to_query' );
[764] Fix | Delete
remove_filter( 'comments_clauses', 'wp_review_filter_comment_by_ip' );
[765] Fix | Delete
[766] Fix | Delete
if ( ! empty( $comment ) ) {
[767] Fix | Delete
return get_comment_meta( $comment[0]->comment_ID, WP_REVIEW_COMMENT_RATING_METAKEY, true );
[768] Fix | Delete
}
[769] Fix | Delete
}
[770] Fix | Delete
return false;
[771] Fix | Delete
}
[772] Fix | Delete
[773] Fix | Delete
/**
[774] Fix | Delete
* Sets theme defaults.
[775] Fix | Delete
*
[776] Fix | Delete
* @param array $new_options New options.
[777] Fix | Delete
* @param bool $force_change Force changes.
[778] Fix | Delete
*/
[779] Fix | Delete
function wp_review_theme_defaults( $new_options, $force_change = false ) {
[780] Fix | Delete
global $pagenow;
[781] Fix | Delete
$opt_name = 'wp_review_options_' . wp_get_theme();
[782] Fix | Delete
$options = get_option( 'wp_review_options' );
[783] Fix | Delete
if ( empty( $options ) ) {
[784] Fix | Delete
$options = array();
[785] Fix | Delete
}
[786] Fix | Delete
$options_updated = get_option( $opt_name );
[787] Fix | Delete
// If the theme was just activated OR options weren't updated yet.
[788] Fix | Delete
if ( empty( $options_updated ) || $options_updated != $new_options || $force_change || ( isset( $_GET['activated'] ) && 'themes.php' == $pagenow ) ) {
[789] Fix | Delete
update_option( 'wp_review_options', array_merge( $options, $new_options ) );
[790] Fix | Delete
update_option( $opt_name, $new_options );
[791] Fix | Delete
}
[792] Fix | Delete
}
[793] Fix | Delete
[794] Fix | Delete
/**
[795] Fix | Delete
* Gets all image sizes.
[796] Fix | Delete
*
[797] Fix | Delete
* @return array
[798] Fix | Delete
*/
[799] Fix | Delete
function wp_review_get_all_image_sizes() {
[800] Fix | Delete
global $_wp_additional_image_sizes;
[801] Fix | Delete
[802] Fix | Delete
$default_image_sizes = array( 'thumbnail', 'medium', 'large' );
[803] Fix | Delete
[804] Fix | Delete
foreach ( $default_image_sizes as $size ) {
[805] Fix | Delete
$image_sizes[ $size ]['width'] = intval( get_option( "{$size}_size_w" ) );
[806] Fix | Delete
$image_sizes[ $size ]['height'] = intval( get_option( "{$size}_size_h" ) );
[807] Fix | Delete
$image_sizes[ $size ]['crop'] = get_option( "{$size}_crop" ) ? get_option( "{$size}_crop" ) : false;
[808] Fix | Delete
}
[809] Fix | Delete
[810] Fix | Delete
if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) ) {
[811] Fix | Delete
$image_sizes = array_merge( $image_sizes, $_wp_additional_image_sizes );
[812] Fix | Delete
}
[813] Fix | Delete
[814] Fix | Delete
return $image_sizes;
[815] Fix | Delete
}
[816] Fix | Delete
[817] Fix | Delete
/**
[818] Fix | Delete
* Exclude review-type comments from being included in the comment query.
[819] Fix | Delete
*
[820] Fix | Delete
* @param WP_Comment_Query $query Comment query.
[821] Fix | Delete
*/
[822] Fix | Delete
function wp_review_exclude_review_comments( WP_Comment_Query $query ) {
[823] Fix | Delete
if ( ! is_admin() && ( WP_REVIEW_COMMENT_TYPE_VISITOR !== $query->query_vars['type'] && ! in_array( WP_REVIEW_COMMENT_TYPE_VISITOR, (array) $query->query_vars['type__in'] ) ) ) {
[824] Fix | Delete
$query->query_vars['type__not_in'] = array_merge(
[825] Fix | Delete
is_array( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(),
[826] Fix | Delete
array( WP_REVIEW_COMMENT_TYPE_VISITOR )
[827] Fix | Delete
);
[828] Fix | Delete
}
[829] Fix | Delete
}
[830] Fix | Delete
add_action( 'pre_get_comments', 'wp_review_exclude_review_comments', 15 );
[831] Fix | Delete
[832] Fix | Delete
/**
[833] Fix | Delete
* Add "Reviews" to comments table view.
[834] Fix | Delete
*
[835] Fix | Delete
* @param array $comment_types Comment types.
[836] Fix | Delete
* @return mixed
[837] Fix | Delete
*/
[838] Fix | Delete
function wp_review_add_to_comment_table_dropdown( $comment_types ) {
[839] Fix | Delete
$comment_types[ WP_REVIEW_COMMENT_TYPE_COMMENT ] = __( 'Comment Reviews', 'wp-review' );
[840] Fix | Delete
$comment_types[ WP_REVIEW_COMMENT_TYPE_VISITOR ] = __( 'Visitor Reviews', 'wp-review' );
[841] Fix | Delete
[842] Fix | Delete
return $comment_types;
[843] Fix | Delete
}
[844] Fix | Delete
add_filter( 'admin_comment_types_dropdown', 'wp_review_add_to_comment_table_dropdown' );
[845] Fix | Delete
[846] Fix | Delete
/**
[847] Fix | Delete
* Gets user rating type.
[848] Fix | Delete
*
[849] Fix | Delete
* @since 3.0.0 Combine with global option.
[850] Fix | Delete
*
[851] Fix | Delete
* @param int $post_id Post ID.
[852] Fix | Delete
*
[853] Fix | Delete
* @return string
[854] Fix | Delete
*
[855] Fix | Delete
* 0 - Disabled
[856] Fix | Delete
* 1 - Visitor Rating Only
[857] Fix | Delete
* 2 - Comment Rating Only
[858] Fix | Delete
* 3 - Both
[859] Fix | Delete
*/
[860] Fix | Delete
function wp_review_get_user_rating_setup( $post_id ) {
[861] Fix | Delete
$default = wp_review_option( 'default_user_review_type', WP_REVIEW_REVIEW_DISABLED );
[862] Fix | Delete
$user_reviews = get_post_meta( $post_id, 'wp_review_userReview', true );
[863] Fix | Delete
$enabled = '' === $user_reviews ? $default : (int) $user_reviews;
[864] Fix | Delete
if ( is_array( $user_reviews ) ) {
[865] Fix | Delete
$enabled = (int) $user_reviews[0];
[866] Fix | Delete
}
[867] Fix | Delete
[868] Fix | Delete
// Reviews through comments: enabled by default.
[869] Fix | Delete
$review_through_comment = get_post_meta( $post_id, 'wp_review_through_comment', true );
[870] Fix | Delete
$custom_fields = get_post_custom();
[871] Fix | Delete
if ( ! isset( $custom_fields['wp_review_through_comment'] ) ) {
[872] Fix | Delete
$review_through_comment = 0;
[873] Fix | Delete
}
[874] Fix | Delete
// Compatibility with the old option.
[875] Fix | Delete
if ( 1 === $enabled ) {
[876] Fix | Delete
if ( $review_through_comment ) {
[877] Fix | Delete
$enabled = WP_REVIEW_REVIEW_ALLOW_BOTH;
[878] Fix | Delete
} else {
[879] Fix | Delete
$enabled = WP_REVIEW_REVIEW_VISITOR_ONLY;
[880] Fix | Delete
}
[881] Fix | Delete
}
[882] Fix | Delete
[883] Fix | Delete
return $enabled;
[884] Fix | Delete
}
[885] Fix | Delete
[886] Fix | Delete
/**
[887] Fix | Delete
* Exclude visitor ratings when updating a post's comment count.
[888] Fix | Delete
*
[889] Fix | Delete
* @param int $post_id Post ID.
[890] Fix | Delete
* @param object $new New comment.
[891] Fix | Delete
* @param object $old Old comment.
[892] Fix | Delete
*
[893] Fix | Delete
* @internal param $comment_id
[894] Fix | Delete
* @internal param $comment
[895] Fix | Delete
*/
[896] Fix | Delete
function wp_review_exclude_visitor_review_count( $post_id, $new, $old ) {
[897] Fix | Delete
global $wpdb;
[898] Fix | Delete
$count = get_comments(
[899] Fix | Delete
array(
[900] Fix | Delete
'type__not_in' => array( WP_REVIEW_COMMENT_TYPE_VISITOR ),
[901] Fix | Delete
'post_id' => $post_id,
[902] Fix | Delete
'count' => true,
[903] Fix | Delete
)
[904] Fix | Delete
);
[905] Fix | Delete
$wpdb->update( $wpdb->posts, array( 'comment_count' => $count ), array( 'ID' => $post_id ) );
[906] Fix | Delete
[907] Fix | Delete
// Update user review count.
[908] Fix | Delete
mts_get_post_reviews( $post_id, true );
[909] Fix | Delete
[910] Fix | Delete
clean_post_cache( $post_id );
[911] Fix | Delete
}
[912] Fix | Delete
add_action( 'wp_update_comment_count', 'wp_review_exclude_visitor_review_count', 10, 3 );
[913] Fix | Delete
[914] Fix | Delete
/**
[915] Fix | Delete
* Get the schema type of a review.
[916] Fix | Delete
*
[917] Fix | Delete
* @param int $post_id Post ID.
[918] Fix | Delete
* @return string
[919] Fix | Delete
*/
[920] Fix | Delete
function wp_review_get_review_schema( $post_id ) {
[921] Fix | Delete
$schema = get_post_meta( $post_id, 'wp_review_schema', true );
[922] Fix | Delete
$schemas = wp_review_schema_types();
[923] Fix | Delete
[924] Fix | Delete
if ( empty( $schema ) || ! isset( $schemas[ $schema ] ) ) {
[925] Fix | Delete
$schema = wp_review_option( 'default_schema_type', 'none' );
[926] Fix | Delete
if ( in_array( $schema, array_keys( wp_review_get_deprecated_schema_types() ) ) ) {
[927] Fix | Delete
$schema = 'none';
[928] Fix | Delete
}
[929] Fix | Delete
}
[930] Fix | Delete
[931] Fix | Delete
return $schema;
[932] Fix | Delete
}
[933] Fix | Delete
[934] Fix | Delete
/**
[935] Fix | Delete
* Get the IP of the current user.
[936] Fix | Delete
*
[937] Fix | Delete
* @return string
[938] Fix | Delete
*/
[939] Fix | Delete
function wp_review_get_user_ip() {
[940] Fix | Delete
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
[941] Fix | Delete
$ip = $_SERVER['HTTP_CLIENT_IP'];
[942] Fix | Delete
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
[943] Fix | Delete
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
[944] Fix | Delete
} else {
[945] Fix | Delete
$ip = $_SERVER['REMOTE_ADDR'];
[946] Fix | Delete
}
[947] Fix | Delete
[948] Fix | Delete
return $ip;
[949] Fix | Delete
}
[950] Fix | Delete
[951] Fix | Delete
/**
[952] Fix | Delete
* Get the HTML for user reviews in review box.
[953] Fix | Delete
*
[954] Fix | Delete
* @param int $post_id Post ID.
[955] Fix | Delete
* @param bool $votable Voteable or not.
[956] Fix | Delete
* @param bool $force_display Force display or not.
[957] Fix | Delete
* @return string
[958] Fix | Delete
*/
[959] Fix | Delete
function wp_review_user_review( $post_id, $votable = true, $force_display = false ) {
[960] Fix | Delete
$review = '';
[961] Fix | Delete
[962] Fix | Delete
if ( ! $force_display && ! in_array( wp_review_get_user_rating_setup( $post_id ), array( WP_REVIEW_REVIEW_VISITOR_ONLY, WP_REVIEW_REVIEW_ALLOW_BOTH ) ) ) {
[963] Fix | Delete
return $review;
[964] Fix | Delete
}
[965] Fix | Delete
[966] Fix | Delete
$allowed_class = 'allowed-to-rate';
[967] Fix | Delete
$has_not_rated_class = ' has-not-rated-yet';
[968] Fix | Delete
$post_reviews = mts_get_post_reviews( $post_id );
[969] Fix | Delete
$user_total = $post_reviews['rating'];
[970] Fix | Delete
$users_reviews_count = $post_reviews['count'];
[971] Fix | Delete
$positive_rating = $post_reviews['positive_count'];
[972] Fix | Delete
$negative_rating = $post_reviews['negative_count'];
[973] Fix | Delete
$total = get_post_meta( $post_id, 'wp_review_total', true );
[974] Fix | Delete
$type = get_post_meta( $post_id, 'wp_review_user_review_type', true );
[975] Fix | Delete
[976] Fix | Delete
$options = get_option( 'wp_review_options' );
[977] Fix | Delete
$colors = wp_review_get_colors( $post_id );
[978] Fix | Delete
$color = $colors['color'];
[979] Fix | Delete
[980] Fix | Delete
$user_id = '';
[981] Fix | Delete
if ( is_user_logged_in() ) {
[982] Fix | Delete
$user_id = get_current_user_id();
[983] Fix | Delete
}
[984] Fix | Delete
[985] Fix | Delete
if ( '' == $user_total ) {
[986] Fix | Delete
$user_total = '0.0';
[987] Fix | Delete
}
[988] Fix | Delete
$value = $user_total;
[989] Fix | Delete
[990] Fix | Delete
if ( ! $votable || wp_review_has_reviewed( $post_id, $user_id, wp_review_get_user_ip(), WP_REVIEW_COMMENT_TYPE_VISITOR ) || ( ! is_user_logged_in() && ! empty( $options['registered_only'] ) ) ) {
[991] Fix | Delete
$has_not_rated_class = '';
[992] Fix | Delete
}
[993] Fix | Delete
[994] Fix | Delete
$class = $allowed_class . $has_not_rated_class;
[995] Fix | Delete
[996] Fix | Delete
$template = mts_get_template_path( $type, 'star-output' );
[997] Fix | Delete
set_query_var( 'rating', compact( 'value', 'users_reviews_count', 'user_id', 'class', 'post_id', 'color', 'colors', 'positive_rating', 'negative_rating' ) );
[998] Fix | Delete
ob_start();
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function