@@ -20,22 +20,22 @@ discard block |
||
| 20 | 20 | 'class' => 'widefat', |
| 21 | 21 | 'label' => __( 'Title', 'site-reviews' ), |
| 22 | 22 | 'name' => 'title', |
| 23 | - ]); |
|
| 23 | + ] ); |
|
| 24 | 24 | if( count( glsr()->reviewTypes ) > 1 ) { |
| 25 | 25 | $this->renderField( 'select', [ |
| 26 | 26 | 'class' => 'widefat', |
| 27 | 27 | 'label' => __( 'Which type of review would you like to use?', 'site-reviews' ), |
| 28 | 28 | 'name' => 'type', |
| 29 | 29 | 'options' => ['' => __( 'All review types', 'site-reviews' )] + glsr()->reviewTypes, |
| 30 | - ]); |
|
| 30 | + ] ); |
|
| 31 | 31 | } |
| 32 | - if( !empty( $terms )) { |
|
| 32 | + if( !empty($terms) ) { |
|
| 33 | 33 | $this->renderField( 'select', [ |
| 34 | 34 | 'class' => 'widefat', |
| 35 | 35 | 'label' => __( 'Limit summary to this category', 'site-reviews' ), |
| 36 | 36 | 'name' => 'category', |
| 37 | 37 | 'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms, |
| 38 | - ]); |
|
| 38 | + ] ); |
|
| 39 | 39 | } |
| 40 | 40 | $this->renderField( 'text', [ |
| 41 | 41 | 'class' => 'widefat', |
@@ -43,16 +43,16 @@ discard block |
||
| 43 | 43 | 'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ), |
| 44 | 44 | 'label' => __( 'Limit summary to reviews assigned to a page/post ID', 'site-reviews' ), |
| 45 | 45 | 'name' => 'assigned_to', |
| 46 | - ]); |
|
| 46 | + ] ); |
|
| 47 | 47 | $this->renderField( 'text', [ |
| 48 | 48 | 'class' => 'widefat', |
| 49 | 49 | 'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ), |
| 50 | 50 | 'name' => 'class', |
| 51 | - ]); |
|
| 51 | + ] ); |
|
| 52 | 52 | $this->renderField( 'checkbox', [ |
| 53 | 53 | 'name' => 'hide', |
| 54 | 54 | 'options' => glsr( SiteReviewsSummaryShortcode::class )->getHideOptions(), |
| 55 | - ]); |
|
| 55 | + ] ); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | 'label' => '['.$tag.']', |
| 49 | 49 | 'required' => $this->required, |
| 50 | 50 | 'title' => esc_html__( 'Shortcode', 'site-reviews' ), |
| 51 | - ]); |
|
| 51 | + ] ); |
|
| 52 | 52 | return $this; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -58,12 +58,12 @@ discard block |
||
| 58 | 58 | protected function generateFields( array $fields ) |
| 59 | 59 | { |
| 60 | 60 | $generatedFields = array_map( function( $field ) { |
| 61 | - if( empty( $field ))return; |
|
| 61 | + if( empty($field) )return; |
|
| 62 | 62 | $field = $this->normalize( $field ); |
| 63 | - if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] )))return; |
|
| 63 | + if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ) ) )return; |
|
| 64 | 64 | return $this->$method( $field ); |
| 65 | 65 | }, $fields ); |
| 66 | - return array_values( array_filter( $generatedFields )); |
|
| 66 | + return array_values( array_filter( $generatedFields ) ); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | protected function getCategories( $tooltip = '' ) |
| 74 | 74 | { |
| 75 | 75 | $terms = glsr( Database::class )->getTerms(); |
| 76 | - if( empty( $terms )) { |
|
| 76 | + if( empty($terms) ) { |
|
| 77 | 77 | return []; |
| 78 | 78 | } |
| 79 | 79 | return [ |
@@ -91,15 +91,15 @@ discard block |
||
| 91 | 91 | protected function getFields() |
| 92 | 92 | { |
| 93 | 93 | $fields = $this->generateFields( $this->fields() ); |
| 94 | - if( !empty( $this->errors )) { |
|
| 94 | + if( !empty($this->errors) ) { |
|
| 95 | 95 | $errors = []; |
| 96 | 96 | foreach( $this->required as $name => $alert ) { |
| 97 | - if( false !== array_search( $name, glsr_array_column( $fields, 'name' )))continue; |
|
| 97 | + if( false !== array_search( $name, glsr_array_column( $fields, 'name' ) ) )continue; |
|
| 98 | 98 | $errors[] = $this->errors[$name]; |
| 99 | 99 | } |
| 100 | 100 | $this->errors = $errors; |
| 101 | 101 | } |
| 102 | - return empty( $this->errors ) |
|
| 102 | + return empty($this->errors) |
|
| 103 | 103 | ? $fields |
| 104 | 104 | : $this->errors; |
| 105 | 105 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | protected function getHideOptions() |
| 111 | 111 | { |
| 112 | - $classname = str_replace( 'Popup', 'Shortcode', get_class( $this )); |
|
| 112 | + $classname = str_replace( 'Popup', 'Shortcode', get_class( $this ) ); |
|
| 113 | 113 | $hideOptions = glsr( $classname )->getHideOptions(); |
| 114 | 114 | $options = []; |
| 115 | 115 | foreach( $hideOptions as $name => $tooltip ) { |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | return wp_parse_args( $field, [ |
| 150 | 150 | 'items' => [], |
| 151 | 151 | 'type' => '', |
| 152 | - ]); |
|
| 152 | + ] ); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | 'tooltip' => '', |
| 168 | 168 | 'type' => '', |
| 169 | 169 | 'value' => '', |
| 170 | - ]); |
|
| 170 | + ] ); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | protected function normalizeContainer( array $field ) |
| 177 | 177 | { |
| 178 | - if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ))return; |
|
| 178 | + if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ) )return; |
|
| 179 | 179 | $field['items'] = $this->generateFields( $field['items'] ); |
| 180 | 180 | return $field; |
| 181 | 181 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | */ |
| 186 | 186 | protected function normalizeField( array $field, array $defaults ) |
| 187 | 187 | { |
| 188 | - if( !$this->validate( $field ))return; |
|
| 188 | + if( !$this->validate( $field ) )return; |
|
| 189 | 189 | return array_filter( shortcode_atts( $defaults, $field ), function( $value ) { |
| 190 | 190 | return $value !== ''; |
| 191 | 191 | }); |
@@ -205,9 +205,9 @@ discard block |
||
| 205 | 205 | 'tooltip' => '', |
| 206 | 206 | 'type' => '', |
| 207 | 207 | 'value' => '', |
| 208 | - ]); |
|
| 209 | - if( !is_array( $listbox ))return; |
|
| 210 | - if( !array_key_exists( '', $listbox['options'] )) { |
|
| 208 | + ] ); |
|
| 209 | + if( !is_array( $listbox ) )return; |
|
| 210 | + if( !array_key_exists( '', $listbox['options'] ) ) { |
|
| 211 | 211 | $listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options']; |
| 212 | 212 | } |
| 213 | 213 | foreach( $listbox['options'] as $value => $text ) { |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | */ |
| 225 | 225 | protected function normalizePost( array $field ) |
| 226 | 226 | { |
| 227 | - if( !is_array( $field['query_args'] )) { |
|
| 227 | + if( !is_array( $field['query_args'] ) ) { |
|
| 228 | 228 | $field['query_args'] = []; |
| 229 | 229 | } |
| 230 | 230 | $posts = get_posts( wp_parse_args( $field['query_args'], [ |
@@ -232,8 +232,8 @@ discard block |
||
| 232 | 232 | 'orderby' => 'title', |
| 233 | 233 | 'post_type' => 'post', |
| 234 | 234 | 'posts_per_page' => 30, |
| 235 | - ])); |
|
| 236 | - if( !empty( $posts )) { |
|
| 235 | + ] ) ); |
|
| 236 | + if( !empty($posts) ) { |
|
| 237 | 237 | $options = []; |
| 238 | 238 | foreach( $posts as $post ) { |
| 239 | 239 | $options[$post->ID] = esc_html( $post->post_title ); |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | 'tooltip' => '', |
| 264 | 264 | 'type' => '', |
| 265 | 265 | 'value' => '', |
| 266 | - ]); |
|
| 266 | + ] ); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | protected function validate( array $field ) |
| 273 | 273 | { |
| 274 | - $args = shortcode_atts([ |
|
| 274 | + $args = shortcode_atts( [ |
|
| 275 | 275 | 'label' => '', |
| 276 | 276 | 'name' => false, |
| 277 | 277 | 'required' => false, |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | */ |
| 288 | 288 | protected function validateErrors( array $args ) |
| 289 | 289 | { |
| 290 | - if( !isset( $args['required']['error'] )) { |
|
| 290 | + if( !isset($args['required']['error']) ) { |
|
| 291 | 291 | return true; |
| 292 | 292 | } |
| 293 | - $this->errors[$args['name']] = $this->normalizeContainer([ |
|
| 293 | + $this->errors[$args['name']] = $this->normalizeContainer( [ |
|
| 294 | 294 | 'html' => $args['required']['error'], |
| 295 | 295 | 'type' => 'container', |
| 296 | - ]); |
|
| 296 | + ] ); |
|
| 297 | 297 | return false; |
| 298 | 298 | } |
| 299 | 299 | |
@@ -306,10 +306,10 @@ discard block |
||
| 306 | 306 | return true; |
| 307 | 307 | } |
| 308 | 308 | $alert = esc_html__( 'Some of the shortcode options are required.', 'site-reviews' ); |
| 309 | - if( isset( $args['required']['alert'] )) { |
|
| 309 | + if( isset($args['required']['alert']) ) { |
|
| 310 | 310 | $alert = $args['required']['alert']; |
| 311 | 311 | } |
| 312 | - else if( !empty( $args['label'] )) { |
|
| 312 | + else if( !empty($args['label']) ) { |
|
| 313 | 313 | $alert = sprintf( |
| 314 | 314 | esc_html_x( 'The "%s" option is required.', 'the option label', 'site-reviews' ), |
| 315 | 315 | str_replace( ':', '', $args['label'] ) |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE ); |
| 40 | 40 | if( strpos( $cookieId, static::DELIMITER ) !== false ) { |
| 41 | - $cookie = explode( static::DELIMITER, stripslashes( $cookieId )); |
|
| 41 | + $cookie = explode( static::DELIMITER, stripslashes( $cookieId ) ); |
|
| 42 | 42 | $this->sessionId = preg_replace( '/[^A-Za-z0-9_]/', '', $cookie[0] ); |
| 43 | 43 | $this->expiryTimestamp = absint( $cookie[1] ); |
| 44 | 44 | $this->expiryTimestampReset = absint( $cookie[2] ); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function deleteExpiredSessions( $limit = 1000 ) |
| 79 | 79 | { |
| 80 | - if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ))) { |
|
| 80 | + if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ) ) ) { |
|
| 81 | 81 | glsr( SqlQueries::class )->deleteExpiredSessions( $expiredSessions ); |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | public function get( $key, $fallback = '', $unset = false ) |
| 92 | 92 | { |
| 93 | 93 | $key = sanitize_key( $key ); |
| 94 | - $value = isset( $this->sessionData[$key] ) |
|
| 94 | + $value = isset($this->sessionData[$key]) |
|
| 95 | 95 | ? maybe_unserialize( $this->sessionData[$key] ) |
| 96 | 96 | : $fallback; |
| 97 | - if( isset( $this->sessionData[$key] ) && $unset ) { |
|
| 98 | - unset( $this->sessionData[$key] ); |
|
| 97 | + if( isset($this->sessionData[$key]) && $unset ) { |
|
| 98 | + unset($this->sessionData[$key]); |
|
| 99 | 99 | $this->updateSession(); |
| 100 | 100 | } |
| 101 | 101 | return $value; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | protected function deleteSession() |
| 130 | 130 | { |
| 131 | 131 | delete_option( $this->getSessionId() ); |
| 132 | - delete_option( $this->getSessionId( 'expires' )); |
|
| 132 | + delete_option( $this->getSessionId( 'expires' ) ); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | protected function generateSessionId() |
| 139 | 139 | { |
| 140 | - return md5(( new PasswordHash( 8, false ))->get_random_bytes( 32 )); |
|
| 140 | + return md5( (new PasswordHash( 8, false ))->get_random_bytes( 32 ) ); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | protected function getExpiredSessions( $limit ) |
| 148 | 148 | { |
| 149 | 149 | $expiredSessions = []; |
| 150 | - $sessions = glsr( SqlQueries::class )->getExpiredSessions( static::SESSION_COOKIE, absint( $limit )); |
|
| 151 | - if( !empty( $sessions )) { |
|
| 150 | + $sessions = glsr( SqlQueries::class )->getExpiredSessions( static::SESSION_COOKIE, absint( $limit ) ); |
|
| 151 | + if( !empty($sessions) ) { |
|
| 152 | 152 | $now = time(); |
| 153 | 153 | foreach( $sessions as $session ) { |
| 154 | 154 | if( $now <= $session->expiration )continue; |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | protected function getSessionId( $separator = '' ) |
| 167 | 167 | { |
| 168 | - return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] )); |
|
| 168 | + return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] ) ); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | { |
| 197 | 197 | if( headers_sent() )return; |
| 198 | 198 | $cookie = $this->sessionId.static::DELIMITER.$this->expiryTimestamp.static::DELIMITER.$this->expiryTimestampReset; |
| 199 | - $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
|
| 199 | + $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ) ) ); |
|
| 200 | 200 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
| 201 | 201 | } |
| 202 | 202 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | protected function updateSession() |
| 216 | 216 | { |
| 217 | - if( false === get_option( $this->getSessionId() )) { |
|
| 217 | + if( false === get_option( $this->getSessionId() ) ) { |
|
| 218 | 218 | return $this->createSession(); |
| 219 | 219 | } |
| 220 | 220 | update_option( $this->getSessionId(), $this->sessionData, false ); |
@@ -20,16 +20,16 @@ discard block |
||
| 20 | 20 | foreach( array_keys( $ipAddresses ) as $version ) { |
| 21 | 21 | $url = 'https://www.cloudflare.com/ips-'.$version; |
| 22 | 22 | $response = wp_remote_get( $url ); |
| 23 | - if( is_wp_error( $response )) { |
|
| 23 | + if( is_wp_error( $response ) ) { |
|
| 24 | 24 | glsr_log()->error( $response->get_error_message() ); |
| 25 | 25 | continue; |
| 26 | 26 | } |
| 27 | - if(( $statusCode = wp_remote_retrieve_response_code( $response )) != '200' ) { |
|
| 27 | + if( ($statusCode = wp_remote_retrieve_response_code( $response )) != '200' ) { |
|
| 28 | 28 | glsr_log()->error( 'Unable to connect to '.$url.' ['.$statusCode.']' ); |
| 29 | 29 | continue; |
| 30 | 30 | } |
| 31 | 31 | $ipAddresses[$version] = array_filter( |
| 32 | - (array)preg_split( '/\R/', wp_remote_retrieve_body( $response )) |
|
| 32 | + (array)preg_split( '/\R/', wp_remote_retrieve_body( $response ) ) |
|
| 33 | 33 | ); |
| 34 | 34 | } |
| 35 | 35 | set_transient( Application::ID.'_cloudflare_ips', $ipAddresses, static::EXPIRY_TIME ); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | if( $test === false ) { |
| 65 | 65 | $response = wp_remote_post( 'https://api.wordpress.org/stats/php/1.0/' ); |
| 66 | 66 | $test = !is_wp_error( $response ) |
| 67 | - && in_array( $response['response']['code'], range( 200, 299 )) |
|
| 67 | + && in_array( $response['response']['code'], range( 200, 299 ) ) |
|
| 68 | 68 | ? 'Works' |
| 69 | 69 | : 'Does not work'; |
| 70 | 70 | set_transient( Application::ID.'_remote_post_test', $test, static::EXPIRY_TIME ); |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | $this->args = $args; |
| 30 | 30 | $this->max_num_pages = $maxPageCount; |
| 31 | 31 | $this->results = $reviews; |
| 32 | - parent::__construct( $reviews, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
| 32 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function routerChangeStatus( array $request ) |
| 24 | 24 | { |
| 25 | - wp_send_json_success( $this->execute( new ChangeStatus( $request ))); |
|
| 25 | + wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) ); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | public function routerClearConsole() |
| 32 | 32 | { |
| 33 | 33 | glsr( AdminController::class )->routerClearConsole(); |
| 34 | - wp_send_json_success([ |
|
| 34 | + wp_send_json_success( [ |
|
| 35 | 35 | 'console' => glsr( Console::class )->get(), |
| 36 | 36 | 'notices' => glsr( Notice::class )->get(), |
| 37 | - ]); |
|
| 37 | + ] ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | public function routerCountReviews() |
| 44 | 44 | { |
| 45 | 45 | glsr( AdminController::class )->routerCountReviews(); |
| 46 | - wp_send_json_success([ |
|
| 46 | + wp_send_json_success( [ |
|
| 47 | 47 | 'notices' => glsr( Notice::class )->get(), |
| 48 | - ]); |
|
| 48 | + ] ); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $shortcode = $request['shortcode']; |
| 57 | 57 | $response = false; |
| 58 | - if( array_key_exists( $shortcode, glsr()->mceShortcodes )) { |
|
| 58 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
| 59 | 59 | $data = glsr()->mceShortcodes[$shortcode]; |
| 60 | - if( !empty( $data['errors'] )) { |
|
| 60 | + if( !empty($data['errors']) ) { |
|
| 61 | 61 | $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
| 62 | 62 | } |
| 63 | 63 | $response = [ |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | public function routerFetchConsole() |
| 78 | 78 | { |
| 79 | 79 | glsr( AdminController::class )->routerFetchConsole(); |
| 80 | - wp_send_json_success([ |
|
| 80 | + wp_send_json_success( [ |
|
| 81 | 81 | 'console' => glsr( Console::class )->get(), |
| 82 | 82 | 'notices' => glsr( Notice::class )->get(), |
| 83 | - ]); |
|
| 83 | + ] ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | public function routerSearchPosts( array $request ) |
| 90 | 90 | { |
| 91 | 91 | $results = glsr( Database::class )->searchPosts( $request['search'] ); |
| 92 | - wp_send_json_success([ |
|
| 92 | + wp_send_json_success( [ |
|
| 93 | 93 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
| 94 | 94 | 'items' => $results, |
| 95 | - ]); |
|
| 95 | + ] ); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function routerSearchTranslations( array $request ) |
| 102 | 102 | { |
| 103 | - if( empty( $request['exclude'] )) { |
|
| 103 | + if( empty($request['exclude']) ) { |
|
| 104 | 104 | $request['exclude'] = []; |
| 105 | 105 | } |
| 106 | 106 | $results = glsr( Translation::class ) |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | ->exclude() |
| 109 | 109 | ->exclude( $request['exclude'] ) |
| 110 | 110 | ->renderResults(); |
| 111 | - wp_send_json_success([ |
|
| 111 | + wp_send_json_success( [ |
|
| 112 | 112 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
| 113 | 113 | 'items' => $results, |
| 114 | - ]); |
|
| 114 | + ] ); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | public function routerSubmitReview( array $request ) |
| 121 | 121 | { |
| 122 | 122 | $command = glsr( PublicController::class )->routerSubmitReview( $request ); |
| 123 | - $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ))); |
|
| 123 | + $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) ); |
|
| 124 | 124 | $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command ); |
| 125 | 125 | $data = [ |
| 126 | 126 | 'errors' => glsr( Session::class )->get( $command->form_id.'errors', false, true ), |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function routerTogglePinned( array $request ) |
| 142 | 142 | { |
| 143 | - $isPinned = $this->execute( new TogglePinned( $request )); |
|
| 144 | - wp_send_json_success([ |
|
| 143 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
| 144 | + wp_send_json_success( [ |
|
| 145 | 145 | 'notices' => glsr( Notice::class )->get(), |
| 146 | 146 | 'pinned' => $isPinned, |
| 147 | - ]); |
|
| 147 | + ] ); |
|
| 148 | 148 | } |
| 149 | 149 | } |
@@ -33,10 +33,10 @@ discard block |
||
| 33 | 33 | public function filterEnqueuedScripts( $tag, $handle ) |
| 34 | 34 | { |
| 35 | 35 | $scripts = [Application::ID.'/google-recaptcha']; |
| 36 | - if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ))) { |
|
| 36 | + if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ) ) ) { |
|
| 37 | 37 | $tag = str_replace( ' src=', ' async src=', $tag ); |
| 38 | 38 | } |
| 39 | - if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ))) { |
|
| 39 | + if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ) ) ) { |
|
| 40 | 40 | $tag = str_replace( ' src=', ' defer src=', $tag ); |
| 41 | 41 | } |
| 42 | 42 | return $tag; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function filterFieldOrder( array $config ) |
| 51 | 51 | { |
| 52 | - $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config )); |
|
| 52 | + $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config ) ); |
|
| 53 | 53 | return array_intersect_key( array_merge( array_flip( $order ), $config ), $config ); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | { |
| 101 | 101 | $validated = glsr( ValidateReview::class )->validate( $request ); |
| 102 | 102 | $command = new CreateReview( $validated->request ); |
| 103 | - if( empty( $validated->error ) && !$validated->recaptchaIsUnset ) { |
|
| 103 | + if( empty($validated->error) && !$validated->recaptchaIsUnset ) { |
|
| 104 | 104 | $this->execute( $command ); |
| 105 | 105 | } |
| 106 | 106 | return $command; |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | if( $assignedPost instanceof WP_Post && $assignedPost->post_status == 'publish' ) { |
| 22 | 22 | $column = glsr( Builder::class )->a( get_the_title( $assignedPost->ID ), [ |
| 23 | 23 | 'href' => (string)get_the_permalink( $assignedPost->ID ), |
| 24 | - ]); |
|
| 24 | + ] ); |
|
| 25 | 25 | } |
| 26 | 26 | return $column; |
| 27 | 27 | } |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | $pinned = get_post_meta( $postId, 'pinned', true ) |
| 36 | 36 | ? 'pinned ' |
| 37 | 37 | : ''; |
| 38 | - return glsr( Builder::class )->i([ |
|
| 38 | + return glsr( Builder::class )->i( [ |
|
| 39 | 39 | 'class' => $pinned.'dashicons dashicons-sticky', |
| 40 | 40 | 'data-id' => $postId, |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function buildColumnReviewer( $postId ) |
| 49 | 49 | { |
| 50 | - return strval( get_post_meta( $postId, 'author', true )); |
|
| 50 | + return strval( get_post_meta( $postId, 'author', true ) ); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function buildColumnRating( $postId ) |
| 59 | 59 | { |
| 60 | - return glsr_star_rating( intval( get_post_meta( $postId, 'rating', true ))); |
|
| 60 | + return glsr_star_rating( intval( get_post_meta( $postId, 'rating', true ) ) ); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function renderFilters( $postType ) |
| 80 | 80 | { |
| 81 | 81 | if( $postType !== Application::POST_TYPE )return; |
| 82 | - if( !( $status = filter_input( INPUT_GET, 'post_status' ))) { |
|
| 82 | + if( !($status = filter_input( INPUT_GET, 'post_status' )) ) { |
|
| 83 | 83 | $status = 'publish'; |
| 84 | 84 | } |
| 85 | 85 | $ratings = glsr( Database::class )->getReviewsMeta( 'rating', $status ); |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | protected function renderFilterRatings( $ratings ) |
| 110 | 110 | { |
| 111 | - if( empty( $ratings ))return; |
|
| 112 | - $ratings = array_flip( array_reverse( $ratings )); |
|
| 111 | + if( empty($ratings) )return; |
|
| 112 | + $ratings = array_flip( array_reverse( $ratings ) ); |
|
| 113 | 113 | array_walk( $ratings, function( &$value, $key ) { |
| 114 | 114 | $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
| 115 | 115 | $value = sprintf( $label, $key ); |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | echo glsr( Builder::class )->label( __( 'Filter by rating', 'site-reviews' ), [ |
| 118 | 118 | 'class' => 'screen-reader-text', |
| 119 | 119 | 'for' => 'rating', |
| 120 | - ]); |
|
| 121 | - echo glsr( Builder::class )->select([ |
|
| 120 | + ] ); |
|
| 121 | + echo glsr( Builder::class )->select( [ |
|
| 122 | 122 | 'name' => 'rating', |
| 123 | 123 | 'options' => ['' => __( 'All ratings', 'site-reviews' )] + $ratings, |
| 124 | 124 | 'value' => filter_input( INPUT_GET, 'rating' ), |
| 125 | - ]); |
|
| 125 | + ] ); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -135,11 +135,11 @@ discard block |
||
| 135 | 135 | echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [ |
| 136 | 136 | 'class' => 'screen-reader-text', |
| 137 | 137 | 'for' => 'review_type', |
| 138 | - ]); |
|
| 139 | - echo glsr( Builder::class )->select([ |
|
| 138 | + ] ); |
|
| 139 | + echo glsr( Builder::class )->select( [ |
|
| 140 | 140 | 'name' => 'review_type', |
| 141 | 141 | 'options' => ['' => __( 'All types', 'site-reviews' )] + glsr()->reviewTypes, |
| 142 | 142 | 'value' => filter_input( INPUT_GET, 'review_type' ), |
| 143 | - ]); |
|
| 143 | + ] ); |
|
| 144 | 144 | } |
| 145 | 145 | } |
@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | public function fields() |
| 14 | 14 | { |
| 15 | 15 | return [[ |
| 16 | - 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' )), |
|
| 16 | + 'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'All settings are optional.', 'site-reviews' ) ), |
|
| 17 | 17 | 'minWidth' => 320, |
| 18 | 18 | 'type' => 'container', |
| 19 | - ],[ |
|
| 19 | + ], [ |
|
| 20 | 20 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
| 21 | 21 | 'name' => 'title', |
| 22 | 22 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
| 23 | 23 | 'type' => 'textbox', |
| 24 | - ],[ |
|
| 24 | + ], [ |
|
| 25 | 25 | 'label' => esc_html__( 'Count', 'site-reviews' ), |
| 26 | 26 | 'maxLength' => 5, |
| 27 | 27 | 'name' => 'count', |
@@ -29,20 +29,20 @@ discard block |
||
| 29 | 29 | 'text' => '10', |
| 30 | 30 | 'tooltip' => __( 'How many reviews would you like to display (default: 10)?', 'site-reviews' ), |
| 31 | 31 | 'type' => 'textbox', |
| 32 | - ],[ |
|
| 32 | + ], [ |
|
| 33 | 33 | 'label' => esc_html__( 'Rating', 'site-reviews' ), |
| 34 | 34 | 'name' => 'rating', |
| 35 | 35 | 'options' => [ |
| 36 | - '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 )), |
|
| 37 | - '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 )), |
|
| 38 | - '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 )), |
|
| 39 | - '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 )), |
|
| 40 | - '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 )), |
|
| 41 | - '0' => esc_html( __( 'Unrated', 'site-reviews' )), |
|
| 36 | + '5' => esc_html( sprintf( _n( '%s star', '%s stars', 5, 'site-reviews' ), 5 ) ), |
|
| 37 | + '4' => esc_html( sprintf( _n( '%s star', '%s stars', 4, 'site-reviews' ), 4 ) ), |
|
| 38 | + '3' => esc_html( sprintf( _n( '%s star', '%s stars', 3, 'site-reviews' ), 3 ) ), |
|
| 39 | + '2' => esc_html( sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ) ), |
|
| 40 | + '1' => esc_html( sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ) ), |
|
| 41 | + '0' => esc_html( __( 'Unrated', 'site-reviews' ) ), |
|
| 42 | 42 | ], |
| 43 | 43 | 'tooltip' => __( 'What is the minimum rating to display (default: 1 star)?', 'site-reviews' ), |
| 44 | 44 | 'type' => 'listbox', |
| 45 | - ],[ |
|
| 45 | + ], [ |
|
| 46 | 46 | 'label' => esc_html__( 'Pagination', 'site-reviews' ), |
| 47 | 47 | 'name' => 'pagination', |
| 48 | 48 | 'options' => [ |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | 'tooltip' => __( 'When using pagination this shortcode can only be used once on a page. (default: disable)', 'site-reviews' ), |
| 54 | 54 | 'type' => 'listbox', |
| 55 | 55 | ], |
| 56 | - $this->getTypes( __( 'Which type of review would you like to display?', 'site-reviews' )), |
|
| 57 | - $this->getCategories( __( 'Limit reviews to this category.', 'site-reviews' )), |
|
| 56 | + $this->getTypes( __( 'Which type of review would you like to display?', 'site-reviews' ) ), |
|
| 57 | + $this->getCategories( __( 'Limit reviews to this category.', 'site-reviews' ) ), |
|
| 58 | 58 | [ |
| 59 | 59 | 'label' => esc_html__( 'Assigned To', 'site-reviews' ), |
| 60 | 60 | 'name' => 'assigned_to', |
| 61 | 61 | 'tooltip' => __( 'Limit reviews to those assigned to this post ID (separate multiple IDs with a comma). You can also enter "post_id" to use the ID of the current page, or "parent_id" to use the ID of the parent page.', 'site-reviews' ), |
| 62 | 62 | 'type' => 'textbox', |
| 63 | - ],[ |
|
| 63 | + ], [ |
|
| 64 | 64 | 'label' => esc_html__( 'Schema', 'site-reviews' ), |
| 65 | 65 | 'name' => 'schema', |
| 66 | 66 | 'options' => [ |
@@ -69,19 +69,19 @@ discard block |
||
| 69 | 69 | ], |
| 70 | 70 | 'tooltip' => __( 'Rich snippets are disabled by default.', 'site-reviews' ), |
| 71 | 71 | 'type' => 'listbox', |
| 72 | - ],[ |
|
| 72 | + ], [ |
|
| 73 | 73 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
| 74 | 74 | 'name' => 'class', |
| 75 | 75 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
| 76 | 76 | 'type' => 'textbox', |
| 77 | - ],[ |
|
| 77 | + ], [ |
|
| 78 | 78 | 'columns' => 2, |
| 79 | 79 | 'items' => $this->getHideOptions(), |
| 80 | 80 | 'label' => esc_html__( 'Hide', 'site-reviews' ), |
| 81 | 81 | 'layout' => 'grid', |
| 82 | 82 | 'spacing' => 5, |
| 83 | 83 | 'type' => 'container', |
| 84 | - ],[ |
|
| 84 | + ], [ |
|
| 85 | 85 | 'hidden' => true, |
| 86 | 86 | 'name' => 'id', |
| 87 | 87 | 'type' => 'textbox', |