Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
pryley committed Oct 19, 2024
1 parent 256e075 commit d55b685
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions config/integrations/woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
'label' => _x('Product Sorting', 'admin-text', 'site-reviews'),
'options' => [
'' => _x('Average Rating', 'admin-text', 'site-reviews'),
'bayesian' => _x('Bayesian Average Rating', 'admin-text', 'site-reviews'),
'bayesian' => _x('Bayesian Ranking', 'admin-text', 'site-reviews'),
],
'sanitizer' => 'text',
'tooltip' => _x('This is the method used to sort products by rating on the shop page.', 'admin-text', 'site-reviews'),
Expand All @@ -83,7 +83,7 @@
'depends_on' => [
'settings.integrations.woocommerce.enabled' => ['yes'],
],
'label' => _x('Display empty ratings?', 'admin-text', 'site-reviews'),
'label' => _x('Display Empty Ratings?', 'admin-text', 'site-reviews'),
'sanitizer' => 'text',
'tooltip' => _x('This will display the rating stars even if the product has no reviews.', 'admin-text', 'site-reviews'),
'type' => 'yes_no',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public function renderLoopRating(): void
return;
}
$ratings = glsr_get_ratings(['assigned_posts' => 'post_id']);
if (0 >= $ratings->average && 'no' === glsr_get_option('integrations.woocommerce.display_empty')) {
if (0 >= $ratings->average && !glsr_get_option('integrations.woocommerce.display_empty', false, 'bool')) {
return;
}
glsr(Template::class)->render('templates/woocommerce/loop/rating', [
Expand Down Expand Up @@ -399,7 +399,7 @@ public function renderTitleRating(): void
{
global $product;
$ratings = glsr_get_ratings(['assigned_posts' => 'post_id']);
if (0 >= $ratings->average && 'no' === glsr_get_option('integrations.woocommerce.display_empty')) {
if (0 >= $ratings->average && !glsr_get_option('integrations.woocommerce.display_empty', false, 'bool')) {
return;
}
glsr(Template::class)->render('templates/woocommerce/rating', [
Expand Down
30 changes: 15 additions & 15 deletions plugin/Shortcodes/SiteReviewsFormShortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ public function loginLink(): string
]);
}

public function loginOrRegister(): string
{
$loginText = sprintf(__('You must be %s to submit a review.', 'site-reviews'), $this->loginLink());
$registerLink = $this->registerLink();
$registerText = '';
if (glsr_get_option('general.require.register', false, 'bool') && !empty($registerLink)) {
$registerText = sprintf(__('You may also %s for an account.', 'site-reviews'), $registerLink);
}
return glsr(Template::class)->build('templates/login-register', [
'context' => [
'text' => trim("{$loginText} {$registerText}"),
],
]);
}

public function loginUrl(): string
{
add_filter('login_url', [$this, 'filterLoginUrl'], 20, 3);
Expand Down Expand Up @@ -119,21 +134,6 @@ protected function hideOptions(): array
];
}

protected function loginOrRegister(): string
{
$loginText = sprintf(__('You must be %s to submit a review.', 'site-reviews'), $this->loginLink());
$registerLink = $this->registerLink();
$registerText = '';
if (glsr_get_option('general.require.register', false, 'bool') && !empty($registerLink)) {
$registerText = sprintf(__('You may also %s for an account.', 'site-reviews'), $registerLink);
}
return glsr(Template::class)->build('templates/login-register', [
'context' => [
'text' => trim("{$loginText} {$registerText}"),
],
]);
}

/**
* @param string $value
*/
Expand Down

0 comments on commit d55b685

Please sign in to comment.