@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | $this->reviews = $reviews; |
| 32 | 32 | $this->navigation = glsr( Partial::class )->build( 'pagination', [ |
| 33 | 33 | 'total' => $maxPageCount, |
| 34 | - ]); |
|
| 35 | - parent::__construct( $reviews, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
| 34 | + ] ); |
|
| 35 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | 'navigation' => $this->getNavigation(), |
| 59 | 59 | 'reviews' => $this->getReviews(), |
| 60 | 60 | ], |
| 61 | - ]); |
|
| 61 | + ] ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $defaults[] = 'glsr-ajax-pagination'; |
| 74 | 74 | } |
| 75 | 75 | $classes = explode( ' ', $this->args['class'] ); |
| 76 | - $classes = array_unique( array_merge( $defaults, $classes )); |
|
| 76 | + $classes = array_unique( array_merge( $defaults, $classes ) ); |
|
| 77 | 77 | return implode( ' ', $classes ); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | protected function getReviews() |
| 94 | 94 | { |
| 95 | - return empty( $this->reviews ) |
|
| 95 | + return empty($this->reviews) |
|
| 96 | 96 | ? $this->getReviewsFallback() |
| 97 | 97 | : implode( PHP_EOL, $this->reviews ); |
| 98 | 98 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | protected function getReviewsFallback() |
| 104 | 104 | { |
| 105 | - if( empty( $this->args['fallback'] ) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' )) { |
|
| 105 | + if( empty($this->args['fallback']) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' ) ) { |
|
| 106 | 106 | $this->args['fallback'] = __( 'There are no reviews yet. Be the first one to write one.', 'site-reviews' ); |
| 107 | 107 | } |
| 108 | 108 | $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>'; |
@@ -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 | $potFile = glsr()->path( glsr()->languages.'/'.Application::ID.'.pot' ); |
| 48 | 48 | $entries = $this->extractEntriesFromPotFile( $potFile ); |
| 49 | 49 | $entries = apply_filters( 'site-reviews/translation/entries', $entries ); |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function filter( $filterWith = null, $entries = null, $intersect = true ) |
| 90 | 90 | { |
| 91 | - if( !is_array( $entries )) { |
|
| 91 | + if( !is_array( $entries ) ) { |
|
| 92 | 92 | $entries = $this->results; |
| 93 | 93 | } |
| 94 | - if( !is_array( $filterWith )) { |
|
| 94 | + if( !is_array( $filterWith ) ) { |
|
| 95 | 95 | $filterWith = $this->translations(); |
| 96 | 96 | } |
| 97 | - $keys = array_flip( glsr_array_column( $filterWith, 'id' )); |
|
| 97 | + $keys = array_flip( glsr_array_column( $filterWith, 'id' ) ); |
|
| 98 | 98 | $this->results = $intersect |
| 99 | 99 | ? array_intersect_key( $entries, $keys ) |
| 100 | 100 | : array_diff_key( $entries, $keys ); |
@@ -108,17 +108,17 @@ discard block |
||
| 108 | 108 | public function render( $template, array $entry ) |
| 109 | 109 | { |
| 110 | 110 | $data = array_combine( |
| 111 | - array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry )), |
|
| 111 | + array_map( function( $key ) { return 'data.'.$key; }, array_keys( $entry ) ), |
|
| 112 | 112 | $entry |
| 113 | 113 | ); |
| 114 | 114 | $data['data.class'] = $data['data.error'] = ''; |
| 115 | - if( array_search( $entry['s1'], glsr_array_column( $this->entries(), 'msgid' )) === false ) { |
|
| 115 | + if( array_search( $entry['s1'], glsr_array_column( $this->entries(), 'msgid' ) ) === false ) { |
|
| 116 | 116 | $data['data.class'] = 'is-invalid'; |
| 117 | 117 | $data['data.error'] = __( 'This custom translation is no longer valid as the original text has been changed or removed.', 'site-reviews' ); |
| 118 | 118 | } |
| 119 | 119 | return glsr( Template::class )->build( 'partials/translations/'.$template, [ |
| 120 | 120 | 'context' => $data, |
| 121 | - ]); |
|
| 121 | + ] ); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -150,13 +150,13 @@ discard block |
||
| 150 | 150 | 'p1' => $this->getEntryString( $entry, 'msgid_plural' ), |
| 151 | 151 | 's1' => $this->getEntryString( $entry, 'msgid' ), |
| 152 | 152 | ]; |
| 153 | - $text = !empty( $data['p1'] ) |
|
| 153 | + $text = !empty($data['p1']) |
|
| 154 | 154 | ? sprintf( '%s | %s', $data['s1'], $data['p1'] ) |
| 155 | 155 | : $data['s1']; |
| 156 | 156 | $rendered .= $this->render( 'result', [ |
| 157 | - 'entry' => json_encode( $data, JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_TAG|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE ), |
|
| 157 | + 'entry' => json_encode( $data, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ), |
|
| 158 | 158 | 'text' => wp_strip_all_tags( $text ), |
| 159 | - ]); |
|
| 159 | + ] ); |
|
| 160 | 160 | } |
| 161 | 161 | if( $resetAfterRender ) { |
| 162 | 162 | $this->reset(); |
@@ -189,12 +189,12 @@ discard block |
||
| 189 | 189 | public function search( $needle = '' ) |
| 190 | 190 | { |
| 191 | 191 | $this->reset(); |
| 192 | - $needle = trim( strtolower( $needle )); |
|
| 192 | + $needle = trim( strtolower( $needle ) ); |
|
| 193 | 193 | foreach( $this->entries() as $key => $entry ) { |
| 194 | - $single = strtolower( $this->getEntryString( $entry, 'msgid' )); |
|
| 195 | - $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' )); |
|
| 194 | + $single = strtolower( $this->getEntryString( $entry, 'msgid' ) ); |
|
| 195 | + $plural = strtolower( $this->getEntryString( $entry, 'msgid_plural' ) ); |
|
| 196 | 196 | if( strlen( $needle ) < static::SEARCH_THRESHOLD ) { |
| 197 | - if( in_array( $needle, [$single, $plural] )) { |
|
| 197 | + if( in_array( $needle, [$single, $plural] ) ) { |
|
| 198 | 198 | $this->results[$key] = $entry; |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -212,10 +212,10 @@ discard block |
||
| 212 | 212 | public function translations() |
| 213 | 213 | { |
| 214 | 214 | static $translations; |
| 215 | - if( empty( $translations )) { |
|
| 215 | + if( empty($translations) ) { |
|
| 216 | 216 | $settings = glsr( OptionManager::class )->get( 'settings' ); |
| 217 | - $translations = isset( $settings['strings'] ) |
|
| 218 | - ? $this->normalizeSettings( (array) $settings['strings'] ) |
|
| 217 | + $translations = isset($settings['strings']) |
|
| 218 | + ? $this->normalizeSettings( (array)$settings['strings'] ) |
|
| 219 | 219 | : []; |
| 220 | 220 | } |
| 221 | 221 | return $translations; |
@@ -227,8 +227,8 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | protected function getEntryString( array $entry, $key ) |
| 229 | 229 | { |
| 230 | - return isset( $entry[$key] ) |
|
| 231 | - ? implode( '', (array) $entry[$key] ) |
|
| 230 | + return isset($entry[$key]) |
|
| 231 | + ? implode( '', (array)$entry[$key] ) |
|
| 232 | 232 | : ''; |
| 233 | 233 | } |
| 234 | 234 | |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | $keys = [ |
| 241 | 241 | 'msgctxt', 'msgid', 'msgid_plural', 'msgstr', 'msgstr[0]', 'msgstr[1]', |
| 242 | 242 | ]; |
| 243 | - array_walk( $entries, function( &$entry ) use( $keys ) { |
|
| 243 | + array_walk( $entries, function( &$entry ) use($keys) { |
|
| 244 | 244 | foreach( $keys as $key ) { |
| 245 | - if( is_array( $entry )) { |
|
| 245 | + if( is_array( $entry ) ) { |
|
| 246 | 246 | $entry = $this->normalizeEntryString( $entry, $key ); |
| 247 | 247 | continue; |
| 248 | 248 | } |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | protected function normalizeEntryString( array $entry, $key ) |
| 260 | 260 | { |
| 261 | - if( isset( $entry[$key] )) { |
|
| 261 | + if( isset($entry[$key]) ) { |
|
| 262 | 262 | $entry[$key] = $this->getEntryString( $entry, $key ); |
| 263 | 263 | } |
| 264 | 264 | return $entry; |
@@ -272,11 +272,11 @@ discard block |
||
| 272 | 272 | $defaultString = array_fill_keys( ['id', 's1', 's2', 'p1', 'p2'], '' ); |
| 273 | 273 | $strings = array_filter( $strings, 'is_array' ); |
| 274 | 274 | foreach( $strings as &$string ) { |
| 275 | - $string['type'] = isset( $string['p1'] ) ? 'plural' : 'single'; |
|
| 275 | + $string['type'] = isset($string['p1']) ? 'plural' : 'single'; |
|
| 276 | 276 | $string = wp_parse_args( $string, $defaultString ); |
| 277 | 277 | } |
| 278 | 278 | return array_filter( $strings, function( $string ) { |
| 279 | - return !empty( $string['id'] ); |
|
| 279 | + return !empty($string['id']); |
|
| 280 | 280 | }); |
| 281 | 281 | } |
| 282 | 282 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function get() |
| 112 | 112 | { |
| 113 | - return empty( $this->log ) |
|
| 113 | + return empty($this->log) |
|
| 114 | 114 | ? __( 'Console is empty', 'site-reviews' ) |
| 115 | 115 | : $this->log; |
| 116 | 116 | } |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | public function humanSize( $valueIfEmpty = null ) |
| 123 | 123 | { |
| 124 | 124 | $bytes = $this->size(); |
| 125 | - if( empty( $bytes ) && is_string( $valueIfEmpty )) { |
|
| 125 | + if( empty($bytes) && is_string( $valueIfEmpty ) ) { |
|
| 126 | 126 | return $valueIfEmpty; |
| 127 | 127 | } |
| 128 | - $exponent = floor( log( max( $bytes, 1 ), 1024 )); |
|
| 129 | - return round( $bytes / pow( 1024, $exponent ), 2 ).' '.['bytes','KB','MB','GB'][$exponent]; |
|
| 128 | + $exponent = floor( log( max( $bytes, 1 ), 1024 ) ); |
|
| 129 | + return round( $bytes / pow( 1024, $exponent ), 2 ).' '.['bytes', 'KB', 'MB', 'GB'][$exponent]; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -149,9 +149,9 @@ discard block |
||
| 149 | 149 | public function log( $level, $message, array $context = [] ) |
| 150 | 150 | { |
| 151 | 151 | $constants = (new ReflectionClass( __CLASS__ ))->getConstants(); |
| 152 | - if( in_array( $level, $constants, true )) { |
|
| 152 | + if( in_array( $level, $constants, true ) ) { |
|
| 153 | 153 | $entry = $this->buildLogEntry( $level, $message, $context ); |
| 154 | - file_put_contents( $this->file, $entry, FILE_APPEND|LOCK_EX ); |
|
| 154 | + file_put_contents( $this->file, $entry, FILE_APPEND | LOCK_EX ); |
|
| 155 | 155 | $this->reset(); |
| 156 | 156 | } |
| 157 | 157 | return $this; |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | public function logOnce() |
| 164 | 164 | { |
| 165 | 165 | $single = glsr( Session::class )->get( 'glsr_log_once', null, true ); |
| 166 | - if( !is_array( $single ))return; |
|
| 166 | + if( !is_array( $single ) )return; |
|
| 167 | 167 | foreach( $single as $message => $debug ) { |
| 168 | - if( !empty( $debug )) { |
|
| 169 | - $message.= PHP_EOL.print_r( $debug, 1 ); |
|
| 168 | + if( !empty($debug) ) { |
|
| 169 | + $message .= PHP_EOL.print_r( $debug, 1 ); |
|
| 170 | 170 | } |
| 171 | 171 | $this->log( static::RECURRING, $message ); |
| 172 | 172 | } |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | public function once( $message, $debug = '' ) |
| 192 | 192 | { |
| 193 | 193 | $once = glsr( Session::class )->get( 'glsr_log_once', [] ); |
| 194 | - if( !is_array( $once )) { |
|
| 194 | + if( !is_array( $once ) ) { |
|
| 195 | 195 | $once = []; |
| 196 | 196 | } |
| 197 | - if( !isset( $once[$message] )) { |
|
| 197 | + if( !isset($once[$message]) ) { |
|
| 198 | 198 | $once[$message] = $debug; |
| 199 | 199 | glsr( Session::class )->set( 'glsr_log_once', $once ); |
| 200 | 200 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | protected function interpolate( $message, $context = [] ) |
| 258 | 258 | { |
| 259 | - if( $this->isObjectOrArray( $message ) || !is_array( $context )) { |
|
| 259 | + if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) { |
|
| 260 | 260 | return print_r( $message, true ); |
| 261 | 261 | } |
| 262 | 262 | $replace = []; |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | if( $value instanceof DateTime ) { |
| 285 | 285 | $value = $value->format( 'Y-m-d H:i:s' ); |
| 286 | 286 | } |
| 287 | - else if( $this->isObjectOrArray( $value )) { |
|
| 287 | + else if( $this->isObjectOrArray( $value ) ) { |
|
| 288 | 288 | $value = json_encode( $value ); |
| 289 | 289 | } |
| 290 | 290 | return (string)$value; |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | $this->clear(); |
| 300 | 300 | file_put_contents( |
| 301 | 301 | $this->file, |
| 302 | - $this->buildLogEntry( 'info', __( 'Console was automatically cleared (128 KB maximum size)', 'site-reviews' )) |
|
| 302 | + $this->buildLogEntry( 'info', __( 'Console was automatically cleared (128 KB maximum size)', 'site-reviews' ) ) |
|
| 303 | 303 | ); |
| 304 | 304 | } |
| 305 | 305 | } |
@@ -163,7 +163,9 @@ |
||
| 163 | 163 | public function logOnce() |
| 164 | 164 | { |
| 165 | 165 | $single = glsr( Session::class )->get( 'glsr_log_once', null, true ); |
| 166 | - if( !is_array( $single ))return; |
|
| 166 | + if( !is_array( $single )) { |
|
| 167 | + return; |
|
| 168 | + } |
|
| 167 | 169 | foreach( $single as $message => $debug ) { |
| 168 | 170 | if( !empty( $debug )) { |
| 169 | 171 | $message.= PHP_EOL.print_r( $debug, 1 ); |
@@ -30,25 +30,25 @@ discard block |
||
| 30 | 30 | public function __construct( $input ) |
| 31 | 31 | { |
| 32 | 32 | $this->request = $input; |
| 33 | - $this->ajax_request = isset( $input['_ajax_request'] ); |
|
| 33 | + $this->ajax_request = isset($input['_ajax_request']); |
|
| 34 | 34 | $this->assigned_to = $this->getNumeric( 'assign_to' ); |
| 35 | - $this->author = sanitize_text_field( $this->getUser( 'name' )); |
|
| 35 | + $this->author = sanitize_text_field( $this->getUser( 'name' ) ); |
|
| 36 | 36 | $this->avatar = $this->getAvatar(); |
| 37 | - $this->blacklisted = isset( $input['blacklisted'] ); |
|
| 38 | - $this->category = sanitize_key( $this->get( 'category' )); |
|
| 39 | - $this->content = sanitize_textarea_field( $this->get( 'content' )); |
|
| 37 | + $this->blacklisted = isset($input['blacklisted']); |
|
| 38 | + $this->category = sanitize_key( $this->get( 'category' ) ); |
|
| 39 | + $this->content = sanitize_textarea_field( $this->get( 'content' ) ); |
|
| 40 | 40 | $this->custom = $this->getCustom(); |
| 41 | 41 | $this->date = $this->getDate( 'date' ); |
| 42 | - $this->email = sanitize_email( $this->getUser( 'email' )); |
|
| 43 | - $this->form_id = sanitize_key( $this->get( 'form_id' )); |
|
| 42 | + $this->email = sanitize_email( $this->getUser( 'email' ) ); |
|
| 43 | + $this->form_id = sanitize_key( $this->get( 'form_id' ) ); |
|
| 44 | 44 | $this->ip_address = $this->get( 'ip_address' ); |
| 45 | - $this->post_id = intval( $this->get( '_post_id' )); |
|
| 46 | - $this->rating = intval( $this->get( 'rating' )); |
|
| 45 | + $this->post_id = intval( $this->get( '_post_id' ) ); |
|
| 46 | + $this->rating = intval( $this->get( 'rating' ) ); |
|
| 47 | 47 | $this->referer = $this->get( '_referer' ); |
| 48 | - $this->response = sanitize_textarea_field( $this->get( 'response' )); |
|
| 49 | - $this->terms = !empty( $input['terms'] ); |
|
| 50 | - $this->title = sanitize_text_field( $this->get( 'title' )); |
|
| 51 | - $this->url = esc_url_raw( $this->get( 'url' )); |
|
| 48 | + $this->response = sanitize_textarea_field( $this->get( 'response' ) ); |
|
| 49 | + $this->terms = !empty($input['terms']); |
|
| 50 | + $this->title = sanitize_text_field( $this->get( 'title' ) ); |
|
| 51 | + $this->url = esc_url_raw( $this->get( 'url' ) ); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | protected function get( $key ) |
| 59 | 59 | { |
| 60 | - return isset( $this->request[$key] ) |
|
| 60 | + return isset($this->request[$key]) |
|
| 61 | 61 | ? (string)$this->request[$key] |
| 62 | 62 | : ''; |
| 63 | 63 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | { |
| 70 | 70 | $avatar = $this->get( 'avatar' ); |
| 71 | 71 | return !filter_var( $avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED ) |
| 72 | - ? (string)get_avatar_url( $this->get( 'email' )) |
|
| 72 | + ? (string)get_avatar_url( $this->get( 'email' ) ) |
|
| 73 | 73 | : $avatar; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $unset = apply_filters( 'site-reviews/create/unset-keys-from-custom', $unset ); |
| 87 | 87 | $custom = $this->request; |
| 88 | 88 | foreach( $unset as $value ) { |
| 89 | - unset( $custom[$value] ); |
|
| 89 | + unset($custom[$value]); |
|
| 90 | 90 | } |
| 91 | 91 | return $custom; |
| 92 | 92 | } |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | protected function getDate( $key ) |
| 99 | 99 | { |
| 100 | - $date = strtotime( $this->get( $key )); |
|
| 100 | + $date = strtotime( $this->get( $key ) ); |
|
| 101 | 101 | if( $date === false ) { |
| 102 | 102 | $date = time(); |
| 103 | 103 | } |
| 104 | - return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date )); |
|
| 104 | + return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ) ); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -111,13 +111,13 @@ discard block |
||
| 111 | 111 | protected function getUser( $key ) |
| 112 | 112 | { |
| 113 | 113 | $value = $this->get( $key ); |
| 114 | - if( empty( $value )) { |
|
| 114 | + if( empty($value) ) { |
|
| 115 | 115 | $user = wp_get_current_user(); |
| 116 | 116 | $userValues = [ |
| 117 | 117 | 'email' => 'user_email', |
| 118 | 118 | 'name' => 'display_name', |
| 119 | 119 | ]; |
| 120 | - if( $user->exists() && array_key_exists( $key, $userValues )) { |
|
| 120 | + if( $user->exists() && array_key_exists( $key, $userValues ) ) { |
|
| 121 | 121 | return $user->{$userValues[$key]}; |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -21,11 +21,11 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function deleteAllSessions( $sessionCookiePrefix ) |
| 23 | 23 | { |
| 24 | - return $this->db->query(" |
|
| 24 | + return $this->db->query( " |
|
| 25 | 25 | DELETE |
| 26 | 26 | FROM {$this->db->options} |
| 27 | 27 | WHERE option_name LIKE '{$sessionCookiePrefix}_%' |
| 28 | - "); |
|
| 28 | + " ); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function deleteExpiredSessions( $expiredSessions ) |
| 36 | 36 | { |
| 37 | - return $this->db->query(" |
|
| 37 | + return $this->db->query( " |
|
| 38 | 38 | DELETE |
| 39 | 39 | FROM {$this->db->options} |
| 40 | 40 | WHERE option_name IN ('{$expiredSessions}') |
| 41 | - "); |
|
| 41 | + " ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function getExpiredSessions( $sessionCookiePrefix, $limit ) |
| 50 | 50 | { |
| 51 | - return $this->db->get_results(" |
|
| 51 | + return $this->db->get_results( " |
|
| 52 | 52 | SELECT option_name AS name, option_value AS expiration |
| 53 | 53 | FROM {$this->db->options} |
| 54 | 54 | WHERE option_name LIKE '{$sessionCookiePrefix}_expires_%' |
| 55 | 55 | ORDER BY option_value ASC |
| 56 | 56 | LIMIT 0, {$limit} |
| 57 | - "); |
|
| 57 | + " ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -63,14 +63,14 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function getPostIdFromReviewId( $metaReviewId ) |
| 65 | 65 | { |
| 66 | - $postId = $this->db->get_var(" |
|
| 66 | + $postId = $this->db->get_var( " |
|
| 67 | 67 | SELECT p.ID |
| 68 | 68 | FROM {$this->db->posts} AS p |
| 69 | 69 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
| 70 | 70 | WHERE p.post_type = '{Application::POST_TYPE}' |
| 71 | 71 | AND m.meta_key = 'review_id' |
| 72 | 72 | AND m.meta_value = '{$metaReviewId}' |
| 73 | - "); |
|
| 73 | + " ); |
|
| 74 | 74 | return intval( $postId ); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function getReviewCounts( array $args, $lastPostId = 0, $limit = 500 ) |
| 83 | 83 | { |
| 84 | - return $this->db->get_results(" |
|
| 84 | + return $this->db->get_results( " |
|
| 85 | 85 | SELECT p.ID, m1.meta_value AS rating, m2.meta_value AS type |
| 86 | 86 | FROM {$this->db->posts} AS p |
| 87 | 87 | INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id |
@@ -104,14 +104,14 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function getReviewCountsFor( $metaKey ) |
| 106 | 106 | { |
| 107 | - return (array) $this->db->get_results(" |
|
| 107 | + return (array)$this->db->get_results( " |
|
| 108 | 108 | SELECT m.meta_value AS name, COUNT(*) num_posts |
| 109 | 109 | FROM {$this->db->posts} AS p |
| 110 | 110 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
| 111 | 111 | WHERE p.post_type = '{Application::POST_TYPE}' |
| 112 | 112 | AND m.meta_key = '{$metaKey}' |
| 113 | 113 | GROUP BY name |
| 114 | - "); |
|
| 114 | + " ); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function getReviewIdsByType( $reviewType ) |
| 122 | 122 | { |
| 123 | - $query = $this->db->get_col(" |
|
| 123 | + $query = $this->db->get_col( " |
|
| 124 | 124 | SELECT m1.meta_value AS review_id |
| 125 | 125 | FROM {$this->db->posts} AS p |
| 126 | 126 | INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | AND m1.meta_key = 'review_id' |
| 130 | 130 | AND m2.meta_key = 'review_type' |
| 131 | 131 | AND m2.meta_value = '{$reviewType}' |
| 132 | - "); |
|
| 133 | - return array_keys( array_flip( $query )); |
|
| 132 | + " ); |
|
| 133 | + return array_keys( array_flip( $query ) ); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | public function getReviewRatingsFromIds( array $postIds, $greaterThanId = 0, $limit = 100 ) |
| 142 | 142 | { |
| 143 | 143 | sort( $postIds ); |
| 144 | - $postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds )), $limit ); |
|
| 144 | + $postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds ) ), $limit ); |
|
| 145 | 145 | $postIds = implode( ',', $postIds ); |
| 146 | - return $this->db->get_results(" |
|
| 146 | + return $this->db->get_results( " |
|
| 147 | 147 | SELECT p.ID, m.meta_value AS rating |
| 148 | 148 | FROM {$this->db->posts} AS p |
| 149 | 149 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | $queryBuilder = glsr( QueryBuilder::class ); |
| 168 | 168 | $key = $queryBuilder->buildSqlOr( $key, "m.meta_key = '%s'" ); |
| 169 | 169 | $status = $queryBuilder->buildSqlOr( $status, "p.post_status = '%s'" ); |
| 170 | - return $this->db->get_col(" |
|
| 170 | + return $this->db->get_col( " |
|
| 171 | 171 | SELECT DISTINCT m.meta_value |
| 172 | 172 | FROM {$this->db->postmeta} m |
| 173 | 173 | LEFT JOIN {$this->db->posts} p ON p.ID = m.post_id |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | AND ({$key}) |
| 176 | 176 | AND ({$status}) |
| 177 | 177 | ORDER BY m.meta_value |
| 178 | - "); |
|
| 178 | + " ); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | /** |
@@ -184,11 +184,11 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | protected function getAndForCounts( array $args, $and = '' ) |
| 186 | 186 | { |
| 187 | - if( !empty( $args['post_id'] )) { |
|
| 188 | - $and.= "AND m3.meta_key = 'assigned_to' AND m3.meta_value = {$args['post_id']}"; |
|
| 187 | + if( !empty($args['post_id']) ) { |
|
| 188 | + $and .= "AND m3.meta_key = 'assigned_to' AND m3.meta_value = {$args['post_id']}"; |
|
| 189 | 189 | } |
| 190 | - if( !empty( $args['term_taxonomy_id'] )) { |
|
| 191 | - $and.= "AND tr.term_taxonomy_id = {$args['term_taxonomy_id']}"; |
|
| 190 | + if( !empty($args['term_taxonomy_id']) ) { |
|
| 191 | + $and .= "AND tr.term_taxonomy_id = {$args['term_taxonomy_id']}"; |
|
| 192 | 192 | } |
| 193 | 193 | return $and; |
| 194 | 194 | } |
@@ -199,11 +199,11 @@ discard block |
||
| 199 | 199 | */ |
| 200 | 200 | protected function getInnerJoinForCounts( array $args, $innerJoin = '' ) |
| 201 | 201 | { |
| 202 | - if( !empty( $args['post_id'] )) { |
|
| 203 | - $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id"; |
|
| 202 | + if( !empty($args['post_id']) ) { |
|
| 203 | + $innerJoin .= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id"; |
|
| 204 | 204 | } |
| 205 | - if( !empty( $args['term_taxonomy_id'] )) { |
|
| 206 | - $innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id"; |
|
| 205 | + if( !empty($args['term_taxonomy_id']) ) { |
|
| 206 | + $innerJoin .= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id"; |
|
| 207 | 207 | } |
| 208 | 208 | return $innerJoin; |
| 209 | 209 | } |