@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function onCreateReview( $postData, $meta, $postId ) |
| 24 | 24 | { |
| 25 | - if( !$this->isReviewPostType( $review = get_post( $postId )))return; |
|
| 25 | + if( !$this->isReviewPostType( $review = get_post( $postId ) ) )return; |
|
| 26 | 26 | $this->updateAssignedToPost( $review ); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function onDeleteReview( $postId ) |
| 34 | 34 | { |
| 35 | - if( !$this->isReviewPostType( $review = get_post( $postId )))return; |
|
| 35 | + if( !$this->isReviewPostType( $review = get_post( $postId ) ) )return; |
|
| 36 | 36 | $review->post_status = 'deleted'; // important to change the post_status here first! |
| 37 | 37 | $this->updateAssignedToPost( $review ); |
| 38 | 38 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function saveAssignedToMetabox( $postId ) |
| 54 | 54 | { |
| 55 | - if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
| 55 | + if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ) )return; |
|
| 56 | 56 | $assignedTo = filter_input( INPUT_POST, 'assigned_to' ); |
| 57 | 57 | $assignedTo || $assignedTo = ''; |
| 58 | 58 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function saveResponseMetabox( $postId ) |
| 69 | 69 | { |
| 70 | - if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ))return; |
|
| 70 | + if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ) )return; |
|
| 71 | 71 | $response = filter_input( INPUT_POST, 'response' ); |
| 72 | 72 | $response || $response = ''; |
| 73 | 73 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
| 74 | 74 | 'a' => ['href' => [], 'title' => []], |
| 75 | 75 | 'em' => [], |
| 76 | 76 | 'strong' => [], |
| 77 | - ]))); |
|
| 77 | + ] ) ) ); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | protected function getAssignedToPostId( $postId ) |
| 85 | 85 | { |
| 86 | - $assignedTo = intval( get_post_meta( $postId, 'assigned_to', true )); |
|
| 87 | - if(( $post = get_post( $assignedTo )) instanceof WP_Post ) { |
|
| 86 | + $assignedTo = intval( get_post_meta( $postId, 'assigned_to', true ) ); |
|
| 87 | + if( ($post = get_post( $assignedTo )) instanceof WP_Post ) { |
|
| 88 | 88 | return $post->ID; |
| 89 | 89 | } |
| 90 | 90 | return false; |
@@ -120,22 +120,22 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | protected function updateAssignedToPost( WP_Post $review ) |
| 122 | 122 | { |
| 123 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
| 124 | - $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
|
| 125 | - if( empty( $reviewIds ))return; |
|
| 123 | + if( !($postId = $this->getAssignedToPostId( $review->ID )) )return; |
|
| 124 | + $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) ); |
|
| 125 | + if( empty($reviewIds) )return; |
|
| 126 | 126 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
| 127 | - $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
|
| 128 | - if( empty( $updatedReviewIds )) { |
|
| 127 | + $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) ); |
|
| 128 | + if( empty($updatedReviewIds) ) { |
|
| 129 | 129 | delete_post_meta( $postId, static::META_RANKING ); |
| 130 | 130 | delete_post_meta( $postId, static::META_REVIEW_ID ); |
| 131 | 131 | } |
| 132 | - else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds )) { |
|
| 133 | - $reviews = glsr( Database::class )->getReviews([ |
|
| 132 | + else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds ) ) { |
|
| 133 | + $reviews = glsr( Database::class )->getReviews( [ |
|
| 134 | 134 | 'count' => -1, |
| 135 | 135 | 'post__in' => $updatedReviewIds, |
| 136 | - ]); |
|
| 137 | - update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results )); |
|
| 138 | - update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results )); |
|
| 136 | + ] ); |
|
| 137 | + update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results ) ); |
|
| 138 | + update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results ) ); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | if( $review->post_status != 'publish' ) { |
| 149 | 149 | delete_post_meta( $postId, static::META_REVIEW_ID, $review->ID ); |
| 150 | 150 | } |
| 151 | - else if( !in_array( $review->ID, $reviewIds )) { |
|
| 151 | + else if( !in_array( $review->ID, $reviewIds ) ) { |
|
| 152 | 152 | add_post_meta( $postId, static::META_REVIEW_ID, $review->ID ); |
| 153 | 153 | } |
| 154 | 154 | } |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | foreach( glsr( Database::class )->getReviews( $this->args )->reviews as $review ) { |
| 33 | 33 | $reviews[] = $this->buildReview( $review ); |
| 34 | 34 | } |
| 35 | - if( !empty( $reviews )) { |
|
| 35 | + if( !empty($reviews) ) { |
|
| 36 | 36 | array_walk( $reviews, function( &$review ) { |
| 37 | - unset( $review['@context'] ); |
|
| 38 | - unset( $review['itemReviewed'] ); |
|
| 37 | + unset($review['@context']); |
|
| 38 | + unset($review['itemReviewed']); |
|
| 39 | 39 | }); |
| 40 | 40 | $schema['review'] = $reviews; |
| 41 | 41 | } |
@@ -49,20 +49,20 @@ discard block |
||
| 49 | 49 | public function buildReview( $review ) |
| 50 | 50 | { |
| 51 | 51 | $schema = SchemaOrg::Review() |
| 52 | - ->doIf( !in_array( 'title', $this->args['hide'] ), function( ReviewSchema $schema ) use( $review ) { |
|
| 52 | + ->doIf( !in_array( 'title', $this->args['hide'] ), function( ReviewSchema $schema ) use($review) { |
|
| 53 | 53 | $schema->name( $review->title ); |
| 54 | 54 | }) |
| 55 | - ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( ReviewSchema $schema ) use( $review ) { |
|
| 55 | + ->doIf( !in_array( 'excerpt', $this->args['hide'] ), function( ReviewSchema $schema ) use($review) { |
|
| 56 | 56 | $schema->reviewBody( $review->content ); |
| 57 | 57 | }) |
| 58 | - ->datePublished(( new DateTime( $review->date ))->format( DateTime::ISO8601 )) |
|
| 58 | + ->datePublished( (new DateTime( $review->date ))->format( DateTime::ISO8601 ) ) |
|
| 59 | 59 | ->author( SchemaOrg::Person() |
| 60 | 60 | ->name( $review->author ) |
| 61 | 61 | ) |
| 62 | 62 | ->itemReviewed( $this->getSchemaType() |
| 63 | 63 | ->name( $this->getThingName() ) |
| 64 | 64 | ); |
| 65 | - if( !empty( $review->rating )) { |
|
| 65 | + if( !empty($review->rating) ) { |
|
| 66 | 66 | $schema->reviewRating( SchemaOrg::Rating() |
| 67 | 67 | ->ratingValue( $review->rating ) |
| 68 | 68 | ->bestRating( Rating::MAX_RATING ) |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function buildSummary( $args = null ) |
| 80 | 80 | { |
| 81 | - if( is_array( $args )) { |
|
| 81 | + if( is_array( $args ) ) { |
|
| 82 | 82 | $this->args = $args; |
| 83 | 83 | } |
| 84 | 84 | $schema = $this->getSchemaType() |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | ->image( $this->getThingImage() ) |
| 91 | 91 | ->url( $this->getThingUrl() ); |
| 92 | 92 | $count = $this->getReviewCount(); |
| 93 | - if( !empty( $count )) { |
|
| 93 | + if( !empty($count) ) { |
|
| 94 | 94 | $schema->aggregateRating( SchemaOrg::AggregateRating() |
| 95 | 95 | ->ratingValue( $this->getRatingValue() ) |
| 96 | 96 | ->reviewCount( $count ) |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function render() |
| 110 | 110 | { |
| 111 | - if( is_null( glsr()->schemas ))return; |
|
| 111 | + if( is_null( glsr()->schemas ) )return; |
|
| 112 | 112 | printf( '<script type="application/ld+json">%s</script>', json_encode( |
| 113 | 113 | apply_filters( 'site-reviews/schema/all', glsr()->schemas ), |
| 114 | 114 | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES |
| 115 | - )); |
|
| 115 | + ) ); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function store( array $schema ) |
| 122 | 122 | { |
| 123 | - $schemas = (array) glsr()->schemas; |
|
| 123 | + $schemas = (array)glsr()->schemas; |
|
| 124 | 124 | $schemas[] = $schema; |
| 125 | - glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ))); |
|
| 125 | + glsr()->schemas = array_map( 'unserialize', array_unique( array_map( 'serialize', $schemas ) ) ); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | protected function getReviews( $force = false ) |
| 149 | 149 | { |
| 150 | - if( !isset( $this->reviews ) || $force ) { |
|
| 150 | + if( !isset($this->reviews) || $force ) { |
|
| 151 | 151 | $args = wp_parse_args( ['count' => -1], $this->args ); |
| 152 | 152 | $this->reviews = glsr( Database::class )->getReviews( $args )->reviews; |
| 153 | 153 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | protected function getSchemaOption( $option, $fallback ) |
| 163 | 163 | { |
| 164 | - if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ))) { |
|
| 164 | + if( $schemaOption = trim( (string)get_post_meta( intval( get_the_ID() ), 'schema_'.$option, true ) ) ) { |
|
| 165 | 165 | return $schemaOption; |
| 166 | 166 | } |
| 167 | 167 | $default = glsr( OptionManager::class )->get( 'settings.reviews.schema.'.$option.'.default', $fallback ); |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function get() |
| 110 | 110 | { |
| 111 | - return empty( $this->log ) |
|
| 111 | + return empty($this->log) |
|
| 112 | 112 | ? __( 'Log is empty', 'site-reviews' ) |
| 113 | 113 | : $this->log; |
| 114 | 114 | } |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $constants = (new ReflectionClass( __CLASS__ ))->getConstants(); |
| 136 | 136 | $constants = (array)apply_filters( 'site-reviews/log-levels', $constants ); |
| 137 | - if( in_array( $level, $constants, true )) { |
|
| 137 | + if( in_array( $level, $constants, true ) ) { |
|
| 138 | 138 | $entry = $this->buildLogEntry( $level, $message, $context ); |
| 139 | - file_put_contents( $this->file, $entry, FILE_APPEND|LOCK_EX ); |
|
| 139 | + file_put_contents( $this->file, $entry, FILE_APPEND | LOCK_EX ); |
|
| 140 | 140 | $this->reset(); |
| 141 | 141 | } |
| 142 | 142 | return $this; |
@@ -186,15 +186,15 @@ discard block |
||
| 186 | 186 | protected function getDebugInformation() |
| 187 | 187 | { |
| 188 | 188 | $caller = debug_backtrace( 0, 6 ); |
| 189 | - $index = array_search( 'log', array_column( $caller, 'function' )); |
|
| 189 | + $index = array_search( 'log', array_column( $caller, 'function' ) ); |
|
| 190 | 190 | if( $index === false |
| 191 | - || !isset( $caller[$index+2]['class'] ) |
|
| 192 | - || !isset( $caller[$index+2]['function'] ) |
|
| 191 | + || !isset($caller[$index + 2]['class']) |
|
| 192 | + || !isset($caller[$index + 2]['function']) |
|
| 193 | 193 | )return; |
| 194 | 194 | return sprintf( '[%s()->%s:%s] ', |
| 195 | - $caller[$index+2]['class'], |
|
| 196 | - $caller[$index+2]['function'], |
|
| 197 | - $caller[$index+1]['line'] |
|
| 195 | + $caller[$index + 2]['class'], |
|
| 196 | + $caller[$index + 2]['function'], |
|
| 197 | + $caller[$index + 1]['line'] |
|
| 198 | 198 | ); |
| 199 | 199 | } |
| 200 | 200 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | protected function interpolate( $message, $context = [] ) |
| 208 | 208 | { |
| 209 | - if( $this->isObjectOrArray( $message ) || !is_array( $context )) { |
|
| 209 | + if( $this->isObjectOrArray( $message ) || !is_array( $context ) ) { |
|
| 210 | 210 | return print_r( $message, true ); |
| 211 | 211 | } |
| 212 | 212 | $replace = []; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | if( $value instanceof DateTime ) { |
| 235 | 235 | $value = $value->format( 'Y-m-d H:i:s' ); |
| 236 | 236 | } |
| 237 | - else if( $this->isObjectOrArray( $value )) { |
|
| 237 | + else if( $this->isObjectOrArray( $value ) ) { |
|
| 238 | 238 | $value = json_encode( $value ); |
| 239 | 239 | } |
| 240 | 240 | return (string)$value; |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | $this->clear(); |
| 251 | 251 | file_put_contents( |
| 252 | 252 | $this->file, |
| 253 | - $this->buildLogEntry( 'info', __( 'Log has been automatically reset (512 KB max size)', 'site-reviews' )) |
|
| 253 | + $this->buildLogEntry( 'info', __( 'Log has been automatically reset (512 KB max size)', 'site-reviews' ) ) |
|
| 254 | 254 | ); |
| 255 | 255 | } |
| 256 | 256 | } |
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | $ipAddresses = array_fill_keys( ['v4', 'v6'], [] ); |
| 20 | 20 | foreach( array_keys( $ipAddresses ) as $version ) { |
| 21 | 21 | $response = wp_remote_get( 'https://www.cloudflare.com/ips-'.$version ); |
| 22 | - if( is_wp_error( $response )) { |
|
| 22 | + if( is_wp_error( $response ) ) { |
|
| 23 | 23 | glsr_log()->error( $response->get_error_message() ); |
| 24 | 24 | continue; |
| 25 | 25 | } |
| 26 | - $ipAddresses[$version] = array_filter( explode( PHP_EOL, wp_remote_retrieve_body( $response ))); |
|
| 26 | + $ipAddresses[$version] = array_filter( explode( PHP_EOL, wp_remote_retrieve_body( $response ) ) ); |
|
| 27 | 27 | } |
| 28 | 28 | set_transient( Application::ID.'_cloudflare_ips', $ipAddresses, static::EXPIRY_TIME ); |
| 29 | 29 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | if( $test === false ) { |
| 58 | 58 | $response = wp_remote_post( 'https://api.wordpress.org/stats/php/1.0/' ); |
| 59 | 59 | $test = !is_wp_error( $response ) |
| 60 | - && in_array( $response['response']['code'], range( 200, 299 )) |
|
| 60 | + && in_array( $response['response']['code'], range( 200, 299 ) ) |
|
| 61 | 61 | ? 'Works' |
| 62 | 62 | : 'Does not work'; |
| 63 | 63 | set_transient( Application::ID.'_remote_post_test', $test, static::EXPIRY_TIME ); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | 'name' => 'tripadvisor', |
| 13 | 13 | 'title' => 'Tripadvisor Reviews', |
| 14 | 14 | ], |
| 15 | - ]); |
|
| 15 | + ] ); |
|
| 16 | 16 | $template->render( 'partials/addons/addon', [ |
| 17 | 17 | 'context' => [ |
| 18 | 18 | 'description' => __( 'Sync your Yelp reviews and display them on your site.', 'site-reviews' ), |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | 'name' => 'yelp', |
| 21 | 21 | 'title' => 'Yelp Reviews', |
| 22 | 22 | ], |
| 23 | - ]); |
|
| 23 | + ] ); |
|
| 24 | 24 | ?> |
| 25 | 25 | </div> |
| 26 | 26 | </div> |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | <p>{{ data.s1 }}</p> |
| 4 | 4 | <p>{{ data.p1 }}</p> |
| 5 | 5 | <p class="row-actions"> |
| 6 | - <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' );?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
| 6 | + <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' ); ?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
| 7 | 7 | </p> |
| 8 | 8 | <button type="button" class="toggle-row"> |
| 9 | 9 | <span class="screen-reader-text"><?= __( 'Show custom translation', 'site-reviews' ); ?></span> |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | <td class="glsr-string-td1 column-primary"> |
| 3 | 3 | <p>{{ data.s1 }}</p> |
| 4 | 4 | <p class="row-actions"> |
| 5 | - <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' );?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
| 5 | + <span class="delete"><a href="#{{ data.index }}" class="delete" aria-label="<?= __( 'Delete translation string', 'site-reviews' ); ?>"><?= __( 'Delete', 'site-reviews' ); ?></a></span> |
|
| 6 | 6 | </p> |
| 7 | 7 | <button type="button" class="toggle-row"> |
| 8 | 8 | <span class="screen-reader-text"><?= __( 'Show custom translation', 'site-reviews' ); ?></span> |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | </ul> |
| 21 | 21 | </div> |
| 22 | 22 | |
| 23 | - <?php if( current_user_can( $taxonomy->cap->edit_terms )) : ?> |
|
| 23 | + <?php if( current_user_can( $taxonomy->cap->edit_terms ) ) : ?> |
|
| 24 | 24 | <div id="<?= $tax_name; ?>-adder" class="wp-hidden-children"> |
| 25 | 25 | <a id="<?= $tax_name; ?>-add-toggle" href="#<?= $tax_name; ?>-add" class="hide-if-no-js taxonomy-add-new"> |
| 26 | 26 | <?= sprintf( '+ %s', $taxonomy->labels->add_new_item ); ?> |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | <label class="screen-reader-text" for="new<?= $tax_name; ?>"><?= $taxonomy->labels->add_new_item; ?></label> |
| 30 | 30 | <input type="text" name="new<?= $tax_name; ?>" id="new<?= $tax_name; ?>" class="form-required form-input-tip" value="<?= esc_attr( $taxonomy->labels->new_item_name ); ?>" aria-required="true"/> |
| 31 | 31 | <input type="button" id="<?= $tax_name; ?>-add-submit" data-wp-lists="add:<?= $tax_name; ?>checklist:<?= $tax_name; ?>-add" class="button category-add-submit" value="<?= esc_attr( $taxonomy->labels->add_new_item ); ?>" /> |
| 32 | - <?php wp_nonce_field( 'add-' . $tax_name, '_ajax_nonce-add-' . $tax_name, false ); ?> |
|
| 32 | + <?php wp_nonce_field( 'add-'.$tax_name, '_ajax_nonce-add-'.$tax_name, false ); ?> |
|
| 33 | 33 | <span id="<?= $tax_name; ?>-ajax-response"></span> |
| 34 | 34 | </div> |
| 35 | 35 | </div> |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php defined( 'WPINC' ) || die; |
| 2 | 2 | |
| 3 | -include trailingslashit(__DIR__).'header.php'; |
|
| 4 | -include trailingslashit(__DIR__).'body.php'; |
|
| 5 | -include trailingslashit(__DIR__).'footer.php'; |
|
| 3 | +include trailingslashit( __DIR__ ).'header.php'; |
|
| 4 | +include trailingslashit( __DIR__ ).'body.php'; |
|
| 5 | +include trailingslashit( __DIR__ ).'footer.php'; |
|