@@ -2,31 +2,31 @@ |
||
| 2 | 2 | |
| 3 | 3 | $render->rating( 'rating', [ |
| 4 | 4 | 'label' => __( 'Your overall rating', 'site-reviews' ), |
| 5 | -]); |
|
| 5 | +] ); |
|
| 6 | 6 | $render->text( 'title', [ |
| 7 | 7 | 'label' => __( 'Title of your review', 'site-reviews' ), |
| 8 | 8 | 'placeholder' => __( 'Summarize your review or highlight an interesting detail', 'site-reviews' ), |
| 9 | -]); |
|
| 9 | +] ); |
|
| 10 | 10 | $render->textarea( 'content', [ |
| 11 | 11 | 'label' => __( 'Your review', 'site-reviews' ), |
| 12 | 12 | 'placeholder' => __( 'Tell people your review', 'site-reviews' ), |
| 13 | -]); |
|
| 13 | +] ); |
|
| 14 | 14 | $render->text( 'name', [ |
| 15 | 15 | 'label' => __( 'Your name', 'site-reviews' ), |
| 16 | 16 | 'placeholder' => __( 'Tell us your name', 'site-reviews' ), |
| 17 | -]); |
|
| 17 | +] ); |
|
| 18 | 18 | $render->email( 'email', [ |
| 19 | 19 | 'label' => __( 'Your email', 'site-reviews' ), |
| 20 | 20 | 'placeholder' => __( 'Tell us your email', 'site-reviews' ), |
| 21 | -]); |
|
| 21 | +] ); |
|
| 22 | 22 | $render->checkbox( 'terms', [ |
| 23 | 23 | 'label' => __( 'This review is based on my own experience and is my genuine opinion.', 'site-reviews' ), |
| 24 | -]); |
|
| 24 | +] ); |
|
| 25 | 25 | $render->honeypot( 'gotcha' ); |
| 26 | 26 | $render->hidden( 'assign_to' ); |
| 27 | 27 | $render->hidden( 'category' ); |
| 28 | 28 | $render->hidden( 'excluded' ); |
| 29 | 29 | $render->hidden( 'id' ); |
| 30 | 30 | wp_nonce_field( 'post-review' ); |
| 31 | -$render->submit( __( 'Submit your review', 'site-reviews' )); |
|
| 31 | +$render->submit( __( 'Submit your review', 'site-reviews' ) ); |
|
| 32 | 32 | $render->result(); |
@@ -197,7 +197,7 @@ |
||
| 197 | 197 | 'type' => 'text', |
| 198 | 198 | ], |
| 199 | 199 | 'settings.submissions.required' => [ |
| 200 | - 'default' => ['title','content','name','email'], |
|
| 200 | + 'default' => ['title', 'content', 'name', 'email'], |
|
| 201 | 201 | 'label' => __( 'Required Fields', 'site-reviews' ), |
| 202 | 202 | 'options' => [ |
| 203 | 203 | 'title' => __( 'Title', 'site-reviews' ), |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | 'post_type' => Application::POST_TYPE, |
| 33 | 33 | ]; |
| 34 | 34 | if( $review['review_type'] == 'local' && ( |
| 35 | - $this->options( 'settings.general.require.approval' ) == 'yes' || $command->blacklisted )) { |
|
| 35 | + $this->options( 'settings.general.require.approval' ) == 'yes' || $command->blacklisted ) ) { |
|
| 36 | 36 | $post['post_status'] = 'pending'; |
| 37 | 37 | } |
| 38 | 38 | $postId = wp_insert_post( $post, true ); |
| 39 | - if( is_wp_error( $postId )) { |
|
| 39 | + if( is_wp_error( $postId ) ) { |
|
| 40 | 40 | glsr_log()->error( '['.__METHOD__.'] '.$postId->get_error_message() ); |
| 41 | 41 | return false; |
| 42 | 42 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function deleteReview( $metaReviewId ) |
| 56 | 56 | { |
| 57 | - if( $postId = $this->getReviewPostId( $metaReviewId )) { |
|
| 57 | + if( $postId = $this->getReviewPostId( $metaReviewId ) ) { |
|
| 58 | 58 | wp_delete_post( $postId, true ); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function getReview( $post ) |
| 67 | 67 | { |
| 68 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
| 68 | + if( !($post instanceof WP_Post) || $post->post_type != Application::POST_TYPE )return; |
|
| 69 | 69 | $review = $this->getReviewMeta( $post->ID ); |
| 70 | 70 | $modified = $this->isReviewModified( $review ); |
| 71 | 71 | $review->content = $post->post_content; |
@@ -87,13 +87,13 @@ discard block |
||
| 87 | 87 | { |
| 88 | 88 | $metaKey = $this->normalizeMetaKey( $metaKey ); |
| 89 | 89 | if( !$metaKey ) { |
| 90 | - return (array) wp_count_posts( Application::POST_TYPE ); |
|
| 90 | + return (array)wp_count_posts( Application::POST_TYPE ); |
|
| 91 | 91 | } |
| 92 | 92 | $counts = glsr( Cache::class )->getReviewCountsFor( $metaKey ); |
| 93 | 93 | if( !$metaValue ) { |
| 94 | 94 | return $counts; |
| 95 | 95 | } |
| 96 | - return isset( $counts[$metaValue] ) |
|
| 96 | + return isset($counts[$metaValue]) |
|
| 97 | 97 | ? $counts[$metaValue] |
| 98 | 98 | : 0; |
| 99 | 99 | } |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | public function getReviewMeta( $postId ) |
| 115 | 115 | { |
| 116 | 116 | $meta = get_post_type( $postId ) == Application::POST_TYPE |
| 117 | - ? array_map( 'array_shift', (array) get_post_meta( $postId )) |
|
| 117 | + ? array_map( 'array_shift', (array)get_post_meta( $postId ) ) |
|
| 118 | 118 | : []; |
| 119 | - return (object) $this->normalizeMeta( array_filter( $meta, 'strlen' )); |
|
| 119 | + return (object)$this->normalizeMeta( array_filter( $meta, 'strlen' ) ); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $paged = glsr( QueryBuilder::class )->getPaged( |
| 146 | 146 | wp_validate_boolean( $args['pagination'] ) |
| 147 | 147 | ); |
| 148 | - $reviews = new WP_Query([ |
|
| 148 | + $reviews = new WP_Query( [ |
|
| 149 | 149 | 'meta_key' => 'pinned', |
| 150 | 150 | 'meta_query' => $metaQuery, |
| 151 | 151 | 'offset' => $args['offset'], |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | 'post_type' => Application::POST_TYPE, |
| 159 | 159 | 'posts_per_page' => $args['count'] ? $args['count'] : -1, |
| 160 | 160 | 'tax_query' => $taxQuery, |
| 161 | - ]); |
|
| 162 | - return (object) [ |
|
| 161 | + ] ); |
|
| 162 | + return (object)[ |
|
| 163 | 163 | 'results' => array_map( [$this, 'getReview'], $reviews->posts ), |
| 164 | 164 | 'max_num_pages' => $reviews->max_num_pages, |
| 165 | 165 | ]; |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | public function getReviewsMeta( $keys, $status = 'publish' ) |
| 174 | 174 | { |
| 175 | 175 | $keys = array_map( [$this, 'normalizeMetaKey'], (array)$keys ); |
| 176 | - if( $status == 'all' || empty( $status )) { |
|
| 176 | + if( $status == 'all' || empty($status) ) { |
|
| 177 | 177 | $status = get_post_stati( ['exclude_from_search' => false] ); |
| 178 | 178 | } |
| 179 | 179 | return glsr( SqlQueries::class )->getReviewsMeta( $keys, $status ); |
@@ -189,10 +189,10 @@ discard block |
||
| 189 | 189 | 'fields' => 'id=>name', |
| 190 | 190 | 'hide_empty' => false, |
| 191 | 191 | 'taxonomy' => Application::TAXONOMY, |
| 192 | - ]); |
|
| 193 | - unset( $args['count'] ); //we don't want a term count |
|
| 192 | + ] ); |
|
| 193 | + unset($args['count']); //we don't want a term count |
|
| 194 | 194 | $terms = get_terms( $args ); |
| 195 | - if( is_wp_error( $terms )) { |
|
| 195 | + if( is_wp_error( $terms ) ) { |
|
| 196 | 196 | glsr_log()->error( '['.__METHOD__.'] '.$terms->get_error_message() ); |
| 197 | 197 | return []; |
| 198 | 198 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public function normalizeMeta( array $meta ) |
| 206 | 206 | { |
| 207 | - if( empty( $meta )) { |
|
| 207 | + if( empty($meta) ) { |
|
| 208 | 208 | return []; |
| 209 | 209 | } |
| 210 | 210 | $defaults = wp_parse_args( $meta, [ |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | 'date' => '', |
| 213 | 213 | 'review_id' => '', |
| 214 | 214 | 'review_type' => '', |
| 215 | - ]); |
|
| 215 | + ] ); |
|
| 216 | 216 | return glsr( CreateReviewDefaults::class )->merge( $defaults, true ); |
| 217 | 217 | } |
| 218 | 218 | |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | public function normalizeMetaKey( $metaKey ) |
| 224 | 224 | { |
| 225 | 225 | $metaKey = strtolower( $metaKey ); |
| 226 | - if( in_array( $metaKey, ['id', 'type'] )) { |
|
| 226 | + if( in_array( $metaKey, ['id', 'type'] ) ) { |
|
| 227 | 227 | $metaKey = 'review_'.$metaKey; |
| 228 | 228 | } |
| 229 | 229 | return $metaKey; |
@@ -236,10 +236,10 @@ discard block |
||
| 236 | 236 | public function normalizeTerms( $termIds ) |
| 237 | 237 | { |
| 238 | 238 | $terms = []; |
| 239 | - $termIds = array_map( 'trim', explode( ',', $termIds )); |
|
| 239 | + $termIds = array_map( 'trim', explode( ',', $termIds ) ); |
|
| 240 | 240 | foreach( $termIds as $termId ) { |
| 241 | 241 | $term = term_exists( $termId, Application::TAXONOMY ); |
| 242 | - if( !isset( $term['term_id'] ))continue; |
|
| 242 | + if( !isset($term['term_id']) )continue; |
|
| 243 | 243 | $terms[] = intval( $term['term_id'] ); |
| 244 | 244 | } |
| 245 | 245 | return $terms; |
@@ -252,14 +252,14 @@ discard block |
||
| 252 | 252 | public function revertReview( $postId ) |
| 253 | 253 | { |
| 254 | 254 | $post = get_post( $postId ); |
| 255 | - if( !( $post instanceof WP_Post ) || $post->post_type != Application::POST_TYPE )return; |
|
| 255 | + if( !($post instanceof WP_Post) || $post->post_type != Application::POST_TYPE )return; |
|
| 256 | 256 | delete_post_meta( $post->ID, '_edit_last' ); |
| 257 | - return wp_update_post([ |
|
| 257 | + return wp_update_post( [ |
|
| 258 | 258 | 'ID' => $post->ID, |
| 259 | 259 | 'post_content' => get_post_meta( $post->ID, 'content', true ), |
| 260 | 260 | 'post_date' => get_post_meta( $post->ID, 'date', true ), |
| 261 | 261 | 'post_title' => get_post_meta( $post->ID, 'title', true ), |
| 262 | - ]); |
|
| 262 | + ] ); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | 'post_status' => 'publish', |
| 273 | 273 | 'post_type' => 'any', |
| 274 | 274 | ]; |
| 275 | - if( is_numeric( $searchTerm )) { |
|
| 275 | + if( is_numeric( $searchTerm ) ) { |
|
| 276 | 276 | $args['post__in'] = [$searchTerm]; |
| 277 | 277 | } |
| 278 | 278 | else { |
@@ -291,9 +291,9 @@ discard block |
||
| 291 | 291 | ob_start(); |
| 292 | 292 | glsr()->render( 'edit/search-result', [ |
| 293 | 293 | 'ID' => get_the_ID(), |
| 294 | - 'permalink' => esc_url( (string) get_permalink() ), |
|
| 294 | + 'permalink' => esc_url( (string)get_permalink() ), |
|
| 295 | 295 | 'title' => esc_attr( get_the_title() ), |
| 296 | - ]); |
|
| 296 | + ] ); |
|
| 297 | 297 | $results .= ob_get_clean(); |
| 298 | 298 | } |
| 299 | 299 | wp_reset_postdata(); |
@@ -308,9 +308,9 @@ discard block |
||
| 308 | 308 | public function setReviewMeta( $postId, $termIds ) |
| 309 | 309 | { |
| 310 | 310 | $terms = $this->normalizeTerms( $termIds ); |
| 311 | - if( empty( $terms ))return; |
|
| 311 | + if( empty($terms) )return; |
|
| 312 | 312 | $result = wp_set_object_terms( $postId, $terms, Application::TAXONOMY ); |
| 313 | - if( is_wp_error( $result )) { |
|
| 313 | + if( is_wp_error( $result ) ) { |
|
| 314 | 314 | glsr_log()->error( '['.__METHOD__.'] '.$result->get_error_message() ); |
| 315 | 315 | } |
| 316 | 316 | } |
@@ -16,7 +16,7 @@ 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']) )return; |
|
| 20 | 20 | $this->checkNonce( $request['action'] ); |
| 21 | 21 | switch( $request['action'] ) { |
| 22 | 22 | case 'clear-log': |
@@ -42,13 +42,13 @@ discard block |
||
| 42 | 42 | public function routeAjaxRequest() |
| 43 | 43 | { |
| 44 | 44 | $request = $this->normalizeAjaxRequest(); |
| 45 | - if( !wp_verify_nonce( $request['nonce'], $request['action'] )) { |
|
| 45 | + if( !wp_verify_nonce( $request['nonce'], $request['action'] ) ) { |
|
| 46 | 46 | glsr_log()->error( 'Nonce check failed for ajax request' )->info( $request ); |
| 47 | 47 | wp_die( -1, 403 ); |
| 48 | 48 | } |
| 49 | 49 | $controller = glsr( AjaxController::class ); |
| 50 | 50 | $method = glsr( Helper::class )->buildMethodName( $request['action'] ); |
| 51 | - if( is_callable( [$controller, $method] )) { |
|
| 51 | + if( is_callable( [$controller, $method] ) ) { |
|
| 52 | 52 | call_user_func( [$controller, $method], $request ); |
| 53 | 53 | } |
| 54 | 54 | else { |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function routePublicPostRequest() |
| 64 | 64 | { |
| 65 | - switch( filter_input( INPUT_POST, 'action' )) { |
|
| 65 | + switch( filter_input( INPUT_POST, 'action' ) ) { |
|
| 66 | 66 | case 'submit-review': |
| 67 | - glsr( PublicController::class )->routerSubmitReview( $this->normalize( $_POST )); |
|
| 67 | + glsr( PublicController::class )->routerSubmitReview( $this->normalize( $_POST ) ); |
|
| 68 | 68 | break; |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function routeWebhookRequest() |
| 76 | 76 | { |
| 77 | - $request = filter_input( INPUT_GET, sprintf( '%s-hook', Application::ID )); |
|
| 77 | + $request = filter_input( INPUT_GET, sprintf( '%s-hook', Application::ID ) ); |
|
| 78 | 78 | if( !$request )return; |
| 79 | 79 | // @todo manage webhook here |
| 80 | 80 | } |
@@ -112,14 +112,14 @@ discard block |
||
| 112 | 112 | protected function normalizeAjaxRequest() |
| 113 | 113 | { |
| 114 | 114 | $request = filter_input( INPUT_POST, 'request', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
| 115 | - if( isset( $request[Application::ID]['action'] )) { |
|
| 115 | + if( isset($request[Application::ID]['action']) ) { |
|
| 116 | 116 | $request = $request[Application::ID]; |
| 117 | 117 | } |
| 118 | - if( !isset( $request['action'] )) { |
|
| 118 | + if( !isset($request['action']) ) { |
|
| 119 | 119 | glsr_log()->error( 'The AJAX request must include an action' )->info( $request ); |
| 120 | 120 | wp_die(); |
| 121 | 121 | } |
| 122 | - if( !isset( $request['nonce'] )) { |
|
| 122 | + if( !isset($request['nonce']) ) { |
|
| 123 | 123 | glsr_log()->error( 'The AJAX request must include a nonce' )->info( $request ); |
| 124 | 124 | wp_die(); |
| 125 | 125 | } |
@@ -20,22 +20,22 @@ discard block |
||
| 20 | 20 | 'class' => 'widefat', |
| 21 | 21 | 'label' => __( 'Title', 'site-reviews' ), |
| 22 | 22 | 'name' => 'title', |
| 23 | - ]); |
|
| 23 | + ] ); |
|
| 24 | 24 | if( count( glsr()->reviewTypes ) > 1 ) { |
| 25 | 25 | $this->renderField( 'select', [ |
| 26 | 26 | 'class' => 'widefat', |
| 27 | 27 | 'label' => __( 'Which type of review would you like to use?', 'site-reviews' ), |
| 28 | 28 | 'name' => 'type', |
| 29 | 29 | 'options' => ['' => __( 'All review types', 'site-reviews' )] + glsr()->reviewTypes, |
| 30 | - ]); |
|
| 30 | + ] ); |
|
| 31 | 31 | } |
| 32 | - if( !empty( $terms )) { |
|
| 32 | + if( !empty($terms) ) { |
|
| 33 | 33 | $this->renderField( 'select', [ |
| 34 | 34 | 'class' => 'widefat', |
| 35 | 35 | 'label' => __( 'Limit summary to this category', 'site-reviews' ), |
| 36 | 36 | 'name' => 'category', |
| 37 | 37 | 'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms, |
| 38 | - ]); |
|
| 38 | + ] ); |
|
| 39 | 39 | } |
| 40 | 40 | $this->renderField( 'text', [ |
| 41 | 41 | 'class' => 'widefat', |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | 'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ), |
| 44 | 44 | 'label' => __( 'Limit summary to reviews assigned to a page/post ID', 'site-reviews' ), |
| 45 | 45 | 'name' => 'assigned_to', |
| 46 | - ]); |
|
| 46 | + ] ); |
|
| 47 | 47 | $this->renderField( 'text', [ |
| 48 | 48 | 'class' => 'widefat', |
| 49 | 49 | 'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ), |
| 50 | 50 | 'name' => 'class', |
| 51 | - ]); |
|
| 51 | + ] ); |
|
| 52 | 52 | $this->renderField( 'checkbox', [ |
| 53 | 53 | 'name' => 'hide', |
| 54 | 54 | 'options' => [ |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | 'summary' => __( 'Hide the summary text?', 'site-reviews' ), |
| 59 | 59 | 'if_empty' => __( 'Hide the summary if no reviews are found?', 'site-reviews' ), |
| 60 | 60 | ], |
| 61 | - ]); |
|
| 61 | + ] ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -20,30 +20,30 @@ discard block |
||
| 20 | 20 | 'class' => 'widefat', |
| 21 | 21 | 'label' => __( 'Title', 'site-reviews' ), |
| 22 | 22 | 'name' => 'title', |
| 23 | - ]); |
|
| 23 | + ] ); |
|
| 24 | 24 | $this->renderField( 'textarea', [ |
| 25 | 25 | 'class' => 'widefat', |
| 26 | 26 | 'label' => __( 'Description', 'site-reviews' ), |
| 27 | 27 | 'name' => 'description', |
| 28 | - ]); |
|
| 28 | + ] ); |
|
| 29 | 29 | $this->renderField( 'select', [ |
| 30 | 30 | 'class' => 'widefat', |
| 31 | 31 | 'label' => __( 'Automatically assign a category', 'site-reviews' ), |
| 32 | 32 | 'name' => 'category', |
| 33 | 33 | 'options' => ['' => __( 'Do not assign a category', 'site-reviews' )] + $terms, |
| 34 | - ]); |
|
| 34 | + ] ); |
|
| 35 | 35 | $this->renderField( 'text', [ |
| 36 | 36 | 'class' => 'widefat', |
| 37 | 37 | 'default' => '', |
| 38 | 38 | 'description' => sprintf( __( 'You may also enter %s to assign to the current post.', 'site-reviews' ), '<code>post_id</code>' ), |
| 39 | 39 | 'label' => __( 'Assign reviews to a custom page/post ID', 'site-reviews' ), |
| 40 | 40 | 'name' => 'assign_to', |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | $this->renderField( 'text', [ |
| 43 | 43 | 'class' => 'widefat', |
| 44 | 44 | 'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ), |
| 45 | 45 | 'name' => 'class', |
| 46 | - ]); |
|
| 46 | + ] ); |
|
| 47 | 47 | $this->renderField( 'checkbox', [ |
| 48 | 48 | 'name' => 'hide', |
| 49 | 49 | 'options' => [ |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | 'terms' => __( 'Hide the terms field', 'site-reviews' ), |
| 53 | 53 | 'title' => __( 'Hide the title field', 'site-reviews' ), |
| 54 | 54 | ], |
| 55 | - ]); |
|
| 55 | + ] ); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | 'class' => 'widefat', |
| 21 | 21 | 'label' => __( 'Title', 'site-reviews' ), |
| 22 | 22 | 'name' => 'title', |
| 23 | - ]); |
|
| 23 | + ] ); |
|
| 24 | 24 | $this->renderField( 'number', [ |
| 25 | 25 | 'class' => 'small-text', |
| 26 | 26 | 'default' => 5, |
| 27 | 27 | 'label' => __( 'How many reviews would you like to display?', 'site-reviews' ), |
| 28 | 28 | 'max' => 100, |
| 29 | 29 | 'name' => 'count', |
| 30 | - ]); |
|
| 30 | + ] ); |
|
| 31 | 31 | $this->renderField( 'select', [ |
| 32 | 32 | 'label' => __( 'What is the minimum rating to display?', 'site-reviews' ), |
| 33 | 33 | 'name' => 'rating', |
@@ -38,22 +38,22 @@ discard block |
||
| 38 | 38 | '2' => sprintf( _n( '%s star', '%s stars', 2, 'site-reviews' ), 2 ), |
| 39 | 39 | '1' => sprintf( _n( '%s star', '%s stars', 1, 'site-reviews' ), 1 ), |
| 40 | 40 | ], |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | if( count( glsr()->reviewTypes ) > 1 ) { |
| 43 | 43 | $this->renderField( 'select', [ |
| 44 | 44 | 'class' => 'widefat', |
| 45 | 45 | 'label' => __( 'Which reviews would you like to display?', 'site-reviews' ), |
| 46 | 46 | 'name' => 'display', |
| 47 | 47 | 'options' => ['' => __( 'All Reviews', 'site-reviews' )] + glsr()->reviewTypes, |
| 48 | - ]); |
|
| 48 | + ] ); |
|
| 49 | 49 | } |
| 50 | - if( !empty( $terms )) { |
|
| 50 | + if( !empty($terms) ) { |
|
| 51 | 51 | $this->renderField( 'select', [ |
| 52 | 52 | 'class' => 'widefat', |
| 53 | 53 | 'label' => __( 'Limit reviews to this category', 'site-reviews' ), |
| 54 | 54 | 'name' => 'category', |
| 55 | 55 | 'options' => ['' => __( 'All Categories', 'site-reviews' )] + $terms, |
| 56 | - ]); |
|
| 56 | + ] ); |
|
| 57 | 57 | } |
| 58 | 58 | $this->renderField( 'text', [ |
| 59 | 59 | 'class' => 'widefat', |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | 'description' => sprintf( __( "Separate multiple ID's with a comma. You may also enter %s to automatically represent the current page/post ID.", 'site-reviews' ), '<code>post_id</code>' ), |
| 62 | 62 | 'label' => __( 'Limit reviews to those assigned to this page/post ID', 'site-reviews' ), |
| 63 | 63 | 'name' => 'assigned_to', |
| 64 | - ]); |
|
| 64 | + ] ); |
|
| 65 | 65 | $this->renderField( 'text', [ |
| 66 | 66 | 'class' => 'widefat', |
| 67 | 67 | 'label' => __( 'Enter any custom CSS classes here', 'site-reviews' ), |
| 68 | 68 | 'name' => 'class', |
| 69 | - ]); |
|
| 69 | + ] ); |
|
| 70 | 70 | $this->renderField( 'checkbox', [ |
| 71 | 71 | 'name' => 'hide', |
| 72 | 72 | 'options' => [ |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 'response' => __( 'Hide the review response?', 'site-reviews' ), |
| 78 | 78 | 'title' => __( 'Hide the review title?', 'site-reviews' ), |
| 79 | 79 | ], |
| 80 | - ]); |
|
| 80 | + ] ); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -87,10 +87,10 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function update( $newInstance, $oldInstance ) |
| 89 | 89 | { |
| 90 | - if( !is_numeric( $newInstance['count'] )) { |
|
| 90 | + if( !is_numeric( $newInstance['count'] ) ) { |
|
| 91 | 91 | $newInstance['count'] = 10; |
| 92 | 92 | } |
| 93 | - $newInstance['count'] = min( 50, max( 0, intval( $newInstance['count'] ))); |
|
| 93 | + $newInstance['count'] = min( 50, max( 0, intval( $newInstance['count'] ) ) ); |
|
| 94 | 94 | return parent::update( $newInstance, $oldInstance ); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -15,13 +15,13 @@ discard block |
||
| 15 | 15 | public function __construct( $idBase, $name, $values ) |
| 16 | 16 | { |
| 17 | 17 | $controlOptions = $widgetOptions = []; |
| 18 | - if( isset( $values['class'] )) { |
|
| 18 | + if( isset($values['class']) ) { |
|
| 19 | 19 | $widgetOptions['classname'] = $values['class']; |
| 20 | 20 | } |
| 21 | - if( isset( $values['description'] )) { |
|
| 21 | + if( isset($values['description']) ) { |
|
| 22 | 22 | $widgetOptions['description'] = $values['description']; |
| 23 | 23 | } |
| 24 | - if( isset( $values['width'] )) { |
|
| 24 | + if( isset($values['width']) ) { |
|
| 25 | 25 | $controlOptions['width'] = $values['width']; |
| 26 | 26 | } |
| 27 | 27 | parent::__construct( $idBase, $name, $widgetOptions, $controlOptions ); |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | protected function renderField( $tag, array $args = [] ) |
| 35 | 35 | { |
| 36 | 36 | $args = $this->normalizeFieldAttributes( $tag, $args ); |
| 37 | - $field = glsr( Builder::class )->{$tag}( $args['name'], $args ); |
|
| 37 | + $field = glsr( Builder::class )->{$tag}($args['name'], $args); |
|
| 38 | 38 | echo glsr( Builder::class )->div( $field, [ |
| 39 | 39 | 'class' => 'glsr-field', |
| 40 | - ]); |
|
| 40 | + ] ); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | protected function normalizeFieldAttributes( $tag, array $args ) |
| 48 | 48 | { |
| 49 | - if( empty( $args['value'] )) { |
|
| 49 | + if( empty($args['value']) ) { |
|
| 50 | 50 | $args['value'] = $this->widgetArgs[$args['name']]; |
| 51 | 51 | } |
| 52 | - if( empty( $this->widgetArgs['options'] ) && in_array( $tag, ['checkbox', 'radio'] )) { |
|
| 52 | + if( empty($this->widgetArgs['options']) && in_array( $tag, ['checkbox', 'radio'] ) ) { |
|
| 53 | 53 | $args['checked'] = in_array( $args['value'], (array)$this->widgetArgs[$args['name']] ); |
| 54 | 54 | } |
| 55 | 55 | $args['id'] = $this->get_field_id( $args['name'] ); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function getDefaults() |
| 68 | 68 | { |
| 69 | - if( empty( $this->defaults )) { |
|
| 69 | + if( empty($this->defaults) ) { |
|
| 70 | 70 | $this->defaults = $this->make( DefaultsManager::class )->get(); |
| 71 | 71 | $this->upgrade(); |
| 72 | 72 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function hasPermission() |
| 80 | 80 | { |
| 81 | - return !$this->isAdmin() || ( $this->isAdmin() && current_user_can( static::CAPABILITY )); |
|
| 81 | + return !$this->isAdmin() || ($this->isAdmin() && current_user_can( static::CAPABILITY )); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $types = apply_filters( 'site-reviews/addon/types', [] ); |
| 134 | 134 | $this->reviewTypes = wp_parse_args( $types, [ |
| 135 | 135 | 'local' => __( 'Local', 'site-reviews' ), |
| 136 | - ]); |
|
| 136 | + ] ); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function scheduleCronJob() |
| 154 | 154 | { |
| 155 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
| 155 | + if( wp_next_scheduled( static::CRON_EVENT ) )return; |
|
| 156 | 156 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
| 157 | 157 | } |
| 158 | 158 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function unscheduleCronJob() |
| 163 | 163 | { |
| 164 | - wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT ); |
|
| 164 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -193,6 +193,6 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public function url( $path = '' ) |
| 195 | 195 | { |
| 196 | - return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
| 196 | + return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
| 197 | 197 | } |
| 198 | 198 | } |