update($pluginManagerInstance->get_tablename('reviews'), ['highlight' => $highlight], ['id' => $id]); wp_cache_delete('ti-reviews-cache-'.$pluginManagerInstance->getShortName()); } exit; } if (isset($_GET['toggle-hide'])) { check_admin_referer('ti-toggle-hide'); $id = (int)$_GET['toggle-hide']; if ($id) { $hidden = 1; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching if ($wpdb->get_var($wpdb->prepare('SELECT hidden FROM %i WHERE id = %s', $pluginManagerInstance->get_tablename('reviews'), $id))) { $hidden = 0; } // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->update($pluginManagerInstance->get_tablename('reviews'), ['hidden' => $hidden], ['id' => $id]); wp_cache_delete('ti-reviews-cache-'.$pluginManagerInstance->getShortName()); } header('Location: admin.php?page='.esc_attr($_page).'&tab=my-reviews'); exit; } /* Replied flag saving: - Google: comes after source connect - Facebook: we saved internal - other: dont save anything & only show "Reply with ChatGPT" button */ if (isset($_POST['save-reply'])) { check_admin_referer('ti-save-reply'); $id = null; $reply = null; if (isset($_POST['id'])) { $id = (int)$_POST['id']; } $reply = wp_kses_post(wp_unslash($_POST['save-reply'])); if ($id && $reply) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->update($pluginManagerInstance->get_tablename('reviews'), ['reply' => $reply], ['id' => $id]); wp_cache_delete('ti-reviews-cache-'.$pluginManagerInstance->getShortName()); } exit; } if (isset($_POST['save-reply-generated'])) { update_option($pluginManagerInstance->get_option_name('reply-generated'), 1, false); exit; } if (isset($_POST['download_data'])) { check_admin_referer('ti-download-reviews'); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $data = json_decode(wp_unslash($_POST['download_data']), true); if (isset($data['is_new_reviews']) && $data['is_new_reviews']) { if (isset($data['reviews']) && is_array($data['reviews']) && $data['reviews']) { $pluginManagerInstance->save_reviews($data['reviews']); if (!$pluginManagerInstance->getNotificationParam('review-download-finished', 'hidden')) { $pluginManagerInstance->setNotificationParam('review-download-finished', 'active', true); } $pluginManagerInstance->sendNotificationEmail('review-download-finished'); } $pageDetails = $pluginManagerInstance->getPageDetails(); if (isset($data['name'])) { $pageDetails['name'] = $data['name']; if (isset($pageDetails['address'])) { $pageDetails['address'] = $data['address']; } if (isset($pageDetails['avatar_url'])) { $pageDetails['avatar_url'] = $data['avatar_url']; } $pageDetails['rating_number'] = $data['rating_number']; if (isset($data['rating_numbers']) && $data['rating_numbers']) { $pageDetails['rating_numbers'] = $data['rating_numbers']; } if (isset($data['rating_numbers_last']) && $data['rating_numbers_last']) { $pageDetails['rating_numbers_last'] = $data['rating_numbers_last']; } $pageDetails['rating_score'] = $data['rating_score']; update_option($pluginManagerInstance->get_option_name('page-details'), $pageDetails, false); $GLOBALS['wp_object_cache']->delete($pluginManagerInstance->get_option_name('page-details'), 'options'); } if (!$pluginManagerInstance->getNotificationParam('review-download-available', 'hidden')) { $pluginManagerInstance->setNotificationParam('review-download-available', 'do-check', true); $pluginManagerInstance->setNotificationParam('review-download-available', 'active', false); } } else { update_option($pluginManagerInstance->get_option_name('review-download-is-failed'), 1, false); } update_option($pluginManagerInstance->get_option_name('download-timestamp'), time() + (int)$data['next_update_available'], false); exit; } $reviews = $pluginManagerInstance->getReviews(); $isReviewDownloadInProgress = $pluginManagerInstance->is_review_download_in_progress(); function trustindex_plugin_write_rating_stars($score) { global $pluginManagerInstance; if ($pluginManagerInstance->is_ten_scale_rating_platform()) { return '
'. $pluginManagerInstance->formatTenRating($score) .'
'; } $text = ""; $link = "https://cdn.trustindex.io/assets/platform/".ucfirst("google")."/star/"; if (!is_numeric($score)) { return $text; } for ($si = 1; $si <= $score; $si++) { $text .= ''; } $fractional = $score - floor($score); if (0.25 <= $fractional) { if ($fractional < 0.75) { $text .= ''; } else { $text .= ''; } $si++; } for (; $si <= 5; $si++) { $text .= ''; } return $text; } wp_enqueue_style('trustindex-widget-css', 'https://cdn.trustindex.io/assets/widget-presetted-css/4-light-background.css', [], true); wp_enqueue_script('trustindex-review-js', 'https://cdn.trustindex.io/assets/js/trustindex-review.js', [], true, true); wp_add_inline_script('trustindex-review-js', ' jQuery(".ti-review-content").TI_shorten({ "showLines": 2, "lessText": "'. esc_html(__('Show less', 'wp-reviews-plugin-for-google')) .'", "moreText": "'. esc_html(__('Show more', 'wp-reviews-plugin-for-google')) .'", }); jQuery(".ti-review-content").TI_format(); '); $downloadTimestamp = get_option($pluginManagerInstance->get_option_name('download-timestamp'), time()); $pageDetails = $pluginManagerInstance->getPageDetails(); if ($reviewDownloadFailed = get_option($pluginManagerInstance->get_option_name('review-download-is-failed'))) { delete_option($pluginManagerInstance->get_option_name('review-download-is-failed')); } ?>

getPageDetails(); ?> get_option_name('review-download-token')); if (!$reviewDownloadToken) { $reviewDownloadToken = wp_create_nonce('ti-noreg-connect-token'); update_option($pluginManagerInstance->get_option_name('review-download-token'), $reviewDownloadToken, false); } ?>

getProFeatureButton('wp-google-pro')); ?>

getReviewHtml($review); ?> hidden): ?> class="ti-hidden-review">

user); ?>
">rating)); ?> date); ?>
reply) { $state = 'replied'; } $hideReplyButton = false; $hideReplyButton = get_option($pluginManagerInstance->get_option_name('review-download-modal'), 1); ?> hidden): ?> reply): ?> text): ?> hidden): ?> hidden && !$hideReplyButton): ?>
text): ?>

reply); ?>

getShortName() === 'google'): ?>
hidden && $review->text): ?>
/', '', $reviewText)); ?>
highlight): ?>
get_option_name('rate-us-feedback'), 0)): ?>