@@ -42,7 +42,9 @@ discard block |
||
| 42 | 42 | $options = $this->all(); |
| 43 | 43 | $pointer = &$options; |
| 44 | 44 | foreach( $keys as $key ) { |
| 45 | - if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] ))continue; |
|
| 45 | + if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] )) { |
|
| 46 | + continue; |
|
| 47 | + } |
|
| 46 | 48 | $pointer = &$pointer[$key]; |
| 47 | 49 | } |
| 48 | 50 | unset( $pointer[$last] ); |
@@ -77,7 +79,9 @@ discard block |
||
| 77 | 79 | glsr( DefaultsManager::class )->defaults() |
| 78 | 80 | ); |
| 79 | 81 | array_walk( $options, function( &$value ) { |
| 80 | - if( !is_string( $value ))return; |
|
| 82 | + if( !is_string( $value )) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 81 | 85 | $value = wp_kses( $value, wp_kses_allowed_html( 'post' )); |
| 82 | 86 | }); |
| 83 | 87 | return glsr( Helper::class )->convertDotNotationArray( $options ); |
@@ -86,7 +86,9 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function renderFilters( $postType ) |
| 88 | 88 | { |
| 89 | - if( $postType !== Application::POST_TYPE )return; |
|
| 89 | + if( $postType !== Application::POST_TYPE ) { |
|
| 90 | + return; |
|
| 91 | + } |
|
| 90 | 92 | if( !( $status = filter_input( INPUT_GET, 'post_status' ))) { |
| 91 | 93 | $status = 'publish'; |
| 92 | 94 | } |
@@ -103,7 +105,9 @@ discard block |
||
| 103 | 105 | */ |
| 104 | 106 | public function renderValues( $column, $postId ) |
| 105 | 107 | { |
| 106 | - if( glsr_current_screen()->post_type != Application::POST_TYPE )return; |
|
| 108 | + if( glsr_current_screen()->post_type != Application::POST_TYPE ) { |
|
| 109 | + return; |
|
| 110 | + } |
|
| 107 | 111 | $method = glsr( Helper::class )->buildMethodName( $column, 'buildColumn' ); |
| 108 | 112 | echo method_exists( $this, $method ) |
| 109 | 113 | ? call_user_func( [$this, $method], $postId ) |
@@ -116,7 +120,9 @@ discard block |
||
| 116 | 120 | */ |
| 117 | 121 | protected function renderFilterRatings( $ratings ) |
| 118 | 122 | { |
| 119 | - if( empty( $ratings ))return; |
|
| 123 | + if( empty( $ratings )) { |
|
| 124 | + return; |
|
| 125 | + } |
|
| 120 | 126 | $ratings = array_flip( array_reverse( $ratings )); |
| 121 | 127 | array_walk( $ratings, function( &$value, $key ) { |
| 122 | 128 | $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
@@ -139,7 +145,9 @@ discard block |
||
| 139 | 145 | */ |
| 140 | 146 | protected function renderFilterTypes( $types ) |
| 141 | 147 | { |
| 142 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
| 148 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 143 | 151 | echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [ |
| 144 | 152 | 'class' => 'screen-reader-text', |
| 145 | 153 | 'for' => 'review_type', |
@@ -53,7 +53,9 @@ |
||
| 53 | 53 | $arrayKeys = ['context', 'globals']; |
| 54 | 54 | $data = wp_parse_args( $data, array_fill_keys( $arrayKeys, [] )); |
| 55 | 55 | foreach( $arrayKeys as $key ) { |
| 56 | - if( is_array( $data[$key] ))continue; |
|
| 56 | + if( is_array( $data[$key] )) { |
|
| 57 | + continue; |
|
| 58 | + } |
|
| 57 | 59 | $data[$key] = []; |
| 58 | 60 | } |
| 59 | 61 | return $data; |
@@ -115,7 +115,9 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function renderReviewEditor( WP_Post $post ) |
| 117 | 117 | { |
| 118 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
| 118 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) { |
|
| 119 | + return; |
|
| 120 | + } |
|
| 119 | 121 | glsr()->render( 'partials/editor/review', [ |
| 120 | 122 | 'post' => $post, |
| 121 | 123 | ]); |
@@ -127,7 +129,9 @@ discard block |
||
| 127 | 129 | */ |
| 128 | 130 | public function renderReviewNotice( WP_Post $post ) |
| 129 | 131 | { |
| 130 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
| 132 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post )) { |
|
| 133 | + return; |
|
| 134 | + } |
|
| 131 | 135 | glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' )); |
| 132 | 136 | glsr( Html::class )->renderTemplate( 'partials/editor/notice', [ |
| 133 | 137 | 'context' => [ |
@@ -142,13 +146,19 @@ discard block |
||
| 142 | 146 | */ |
| 143 | 147 | public function renderTinymceButton() |
| 144 | 148 | { |
| 145 | - if( glsr_current_screen()->base != 'post' )return; |
|
| 149 | + if( glsr_current_screen()->base != 'post' ) { |
|
| 150 | + return; |
|
| 151 | + } |
|
| 146 | 152 | $shortcodes = []; |
| 147 | 153 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
| 148 | - if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ))continue; |
|
| 154 | + if( !apply_filters( sanitize_title( $shortcode ).'_condition', true )) { |
|
| 155 | + continue; |
|
| 156 | + } |
|
| 149 | 157 | $shortcodes[$shortcode] = $values; |
| 150 | 158 | } |
| 151 | - if( empty( $shortcodes ))return; |
|
| 159 | + if( empty( $shortcodes )) { |
|
| 160 | + return; |
|
| 161 | + } |
|
| 152 | 162 | glsr()->render( 'partials/editor/tinymce', [ |
| 153 | 163 | 'shortcodes' => $shortcodes, |
| 154 | 164 | ]); |
@@ -54,7 +54,9 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 56 | 56 | foreach( $postTypeColumns as $key => &$value ) { |
| 57 | - if( !array_key_exists( $key, $columns ) || !empty( $value ))continue; |
|
| 57 | + if( !array_key_exists( $key, $columns ) || !empty( $value )) { |
|
| 58 | + continue; |
|
| 59 | + } |
|
| 58 | 60 | $value = $columns[$key]; |
| 59 | 61 | } |
| 60 | 62 | if( count( glsr( Database::class )->getReviewsMeta( 'type' )) < 2 ) { |
@@ -92,7 +94,8 @@ discard block |
||
| 92 | 94 | * @return array |
| 93 | 95 | * @filter display_post_states |
| 94 | 96 | */ |
| 95 | - public function filterPostStates( array $postStates, WP_Post $post ) { |
|
| 97 | + public function filterPostStates( array $postStates, WP_Post $post ) |
|
| 98 | + { |
|
| 96 | 99 | if( $post->post_type == Application::POST_TYPE |
| 97 | 100 | && array_key_exists( 'pending', $postStates )) { |
| 98 | 101 | $postStates['pending'] = __( 'Unapproved', 'site-reviews' ); |
@@ -137,7 +140,9 @@ discard block |
||
| 137 | 140 | $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE]; |
| 138 | 141 | unset( $postTypeColumns['cb'] ); |
| 139 | 142 | foreach( $postTypeColumns as $key => $value ) { |
| 140 | - if( glsr( Helper::class )->startsWith( 'taxonomy', $key ))continue; |
|
| 143 | + if( glsr( Helper::class )->startsWith( 'taxonomy', $key )) { |
|
| 144 | + continue; |
|
| 145 | + } |
|
| 141 | 146 | $columns[$key] = $key; |
| 142 | 147 | } |
| 143 | 148 | return $columns; |
@@ -161,7 +166,9 @@ discard block |
||
| 161 | 166 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
| 162 | 167 | ]; |
| 163 | 168 | foreach( $strings as $search => $replace ) { |
| 164 | - if( strpos( $single, $search ) === false )continue; |
|
| 169 | + if( strpos( $single, $search ) === false ) { |
|
| 170 | + continue; |
|
| 171 | + } |
|
| 165 | 172 | $translation = $this->getTranslation([ |
| 166 | 173 | 'number' => $number, |
| 167 | 174 | 'plural' => str_replace( $search, $replace, $plural ), |
@@ -213,7 +220,9 @@ discard block |
||
| 213 | 220 | */ |
| 214 | 221 | public function saveBulkEditFields( $postId ) |
| 215 | 222 | { |
| 216 | - if( !current_user_can( 'edit_posts' ))return; |
|
| 223 | + if( !current_user_can( 'edit_posts' )) { |
|
| 224 | + return; |
|
| 225 | + } |
|
| 217 | 226 | $assignedTo = filter_input( INPUT_GET, 'assigned_to' ); |
| 218 | 227 | if( $assignedTo && get_post( $assignedTo )) { |
| 219 | 228 | update_post_meta( $postId, 'assigned_to', $assignedTo ); |
@@ -226,7 +235,9 @@ discard block |
||
| 226 | 235 | */ |
| 227 | 236 | public function setQueryForColumn( WP_Query $query ) |
| 228 | 237 | { |
| 229 | - if( !$this->hasPermission( $query ))return; |
|
| 238 | + if( !$this->hasPermission( $query )) { |
|
| 239 | + return; |
|
| 240 | + } |
|
| 230 | 241 | $this->setMetaQuery( $query, [ |
| 231 | 242 | 'rating', 'review_type', |
| 232 | 243 | ]); |
@@ -297,7 +308,9 @@ discard block |
||
| 297 | 308 | protected function setMetaQuery( WP_Query $query, array $metaKeys ) |
| 298 | 309 | { |
| 299 | 310 | foreach( $metaKeys as $key ) { |
| 300 | - if( !( $value = filter_input( INPUT_GET, $key )))continue; |
|
| 311 | + if( !( $value = filter_input( INPUT_GET, $key ))) { |
|
| 312 | + continue; |
|
| 313 | + } |
|
| 301 | 314 | $metaQuery = (array)$query->get( 'meta_query' ); |
| 302 | 315 | $metaQuery[] = [ |
| 303 | 316 | 'key' => $key, |
@@ -70,7 +70,9 @@ discard block |
||
| 70 | 70 | public function getAssignedToPost( $post, $assignedTo = '' ) |
| 71 | 71 | { |
| 72 | 72 | $post = get_post( $post ); |
| 73 | - if( !( $post instanceof WP_Post ))return; |
|
| 73 | + if( !( $post instanceof WP_Post )) { |
|
| 74 | + return; |
|
| 75 | + } |
|
| 74 | 76 | if( empty( $assignedTo )) { |
| 75 | 77 | $assignedTo = get_post_meta( $post->ID, 'assigned_to', true ); |
| 76 | 78 | } |
@@ -88,7 +90,9 @@ discard block |
||
| 88 | 90 | */ |
| 89 | 91 | public function getReview( $post ) |
| 90 | 92 | { |
| 91 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
| 93 | + if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE ) { |
|
| 94 | + return; |
|
| 95 | + } |
|
| 92 | 96 | $review = $this->getReviewMeta( $post->ID ); |
| 93 | 97 | $modified = $this->isReviewModified( $post, $review ); |
| 94 | 98 | $review->content = $post->post_content; |
@@ -262,7 +266,9 @@ discard block |
||
| 262 | 266 | $termIds = array_map( 'trim', explode( ',', $termIds )); |
| 263 | 267 | foreach( $termIds as $termId ) { |
| 264 | 268 | $term = term_exists( $termId, Application::TAXONOMY ); |
| 265 | - if( !isset( $term['term_id'] ))continue; |
|
| 269 | + if( !isset( $term['term_id'] )) { |
|
| 270 | + continue; |
|
| 271 | + } |
|
| 266 | 272 | $terms[] = intval( $term['term_id'] ); |
| 267 | 273 | } |
| 268 | 274 | return $terms; |
@@ -275,7 +281,9 @@ discard block |
||
| 275 | 281 | public function revertReview( $postId ) |
| 276 | 282 | { |
| 277 | 283 | $post = get_post( $postId ); |
| 278 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
| 284 | + if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE ) { |
|
| 285 | + return; |
|
| 286 | + } |
|
| 279 | 287 | delete_post_meta( $post->ID, '_edit_last' ); |
| 280 | 288 | $result = wp_update_post([ |
| 281 | 289 | 'ID' => $post->ID, |
@@ -310,7 +318,9 @@ discard block |
||
| 310 | 318 | add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 ); |
| 311 | 319 | $search = new WP_Query( $args ); |
| 312 | 320 | remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 ); |
| 313 | - if( !$search->have_posts() )return; |
|
| 321 | + if( !$search->have_posts() ) { |
|
| 322 | + return; |
|
| 323 | + } |
|
| 314 | 324 | $results = ''; |
| 315 | 325 | while( $search->have_posts() ) { |
| 316 | 326 | $search->the_post(); |
@@ -334,7 +344,9 @@ discard block |
||
| 334 | 344 | public function setReviewMeta( $postId, $termIds ) |
| 335 | 345 | { |
| 336 | 346 | $terms = $this->normalizeTerms( $termIds ); |
| 337 | - if( empty( $terms ))return; |
|
| 347 | + if( empty( $terms )) { |
|
| 348 | + return; |
|
| 349 | + } |
|
| 338 | 350 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
| 339 | 351 | if( is_wp_error( $result )) { |
| 340 | 352 | glsr_log()->error( $result->get_error_message() ); |
@@ -48,7 +48,9 @@ |
||
| 48 | 48 | public function filterUpdateMessages( array $messages ) |
| 49 | 49 | { |
| 50 | 50 | $post = get_post(); |
| 51 | - if( !( $post instanceof WP_Post ))return; |
|
| 51 | + if( !( $post instanceof WP_Post )) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 52 | 54 | $strings = $this->getReviewLabels(); |
| 53 | 55 | $restored = filter_input( INPUT_GET, 'revision' ); |
| 54 | 56 | if( $revisionTitle = wp_post_revision_title( intval( $restored ), false )) { |
@@ -118,7 +118,9 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function registerMetaBoxes( $postType ) |
| 120 | 120 | { |
| 121 | - if( $postType != Application::POST_TYPE )return; |
|
| 121 | + if( $postType != Application::POST_TYPE ) { |
|
| 122 | + return; |
|
| 123 | + } |
|
| 122 | 124 | add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' ); |
| 123 | 125 | add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' ); |
| 124 | 126 | add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' ); |
@@ -148,7 +150,9 @@ discard block |
||
| 148 | 150 | */ |
| 149 | 151 | public function renderAssignedToMetabox( WP_Post $post ) |
| 150 | 152 | { |
| 151 | - if( !$this->isReviewPostType( $post ))return; |
|
| 153 | + if( !$this->isReviewPostType( $post )) { |
|
| 154 | + return; |
|
| 155 | + } |
|
| 152 | 156 | $assignedTo = (string)get_post_meta( $post->ID, 'assigned_to', true ); |
| 153 | 157 | wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false ); |
| 154 | 158 | glsr()->render( 'partials/editor/metabox-assigned-to', [ |
@@ -163,7 +167,9 @@ discard block |
||
| 163 | 167 | */ |
| 164 | 168 | public function renderDetailsMetaBox( WP_Post $post ) |
| 165 | 169 | { |
| 166 | - if( !$this->isReviewPostType( $post ))return; |
|
| 170 | + if( !$this->isReviewPostType( $post )) { |
|
| 171 | + return; |
|
| 172 | + } |
|
| 167 | 173 | $review = glsr( Database::class )->getReview( $post ); |
| 168 | 174 | glsr()->render( 'partials/editor/metabox-details', [ |
| 169 | 175 | 'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ), |
@@ -177,7 +183,9 @@ discard block |
||
| 177 | 183 | */ |
| 178 | 184 | public function renderPinnedInPublishMetaBox() |
| 179 | 185 | { |
| 180 | - if( !$this->isReviewPostType( get_post() ))return; |
|
| 186 | + if( !$this->isReviewPostType( get_post() )) { |
|
| 187 | + return; |
|
| 188 | + } |
|
| 181 | 189 | glsr( Html::class )->renderTemplate( 'partials/editor/pinned', [ |
| 182 | 190 | 'context' => [ |
| 183 | 191 | 'no' => __( 'No', 'site-reviews' ), |
@@ -193,7 +201,9 @@ discard block |
||
| 193 | 201 | */ |
| 194 | 202 | public function renderResponseMetaBox( WP_Post $post ) |
| 195 | 203 | { |
| 196 | - if( !$this->isReviewPostType( $post ))return; |
|
| 204 | + if( !$this->isReviewPostType( $post )) { |
|
| 205 | + return; |
|
| 206 | + } |
|
| 197 | 207 | wp_nonce_field( 'response', '_nonce-response', false ); |
| 198 | 208 | glsr()->render( 'partials/editor/metabox-response', [ |
| 199 | 209 | 'response' => glsr( Database::class )->getReview( $post )->response, |
@@ -207,7 +217,9 @@ discard block |
||
| 207 | 217 | */ |
| 208 | 218 | public function renderTaxonomyMetabox( WP_Post $post ) |
| 209 | 219 | { |
| 210 | - if( !$this->isReviewPostType( $post ))return; |
|
| 220 | + if( !$this->isReviewPostType( $post )) { |
|
| 221 | + return; |
|
| 222 | + } |
|
| 211 | 223 | glsr()->render( 'partials/editor/metabox-categories', [ |
| 212 | 224 | 'post' => $post, |
| 213 | 225 | 'tax_name' => Application::TAXONOMY, |
@@ -245,7 +257,9 @@ discard block |
||
| 245 | 257 | protected function buildAssignedToTemplate( $assignedTo, WP_Post $post ) |
| 246 | 258 | { |
| 247 | 259 | $assignedPost = glsr( Database::class )->getAssignedToPost( $post, $assignedTo ); |
| 248 | - if( !( $assignedPost instanceof WP_Post ))return; |
|
| 260 | + if( !( $assignedPost instanceof WP_Post )) { |
|
| 261 | + return; |
|
| 262 | + } |
|
| 249 | 263 | return glsr( Html::class )->buildTemplate( 'partials/editor/assigned-post', [ |
| 250 | 264 | 'context' => [ |
| 251 | 265 | 'data.url' => (string)get_permalink( $assignedPost ), |
@@ -287,7 +301,9 @@ discard block |
||
| 287 | 301 | */ |
| 288 | 302 | protected function getReviewType( $review ) |
| 289 | 303 | { |
| 290 | - if( count( glsr()->reviewTypes ) < 2 )return; |
|
| 304 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
| 305 | + return; |
|
| 306 | + } |
|
| 291 | 307 | $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes ) |
| 292 | 308 | ? glsr()->reviewTypes[$review->review_type] |
| 293 | 309 | : __( 'Unknown', 'site-reviews' ); |
@@ -19,13 +19,17 @@ discard block |
||
| 19 | 19 | public function build( array $args = [] ) |
| 20 | 20 | { |
| 21 | 21 | $this->args = $this->normalize( $args ); |
| 22 | - if( $this->args['total'] < 2 )return; |
|
| 22 | + if( $this->args['total'] < 2 ) { |
|
| 23 | + return; |
|
| 24 | + } |
|
| 23 | 25 | $links = $this->buildLinksForDeprecatedThemes(); |
| 24 | 26 | if( empty( $links )) { |
| 25 | 27 | $links = $this->buildLinks(); |
| 26 | 28 | } |
| 27 | 29 | $links = apply_filters( 'site-reviews/reviews/navigation_links', $links, $this->args ); |
| 28 | - if( empty( $links ))return; |
|
| 30 | + if( empty( $links )) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 29 | 33 | return $this->buildTemplate( $links ); |
| 30 | 34 | } |
| 31 | 35 | |
@@ -55,7 +59,9 @@ discard block |
||
| 55 | 59 | protected function buildLinksForDeprecatedThemes() |
| 56 | 60 | { |
| 57 | 61 | $theme = wp_get_theme()->get( 'TextDomain' ); |
| 58 | - if( !in_array( $theme, ['twentyten','twentyeleven','twentytwelve','twentythirteen'] ))return; |
|
| 62 | + if( !in_array( $theme, ['twentyten','twentyeleven','twentytwelve','twentythirteen'] )) { |
|
| 63 | + return; |
|
| 64 | + } |
|
| 59 | 65 | $links = ''; |
| 60 | 66 | if( $this->args['paged'] > 1 ) { |
| 61 | 67 | $links.= sprintf( '<div class="nav-previous"><a href="%s"><span class="meta-nav">←</span> %s</a></div>', |