@@ -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; |
@@ -17,13 +17,13 @@ discard block |
||
| 17 | 17 | $review = glsr( ReviewManager::class )->create( $command ); |
| 18 | 18 | if( !$review ) { |
| 19 | 19 | glsr( Session::class )->set( $command->form_id.'errors', [] ); |
| 20 | - glsr( Session::class )->set( $command->form_id.'message', __( 'Your review could not be submitted and the error has been logged. Please notify the site admin.', 'site-reviews' )); |
|
| 20 | + glsr( Session::class )->set( $command->form_id.'message', __( 'Your review could not be submitted and the error has been logged. Please notify the site admin.', 'site-reviews' ) ); |
|
| 21 | 21 | return; |
| 22 | 22 | } |
| 23 | - glsr( Session::class )->set( $command->form_id.'message', __( 'Your review has been submitted!', 'site-reviews' )); |
|
| 23 | + glsr( Session::class )->set( $command->form_id.'message', __( 'Your review has been submitted!', 'site-reviews' ) ); |
|
| 24 | 24 | glsr( Notification::class )->send( $review ); |
| 25 | 25 | if( $command->ajax_request )return; |
| 26 | - wp_safe_redirect( $this->getReferer( $command )); |
|
| 26 | + wp_safe_redirect( $this->getReferer( $command ) ); |
|
| 27 | 27 | exit; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | protected function getReferer( Command $command ) |
| 34 | 34 | { |
| 35 | - $referer = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ))); |
|
| 35 | + $referer = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) ); |
|
| 36 | 36 | $referer = apply_filters( 'site-reviews/review/redirect', $referer, $command ); |
| 37 | - if( empty( $referer )) { |
|
| 37 | + if( empty($referer) ) { |
|
| 38 | 38 | $referer = $command->referer; |
| 39 | 39 | } |
| 40 | - if( empty( $referer )) { |
|
| 40 | + if( empty($referer) ) { |
|
| 41 | 41 | glsr_log()->warning( 'The form referer ($_SERVER[REQUEST_URI]) was empty.' )->info( $command ); |
| 42 | 42 | $referer = home_url(); |
| 43 | 43 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | 'setting' => 'Plugin Settings', |
| 41 | 41 | 'reviews' => 'Review Counts', |
| 42 | 42 | ]; |
| 43 | - $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) { |
|
| 43 | + $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) { |
|
| 44 | 44 | $methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' ); |
| 45 | 45 | if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) { |
| 46 | 46 | return $carry.$this->implode( |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $plugins = get_plugins(); |
| 62 | 62 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 63 | - $inactive = array_diff_key( $plugins, array_flip( $activePlugins )); |
|
| 64 | - return $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
| 63 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
| 64 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | public function getInactivePluginDetails() |
| 96 | 96 | { |
| 97 | 97 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 98 | - return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ))); |
|
| 98 | + return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | { |
| 106 | 106 | $plugins = array_merge( |
| 107 | 107 | get_mu_plugins(), |
| 108 | - get_plugins( '/../'.basename( WPMU_PLUGIN_DIR )) |
|
| 108 | + get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) ) |
|
| 109 | 109 | ); |
| 110 | - if( empty( $plugins ))return; |
|
| 110 | + if( empty($plugins) )return; |
|
| 111 | 111 | return $this->normalizePluginList( $plugins ); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function getMultisitePluginDetails() |
| 118 | 118 | { |
| 119 | - if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return; |
|
| 119 | + if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return; |
|
| 120 | 120 | return $this->normalizePluginList( wp_get_active_network_plugins() ); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | 'Memory Limit' => ini_get( 'memory_limit' ), |
| 145 | 145 | 'Post Max Size' => ini_get( 'post_max_size' ), |
| 146 | 146 | 'Sendmail Path' => ini_get( 'sendmail_path' ), |
| 147 | - 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )), |
|
| 148 | - 'Session Name' => esc_html( ini_get( 'session.name' )), |
|
| 149 | - 'Session Save Path' => esc_html( ini_get( 'session.save_path' )), |
|
| 150 | - 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ), |
|
| 151 | - 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ), |
|
| 147 | + 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ), |
|
| 148 | + 'Session Name' => esc_html( ini_get( 'session.name' ) ), |
|
| 149 | + 'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ), |
|
| 150 | + 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ), |
|
| 151 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ), |
|
| 152 | 152 | 'Upload Max Filesize' => ini_get( 'upload_max_filesize' ), |
| 153 | 153 | ]; |
| 154 | 154 | } |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | { |
| 161 | 161 | $counts = glsr( CountsManager::class )->getCounts(); |
| 162 | 162 | $counts = glsr( Helper::class )->flattenArray( $counts ); |
| 163 | - array_walk( $counts, function( &$ratings ) use( $counts ) { |
|
| 164 | - if( !is_array( $ratings )) { |
|
| 163 | + array_walk( $counts, function( &$ratings ) use($counts) { |
|
| 164 | + if( !is_array( $ratings ) ) { |
|
| 165 | 165 | glsr_log() |
| 166 | 166 | ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' ) |
| 167 | 167 | ->debug( $ratings ) |
@@ -200,8 +200,8 @@ discard block |
||
| 200 | 200 | ksort( $settings ); |
| 201 | 201 | $details = []; |
| 202 | 202 | foreach( $settings as $key => $value ) { |
| 203 | - if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
| 204 | - $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
|
| 203 | + if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) )continue; |
|
| 204 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
| 205 | 205 | $details[$key] = $value; |
| 206 | 206 | } |
| 207 | 207 | return $details; |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | { |
| 215 | 215 | return [ |
| 216 | 216 | 'Console size' => glsr( Console::class )->humanSize( '0' ), |
| 217 | - 'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' )), |
|
| 217 | + 'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ), |
|
| 218 | 218 | 'Version (current)' => glsr()->version, |
| 219 | 219 | 'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ), |
| 220 | 220 | ]; |
@@ -274,10 +274,10 @@ discard block |
||
| 274 | 274 | 'WPE_APIKEY' => 'WP Engine', |
| 275 | 275 | ]; |
| 276 | 276 | foreach( $checks as $key => $value ) { |
| 277 | - if( !$this->isWebhostCheckValid( $key ))continue; |
|
| 277 | + if( !$this->isWebhostCheckValid( $key ) )continue; |
|
| 278 | 278 | return $value; |
| 279 | 279 | } |
| 280 | - return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] )); |
|
| 280 | + return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) ); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
@@ -298,8 +298,8 @@ discard block |
||
| 298 | 298 | { |
| 299 | 299 | $plugins = get_plugins(); |
| 300 | 300 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
| 301 | - $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ))); |
|
| 302 | - $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
| 301 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
| 302 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
| 303 | 303 | return $active + $inactive; |
| 304 | 304 | } |
| 305 | 305 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | protected function implode( $title, array $details ) |
| 311 | 311 | { |
| 312 | 312 | $strings = ['['.$title.']']; |
| 313 | - $padding = max( array_map( 'strlen', array_keys( $details )) ); |
|
| 313 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
| 314 | 314 | $padding = max( [$padding, static::PAD] ); |
| 315 | 315 | foreach( $details as $key => $value ) { |
| 316 | 316 | $strings[] = is_string( $key ) |
@@ -353,9 +353,9 @@ discard block |
||
| 353 | 353 | $keys = [ |
| 354 | 354 | 'licenses.', 'submissions.recaptcha.key', 'submissions.recaptcha.secret', |
| 355 | 355 | ]; |
| 356 | - array_walk( $settings, function( &$value, $setting ) use( $keys ) { |
|
| 356 | + array_walk( $settings, function( &$value, $setting ) use($keys) { |
|
| 357 | 357 | foreach( $keys as $key ) { |
| 358 | - if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty( $value ))continue; |
|
| 358 | + if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) )continue; |
|
| 359 | 359 | $value = str_repeat( '•', 13 ); |
| 360 | 360 | return; |
| 361 | 361 | } |
@@ -36,12 +36,12 @@ discard block |
||
| 36 | 36 | 'post_type' => Application::POST_TYPE, |
| 37 | 37 | ]; |
| 38 | 38 | $postId = wp_insert_post( $postValues, true ); |
| 39 | - if( is_wp_error( $postId )) { |
|
| 39 | + if( is_wp_error( $postId ) ) { |
|
| 40 | 40 | glsr_log()->error( $postId->get_error_message() )->debug( $postValues ); |
| 41 | 41 | return false; |
| 42 | 42 | } |
| 43 | 43 | $this->setTerms( $postId, $command->category ); |
| 44 | - $review = $this->single( get_post( $postId )); |
|
| 44 | + $review = $this->single( get_post( $postId ) ); |
|
| 45 | 45 | do_action( 'site-reviews/review/created', $review, $command ); |
| 46 | 46 | return $review; |
| 47 | 47 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function delete( $metaReviewId ) |
| 54 | 54 | { |
| 55 | - if( $postId = $this->getPostId( $metaReviewId )) { |
|
| 55 | + if( $postId = $this->getPostId( $metaReviewId ) ) { |
|
| 56 | 56 | wp_delete_post( $postId, true ); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $paged = glsr( QueryBuilder::class )->getPaged( |
| 75 | 75 | wp_validate_boolean( $args['pagination'] ) |
| 76 | 76 | ); |
| 77 | - $query = new WP_Query([ |
|
| 77 | + $query = new WP_Query( [ |
|
| 78 | 78 | 'meta_key' => 'pinned', |
| 79 | 79 | 'meta_query' => $metaQuery, |
| 80 | 80 | 'offset' => $args['offset'], |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | 'post_type' => Application::POST_TYPE, |
| 88 | 88 | 'posts_per_page' => $args['count'], |
| 89 | 89 | 'tax_query' => $taxQuery, |
| 90 | - ]); |
|
| 90 | + ] ); |
|
| 91 | 91 | $results = array_map( [$this, 'single'], $query->posts ); |
| 92 | 92 | $reviews = new Reviews( $results, $query->max_num_pages, $args ); |
| 93 | 93 | return apply_filters( 'site-reviews/get/reviews', $reviews, $query ); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | public function normalizeTermIds( $commaSeparatedTermIds ) |
| 110 | 110 | { |
| 111 | 111 | $termIds = glsr_array_column( $this->normalizeTerms( $commaSeparatedTermIds ), 'term_id' ); |
| 112 | - return array_unique( array_map( 'intval', $termIds )); |
|
| 112 | + return array_unique( array_map( 'intval', $termIds ) ); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -121,11 +121,11 @@ discard block |
||
| 121 | 121 | $terms = []; |
| 122 | 122 | $termIds = glsr( Helper::class )->convertStringToArray( $commaSeparatedTermIds ); |
| 123 | 123 | foreach( $termIds as $termId ) { |
| 124 | - if( is_numeric( $termId )) { |
|
| 124 | + if( is_numeric( $termId ) ) { |
|
| 125 | 125 | $termId = intval( $termId ); |
| 126 | 126 | } |
| 127 | 127 | $term = term_exists( $termId, Application::TAXONOMY ); |
| 128 | - if( !isset( $term['term_id'] ))continue; |
|
| 128 | + if( !isset($term['term_id']) )continue; |
|
| 129 | 129 | $terms[] = $term; |
| 130 | 130 | } |
| 131 | 131 | return $terms; |
@@ -139,13 +139,13 @@ discard block |
||
| 139 | 139 | { |
| 140 | 140 | if( get_post_field( 'post_type', $postId ) != Application::POST_TYPE )return; |
| 141 | 141 | delete_post_meta( $postId, '_edit_last' ); |
| 142 | - $result = wp_update_post([ |
|
| 142 | + $result = wp_update_post( [ |
|
| 143 | 143 | 'ID' => $postId, |
| 144 | 144 | 'post_content' => get_post_meta( $postId, 'content', true ), |
| 145 | 145 | 'post_date' => get_post_meta( $postId, 'date', true ), |
| 146 | 146 | 'post_title' => get_post_meta( $postId, 'title', true ), |
| 147 | - ]); |
|
| 148 | - if( is_wp_error( $result )) { |
|
| 147 | + ] ); |
|
| 148 | + if( is_wp_error( $result ) ) { |
|
| 149 | 149 | glsr_log()->error( $result->get_error_message() ); |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | protected function getNewPostStatus( array $review, $isBlacklisted ) |
| 170 | 170 | { |
| 171 | 171 | $requireApprovalOption = glsr( OptionManager::class )->get( 'settings.general.require.approval' ); |
| 172 | - return $review['review_type'] == 'local' && ( $requireApprovalOption == 'yes' || $isBlacklisted ) |
|
| 172 | + return $review['review_type'] == 'local' && ($requireApprovalOption == 'yes' || $isBlacklisted) |
|
| 173 | 173 | ? 'pending' |
| 174 | 174 | : 'publish'; |
| 175 | 175 | } |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | protected function setTerms( $postId, $termIds ) |
| 183 | 183 | { |
| 184 | 184 | $termIds = $this->normalizeTermIds( $termIds ); |
| 185 | - if( empty( $termIds ))return; |
|
| 185 | + if( empty($termIds) )return; |
|
| 186 | 186 | $termTaxonomyIds = wp_set_object_terms( $postId, $termIds, Application::TAXONOMY ); |
| 187 | - if( is_wp_error( $termTaxonomyIds )) { |
|
| 187 | + if( is_wp_error( $termTaxonomyIds ) ) { |
|
| 188 | 188 | glsr_log()->error( $termTaxonomyIds->get_error_message() ); |
| 189 | 189 | } |
| 190 | 190 | } |
@@ -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 | } |
@@ -34,15 +34,15 @@ discard block |
||
| 34 | 34 | public function build( array $args = [] ) |
| 35 | 35 | { |
| 36 | 36 | $this->args = $args; |
| 37 | - $counts = glsr( CountsManager::class )->get([ |
|
| 37 | + $counts = glsr( CountsManager::class )->get( [ |
|
| 38 | 38 | 'post_ids' => glsr( Helper::class )->convertStringToArray( $args['assigned_to'] ), |
| 39 | 39 | 'term_ids' => glsr( ReviewManager::class )->normalizeTermIds( $args['category'] ), |
| 40 | 40 | 'type' => $args['type'], |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | $this->ratingCounts = glsr( CountsManager::class )->flatten( $counts, [ |
| 43 | 43 | 'min' => $args['rating'], |
| 44 | - ]); |
|
| 45 | - if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ))return; |
|
| 44 | + ] ); |
|
| 45 | + if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ) )return; |
|
| 46 | 46 | $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts ); |
| 47 | 47 | $this->generateSchema(); |
| 48 | 48 | return glsr( Template::class )->build( 'templates/reviews-summary', [ |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | 'stars' => $this->buildStars(), |
| 56 | 56 | 'text' => $this->buildText(), |
| 57 | 57 | ], |
| 58 | - ]); |
|
| 58 | + ] ); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | protected function buildPercentage() |
| 65 | 65 | { |
| 66 | - if( $this->isHidden( 'bars' ))return; |
|
| 67 | - $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts )); |
|
| 68 | - $bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use( $percentages ) { |
|
| 66 | + if( $this->isHidden( 'bars' ) )return; |
|
| 67 | + $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ) ); |
|
| 68 | + $bars = array_reduce( range( Rating::MAX_RATING, 1 ), function( $carry, $level ) use($percentages) { |
|
| 69 | 69 | $label = $this->buildPercentageLabel( $this->args['labels'][$level] ); |
| 70 | 70 | $background = $this->buildPercentageBackground( $percentages[$level] ); |
| 71 | 71 | $count = apply_filters( 'site-reviews/summary/counts', |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $percent = $this->buildPercentageCount( $count ); |
| 76 | 76 | return $carry.glsr( Builder::class )->div( $label.$background.$percent, [ |
| 77 | 77 | 'class' => 'glsr-bar', |
| 78 | - ]); |
|
| 78 | + ] ); |
|
| 79 | 79 | }); |
| 80 | 80 | return $this->wrap( 'percentage', $bars ); |
| 81 | 81 | } |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | protected function buildPercentageBackground( $percent ) |
| 88 | 88 | { |
| 89 | - $backgroundPercent = glsr( Builder::class )->span([ |
|
| 89 | + $backgroundPercent = glsr( Builder::class )->span( [ |
|
| 90 | 90 | 'class' => 'glsr-bar-background-percent', |
| 91 | 91 | 'style' => 'width:'.$percent, |
| 92 | - ]); |
|
| 92 | + ] ); |
|
| 93 | 93 | return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>'; |
| 94 | 94 | } |
| 95 | 95 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | protected function buildRating() |
| 118 | 118 | { |
| 119 | - if( $this->isHidden( 'rating' ))return; |
|
| 119 | + if( $this->isHidden( 'rating' ) )return; |
|
| 120 | 120 | return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' ); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | protected function buildStars() |
| 127 | 127 | { |
| 128 | - if( $this->isHidden( 'stars' ))return; |
|
| 128 | + if( $this->isHidden( 'stars' ) )return; |
|
| 129 | 129 | $stars = glsr_star_rating( $this->averageRating ); |
| 130 | 130 | return $this->wrap( 'stars', $stars ); |
| 131 | 131 | } |
@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | protected function buildText() |
| 137 | 137 | { |
| 138 | - if( $this->isHidden( 'summary' ))return; |
|
| 139 | - $count = intval( array_sum( $this->ratingCounts )); |
|
| 140 | - if( empty( $this->args['text'] )) { |
|
| 138 | + if( $this->isHidden( 'summary' ) )return; |
|
| 139 | + $count = intval( array_sum( $this->ratingCounts ) ); |
|
| 140 | + if( empty($this->args['text']) ) { |
|
| 141 | 141 | // @todo document this change |
| 142 | 142 | $this->args['text'] = _nx( |
| 143 | 143 | '{rating} out of {max} stars (based on {num} review)', |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | ); |
| 149 | 149 | } |
| 150 | 150 | $summary = str_replace( |
| 151 | - ['{rating}','{max}', '{num}'], |
|
| 151 | + ['{rating}', '{max}', '{num}'], |
|
| 152 | 152 | [$this->averageRating, Rating::MAX_RATING, $count], |
| 153 | 153 | $this->args['text'] |
| 154 | 154 | ); |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | protected function generateSchema() |
| 162 | 162 | { |
| 163 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 163 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
| 164 | 164 | glsr( Schema::class )->store( |
| 165 | 165 | glsr( Schema::class )->buildSummary( $this->args ) |
| 166 | 166 | ); |
@@ -192,6 +192,6 @@ discard block |
||
| 192 | 192 | { |
| 193 | 193 | return glsr( Builder::class )->div( $value, [ |
| 194 | 194 | 'class' => 'glsr-summary-'.$key, |
| 195 | - ]); |
|
| 195 | + ] ); |
|
| 196 | 196 | } |
| 197 | 197 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | foreach( $this->reviews as $index => $review ) { |
| 86 | 86 | $renderedReviews[] = glsr( Template::class )->build( 'templates/review', [ |
| 87 | 87 | 'context' => $this->buildReview( $review )->values, |
| 88 | - ]); |
|
| 88 | + ] ); |
|
| 89 | 89 | } |
| 90 | 90 | return new ReviewsHtml( $renderedReviews, $this->reviews->max_num_pages, $this->args ); |
| 91 | 91 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function generateSchema() |
| 97 | 97 | { |
| 98 | - if( !wp_validate_boolean( $this->args['schema'] ))return; |
|
| 98 | + if( !wp_validate_boolean( $this->args['schema'] ) )return; |
|
| 99 | 99 | glsr( Schema::class )->store( |
| 100 | 100 | glsr( Schema::class )->build( $this->args ) |
| 101 | 101 | ); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function isHidden( $key, $path = '' ) |
| 110 | 110 | { |
| 111 | - $isOptionEnabled = !empty( $path ) |
|
| 111 | + $isOptionEnabled = !empty($path) |
|
| 112 | 112 | ? $this->isOptionEnabled( $path ) |
| 113 | 113 | : true; |
| 114 | 114 | return in_array( $key, $this->args['hide'] ) || !$isOptionEnabled; |
@@ -121,12 +121,12 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | protected function buildOptionAssignedTo( $key, $value ) |
| 123 | 123 | { |
| 124 | - if( $this->isHidden( $key, 'settings.reviews.assigned_links' ))return; |
|
| 124 | + if( $this->isHidden( $key, 'settings.reviews.assigned_links' ) )return; |
|
| 125 | 125 | $post = glsr( Polylang::class )->getPost( $value ); |
| 126 | - if( !( $post instanceof WP_Post ))return; |
|
| 126 | + if( !($post instanceof WP_Post) )return; |
|
| 127 | 127 | $permalink = glsr( Builder::class )->a( get_the_title( $post->ID ), [ |
| 128 | 128 | 'href' => get_the_permalink( $post->ID ), |
| 129 | - ]); |
|
| 129 | + ] ); |
|
| 130 | 130 | $assignedTo = sprintf( __( 'Review of %s', 'site-reviews' ), $permalink ); |
| 131 | 131 | return '<span>'.$assignedTo.'</span>'; |
| 132 | 132 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | protected function buildOptionAuthor( $key, $value ) |
| 140 | 140 | { |
| 141 | - if( $this->isHidden( $key ))return; |
|
| 141 | + if( $this->isHidden( $key ) )return; |
|
| 142 | 142 | return '<span>'.$value.'</span>'; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | protected function buildOptionAvatar( $key, $value ) |
| 151 | 151 | { |
| 152 | - if( $this->isHidden( $key, 'settings.reviews.avatars' ))return; |
|
| 152 | + if( $this->isHidden( $key, 'settings.reviews.avatars' ) )return; |
|
| 153 | 153 | $size = $this->getOption( 'settings.reviews.avatars_size', 40 ); |
| 154 | - return glsr( Builder::class )->img([ |
|
| 154 | + return glsr( Builder::class )->img( [ |
|
| 155 | 155 | 'height' => $size, |
| 156 | 156 | 'src' => $this->generateAvatar( $value ), |
| 157 | 157 | 'style' => sprintf( 'width:%1$spx; height:%1$spx;', $size ), |
| 158 | 158 | 'width' => $size, |
| 159 | - ]); |
|
| 159 | + ] ); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | protected function buildOptionContent( $key, $value ) |
| 168 | 168 | { |
| 169 | 169 | $text = $this->normalizeText( $value ); |
| 170 | - if( $this->isHiddenOrEmpty( $key, $text ))return; |
|
| 170 | + if( $this->isHiddenOrEmpty( $key, $text ) )return; |
|
| 171 | 171 | return '<p>'.$text.'</p>'; |
| 172 | 172 | } |
| 173 | 173 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | protected function buildOptionDate( $key, $value ) |
| 180 | 180 | { |
| 181 | - if( $this->isHidden( $key ))return; |
|
| 181 | + if( $this->isHidden( $key ) )return; |
|
| 182 | 182 | $dateFormat = $this->getOption( 'settings.reviews.date.format', 'default' ); |
| 183 | 183 | if( $dateFormat == 'relative' ) { |
| 184 | 184 | $date = glsr( Date::class )->relative( $value ); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $format = $dateFormat == 'custom' |
| 188 | 188 | ? $this->getOption( 'settings.reviews.date.custom', 'M j, Y' ) |
| 189 | 189 | : (string)get_option( 'date_format' ); |
| 190 | - $date = date_i18n( $format, strtotime( $value )); |
|
| 190 | + $date = date_i18n( $format, strtotime( $value ) ); |
|
| 191 | 191 | } |
| 192 | 192 | return '<span>'.$date.'</span>'; |
| 193 | 193 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | */ |
| 200 | 200 | protected function buildOptionRating( $key, $value ) |
| 201 | 201 | { |
| 202 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 202 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
| 203 | 203 | return glsr_star_rating( $value ); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | protected function buildOptionResponse( $key, $value ) |
| 212 | 212 | { |
| 213 | - if( $this->isHiddenOrEmpty( $key, $value ))return; |
|
| 214 | - $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' )); |
|
| 213 | + if( $this->isHiddenOrEmpty( $key, $value ) )return; |
|
| 214 | + $title = sprintf( __( 'Response from %s', 'site-reviews' ), get_bloginfo( 'name' ) ); |
|
| 215 | 215 | $text = $this->normalizeText( $value ); |
| 216 | 216 | $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>'; |
| 217 | 217 | $response = glsr( Builder::class )->div( $text, ['class' => 'glsr-review-response-inner'] ); |
@@ -226,8 +226,8 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | protected function buildOptionTitle( $key, $value ) |
| 228 | 228 | { |
| 229 | - if( $this->isHidden( $key ))return; |
|
| 230 | - if( empty( $value )) { |
|
| 229 | + if( $this->isHidden( $key ) )return; |
|
| 230 | + if( empty($value) ) { |
|
| 231 | 231 | $value = __( 'No Title', 'site-reviews' ); |
| 232 | 232 | } |
| 233 | 233 | return '<h3>'.$value.'</h3>'; |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | return $avatarUrl; |
| 244 | 244 | } |
| 245 | 245 | $authorIdOrEmail = get_the_author_meta( 'ID', $this->current->user_id ); |
| 246 | - if( empty( $authorIdOrEmail )) { |
|
| 246 | + if( empty($authorIdOrEmail) ) { |
|
| 247 | 247 | $authorIdOrEmail = $this->current->email; |
| 248 | 248 | } |
| 249 | - if( $newAvatar = get_avatar_url( $authorIdOrEmail )) { |
|
| 249 | + if( $newAvatar = get_avatar_url( $authorIdOrEmail ) ) { |
|
| 250 | 250 | return $newAvatar; |
| 251 | 251 | } |
| 252 | 252 | return $avatarUrl; |
@@ -258,18 +258,18 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | protected function getExcerpt( $text ) |
| 260 | 260 | { |
| 261 | - $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 )); |
|
| 261 | + $limit = intval( $this->getOption( 'settings.reviews.excerpts_length', 55 ) ); |
|
| 262 | 262 | $split = extension_loaded( 'intl' ) |
| 263 | 263 | ? $this->getExcerptIntlSplit( $text, $limit ) |
| 264 | 264 | : $this->getExcerptSplit( $text, $limit ); |
| 265 | 265 | $hiddenText = substr( $text, $split ); |
| 266 | - if( !empty( $hiddenText )) { |
|
| 266 | + if( !empty($hiddenText) ) { |
|
| 267 | 267 | $showMore = glsr( Builder::class )->span( $hiddenText, [ |
| 268 | 268 | 'class' => 'glsr-hidden glsr-hidden-text', |
| 269 | 269 | 'data-show-less' => __( 'Show less', 'site-reviews' ), |
| 270 | 270 | 'data-show-more' => __( 'Show more', 'site-reviews' ), |
| 271 | - ]); |
|
| 272 | - $text = ltrim( substr( $text, 0, $split )).$showMore; |
|
| 271 | + ] ); |
|
| 272 | + $text = ltrim( substr( $text, 0, $split ) ).$showMore; |
|
| 273 | 273 | } |
| 274 | 274 | return nl2br( $text ); |
| 275 | 275 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | $words = IntlRuleBasedBreakIterator::createWordInstance( '' ); |
| 285 | 285 | $words->setText( $text ); |
| 286 | 286 | $count = 0; |
| 287 | - foreach( $words as $offset ){ |
|
| 287 | + foreach( $words as $offset ) { |
|
| 288 | 288 | if( $words->getRuleStatus() === IntlRuleBasedBreakIterator::WORD_NONE )continue; |
| 289 | 289 | $count++; |
| 290 | 290 | if( $count != $limit )continue; |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | protected function getExcerptSplit( $text, $limit ) |
| 302 | 302 | { |
| 303 | 303 | if( str_word_count( $text, 0 ) > $limit ) { |
| 304 | - $words = array_keys( str_word_count( $text, 2 )); |
|
| 304 | + $words = array_keys( str_word_count( $text, 2 ) ); |
|
| 305 | 305 | return $words[$limit]; |
| 306 | 306 | } |
| 307 | 307 | return strlen( $text ); |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | protected function getOption( $path, $fallback = '' ) |
| 316 | 316 | { |
| 317 | - if( array_key_exists( $path, $this->options )) { |
|
| 317 | + if( array_key_exists( $path, $this->options ) ) { |
|
| 318 | 318 | return $this->options[$path]; |
| 319 | 319 | } |
| 320 | 320 | return $fallback; |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | */ |
| 328 | 328 | protected function isHiddenOrEmpty( $key, $value ) |
| 329 | 329 | { |
| 330 | - return $this->isHidden( $key ) || empty( $value ); |
|
| 330 | + return $this->isHidden( $key ) || empty($value); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -346,10 +346,10 @@ discard block |
||
| 346 | 346 | protected function normalizeText( $text ) |
| 347 | 347 | { |
| 348 | 348 | $text = wp_kses( $text, wp_kses_allowed_html() ); |
| 349 | - $text = convert_smilies( strip_shortcodes( $text )); |
|
| 349 | + $text = convert_smilies( strip_shortcodes( $text ) ); |
|
| 350 | 350 | $text = str_replace( ']]>', ']]>', $text ); |
| 351 | 351 | $text = preg_replace( '/(\R){2,}/', '$1', $text ); |
| 352 | - if( $this->isOptionEnabled( 'settings.reviews.excerpts' )) { |
|
| 352 | + if( $this->isOptionEnabled( 'settings.reviews.excerpts' ) ) { |
|
| 353 | 353 | $text = $this->getExcerpt( $text ); |
| 354 | 354 | } |
| 355 | 355 | return wptexturize( $text ); |
@@ -361,12 +361,12 @@ discard block |
||
| 361 | 361 | protected function wrap( array &$renderedFields, Review $review ) |
| 362 | 362 | { |
| 363 | 363 | $renderedFields = apply_filters( 'site-reviews/review/wrap', $renderedFields, $review ); |
| 364 | - array_walk( $renderedFields, function( &$value, $key ) use( $review ) { |
|
| 364 | + array_walk( $renderedFields, function( &$value, $key ) use($review) { |
|
| 365 | 365 | $value = apply_filters( 'site-reviews/review/wrap/'.$key, $value, $review ); |
| 366 | - if( empty( $value ))return; |
|
| 366 | + if( empty($value) )return; |
|
| 367 | 367 | $value = glsr( Builder::class )->div( $value, [ |
| 368 | 368 | 'class' => 'glsr-review-'.$key, |
| 369 | - ]); |
|
| 369 | + ] ); |
|
| 370 | 370 | }); |
| 371 | 371 | } |
| 372 | 372 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | if( $assignedPost instanceof WP_Post && $assignedPost->post_status == 'publish' ) { |
| 22 | 22 | $column = glsr( Builder::class )->a( get_the_title( $assignedPost->ID ), [ |
| 23 | 23 | 'href' => (string)get_the_permalink( $assignedPost->ID ), |
| 24 | - ]); |
|
| 24 | + ] ); |
|
| 25 | 25 | } |
| 26 | 26 | return $column; |
| 27 | 27 | } |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | $pinned = get_post_meta( $postId, 'pinned', true ) |
| 36 | 36 | ? 'pinned ' |
| 37 | 37 | : ''; |
| 38 | - return glsr( Builder::class )->i([ |
|
| 38 | + return glsr( Builder::class )->i( [ |
|
| 39 | 39 | 'class' => $pinned.'dashicons dashicons-sticky', |
| 40 | 40 | 'data-id' => $postId, |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function buildColumnReviewer( $postId ) |
| 49 | 49 | { |
| 50 | - return strval( get_post_meta( $postId, 'author', true )); |
|
| 50 | + return strval( get_post_meta( $postId, 'author', true ) ); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function buildColumnRating( $postId ) |
| 59 | 59 | { |
| 60 | - return glsr_star_rating( intval( get_post_meta( $postId, 'rating', true ))); |
|
| 60 | + return glsr_star_rating( intval( get_post_meta( $postId, 'rating', true ) ) ); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function renderFilters( $postType ) |
| 80 | 80 | { |
| 81 | 81 | if( $postType !== Application::POST_TYPE )return; |
| 82 | - if( !( $status = filter_input( INPUT_GET, 'post_status' ))) { |
|
| 82 | + if( !($status = filter_input( INPUT_GET, 'post_status' )) ) { |
|
| 83 | 83 | $status = 'publish'; |
| 84 | 84 | } |
| 85 | 85 | $ratings = glsr( Database::class )->getReviewsMeta( 'rating', $status ); |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | protected function renderFilterRatings( $ratings ) |
| 110 | 110 | { |
| 111 | - if( empty( $ratings ))return; |
|
| 112 | - $ratings = array_flip( array_reverse( $ratings )); |
|
| 111 | + if( empty($ratings) )return; |
|
| 112 | + $ratings = array_flip( array_reverse( $ratings ) ); |
|
| 113 | 113 | array_walk( $ratings, function( &$value, $key ) { |
| 114 | 114 | $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
| 115 | 115 | $value = sprintf( $label, $key ); |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | echo glsr( Builder::class )->label( __( 'Filter by rating', 'site-reviews' ), [ |
| 118 | 118 | 'class' => 'screen-reader-text', |
| 119 | 119 | 'for' => 'rating', |
| 120 | - ]); |
|
| 121 | - echo glsr( Builder::class )->select([ |
|
| 120 | + ] ); |
|
| 121 | + echo glsr( Builder::class )->select( [ |
|
| 122 | 122 | 'name' => 'rating', |
| 123 | 123 | 'options' => ['' => __( 'All ratings', 'site-reviews' )] + $ratings, |
| 124 | 124 | 'value' => filter_input( INPUT_GET, 'rating' ), |
| 125 | - ]); |
|
| 125 | + ] ); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -135,11 +135,11 @@ discard block |
||
| 135 | 135 | echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [ |
| 136 | 136 | 'class' => 'screen-reader-text', |
| 137 | 137 | 'for' => 'review_type', |
| 138 | - ]); |
|
| 139 | - echo glsr( Builder::class )->select([ |
|
| 138 | + ] ); |
|
| 139 | + echo glsr( Builder::class )->select( [ |
|
| 140 | 140 | 'name' => 'review_type', |
| 141 | 141 | 'options' => ['' => __( 'All types', 'site-reviews' )] + glsr()->reviewTypes, |
| 142 | 142 | 'value' => filter_input( INPUT_GET, 'review_type' ), |
| 143 | - ]); |
|
| 143 | + ] ); |
|
| 144 | 144 | } |
| 145 | 145 | } |
@@ -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 | } |