@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function __get( $key ) |
| 48 | 48 | { |
| 49 | - if( property_exists( $this, $key )) { |
|
| 49 | + if( property_exists( $this, $key ) ) { |
|
| 50 | 50 | return $this->$key; |
| 51 | 51 | } |
| 52 | - if( is_array( $this->custom ) && array_key_exists( $key, $this->custom )) { |
|
| 52 | + if( is_array( $this->custom ) && array_key_exists( $key, $this->custom ) ) { |
|
| 53 | 53 | return $this->custom[$key]; |
| 54 | 54 | } |
| 55 | 55 | return ''; |
@@ -77,13 +77,13 @@ discard block |
||
| 77 | 77 | 'review_type' => '', |
| 78 | 78 | ]; |
| 79 | 79 | $meta = array_filter( |
| 80 | - array_map( 'array_shift', (array)get_post_meta( $post->ID )), |
|
| 80 | + array_map( 'array_shift', (array)get_post_meta( $post->ID ) ), |
|
| 81 | 81 | 'strlen' |
| 82 | 82 | ); |
| 83 | - $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
|
| 83 | + $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) ); |
|
| 84 | 84 | $this->modified = $this->isModified( $properties ); |
| 85 | 85 | array_walk( $properties, function( $value, $key ) { |
| 86 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
| 86 | + if( !property_exists( $this, $key ) || isset($this->$key) )return; |
|
| 87 | 87 | $this->$key = maybe_unserialize( $value ); |
| 88 | 88 | }); |
| 89 | 89 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | protected function setTermIds( WP_Post $post ) |
| 95 | 95 | { |
| 96 | 96 | $this->term_ids = []; |
| 97 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
| 97 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) )return; |
|
| 98 | 98 | foreach( $terms as $term ) { |
| 99 | 99 | $this->term_ids[] = $term->term_id; |
| 100 | 100 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | // Database/ReviewManager.php |
| 6 | 6 | add_action( 'site-reviews/review/created', function( $review ) { |
| 7 | - if( has_action( 'site-reviews/local/review/create' )) { |
|
| 7 | + if( has_action( 'site-reviews/local/review/create' ) ) { |
|
| 8 | 8 | glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/create/review" hook instead.'; |
| 9 | 9 | do_action( 'site-reviews/local/review/create', (array)get_post( $review->ID ), (array)$review, $review->ID ); |
| 10 | 10 | } |
@@ -12,18 +12,18 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | // Handlers/CreateReview.php |
| 14 | 14 | add_action( 'site-reviews/review/submitted', function( $review ) { |
| 15 | - if( has_action( 'site-reviews/local/review/submitted' )) { |
|
| 15 | + if( has_action( 'site-reviews/local/review/submitted' ) ) { |
|
| 16 | 16 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.'; |
| 17 | 17 | do_action( 'site-reviews/local/review/submitted', null, $review ); |
| 18 | 18 | } |
| 19 | - if( has_filter( 'site-reviews/local/review/submitted/message' )) { |
|
| 19 | + if( has_filter( 'site-reviews/local/review/submitted/message' ) ) { |
|
| 20 | 20 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.'; |
| 21 | 21 | } |
| 22 | 22 | }, 9 ); |
| 23 | 23 | |
| 24 | 24 | // Database/ReviewManager.php |
| 25 | 25 | add_filter( 'site-reviews/create/review-values', function( $values, $command ) { |
| 26 | - if( has_filter( 'site-reviews/local/review' )) { |
|
| 26 | + if( has_filter( 'site-reviews/local/review' ) ) { |
|
| 27 | 27 | glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.'; |
| 28 | 28 | return apply_filters( 'site-reviews/local/review', $values, $command ); |
| 29 | 29 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | // Handlers/EnqueuePublicAssets.php |
| 34 | 34 | add_filter( 'site-reviews/enqueue/public/localize', function( $variables ) { |
| 35 | - if( has_filter( 'site-reviews/enqueue/localize' )) { |
|
| 35 | + if( has_filter( 'site-reviews/enqueue/localize' ) ) { |
|
| 36 | 36 | glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.'; |
| 37 | 37 | return apply_filters( 'site-reviews/enqueue/localize', $variables ); |
| 38 | 38 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | // Modules/Rating.php |
| 43 | 43 | add_filter( 'site-reviews/rating/average', function( $average ) { |
| 44 | - if( has_filter( 'site-reviews/average/rating' )) { |
|
| 44 | + if( has_filter( 'site-reviews/average/rating' ) ) { |
|
| 45 | 45 | glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.'; |
| 46 | 46 | } |
| 47 | 47 | return $average; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | // Modules/Rating.php |
| 51 | 51 | add_filter( 'site-reviews/rating/ranking', function( $ranking ) { |
| 52 | - if( has_filter( 'site-reviews/bayesian/ranking' )) { |
|
| 52 | + if( has_filter( 'site-reviews/bayesian/ranking' ) ) { |
|
| 53 | 53 | glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.'; |
| 54 | 54 | } |
| 55 | 55 | return $ranking; |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | // Modules/Html/Partials/SiteReviews.php |
| 59 | 59 | add_filter( 'site-reviews/review/build/after', function( $renderedFields ) { |
| 60 | - if( has_filter( 'site-reviews/reviews/review/text' )) { |
|
| 60 | + if( has_filter( 'site-reviews/reviews/review/text' ) ) { |
|
| 61 | 61 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
| 62 | 62 | } |
| 63 | - if( has_filter( 'site-reviews/reviews/review/title' )) { |
|
| 63 | + if( has_filter( 'site-reviews/reviews/review/title' ) ) { |
|
| 64 | 64 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
| 65 | 65 | } |
| 66 | 66 | return $renderedFields; |
@@ -68,26 +68,26 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | // Modules/Html/Partials/SiteReviews.php |
| 70 | 70 | add_filter( 'site-reviews/review/build/before', function( $review ) { |
| 71 | - if( has_filter( 'site-reviews/rendered/review' )) { |
|
| 71 | + if( has_filter( 'site-reviews/rendered/review' ) ) { |
|
| 72 | 72 | glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.'; |
| 73 | 73 | } |
| 74 | - if( has_filter( 'site-reviews/rendered/review/meta/order' )) { |
|
| 74 | + if( has_filter( 'site-reviews/rendered/review/meta/order' ) ) { |
|
| 75 | 75 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
| 76 | 76 | } |
| 77 | - if( has_filter( 'site-reviews/rendered/review/order' )) { |
|
| 77 | + if( has_filter( 'site-reviews/rendered/review/order' ) ) { |
|
| 78 | 78 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
| 79 | 79 | } |
| 80 | - if( has_filter( 'site-reviews/rendered/review-form/login-register' )) { |
|
| 80 | + if( has_filter( 'site-reviews/rendered/review-form/login-register' ) ) { |
|
| 81 | 81 | glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).'; |
| 82 | 82 | } |
| 83 | - if( has_filter( 'site-reviews/reviews/navigation_links' )) { |
|
| 83 | + if( has_filter( 'site-reviews/reviews/navigation_links' ) ) { |
|
| 84 | 84 | glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).'; |
| 85 | 85 | } |
| 86 | 86 | return $review; |
| 87 | 87 | }, 9 ); |
| 88 | 88 | |
| 89 | 89 | add_filter( 'site-reviews/validate/custom', function( $result, $request ) { |
| 90 | - if( has_filter( 'site-reviews/validate/review/submission' )) { |
|
| 90 | + if( has_filter( 'site-reviews/validate/review/submission' ) ) { |
|
| 91 | 91 | glsr_log()->notice( 'The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.' ); |
| 92 | 92 | return apply_filters( 'site-reviews/validate/review/submission', $result, $request ); |
| 93 | 93 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | }, 9, 2 ); |
| 96 | 96 | |
| 97 | 97 | add_filter( 'site-reviews/views/file', function( $file, $view, $data ) { |
| 98 | - if( has_filter( 'site-reviews/addon/views/file' )) { |
|
| 98 | + if( has_filter( 'site-reviews/addon/views/file' ) ) { |
|
| 99 | 99 | glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.'; |
| 100 | 100 | $file = apply_filters( 'site-reviews/addon/views/file', $file, $view, $data ); |
| 101 | 101 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | }, 9, 3 ); |
| 104 | 104 | |
| 105 | 105 | add_action( 'wp_footer', function() { |
| 106 | - $notices = array_keys( array_flip( glsr()->deprecated )); |
|
| 106 | + $notices = array_keys( array_flip( glsr()->deprecated ) ); |
|
| 107 | 107 | natsort( $notices ); |
| 108 | 108 | foreach( $notices as $notice ) { |
| 109 | 109 | glsr_log()->notice( $notice ); |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | <p>{{ data.s1 }}</p> |
| 8 | 8 | </div> |
| 9 | 9 | <p class="row-actions"> |
| 10 | - <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' );?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
| 10 | + <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' ); ?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
| 11 | 11 | </p> |
| 12 | 12 | </td> |
| 13 | 13 | <td class="glsr-string-td2"> |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | <p>{{ data.p1 }}</p> |
| 9 | 9 | </div> |
| 10 | 10 | <p class="row-actions"> |
| 11 | - <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' );?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
| 11 | + <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' ); ?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
| 12 | 12 | </p> |
| 13 | 13 | </td> |
| 14 | 14 | <td class="glsr-string-td2"> |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | { |
| 19 | 19 | return $this->translate( $translation, $domain, [ |
| 20 | 20 | 'single' => $text, |
| 21 | - ]); |
|
| 21 | + ] ); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | return $this->translate( $translation, $domain, [ |
| 34 | 34 | 'context' => $context, |
| 35 | 35 | 'single' => $text, |
| 36 | - ]); |
|
| 36 | + ] ); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | 'number' => $number, |
| 51 | 51 | 'plural' => $plural, |
| 52 | 52 | 'single' => $single, |
| 53 | - ]); |
|
| 53 | + ] ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | 'number' => $number, |
| 70 | 70 | 'plural' => $plural, |
| 71 | 71 | 'single' => $single, |
| 72 | - ]); |
|
| 72 | + ] ); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | $args = $this->normalizeTranslationArgs( $args ); |
| 86 | 86 | $strings = $this->getTranslationStrings( $args['single'], $args['plural'] ); |
| 87 | - if( empty( $strings )) { |
|
| 87 | + if( empty($strings) ) { |
|
| 88 | 88 | return $original; |
| 89 | 89 | } |
| 90 | 90 | $string = current( $strings ); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | protected function getTranslationStrings( $single, $plural ) |
| 102 | 102 | { |
| 103 | - return array_filter( glsr( Translation::class )->translations(), function( $string ) use( $single, $plural ) { |
|
| 103 | + return array_filter( glsr( Translation::class )->translations(), function( $string ) use($single, $plural) { |
|
| 104 | 104 | return $string['s1'] == html_entity_decode( $single, ENT_COMPAT, 'UTF-8' ) |
| 105 | 105 | && $string['p1'] == html_entity_decode( $plural, ENT_COMPAT, 'UTF-8' ); |
| 106 | 106 | }); |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | protected function translatePlural( $domain, array $string, array $args ) |
| 128 | 128 | { |
| 129 | - if( !empty( $string['s2'] )) { |
|
| 129 | + if( !empty($string['s2']) ) { |
|
| 130 | 130 | $args['single'] = $string['s2']; |
| 131 | 131 | } |
| 132 | - if( !empty( $string['p2'] )) { |
|
| 132 | + if( !empty($string['p2']) ) { |
|
| 133 | 133 | $args['plural'] = $string['p2']; |
| 134 | 134 | } |
| 135 | 135 | return get_translations_for_domain( $domain )->translate_plural( |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | protected function translateSingle( $domain, array $string, array $args ) |
| 148 | 148 | { |
| 149 | - if( !empty( $string['s2'] )) { |
|
| 149 | + if( !empty($string['s2']) ) { |
|
| 150 | 150 | $args['single'] = $string['s2']; |
| 151 | 151 | } |
| 152 | 152 | return get_translations_for_domain( $domain )->translate( |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | $className = str_replace( '.php', '', $file ); |
| 29 | 29 | $version = str_replace( ['Upgrade_', '_'], ['', '.'], $className ); |
| 30 | 30 | $versionSuffix = preg_replace( '/[\d.]+(.+)?/', '${1}', glsr()->version ); // allow alpha/beta versions |
| 31 | - if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ))return; |
|
| 31 | + if( version_compare( $this->currentVersion(), $version.$versionSuffix, '>=' ) )return; |
|
| 32 | 32 | glsr( 'Modules\\Upgrader\\'.$className ); |
| 33 | 33 | glsr_log()->info( 'Completed Upgrade for v'.$version.$versionSuffix ); |
| 34 | 34 | }); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | protected function filterAttributes( array $allowedAttributeKeys ) |
| 124 | 124 | { |
| 125 | - return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys )); |
|
| 125 | + return array_intersect_key( $this->attributes, array_flip( $allowedAttributeKeys ) ); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $globalAttributes = $this->filterAttributes( static::GLOBAL_ATTRIBUTES ); |
| 134 | 134 | $wildcards = []; |
| 135 | 135 | foreach( static::GLOBAL_WILDCARD_ATTRIBUTES as $wildcard ) { |
| 136 | - $newWildcards = array_filter( $this->attributes, function( $key ) use( $wildcard ) { |
|
| 136 | + $newWildcards = array_filter( $this->attributes, function( $key ) use($wildcard) { |
|
| 137 | 137 | return glsr( Helper::class )->startsWith( $wildcard, $key ); |
| 138 | 138 | }, ARRAY_FILTER_USE_KEY ); |
| 139 | 139 | $wildcards = array_merge( $wildcards, $newWildcards ); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | protected function getPermanentAttributes() |
| 148 | 148 | { |
| 149 | 149 | $permanentAttributes = []; |
| 150 | - if( array_key_exists( 'value', $this->attributes )) { |
|
| 150 | + if( array_key_exists( 'value', $this->attributes ) ) { |
|
| 151 | 151 | $permanentAttributes['value'] = $this->attributes['value']; |
| 152 | 152 | } |
| 153 | 153 | return $permanentAttributes; |
@@ -199,11 +199,11 @@ discard block |
||
| 199 | 199 | protected function normalizeBooleanAttributes() |
| 200 | 200 | { |
| 201 | 201 | foreach( $this->attributes as $key => $value ) { |
| 202 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
| 202 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
| 203 | 203 | $key = $value; |
| 204 | 204 | $value = true; |
| 205 | 205 | } |
| 206 | - if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ))continue; |
|
| 206 | + if( !in_array( $key, static::BOOLEAN_ATTRIBUTES ) )continue; |
|
| 207 | 207 | $this->attributes[$key] = wp_validate_boolean( $value ); |
| 208 | 208 | } |
| 209 | 209 | } |
@@ -214,13 +214,13 @@ discard block |
||
| 214 | 214 | protected function normalizeDataAttributes() |
| 215 | 215 | { |
| 216 | 216 | foreach( $this->attributes as $key => $value ) { |
| 217 | - if( $this->isAttributeKeyNumeric( $key, $value )) { |
|
| 217 | + if( $this->isAttributeKeyNumeric( $key, $value ) ) { |
|
| 218 | 218 | $key = $value; |
| 219 | 219 | $value = ''; |
| 220 | 220 | } |
| 221 | - if( !glsr( Helper::class )->startsWith( 'data-', $key ))continue; |
|
| 222 | - if( is_array( $value )) { |
|
| 223 | - $value = json_encode( $value, JSON_HEX_APOS|JSON_NUMERIC_CHECK|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ); |
|
| 221 | + if( !glsr( Helper::class )->startsWith( 'data-', $key ) )continue; |
|
| 222 | + if( is_array( $value ) ) { |
|
| 223 | + $value = json_encode( $value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); |
|
| 224 | 224 | } |
| 225 | 225 | $this->attributes[$key] = $value; |
| 226 | 226 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | protected function normalizeStringAttributes() |
| 233 | 233 | { |
| 234 | 234 | foreach( $this->attributes as $key => $value ) { |
| 235 | - if( !is_string( $value ))continue; |
|
| 235 | + if( !is_string( $value ) )continue; |
|
| 236 | 236 | $this->attributes[$key] = trim( $value ); |
| 237 | 237 | } |
| 238 | 238 | } |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | { |
| 246 | 246 | if( $method != 'input' )return; |
| 247 | 247 | $attributes = wp_parse_args( $this->attributes, ['type' => ''] ); |
| 248 | - if( !in_array( $attributes['type'], static::INPUT_TYPES )) { |
|
| 248 | + if( !in_array( $attributes['type'], static::INPUT_TYPES ) ) { |
|
| 249 | 249 | $this->attributes['type'] = 'text'; |
| 250 | 250 | } |
| 251 | 251 | } |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | $permanentAttributes = $this->getPermanentAttributes(); |
| 260 | 260 | foreach( $this->attributes as $key => $value ) { |
| 261 | 261 | if( in_array( $key, static::BOOLEAN_ATTRIBUTES ) && !$value ) { |
| 262 | - unset( $attributes[$key] ); |
|
| 262 | + unset($attributes[$key]); |
|
| 263 | 263 | } |
| 264 | - if( glsr( Helper::class )->startsWith( 'data-', $key )) { |
|
| 264 | + if( glsr( Helper::class )->startsWith( 'data-', $key ) ) { |
|
| 265 | 265 | $permanentAttributes[$key] = $value; |
| 266 | - unset( $attributes[$key] ); |
|
| 266 | + unset($attributes[$key]); |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | $this->attributes = array_merge( array_filter( $attributes ), $permanentAttributes ); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $translations = $this->translations(); |
| 32 | 32 | $entries = $this->filter( $translations, $this->entries() )->results(); |
| 33 | - array_walk( $translations, function( &$entry ) use( $entries ) { |
|
| 33 | + array_walk( $translations, function( &$entry ) use($entries) { |
|
| 34 | 34 | $entry['desc'] = array_key_exists( $entry['id'], $entries ) |
| 35 | 35 | ? $this->getEntryString( $entries[$entry['id']], 'msgctxt' ) |
| 36 | 36 | : ''; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function entries() |
| 45 | 45 | { |
| 46 | - if( !isset( $this->entries )) { |
|
| 46 | + if( !isset($this->entries) ) { |
|
| 47 | 47 | try { |
| 48 | 48 | $potFile = glsr()->path( glsr()->languages.'/'.Application::ID.'.pot' ); |
| 49 | 49 | $entries = $this->normalize( Parser::parseFile( $potFile )->getEntries() ); |
@@ -76,13 +76,13 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function filter( $filterWith = null, $entries = null, $intersect = true ) |
| 78 | 78 | { |
| 79 | - if( !is_array( $entries )) { |
|
| 79 | + if( !is_array( $entries ) ) { |
|
| 80 | 80 | $entries = $this->results; |
| 81 | 81 | } |
| 82 | - if( !is_array( $filterWith )) { |
|
| 82 | + if( !is_array( $filterWith ) ) { |
|
| 83 | 83 | $filterWith = $this->translations(); |
| 84 | 84 | } |
| 85 | - $keys = array_flip( array_column( $filterWith, 'id' )); |
|
| 85 | + $keys = array_flip( array_column( $filterWith, 'id' ) ); |
|
| 86 | 86 | $this->results = $intersect |
| 87 | 87 | ? array_intersect_key( $entries, $keys ) |
| 88 | 88 | : array_diff_key( $entries, $keys ); |
@@ -96,17 +96,17 @@ discard block |
||
| 96 | 96 | public function render( $template, array $entry ) |
| 97 | 97 | { |
| 98 | 98 | $data = array_combine( |
| 99 | - array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry )), |
|
| 99 | + array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry ) ), |
|
| 100 | 100 | $entry |
| 101 | 101 | ); |
| 102 | 102 | $data['data.class'] = $data['data.error'] = ''; |
| 103 | - if( array_search( $entry['s1'], array_column( $this->entries(), 'msgid' )) === false ) { |
|
| 103 | + if( array_search( $entry['s1'], array_column( $this->entries(), 'msgid' ) ) === false ) { |
|
| 104 | 104 | $data['data.class'] = 'is-invalid'; |
| 105 | 105 | $data['data.error'] = __( 'This custom translation is no longer valid as the original text has been changed or removed.', 'site-reviews' ); |
| 106 | 106 | } |
| 107 | 107 | return glsr( Template::class )->build( 'partials/translations/'.$template, [ |
| 108 | 108 | 'context' => $data, |
| 109 | - ]); |
|
| 109 | + ] ); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -138,13 +138,13 @@ discard block |
||
| 138 | 138 | 'p1' => $this->getEntryString( $entry, 'msgid_plural' ), |
| 139 | 139 | 's1' => $this->getEntryString( $entry, 'msgid' ), |
| 140 | 140 | ]; |
| 141 | - $text = !empty( $data['p1'] ) |
|
| 141 | + $text = !empty($data['p1']) |
|
| 142 | 142 | ? sprintf( '%s | %s', $data['s1'], $data['p1'] ) |
| 143 | 143 | : $data['s1']; |
| 144 | 144 | $rendered .= $this->render( 'result', [ |
| 145 | - 'entry' => json_encode( $data, JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_TAG|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ), |
|
| 145 | + 'entry' => json_encode( $data, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ), |
|
| 146 | 146 | 'text' => wp_strip_all_tags( $text ), |
| 147 | - ]); |
|
| 147 | + ] ); |
|
| 148 | 148 | } |
| 149 | 149 | if( $resetAfterRender ) { |
| 150 | 150 | $this->reset(); |
@@ -177,12 +177,12 @@ discard block |
||
| 177 | 177 | public function search( $needle = '' ) |
| 178 | 178 | { |
| 179 | 179 | $this->reset(); |
| 180 | - $needle = trim( strtolower( $needle )); |
|
| 180 | + $needle = trim( strtolower( $needle ) ); |
|
| 181 | 181 | foreach( $this->entries() as $key => $entry ) { |
| 182 | - $single = strtolower( $this->getEntryString( $entry, 'msgid' )); |
|
| 183 | - $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' )); |
|
| 182 | + $single = strtolower( $this->getEntryString( $entry, 'msgid' ) ); |
|
| 183 | + $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ) ); |
|
| 184 | 184 | if( strlen( $needle ) < static::SEARCH_THRESHOLD ) { |
| 185 | - if( in_array( $needle, [$single, $plural] )) { |
|
| 185 | + if( in_array( $needle, [$single, $plural] ) ) { |
|
| 186 | 186 | $this->results[$key] = $entry; |
| 187 | 187 | } |
| 188 | 188 | } |
@@ -200,10 +200,10 @@ discard block |
||
| 200 | 200 | public function translations() |
| 201 | 201 | { |
| 202 | 202 | static $translations; |
| 203 | - if( empty( $translations )) { |
|
| 203 | + if( empty($translations) ) { |
|
| 204 | 204 | $settings = glsr( OptionManager::class )->get( 'settings' ); |
| 205 | - $translations = isset( $settings['strings'] ) |
|
| 206 | - ? $this->normalizeSettings( (array) $settings['strings'] ) |
|
| 205 | + $translations = isset($settings['strings']) |
|
| 206 | + ? $this->normalizeSettings( (array)$settings['strings'] ) |
|
| 207 | 207 | : []; |
| 208 | 208 | } |
| 209 | 209 | return $translations; |
@@ -215,8 +215,8 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | protected function getEntryString( array $entry, $key ) |
| 217 | 217 | { |
| 218 | - return isset( $entry[$key] ) |
|
| 219 | - ? implode( '', (array) $entry[$key] ) |
|
| 218 | + return isset($entry[$key]) |
|
| 219 | + ? implode( '', (array)$entry[$key] ) |
|
| 220 | 220 | : ''; |
| 221 | 221 | } |
| 222 | 222 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | $keys = [ |
| 229 | 229 | 'msgctxt', 'msgid', 'msgid_plural', 'msgstr', 'msgstr[0]', 'msgstr[1]', |
| 230 | 230 | ]; |
| 231 | - array_walk( $entries, function( &$entry ) use( $keys ) { |
|
| 231 | + array_walk( $entries, function( &$entry ) use($keys) { |
|
| 232 | 232 | foreach( $keys as $key ) { |
| 233 | 233 | $entry = $this->normalizeEntryString( $entry, $key ); |
| 234 | 234 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | protected function normalizeEntryString( array $entry, $key ) |
| 244 | 244 | { |
| 245 | - if( isset( $entry[$key] )) { |
|
| 245 | + if( isset($entry[$key]) ) { |
|
| 246 | 246 | $entry[$key] = $this->getEntryString( $entry, $key ); |
| 247 | 247 | } |
| 248 | 248 | return $entry; |
@@ -256,11 +256,11 @@ discard block |
||
| 256 | 256 | $defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' ); |
| 257 | 257 | $strings = array_filter( $strings, 'is_array' ); |
| 258 | 258 | foreach( $strings as &$string ) { |
| 259 | - $string['type'] = isset( $string['p1'] ) ? 'plural' : 'single'; |
|
| 259 | + $string['type'] = isset($string['p1']) ? 'plural' : 'single'; |
|
| 260 | 260 | $string = wp_parse_args( $string, $defaultString ); |
| 261 | 261 | } |
| 262 | 262 | return array_filter( $strings, function( $string ) { |
| 263 | - return !empty( $string['id'] ); |
|
| 263 | + return !empty($string['id']); |
|
| 264 | 264 | }); |
| 265 | 265 | } |
| 266 | 266 | } |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | $this->newSettings = $this->getNewSettings(); |
| 76 | 76 | $this->oldSettings = $this->getOldSettings(); |
| 77 | - if( empty( $this->oldSettings ))return; |
|
| 77 | + if( empty($this->oldSettings) )return; |
|
| 78 | 78 | foreach( static::MAPPED_SETTINGS as $old => $new ) { |
| 79 | - if( empty( $this->oldSettings[$old] ))continue; |
|
| 79 | + if( empty($this->oldSettings[$old]) )continue; |
|
| 80 | 80 | $this->newSettings[$new] = $this->oldSettings[$old]; |
| 81 | 81 | } |
| 82 | 82 | $this->migrateNotificationSettings(); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $this->migrateRequiredSettings(); |
| 85 | 85 | $oldSettings = glsr( Helper::class )->convertDotNotationArray( $this->oldSettings ); |
| 86 | 86 | $newSettings = glsr( Helper::class )->convertDotNotationArray( $this->newSettings ); |
| 87 | - if( isset( $oldSettings['settings']['strings'] ) && is_array( $oldSettings['settings']['strings'] )) { |
|
| 87 | + if( isset($oldSettings['settings']['strings']) && is_array( $oldSettings['settings']['strings'] ) ) { |
|
| 88 | 88 | $newSettings['settings']['strings'] = $oldSettings['settings']['strings']; |
| 89 | 89 | } |
| 90 | 90 | glsr( OptionManager::class )->set( $newSettings ); |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | protected function getOldSettings() |
| 118 | 118 | { |
| 119 | 119 | $defaults = array_fill_keys( array_keys( static::MAPPED_SETTINGS ), '' ); |
| 120 | - $settings = glsr( Helper::class )->flattenArray( get_option( 'geminilabs_site_reviews-v2', [] )); |
|
| 121 | - if( !empty( $settings )) { |
|
| 120 | + $settings = glsr( Helper::class )->flattenArray( get_option( 'geminilabs_site_reviews-v2', [] ) ); |
|
| 121 | + if( !empty($settings) ) { |
|
| 122 | 122 | $settings = wp_parse_args( $settings, $defaults ); |
| 123 | 123 | } |
| 124 | 124 | return $settings; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | 'SecretKey' => $this->oldSettings['settings.reviews-form.recaptcha.secret'], |
| 152 | 152 | 'SiteKey' => $this->oldSettings['settings.reviews-form.recaptcha.key'], |
| 153 | 153 | ]; |
| 154 | - if( in_array( $this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'] )) { |
|
| 154 | + if( in_array( $this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'] ) ) { |
|
| 155 | 155 | $this->newSettings['settings.submissions.recaptcha.integration'] = 'all'; |
| 156 | 156 | } |
| 157 | 157 | if( $this->oldSettings['settings.reviews-form.recaptcha.integration'] == 'invisible-recaptcha' ) { |