@@ -50,7 +50,7 @@ |
||
| 50 | 50 | public function routerSubmitReview( array $request ) |
| 51 | 51 | { |
| 52 | 52 | $validated = glsr( ValidateReview::class )->validate( $request ); |
| 53 | - if( !empty( $validated->error ) || $validated->recaptchaIsUnset )return; |
|
| 54 | - $this->execute( new CreateReview( $validated->request )); |
|
| 53 | + if( !empty($validated->error) || $validated->recaptchaIsUnset )return; |
|
| 54 | + $this->execute( new CreateReview( $validated->request ) ); |
|
| 55 | 55 | } |
| 56 | 56 | } |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | public function __construct() |
| 36 | 36 | { |
| 37 | - if( $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE )) { |
|
| 38 | - $cookie = explode( '||', stripslashes( $cookieId )); |
|
| 37 | + if( $cookieId = filter_input( INPUT_COOKIE, static::SESSION_COOKIE ) ) { |
|
| 38 | + $cookie = explode( '||', stripslashes( $cookieId ) ); |
|
| 39 | 39 | $this->sessionId = preg_replace( '/[^A-Za-z0-9_]/', '', $cookie[0] ); |
| 40 | 40 | $this->expiryTimestamp = absint( $cookie[1] ); |
| 41 | 41 | $this->expiryTimestampReset = absint( $cookie[2] ); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function deleteExpiredSessions( $limit = 1000 ) |
| 77 | 77 | { |
| 78 | - if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ))) { |
|
| 78 | + if( $expiredSessions = implode( "','", $this->getExpiredSessions( $limit ) ) ) { |
|
| 79 | 79 | glsr( SqlQueries::class )->deleteExpiredSessions( $expiredSessions ); |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | public function get( $key, $fallback = '', $unset = false ) |
| 90 | 90 | { |
| 91 | 91 | $key = sanitize_key( $key ); |
| 92 | - $value = isset( $this->sessionData[$key] ) |
|
| 92 | + $value = isset($this->sessionData[$key]) |
|
| 93 | 93 | ? maybe_unserialize( $this->sessionData[$key] ) |
| 94 | 94 | : $fallback; |
| 95 | - if( isset( $this->sessionData[$key] ) && $unset ) { |
|
| 96 | - unset( $this->sessionData[$key] ); |
|
| 95 | + if( isset($this->sessionData[$key]) && $unset ) { |
|
| 96 | + unset($this->sessionData[$key]); |
|
| 97 | 97 | $this->updateSession(); |
| 98 | 98 | } |
| 99 | 99 | return $value; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | protected function deleteSession() |
| 128 | 128 | { |
| 129 | 129 | delete_option( $this->getSessionId() ); |
| 130 | - delete_option( $this->getSessionId( 'expires' )); |
|
| 130 | + delete_option( $this->getSessionId( 'expires' ) ); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | protected function generateSessionId() |
| 137 | 137 | { |
| 138 | - return md5(( new PasswordHash( 8, false ))->get_random_bytes( 32 )); |
|
| 138 | + return md5( (new PasswordHash( 8, false ))->get_random_bytes( 32 ) ); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | protected function getExpiredSessions( $limit ) |
| 146 | 146 | { |
| 147 | 147 | $expiredSessions = []; |
| 148 | - $sessions = glsr( SqlQueries::class )->getExpiredSessions( static::SESSION_COOKIE, absint( $limit )); |
|
| 149 | - if( !empty( $sessions )) { |
|
| 148 | + $sessions = glsr( SqlQueries::class )->getExpiredSessions( static::SESSION_COOKIE, absint( $limit ) ); |
|
| 149 | + if( !empty($sessions) ) { |
|
| 150 | 150 | $now = time(); |
| 151 | 151 | foreach( $sessions as $session ) { |
| 152 | 152 | if( $now <= $session->expiration )continue; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | protected function getSessionId( $separator = '' ) |
| 165 | 165 | { |
| 166 | - return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] )); |
|
| 166 | + return implode( '_', array_filter( [static::SESSION_COOKIE, $separator, $this->sessionId] ) ); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | { |
| 195 | 195 | if( headers_sent() )return; |
| 196 | 196 | $cookie = $this->sessionId.'||'.$this->expiryTimestamp.'||'.$this->expiryTimestampReset; |
| 197 | - $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
|
| 197 | + $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ) ) ); |
|
| 198 | 198 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
| 199 | 199 | } |
| 200 | 200 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | protected function updateSession() |
| 214 | 214 | { |
| 215 | - if( false === get_option( $this->getSessionId() )) { |
|
| 215 | + if( false === get_option( $this->getSessionId() ) ) { |
|
| 216 | 216 | return $this->createSession(); |
| 217 | 217 | } |
| 218 | 218 | update_option( $this->getSessionId(), $this->sessionData, false ); |
@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | public function isBlacklisted( array $review ) |
| 13 | 13 | { |
| 14 | - $target = implode( "\n", array_filter([ |
|
| 14 | + $target = implode( "\n", array_filter( [ |
|
| 15 | 15 | $review['name'], |
| 16 | 16 | $review['content'], |
| 17 | 17 | $review['email'], |
| 18 | 18 | $review['ip_address'], |
| 19 | 19 | $review['title'], |
| 20 | - ])); |
|
| 21 | - return (bool) apply_filters( 'site-reviews/blacklist/is-blacklisted', |
|
| 20 | + ] ) ); |
|
| 21 | + return (bool)apply_filters( 'site-reviews/blacklist/is-blacklisted', |
|
| 22 | 22 | $this->check( $target ), |
| 23 | 23 | $review |
| 24 | 24 | ); |
@@ -30,16 +30,16 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | protected function check( $target ) |
| 32 | 32 | { |
| 33 | - $blacklist = trim( glsr( OptionManager::class )->get( 'settings.submissions.blacklist.entries' )); |
|
| 34 | - if( empty( $blacklist )) { |
|
| 33 | + $blacklist = trim( glsr( OptionManager::class )->get( 'settings.submissions.blacklist.entries' ) ); |
|
| 34 | + if( empty($blacklist) ) { |
|
| 35 | 35 | return false; |
| 36 | 36 | } |
| 37 | 37 | $lines = explode( "\n", $blacklist ); |
| 38 | - foreach( (array) $lines as $line ) { |
|
| 38 | + foreach( (array)$lines as $line ) { |
|
| 39 | 39 | $line = trim( $line ); |
| 40 | - if( empty( $line ) || 256 < strlen( $line ))continue; |
|
| 41 | - $pattern = sprintf( '#%s#i', preg_quote( $line, '#' )); |
|
| 42 | - if( preg_match( $pattern, $target )) { |
|
| 40 | + if( empty($line) || 256 < strlen( $line ) )continue; |
|
| 41 | + $pattern = sprintf( '#%s#i', preg_quote( $line, '#' ) ); |
|
| 42 | + if( preg_match( $pattern, $target ) ) { |
|
| 43 | 43 | return true; |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -22,11 +22,11 @@ discard block |
||
| 22 | 22 | $this->args = $this->normalize( $args ); |
| 23 | 23 | if( $this->args['total'] < 2 )return; |
| 24 | 24 | $links = $this->buildLinksForDeprecatedThemes(); |
| 25 | - if( empty( $links )) { |
|
| 25 | + if( empty($links) ) { |
|
| 26 | 26 | $links = $this->buildLinks(); |
| 27 | 27 | } |
| 28 | 28 | $links = apply_filters( 'site-reviews/reviews/navigation_links', $links, $this->args ); |
| 29 | - if( empty( $links ))return; |
|
| 29 | + if( empty($links) )return; |
|
| 30 | 30 | return $this->buildTemplate( $links ); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | 'total' => $this->args['total'], |
| 46 | 46 | ]; |
| 47 | 47 | if( is_front_page() ) { |
| 48 | - unset( $paginateArgs['format'] ); |
|
| 48 | + unset($paginateArgs['format']); |
|
| 49 | 49 | } |
| 50 | 50 | return paginate_links( $paginateArgs ); |
| 51 | 51 | } |
@@ -56,17 +56,17 @@ discard block |
||
| 56 | 56 | protected function buildLinksForDeprecatedThemes() |
| 57 | 57 | { |
| 58 | 58 | $theme = wp_get_theme()->get( 'TextDomain' ); |
| 59 | - if( !in_array( $theme, ['twentyten','twentyeleven','twentytwelve','twentythirteen'] ))return; |
|
| 59 | + if( !in_array( $theme, ['twentyten', 'twentyeleven', 'twentytwelve', 'twentythirteen'] ) )return; |
|
| 60 | 60 | $links = ''; |
| 61 | 61 | if( $this->args['paged'] > 1 ) { |
| 62 | - $links.= sprintf( '<div class="nav-previous"><a href="%s"><span class="meta-nav">←</span> %s</a></div>', |
|
| 62 | + $links .= sprintf( '<div class="nav-previous"><a href="%s"><span class="meta-nav">←</span> %s</a></div>', |
|
| 63 | 63 | $this->buildUrlForDeprecatedThemes(-1), |
| 64 | 64 | __( 'Previous', 'site-reviews' ) |
| 65 | 65 | ); |
| 66 | 66 | } |
| 67 | 67 | if( $this->args['paged'] < $this->args['total'] ) { |
| 68 | - $links.= sprintf( '<div class="nav-next"><a href="%s">%s <span class="meta-nav">→</span></a></div>', |
|
| 69 | - $this->buildUrlForDeprecatedThemes(1), |
|
| 68 | + $links .= sprintf( '<div class="nav-next"><a href="%s">%s <span class="meta-nav">→</span></a></div>', |
|
| 69 | + $this->buildUrlForDeprecatedThemes( 1 ), |
|
| 70 | 70 | __( 'Next', 'site-reviews' ) |
| 71 | 71 | ); |
| 72 | 72 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $screenReaderTemplate = '<h2 class="screen-reader-text">%2$s</h2>'; |
| 85 | 85 | $screenReaderText = __( 'Site Reviews navigation', 'site-reviews' ); |
| 86 | 86 | $innerTemplate = $screenReaderTemplate.'<div class="nav-links">%3$s</div>'; |
| 87 | - if( in_array( $theme, ['twentyten', 'twentyeleven', 'twentytwelve'] )) { |
|
| 87 | + if( in_array( $theme, ['twentyten', 'twentyeleven', 'twentytwelve'] ) ) { |
|
| 88 | 88 | $innerTemplate = '%3$s'; |
| 89 | 89 | } |
| 90 | 90 | else if( $theme == 'twentyfourteen' ) { |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $template = sprintf( $template, $class, $screenReaderText, $links ); |
| 97 | 97 | return glsr( Builder::class )->div( $template.'<div class="glsr-loader"></div>', [ |
| 98 | 98 | 'class' => 'glsr-navigation', |
| 99 | - ]); |
|
| 99 | + ] ); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -119,6 +119,6 @@ discard block |
||
| 119 | 119 | return wp_parse_args( $args, [ |
| 120 | 120 | 'paged' => glsr( QueryBuilder::class )->getPaged(), |
| 121 | 121 | 'total' => 1, |
| 122 | - ]); |
|
| 122 | + ] ); |
|
| 123 | 123 | } |
| 124 | 124 | } |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | <div id="<?= $tax_name; ?>-all" class="tabs-panel"> |
| 17 | 17 | <input type="hidden" name="tax_input[<?= $tax_name; ?>][]" value='0' /> |
| 18 | 18 | <ul id="<?= $tax_name; ?>checklist" data-wp-lists="list:<?= $tax_name; ?>" class="categorychecklist form-no-clear"> |
| 19 | - <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => $tax_name, 'popular_cats' => $popular_ids )); ?> |
|
| 19 | + <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => $tax_name, 'popular_cats' => $popular_ids ) ); ?> |
|
| 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,7 +1,7 @@ |
||
| 1 | 1 | <?php defined( 'WPINC' ) || die; ?> |
| 2 | 2 | |
| 3 | 3 | <div id="titlediv"> |
| 4 | - <input type="text" id="title" value="<?= $post->post_title ? esc_attr( $post->post_title ) : sprintf( '(%s)', __( 'no title', 'site-reviews' )); ?>" readonly> |
|
| 4 | + <input type="text" id="title" value="<?= $post->post_title ? esc_attr( $post->post_title ) : sprintf( '(%s)', __( 'no title', 'site-reviews' ) ); ?>" readonly> |
|
| 5 | 5 | </div> |
| 6 | 6 | |
| 7 | 7 | <div id="contentdiv"> |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function renderTaxonomyFilter() |
| 37 | 37 | { |
| 38 | - if( !is_object_in_taxonomy( get_current_screen()->post_type, Application::TAXONOMY ))return; |
|
| 38 | + if( !is_object_in_taxonomy( get_current_screen()->post_type, Application::TAXONOMY ) )return; |
|
| 39 | 39 | glsr( Html::class )->render()->label( __( 'Filter by category', 'site-reviews' ), [ |
| 40 | 40 | 'class' => 'screen-reader-text', |
| 41 | 41 | 'for' => Application::TAXONOMY, |
| 42 | - ]); |
|
| 43 | - wp_dropdown_categories([ |
|
| 42 | + ] ); |
|
| 43 | + wp_dropdown_categories( [ |
|
| 44 | 44 | 'depth' => 3, |
| 45 | 45 | 'hide_empty' => true, |
| 46 | 46 | 'hide_if_empty' => true, |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | 'show_option_all' => $this->getShowOptionAll(), |
| 53 | 53 | 'taxonomy' => Application::TAXONOMY, |
| 54 | 54 | 'value_field' => 'slug', |
| 55 | - ]); |
|
| 55 | + ] ); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | protected function getSelected() |
| 62 | 62 | { |
| 63 | 63 | global $wp_query; |
| 64 | - return isset( $wp_query->query[Application::TAXONOMY] ) |
|
| 64 | + return isset($wp_query->query[Application::TAXONOMY]) |
|
| 65 | 65 | ? $wp_query->query[Application::TAXONOMY] |
| 66 | 66 | : ''; |
| 67 | 67 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | { |
| 74 | 74 | $taxonomy = get_taxonomy( Application::TAXONOMY ); |
| 75 | 75 | return $taxonomy |
| 76 | - ? ucfirst( strtolower( $taxonomy->labels->all_items )) |
|
| 76 | + ? ucfirst( strtolower( $taxonomy->labels->all_items ) ) |
|
| 77 | 77 | : ''; |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | 'savePending' => __( 'Save as Unapproved', 'site-reviews' ), |
| 18 | 18 | 'published' => __( 'Approved', 'site-reviews' ), |
| 19 | 19 | ]; |
| 20 | - if( $this->canModifyTranslation() && isset( $wp_scripts->registered['post']->extra['data'] )) { |
|
| 20 | + if( $this->canModifyTranslation() && isset($wp_scripts->registered['post']->extra['data']) ) { |
|
| 21 | 21 | $l10n = &$wp_scripts->registered['post']->extra['data']; |
| 22 | 22 | foreach( $strings as $search => $replace ) { |
| 23 | 23 | $l10n = preg_replace( '/("'.$search.'":")([^"]+)/', "$1".$replace, $l10n ); |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function filterPostStatusLabels( $translation, $text, $domain ) |
| 35 | 35 | { |
| 36 | - if( $this->canModifyTranslation( $domain )) { |
|
| 36 | + if( $this->canModifyTranslation( $domain ) ) { |
|
| 37 | 37 | $replacements = $this->getStatusLabels(); |
| 38 | - if( array_key_exists( $text, $replacements )) { |
|
| 38 | + if( array_key_exists( $text, $replacements ) ) { |
|
| 39 | 39 | $translation = $replacements[$text]; |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -48,14 +48,14 @@ discard block |
||
| 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) )return; |
|
| 52 | 52 | $strings = $this->getReviewLabels(); |
| 53 | 53 | $restored = filter_input( INPUT_GET, 'revision' ); |
| 54 | - if( $revisionTitle = wp_post_revision_title( intval( $restored ), false )) { |
|
| 54 | + if( $revisionTitle = wp_post_revision_title( intval( $restored ), false ) ) { |
|
| 55 | 55 | $restored = sprintf( $strings['restored'], $revisionTitle ); |
| 56 | 56 | } |
| 57 | - $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date )); |
|
| 58 | - $messages[ Application::POST_TYPE ] = [ |
|
| 57 | + $scheduled_date = date_i18n( 'M j, Y @ H:i', strtotime( $post->post_date ) ); |
|
| 58 | + $messages[Application::POST_TYPE] = [ |
|
| 59 | 59 | 1 => $strings['updated'], |
| 60 | 60 | 4 => $strings['updated'], |
| 61 | 61 | 5 => $restored, |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | protected function canModifyTranslation( $domain = 'default' ) |
| 79 | 79 | { |
| 80 | - if( $domain != 'default' || empty( glsr_current_screen()->base )) { |
|
| 80 | + if( $domain != 'default' || empty(glsr_current_screen()->base) ) { |
|
| 81 | 81 | return false; |
| 82 | 82 | } |
| 83 | 83 | return get_current_screen()->post_type == Application::POST_TYPE |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | protected function getStatusLabels() |
| 113 | 113 | { |
| 114 | 114 | static $labels; |
| 115 | - if( empty( $labels )) { |
|
| 115 | + if( empty($labels) ) { |
|
| 116 | 116 | $labels = [ |
| 117 | 117 | 'Pending' => __( 'Unapproved', 'site-reviews' ), |
| 118 | 118 | 'Pending Review' => __( 'Unapproved', 'site-reviews' ), |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | */ |
| 58 | 58 | protected function isReviewEditable() |
| 59 | 59 | { |
| 60 | - $postId = intval( filter_input( INPUT_GET, 'post' )); |
|
| 60 | + $postId = intval( filter_input( INPUT_GET, 'post' ) ); |
|
| 61 | 61 | return $postId > 0 |
| 62 | 62 | && get_post_meta( $postId, 'review_type', true ) == 'local' |
| 63 | 63 | && $this->isReviewEditor(); |