@@ -23,7 +23,9 @@ discard block |
||
| 23 | 23 | if( empty( $assignedTo )) { |
| 24 | 24 | $assignedTo = get_post_meta( $postId, 'assigned_to', true ); |
| 25 | 25 | } |
| 26 | - if( empty( $assignedTo ))return; |
|
| 26 | + if( empty( $assignedTo )) { |
|
| 27 | + return; |
|
| 28 | + } |
|
| 27 | 29 | $assignedPost = get_post( $assignedTo ); |
| 28 | 30 | if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) { |
| 29 | 31 | return $assignedPost; |
@@ -80,7 +82,9 @@ discard block |
||
| 80 | 82 | $termIds = []; |
| 81 | 83 | foreach( $values as $value ) { |
| 82 | 84 | $term = get_term_by( $field, $value, Application::TAXONOMY ); |
| 83 | - if( !isset( $term->term_id ))continue; |
|
| 85 | + if( !isset( $term->term_id )) { |
|
| 86 | + continue; |
|
| 87 | + } |
|
| 84 | 88 | $termIds[] = $term->term_id; |
| 85 | 89 | } |
| 86 | 90 | return $termIds; |
@@ -127,7 +131,9 @@ discard block |
||
| 127 | 131 | add_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500, 2 ); |
| 128 | 132 | $search = new WP_Query( $args ); |
| 129 | 133 | remove_filter( 'posts_search', [$queryBuilder, 'filterSearchByTitle'], 500 ); |
| 130 | - if( !$search->have_posts() )return; |
|
| 134 | + if( !$search->have_posts() ) { |
|
| 135 | + return; |
|
| 136 | + } |
|
| 131 | 137 | $results = ''; |
| 132 | 138 | while( $search->have_posts() ) { |
| 133 | 139 | $search->the_post(); |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | public function getAssignedToPost( $postId, $assignedTo = '' ) |
| 22 | 22 | { |
| 23 | - if( empty( $assignedTo )) { |
|
| 23 | + if( empty($assignedTo) ) { |
|
| 24 | 24 | $assignedTo = get_post_meta( $postId, 'assigned_to', true ); |
| 25 | 25 | } |
| 26 | - if( empty( $assignedTo ))return; |
|
| 26 | + if( empty($assignedTo) )return; |
|
| 27 | 27 | $assignedPost = get_post( $assignedTo ); |
| 28 | 28 | if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) { |
| 29 | 29 | return $assignedPost; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function getReviewsMeta( $key, $status = 'publish' ) |
| 65 | 65 | { |
| 66 | - if( $status == 'all' || empty( $status )) { |
|
| 66 | + if( $status == 'all' || empty($status) ) { |
|
| 67 | 67 | $status = get_post_stati( ['exclude_from_search' => false] ); |
| 68 | 68 | } |
| 69 | 69 | return glsr( SqlQueries::class )->getReviewsMeta( $key, $status ); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $termIds = []; |
| 79 | 79 | foreach( $values as $value ) { |
| 80 | 80 | $term = get_term_by( $field, $value, Application::TAXONOMY ); |
| 81 | - if( !isset( $term->term_id ))continue; |
|
| 81 | + if( !isset($term->term_id) )continue; |
|
| 82 | 82 | $termIds[] = $term->term_id; |
| 83 | 83 | } |
| 84 | 84 | return $termIds; |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | 'fields' => 'id=>name', |
| 95 | 95 | 'hide_empty' => false, |
| 96 | 96 | 'taxonomy' => Application::TAXONOMY, |
| 97 | - ]); |
|
| 97 | + ] ); |
|
| 98 | 98 | $terms = get_terms( $args ); |
| 99 | - if( is_wp_error( $terms )) { |
|
| 99 | + if( is_wp_error( $terms ) ) { |
|
| 100 | 100 | glsr_log()->error( $terms->get_error_message() ); |
| 101 | 101 | return []; |
| 102 | 102 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | 'post_status' => 'publish', |
| 114 | 114 | 'post_type' => 'any', |
| 115 | 115 | ]; |
| 116 | - if( is_numeric( $searchTerm )) { |
|
| 116 | + if( is_numeric( $searchTerm ) ) { |
|
| 117 | 117 | $args['post__in'] = [$searchTerm]; |
| 118 | 118 | } |
| 119 | 119 | else { |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | ob_start(); |
| 133 | 133 | glsr()->render( 'partials/editor/search-result', [ |
| 134 | 134 | 'ID' => get_the_ID(), |
| 135 | - 'permalink' => esc_url( (string) get_permalink() ), |
|
| 135 | + 'permalink' => esc_url( (string)get_permalink() ), |
|
| 136 | 136 | 'title' => esc_attr( get_the_title() ), |
| 137 | - ]); |
|
| 137 | + ] ); |
|
| 138 | 138 | $results .= ob_get_clean(); |
| 139 | 139 | } |
| 140 | 140 | wp_reset_postdata(); |
@@ -6,7 +6,8 @@ |
||
| 6 | 6 | |
| 7 | 7 | class SiteReviewsSummaryShortcode extends Shortcode |
| 8 | 8 | { |
| 9 | - protected function hideOptions() { |
|
| 9 | + protected function hideOptions() |
|
| 10 | + { |
|
| 10 | 11 | return [ |
| 11 | 12 | 'rating' => __( 'Hide the rating', 'site-reviews' ), |
| 12 | 13 | 'stars' => __( 'Hide the stars', 'site-reviews' ), |
@@ -6,7 +6,8 @@ |
||
| 6 | 6 | |
| 7 | 7 | class SiteReviewsShortcode extends Shortcode |
| 8 | 8 | { |
| 9 | - protected function hideOptions() { |
|
| 9 | + protected function hideOptions() |
|
| 10 | + { |
|
| 10 | 11 | return [ |
| 11 | 12 | 'title' => __( 'Hide the title', 'site-reviews' ), |
| 12 | 13 | 'rating' => __( 'Hide the rating', 'site-reviews' ), |
@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | return [[ |
| 16 | 16 | 'type' => 'container', |
| 17 | 17 | 'html' => '<p class="strong">'.esc_html__( 'All settings are optional.', 'site-reviews' ).'</p>', |
| 18 | - ],[ |
|
| 18 | + ], [ |
|
| 19 | 19 | 'label' => esc_html__( 'Title', 'site-reviews' ), |
| 20 | 20 | 'name' => 'title', |
| 21 | 21 | 'tooltip' => __( 'Enter a custom shortcode heading.', 'site-reviews' ), |
| 22 | 22 | 'type' => 'textbox', |
| 23 | - ],[ |
|
| 23 | + ], [ |
|
| 24 | 24 | 'label' => esc_html__( 'Description', 'site-reviews' ), |
| 25 | 25 | 'minHeight' => 60, |
| 26 | 26 | 'minWidth' => 240, |
@@ -29,25 +29,25 @@ discard block |
||
| 29 | 29 | 'tooltip' => __( 'Enter a custom shortcode description.', 'site-reviews' ), |
| 30 | 30 | 'type' => 'textbox', |
| 31 | 31 | ], |
| 32 | - $this->getCategories( __( 'Automatically assign a category to reviews submitted with this shortcode.', 'site-reviews' )), |
|
| 32 | + $this->getCategories( __( 'Automatically assign a category to reviews submitted with this shortcode.', 'site-reviews' ) ), |
|
| 33 | 33 | [ |
| 34 | 34 | 'label' => esc_html__( 'Assign To', 'site-reviews' ), |
| 35 | 35 | 'name' => 'assign_to', |
| 36 | 36 | 'tooltip' => __( 'Assign submitted reviews to a custom page/post ID. You can also enter "post_id" to assign reviews to the ID of the current page.', 'site-reviews' ), |
| 37 | 37 | 'type' => 'textbox', |
| 38 | - ],[ |
|
| 38 | + ], [ |
|
| 39 | 39 | 'label' => esc_html__( 'Classes', 'site-reviews' ), |
| 40 | 40 | 'name' => 'class', |
| 41 | 41 | 'tooltip' => __( 'Add custom CSS classes to the shortcode.', 'site-reviews' ), |
| 42 | 42 | 'type' => 'textbox', |
| 43 | - ],[ |
|
| 43 | + ], [ |
|
| 44 | 44 | 'columns' => 2, |
| 45 | 45 | 'items' => $this->getHideOptions(), |
| 46 | 46 | 'label' => esc_html__( 'Hide', 'site-reviews' ), |
| 47 | 47 | 'layout' => 'grid', |
| 48 | 48 | 'spacing' => 5, |
| 49 | 49 | 'type' => 'container', |
| 50 | - ],[ |
|
| 50 | + ], [ |
|
| 51 | 51 | 'hidden' => true, |
| 52 | 52 | 'name' => 'id', |
| 53 | 53 | 'type' => 'textbox', |
@@ -6,7 +6,8 @@ |
||
| 6 | 6 | |
| 7 | 7 | class SiteReviewsFormShortcode extends Shortcode |
| 8 | 8 | { |
| 9 | - protected function hideOptions() { |
|
| 9 | + protected function hideOptions() |
|
| 10 | + { |
|
| 10 | 11 | return [ |
| 11 | 12 | 'rating' => __( 'Hide the rating field', 'site-reviews' ), |
| 12 | 13 | 'title' => __( 'Hide the title field', 'site-reviews' ), |
@@ -25,8 +25,8 @@ |
||
| 25 | 25 | public function normalizeAtts( $atts, $type = 'shortcode' ) |
| 26 | 26 | { |
| 27 | 27 | $atts = parent::normalizeAtts( $atts, $type ); |
| 28 | - if( empty( $atts['id'] )) { |
|
| 29 | - $atts['id'] = substr( md5( serialize( $atts )), 0, 8 ); |
|
| 28 | + if( empty($atts['id']) ) { |
|
| 29 | + $atts['id'] = substr( md5( serialize( $atts ) ), 0, 8 ); |
|
| 30 | 30 | } |
| 31 | 31 | return $atts; |
| 32 | 32 | } |
@@ -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 type of review would you like to display?', 'site-reviews' ), |
| 46 | 46 | 'name' => 'type', |
| 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,16 +61,16 @@ 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' => glsr( SiteReviewsShortcode::class )->getHideOptions(), |
| 73 | - ]); |
|
| 73 | + ] ); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function update( $newInstance, $oldInstance ) |
| 82 | 82 | { |
| 83 | - if( !is_numeric( $newInstance['count'] )) { |
|
| 83 | + if( !is_numeric( $newInstance['count'] ) ) { |
|
| 84 | 84 | $newInstance['count'] = 10; |
| 85 | 85 | } |
| 86 | - $newInstance['count'] = min( 50, max( 0, intval( $newInstance['count'] ))); |
|
| 86 | + $newInstance['count'] = min( 50, max( 0, intval( $newInstance['count'] ) ) ); |
|
| 87 | 87 | return parent::update( $newInstance, $oldInstance ); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -20,34 +20,34 @@ |
||
| 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' => glsr( SiteReviewsFormShortcode::class )->getHideOptions(), |
| 50 | - ]); |
|
| 50 | + ] ); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -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,16 +43,16 @@ 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' => glsr( SiteReviewsSummaryShortcode::class )->getHideOptions(), |
| 55 | - ]); |
|
| 55 | + ] ); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -150,7 +150,9 @@ discard block |
||
| 150 | 150 | if( !empty( $sessions )) { |
| 151 | 151 | $now = time(); |
| 152 | 152 | foreach( $sessions as $session ) { |
| 153 | - if( $now <= $session->expiration )continue; |
|
| 153 | + if( $now <= $session->expiration ) { |
|
| 154 | + continue; |
|
| 155 | + } |
|
| 154 | 156 | $expiredSessions[] = $session->name; |
| 155 | 157 | $expiredSessions[] = str_replace( '_expires_', '_', $session->name ); |
| 156 | 158 | } |
@@ -193,7 +195,9 @@ discard block |
||
| 193 | 195 | */ |
| 194 | 196 | protected function setCookie() |
| 195 | 197 | { |
| 196 | - if( headers_sent() )return; |
|
| 198 | + if( headers_sent() ) { |
|
| 199 | + return; |
|
| 200 | + } |
|
| 197 | 201 | $cookie = $this->sessionId.static::DELIMITER.$this->expiryTimestamp.static::DELIMITER.$this->expiryTimestampReset; |
| 198 | 202 | $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
| 199 | 203 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE ); |
| 40 | 40 | if( strpos( $cookieId, static::DELIMITER ) !== false ) { |
| 41 | - $cookie = explode( static::DELIMITER, stripslashes( $cookieId )); |
|
| 41 | + $cookie = explode( static::DELIMITER, stripslashes( $cookieId ) ); |
|
| 42 | 42 | $this->sessionId = preg_replace( '/[^A-Za-z0-9_]/', '', $cookie[0] ); |
| 43 | 43 | $this->expiryTimestamp = absint( $cookie[1] ); |
| 44 | 44 | $this->expiryTimestampReset = absint( $cookie[2] ); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function deleteExpiredSessions( $limit = 1000 ) |
| 79 | 79 | { |
| 80 | - if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ))) { |
|
| 80 | + if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ) ) ) { |
|
| 81 | 81 | glsr( SqlQueries::class )->deleteExpiredSessions( $expiredSessions ); |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | public function get( $key, $fallback = '', $unset = false ) |
| 92 | 92 | { |
| 93 | 93 | $key = sanitize_key( $key ); |
| 94 | - $value = isset( $this->sessionData[$key] ) |
|
| 94 | + $value = isset($this->sessionData[$key]) |
|
| 95 | 95 | ? maybe_unserialize( $this->sessionData[$key] ) |
| 96 | 96 | : $fallback; |
| 97 | - if( isset( $this->sessionData[$key] ) && $unset ) { |
|
| 98 | - unset( $this->sessionData[$key] ); |
|
| 97 | + if( isset($this->sessionData[$key]) && $unset ) { |
|
| 98 | + unset($this->sessionData[$key]); |
|
| 99 | 99 | $this->updateSession(); |
| 100 | 100 | } |
| 101 | 101 | return $value; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | protected function deleteSession() |
| 130 | 130 | { |
| 131 | 131 | delete_option( $this->getSessionId() ); |
| 132 | - delete_option( $this->getSessionId( 'expires' )); |
|
| 132 | + delete_option( $this->getSessionId( 'expires' ) ); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | protected function generateSessionId() |
| 139 | 139 | { |
| 140 | - return md5(( new PasswordHash( 8, false ))->get_random_bytes( 32 )); |
|
| 140 | + return md5( (new PasswordHash( 8, false ))->get_random_bytes( 32 ) ); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | protected function getExpiredSessions( $limit ) |
| 148 | 148 | { |
| 149 | 149 | $expiredSessions = []; |
| 150 | - $sessions = glsr( SqlQueries::class )->getExpiredSessions( static::SESSION_COOKIE, absint( $limit )); |
|
| 151 | - if( !empty( $sessions )) { |
|
| 150 | + $sessions = glsr( SqlQueries::class )->getExpiredSessions( static::SESSION_COOKIE, absint( $limit ) ); |
|
| 151 | + if( !empty($sessions) ) { |
|
| 152 | 152 | $now = time(); |
| 153 | 153 | foreach( $sessions as $session ) { |
| 154 | 154 | if( $now <= $session->expiration )continue; |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | protected function getSessionId( $separator = '' ) |
| 167 | 167 | { |
| 168 | - return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] )); |
|
| 168 | + return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] ) ); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | { |
| 197 | 197 | if( headers_sent() )return; |
| 198 | 198 | $cookie = $this->sessionId.static::DELIMITER.$this->expiryTimestamp.static::DELIMITER.$this->expiryTimestampReset; |
| 199 | - $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
|
| 199 | + $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ) ) ); |
|
| 200 | 200 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
| 201 | 201 | } |
| 202 | 202 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | protected function updateSession() |
| 216 | 216 | { |
| 217 | - if( false === get_option( $this->getSessionId() )) { |
|
| 217 | + if( false === get_option( $this->getSessionId() ) ) { |
|
| 218 | 218 | return $this->createSession(); |
| 219 | 219 | } |
| 220 | 220 | update_option( $this->getSessionId(), $this->sessionData, false ); |