@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | 'post_type' => Application::POST_TYPE, |
| 40 | 40 | ]; |
| 41 | 41 | $postId = wp_insert_post( $postValues, true ); |
| 42 | - if( is_wp_error( $postId )) { |
|
| 42 | + if( is_wp_error( $postId ) ) { |
|
| 43 | 43 | glsr_log()->error( $postId->get_error_message() )->debug( $postValues ); |
| 44 | 44 | return false; |
| 45 | 45 | } |
| 46 | 46 | $this->setTerms( $postId, $command->category ); |
| 47 | - $review = $this->single( get_post( $postId )); |
|
| 47 | + $review = $this->single( get_post( $postId ) ); |
|
| 48 | 48 | do_action( 'site-reviews/review/created', $review, $command ); |
| 49 | 49 | return $review; |
| 50 | 50 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function delete( $metaReviewId ) |
| 57 | 57 | { |
| 58 | - if( $postId = $this->getPostId( $metaReviewId )) { |
|
| 58 | + if( $postId = $this->getPostId( $metaReviewId ) ) { |
|
| 59 | 59 | wp_delete_post( $postId, true ); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -113,14 +113,14 @@ discard block |
||
| 113 | 113 | public function getRatingCounts( array $args = [] ) |
| 114 | 114 | { |
| 115 | 115 | $args = glsr( SiteReviewsSummaryDefaults::class )->filter( $args ); |
| 116 | - $counts = glsr( CountsManager::class )->get([ |
|
| 116 | + $counts = glsr( CountsManager::class )->get( [ |
|
| 117 | 117 | 'post_ids' => glsr( Helper::class )->convertStringToArray( $args['assigned_to'] ), |
| 118 | 118 | 'term_ids' => $this->normalizeTermIds( $args['category'] ), |
| 119 | 119 | 'type' => $args['type'], |
| 120 | - ]); |
|
| 120 | + ] ); |
|
| 121 | 121 | return glsr( CountsManager::class )->flatten( $counts, [ |
| 122 | 122 | 'min' => $args['rating'], |
| 123 | - ]); |
|
| 123 | + ] ); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | public function normalizeTermIds( $commaSeparatedTermIds ) |
| 131 | 131 | { |
| 132 | 132 | $termIds = glsr_array_column( $this->normalizeTerms( $commaSeparatedTermIds ), 'term_id' ); |
| 133 | - return array_unique( array_map( 'intval', $termIds )); |
|
| 133 | + return array_unique( array_map( 'intval', $termIds ) ); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | $terms = []; |
| 143 | 143 | $termIds = glsr( Helper::class )->convertStringToArray( $commaSeparatedTermIds ); |
| 144 | 144 | foreach( $termIds as $termId ) { |
| 145 | - if( is_numeric( $termId )) { |
|
| 145 | + if( is_numeric( $termId ) ) { |
|
| 146 | 146 | $termId = intval( $termId ); |
| 147 | 147 | } |
| 148 | 148 | $term = term_exists( $termId, Application::TAXONOMY ); |
| 149 | - if( !isset( $term['term_id'] ))continue; |
|
| 149 | + if( !isset($term['term_id']) )continue; |
|
| 150 | 150 | $terms[] = $term; |
| 151 | 151 | } |
| 152 | 152 | return $terms; |
@@ -160,13 +160,13 @@ discard block |
||
| 160 | 160 | { |
| 161 | 161 | if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
| 162 | 162 | delete_post_meta( $postId, '_edit_last' ); |
| 163 | - $result = wp_update_post([ |
|
| 163 | + $result = wp_update_post( [ |
|
| 164 | 164 | 'ID' => $postId, |
| 165 | 165 | 'post_content' => get_post_meta( $postId, 'content', true ), |
| 166 | 166 | 'post_date' => get_post_meta( $postId, 'date', true ), |
| 167 | 167 | 'post_title' => get_post_meta( $postId, 'title', true ), |
| 168 | - ]); |
|
| 169 | - if( is_wp_error( $result )) { |
|
| 168 | + ] ); |
|
| 169 | + if( is_wp_error( $result ) ) { |
|
| 170 | 170 | glsr_log()->error( $result->get_error_message() ); |
| 171 | 171 | } |
| 172 | 172 | } |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | protected function getNewPostStatus( array $review, $isBlacklisted ) |
| 191 | 191 | { |
| 192 | 192 | $requireApproval = glsr( OptionManager::class )->getBool( 'settings.general.require.approval' ); |
| 193 | - return $review['review_type'] == 'local' && ( $requireApproval || $isBlacklisted ) |
|
| 193 | + return $review['review_type'] == 'local' && ($requireApproval || $isBlacklisted) |
|
| 194 | 194 | ? 'pending' |
| 195 | 195 | : 'publish'; |
| 196 | 196 | } |
@@ -203,9 +203,9 @@ discard block |
||
| 203 | 203 | protected function setTerms( $postId, $termIds ) |
| 204 | 204 | { |
| 205 | 205 | $termIds = $this->normalizeTermIds( $termIds ); |
| 206 | - if( empty( $termIds ))return; |
|
| 206 | + if( empty($termIds) )return; |
|
| 207 | 207 | $termTaxonomyIds = wp_set_object_terms( $postId, $termIds, Application::TAXONOMY ); |
| 208 | - if( is_wp_error( $termTaxonomyIds )) { |
|
| 208 | + if( is_wp_error( $termTaxonomyIds ) ) { |
|
| 209 | 209 | glsr_log()->error( $termTaxonomyIds->get_error_message() ); |
| 210 | 210 | } |
| 211 | 211 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | { |
| 17 | 17 | $className = $this->camelCase( $name ); |
| 18 | 18 | $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' ); |
| 19 | - return !empty( $path ) |
|
| 19 | + return !empty($path) |
|
| 20 | 20 | ? __NAMESPACE__.'\\'.$path.'\\'.$className |
| 21 | 21 | : $className; |
| 22 | 22 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | public function buildMethodName( $name, $prefix = '' ) |
| 30 | 30 | { |
| 31 | - return lcfirst( $prefix.$this->buildClassName( $name )); |
|
| 31 | + return lcfirst( $prefix.$this->buildClassName( $name ) ); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function buildPropertyName( $name ) |
| 39 | 39 | { |
| 40 | - return lcfirst( $this->buildClassName( $name )); |
|
| 40 | + return lcfirst( $this->buildClassName( $name ) ); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function camelCase( $string ) |
| 48 | 48 | { |
| 49 | - $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ))); |
|
| 49 | + $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ) ) ); |
|
| 50 | 50 | return str_replace( ' ', '', $string ); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function convertPathToId( $path, $prefix = '' ) |
| 91 | 91 | { |
| 92 | - return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix )); |
|
| 92 | + return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix ) ); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | { |
| 101 | 101 | $levels = explode( '.', $path ); |
| 102 | 102 | return array_reduce( $levels, function( $result, $value ) { |
| 103 | - return $result.= '['.$value.']'; |
|
| 103 | + return $result .= '['.$value.']'; |
|
| 104 | 104 | }, $prefix ); |
| 105 | 105 | } |
| 106 | 106 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function convertStringToArray( $string, $callback = null ) |
| 113 | 113 | { |
| 114 | - $array = array_map( 'trim', explode( ',', $string )); |
|
| 114 | + $array = array_map( 'trim', explode( ',', $string ) ); |
|
| 115 | 115 | return $callback |
| 116 | 116 | ? array_filter( $array, $callback ) |
| 117 | 117 | : array_filter( $array ); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function dashCase( $string ) |
| 125 | 125 | { |
| 126 | - return str_replace( '_', '-', $this->snakeCase( $string )); |
|
| 126 | + return str_replace( '_', '-', $this->snakeCase( $string ) ); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $data = $this->consolidateArray( $data ); |
| 139 | 139 | $keys = explode( '.', $path ); |
| 140 | 140 | foreach( $keys as $key ) { |
| 141 | - if( !isset( $data[$key] )) { |
|
| 141 | + if( !isset($data[$key]) ) { |
|
| 142 | 142 | return $fallback; |
| 143 | 143 | } |
| 144 | 144 | $data = $data[$key]; |
@@ -184,11 +184,11 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function filterInput( $key, array $request = [] ) |
| 186 | 186 | { |
| 187 | - if( isset( $request[$key] )) { |
|
| 187 | + if( isset($request[$key]) ) { |
|
| 188 | 188 | return $request[$key]; |
| 189 | 189 | } |
| 190 | 190 | $variable = filter_input( INPUT_POST, $key ); |
| 191 | - if( is_null( $variable ) && isset( $_POST[$key] )) { |
|
| 191 | + if( is_null( $variable ) && isset($_POST[$key]) ) { |
|
| 192 | 192 | $variable = $_POST[$key]; |
| 193 | 193 | } |
| 194 | 194 | return $variable; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | public function filterInputArray( $key ) |
| 202 | 202 | { |
| 203 | 203 | $variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
| 204 | - if( empty( $variable ) && !empty( $_POST[$key] ) && is_array( $_POST[$key] )) { |
|
| 204 | + if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) { |
|
| 205 | 205 | $variable = $_POST[$key]; |
| 206 | 206 | } |
| 207 | 207 | return (array)$variable; |
@@ -217,13 +217,13 @@ discard block |
||
| 217 | 217 | $result = []; |
| 218 | 218 | foreach( $array as $key => $value ) { |
| 219 | 219 | $newKey = ltrim( $prefix.'.'.$key, '.' ); |
| 220 | - if( $this->isIndexedFlatArray( $value )) { |
|
| 220 | + if( $this->isIndexedFlatArray( $value ) ) { |
|
| 221 | 221 | if( $flattenValue ) { |
| 222 | 222 | $value = '['.implode( ', ', $value ).']'; |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | - else if( is_array( $value )) { |
|
| 226 | - $result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey )); |
|
| 225 | + else if( is_array( $value ) ) { |
|
| 226 | + $result = array_merge( $result, $this->flattenArray( $value, $flattenValue, $newKey ) ); |
|
| 227 | 227 | continue; |
| 228 | 228 | } |
| 229 | 229 | $result[$newKey] = $value; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | Whip::IPV4 => $cloudflareIps['v4'], |
| 246 | 246 | Whip::IPV6 => $ipv6, |
| 247 | 247 | ], |
| 248 | - ]); |
|
| 248 | + ] ); |
|
| 249 | 249 | $whip = new Whip( Whip::ALL_METHODS, $whitelist ); |
| 250 | 250 | do_action_ref_array( 'site-reviews/whip', [&$whip] ); |
| 251 | 251 | return (string)$whip->getValidIpAddress(); |
@@ -258,14 +258,14 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | public function insertInArray( array $array, array $insert, $key, $position = 'before' ) |
| 260 | 260 | { |
| 261 | - $keyPosition = intval( array_search( $key, array_keys( $array ))); |
|
| 261 | + $keyPosition = intval( array_search( $key, array_keys( $array ) ) ); |
|
| 262 | 262 | if( 'after' == $position ) { |
| 263 | 263 | $keyPosition++; |
| 264 | 264 | } |
| 265 | 265 | if( false !== $keyPosition ) { |
| 266 | 266 | $result = array_slice( $array, 0, $keyPosition ); |
| 267 | 267 | $result = array_merge( $result, $insert ); |
| 268 | - return array_merge( $result, array_slice( $array, $keyPosition )); |
|
| 268 | + return array_merge( $result, array_slice( $array, $keyPosition ) ); |
|
| 269 | 269 | } |
| 270 | 270 | return array_merge( $array, $insert ); |
| 271 | 271 | } |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | public function isIndexedFlatArray( $array ) |
| 278 | 278 | { |
| 279 | - if( !is_array( $array ) || array_filter( $array, 'is_array' )) { |
|
| 279 | + if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) { |
|
| 280 | 280 | return false; |
| 281 | 281 | } |
| 282 | 282 | return wp_is_numeric_array( $array ); |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | */ |
| 290 | 290 | public function prefixString( $string, $prefix = '' ) |
| 291 | 291 | { |
| 292 | - return $prefix.str_replace( $prefix, '', trim( $string )); |
|
| 292 | + return $prefix.str_replace( $prefix, '', trim( $string ) ); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | public function removePrefix( $prefix, $text ) |
| 316 | 316 | { |
| 317 | 317 | return 0 === strpos( $text, $prefix ) |
| 318 | - ? substr( $text, strlen( $prefix )) |
|
| 318 | + ? substr( $text, strlen( $prefix ) ) |
|
| 319 | 319 | : $text; |
| 320 | 320 | } |
| 321 | 321 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | */ |
| 326 | 326 | public function snakeCase( $string ) |
| 327 | 327 | { |
| 328 | - if( !ctype_lower( $string )) { |
|
| 328 | + if( !ctype_lower( $string ) ) { |
|
| 329 | 329 | $string = preg_replace( '/\s+/u', '', $string ); |
| 330 | 330 | $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string ); |
| 331 | 331 | $string = function_exists( 'mb_strtolower' ) |
@@ -342,6 +342,6 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | public function startsWith( $needle, $haystack ) |
| 344 | 344 | { |
| 345 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
| 345 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
| 346 | 346 | } |
| 347 | 347 | } |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | sort( $termTaxonomyIds ); |
| 28 | 28 | sort( $oldTermTaxonomyIds ); |
| 29 | - if( $termTaxonomyIds === $oldTermTaxonomyIds || !$this->isReviewPostId( $postId ))return; |
|
| 30 | - $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
|
| 29 | + if( $termTaxonomyIds === $oldTermTaxonomyIds || !$this->isReviewPostId( $postId ) )return; |
|
| 30 | + $review = glsr( ReviewManager::class )->single( get_post( $postId ) ); |
|
| 31 | 31 | $ignoredIds = array_intersect( $oldTermTaxonomyIds, $termTaxonomyIds ); |
| 32 | 32 | $decreasedIds = array_diff( $oldTermTaxonomyIds, $ignoredIds ); |
| 33 | 33 | $increasedIds = array_diff( $termTaxonomyIds, $ignoredIds ); |
| 34 | - if( $review->term_ids = glsr( Database::class )->getTermIds( $decreasedIds, 'term_taxonomy_id' )) { |
|
| 34 | + if( $review->term_ids = glsr( Database::class )->getTermIds( $decreasedIds, 'term_taxonomy_id' ) ) { |
|
| 35 | 35 | glsr( CountsManager::class )->decreaseTermCounts( $review ); |
| 36 | 36 | } |
| 37 | - if( $review->term_ids = glsr( Database::class )->getTermIds( $increasedIds, 'term_taxonomy_id' )) { |
|
| 37 | + if( $review->term_ids = glsr( Database::class )->getTermIds( $increasedIds, 'term_taxonomy_id' ) ) { |
|
| 38 | 38 | glsr( CountsManager::class )->increaseTermCounts( $review ); |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function onAfterChangeStatus( $newStatus, $oldStatus, $post ) |
| 50 | 50 | { |
| 51 | - if( glsr_get( $post, 'post_type') != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
| 52 | - $review = glsr( ReviewManager::class )->single( get_post( $post->ID )); |
|
| 51 | + if( glsr_get( $post, 'post_type' ) != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ) )return; |
|
| 52 | + $review = glsr( ReviewManager::class )->single( get_post( $post->ID ) ); |
|
| 53 | 53 | if( $post->post_status == 'publish' ) { |
| 54 | 54 | glsr( CountsManager::class )->increase( $review ); |
| 55 | 55 | } |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function onBeforeDelete( $postId ) |
| 77 | 77 | { |
| 78 | - if( !$this->isReviewPostId( $postId ))return; |
|
| 79 | - $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
|
| 78 | + if( !$this->isReviewPostId( $postId ) )return; |
|
| 79 | + $review = glsr( ReviewManager::class )->single( get_post( $postId ) ); |
|
| 80 | 80 | glsr( CountsManager::class )->decrease( $review ); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | if( !$this->isReviewPostId( $postId ) |
| 94 | 94 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
| 95 | 95 | )return; |
| 96 | - $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
|
| 96 | + $review = glsr( ReviewManager::class )->single( get_post( $postId ) ); |
|
| 97 | 97 | if( $review->$metaKey == $metaValue )return; |
| 98 | 98 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
| 99 | 99 | call_user_func( [$this, $method], $review, $metaValue ); |
@@ -26,7 +26,9 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | sort( $termTaxonomyIds ); |
| 28 | 28 | sort( $oldTermTaxonomyIds ); |
| 29 | - if( $termTaxonomyIds === $oldTermTaxonomyIds || !$this->isReviewPostId( $postId ))return; |
|
| 29 | + if( $termTaxonomyIds === $oldTermTaxonomyIds || !$this->isReviewPostId( $postId )) { |
|
| 30 | + return; |
|
| 31 | + } |
|
| 30 | 32 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 31 | 33 | $ignoredIds = array_intersect( $oldTermTaxonomyIds, $termTaxonomyIds ); |
| 32 | 34 | $decreasedIds = array_diff( $oldTermTaxonomyIds, $ignoredIds ); |
@@ -48,7 +50,9 @@ discard block |
||
| 48 | 50 | */ |
| 49 | 51 | public function onAfterChangeStatus( $newStatus, $oldStatus, $post ) |
| 50 | 52 | { |
| 51 | - if( glsr_get( $post, 'post_type') != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
| 53 | + if( glsr_get( $post, 'post_type') != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] )) { |
|
| 54 | + return; |
|
| 55 | + } |
|
| 52 | 56 | $review = glsr( ReviewManager::class )->single( get_post( $post->ID )); |
| 53 | 57 | if( $post->post_status == 'publish' ) { |
| 54 | 58 | glsr( CountsManager::class )->increase( $review ); |
@@ -64,7 +68,9 @@ discard block |
||
| 64 | 68 | */ |
| 65 | 69 | public function onAfterCreate( Review $review ) |
| 66 | 70 | { |
| 67 | - if( $review->status !== 'publish' )return; |
|
| 71 | + if( $review->status !== 'publish' ) { |
|
| 72 | + return; |
|
| 73 | + } |
|
| 68 | 74 | glsr( CountsManager::class )->increase( $review ); |
| 69 | 75 | } |
| 70 | 76 | |
@@ -75,7 +81,9 @@ discard block |
||
| 75 | 81 | */ |
| 76 | 82 | public function onBeforeDelete( $postId ) |
| 77 | 83 | { |
| 78 | - if( !$this->isReviewPostId( $postId ))return; |
|
| 84 | + if( !$this->isReviewPostId( $postId )) { |
|
| 85 | + return; |
|
| 86 | + } |
|
| 79 | 87 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 80 | 88 | glsr( CountsManager::class )->decrease( $review ); |
| 81 | 89 | } |
@@ -92,9 +100,13 @@ discard block |
||
| 92 | 100 | { |
| 93 | 101 | if( !$this->isReviewPostId( $postId ) |
| 94 | 102 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
| 95 | - )return; |
|
| 103 | + ) { |
|
| 104 | + return; |
|
| 105 | + } |
|
| 96 | 106 | $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
| 97 | - if( $review->$metaKey == $metaValue )return; |
|
| 107 | + if( $review->$metaKey == $metaValue ) { |
|
| 108 | + return; |
|
| 109 | + } |
|
| 98 | 110 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
| 99 | 111 | call_user_func( [$this, $method], $review, $metaValue ); |
| 100 | 112 | } |
@@ -22,11 +22,11 @@ discard block |
||
| 22 | 22 | public function approve() |
| 23 | 23 | { |
| 24 | 24 | if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
| 25 | - check_admin_referer( 'approve-review_'.( $postId = $this->getPostId() )); |
|
| 26 | - wp_update_post([ |
|
| 25 | + check_admin_referer( 'approve-review_'.($postId = $this->getPostId()) ); |
|
| 26 | + wp_update_post( [ |
|
| 27 | 27 | 'ID' => $postId, |
| 28 | 28 | 'post_status' => 'publish', |
| 29 | - ]); |
|
| 29 | + ] ); |
|
| 30 | 30 | wp_safe_redirect( wp_get_referer() ); |
| 31 | 31 | exit; |
| 32 | 32 | } |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | $columns = glsr( Helper::class )->consolidateArray( $columns ); |
| 60 | 60 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 61 | 61 | foreach( $postTypeColumns as $key => &$value ) { |
| 62 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
| 62 | + if( !array_key_exists( $key, $columns ) || !empty($value) )continue; |
|
| 63 | 63 | $value = $columns[$key]; |
| 64 | 64 | } |
| 65 | - if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) { |
|
| 66 | - unset( $postTypeColumns['review_type'] ); |
|
| 65 | + if( count( glsr( Database::class )->getReviewsMeta( 'review_type' ) ) < 2 ) { |
|
| 66 | + unset($postTypeColumns['review_type']); |
|
| 67 | 67 | } |
| 68 | 68 | return array_filter( $postTypeColumns, 'strlen' ); |
| 69 | 69 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function filterPostStates( $postStates, $post ) { |
| 107 | 107 | $postStates = glsr( Helper::class )->consolidateArray( $postStates ); |
| 108 | - if( glsr_get( $post, 'post_type' ) == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) { |
|
| 108 | + if( glsr_get( $post, 'post_type' ) == Application::POST_TYPE && array_key_exists( 'pending', $postStates ) ) { |
|
| 109 | 109 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
| 110 | 110 | } |
| 111 | 111 | return $postStates; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | if( glsr_get( $post, 'post_type' ) != Application::POST_TYPE || $post->post_status == 'trash' ) { |
| 123 | 123 | return $actions; |
| 124 | 124 | } |
| 125 | - unset( $actions['inline hide-if-no-js'] ); //Remove Quick-edit |
|
| 125 | + unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
|
| 126 | 126 | $rowActions = [ |
| 127 | 127 | 'approve' => esc_attr__( 'Approve', 'site-reviews' ), |
| 128 | 128 | 'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ), |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | admin_url( 'post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID ), |
| 137 | 137 | $key.'-review_'.$post->ID |
| 138 | 138 | ), |
| 139 | - ]); |
|
| 139 | + ] ); |
|
| 140 | 140 | } |
| 141 | 141 | return $newActions + glsr( Helper::class )->consolidateArray( $actions ); |
| 142 | 142 | } |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | { |
| 151 | 151 | $columns = glsr( Helper::class )->consolidateArray( $columns ); |
| 152 | 152 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 153 | - unset( $postTypeColumns['cb'] ); |
|
| 153 | + unset($postTypeColumns['cb']); |
|
| 154 | 154 | foreach( $postTypeColumns as $key => $value ) { |
| 155 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
| 155 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key ) )continue; |
|
| 156 | 156 | $columns[$key] = $key; |
| 157 | 157 | } |
| 158 | 158 | return $columns; |
@@ -170,18 +170,18 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function filterStatusText( $translation, $single, $plural, $number, $domain ) |
| 172 | 172 | { |
| 173 | - if( $this->canModifyTranslation( $domain )) { |
|
| 173 | + if( $this->canModifyTranslation( $domain ) ) { |
|
| 174 | 174 | $strings = [ |
| 175 | 175 | 'Published' => __( 'Approved', 'site-reviews' ), |
| 176 | 176 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
| 177 | 177 | ]; |
| 178 | 178 | foreach( $strings as $search => $replace ) { |
| 179 | 179 | if( strpos( $single, $search ) === false )continue; |
| 180 | - $translation = $this->getTranslation([ |
|
| 180 | + $translation = $this->getTranslation( [ |
|
| 181 | 181 | 'number' => $number, |
| 182 | 182 | 'plural' => str_replace( $search, $replace, $plural ), |
| 183 | 183 | 'single' => str_replace( $search, $replace, $single ), |
| 184 | - ]); |
|
| 184 | + ] ); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | return $translation; |
@@ -228,9 +228,9 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | public function saveBulkEditFields( $postId ) |
| 230 | 230 | { |
| 231 | - if( !current_user_can( 'edit_posts' ))return; |
|
| 231 | + if( !current_user_can( 'edit_posts' ) )return; |
|
| 232 | 232 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
| 233 | - if( $assignedTo && get_post( $assignedTo )) { |
|
| 233 | + if( $assignedTo && get_post( $assignedTo ) ) { |
|
| 234 | 234 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -241,10 +241,10 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function setQueryForColumn( WP_Query $query ) |
| 243 | 243 | { |
| 244 | - if( !$this->hasPermission( $query ))return; |
|
| 244 | + if( !$this->hasPermission( $query ) )return; |
|
| 245 | 245 | $this->setMetaQuery( $query, [ |
| 246 | 246 | 'rating', 'review_type', |
| 247 | - ]); |
|
| 247 | + ] ); |
|
| 248 | 248 | $this->setOrderby( $query ); |
| 249 | 249 | } |
| 250 | 250 | |
@@ -255,11 +255,11 @@ discard block |
||
| 255 | 255 | public function unapprove() |
| 256 | 256 | { |
| 257 | 257 | if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
| 258 | - check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
|
| 259 | - wp_update_post([ |
|
| 258 | + check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) ); |
|
| 259 | + wp_update_post( [ |
|
| 260 | 260 | 'ID' => $postId, |
| 261 | 261 | 'post_status' => 'pending', |
| 262 | - ]); |
|
| 262 | + ] ); |
|
| 263 | 263 | wp_safe_redirect( wp_get_referer() ); |
| 264 | 264 | exit; |
| 265 | 265 | } |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | 'single' => '', |
| 290 | 290 | 'text' => '', |
| 291 | 291 | ]; |
| 292 | - $args = (object) wp_parse_args( $args, $defaults ); |
|
| 292 | + $args = (object)wp_parse_args( $args, $defaults ); |
|
| 293 | 293 | $translations = get_translations_for_domain( Application::ID ); |
| 294 | 294 | return $args->text |
| 295 | 295 | ? $translations->translate( $args->text ) |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
| 315 | 315 | { |
| 316 | 316 | foreach( $metaKeys as $key ) { |
| 317 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
| 317 | + if( !($value = filter_input( INPUT_GET, $key )) )continue; |
|
| 318 | 318 | $metaQuery = (array)$query->get( 'meta_query' ); |
| 319 | 319 | $metaQuery[] = [ |
| 320 | 320 | 'key' => $key, |
@@ -331,8 +331,8 @@ discard block |
||
| 331 | 331 | { |
| 332 | 332 | $orderby = $query->get( 'orderby' ); |
| 333 | 333 | $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 334 | - unset( $columns['cb'], $columns['title'], $columns['date'] ); |
|
| 335 | - if( in_array( $orderby, array_keys( $columns ))) { |
|
| 334 | + unset($columns['cb'], $columns['title'], $columns['date']); |
|
| 335 | + if( in_array( $orderby, array_keys( $columns ) ) ) { |
|
| 336 | 336 | if( $orderby == 'reviewer' ) { |
| 337 | 337 | $orderby = 'author'; |
| 338 | 338 | } |
@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function approve() |
| 23 | 23 | { |
| 24 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
| 24 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
| 25 | + return; |
|
| 26 | + } |
|
| 25 | 27 | check_admin_referer( 'approve-review_'.( $postId = $this->getPostId() )); |
| 26 | 28 | wp_update_post([ |
| 27 | 29 | 'ID' => $postId, |
@@ -59,7 +61,9 @@ discard block |
||
| 59 | 61 | $columns = glsr( Helper::class )->consolidateArray( $columns ); |
| 60 | 62 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 61 | 63 | foreach( $postTypeColumns as $key => &$value ) { |
| 62 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
| 64 | + if( !array_key_exists( $key, $columns ) || !empty( $value )) { |
|
| 65 | + continue; |
|
| 66 | + } |
|
| 63 | 67 | $value = $columns[$key]; |
| 64 | 68 | } |
| 65 | 69 | if( count( glsr( Database::class )->getReviewsMeta( 'review_type' )) < 2 ) { |
@@ -103,7 +107,8 @@ discard block |
||
| 103 | 107 | * @return array |
| 104 | 108 | * @filter display_post_states |
| 105 | 109 | */ |
| 106 | - public function filterPostStates( $postStates, $post ) { |
|
| 110 | + public function filterPostStates( $postStates, $post ) |
|
| 111 | + { |
|
| 107 | 112 | $postStates = glsr( Helper::class )->consolidateArray( $postStates ); |
| 108 | 113 | if( glsr_get( $post, 'post_type' ) == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) { |
| 109 | 114 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
@@ -152,7 +157,9 @@ discard block |
||
| 152 | 157 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 153 | 158 | unset( $postTypeColumns['cb'] ); |
| 154 | 159 | foreach( $postTypeColumns as $key => $value ) { |
| 155 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
| 160 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key )) { |
|
| 161 | + continue; |
|
| 162 | + } |
|
| 156 | 163 | $columns[$key] = $key; |
| 157 | 164 | } |
| 158 | 165 | return $columns; |
@@ -176,7 +183,9 @@ discard block |
||
| 176 | 183 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
| 177 | 184 | ]; |
| 178 | 185 | foreach( $strings as $search => $replace ) { |
| 179 | - if( strpos( $single, $search ) === false )continue; |
|
| 186 | + if( strpos( $single, $search ) === false ) { |
|
| 187 | + continue; |
|
| 188 | + } |
|
| 180 | 189 | $translation = $this->getTranslation([ |
| 181 | 190 | 'number' => $number, |
| 182 | 191 | 'plural' => str_replace( $search, $replace, $plural ), |
@@ -228,7 +237,9 @@ discard block |
||
| 228 | 237 | */ |
| 229 | 238 | public function saveBulkEditFields( $postId ) |
| 230 | 239 | { |
| 231 | - if( !current_user_can( 'edit_posts' ))return; |
|
| 240 | + if( !current_user_can( 'edit_posts' )) { |
|
| 241 | + return; |
|
| 242 | + } |
|
| 232 | 243 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
| 233 | 244 | if( $assignedTo && get_post( $assignedTo )) { |
| 234 | 245 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
@@ -241,7 +252,9 @@ discard block |
||
| 241 | 252 | */ |
| 242 | 253 | public function setQueryForColumn( WP_Query $query ) |
| 243 | 254 | { |
| 244 | - if( !$this->hasPermission( $query ))return; |
|
| 255 | + if( !$this->hasPermission( $query )) { |
|
| 256 | + return; |
|
| 257 | + } |
|
| 245 | 258 | $this->setMetaQuery( $query, [ |
| 246 | 259 | 'rating', 'review_type', |
| 247 | 260 | ]); |
@@ -254,7 +267,9 @@ discard block |
||
| 254 | 267 | */ |
| 255 | 268 | public function unapprove() |
| 256 | 269 | { |
| 257 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
| 270 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
| 271 | + return; |
|
| 272 | + } |
|
| 258 | 273 | check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
| 259 | 274 | wp_update_post([ |
| 260 | 275 | 'ID' => $postId, |
@@ -314,7 +329,9 @@ discard block |
||
| 314 | 329 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
| 315 | 330 | { |
| 316 | 331 | foreach( $metaKeys as $key ) { |
| 317 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
| 332 | + if( !( $value = filter_input( INPUT_GET, $key ))) { |
|
| 333 | + continue; |
|
| 334 | + } |
|
| 318 | 335 | $metaQuery = (array)$query->get( 'meta_query' ); |
| 319 | 336 | $metaQuery[] = [ |
| 320 | 337 | 'key' => $key, |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function renderAssignedToMetabox( $post ) |
| 135 | 135 | { |
| 136 | - if( !$this->isReviewPostType( $post ))return; |
|
| 136 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 137 | 137 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
| 138 | 138 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
| 139 | 139 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
| 140 | 140 | 'id' => $assignedTo, |
| 141 | 141 | 'template' => $this->buildAssignedToTemplate( $assignedTo, $post ), |
| 142 | - ]); |
|
| 142 | + ] ); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -149,12 +149,12 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | public function renderDetailsMetaBox( $post ) |
| 151 | 151 | { |
| 152 | - if( !$this->isReviewPostType( $post ))return; |
|
| 152 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 153 | 153 | $review = glsr( ReviewManager::class )->single( $post ); |
| 154 | 154 | glsr()->render( 'partials/editor/metabox-details', [ |
| 155 | 155 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
| 156 | 156 | 'metabox' => $this->normalizeDetailsMetaBox( $review ), |
| 157 | - ]); |
|
| 157 | + ] ); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -163,14 +163,14 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function renderPinnedInPublishMetaBox() |
| 165 | 165 | { |
| 166 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 166 | + if( !$this->isReviewPostType( get_post() ) )return; |
|
| 167 | 167 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
| 168 | 168 | 'context' => [ |
| 169 | 169 | 'no' => __( 'No', 'site-reviews' ), |
| 170 | 170 | 'yes' => __( 'Yes', 'site-reviews' ), |
| 171 | 171 | ], |
| 172 | - 'pinned' => wp_validate_boolean( get_post_meta( intval( get_the_ID() ), 'pinned', true )), |
|
| 173 | - ]); |
|
| 172 | + 'pinned' => wp_validate_boolean( get_post_meta( intval( get_the_ID() ), 'pinned', true ) ), |
|
| 173 | + ] ); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -180,11 +180,11 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function renderResponseMetaBox( $post ) |
| 182 | 182 | { |
| 183 | - if( !$this->isReviewPostType( $post ))return; |
|
| 183 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 184 | 184 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 185 | 185 | glsr()->render( 'partials/editor/metabox-response', [ |
| 186 | 186 | 'response' => get_post_meta( $post->ID, 'response', true ), |
| 187 | - ]); |
|
| 187 | + ] ); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | public function renderReviewEditor( $post ) |
| 196 | 196 | { |
| 197 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 197 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
| 198 | 198 | glsr()->render( 'partials/editor/review', [ |
| 199 | 199 | 'post' => $post, |
| 200 | 200 | 'response' => get_post_meta( $post->ID, 'response', true ), |
| 201 | - ]); |
|
| 201 | + ] ); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | $screen = glsr_current_screen(); |
| 211 | 211 | if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
| 212 | 212 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
| 213 | - add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
| 213 | + add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -220,16 +220,16 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | public function renderReviewNotice( $post ) |
| 222 | 222 | { |
| 223 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 223 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
| 224 | 224 | glsr( Notice::class )->addWarning( sprintf( |
| 225 | 225 | __( '%s reviews are read-only.', 'site-reviews' ), |
| 226 | 226 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
| 227 | - )); |
|
| 227 | + ) ); |
|
| 228 | 228 | glsr( Template::class )->render( 'partials/editor/notice', [ |
| 229 | 229 | 'context' => [ |
| 230 | 230 | 'notices' => glsr( Notice::class )->get(), |
| 231 | 231 | ], |
| 232 | - ]); |
|
| 232 | + ] ); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -240,12 +240,12 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | public function renderTaxonomyMetabox( $post ) |
| 242 | 242 | { |
| 243 | - if( !$this->isReviewPostType( $post ))return; |
|
| 243 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 244 | 244 | glsr()->render( 'partials/editor/metabox-categories', [ |
| 245 | 245 | 'post' => $post, |
| 246 | 246 | 'tax_name' => Application::TAXONOMY, |
| 247 | 247 | 'taxonomy' => get_taxonomy( Application::TAXONOMY ), |
| 248 | - ]); |
|
| 248 | + ] ); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | public function revertReview() |
| 257 | 257 | { |
| 258 | 258 | if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
| 259 | - check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
|
| 259 | + check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) ); |
|
| 260 | 260 | glsr( ReviewManager::class )->revert( $postId ); |
| 261 | 261 | $this->redirect( $postId, 52 ); |
| 262 | 262 | } |
@@ -279,13 +279,13 @@ discard block |
||
| 279 | 279 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
| 280 | 280 | { |
| 281 | 281 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
| 282 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
| 282 | + if( !($assignedPost instanceof WP_Post) )return; |
|
| 283 | 283 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
| 284 | 284 | 'context' => [ |
| 285 | 285 | 'data.url' => (string)get_permalink( $assignedPost ), |
| 286 | 286 | 'data.title' => get_the_title( $assignedPost ), |
| 287 | 287 | ], |
| 288 | - ]); |
|
| 288 | + ] ); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -310,13 +310,13 @@ discard block |
||
| 310 | 310 | 'class' => 'button button-large', |
| 311 | 311 | 'href' => $revertUrl, |
| 312 | 312 | 'id' => 'revert', |
| 313 | - ]); |
|
| 313 | + ] ); |
|
| 314 | 314 | } |
| 315 | 315 | return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [ |
| 316 | 316 | 'class' => 'button button-large', |
| 317 | 317 | 'disabled' => true, |
| 318 | 318 | 'id' => 'revert', |
| 319 | - ]); |
|
| 319 | + ] ); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -329,11 +329,11 @@ discard block |
||
| 329 | 329 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
| 330 | 330 | ? glsr()->reviewTypes[$review->review_type] |
| 331 | 331 | : __( 'Unknown', 'site-reviews' ); |
| 332 | - if( !empty( $review->url )) { |
|
| 332 | + if( !empty($review->url) ) { |
|
| 333 | 333 | $reviewType = glsr( Builder::class )->a( $reviewType, [ |
| 334 | 334 | 'href' => $review->url, |
| 335 | 335 | 'target' => '_blank', |
| 336 | - ]); |
|
| 336 | + ] ); |
|
| 337 | 337 | } |
| 338 | 338 | return $reviewType; |
| 339 | 339 | } |
@@ -362,16 +362,16 @@ discard block |
||
| 362 | 362 | */ |
| 363 | 363 | protected function normalizeDetailsMetaBox( Review $review ) |
| 364 | 364 | { |
| 365 | - $user = empty( $review->user_id ) |
|
| 365 | + $user = empty($review->user_id) |
|
| 366 | 366 | ? __( 'Unregistered user', 'site-reviews' ) |
| 367 | 367 | : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [ |
| 368 | 368 | 'href' => get_author_posts_url( $review->user_id ), |
| 369 | - ]); |
|
| 370 | - $email = empty( $review->email ) |
|
| 369 | + ] ); |
|
| 370 | + $email = empty($review->email) |
|
| 371 | 371 | ? '—' |
| 372 | 372 | : glsr( Builder::class )->a( $review->email, [ |
| 373 | 373 | 'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ), |
| 374 | - ]); |
|
| 374 | + ] ); |
|
| 375 | 375 | $metabox = [ |
| 376 | 376 | __( 'Rating', 'site-reviews' ) => glsr_star_rating( $review->rating ), |
| 377 | 377 | __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ), |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | __( 'IP Address', 'site-reviews' ) => $review->ip_address, |
| 383 | 383 | __( 'Avatar', 'site-reviews' ) => sprintf( '<img src="%s" width="96">', $review->avatar ), |
| 384 | 384 | ]; |
| 385 | - return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review )); |
|
| 385 | + return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review ) ); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | $redirectUri = $hasReferer |
| 400 | 400 | ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer ) |
| 401 | 401 | : get_edit_post_link( $postId ); |
| 402 | - wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri )); |
|
| 402 | + wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) ); |
|
| 403 | 403 | exit; |
| 404 | 404 | } |
| 405 | 405 | } |
@@ -96,7 +96,9 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
| 98 | 98 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
| 99 | - if( get_post_meta( $post->ID, 'review_type', true ) != 'local' )return; |
|
| 99 | + if( get_post_meta( $post->ID, 'review_type', true ) != 'local' ) { |
|
| 100 | + return; |
|
| 101 | + } |
|
| 100 | 102 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
| 101 | 103 | } |
| 102 | 104 | |
@@ -133,7 +135,9 @@ discard block |
||
| 133 | 135 | */ |
| 134 | 136 | public function renderAssignedToMetabox( $post ) |
| 135 | 137 | { |
| 136 | - if( !$this->isReviewPostType( $post ))return; |
|
| 138 | + if( !$this->isReviewPostType( $post )) { |
|
| 139 | + return; |
|
| 140 | + } |
|
| 137 | 141 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
| 138 | 142 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
| 139 | 143 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
@@ -149,7 +153,9 @@ discard block |
||
| 149 | 153 | */ |
| 150 | 154 | public function renderDetailsMetaBox( $post ) |
| 151 | 155 | { |
| 152 | - if( !$this->isReviewPostType( $post ))return; |
|
| 156 | + if( !$this->isReviewPostType( $post )) { |
|
| 157 | + return; |
|
| 158 | + } |
|
| 153 | 159 | $review = glsr( ReviewManager::class )->single( $post ); |
| 154 | 160 | glsr()->render( 'partials/editor/metabox-details', [ |
| 155 | 161 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
@@ -163,7 +169,9 @@ discard block |
||
| 163 | 169 | */ |
| 164 | 170 | public function renderPinnedInPublishMetaBox() |
| 165 | 171 | { |
| 166 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 172 | + if( !$this->isReviewPostType( get_post() )) { |
|
| 173 | + return; |
|
| 174 | + } |
|
| 167 | 175 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
| 168 | 176 | 'context' => [ |
| 169 | 177 | 'no' => __( 'No', 'site-reviews' ), |
@@ -180,7 +188,9 @@ discard block |
||
| 180 | 188 | */ |
| 181 | 189 | public function renderResponseMetaBox( $post ) |
| 182 | 190 | { |
| 183 | - if( !$this->isReviewPostType( $post ))return; |
|
| 191 | + if( !$this->isReviewPostType( $post )) { |
|
| 192 | + return; |
|
| 193 | + } |
|
| 184 | 194 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 185 | 195 | glsr()->render( 'partials/editor/metabox-response', [ |
| 186 | 196 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -194,7 +204,9 @@ discard block |
||
| 194 | 204 | */ |
| 195 | 205 | public function renderReviewEditor( $post ) |
| 196 | 206 | { |
| 197 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 207 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 208 | + return; |
|
| 209 | + } |
|
| 198 | 210 | glsr()->render( 'partials/editor/review', [ |
| 199 | 211 | 'post' => $post, |
| 200 | 212 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -208,7 +220,9 @@ discard block |
||
| 208 | 220 | public function renderReviewFields() |
| 209 | 221 | { |
| 210 | 222 | $screen = glsr_current_screen(); |
| 211 | - if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
|
| 223 | + if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE ) { |
|
| 224 | + return; |
|
| 225 | + } |
|
| 212 | 226 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
| 213 | 227 | add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
| 214 | 228 | } |
@@ -220,7 +234,9 @@ discard block |
||
| 220 | 234 | */ |
| 221 | 235 | public function renderReviewNotice( $post ) |
| 222 | 236 | { |
| 223 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 237 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 238 | + return; |
|
| 239 | + } |
|
| 224 | 240 | glsr( Notice::class )->addWarning( sprintf( |
| 225 | 241 | __( '%s reviews are read-only.', 'site-reviews' ), |
| 226 | 242 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
@@ -240,7 +256,9 @@ discard block |
||
| 240 | 256 | */ |
| 241 | 257 | public function renderTaxonomyMetabox( $post ) |
| 242 | 258 | { |
| 243 | - if( !$this->isReviewPostType( $post ))return; |
|
| 259 | + if( !$this->isReviewPostType( $post )) { |
|
| 260 | + return; |
|
| 261 | + } |
|
| 244 | 262 | glsr()->render( 'partials/editor/metabox-categories', [ |
| 245 | 263 | 'post' => $post, |
| 246 | 264 | 'tax_name' => Application::TAXONOMY, |
@@ -255,7 +273,9 @@ discard block |
||
| 255 | 273 | */ |
| 256 | 274 | public function revertReview() |
| 257 | 275 | { |
| 258 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
| 276 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
| 277 | + return; |
|
| 278 | + } |
|
| 259 | 279 | check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
| 260 | 280 | glsr( ReviewManager::class )->revert( $postId ); |
| 261 | 281 | $this->redirect( $postId, 52 ); |
@@ -279,7 +299,9 @@ discard block |
||
| 279 | 299 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
| 280 | 300 | { |
| 281 | 301 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
| 282 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
| 302 | + if( !( $assignedPost instanceof WP_Post )) { |
|
| 303 | + return; |
|
| 304 | + } |
|
| 283 | 305 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
| 284 | 306 | 'context' => [ |
| 285 | 307 | 'data.url' => (string)get_permalink( $assignedPost ), |
@@ -325,7 +347,9 @@ discard block |
||
| 325 | 347 | */ |
| 326 | 348 | protected function getReviewType( $review ) |
| 327 | 349 | { |
| 328 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
| 350 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
| 351 | + return; |
|
| 352 | + } |
|
| 329 | 353 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
| 330 | 354 | ? glsr()->reviewTypes[$review->review_type] |
| 331 | 355 | : __( 'Unknown', 'site-reviews' ); |
@@ -38,10 +38,10 @@ discard block |
||
| 38 | 38 | if( $review->review_type != 'local' )continue; |
| 39 | 39 | $reviews[] = $this->buildReview( $review ); |
| 40 | 40 | } |
| 41 | - if( !empty( $reviews )) { |
|
| 41 | + if( !empty($reviews) ) { |
|
| 42 | 42 | array_walk( $reviews, function( &$review ) { |
| 43 | - unset( $review['@context'] ); |
|
| 44 | - unset( $review['itemReviewed'] ); |
|
| 43 | + unset($review['@context']); |
|
| 44 | + unset($review['itemReviewed']); |
|
| 45 | 45 | }); |
| 46 | 46 | $schema['review'] = $reviews; |
| 47 | 47 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function buildSummary( $args = null ) |
| 56 | 56 | { |
| 57 | - if( is_array( $args )) { |
|
| 57 | + if( is_array( $args ) ) { |
|
| 58 | 58 | $this->args = $args; |
| 59 | 59 | } |
| 60 | 60 | $buildSummary = glsr( Helper::class )->buildMethodName( $this->getSchemaOptionValue( 'type' ), 'buildSummaryFor' ); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $schema = method_exists( $this, $buildSummary ) |
| 63 | 63 | ? $this->$buildSummary() |
| 64 | 64 | : $this->buildSummaryForCustom(); |
| 65 | - if( !empty( $count )) { |
|
| 65 | + if( !empty($count) ) { |
|
| 66 | 66 | $schema->aggregateRating( |
| 67 | 67 | $this->getSchemaType( 'AggregateRating' ) |
| 68 | 68 | ->ratingValue( $this->getRatingValue() ) |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function render() |
| 82 | 82 | { |
| 83 | - if( empty( glsr()->schemas ))return; |
|
| 83 | + if( empty(glsr()->schemas) )return; |
|
| 84 | 84 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
| 85 | 85 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
| 86 | 86 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
| 87 | - )); |
|
| 87 | + ) ); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | $schemas = glsr()->schemas; |
| 96 | 96 | $schemas[] = $schema; |
| 97 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
| 97 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -104,16 +104,16 @@ discard block |
||
| 104 | 104 | protected function buildReview( $review ) |
| 105 | 105 | { |
| 106 | 106 | $schema = $this->getSchemaType( 'Review' ) |
| 107 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
| 107 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( $schema ) use($review) { |
|
| 108 | 108 | $schema->name( $review->title ); |
| 109 | 109 | }) |
| 110 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use( $review ) { |
|
| 110 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( $schema ) use($review) { |
|
| 111 | 111 | $schema->reviewBody( $review->content ); |
| 112 | 112 | }) |
| 113 | - ->datePublished(( new DateTime( $review->date ))) |
|
| 114 | - ->author( $this->getSchemaType( 'Person' )->name( $review->author )) |
|
| 115 | - ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ))); |
|
| 116 | - if( !empty( $review->rating )) { |
|
| 113 | + ->datePublished( (new DateTime( $review->date )) ) |
|
| 114 | + ->author( $this->getSchemaType( 'Person' )->name( $review->author ) ) |
|
| 115 | + ->itemReviewed( $this->getSchemaType()->name( $this->getSchemaOptionValue( 'name' ) ) ); |
|
| 116 | + if( !empty($review->rating) ) { |
|
| 117 | 117 | $schema->reviewRating( |
| 118 | 118 | $this->getSchemaType( 'Rating' ) |
| 119 | 119 | ->ratingValue( $review->rating ) |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | foreach( $values as $value ) { |
| 134 | 134 | $option = $this->getSchemaOptionValue( $value ); |
| 135 | - if( empty( $option ))continue; |
|
| 135 | + if( empty($option) )continue; |
|
| 136 | 136 | $schema->$value( $option ); |
| 137 | 137 | } |
| 138 | 138 | return $schema; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | { |
| 146 | 146 | return $this->buildSchemaValues( $this->getSchemaType(), [ |
| 147 | 147 | 'description', 'image', 'name', 'url', |
| 148 | - ]); |
|
| 148 | + ] ); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | { |
| 156 | 156 | return $this->buildSchemaValues( $this->buildSummaryForCustom(), [ |
| 157 | 157 | 'address', 'priceRange', 'telephone', |
| 158 | - ]); |
|
| 158 | + ] ); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | $offerType = $this->getSchemaOption( 'offerType', 'AggregateOffer' ); |
| 167 | 167 | $offers = $this->buildSchemaValues( $this->getSchemaType( $offerType ), [ |
| 168 | 168 | 'highPrice', 'lowPrice', 'price', 'priceCurrency', |
| 169 | - ]); |
|
| 169 | + ] ); |
|
| 170 | 170 | return $this->buildSummaryForCustom() |
| 171 | - ->doIf( !empty( $offers->getProperties() ), function( $schema ) use( $offers ) { |
|
| 171 | + ->doIf( !empty($offers->getProperties()), function( $schema ) use($offers) { |
|
| 172 | 172 | $schema->offers( $offers ); |
| 173 | 173 | }) |
| 174 | 174 | ->setProperty( '@id', $this->getSchemaOptionValue( 'url' ).'#product' ); |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | protected function getRatingCounts() |
| 181 | 181 | { |
| 182 | - if( !isset( $this->ratingCounts )) { |
|
| 182 | + if( !isset($this->ratingCounts) ) { |
|
| 183 | 183 | $this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $this->args ); |
| 184 | 184 | } |
| 185 | 185 | return $this->ratingCounts; |
@@ -201,14 +201,14 @@ discard block |
||
| 201 | 201 | protected function getSchemaOption( $option, $fallback ) |
| 202 | 202 | { |
| 203 | 203 | $option = strtolower( $option ); |
| 204 | - if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) { |
|
| 204 | + if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) { |
|
| 205 | 205 | return $schemaOption; |
| 206 | 206 | } |
| 207 | 207 | $setting = glsr( OptionManager::class )->get( 'settings.schema.'.$option ); |
| 208 | - if( is_array( $setting )) { |
|
| 208 | + if( is_array( $setting ) ) { |
|
| 209 | 209 | return $this->getSchemaOptionDefault( $setting, $fallback ); |
| 210 | 210 | } |
| 211 | - return !empty( $setting ) |
|
| 211 | + return !empty($setting) |
|
| 212 | 212 | ? $setting |
| 213 | 213 | : $fallback; |
| 214 | 214 | } |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | $setting = wp_parse_args( $setting, [ |
| 223 | 223 | 'custom' => '', |
| 224 | 224 | 'default' => $fallback, |
| 225 | - ]); |
|
| 225 | + ] ); |
|
| 226 | 226 | return $setting['default'] != 'custom' |
| 227 | 227 | ? $setting['default'] |
| 228 | 228 | : $setting['custom']; |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | if( !is_single() && !is_page() )return; |
| 243 | 243 | $method = glsr( Helper::class )->buildMethodName( $option, 'getThing' ); |
| 244 | - if( method_exists( $this, $method )) { |
|
| 244 | + if( method_exists( $this, $method ) ) { |
|
| 245 | 245 | return $this->$method(); |
| 246 | 246 | } |
| 247 | 247 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | protected function getSchemaType( $type = null ) |
| 254 | 254 | { |
| 255 | - if( !is_string( $type )) { |
|
| 255 | + if( !is_string( $type ) ) { |
|
| 256 | 256 | $type = $this->getSchemaOption( 'type', 'LocalBusiness' ); |
| 257 | 257 | } |
| 258 | 258 | $className = glsr( Helper::class )->buildClassName( $type, 'Modules\Schema' ); |
@@ -267,11 +267,11 @@ discard block |
||
| 267 | 267 | protected function getThingDescription() |
| 268 | 268 | { |
| 269 | 269 | $post = get_post(); |
| 270 | - if( !( $post instanceof WP_Post )) { |
|
| 270 | + if( !($post instanceof WP_Post) ) { |
|
| 271 | 271 | return ''; |
| 272 | 272 | } |
| 273 | - $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt )); |
|
| 274 | - return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 )); |
|
| 273 | + $text = strip_shortcodes( wp_strip_all_tags( $post->post_excerpt ) ); |
|
| 274 | + return wp_trim_words( $text, apply_filters( 'excerpt_length', 55 ) ); |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function build() |
| 23 | 23 | { |
| 24 | - glsr_log()->error( 'Build method is not implemented for '.get_class( $this )); |
|
| 24 | + glsr_log()->error( 'Build method is not implemented for '.get_class( $this ) ); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | wp_parse_args( $args, static::defaults() ), |
| 42 | 42 | static::required() |
| 43 | 43 | ); |
| 44 | - $merged['class'] = implode( ' ', static::mergedAttribute( 'class', ' ', $args )); |
|
| 45 | - $merged['style'] = implode( ';', static::mergedAttribute( 'style', ';', $args )); |
|
| 44 | + $merged['class'] = implode( ' ', static::mergedAttribute( 'class', ' ', $args ) ); |
|
| 45 | + $merged['style'] = implode( ';', static::mergedAttribute( 'style', ';', $args ) ); |
|
| 46 | 46 | return $merged; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | public static function mergedAttribute( $key, $delimiter, array $args ) |
| 55 | 55 | { |
| 56 | 56 | return array_filter( array_merge( |
| 57 | - explode( $delimiter, glsr_get( $args, $key )), |
|
| 58 | - explode( $delimiter, glsr_get( static::defaults(), $key )), |
|
| 59 | - explode( $delimiter, glsr_get( static::required(), $key )) |
|
| 60 | - )); |
|
| 57 | + explode( $delimiter, glsr_get( $args, $key ) ), |
|
| 58 | + explode( $delimiter, glsr_get( static::defaults(), $key ) ), |
|
| 59 | + explode( $delimiter, glsr_get( static::required(), $key ) ) |
|
| 60 | + ) ); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | { |
| 67 | 67 | $instance = new static; |
| 68 | 68 | $instance->setTagFromMethod( $method ); |
| 69 | - call_user_func_array( [$instance, 'normalize'], $args += ['',''] ); |
|
| 69 | + call_user_func_array( [$instance, 'normalize'], $args += ['', ''] ); |
|
| 70 | 70 | $tags = array_merge( static::TAGS_FORM, static::TAGS_SINGLE, static::TAGS_STRUCTURE, static::TAGS_TEXT ); |
| 71 | 71 | do_action_ref_array( 'site-reviews/builder', [&$instance] ); |
| 72 | 72 | $generatedTag = in_array( $instance->tag, $tags ) |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | 'render' => 'is_bool', |
| 92 | 92 | 'tag' => 'is_string', |
| 93 | 93 | ]; |
| 94 | - if( !isset( $properties[$property] ) |
|
| 95 | - || empty( array_filter( [$value], $properties[$property] )) |
|
| 94 | + if( !isset($properties[$property]) |
|
| 95 | + || empty(array_filter( [$value], $properties[$property] )) |
|
| 96 | 96 | )return; |
| 97 | 97 | $this->$property = $value; |
| 98 | 98 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function getClosingTag() |
| 104 | 104 | { |
| 105 | - if( empty( $this->tag ))return; |
|
| 105 | + if( empty($this->tag) )return; |
|
| 106 | 106 | return '</'.$this->tag.'>'; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function getOpeningTag() |
| 113 | 113 | { |
| 114 | - if( empty( $this->tag ))return; |
|
| 115 | - $attributes = glsr( Attributes::class )->{$this->tag}( $this->args )->toString(); |
|
| 114 | + if( empty($this->tag) )return; |
|
| 115 | + $attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString(); |
|
| 116 | 116 | return '<'.trim( $this->tag.' '.$attributes ).'>'; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function getTag() |
| 123 | 123 | { |
| 124 | - if( in_array( $this->tag, static::TAGS_SINGLE )) { |
|
| 124 | + if( in_array( $this->tag, static::TAGS_SINGLE ) ) { |
|
| 125 | 125 | return $this->getOpeningTag(); |
| 126 | 126 | } |
| 127 | - if( !in_array( $this->tag, static::TAGS_FORM )) { |
|
| 127 | + if( !in_array( $this->tag, static::TAGS_FORM ) ) { |
|
| 128 | 128 | return $this->buildDefaultTag(); |
| 129 | 129 | } |
| 130 | 130 | return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription(); |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | public function raw( array $field ) |
| 137 | 137 | { |
| 138 | - unset( $field['label'] ); |
|
| 139 | - return $this->{$field['type']}( $field ); |
|
| 138 | + unset($field['label']); |
|
| 139 | + return $this->{$field['type']}($field); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | protected function buildCustomField() |
| 146 | 146 | { |
| 147 | 147 | $className = $this->getCustomFieldClassName(); |
| 148 | - if( class_exists( $className )) { |
|
| 148 | + if( class_exists( $className ) ) { |
|
| 149 | 149 | return (new $className( $this ))->build(); |
| 150 | 150 | } |
| 151 | 151 | glsr_log()->error( 'Field missing: '.$className ); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | protected function buildDefaultTag( $text = '' ) |
| 158 | 158 | { |
| 159 | - if( empty( $text )) { |
|
| 159 | + if( empty($text) ) { |
|
| 160 | 160 | $text = $this->args['text']; |
| 161 | 161 | } |
| 162 | 162 | return $this->getOpeningTag().$text.$this->getClosingTag(); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | protected function buildFieldDescription() |
| 169 | 169 | { |
| 170 | - if( empty( $this->args['description'] ))return; |
|
| 170 | + if( empty($this->args['description']) )return; |
|
| 171 | 171 | if( $this->args['is_widget'] ) { |
| 172 | 172 | return $this->small( $this->args['description'] ); |
| 173 | 173 | } |
@@ -179,13 +179,13 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | protected function buildFormInput() |
| 181 | 181 | { |
| 182 | - if( !in_array( $this->args['type'], ['checkbox', 'radio'] )) { |
|
| 183 | - if( isset( $this->args['multiple'] )) { |
|
| 184 | - $this->args['name'].= '[]'; |
|
| 182 | + if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) { |
|
| 183 | + if( isset($this->args['multiple']) ) { |
|
| 184 | + $this->args['name'] .= '[]'; |
|
| 185 | 185 | } |
| 186 | 186 | return $this->buildFormLabel().$this->getOpeningTag(); |
| 187 | 187 | } |
| 188 | - return empty( $this->args['options'] ) |
|
| 188 | + return empty($this->args['options']) |
|
| 189 | 189 | ? $this->buildFormInputChoice() |
| 190 | 190 | : $this->buildFormInputMultiChoice(); |
| 191 | 191 | } |
@@ -195,19 +195,19 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | protected function buildFormInputChoice() |
| 197 | 197 | { |
| 198 | - if( !empty( $this->args['text'] )) { |
|
| 198 | + if( !empty($this->args['text']) ) { |
|
| 199 | 199 | $this->args['label'] = $this->args['text']; |
| 200 | 200 | } |
| 201 | 201 | if( !$this->args['is_public'] ) { |
| 202 | - return $this->buildFormLabel([ |
|
| 202 | + return $this->buildFormLabel( [ |
|
| 203 | 203 | 'class' => 'glsr-'.$this->args['type'].'-label', |
| 204 | 204 | 'text' => $this->getOpeningTag().' '.$this->args['label'].'<span></span>', |
| 205 | - ]); |
|
| 205 | + ] ); |
|
| 206 | 206 | } |
| 207 | - return $this->getOpeningTag().$this->buildFormLabel([ |
|
| 207 | + return $this->getOpeningTag().$this->buildFormLabel( [ |
|
| 208 | 208 | 'class' => 'glsr-'.$this->args['type'].'-label', |
| 209 | 209 | 'text' => $this->args['label'].'<span></span>', |
| 210 | - ]); |
|
| 210 | + ] ); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -216,22 +216,22 @@ discard block |
||
| 216 | 216 | protected function buildFormInputMultiChoice() |
| 217 | 217 | { |
| 218 | 218 | if( $this->args['type'] == 'checkbox' ) { |
| 219 | - $this->args['name'].= '[]'; |
|
| 219 | + $this->args['name'] .= '[]'; |
|
| 220 | 220 | } |
| 221 | 221 | $index = 0; |
| 222 | - $options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) use( &$index ) { |
|
| 222 | + $options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) use(&$index) { |
|
| 223 | 223 | return $carry.$this->li( $this->{$this->args['type']}([ |
| 224 | 224 | 'checked' => in_array( $key, (array)$this->args['value'] ), |
| 225 | 225 | 'id' => $this->args['id'].'-'.$index++, |
| 226 | 226 | 'name' => $this->args['name'], |
| 227 | 227 | 'text' => $this->args['options'][$key], |
| 228 | 228 | 'value' => $key, |
| 229 | - ])); |
|
| 229 | + ]) ); |
|
| 230 | 230 | }); |
| 231 | 231 | return $this->ul( $options, [ |
| 232 | 232 | 'class' => $this->args['class'], |
| 233 | 233 | 'id' => $this->args['id'], |
| 234 | - ]); |
|
| 234 | + ] ); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -239,13 +239,13 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | protected function buildFormLabel( array $customArgs = [] ) |
| 241 | 241 | { |
| 242 | - if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return; |
|
| 242 | + if( empty($this->args['label']) || $this->args['type'] == 'hidden' )return; |
|
| 243 | 243 | return $this->label( wp_parse_args( $customArgs, [ |
| 244 | 244 | 'for' => $this->args['id'], |
| 245 | 245 | 'is_public' => $this->args['is_public'], |
| 246 | 246 | 'text' => $this->args['label'], |
| 247 | 247 | 'type' => $this->args['type'], |
| 248 | - ])); |
|
| 248 | + ] ) ); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -262,11 +262,11 @@ discard block |
||
| 262 | 262 | protected function buildFormSelectOptions() |
| 263 | 263 | { |
| 264 | 264 | return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) { |
| 265 | - return $carry.$this->option([ |
|
| 265 | + return $carry.$this->option( [ |
|
| 266 | 266 | 'selected' => $this->args['value'] == $key, |
| 267 | 267 | 'text' => $this->args['options'][$key], |
| 268 | 268 | 'value' => $key, |
| 269 | - ]); |
|
| 269 | + ] ); |
|
| 270 | 270 | }); |
| 271 | 271 | } |
| 272 | 272 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | protected function mergeArgsWithRequiredDefaults() |
| 303 | 303 | { |
| 304 | 304 | $className = $this->getCustomFieldClassName(); |
| 305 | - if( class_exists( $className )) { |
|
| 305 | + if( class_exists( $className ) ) { |
|
| 306 | 306 | $this->args = $className::merge( $this->args ); |
| 307 | 307 | } |
| 308 | 308 | $this->args = glsr( BuilderDefaults::class )->merge( $this->args ); |
@@ -314,16 +314,16 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | protected function normalize( ...$params ) |
| 316 | 316 | { |
| 317 | - if( is_string( $params[0] ) || is_numeric( $params[0] )) { |
|
| 317 | + if( is_string( $params[0] ) || is_numeric( $params[0] ) ) { |
|
| 318 | 318 | $this->setNameOrTextAttributeForTag( $params[0] ); |
| 319 | 319 | } |
| 320 | - if( is_array( $params[0] )) { |
|
| 320 | + if( is_array( $params[0] ) ) { |
|
| 321 | 321 | $this->args += $params[0]; |
| 322 | 322 | } |
| 323 | - else if( is_array( $params[1] )) { |
|
| 323 | + else if( is_array( $params[1] ) ) { |
|
| 324 | 324 | $this->args += $params[1]; |
| 325 | 325 | } |
| 326 | - if( !isset( $this->args['is_public'] )) { |
|
| 326 | + if( !isset($this->args['is_public']) ) { |
|
| 327 | 327 | $this->args['is_public'] = false; |
| 328 | 328 | } |
| 329 | 329 | } |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | protected function setTagFromMethod( $method ) |
| 348 | 348 | { |
| 349 | 349 | $this->tag = strtolower( $method ); |
| 350 | - if( in_array( $this->tag, static::INPUT_TYPES )) { |
|
| 350 | + if( in_array( $this->tag, static::INPUT_TYPES ) ) { |
|
| 351 | 351 | $this->args['type'] = $this->tag; |
| 352 | 352 | $this->tag = 'input'; |
| 353 | 353 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | 'is_valid' => true, |
| 28 | 28 | 'is_widget' => false, |
| 29 | 29 | 'path' => '', |
| 30 | - ]); |
|
| 30 | + ] ); |
|
| 31 | 31 | $this->normalize(); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | if( !$this->field['is_valid'] )return; |
| 48 | 48 | if( $this->field['is_raw'] ) { |
| 49 | - return glsr( Builder::class )->{$this->field['type']}( $this->field ); |
|
| 49 | + return glsr( Builder::class )->{$this->field['type']}($this->field); |
|
| 50 | 50 | } |
| 51 | 51 | if( !$this->field['is_setting'] ) { |
| 52 | 52 | return $this->buildField(); |
@@ -75,15 +75,15 @@ discard block |
||
| 75 | 75 | 'class' => $this->getFieldClass(), |
| 76 | 76 | 'errors' => $this->getFieldErrors(), |
| 77 | 77 | 'field' => glsr( Builder::class )->raw( $this->field ), |
| 78 | - 'label' => glsr( Builder::class )->label([ |
|
| 78 | + 'label' => glsr( Builder::class )->label( [ |
|
| 79 | 79 | 'class' => 'glsr-'.$this->field['type'].'-label', |
| 80 | 80 | 'for' => $this->field['id'], |
| 81 | 81 | 'is_public' => $this->field['is_public'], |
| 82 | 82 | 'text' => $this->field['label'].'<span></span>', |
| 83 | 83 | 'type' => $this->field['type'], |
| 84 | - ]), |
|
| 84 | + ] ), |
|
| 85 | 85 | ], |
| 86 | - ]); |
|
| 86 | + ] ); |
|
| 87 | 87 | return apply_filters( 'site-reviews/rendered/field', $field, $this->field['type'], $this->field ); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | return glsr( Template::class )->build( 'partials/form/table-row', [ |
| 96 | 96 | 'context' => [ |
| 97 | 97 | 'class' => $this->getFieldClass(), |
| 98 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
| 98 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
| 99 | 99 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
| 100 | 100 | ], |
| 101 | - ]); |
|
| 101 | + ] ); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -107,16 +107,16 @@ discard block |
||
| 107 | 107 | protected function buildSettingMultiField() |
| 108 | 108 | { |
| 109 | 109 | $dependsOn = $this->getFieldDependsOn(); |
| 110 | - unset( $this->field['data-depends'] ); |
|
| 110 | + unset($this->field['data-depends']); |
|
| 111 | 111 | return glsr( Template::class )->build( 'partials/form/table-row-multiple', [ |
| 112 | 112 | 'context' => [ |
| 113 | 113 | 'class' => $this->getFieldClass(), |
| 114 | 114 | 'depends_on' => $dependsOn, |
| 115 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
| 115 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
| 116 | 116 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
| 117 | 117 | 'legend' => $this->field['legend'], |
| 118 | 118 | ], |
| 119 | - ]); |
|
| 119 | + ] ); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | protected function getFieldClass() |
| 126 | 126 | { |
| 127 | 127 | $classes = []; |
| 128 | - if( !empty( $this->field['errors'] )) { |
|
| 128 | + if( !empty($this->field['errors']) ) { |
|
| 129 | 129 | $classes[] = 'glsr-has-error'; |
| 130 | 130 | } |
| 131 | 131 | if( $this->field['is_hidden'] ) { |
| 132 | 132 | $classes[] = 'hidden'; |
| 133 | 133 | } |
| 134 | - if( !empty( $this->field['required'] )) { |
|
| 134 | + if( !empty($this->field['required']) ) { |
|
| 135 | 135 | $classes[] = 'glsr-required'; |
| 136 | 136 | } |
| 137 | 137 | $classes = apply_filters( 'site-reviews/rendered/field/classes', $classes, $this->field ); |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | protected function getFieldDependsOn() |
| 145 | 145 | { |
| 146 | - return !empty( $this->field['data-depends'] ) |
|
| 146 | + return !empty($this->field['data-depends']) |
|
| 147 | 147 | ? $this->field['data-depends'] |
| 148 | 148 | : ''; |
| 149 | 149 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | protected function getFieldErrors() |
| 155 | 155 | { |
| 156 | - if( empty( $this->field['errors'] ) || !is_array( $this->field['errors'] ))return; |
|
| 156 | + if( empty($this->field['errors']) || !is_array( $this->field['errors'] ) )return; |
|
| 157 | 157 | $errors = array_reduce( $this->field['errors'], function( $carry, $error ) { |
| 158 | 158 | return $carry.glsr( Builder::class )->span( $error, ['class' => 'glsr-field-error'] ); |
| 159 | 159 | }); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | 'context' => [ |
| 162 | 162 | 'errors' => $errors, |
| 163 | 163 | ], |
| 164 | - ]); |
|
| 164 | + ] ); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -184,13 +184,13 @@ discard block |
||
| 184 | 184 | 'name', 'type', |
| 185 | 185 | ]; |
| 186 | 186 | foreach( $requiredValues as $value ) { |
| 187 | - if( isset( $this->field[$value] ))continue; |
|
| 187 | + if( isset($this->field[$value]) )continue; |
|
| 188 | 188 | $missingValues[] = $value; |
| 189 | 189 | $this->field['is_valid'] = false; |
| 190 | 190 | } |
| 191 | - if( !empty( $missingValues )) { |
|
| 191 | + if( !empty($missingValues) ) { |
|
| 192 | 192 | glsr_log() |
| 193 | - ->warning( 'Field is missing: '.implode( ', ', $missingValues )) |
|
| 193 | + ->warning( 'Field is missing: '.implode( ', ', $missingValues ) ) |
|
| 194 | 194 | ->debug( $this->field ); |
| 195 | 195 | } |
| 196 | 196 | return $this->field['is_valid']; |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | if( !$this->isFieldValid() )return; |
| 205 | 205 | $this->field['path'] = $this->field['name']; |
| 206 | 206 | $className = glsr( Helper::class )->buildClassName( $this->field['type'], __NAMESPACE__.'\Fields' ); |
| 207 | - if( class_exists( $className )) { |
|
| 207 | + if( class_exists( $className ) ) { |
|
| 208 | 208 | $this->field = $className::merge( $this->field ); |
| 209 | 209 | } |
| 210 | 210 | $this->normalizeFieldId(); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | protected function normalizeFieldId() |
| 218 | 218 | { |
| 219 | - if( isset( $this->field['id'] ) || $this->field['is_raw'] )return; |
|
| 219 | + if( isset($this->field['id']) || $this->field['is_raw'] )return; |
|
| 220 | 220 | $this->field['id'] = glsr( Helper::class )->convertPathToId( |
| 221 | 221 | $this->field['path'], |
| 222 | 222 | $this->getFieldPrefix() |