@@ -36,7 +36,9 @@ discard block |
||
| 36 | 36 | [], |
| 37 | 37 | glsr()->version |
| 38 | 38 | ); |
| 39 | - if( !$this->isCurrentScreen() )return; |
|
| 39 | + if( !$this->isCurrentScreen() ) { |
|
| 40 | + return; |
|
| 41 | + } |
|
| 40 | 42 | wp_enqueue_script( |
| 41 | 43 | Application::ID, |
| 42 | 44 | glsr()->url( 'assets/scripts/'.Application::ID.'-admin.js' ), |
@@ -113,8 +115,12 @@ discard block |
||
| 113 | 115 | $dismissedPointers = explode( ',', (string)$dismissedPointers ); |
| 114 | 116 | $generatedPointers = []; |
| 115 | 117 | foreach( $pointers as $pointer ) { |
| 116 | - if( $pointer['screen'] != glsr_current_screen()->id )continue; |
|
| 117 | - if( in_array( $pointer['id'], $dismissedPointers ))continue; |
|
| 118 | + if( $pointer['screen'] != glsr_current_screen()->id ) { |
|
| 119 | + continue; |
|
| 120 | + } |
|
| 121 | + if( in_array( $pointer['id'], $dismissedPointers )) { |
|
| 122 | + continue; |
|
| 123 | + } |
|
| 118 | 124 | $generatedPointers[] = $this->generatePointer( $pointer ); |
| 119 | 125 | } |
| 120 | 126 | $this->pointers = $generatedPointers; |
@@ -140,7 +146,9 @@ discard block |
||
| 140 | 146 | { |
| 141 | 147 | $variables = []; |
| 142 | 148 | foreach( glsr()->mceShortcodes as $tag => $args ) { |
| 143 | - if( empty( $args['required'] ))continue; |
|
| 149 | + if( empty( $args['required'] )) { |
|
| 150 | + continue; |
|
| 151 | + } |
|
| 144 | 152 | $variables[$tag] = $args['required']; |
| 145 | 153 | } |
| 146 | 154 | return $variables; |
@@ -91,7 +91,9 @@ discard block |
||
| 91 | 91 | get_mu_plugins(), |
| 92 | 92 | get_plugins( '/../'.basename( WPMU_PLUGIN_DIR )) |
| 93 | 93 | ); |
| 94 | - if( empty( $plugins ))return; |
|
| 94 | + if( empty( $plugins )) { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 95 | 97 | return $this->normalizePluginList( $plugins ); |
| 96 | 98 | } |
| 97 | 99 | |
@@ -100,7 +102,9 @@ discard block |
||
| 100 | 102 | */ |
| 101 | 103 | public function getMultisitePluginDetails() |
| 102 | 104 | { |
| 103 | - if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return; |
|
| 105 | + if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] ))) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 104 | 108 | return $this->normalizePluginList( wp_get_active_network_plugins() ); |
| 105 | 109 | } |
| 106 | 110 | |
@@ -154,12 +158,16 @@ discard block |
||
| 154 | 158 | $settings = glsr( OptionManager::class )->get( 'settings', [] ); |
| 155 | 159 | $settings = $helper->flattenArray( $settings, true ); |
| 156 | 160 | foreach( ['submissions.recaptcha.key', 'submissions.recaptcha.secret'] as $key ) { |
| 157 | - if( empty( $settings[$key] ))continue; |
|
| 161 | + if( empty( $settings[$key] )) { |
|
| 162 | + continue; |
|
| 163 | + } |
|
| 158 | 164 | $settings[$key] = str_repeat( '*', 10 ); |
| 159 | 165 | } |
| 160 | 166 | $details = []; |
| 161 | 167 | foreach( $settings as $key => $value ) { |
| 162 | - if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
| 168 | + if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key )) { |
|
| 169 | + continue; |
|
| 170 | + } |
|
| 163 | 171 | $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
| 164 | 172 | $details[$key] = $value; |
| 165 | 173 | } |
@@ -231,7 +239,9 @@ discard block |
||
| 231 | 239 | 'WPE_APIKEY' => 'WP Engine', |
| 232 | 240 | ]; |
| 233 | 241 | foreach( $checks as $key => $value ) { |
| 234 | - if( !$this->isWebhostCheckValid( $key ))continue; |
|
| 242 | + if( !$this->isWebhostCheckValid( $key )) { |
|
| 243 | + continue; |
|
| 244 | + } |
|
| 235 | 245 | return $value; |
| 236 | 246 | } |
| 237 | 247 | return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] )); |
@@ -15,9 +15,13 @@ |
||
| 15 | 15 | ]; |
| 16 | 16 | foreach( $namespaces as $prefix => $baseDir ) { |
| 17 | 17 | $len = strlen( $prefix ); |
| 18 | - if( strncmp( $prefix, $className, $len ) !== 0 )continue; |
|
| 18 | + if( strncmp( $prefix, $className, $len ) !== 0 ) { |
|
| 19 | + continue; |
|
| 20 | + } |
|
| 19 | 21 | $file = $baseDir.str_replace( '\\', '/', substr( $className, $len )).'.php'; |
| 20 | - if( !file_exists( $file ))continue; |
|
| 22 | + if( !file_exists( $file )) { |
|
| 23 | + continue; |
|
| 24 | + } |
|
| 21 | 25 | require $file; |
| 22 | 26 | break; |
| 23 | 27 | } |
@@ -4,7 +4,8 @@ discard block |
||
| 4 | 4 | /** |
| 5 | 5 | * @return mixed |
| 6 | 6 | */ |
| 7 | -function glsr( $alias = null ) { |
|
| 7 | +function glsr( $alias = null ) |
|
| 8 | +{ |
|
| 8 | 9 | $app = \GeminiLabs\SiteReviews\Application::load(); |
| 9 | 10 | return !empty( $alias ) |
| 10 | 11 | ? $app->make( $alias ) |
@@ -14,7 +15,8 @@ discard block |
||
| 14 | 15 | /** |
| 15 | 16 | * @return \WP_Screen|object |
| 16 | 17 | */ |
| 17 | -function glsr_current_screen() { |
|
| 18 | +function glsr_current_screen() |
|
| 19 | +{ |
|
| 18 | 20 | if( function_exists( 'get_current_screen' )) { |
| 19 | 21 | $screen = get_current_screen(); |
| 20 | 22 | } |
@@ -26,7 +28,8 @@ discard block |
||
| 26 | 28 | /** |
| 27 | 29 | * @return \GeminiLabs\SiteReviews\Database |
| 28 | 30 | */ |
| 29 | -function glsr_db() { |
|
| 31 | +function glsr_db() |
|
| 32 | +{ |
|
| 30 | 33 | return glsr( 'Database' ); |
| 31 | 34 | } |
| 32 | 35 | |
@@ -34,7 +37,8 @@ discard block |
||
| 34 | 37 | * @param mixed ...$vars |
| 35 | 38 | * @return void |
| 36 | 39 | */ |
| 37 | -function glsr_debug( ...$vars ) { |
|
| 40 | +function glsr_debug( ...$vars ) |
|
| 41 | +{ |
|
| 38 | 42 | if( count( $vars ) == 1 ) { |
| 39 | 43 | $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
| 40 | 44 | printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
@@ -51,7 +55,8 @@ discard block |
||
| 51 | 55 | /** |
| 52 | 56 | * @return \GeminiLabs\SiteReviews\Modules\Logger |
| 53 | 57 | */ |
| 54 | -function glsr_log() { |
|
| 58 | +function glsr_log() |
|
| 59 | +{ |
|
| 55 | 60 | $args = func_get_args(); |
| 56 | 61 | $context = isset( $args[1] ) |
| 57 | 62 | ? $args[1] |
@@ -67,14 +72,16 @@ discard block |
||
| 67 | 72 | * @param mixed $fallback |
| 68 | 73 | * @return string|array |
| 69 | 74 | */ |
| 70 | -function glsr_get_option( $path = '', $fallback = '' ) { |
|
| 75 | +function glsr_get_option( $path = '', $fallback = '' ) |
|
| 76 | +{ |
|
| 71 | 77 | return glsr( 'Database\OptionManager' )->get( 'settings.'.$path, $fallback ); |
| 72 | 78 | } |
| 73 | 79 | |
| 74 | 80 | /** |
| 75 | 81 | * @return array |
| 76 | 82 | */ |
| 77 | -function glsr_get_options() { |
|
| 83 | +function glsr_get_options() |
|
| 84 | +{ |
|
| 78 | 85 | return glsr( 'Database\OptionManager' )->get( 'settings' ); |
| 79 | 86 | } |
| 80 | 87 | |
@@ -16,7 +16,9 @@ discard block |
||
| 16 | 16 | public function routeAdminPostRequest() |
| 17 | 17 | { |
| 18 | 18 | $request = filter_input( INPUT_POST, Application::ID, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
| 19 | - if( !isset( $request['action'] ))return; |
|
| 19 | + if( !isset( $request['action'] )) { |
|
| 20 | + return; |
|
| 21 | + } |
|
| 20 | 22 | $this->checkNonce( $request['action'] ); |
| 21 | 23 | $this->routeRequest( 'admin', $request['action'], $request ); |
| 22 | 24 | } |
@@ -41,7 +43,9 @@ discard block |
||
| 41 | 43 | public function routePublicPostRequest() |
| 42 | 44 | { |
| 43 | 45 | $request = filter_input( INPUT_POST, Application::ID, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
| 44 | - if( !isset( $request['action'] ))return; |
|
| 46 | + if( !isset( $request['action'] )) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 45 | 49 | if( !wp_verify_nonce( $request['_wpnonce'], $request['action'] )) { |
| 46 | 50 | glsr_log()->error( 'Nonce check failed for public request' )->info( $request ); |
| 47 | 51 | return; |
@@ -76,7 +80,9 @@ discard block |
||
| 76 | 80 | public function routeWebhookRequest() |
| 77 | 81 | { |
| 78 | 82 | $request = filter_input( INPUT_GET, sprintf( '%s-hook', Application::ID )); |
| 79 | - if( !$request )return; |
|
| 83 | + if( !$request ) { |
|
| 84 | + return; |
|
| 85 | + } |
|
| 80 | 86 | // @todo manage webhook here |
| 81 | 87 | } |
| 82 | 88 | |
@@ -64,7 +64,9 @@ discard block |
||
| 64 | 64 | public function getAssignedToPost( $post, $assignedTo = '' ) |
| 65 | 65 | { |
| 66 | 66 | $post = get_post( $post ); |
| 67 | - if( !( $post instanceof WP_Post ))return; |
|
| 67 | + if( !( $post instanceof WP_Post )) { |
|
| 68 | + return; |
|
| 69 | + } |
|
| 68 | 70 | if( empty( $assignedTo )) { |
| 69 | 71 | $assignedTo = get_post_meta( $post->ID, 'assigned_to', true ); |
| 70 | 72 | } |
@@ -82,7 +84,9 @@ discard block |
||
| 82 | 84 | */ |
| 83 | 85 | public function getReview( $post ) |
| 84 | 86 | { |
| 85 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
| 87 | + if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE ) { |
|
| 88 | + return; |
|
| 89 | + } |
|
| 86 | 90 | $review = $this->getReviewMeta( $post->ID ); |
| 87 | 91 | $modified = $this->isReviewModified( $post, $review ); |
| 88 | 92 | $review->content = $post->post_content; |
@@ -256,7 +260,9 @@ discard block |
||
| 256 | 260 | $termIds = array_map( 'trim', explode( ',', $termIds )); |
| 257 | 261 | foreach( $termIds as $termId ) { |
| 258 | 262 | $term = term_exists( $termId, Application::TAXONOMY ); |
| 259 | - if( !isset( $term['term_id'] ))continue; |
|
| 263 | + if( !isset( $term['term_id'] )) { |
|
| 264 | + continue; |
|
| 265 | + } |
|
| 260 | 266 | $terms[] = intval( $term['term_id'] ); |
| 261 | 267 | } |
| 262 | 268 | return $terms; |
@@ -269,7 +275,9 @@ discard block |
||
| 269 | 275 | public function revertReview( $postId ) |
| 270 | 276 | { |
| 271 | 277 | $post = get_post( $postId ); |
| 272 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
| 278 | + if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE ) { |
|
| 279 | + return; |
|
| 280 | + } |
|
| 273 | 281 | delete_post_meta( $post->ID, '_edit_last' ); |
| 274 | 282 | $result = wp_update_post([ |
| 275 | 283 | 'ID' => $post->ID, |
@@ -304,7 +312,9 @@ discard block |
||
| 304 | 312 | add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 ); |
| 305 | 313 | $search = new WP_Query( $args ); |
| 306 | 314 | remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 ); |
| 307 | - if( !$search->have_posts() )return; |
|
| 315 | + if( !$search->have_posts() ) { |
|
| 316 | + return; |
|
| 317 | + } |
|
| 308 | 318 | $results = ''; |
| 309 | 319 | while( $search->have_posts() ) { |
| 310 | 320 | $search->the_post(); |
@@ -331,7 +341,9 @@ discard block |
||
| 331 | 341 | update_post_meta( $postId, $metaKey, $metaValue ); |
| 332 | 342 | } |
| 333 | 343 | $terms = $this->normalizeTerms( $termIds ); |
| 334 | - if( empty( $terms ))return; |
|
| 344 | + if( empty( $terms )) { |
|
| 345 | + return; |
|
| 346 | + } |
|
| 335 | 347 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
| 336 | 348 | if( is_wp_error( $result )) { |
| 337 | 349 | glsr_log()->error( $result->get_error_message() ); |
@@ -50,7 +50,9 @@ |
||
| 50 | 50 | public function routerSubmitReview( array $request ) |
| 51 | 51 | { |
| 52 | 52 | $validated = glsr( ValidateReview::class )->validate( $request ); |
| 53 | - if( !empty( $validated->error ) || $validated->recaptchaIsUnset )return; |
|
| 53 | + if( !empty( $validated->error ) || $validated->recaptchaIsUnset ) { |
|
| 54 | + return; |
|
| 55 | + } |
|
| 54 | 56 | $this->execute( new CreateReview( $validated->request )); |
| 55 | 57 | } |
| 56 | 58 | } |
@@ -19,7 +19,9 @@ |
||
| 19 | 19 | public function build( array $args = [] ) |
| 20 | 20 | { |
| 21 | 21 | $this->errors = $args['errors']; |
| 22 | - if( empty( $args['message'] ))return; |
|
| 22 | + if( empty( $args['message'] )) { |
|
| 23 | + return; |
|
| 24 | + } |
|
| 23 | 25 | return glsr( Builder::class )->div( wpautop( $args['message'] ), [ |
| 24 | 26 | 'class' => $this->getClass(), |
| 25 | 27 | ]); |
@@ -152,7 +152,9 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | protected function normalizeFieldErrors( Field &$field ) |
| 154 | 154 | { |
| 155 | - if( !array_key_exists( $field->field['path'], $this->errors ))return; |
|
| 155 | + if( !array_key_exists( $field->field['path'], $this->errors )) { |
|
| 156 | + return; |
|
| 157 | + } |
|
| 156 | 158 | $field->field['errors'] = $this->errors[$field->field['path']]; |
| 157 | 159 | } |
| 158 | 160 | |
@@ -161,7 +163,9 @@ discard block |
||
| 161 | 163 | */ |
| 162 | 164 | protected function normalizeFieldRequired( Field &$field ) |
| 163 | 165 | { |
| 164 | - if( !in_array( $field->field['path'], $this->required ))return; |
|
| 166 | + if( !in_array( $field->field['path'], $this->required )) { |
|
| 167 | + return; |
|
| 168 | + } |
|
| 165 | 169 | $field->field['required'] = true; |
| 166 | 170 | } |
| 167 | 171 | |
@@ -183,7 +187,9 @@ discard block |
||
| 183 | 187 | */ |
| 184 | 188 | protected function normalizeFieldValue( Field &$field ) |
| 185 | 189 | { |
| 186 | - if( !array_key_exists( $field->field['path'], $this->values ))return; |
|
| 190 | + if( !array_key_exists( $field->field['path'], $this->values )) { |
|
| 191 | + return; |
|
| 192 | + } |
|
| 187 | 193 | if( in_array( $field->field['type'], ['radio', 'checkbox'] )) { |
| 188 | 194 | $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
| 189 | 195 | } |