@@ -1,22 +1,22 @@ discard block |
||
| 1 | -<?php defined('WPINC') || die; ?> |
|
| 1 | +<?php defined( 'WPINC' ) || die; ?> |
|
| 2 | 2 | |
| 3 | -<p><?= sprintf(__('Here you can customise any text of the plugin, including the submission form labels and placeholders. However, if you have a multilingual website you should use the %s plugin instead.', 'site-reviews'), '<a href="https://wordpress.org/plugins/loco-translate/">Loco Translate</a>'); ?></p> |
|
| 3 | +<p><?= sprintf( __( 'Here you can customise any text of the plugin, including the submission form labels and placeholders. However, if you have a multilingual website you should use the %s plugin instead.', 'site-reviews' ), '<a href="https://wordpress.org/plugins/loco-translate/">Loco Translate</a>' ); ?></p> |
|
| 4 | 4 | |
| 5 | 5 | <div class="glsr-strings-form"> |
| 6 | 6 | <div class="glsr-search-box" id="glsr-search-translations"> |
| 7 | - <span class="screen-reader-text"><?= __('Search for translatable text', 'site-reviews'); ?></span> |
|
| 7 | + <span class="screen-reader-text"><?= __( 'Search for translatable text', 'site-reviews' ); ?></span> |
|
| 8 | 8 | <div class="glsr-spinner"> |
| 9 | 9 | <span class="spinner"></span> |
| 10 | 10 | </div> |
| 11 | - <input type="search" class="glsr-search-input" autocomplete="off" placeholder="<?= __('Search here for text to translate...', 'site-reviews'); ?>"> |
|
| 12 | - <?php wp_nonce_field('search-translations', '_search_nonce', false); ?> |
|
| 11 | + <input type="search" class="glsr-search-input" autocomplete="off" placeholder="<?= __( 'Search here for text to translate...', 'site-reviews' ); ?>"> |
|
| 12 | + <?php wp_nonce_field( 'search-translations', '_search_nonce', false ); ?> |
|
| 13 | 13 | <div class="glsr-search-results" data-prefix="{{ database_key }}"></div> |
| 14 | 14 | </div> |
| 15 | 15 | <table class="glsr-strings-table wp-list-table widefat striped {{ class }}"> |
| 16 | 16 | <thead> |
| 17 | 17 | <tr> |
| 18 | - <th scope="col" class="manage-column column-primary"><?= __('Original Text', 'site-reviews'); ?></th> |
|
| 19 | - <th scope="col" class="manage-column"><?= __('Custom Translation', 'site-reviews'); ?></th> |
|
| 18 | + <th scope="col" class="manage-column column-primary"><?= __( 'Original Text', 'site-reviews' ); ?></th> |
|
| 19 | + <th scope="col" class="manage-column"><?= __( 'Custom Translation', 'site-reviews' ); ?></th> |
|
| 20 | 20 | </tr> |
| 21 | 21 | </thead> |
| 22 | 22 | <tbody>{{ translations }}</tbody> |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | </div> |
| 26 | 26 | |
| 27 | 27 | <script type="text/html" id="tmpl-glsr-string-plural"> |
| 28 | -<?php include glsr()->path('views/partials/translations/plural.php'); ?> |
|
| 28 | +<?php include glsr()->path( 'views/partials/translations/plural.php' ); ?> |
|
| 29 | 29 | </script> |
| 30 | 30 | <script type="text/html" id="tmpl-glsr-string-single"> |
| 31 | -<?php include glsr()->path('views/partials/translations/single.php'); ?> |
|
| 31 | +<?php include glsr()->path( 'views/partials/translations/single.php' ); ?> |
|
| 32 | 32 | </script> |
@@ -8,105 +8,105 @@ |
||
| 8 | 8 | |
| 9 | 9 | class ReviewLimits |
| 10 | 10 | { |
| 11 | - protected $request; |
|
| 11 | + protected $request; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @return array |
|
| 15 | - * @filter site-reviews/get/reviews/query |
|
| 16 | - */ |
|
| 17 | - public function filterReviewsQuery(array $parameters, array $args) |
|
| 18 | - { |
|
| 19 | - if ($authorId = get_current_user_id()) { |
|
| 20 | - $parameters['author'] = $authorId; |
|
| 21 | - } |
|
| 22 | - $parameters['post_status'] = ['pending', 'publish']; |
|
| 23 | - return apply_filters('site-reviews/review-limits/query', $parameters, $args); |
|
| 24 | - } |
|
| 13 | + /** |
|
| 14 | + * @return array |
|
| 15 | + * @filter site-reviews/get/reviews/query |
|
| 16 | + */ |
|
| 17 | + public function filterReviewsQuery(array $parameters, array $args) |
|
| 18 | + { |
|
| 19 | + if ($authorId = get_current_user_id()) { |
|
| 20 | + $parameters['author'] = $authorId; |
|
| 21 | + } |
|
| 22 | + $parameters['post_status'] = ['pending', 'publish']; |
|
| 23 | + return apply_filters('site-reviews/review-limits/query', $parameters, $args); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @return bool |
|
| 28 | - */ |
|
| 29 | - public function hasReachedLimit(array $request = []) |
|
| 30 | - { |
|
| 31 | - $this->request = $request; |
|
| 32 | - $method = Helper::buildMethodName( |
|
| 33 | - glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy' |
|
| 34 | - ); |
|
| 35 | - return method_exists($this, $method) |
|
| 36 | - ? !call_user_func([$this, $method]) |
|
| 37 | - : false; |
|
| 38 | - } |
|
| 26 | + /** |
|
| 27 | + * @return bool |
|
| 28 | + */ |
|
| 29 | + public function hasReachedLimit(array $request = []) |
|
| 30 | + { |
|
| 31 | + $this->request = $request; |
|
| 32 | + $method = Helper::buildMethodName( |
|
| 33 | + glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy' |
|
| 34 | + ); |
|
| 35 | + return method_exists($this, $method) |
|
| 36 | + ? !call_user_func([$this, $method]) |
|
| 37 | + : false; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @param string $value |
|
| 42 | - * @param string $whitelist |
|
| 43 | - * @return bool |
|
| 44 | - */ |
|
| 45 | - public function isWhitelisted($value, $whitelist) |
|
| 46 | - { |
|
| 47 | - if (empty($whitelist)) { |
|
| 48 | - return false; |
|
| 49 | - } |
|
| 50 | - return in_array($value, array_filter(explode("\n", $whitelist), 'trim')); |
|
| 51 | - } |
|
| 40 | + /** |
|
| 41 | + * @param string $value |
|
| 42 | + * @param string $whitelist |
|
| 43 | + * @return bool |
|
| 44 | + */ |
|
| 45 | + public function isWhitelisted($value, $whitelist) |
|
| 46 | + { |
|
| 47 | + if (empty($whitelist)) { |
|
| 48 | + return false; |
|
| 49 | + } |
|
| 50 | + return in_array($value, array_filter(explode("\n", $whitelist), 'trim')); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @param string $whitelistName |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 57 | - protected function getWhitelist($whitelistName) |
|
| 58 | - { |
|
| 59 | - return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName); |
|
| 60 | - } |
|
| 53 | + /** |
|
| 54 | + * @param string $whitelistName |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | + protected function getWhitelist($whitelistName) |
|
| 58 | + { |
|
| 59 | + return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @return bool |
|
| 64 | - */ |
|
| 65 | - protected function validate($key, $value, $addMetaQuery = true) |
|
| 66 | - { |
|
| 67 | - if ($this->isWhitelisted($value, $this->getWhitelist($key))) { |
|
| 68 | - return true; |
|
| 69 | - } |
|
| 70 | - add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2); |
|
| 71 | - $args = ['assigned_to' => Arr::get($this->request, 'assign_to')]; |
|
| 72 | - if ($addMetaQuery) { |
|
| 73 | - $args[$key] = $value; |
|
| 74 | - } |
|
| 75 | - $reviews = glsr_get_reviews($args); |
|
| 76 | - remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5); |
|
| 77 | - $result = 0 === count($reviews); |
|
| 78 | - $result = apply_filters('site-reviews/review-limits/validate', $result, $reviews, $key); |
|
| 79 | - return wp_validate_boolean($result); |
|
| 80 | - } |
|
| 62 | + /** |
|
| 63 | + * @return bool |
|
| 64 | + */ |
|
| 65 | + protected function validate($key, $value, $addMetaQuery = true) |
|
| 66 | + { |
|
| 67 | + if ($this->isWhitelisted($value, $this->getWhitelist($key))) { |
|
| 68 | + return true; |
|
| 69 | + } |
|
| 70 | + add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2); |
|
| 71 | + $args = ['assigned_to' => Arr::get($this->request, 'assign_to')]; |
|
| 72 | + if ($addMetaQuery) { |
|
| 73 | + $args[$key] = $value; |
|
| 74 | + } |
|
| 75 | + $reviews = glsr_get_reviews($args); |
|
| 76 | + remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5); |
|
| 77 | + $result = 0 === count($reviews); |
|
| 78 | + $result = apply_filters('site-reviews/review-limits/validate', $result, $reviews, $key); |
|
| 79 | + return wp_validate_boolean($result); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @return bool |
|
| 84 | - */ |
|
| 85 | - protected function validateByEmail() |
|
| 86 | - { |
|
| 87 | - glsr_log()->debug('Email is: '.Arr::get($this->request, 'email')); |
|
| 88 | - return $this->validate('email', Arr::get($this->request, 'email')); |
|
| 89 | - } |
|
| 82 | + /** |
|
| 83 | + * @return bool |
|
| 84 | + */ |
|
| 85 | + protected function validateByEmail() |
|
| 86 | + { |
|
| 87 | + glsr_log()->debug('Email is: '.Arr::get($this->request, 'email')); |
|
| 88 | + return $this->validate('email', Arr::get($this->request, 'email')); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @return bool |
|
| 93 | - */ |
|
| 94 | - protected function validateByIpAddress() |
|
| 95 | - { |
|
| 96 | - glsr_log()->debug('IP Address is: '.Arr::get($this->request, 'ip_address')); |
|
| 97 | - return $this->validate('ip_address', Arr::get($this->request, 'ip_address')); |
|
| 98 | - } |
|
| 91 | + /** |
|
| 92 | + * @return bool |
|
| 93 | + */ |
|
| 94 | + protected function validateByIpAddress() |
|
| 95 | + { |
|
| 96 | + glsr_log()->debug('IP Address is: '.Arr::get($this->request, 'ip_address')); |
|
| 97 | + return $this->validate('ip_address', Arr::get($this->request, 'ip_address')); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * @return bool |
|
| 102 | - */ |
|
| 103 | - protected function validateByUsername() |
|
| 104 | - { |
|
| 105 | - $user = wp_get_current_user(); |
|
| 106 | - if (!$user->exists()) { |
|
| 107 | - return true; |
|
| 108 | - } |
|
| 109 | - glsr_log()->debug('Username is: '.$user->user_login); |
|
| 110 | - return $this->validate('username', $user->user_login, false); |
|
| 111 | - } |
|
| 100 | + /** |
|
| 101 | + * @return bool |
|
| 102 | + */ |
|
| 103 | + protected function validateByUsername() |
|
| 104 | + { |
|
| 105 | + $user = wp_get_current_user(); |
|
| 106 | + if (!$user->exists()) { |
|
| 107 | + return true; |
|
| 108 | + } |
|
| 109 | + glsr_log()->debug('Username is: '.$user->user_login); |
|
| 110 | + return $this->validate('username', $user->user_login, false); |
|
| 111 | + } |
|
| 112 | 112 | } |
@@ -14,26 +14,26 @@ discard block |
||
| 14 | 14 | * @return array |
| 15 | 15 | * @filter site-reviews/get/reviews/query |
| 16 | 16 | */ |
| 17 | - public function filterReviewsQuery(array $parameters, array $args) |
|
| 17 | + public function filterReviewsQuery( array $parameters, array $args ) |
|
| 18 | 18 | { |
| 19 | - if ($authorId = get_current_user_id()) { |
|
| 19 | + if( $authorId = get_current_user_id() ) { |
|
| 20 | 20 | $parameters['author'] = $authorId; |
| 21 | 21 | } |
| 22 | 22 | $parameters['post_status'] = ['pending', 'publish']; |
| 23 | - return apply_filters('site-reviews/review-limits/query', $parameters, $args); |
|
| 23 | + return apply_filters( 'site-reviews/review-limits/query', $parameters, $args ); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * @return bool |
| 28 | 28 | */ |
| 29 | - public function hasReachedLimit(array $request = []) |
|
| 29 | + public function hasReachedLimit( array $request = [] ) |
|
| 30 | 30 | { |
| 31 | 31 | $this->request = $request; |
| 32 | 32 | $method = Helper::buildMethodName( |
| 33 | - glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy' |
|
| 33 | + glsr( OptionManager::class )->get( 'settings.submissions.limit' ), 'validateBy' |
|
| 34 | 34 | ); |
| 35 | - return method_exists($this, $method) |
|
| 36 | - ? !call_user_func([$this, $method]) |
|
| 35 | + return method_exists( $this, $method ) |
|
| 36 | + ? !call_user_func( [$this, $method] ) |
|
| 37 | 37 | : false; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -42,41 +42,41 @@ discard block |
||
| 42 | 42 | * @param string $whitelist |
| 43 | 43 | * @return bool |
| 44 | 44 | */ |
| 45 | - public function isWhitelisted($value, $whitelist) |
|
| 45 | + public function isWhitelisted( $value, $whitelist ) |
|
| 46 | 46 | { |
| 47 | - if (empty($whitelist)) { |
|
| 47 | + if( empty($whitelist) ) { |
|
| 48 | 48 | return false; |
| 49 | 49 | } |
| 50 | - return in_array($value, array_filter(explode("\n", $whitelist), 'trim')); |
|
| 50 | + return in_array( $value, array_filter( explode( "\n", $whitelist ), 'trim' ) ); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * @param string $whitelistName |
| 55 | 55 | * @return string |
| 56 | 56 | */ |
| 57 | - protected function getWhitelist($whitelistName) |
|
| 57 | + protected function getWhitelist( $whitelistName ) |
|
| 58 | 58 | { |
| 59 | - return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName); |
|
| 59 | + return glsr( OptionManager::class )->get( 'settings.submissions.limit_whitelist.'.$whitelistName ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @return bool |
| 64 | 64 | */ |
| 65 | - protected function validate($key, $value, $addMetaQuery = true) |
|
| 65 | + protected function validate( $key, $value, $addMetaQuery = true ) |
|
| 66 | 66 | { |
| 67 | - if ($this->isWhitelisted($value, $this->getWhitelist($key))) { |
|
| 67 | + if( $this->isWhitelisted( $value, $this->getWhitelist( $key ) ) ) { |
|
| 68 | 68 | return true; |
| 69 | 69 | } |
| 70 | - add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2); |
|
| 71 | - $args = ['assigned_to' => Arr::get($this->request, 'assign_to')]; |
|
| 72 | - if ($addMetaQuery) { |
|
| 70 | + add_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2 ); |
|
| 71 | + $args = ['assigned_to' => Arr::get( $this->request, 'assign_to' )]; |
|
| 72 | + if( $addMetaQuery ) { |
|
| 73 | 73 | $args[$key] = $value; |
| 74 | 74 | } |
| 75 | - $reviews = glsr_get_reviews($args); |
|
| 76 | - remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5); |
|
| 77 | - $result = 0 === count($reviews); |
|
| 78 | - $result = apply_filters('site-reviews/review-limits/validate', $result, $reviews, $key); |
|
| 79 | - return wp_validate_boolean($result); |
|
| 75 | + $reviews = glsr_get_reviews( $args ); |
|
| 76 | + remove_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5 ); |
|
| 77 | + $result = 0 === count( $reviews ); |
|
| 78 | + $result = apply_filters( 'site-reviews/review-limits/validate', $result, $reviews, $key ); |
|
| 79 | + return wp_validate_boolean( $result ); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | protected function validateByEmail() |
| 86 | 86 | { |
| 87 | - glsr_log()->debug('Email is: '.Arr::get($this->request, 'email')); |
|
| 88 | - return $this->validate('email', Arr::get($this->request, 'email')); |
|
| 87 | + glsr_log()->debug( 'Email is: '.Arr::get( $this->request, 'email' ) ); |
|
| 88 | + return $this->validate( 'email', Arr::get( $this->request, 'email' ) ); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | protected function validateByIpAddress() |
| 95 | 95 | { |
| 96 | - glsr_log()->debug('IP Address is: '.Arr::get($this->request, 'ip_address')); |
|
| 97 | - return $this->validate('ip_address', Arr::get($this->request, 'ip_address')); |
|
| 96 | + glsr_log()->debug( 'IP Address is: '.Arr::get( $this->request, 'ip_address' ) ); |
|
| 97 | + return $this->validate( 'ip_address', Arr::get( $this->request, 'ip_address' ) ); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | protected function validateByUsername() |
| 104 | 104 | { |
| 105 | 105 | $user = wp_get_current_user(); |
| 106 | - if (!$user->exists()) { |
|
| 106 | + if( !$user->exists() ) { |
|
| 107 | 107 | return true; |
| 108 | 108 | } |
| 109 | - glsr_log()->debug('Username is: '.$user->user_login); |
|
| 110 | - return $this->validate('username', $user->user_login, false); |
|
| 109 | + glsr_log()->debug( 'Username is: '.$user->user_login ); |
|
| 110 | + return $this->validate( 'username', $user->user_login, false ); |
|
| 111 | 111 | } |
| 112 | 112 | } |