@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | public function __construct() |
| 34 | 34 | { |
| 35 | 35 | static::$instance = $this; |
| 36 | - $this->file = realpath( trailingslashit( dirname( __DIR__ )).static::ID.'.php' ); |
|
| 36 | + $this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' ); |
|
| 37 | 37 | $plugin = get_file_data( $this->file, [ |
| 38 | 38 | 'languages' => 'Domain Path', |
| 39 | 39 | 'name' => 'Plugin Name', |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | $constant = 'static::'.$property; |
| 87 | 87 | return defined( $constant ) |
| 88 | - ? apply_filters( 'site-reviews/const/'.$property, constant( $constant )) |
|
| 88 | + ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) ) |
|
| 89 | 89 | : ''; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -103,15 +103,15 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function file( $view ) |
| 105 | 105 | { |
| 106 | - $view.= '.php'; |
|
| 106 | + $view .= '.php'; |
|
| 107 | 107 | $filePaths = []; |
| 108 | - if( glsr( Helper::class )->startsWith( 'templates/', $view )) { |
|
| 109 | - $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view )); |
|
| 108 | + if( glsr( Helper::class )->startsWith( 'templates/', $view ) ) { |
|
| 109 | + $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view ) ); |
|
| 110 | 110 | } |
| 111 | 111 | $filePaths[] = $this->path( $view ); |
| 112 | 112 | $filePaths[] = $this->path( 'views/'.$view ); |
| 113 | 113 | foreach( $filePaths as $file ) { |
| 114 | - if( !file_exists( $file ))continue; |
|
| 114 | + if( !file_exists( $file ) )continue; |
|
| 115 | 115 | return $file; |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function getDefaults() |
| 123 | 123 | { |
| 124 | - if( empty( $this->defaults )) { |
|
| 124 | + if( empty($this->defaults) ) { |
|
| 125 | 125 | $this->defaults = $this->make( DefaultsManager::class )->get(); |
| 126 | 126 | $this->upgrade(); |
| 127 | 127 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | public function hasPermission() |
| 135 | 135 | { |
| 136 | 136 | $isAdmin = $this->isAdmin(); |
| 137 | - return !$isAdmin || ( $isAdmin && current_user_can( $this->constant( 'CAPABILITY' ))); |
|
| 137 | + return !$isAdmin || ($isAdmin && current_user_can( $this->constant( 'CAPABILITY' ) )); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $types = apply_filters( 'site-reviews/addon/types', [] ); |
| 191 | 191 | $this->reviewTypes = wp_parse_args( $types, [ |
| 192 | 192 | 'local' => __( 'Local', 'site-reviews' ), |
| 193 | - ]); |
|
| 193 | + ] ); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | { |
| 202 | 202 | $view = apply_filters( 'site-reviews/render/view', $view, $data ); |
| 203 | 203 | $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data ); |
| 204 | - if( !file_exists( $file )) { |
|
| 204 | + if( !file_exists( $file ) ) { |
|
| 205 | 205 | glsr_log()->error( 'File not found: '.$file ); |
| 206 | 206 | return; |
| 207 | 207 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | public function scheduleCronJob() |
| 217 | 217 | { |
| 218 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
| 218 | + if( wp_next_scheduled( static::CRON_EVENT ) )return; |
|
| 219 | 219 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
| 220 | 220 | } |
| 221 | 221 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | public function unscheduleCronJob() |
| 235 | 235 | { |
| 236 | - wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT ); |
|
| 236 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | */ |
| 266 | 266 | public function url( $path = '' ) |
| 267 | 267 | { |
| 268 | - $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
| 268 | + $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
| 269 | 269 | return apply_filters( 'site-reviews/url', $url, $path ); |
| 270 | 270 | } |
| 271 | 271 | } |
@@ -60,7 +60,9 @@ discard block |
||
| 60 | 60 | public function catchFatalError() |
| 61 | 61 | { |
| 62 | 62 | $error = error_get_last(); |
| 63 | - if( $error['type'] !== E_ERROR || strpos( $error['message'], $this->path() ) === false )return; |
|
| 63 | + if( $error['type'] !== E_ERROR || strpos( $error['message'], $this->path() ) === false ) { |
|
| 64 | + return; |
|
| 65 | + } |
|
| 64 | 66 | glsr_log()->error( $error['message'] ); |
| 65 | 67 | } |
| 66 | 68 | |
@@ -111,7 +113,9 @@ discard block |
||
| 111 | 113 | $filePaths[] = $this->path( $view ); |
| 112 | 114 | $filePaths[] = $this->path( 'views/'.$view ); |
| 113 | 115 | foreach( $filePaths as $file ) { |
| 114 | - if( !file_exists( $file ))continue; |
|
| 116 | + if( !file_exists( $file )) { |
|
| 117 | + continue; |
|
| 118 | + } |
|
| 115 | 119 | return $file; |
| 116 | 120 | } |
| 117 | 121 | } |
@@ -215,7 +219,9 @@ discard block |
||
| 215 | 219 | */ |
| 216 | 220 | public function scheduleCronJob() |
| 217 | 221 | { |
| 218 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
| 222 | + if( wp_next_scheduled( static::CRON_EVENT )) { |
|
| 223 | + return; |
|
| 224 | + } |
|
| 219 | 225 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
| 220 | 226 | } |
| 221 | 227 | |
@@ -255,7 +261,9 @@ discard block |
||
| 255 | 261 | || !in_array( plugin_basename( $this->file ), $data['plugins'] ) |
| 256 | 262 | || $data['action'] != 'update' |
| 257 | 263 | || $data['type'] != 'plugin' |
| 258 | - )return; |
|
| 264 | + ) { |
|
| 265 | + return; |
|
| 266 | + } |
|
| 259 | 267 | $this->upgrade(); |
| 260 | 268 | } |
| 261 | 269 | |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | 'templates/form/submit-button', |
| 51 | 51 | 'templates/reviews-form', |
| 52 | 52 | ]; |
| 53 | - if( !preg_match( '('.implode( '|', $styledViews ).')', $view )) { |
|
| 53 | + if( !preg_match( '('.implode( '|', $styledViews ).')', $view ) ) { |
|
| 54 | 54 | return $view; |
| 55 | 55 | } |
| 56 | 56 | $views = $this->generatePossibleViews( $view ); |
| 57 | 57 | foreach( $views as $possibleView ) { |
| 58 | - if( !file_exists( glsr()->file( $possibleView )))continue; |
|
| 58 | + if( !file_exists( glsr()->file( $possibleView ) ) )continue; |
|
| 59 | 59 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
| 60 | 60 | } |
| 61 | 61 | return $view; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function modifyField( Builder $instance ) |
| 90 | 90 | { |
| 91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
| 91 | + if( !$this->isPublicInstance( $instance ) || empty(array_filter( $this->fields )) )return; |
|
| 92 | 92 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | protected function customize( Builder $instance ) |
| 107 | 107 | { |
| 108 | - if( !array_key_exists( $instance->tag, $this->fields ))return; |
|
| 109 | - $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
|
| 108 | + if( !array_key_exists( $instance->tag, $this->fields ) )return; |
|
| 109 | + $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) ); |
|
| 110 | 110 | $key = $instance->tag.'_'.$args['type']; |
| 111 | - $classes = !isset( $this->fields[$key] ) |
|
| 111 | + $classes = !isset($this->fields[$key]) |
|
| 112 | 112 | ? $this->fields[$instance->tag] |
| 113 | 113 | : $this->fields[$key]; |
| 114 | 114 | $instance->args['class'] = trim( $args['class'].' '.$classes ); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $args = wp_parse_args( $instance->args, [ |
| 143 | 143 | 'is_public' => false, |
| 144 | 144 | 'is_raw' => false, |
| 145 | - ]); |
|
| 145 | + ] ); |
|
| 146 | 146 | if( is_admin() || !$args['is_public'] || $args['is_raw'] ) { |
| 147 | 147 | return false; |
| 148 | 148 | } |
@@ -55,7 +55,9 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | $views = $this->generatePossibleViews( $view ); |
| 57 | 57 | foreach( $views as $possibleView ) { |
| 58 | - if( !file_exists( glsr()->file( $possibleView )))continue; |
|
| 58 | + if( !file_exists( glsr()->file( $possibleView ))) { |
|
| 59 | + continue; |
|
| 60 | + } |
|
| 59 | 61 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
| 60 | 62 | } |
| 61 | 63 | return $view; |
@@ -88,7 +90,9 @@ discard block |
||
| 88 | 90 | */ |
| 89 | 91 | public function modifyField( Builder $instance ) |
| 90 | 92 | { |
| 91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
| 93 | + if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields ))) { |
|
| 94 | + return; |
|
| 95 | + } |
|
| 92 | 96 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
| 93 | 97 | } |
| 94 | 98 | |
@@ -105,7 +109,9 @@ discard block |
||
| 105 | 109 | */ |
| 106 | 110 | protected function customize( Builder $instance ) |
| 107 | 111 | { |
| 108 | - if( !array_key_exists( $instance->tag, $this->fields ))return; |
|
| 112 | + if( !array_key_exists( $instance->tag, $this->fields )) { |
|
| 113 | + return; |
|
| 114 | + } |
|
| 109 | 115 | $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
| 110 | 116 | $key = $instance->tag.'_'.$args['type']; |
| 111 | 117 | $classes = !isset( $this->fields[$key] ) |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | public function __construct( array $values = [] ) |
| 16 | 16 | { |
| 17 | 17 | $this->values = $values; |
| 18 | - parent::__construct( $values, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
| 18 | + parent::__construct( $values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function __toString() |
| 35 | 35 | { |
| 36 | - if( empty( $this->values ))return; |
|
| 36 | + if( empty($this->values) )return; |
|
| 37 | 37 | return glsr( Template::class )->build( 'templates/review', [ |
| 38 | 38 | 'context' => $this->values, |
| 39 | - ]); |
|
| 39 | + ] ); |
|
| 40 | 40 | } |
| 41 | 41 | } |
@@ -33,7 +33,9 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | public function __toString() |
| 35 | 35 | { |
| 36 | - if( empty( $this->values ))return; |
|
| 36 | + if( empty( $this->values )) { |
|
| 37 | + return; |
|
| 38 | + } |
|
| 37 | 39 | return glsr( Template::class )->build( 'templates/review', [ |
| 38 | 40 | 'context' => $this->values, |
| 39 | 41 | ]); |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | $this->args = $args; |
| 30 | 30 | $this->max_num_pages = $maxPageCount; |
| 31 | 31 | $this->results = $reviews; |
| 32 | - parent::__construct( $reviews, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
| 32 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function build( array $args = [] ) |
| 70 | 70 | { |
| 71 | - if( empty( $this->ID )) { |
|
| 71 | + if( empty($this->ID) ) { |
|
| 72 | 72 | return new ReviewHtml; |
| 73 | 73 | } |
| 74 | 74 | $partial = glsr( SiteReviewsPartial::class ); |
@@ -92,10 +92,10 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function offsetGet( $key ) |
| 94 | 94 | { |
| 95 | - if( property_exists( $this, $key )) { |
|
| 95 | + if( property_exists( $this, $key ) ) { |
|
| 96 | 96 | return $this->$key; |
| 97 | 97 | } |
| 98 | - if( array_key_exists( $key, (array)$this->custom )) { |
|
| 98 | + if( array_key_exists( $key, (array)$this->custom ) ) { |
|
| 99 | 99 | return $this->custom[$key]; |
| 100 | 100 | } |
| 101 | 101 | return null; |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function offsetSet( $key, $value ) |
| 110 | 110 | { |
| 111 | - if( property_exists( $this, $key )) { |
|
| 111 | + if( property_exists( $this, $key ) ) { |
|
| 112 | 112 | $this->$key = $value; |
| 113 | 113 | return; |
| 114 | 114 | } |
| 115 | - if( !is_array( $this->custom )) { |
|
| 115 | + if( !is_array( $this->custom ) ) { |
|
| 116 | 116 | $this->custom = array_filter( (array)$this->custom ); |
| 117 | 117 | } |
| 118 | 118 | $this->custom[$key] = $value; |
@@ -157,13 +157,13 @@ discard block |
||
| 157 | 157 | 'review_type' => 'local', |
| 158 | 158 | ]; |
| 159 | 159 | $meta = array_filter( |
| 160 | - array_map( 'array_shift', array_filter((array)get_post_meta( $post->ID ))), |
|
| 160 | + array_map( 'array_shift', array_filter( (array)get_post_meta( $post->ID ) ) ), |
|
| 161 | 161 | 'strlen' |
| 162 | 162 | ); |
| 163 | - $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
|
| 163 | + $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) ); |
|
| 164 | 164 | $this->modified = $this->isModified( $properties ); |
| 165 | 165 | array_walk( $properties, function( $value, $key ) { |
| 166 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
| 166 | + if( !property_exists( $this, $key ) || isset($this->$key) )return; |
|
| 167 | 167 | $this->$key = maybe_unserialize( $value ); |
| 168 | 168 | }); |
| 169 | 169 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | protected function setTermIds( WP_Post $post ) |
| 175 | 175 | { |
| 176 | 176 | $this->term_ids = []; |
| 177 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
| 177 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) )return; |
|
| 178 | 178 | foreach( $terms as $term ) { |
| 179 | 179 | $this->term_ids[] = $term->term_id; |
| 180 | 180 | } |
@@ -36,7 +36,9 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public function __construct( WP_Post $post ) |
| 38 | 38 | { |
| 39 | - if( $post->post_type != Application::POST_TYPE )return; |
|
| 39 | + if( $post->post_type != Application::POST_TYPE ) { |
|
| 40 | + return; |
|
| 41 | + } |
|
| 40 | 42 | $this->content = $post->post_content; |
| 41 | 43 | $this->date = $post->post_date; |
| 42 | 44 | $this->ID = intval( $post->ID ); |
@@ -163,7 +165,9 @@ discard block |
||
| 163 | 165 | $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
| 164 | 166 | $this->modified = $this->isModified( $properties ); |
| 165 | 167 | array_walk( $properties, function( $value, $key ) { |
| 166 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
| 168 | + if( !property_exists( $this, $key ) || isset( $this->$key )) { |
|
| 169 | + return; |
|
| 170 | + } |
|
| 167 | 171 | $this->$key = maybe_unserialize( $value ); |
| 168 | 172 | }); |
| 169 | 173 | } |
@@ -174,7 +178,9 @@ discard block |
||
| 174 | 178 | protected function setTermIds( WP_Post $post ) |
| 175 | 179 | { |
| 176 | 180 | $this->term_ids = []; |
| 177 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
| 181 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ))) { |
|
| 182 | + return; |
|
| 183 | + } |
|
| 178 | 184 | foreach( $terms as $term ) { |
| 179 | 185 | $this->term_ids[] = $term->term_id; |
| 180 | 186 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function routerChangeStatus( array $request ) |
| 24 | 24 | { |
| 25 | - wp_send_json_success( $this->execute( new ChangeStatus( $request ))); |
|
| 25 | + wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) ); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | public function routerClearConsole() |
| 32 | 32 | { |
| 33 | 33 | glsr( AdminController::class )->routerClearConsole(); |
| 34 | - wp_send_json_success([ |
|
| 34 | + wp_send_json_success( [ |
|
| 35 | 35 | 'console' => glsr( Console::class )->get(), |
| 36 | 36 | 'notices' => glsr( Notice::class )->get(), |
| 37 | - ]); |
|
| 37 | + ] ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | public function routerCountReviews() |
| 44 | 44 | { |
| 45 | 45 | glsr( AdminController::class )->routerCountReviews(); |
| 46 | - wp_send_json_success([ |
|
| 46 | + wp_send_json_success( [ |
|
| 47 | 47 | 'notices' => glsr( Notice::class )->get(), |
| 48 | - ]); |
|
| 48 | + ] ); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $shortcode = $request['shortcode']; |
| 57 | 57 | $response = false; |
| 58 | - if( array_key_exists( $shortcode, glsr()->mceShortcodes )) { |
|
| 58 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
| 59 | 59 | $data = glsr()->mceShortcodes[$shortcode]; |
| 60 | - if( !empty( $data['errors'] )) { |
|
| 60 | + if( !empty($data['errors']) ) { |
|
| 61 | 61 | $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
| 62 | 62 | } |
| 63 | 63 | $response = [ |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | public function routerFetchConsole() |
| 78 | 78 | { |
| 79 | 79 | glsr( AdminController::class )->routerFetchConsole(); |
| 80 | - wp_send_json_success([ |
|
| 80 | + wp_send_json_success( [ |
|
| 81 | 81 | 'console' => glsr( Console::class )->get(), |
| 82 | 82 | 'notices' => glsr( Notice::class )->get(), |
| 83 | - ]); |
|
| 83 | + ] ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | public function routerSearchPosts( array $request ) |
| 90 | 90 | { |
| 91 | 91 | $results = glsr( Database::class )->searchPosts( $request['search'] ); |
| 92 | - wp_send_json_success([ |
|
| 92 | + wp_send_json_success( [ |
|
| 93 | 93 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
| 94 | 94 | 'items' => $results, |
| 95 | - ]); |
|
| 95 | + ] ); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function routerSearchTranslations( array $request ) |
| 102 | 102 | { |
| 103 | - if( empty( $request['exclude'] )) { |
|
| 103 | + if( empty($request['exclude']) ) { |
|
| 104 | 104 | $request['exclude'] = []; |
| 105 | 105 | } |
| 106 | 106 | $results = glsr( Translation::class ) |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | ->exclude() |
| 109 | 109 | ->exclude( $request['exclude'] ) |
| 110 | 110 | ->renderResults(); |
| 111 | - wp_send_json_success([ |
|
| 111 | + wp_send_json_success( [ |
|
| 112 | 112 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
| 113 | 113 | 'items' => $results, |
| 114 | - ]); |
|
| 114 | + ] ); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | public function routerSubmitReview( array $request ) |
| 121 | 121 | { |
| 122 | 122 | $command = glsr( PublicController::class )->routerSubmitReview( $request ); |
| 123 | - $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ))); |
|
| 123 | + $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) ); |
|
| 124 | 124 | $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command ); |
| 125 | 125 | $data = [ |
| 126 | 126 | 'errors' => glsr( Session::class )->get( $command->form_id.'errors', false, true ), |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function routerTogglePinned( array $request ) |
| 142 | 142 | { |
| 143 | - $isPinned = $this->execute( new TogglePinned( $request )); |
|
| 144 | - wp_send_json_success([ |
|
| 143 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
| 144 | + wp_send_json_success( [ |
|
| 145 | 145 | 'notices' => glsr( Notice::class )->get(), |
| 146 | 146 | 'pinned' => $isPinned, |
| 147 | - ]); |
|
| 147 | + ] ); |
|
| 148 | 148 | } |
| 149 | 149 | } |
@@ -33,10 +33,10 @@ discard block |
||
| 33 | 33 | public function filterEnqueuedScripts( $tag, $handle ) |
| 34 | 34 | { |
| 35 | 35 | $scripts = [Application::ID.'/google-recaptcha']; |
| 36 | - if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ))) { |
|
| 36 | + if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ) ) ) { |
|
| 37 | 37 | $tag = str_replace( ' src=', ' async src=', $tag ); |
| 38 | 38 | } |
| 39 | - if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ))) { |
|
| 39 | + if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ) ) ) { |
|
| 40 | 40 | $tag = str_replace( ' src=', ' defer src=', $tag ); |
| 41 | 41 | } |
| 42 | 42 | return $tag; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function filterFieldOrder( array $config ) |
| 51 | 51 | { |
| 52 | - $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config )); |
|
| 52 | + $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config ) ); |
|
| 53 | 53 | return array_intersect_key( array_merge( array_flip( $order ), $config ), $config ); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | { |
| 101 | 101 | $validated = glsr( ValidateReview::class )->validate( $request ); |
| 102 | 102 | $command = new CreateReview( $validated->request ); |
| 103 | - if( empty( $validated->error ) && !$validated->recaptchaIsUnset ) { |
|
| 103 | + if( empty($validated->error) && !$validated->recaptchaIsUnset ) { |
|
| 104 | 104 | $this->execute( $command ); |
| 105 | 105 | } |
| 106 | 106 | return $command; |
@@ -21,7 +21,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 ) { |
@@ -100,7 +104,8 @@ discard block |
||
| 100 | 104 | * @return array |
| 101 | 105 | * @filter display_post_states |
| 102 | 106 | */ |
| 103 | - public function filterPostStates( $postStates, WP_Post $post ) { |
|
| 107 | + public function filterPostStates( $postStates, WP_Post $post ) |
|
| 108 | + { |
|
| 104 | 109 | $postStates = glsr( Helper::class )->consolidateArray( $postStates ); |
| 105 | 110 | if( $post->post_type == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) { |
| 106 | 111 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
@@ -148,7 +153,9 @@ discard block |
||
| 148 | 153 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 149 | 154 | unset( $postTypeColumns['cb'] ); |
| 150 | 155 | foreach( $postTypeColumns as $key => $value ) { |
| 151 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
| 156 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key )) { |
|
| 157 | + continue; |
|
| 158 | + } |
|
| 152 | 159 | $columns[$key] = $key; |
| 153 | 160 | } |
| 154 | 161 | return $columns; |
@@ -172,7 +179,9 @@ discard block |
||
| 172 | 179 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
| 173 | 180 | ]; |
| 174 | 181 | foreach( $strings as $search => $replace ) { |
| 175 | - if( strpos( $single, $search ) === false )continue; |
|
| 182 | + if( strpos( $single, $search ) === false ) { |
|
| 183 | + continue; |
|
| 184 | + } |
|
| 176 | 185 | $translation = $this->getTranslation([ |
| 177 | 186 | 'number' => $number, |
| 178 | 187 | 'plural' => str_replace( $search, $replace, $plural ), |
@@ -224,7 +233,9 @@ discard block |
||
| 224 | 233 | */ |
| 225 | 234 | public function saveBulkEditFields( $postId ) |
| 226 | 235 | { |
| 227 | - if( !current_user_can( 'edit_posts' ))return; |
|
| 236 | + if( !current_user_can( 'edit_posts' )) { |
|
| 237 | + return; |
|
| 238 | + } |
|
| 228 | 239 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
| 229 | 240 | if( $assignedTo && get_post( $assignedTo )) { |
| 230 | 241 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
@@ -237,7 +248,9 @@ discard block |
||
| 237 | 248 | */ |
| 238 | 249 | public function setQueryForColumn( WP_Query $query ) |
| 239 | 250 | { |
| 240 | - if( !$this->hasPermission( $query ))return; |
|
| 251 | + if( !$this->hasPermission( $query )) { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 241 | 254 | $this->setMetaQuery( $query, [ |
| 242 | 255 | 'rating', 'review_type', |
| 243 | 256 | ]); |
@@ -250,7 +263,9 @@ discard block |
||
| 250 | 263 | */ |
| 251 | 264 | public function unapprove() |
| 252 | 265 | { |
| 253 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
| 266 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
| 267 | + return; |
|
| 268 | + } |
|
| 254 | 269 | check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
| 255 | 270 | wp_update_post([ |
| 256 | 271 | 'ID' => $postId, |
@@ -310,7 +325,9 @@ discard block |
||
| 310 | 325 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
| 311 | 326 | { |
| 312 | 327 | foreach( $metaKeys as $key ) { |
| 313 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
| 328 | + if( !( $value = filter_input( INPUT_GET, $key ))) { |
|
| 329 | + continue; |
|
| 330 | + } |
|
| 314 | 331 | $metaQuery = (array)$query->get( 'meta_query' ); |
| 315 | 332 | $metaQuery[] = [ |
| 316 | 333 | 'key' => $key, |
@@ -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 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function filterPostStates( $postStates, WP_Post $post ) { |
| 104 | 104 | $postStates = glsr( Helper::class )->consolidateArray( $postStates ); |
| 105 | - if( $post->post_type == Application::POST_TYPE && array_key_exists( 'pending', $postStates )) { |
|
| 105 | + if( $post->post_type == Application::POST_TYPE && array_key_exists( 'pending', $postStates ) ) { |
|
| 106 | 106 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
| 107 | 107 | } |
| 108 | 108 | return $postStates; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | if( $post->post_type != Application::POST_TYPE || $post->post_status == 'trash' ) { |
| 119 | 119 | return $actions; |
| 120 | 120 | } |
| 121 | - unset( $actions['inline hide-if-no-js'] ); //Remove Quick-edit |
|
| 121 | + unset($actions['inline hide-if-no-js']); //Remove Quick-edit |
|
| 122 | 122 | $rowActions = [ |
| 123 | 123 | 'approve' => esc_attr__( 'Approve', 'site-reviews' ), |
| 124 | 124 | 'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ), |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | admin_url( 'post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID ), |
| 133 | 133 | $key.'-review_'.$post->ID |
| 134 | 134 | ), |
| 135 | - ]); |
|
| 135 | + ] ); |
|
| 136 | 136 | } |
| 137 | 137 | return $newActions + glsr( Helper::class )->consolidateArray( $actions ); |
| 138 | 138 | } |
@@ -146,9 +146,9 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $columns = glsr( Helper::class )->consolidateArray( $columns ); |
| 148 | 148 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 149 | - unset( $postTypeColumns['cb'] ); |
|
| 149 | + unset($postTypeColumns['cb']); |
|
| 150 | 150 | foreach( $postTypeColumns as $key => $value ) { |
| 151 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
| 151 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key ) )continue; |
|
| 152 | 152 | $columns[$key] = $key; |
| 153 | 153 | } |
| 154 | 154 | return $columns; |
@@ -166,18 +166,18 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public function filterStatusText( $translation, $single, $plural, $number, $domain ) |
| 168 | 168 | { |
| 169 | - if( $this->canModifyTranslation( $domain )) { |
|
| 169 | + if( $this->canModifyTranslation( $domain ) ) { |
|
| 170 | 170 | $strings = [ |
| 171 | 171 | 'Published' => __( 'Approved', 'site-reviews' ), |
| 172 | 172 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
| 173 | 173 | ]; |
| 174 | 174 | foreach( $strings as $search => $replace ) { |
| 175 | 175 | if( strpos( $single, $search ) === false )continue; |
| 176 | - $translation = $this->getTranslation([ |
|
| 176 | + $translation = $this->getTranslation( [ |
|
| 177 | 177 | 'number' => $number, |
| 178 | 178 | 'plural' => str_replace( $search, $replace, $plural ), |
| 179 | 179 | 'single' => str_replace( $search, $replace, $single ), |
| 180 | - ]); |
|
| 180 | + ] ); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | return $translation; |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | */ |
| 225 | 225 | public function saveBulkEditFields( $postId ) |
| 226 | 226 | { |
| 227 | - if( !current_user_can( 'edit_posts' ))return; |
|
| 227 | + if( !current_user_can( 'edit_posts' ) )return; |
|
| 228 | 228 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
| 229 | - if( $assignedTo && get_post( $assignedTo )) { |
|
| 229 | + if( $assignedTo && get_post( $assignedTo ) ) { |
|
| 230 | 230 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
| 231 | 231 | } |
| 232 | 232 | } |
@@ -237,10 +237,10 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | public function setQueryForColumn( WP_Query $query ) |
| 239 | 239 | { |
| 240 | - if( !$this->hasPermission( $query ))return; |
|
| 240 | + if( !$this->hasPermission( $query ) )return; |
|
| 241 | 241 | $this->setMetaQuery( $query, [ |
| 242 | 242 | 'rating', 'review_type', |
| 243 | - ]); |
|
| 243 | + ] ); |
|
| 244 | 244 | $this->setOrderby( $query ); |
| 245 | 245 | } |
| 246 | 246 | |
@@ -251,11 +251,11 @@ discard block |
||
| 251 | 251 | public function unapprove() |
| 252 | 252 | { |
| 253 | 253 | if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
| 254 | - check_admin_referer( 'unapprove-review_'.( $postId = $this->getPostId() )); |
|
| 255 | - wp_update_post([ |
|
| 254 | + check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) ); |
|
| 255 | + wp_update_post( [ |
|
| 256 | 256 | 'ID' => $postId, |
| 257 | 257 | 'post_status' => 'pending', |
| 258 | - ]); |
|
| 258 | + ] ); |
|
| 259 | 259 | wp_safe_redirect( wp_get_referer() ); |
| 260 | 260 | exit; |
| 261 | 261 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | 'single' => '', |
| 286 | 286 | 'text' => '', |
| 287 | 287 | ]; |
| 288 | - $args = (object) wp_parse_args( $args, $defaults ); |
|
| 288 | + $args = (object)wp_parse_args( $args, $defaults ); |
|
| 289 | 289 | $translations = get_translations_for_domain( Application::ID ); |
| 290 | 290 | return $args->text |
| 291 | 291 | ? $translations->translate( $args->text ) |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
| 311 | 311 | { |
| 312 | 312 | foreach( $metaKeys as $key ) { |
| 313 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
| 313 | + if( !($value = filter_input( INPUT_GET, $key )) )continue; |
|
| 314 | 314 | $metaQuery = (array)$query->get( 'meta_query' ); |
| 315 | 315 | $metaQuery[] = [ |
| 316 | 316 | 'key' => $key, |
@@ -327,8 +327,8 @@ discard block |
||
| 327 | 327 | { |
| 328 | 328 | $orderby = $query->get( 'orderby' ); |
| 329 | 329 | $columns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 330 | - unset( $columns['cb'], $columns['title'], $columns['date'] ); |
|
| 331 | - if( in_array( $orderby, array_keys( $columns ))) { |
|
| 330 | + unset($columns['cb'], $columns['title'], $columns['date']); |
|
| 331 | + if( in_array( $orderby, array_keys( $columns ) ) ) { |
|
| 332 | 332 | if( $orderby == 'reviewer' ) { |
| 333 | 333 | $orderby = 'author'; |
| 334 | 334 | } |
@@ -97,7 +97,9 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
| 99 | 99 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
| 100 | - if( get_post_meta( $post->ID, 'review_type', true ) != 'local' )return; |
|
| 100 | + if( get_post_meta( $post->ID, 'review_type', true ) != 'local' ) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 101 | 103 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
| 102 | 104 | } |
| 103 | 105 | |
@@ -133,7 +135,9 @@ discard block |
||
| 133 | 135 | */ |
| 134 | 136 | public function renderAssignedToMetabox( WP_Post $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', [ |
@@ -148,7 +152,9 @@ discard block |
||
| 148 | 152 | */ |
| 149 | 153 | public function renderDetailsMetaBox( WP_Post $post ) |
| 150 | 154 | { |
| 151 | - if( !$this->isReviewPostType( $post ))return; |
|
| 155 | + if( !$this->isReviewPostType( $post )) { |
|
| 156 | + return; |
|
| 157 | + } |
|
| 152 | 158 | $review = glsr( ReviewManager::class )->single( $post ); |
| 153 | 159 | glsr()->render( 'partials/editor/metabox-details', [ |
| 154 | 160 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
@@ -162,7 +168,9 @@ discard block |
||
| 162 | 168 | */ |
| 163 | 169 | public function renderPinnedInPublishMetaBox() |
| 164 | 170 | { |
| 165 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 171 | + if( !$this->isReviewPostType( get_post() )) { |
|
| 172 | + return; |
|
| 173 | + } |
|
| 166 | 174 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
| 167 | 175 | 'context' => [ |
| 168 | 176 | 'no' => __( 'No', 'site-reviews' ), |
@@ -178,7 +186,9 @@ discard block |
||
| 178 | 186 | */ |
| 179 | 187 | public function renderResponseMetaBox( WP_Post $post ) |
| 180 | 188 | { |
| 181 | - if( !$this->isReviewPostType( $post ))return; |
|
| 189 | + if( !$this->isReviewPostType( $post )) { |
|
| 190 | + return; |
|
| 191 | + } |
|
| 182 | 192 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 183 | 193 | glsr()->render( 'partials/editor/metabox-response', [ |
| 184 | 194 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -191,7 +201,9 @@ discard block |
||
| 191 | 201 | */ |
| 192 | 202 | public function renderReviewEditor( WP_Post $post ) |
| 193 | 203 | { |
| 194 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 204 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 205 | + return; |
|
| 206 | + } |
|
| 195 | 207 | glsr()->render( 'partials/editor/review', [ |
| 196 | 208 | 'post' => $post, |
| 197 | 209 | 'response' => get_post_meta( $post->ID, 'response', true ), |
@@ -205,7 +217,9 @@ discard block |
||
| 205 | 217 | public function renderReviewFields() |
| 206 | 218 | { |
| 207 | 219 | $screen = glsr_current_screen(); |
| 208 | - if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
|
| 220 | + if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE ) { |
|
| 221 | + return; |
|
| 222 | + } |
|
| 209 | 223 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
| 210 | 224 | add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
| 211 | 225 | } |
@@ -216,7 +230,9 @@ discard block |
||
| 216 | 230 | */ |
| 217 | 231 | public function renderReviewNotice( WP_Post $post ) |
| 218 | 232 | { |
| 219 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 233 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 234 | + return; |
|
| 235 | + } |
|
| 220 | 236 | glsr( Notice::class )->addWarning( sprintf( |
| 221 | 237 | __( '%s reviews are read-only.', 'site-reviews' ), |
| 222 | 238 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
@@ -235,7 +251,9 @@ discard block |
||
| 235 | 251 | */ |
| 236 | 252 | public function renderTaxonomyMetabox( WP_Post $post ) |
| 237 | 253 | { |
| 238 | - if( !$this->isReviewPostType( $post ))return; |
|
| 254 | + if( !$this->isReviewPostType( $post )) { |
|
| 255 | + return; |
|
| 256 | + } |
|
| 239 | 257 | glsr()->render( 'partials/editor/metabox-categories', [ |
| 240 | 258 | 'post' => $post, |
| 241 | 259 | 'tax_name' => Application::TAXONOMY, |
@@ -250,7 +268,9 @@ discard block |
||
| 250 | 268 | */ |
| 251 | 269 | public function revertReview() |
| 252 | 270 | { |
| 253 | - if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
|
| 271 | + if( filter_input( INPUT_GET, 'plugin' ) != Application::ID ) { |
|
| 272 | + return; |
|
| 273 | + } |
|
| 254 | 274 | check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
| 255 | 275 | glsr( ReviewManager::class )->revert( $postId ); |
| 256 | 276 | $this->redirect( $postId, 52 ); |
@@ -274,7 +294,9 @@ discard block |
||
| 274 | 294 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
| 275 | 295 | { |
| 276 | 296 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
| 277 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
| 297 | + if( !( $assignedPost instanceof WP_Post )) { |
|
| 298 | + return; |
|
| 299 | + } |
|
| 278 | 300 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
| 279 | 301 | 'context' => [ |
| 280 | 302 | 'data.url' => (string)get_permalink( $assignedPost ), |
@@ -320,7 +342,9 @@ discard block |
||
| 320 | 342 | */ |
| 321 | 343 | protected function getReviewType( $review ) |
| 322 | 344 | { |
| 323 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
| 345 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
| 346 | + return; |
|
| 347 | + } |
|
| 324 | 348 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
| 325 | 349 | ? glsr()->reviewTypes[$review->review_type] |
| 326 | 350 | : __( 'Unknown', 'site-reviews' ); |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | public function renderAssignedToMetabox( WP_Post $post ) |
| 134 | 134 | { |
| 135 | - if( !$this->isReviewPostType( $post ))return; |
|
| 135 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 136 | 136 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
| 137 | 137 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
| 138 | 138 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
| 139 | 139 | 'id' => $assignedTo, |
| 140 | 140 | 'template' => $this->buildAssignedToTemplate( $assignedTo, $post ), |
| 141 | - ]); |
|
| 141 | + ] ); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -147,12 +147,12 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function renderDetailsMetaBox( WP_Post $post ) |
| 149 | 149 | { |
| 150 | - if( !$this->isReviewPostType( $post ))return; |
|
| 150 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 151 | 151 | $review = glsr( ReviewManager::class )->single( $post ); |
| 152 | 152 | glsr()->render( 'partials/editor/metabox-details', [ |
| 153 | 153 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
| 154 | 154 | 'metabox' => $this->normalizeDetailsMetaBox( $review ), |
| 155 | - ]); |
|
| 155 | + ] ); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -161,14 +161,14 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function renderPinnedInPublishMetaBox() |
| 163 | 163 | { |
| 164 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 164 | + if( !$this->isReviewPostType( get_post() ) )return; |
|
| 165 | 165 | glsr( Template::class )->render( 'partials/editor/pinned', [ |
| 166 | 166 | 'context' => [ |
| 167 | 167 | 'no' => __( 'No', 'site-reviews' ), |
| 168 | 168 | 'yes' => __( 'Yes', 'site-reviews' ), |
| 169 | 169 | ], |
| 170 | - 'pinned' => wp_validate_boolean( get_post_meta( intval( get_the_ID() ), 'pinned', true )), |
|
| 171 | - ]); |
|
| 170 | + 'pinned' => wp_validate_boolean( get_post_meta( intval( get_the_ID() ), 'pinned', true ) ), |
|
| 171 | + ] ); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -177,11 +177,11 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | public function renderResponseMetaBox( WP_Post $post ) |
| 179 | 179 | { |
| 180 | - if( !$this->isReviewPostType( $post ))return; |
|
| 180 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 181 | 181 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 182 | 182 | glsr()->render( 'partials/editor/metabox-response', [ |
| 183 | 183 | 'response' => get_post_meta( $post->ID, 'response', true ), |
| 184 | - ]); |
|
| 184 | + ] ); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -190,11 +190,11 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public function renderReviewEditor( WP_Post $post ) |
| 192 | 192 | { |
| 193 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 193 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
| 194 | 194 | glsr()->render( 'partials/editor/review', [ |
| 195 | 195 | 'post' => $post, |
| 196 | 196 | 'response' => get_post_meta( $post->ID, 'response', true ), |
| 197 | - ]); |
|
| 197 | + ] ); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | $screen = glsr_current_screen(); |
| 207 | 207 | if( $screen->base != 'post' || $screen->post_type != Application::POST_TYPE )return; |
| 208 | 208 | add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] ); |
| 209 | - add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
| 209 | + add_action( 'edit_form_top', [$this, 'renderReviewNotice'] ); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -215,16 +215,16 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | public function renderReviewNotice( WP_Post $post ) |
| 217 | 217 | { |
| 218 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 218 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
| 219 | 219 | glsr( Notice::class )->addWarning( sprintf( |
| 220 | 220 | __( '%s reviews are read-only.', 'site-reviews' ), |
| 221 | 221 | glsr( Columns::class )->buildColumnReviewType( $post->ID ) |
| 222 | - )); |
|
| 222 | + ) ); |
|
| 223 | 223 | glsr( Template::class )->render( 'partials/editor/notice', [ |
| 224 | 224 | 'context' => [ |
| 225 | 225 | 'notices' => glsr( Notice::class )->get(), |
| 226 | 226 | ], |
| 227 | - ]); |
|
| 227 | + ] ); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -234,12 +234,12 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | public function renderTaxonomyMetabox( WP_Post $post ) |
| 236 | 236 | { |
| 237 | - if( !$this->isReviewPostType( $post ))return; |
|
| 237 | + if( !$this->isReviewPostType( $post ) )return; |
|
| 238 | 238 | glsr()->render( 'partials/editor/metabox-categories', [ |
| 239 | 239 | 'post' => $post, |
| 240 | 240 | 'tax_name' => Application::TAXONOMY, |
| 241 | 241 | 'taxonomy' => get_taxonomy( Application::TAXONOMY ), |
| 242 | - ]); |
|
| 242 | + ] ); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | public function revertReview() |
| 251 | 251 | { |
| 252 | 252 | if( filter_input( INPUT_GET, 'plugin' ) != Application::ID )return; |
| 253 | - check_admin_referer( 'revert-review_'.( $postId = $this->getPostId() )); |
|
| 253 | + check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) ); |
|
| 254 | 254 | glsr( ReviewManager::class )->revert( $postId ); |
| 255 | 255 | $this->redirect( $postId, 52 ); |
| 256 | 256 | } |
@@ -273,13 +273,13 @@ discard block |
||
| 273 | 273 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
| 274 | 274 | { |
| 275 | 275 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo ); |
| 276 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
| 276 | + if( !($assignedPost instanceof WP_Post) )return; |
|
| 277 | 277 | return glsr( Template::class )->build( 'partials/editor/assigned-post', [ |
| 278 | 278 | 'context' => [ |
| 279 | 279 | 'data.url' => (string)get_permalink( $assignedPost ), |
| 280 | 280 | 'data.title' => get_the_title( $assignedPost ), |
| 281 | 281 | ], |
| 282 | - ]); |
|
| 282 | + ] ); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -304,13 +304,13 @@ discard block |
||
| 304 | 304 | 'class' => 'button button-large', |
| 305 | 305 | 'href' => $revertUrl, |
| 306 | 306 | 'id' => 'revert', |
| 307 | - ]); |
|
| 307 | + ] ); |
|
| 308 | 308 | } |
| 309 | 309 | return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [ |
| 310 | 310 | 'class' => 'button button-large', |
| 311 | 311 | 'disabled' => true, |
| 312 | 312 | 'id' => 'revert', |
| 313 | - ]); |
|
| 313 | + ] ); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -323,11 +323,11 @@ discard block |
||
| 323 | 323 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
| 324 | 324 | ? glsr()->reviewTypes[$review->review_type] |
| 325 | 325 | : __( 'Unknown', 'site-reviews' ); |
| 326 | - if( !empty( $review->url )) { |
|
| 326 | + if( !empty($review->url) ) { |
|
| 327 | 327 | $reviewType = glsr( Builder::class )->a( $reviewType, [ |
| 328 | 328 | 'href' => $review->url, |
| 329 | 329 | 'target' => '_blank', |
| 330 | - ]); |
|
| 330 | + ] ); |
|
| 331 | 331 | } |
| 332 | 332 | return $reviewType; |
| 333 | 333 | } |
@@ -356,16 +356,16 @@ discard block |
||
| 356 | 356 | */ |
| 357 | 357 | protected function normalizeDetailsMetaBox( Review $review ) |
| 358 | 358 | { |
| 359 | - $user = empty( $review->user_id ) |
|
| 359 | + $user = empty($review->user_id) |
|
| 360 | 360 | ? __( 'Unregistered user', 'site-reviews' ) |
| 361 | 361 | : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [ |
| 362 | 362 | 'href' => get_author_posts_url( $review->user_id ), |
| 363 | - ]); |
|
| 364 | - $email = empty( $review->email ) |
|
| 363 | + ] ); |
|
| 364 | + $email = empty($review->email) |
|
| 365 | 365 | ? '—' |
| 366 | 366 | : glsr( Builder::class )->a( $review->email, [ |
| 367 | 367 | 'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ), |
| 368 | - ]); |
|
| 368 | + ] ); |
|
| 369 | 369 | $metabox = [ |
| 370 | 370 | __( 'Rating', 'site-reviews' ) => glsr_star_rating( $review->rating ), |
| 371 | 371 | __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ), |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | __( 'IP Address', 'site-reviews' ) => $review->ip_address, |
| 377 | 377 | __( 'Avatar', 'site-reviews' ) => sprintf( '<img src="%s" width="96">', $review->avatar ), |
| 378 | 378 | ]; |
| 379 | - return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review )); |
|
| 379 | + return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review ) ); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | /** |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | $redirectUri = $hasReferer |
| 394 | 394 | ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer ) |
| 395 | 395 | : get_edit_post_link( $postId ); |
| 396 | - wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri )); |
|
| 396 | + wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) ); |
|
| 397 | 397 | exit; |
| 398 | 398 | } |
| 399 | 399 | } |