@@ -16,7 +16,7 @@ |
||
| 16 | 16 | 'author' => '', |
| 17 | 17 | 'avatar' => '', |
| 18 | 18 | 'content' => '', |
| 19 | - 'date' => get_date_from_gmt( gmdate( 'Y-m-d H:i:s' )), |
|
| 19 | + 'date' => get_date_from_gmt( gmdate( 'Y-m-d H:i:s' ) ), |
|
| 20 | 20 | 'email' => '', |
| 21 | 21 | 'ip_address' => '', |
| 22 | 22 | 'pinned' => false, |
@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | public function buildClassName( $name, $path = '' ) |
| 16 | 16 | { |
| 17 | - $className = array_map( 'strtolower', (array)preg_split( '/[-_]/', $name )); |
|
| 17 | + $className = array_map( 'strtolower', (array)preg_split( '/[-_]/', $name ) ); |
|
| 18 | 18 | $className = array_map( 'ucfirst', $className ); |
| 19 | 19 | $className = implode( '', $className ); |
| 20 | 20 | $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' ); |
| 21 | - return !empty( $path ) |
|
| 21 | + return !empty($path) |
|
| 22 | 22 | ? __NAMESPACE__.'\\'.$path.'\\'.$className |
| 23 | 23 | : $className; |
| 24 | 24 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function buildMethodName( $name, $prefix = '' ) |
| 32 | 32 | { |
| 33 | - return lcfirst( $prefix.$this->buildClassName( $name )); |
|
| 33 | + return lcfirst( $prefix.$this->buildClassName( $name ) ); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function buildPropertyName( $name ) |
| 41 | 41 | { |
| 42 | - return lcfirst( $this->buildClassName( $name )); |
|
| 42 | + return lcfirst( $this->buildClassName( $name ) ); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function dashCase( $string ) |
| 72 | 72 | { |
| 73 | - return str_replace( '_', '-', $this->snakeCase( $string )); |
|
| 73 | + return str_replace( '_', '-', $this->snakeCase( $string ) ); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | $result = []; |
| 96 | 96 | foreach( $array as $key => $value ) { |
| 97 | - $newKey = $prefix.( empty( $prefix ) ? '' : '.' ).$key; |
|
| 98 | - if( $this->isIndexedArray( $value )) { |
|
| 97 | + $newKey = $prefix.(empty($prefix) ? '' : '.').$key; |
|
| 98 | + if( $this->isIndexedArray( $value ) ) { |
|
| 99 | 99 | $value = '['.implode( ', ', $value ).']'; |
| 100 | 100 | } |
| 101 | - if( is_array( $value )) { |
|
| 102 | - $result = array_merge( $result, $this->flattenArray( $value, $newKey )); |
|
| 101 | + if( is_array( $value ) ) { |
|
| 102 | + $result = array_merge( $result, $this->flattenArray( $value, $newKey ) ); |
|
| 103 | 103 | continue; |
| 104 | 104 | } |
| 105 | 105 | $result[$newKey] = $value; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | Whip::IPV4 => $cloudflareIps['v4'], |
| 119 | 119 | Whip::IPV6 => $cloudflareIps['v6'], |
| 120 | 120 | ], |
| 121 | - ]))->getValidIpAddress(); |
|
| 121 | + ] ))->getValidIpAddress(); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | { |
| 132 | 132 | $keys = explode( '.', $path ); |
| 133 | 133 | foreach( $keys as $key ) { |
| 134 | - if( !isset( $values[$key] )) { |
|
| 134 | + if( !isset($values[$key]) ) { |
|
| 135 | 135 | return $fallback; |
| 136 | 136 | } |
| 137 | 137 | $values = $values[$key]; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | public function isIndexedArray( $array ) |
| 147 | 147 | { |
| 148 | - if( !is_array( $array ) || array_filter( $array, 'is_array' )) { |
|
| 148 | + if( !is_array( $array ) || array_filter( $array, 'is_array' ) ) { |
|
| 149 | 149 | return false; |
| 150 | 150 | } |
| 151 | 151 | $current = 0; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | */ |
| 202 | 202 | public function snakeCase( $string ) |
| 203 | 203 | { |
| 204 | - if( !ctype_lower( $string )) { |
|
| 204 | + if( !ctype_lower( $string ) ) { |
|
| 205 | 205 | $string = preg_replace( '/\s+/u', '', $string ); |
| 206 | 206 | $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string ); |
| 207 | 207 | $string = mb_strtolower( $string, 'UTF-8' ); |
@@ -216,6 +216,6 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function startsWith( $needle, $haystack ) |
| 218 | 218 | { |
| 219 | - return substr( $haystack, 0, strlen( $needle )) === $needle; |
|
| 219 | + return substr( $haystack, 0, strlen( $needle ) ) === $needle; |
|
| 220 | 220 | } |
| 221 | 221 | } |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | defined( 'WPINC' ) || die; |
| 4 | 4 | |
| 5 | -require_once( ABSPATH.WPINC.'/class-phpass.php' ); |
|
| 5 | +require_once(ABSPATH.WPINC.'/class-phpass.php'); |
|
| 6 | 6 | |
| 7 | 7 | spl_autoload_register( function( $className ) { |
| 8 | 8 | $namespaces = [ |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | foreach( $namespaces as $prefix => $base_dir ) { |
| 17 | 17 | $len = strlen( $prefix ); |
| 18 | 18 | if( strncmp( $prefix, $className, $len ) !== 0 )continue; |
| 19 | - $file = $base_dir.str_replace( '\\', '/', substr( $className, $len )).'.php'; |
|
| 20 | - if( !file_exists( $file ))continue; |
|
| 19 | + $file = $base_dir.str_replace( '\\', '/', substr( $className, $len ) ).'.php'; |
|
| 20 | + if( !file_exists( $file ) )continue; |
|
| 21 | 21 | require $file; |
| 22 | 22 | break; |
| 23 | 23 | } |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public static function isPhpValid( $version = '' ) |
| 34 | 34 | { |
| 35 | - if( !empty( $version )) { |
|
| 36 | - static::normalize( array( 'php' => $version )); |
|
| 35 | + if( !empty($version) ) { |
|
| 36 | + static::normalize( array( 'php' => $version ) ); |
|
| 37 | 37 | } |
| 38 | 38 | return !version_compare( PHP_VERSION, static::$versions->php, '<' ); |
| 39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public static function isValid( array $args = array() ) |
| 45 | 45 | { |
| 46 | - if( !empty( $args )) { |
|
| 46 | + if( !empty($args) ) { |
|
| 47 | 47 | static::normalize( $args ); |
| 48 | 48 | } |
| 49 | 49 | return static::isPhpValid() && static::isWpValid(); |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | public static function isWpValid( $version = '' ) |
| 57 | 57 | { |
| 58 | 58 | global $wp_version; |
| 59 | - if( !empty( $version )) { |
|
| 60 | - static::normalize( array( 'wordpress' => $version )); |
|
| 59 | + if( !empty($version) ) { |
|
| 60 | + static::normalize( array( 'wordpress' => $version ) ); |
|
| 61 | 61 | } |
| 62 | 62 | return !version_compare( $wp_version, static::$versions->wordpress, '<' ); |
| 63 | 63 | } |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public static function shouldDeactivate( $file, array $args = array() ) |
| 70 | 70 | { |
| 71 | - if( empty( static::$instance )) { |
|
| 71 | + if( empty(static::$instance) ) { |
|
| 72 | 72 | static::$file = realpath( $file ); |
| 73 | 73 | static::$instance = new static; |
| 74 | 74 | static::$versions = static::normalize( $args ); |
| 75 | 75 | } |
| 76 | 76 | if( !static::isValid() ) { |
| 77 | - add_action( 'activated_plugin', array( static::$instance, 'deactivate' )); |
|
| 78 | - add_action( 'admin_notices', array( static::$instance, 'deactivate' )); |
|
| 77 | + add_action( 'activated_plugin', array( static::$instance, 'deactivate' ) ); |
|
| 78 | + add_action( 'admin_notices', array( static::$instance, 'deactivate' ) ); |
|
| 79 | 79 | return true; |
| 80 | 80 | } |
| 81 | 81 | return false; |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | return (object)wp_parse_args( $args, array( |
| 106 | 106 | 'php' => static::MIN_PHP_VERSION, |
| 107 | 107 | 'wordpress' => static::MIN_WORDPRESS_VERSION, |
| 108 | - )); |
|
| 108 | + ) ); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | filter_input( INPUT_GET, 'plugin_status' ), |
| 118 | 118 | filter_input( INPUT_GET, 'paged' ), |
| 119 | 119 | filter_input( INPUT_GET, 's' ) |
| 120 | - ))); |
|
| 120 | + ) ) ); |
|
| 121 | 121 | exit; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | 'post_type' => Application::POST_TYPE, |
| 35 | 35 | ]; |
| 36 | 36 | if( $review['review_type'] == 'local' && ( |
| 37 | - glsr( OptionManager::class )->get( 'settings.general.require.approval' ) == 'yes' || $command->blacklisted )) { |
|
| 37 | + glsr( OptionManager::class )->get( 'settings.general.require.approval' ) == 'yes' || $command->blacklisted ) ) { |
|
| 38 | 38 | $post['post_status'] = 'pending'; |
| 39 | 39 | } |
| 40 | 40 | $postId = wp_insert_post( $post, true ); |
| 41 | - if( is_wp_error( $postId )) { |
|
| 41 | + if( is_wp_error( $postId ) ) { |
|
| 42 | 42 | glsr_log()->error( $postId->get_error_message() ); |
| 43 | 43 | return false; |
| 44 | 44 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function deleteReview( $metaReviewId ) |
| 58 | 58 | { |
| 59 | - if( $postId = $this->getReviewPostId( $metaReviewId )) { |
|
| 59 | + if( $postId = $this->getReviewPostId( $metaReviewId ) ) { |
|
| 60 | 60 | wp_delete_post( $postId, true ); |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function getReview( $post ) |
| 69 | 69 | { |
| 70 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
| 70 | + if( !($post instanceof WP_Post) || $post->post_type != Application::POST_TYPE )return; |
|
| 71 | 71 | $review = $this->getReviewMeta( $post->ID ); |
| 72 | 72 | $modified = $this->isReviewModified( $post, $review ); |
| 73 | 73 | $review->content = $post->post_content; |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | { |
| 90 | 90 | $metaKey = $this->normalizeMetaKey( $metaKey ); |
| 91 | 91 | if( !$metaKey ) { |
| 92 | - return (array) wp_count_posts( Application::POST_TYPE ); |
|
| 92 | + return (array)wp_count_posts( Application::POST_TYPE ); |
|
| 93 | 93 | } |
| 94 | 94 | $counts = glsr( Cache::class )->getReviewCountsFor( $metaKey ); |
| 95 | 95 | if( !$metaValue ) { |
| 96 | 96 | return $counts; |
| 97 | 97 | } |
| 98 | - return isset( $counts[$metaValue] ) |
|
| 98 | + return isset($counts[$metaValue]) |
|
| 99 | 99 | ? $counts[$metaValue] |
| 100 | 100 | : 0; |
| 101 | 101 | } |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | public function getReviewMeta( $postId ) |
| 117 | 117 | { |
| 118 | 118 | $meta = get_post_type( $postId ) == Application::POST_TYPE |
| 119 | - ? array_map( 'array_shift', (array) get_post_meta( $postId )) |
|
| 119 | + ? array_map( 'array_shift', (array)get_post_meta( $postId ) ) |
|
| 120 | 120 | : []; |
| 121 | - return (object) $this->normalizeMeta( array_filter( $meta, 'strlen' )); |
|
| 121 | + return (object)$this->normalizeMeta( array_filter( $meta, 'strlen' ) ); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $paged = glsr( QueryBuilder::class )->getPaged( |
| 148 | 148 | wp_validate_boolean( $args['pagination'] ) |
| 149 | 149 | ); |
| 150 | - $reviews = new WP_Query([ |
|
| 150 | + $reviews = new WP_Query( [ |
|
| 151 | 151 | 'meta_key' => 'pinned', |
| 152 | 152 | 'meta_query' => $metaQuery, |
| 153 | 153 | 'offset' => $args['offset'], |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | 'post_type' => Application::POST_TYPE, |
| 161 | 161 | 'posts_per_page' => $args['count'] ? $args['count'] : -1, |
| 162 | 162 | 'tax_query' => $taxQuery, |
| 163 | - ]); |
|
| 164 | - return (object) [ |
|
| 163 | + ] ); |
|
| 164 | + return (object)[ |
|
| 165 | 165 | 'results' => array_map( [$this, 'getReview'], $reviews->posts ), |
| 166 | 166 | 'max_num_pages' => $reviews->max_num_pages, |
| 167 | 167 | ]; |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | public function getReviewsMeta( $keys, $status = 'publish' ) |
| 176 | 176 | { |
| 177 | 177 | $keys = array_map( [$this, 'normalizeMetaKey'], (array)$keys ); |
| 178 | - if( $status == 'all' || empty( $status )) { |
|
| 178 | + if( $status == 'all' || empty($status) ) { |
|
| 179 | 179 | $status = get_post_stati( ['exclude_from_search' => false] ); |
| 180 | 180 | } |
| 181 | 181 | return glsr( SqlQueries::class )->getReviewsMeta( $keys, $status ); |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | 'fields' => 'id=>name', |
| 192 | 192 | 'hide_empty' => false, |
| 193 | 193 | 'taxonomy' => Application::TAXONOMY, |
| 194 | - ]); |
|
| 195 | - unset( $args['count'] ); //we don't want a term count |
|
| 194 | + ] ); |
|
| 195 | + unset($args['count']); //we don't want a term count |
|
| 196 | 196 | $terms = get_terms( $args ); |
| 197 | - if( is_wp_error( $terms )) { |
|
| 197 | + if( is_wp_error( $terms ) ) { |
|
| 198 | 198 | glsr_log()->error( $terms->get_error_message() ); |
| 199 | 199 | return []; |
| 200 | 200 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public function normalizeMeta( array $meta ) |
| 208 | 208 | { |
| 209 | - if( empty( $meta )) { |
|
| 209 | + if( empty($meta) ) { |
|
| 210 | 210 | return []; |
| 211 | 211 | } |
| 212 | 212 | $defaults = wp_parse_args( $meta, [ |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | 'date' => '', |
| 215 | 215 | 'review_id' => '', |
| 216 | 216 | 'review_type' => '', |
| 217 | - ]); |
|
| 217 | + ] ); |
|
| 218 | 218 | return glsr( CreateReviewDefaults::class )->merge( $defaults, true ); |
| 219 | 219 | } |
| 220 | 220 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | public function normalizeMetaKey( $metaKey ) |
| 226 | 226 | { |
| 227 | 227 | $metaKey = strtolower( $metaKey ); |
| 228 | - if( in_array( $metaKey, ['id', 'type'] )) { |
|
| 228 | + if( in_array( $metaKey, ['id', 'type'] ) ) { |
|
| 229 | 229 | $metaKey = 'review_'.$metaKey; |
| 230 | 230 | } |
| 231 | 231 | return $metaKey; |
@@ -238,10 +238,10 @@ discard block |
||
| 238 | 238 | public function normalizeTerms( $termIds ) |
| 239 | 239 | { |
| 240 | 240 | $terms = []; |
| 241 | - $termIds = array_map( 'trim', explode( ',', $termIds )); |
|
| 241 | + $termIds = array_map( 'trim', explode( ',', $termIds ) ); |
|
| 242 | 242 | foreach( $termIds as $termId ) { |
| 243 | 243 | $term = term_exists( $termId, Application::TAXONOMY ); |
| 244 | - if( !isset( $term['term_id'] ))continue; |
|
| 244 | + if( !isset($term['term_id']) )continue; |
|
| 245 | 245 | $terms[] = intval( $term['term_id'] ); |
| 246 | 246 | } |
| 247 | 247 | return $terms; |
@@ -254,15 +254,15 @@ discard block |
||
| 254 | 254 | public function revertReview( $postId ) |
| 255 | 255 | { |
| 256 | 256 | $post = get_post( $postId ); |
| 257 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
| 257 | + if( !($post instanceof WP_Post) || $post->post_type != Application::POST_TYPE )return; |
|
| 258 | 258 | delete_post_meta( $post->ID, '_edit_last' ); |
| 259 | - $result = wp_update_post([ |
|
| 259 | + $result = wp_update_post( [ |
|
| 260 | 260 | 'ID' => $post->ID, |
| 261 | 261 | 'post_content' => get_post_meta( $post->ID, 'content', true ), |
| 262 | 262 | 'post_date' => get_post_meta( $post->ID, 'date', true ), |
| 263 | 263 | 'post_title' => get_post_meta( $post->ID, 'title', true ), |
| 264 | - ]); |
|
| 265 | - if( is_wp_error( $result )) { |
|
| 264 | + ] ); |
|
| 265 | + if( is_wp_error( $result ) ) { |
|
| 266 | 266 | glsr_log()->error( $result->get_error_message() ); |
| 267 | 267 | } |
| 268 | 268 | } |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | 'post_status' => 'publish', |
| 278 | 278 | 'post_type' => 'any', |
| 279 | 279 | ]; |
| 280 | - if( is_numeric( $searchTerm )) { |
|
| 280 | + if( is_numeric( $searchTerm ) ) { |
|
| 281 | 281 | $args['post__in'] = [$searchTerm]; |
| 282 | 282 | } |
| 283 | 283 | else { |
@@ -296,9 +296,9 @@ discard block |
||
| 296 | 296 | ob_start(); |
| 297 | 297 | glsr()->render( 'edit/search-result', [ |
| 298 | 298 | 'ID' => get_the_ID(), |
| 299 | - 'permalink' => esc_url( (string) get_permalink() ), |
|
| 299 | + 'permalink' => esc_url( (string)get_permalink() ), |
|
| 300 | 300 | 'title' => esc_attr( get_the_title() ), |
| 301 | - ]); |
|
| 301 | + ] ); |
|
| 302 | 302 | $results .= ob_get_clean(); |
| 303 | 303 | } |
| 304 | 304 | wp_reset_postdata(); |
@@ -313,9 +313,9 @@ discard block |
||
| 313 | 313 | public function setReviewMeta( $postId, $termIds ) |
| 314 | 314 | { |
| 315 | 315 | $terms = $this->normalizeTerms( $termIds ); |
| 316 | - if( empty( $terms ))return; |
|
| 316 | + if( empty($terms) )return; |
|
| 317 | 317 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
| 318 | - if( is_wp_error( $result )) { |
|
| 318 | + if( is_wp_error( $result ) ) { |
|
| 319 | 319 | glsr_log()->error( $result->get_error_message() ); |
| 320 | 320 | } |
| 321 | 321 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | wp_send_json( glsr( Html::class )->renderPartial( 'link', [ |
| 25 | 25 | 'post_id' => $request['ID'], |
| 26 | - ])); |
|
| 26 | + ] ) ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function changeReviewStatus( array $request ) |
| 33 | 33 | { |
| 34 | - wp_send_json( $this->execute( new ChangeStatus( $request ))); |
|
| 34 | + wp_send_json( $this->execute( new ChangeStatus( $request ) ) ); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | public function clearLog() |
| 41 | 41 | { |
| 42 | 42 | glsr( AdminController::class )->routerClearLog(); |
| 43 | - wp_send_json([ |
|
| 43 | + wp_send_json( [ |
|
| 44 | 44 | 'logger' => glsr( Logger::class )->get(), |
| 45 | 45 | 'notices' => glsr( Notice::class )->get(), |
| 46 | - ]); |
|
| 46 | + ] ); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | { |
| 54 | 54 | $shortcode = $request['shortcode']; |
| 55 | 55 | $response = false; |
| 56 | - if( array_key_exists( $shortcode, glsr()->mceShortcodes )) { |
|
| 56 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
| 57 | 57 | $data = glsr()->mceShortcodes[$shortcode]; |
| 58 | - if( !empty( $data['errors'] )) { |
|
| 58 | + if( !empty($data['errors']) ) { |
|
| 59 | 59 | $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
| 60 | 60 | } |
| 61 | 61 | $response = [ |
@@ -75,10 +75,10 @@ discard block |
||
| 75 | 75 | public function searchPosts( array $request ) |
| 76 | 76 | { |
| 77 | 77 | $results = glsr_db()->searchPosts( $request['search'] ); |
| 78 | - wp_send_json_success([ |
|
| 78 | + wp_send_json_success( [ |
|
| 79 | 79 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
| 80 | 80 | 'items' => $results, |
| 81 | - ]); |
|
| 81 | + ] ); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function searchTranslations( array $request ) |
| 88 | 88 | { |
| 89 | - if( empty( $request['exclude'] )) { |
|
| 89 | + if( empty($request['exclude']) ) { |
|
| 90 | 90 | $request['exclude'] = []; |
| 91 | 91 | } |
| 92 | 92 | $results = glsr( Translator::class ) |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | ->exclude() |
| 95 | 95 | ->exclude( $request['exclude'] ) |
| 96 | 96 | ->renderResults(); |
| 97 | - wp_send_json_success([ |
|
| 97 | + wp_send_json_success( [ |
|
| 98 | 98 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
| 99 | 99 | 'items' => $results, |
| 100 | - ]); |
|
| 100 | + ] ); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | { |
| 108 | 108 | $response = glsr( PublicController::class )->routerCreateReview( $request ); |
| 109 | 109 | $session = glsr( Session::class ); |
| 110 | - wp_send_json([ |
|
| 110 | + wp_send_json( [ |
|
| 111 | 111 | 'errors' => $session->get( $request['form_id'].'-errors', false, true ), |
| 112 | 112 | 'message' => $response, |
| 113 | 113 | 'recaptcha' => $session->get( $request['form_id'].'-recaptcha', false, true ), |
| 114 | - ]); |
|
| 114 | + ] ); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function togglePinned( array $request ) |
| 121 | 121 | { |
| 122 | - wp_send_json([ |
|
| 122 | + wp_send_json( [ |
|
| 123 | 123 | 'notices' => glsr( Notice::class )->get(), |
| 124 | - 'pinned' => $this->execute( new TogglePinned( $request )), |
|
| 125 | - ]); |
|
| 124 | + 'pinned' => $this->execute( new TogglePinned( $request ) ), |
|
| 125 | + ] ); |
|
| 126 | 126 | } |
| 127 | 127 | } |
@@ -44,10 +44,10 @@ discard block |
||
| 44 | 44 | $vars[] = Application::PAGED_QUERY_VAR; |
| 45 | 45 | // dirty hack to fix a form submission with a field that has "name" as name |
| 46 | 46 | if( filter_input( INPUT_POST, 'action' ) == 'submit-review' |
| 47 | - && !is_null( filter_input( INPUT_POST, 'gotcha' ))) { |
|
| 47 | + && !is_null( filter_input( INPUT_POST, 'gotcha' ) ) ) { |
|
| 48 | 48 | $index = array_search( 'name', $vars, true ); |
| 49 | 49 | if( false !== $index ) { |
| 50 | - unset( $vars[$index] ); |
|
| 50 | + unset($vars[$index]); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | return $vars; |
@@ -59,10 +59,10 @@ discard block |
||
| 59 | 59 | public function postCreateReview( array $request ) |
| 60 | 60 | { |
| 61 | 61 | $validated = glsr( ValidateReview::class )->validate( $request ); |
| 62 | - if( !empty( $validated->error )) { |
|
| 62 | + if( !empty($validated->error) ) { |
|
| 63 | 63 | return $validated->request; |
| 64 | 64 | } |
| 65 | 65 | if( $validated->recaptchaIsUnset )return; |
| 66 | - return $this->execute( new CreateReview( $validated->request )); |
|
| 66 | + return $this->execute( new CreateReview( $validated->request ) ); |
|
| 67 | 67 | } |
| 68 | 68 | } |
@@ -21,11 +21,11 @@ discard block |
||
| 21 | 21 | return $input; |
| 22 | 22 | } |
| 23 | 23 | $triggered = true; |
| 24 | - if( !is_array( $input )) { |
|
| 24 | + if( !is_array( $input ) ) { |
|
| 25 | 25 | $input = ['settings' => []]; |
| 26 | 26 | } |
| 27 | 27 | if( key( $input ) == 'settings' ) { |
| 28 | - glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' )); |
|
| 28 | + glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) ); |
|
| 29 | 29 | } |
| 30 | 30 | $options = array_replace_recursive( glsr( OptionManager::class )->all(), $input ); |
| 31 | 31 | $options = $this->sanitizeSubmissions( $input, $options ); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | foreach( $settings as $setting ) { |
| 44 | 44 | register_setting( Application::ID.'-'.$setting, OptionManager::databaseKey(), [ |
| 45 | 45 | 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
| 46 | - ]); |
|
| 46 | + ] ); |
|
| 47 | 47 | } |
| 48 | 48 | glsr( Settings::class )->register(); |
| 49 | 49 | } |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | protected function sanitizeSubmissions( array $input, array $options ) |
| 55 | 55 | { |
| 56 | - if( isset( $input['settings']['submissions'] )) { |
|
| 56 | + if( isset($input['settings']['submissions']) ) { |
|
| 57 | 57 | $inputForm = $input['settings']['submissions']; |
| 58 | - $options['settings']['submissions']['required'] = isset( $inputForm['required'] ) |
|
| 58 | + $options['settings']['submissions']['required'] = isset($inputForm['required']) |
|
| 59 | 59 | ? $inputForm['required'] |
| 60 | 60 | : []; |
| 61 | 61 | } |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | protected function sanitizeTranslations( array $input, array $options ) |
| 69 | 69 | { |
| 70 | - if( isset( $input['settings']['translations'] )) { |
|
| 71 | - $options['settings']['translations'] = array_values( array_filter( $input['settings']['translations'] )); |
|
| 70 | + if( isset($input['settings']['translations']) ) { |
|
| 71 | + $options['settings']['translations'] = array_values( array_filter( $input['settings']['translations'] ) ); |
|
| 72 | 72 | array_walk( $options['settings']['translations'], function( &$string ) { |
| 73 | - if( isset( $string['s2'] )) { |
|
| 73 | + if( isset($string['s2']) ) { |
|
| 74 | 74 | $string['s2'] = wp_strip_all_tags( $string['s2'] ); |
| 75 | 75 | } |
| 76 | - if( isset( $string['p2'] )) { |
|
| 76 | + if( isset($string['p2']) ) { |
|
| 77 | 77 | $string['p2'] = wp_strip_all_tags( $string['p2'] ); |
| 78 | 78 | } |
| 79 | 79 | }); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | public function __construct( $input ) |
| 25 | 25 | { |
| 26 | - $this->ajaxRequest = isset( $input['ajax_request'] ); |
|
| 26 | + $this->ajaxRequest = isset($input['ajax_request']); |
|
| 27 | 27 | $this->assignedTo = is_numeric( $input['assign_to'] ) |
| 28 | 28 | ? $input['assign_to'] |
| 29 | 29 | : ''; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $this->rating = intval( $input['rating'] ); |
| 38 | 38 | $this->referrer = $input['_wp_http_referer']; |
| 39 | 39 | $this->request = $input; |
| 40 | - $this->terms = isset( $input['terms'] ); |
|
| 40 | + $this->terms = isset($input['terms']); |
|
| 41 | 41 | $this->title = sanitize_text_field( $input['title'] ); |
| 42 | 42 | } |
| 43 | 43 | } |