@@ -15,8 +15,8 @@ |
||
15 | 15 | */ |
16 | 16 | protected function sanitize( array $args ) |
17 | 17 | { |
18 | - if( empty( $args['id'] )) { |
|
19 | - $args['id'] = substr( md5( serialize( $args )), 0, 8 ); |
|
18 | + if( empty($args['id']) ) { |
|
19 | + $args['id'] = substr( md5( serialize( $args ) ), 0, 8 ); |
|
20 | 20 | } |
21 | 21 | return $args; |
22 | 22 | } |
@@ -14,8 +14,8 @@ |
||
14 | 14 | { |
15 | 15 | foreach( $command->shortcodes as $shortcode ) { |
16 | 16 | $shortcodeClass = glsr( Helper::class )->buildClassName( $shortcode.'-shortcode', 'Shortcodes' ); |
17 | - if( !class_exists( $shortcodeClass )) { |
|
18 | - glsr_log()->error( sprintf( 'Class missing (%s)', $shortcodeClass )); |
|
17 | + if( !class_exists( $shortcodeClass ) ) { |
|
18 | + glsr_log()->error( sprintf( 'Class missing (%s)', $shortcodeClass ) ); |
|
19 | 19 | continue; |
20 | 20 | } |
21 | 21 | add_shortcode( $shortcode, [glsr( $shortcodeClass ), 'buildShortcode'] ); |
@@ -16,8 +16,8 @@ |
||
16 | 16 | global $wp_widget_factory; |
17 | 17 | foreach( $command->widgets as $key => $values ) { |
18 | 18 | $widgetClass = glsr( Helper::class )->buildClassName( $key.'-widget', 'Widgets' ); |
19 | - if( !class_exists( $widgetClass )) { |
|
20 | - glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass )); |
|
19 | + if( !class_exists( $widgetClass ) ) { |
|
20 | + glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass ) ); |
|
21 | 21 | continue; |
22 | 22 | } |
23 | 23 | // Here we bypass register_widget() in order to pass our custom values to the widget |
@@ -12,10 +12,10 @@ |
||
12 | 12 | */ |
13 | 13 | public function handle( Command $command ) |
14 | 14 | { |
15 | - if( !get_post( $command->id )) { |
|
15 | + if( !get_post( $command->id ) ) { |
|
16 | 16 | return false; |
17 | 17 | } |
18 | - if( is_null( $command->pinned )) { |
|
18 | + if( is_null( $command->pinned ) ) { |
|
19 | 19 | $meta = get_post_meta( $command->id, 'pinned', true ); |
20 | 20 | $command->pinned = !wp_validate_boolean( $meta ); |
21 | 21 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | public function build( $partialPath, array $args = [] ) |
14 | 14 | { |
15 | 15 | $className = glsr( Helper::class )->buildClassName( $partialPath, 'Modules\Html\Partials' ); |
16 | - if( !class_exists( $className )) { |
|
16 | + if( !class_exists( $className ) ) { |
|
17 | 17 | glsr_log()->error( 'Partial missing: '.$className ); |
18 | 18 | return; |
19 | 19 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | public function __construct( $input ) |
11 | 11 | { |
12 | 12 | $this->id = $input['id']; |
13 | - $this->pinned = isset( $input['pinned'] ) |
|
13 | + $this->pinned = isset($input['pinned']) |
|
14 | 14 | ? wp_validate_boolean( $input['pinned'] ) |
15 | 15 | : null; |
16 | 16 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | $diff = time() - strtotime( $date ); |
32 | 32 | foreach( static::$TIME_PERIODS as $i => $timePeriod ) { |
33 | 33 | if( $diff > $timePeriod[0] )continue; |
34 | - $unit = intval( floor( $diff / $timePeriod[1] )); |
|
34 | + $unit = intval( floor( $diff / $timePeriod[1] ) ); |
|
35 | 35 | $relativeDates = [ |
36 | 36 | _n( '%s second ago', '%s seconds ago', $unit, 'site-reviews' ), |
37 | 37 | _n( '%s minute ago', '%s minutes ago', $unit, 'site-reviews' ), |
@@ -30,7 +30,9 @@ |
||
30 | 30 | { |
31 | 31 | $diff = time() - strtotime( $date ); |
32 | 32 | foreach( static::$TIME_PERIODS as $i => $timePeriod ) { |
33 | - if( $diff > $timePeriod[0] )continue; |
|
33 | + if( $diff > $timePeriod[0] ) { |
|
34 | + continue; |
|
35 | + } |
|
34 | 36 | $unit = intval( floor( $diff / $timePeriod[1] )); |
35 | 37 | $relativeDates = [ |
36 | 38 | _n( '%s second ago', '%s seconds ago', $unit, 'site-reviews' ), |
@@ -161,7 +161,9 @@ discard block |
||
161 | 161 | if( !empty( $sessions )) { |
162 | 162 | $now = time(); |
163 | 163 | foreach( $sessions as $session ) { |
164 | - if( $now <= $session->expiration )continue; |
|
164 | + if( $now <= $session->expiration ) { |
|
165 | + continue; |
|
166 | + } |
|
165 | 167 | $expiredSessions[] = $session->name; |
166 | 168 | $expiredSessions[] = str_replace( '_expires_', '_', $session->name ); |
167 | 169 | } |
@@ -204,7 +206,9 @@ discard block |
||
204 | 206 | */ |
205 | 207 | protected function setCookie() |
206 | 208 | { |
207 | - if( headers_sent() )return; |
|
209 | + if( headers_sent() ) { |
|
210 | + return; |
|
211 | + } |
|
208 | 212 | $cookie = $this->sessionId.'||'.$this->expiryTimestamp.'||'.$this->expiryTimestampReset; |
209 | 213 | $cookiePath = preg_replace( '|https?://[^/]+|i', '', trailingslashit( (string)get_option( 'home' ))); |
210 | 214 | setcookie( static::SESSION_COOKIE, $cookie, $this->expiryTimestamp, $cookiePath ); |
@@ -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 ); |
@@ -22,7 +22,8 @@ |
||
22 | 22 | protected $public; |
23 | 23 | protected $translator; |
24 | 24 | |
25 | - public function __construct( Application $app ) { |
|
25 | + public function __construct( Application $app ) |
|
26 | + { |
|
26 | 27 | $this->app = $app; |
27 | 28 | $this->admin = $app->make( AdminController::class ); |
28 | 29 | $this->basename = plugin_basename( $app->file ); |
@@ -41,32 +41,32 @@ |
||
41 | 41 | */ |
42 | 42 | public function run() |
43 | 43 | { |
44 | - add_filter( 'mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15 ); |
|
45 | - add_filter( 'plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks'] ); |
|
46 | - add_filter( 'dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems'] ); |
|
47 | - add_filter( 'block_categories', [$this->blocks, 'filterBlockCategories'] ); |
|
48 | - add_filter( 'classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2 ); |
|
49 | - add_filter( 'use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2 ); |
|
50 | - add_filter( 'wp_editor_settings', [$this->editor, 'filterEditorSettings'] ); |
|
51 | - add_filter( 'the_editor', [$this->editor, 'filterEditorTextarea'] ); |
|
52 | - add_filter( 'gettext', [$this->editor, 'filterPostStatusLabels'], 10, 3 ); |
|
53 | - add_filter( 'gettext_with_context', [$this->editor, 'filterPostStatusLabelsWithContext'], 10, 4 ); |
|
54 | - add_filter( 'post_updated_messages', [$this->editor, 'filterUpdateMessages'] ); |
|
55 | - add_filter( 'bulk_post_updated_messages', [$this->listtable, 'filterBulkUpdateMessages'], 10, 2 ); |
|
56 | - add_filter( 'manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType'] ); |
|
57 | - add_filter( 'post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2 ); |
|
58 | - add_filter( 'default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 ); |
|
59 | - add_filter( 'display_post_states', [$this->listtable, 'filterPostStates'], 10, 2 ); |
|
60 | - add_filter( 'post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2 ); |
|
44 | + add_filter( 'mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15 ); |
|
45 | + add_filter( 'plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks'] ); |
|
46 | + add_filter( 'dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems'] ); |
|
47 | + add_filter( 'block_categories', [$this->blocks, 'filterBlockCategories'] ); |
|
48 | + add_filter( 'classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2 ); |
|
49 | + add_filter( 'use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2 ); |
|
50 | + add_filter( 'wp_editor_settings', [$this->editor, 'filterEditorSettings'] ); |
|
51 | + add_filter( 'the_editor', [$this->editor, 'filterEditorTextarea'] ); |
|
52 | + add_filter( 'gettext', [$this->editor, 'filterPostStatusLabels'], 10, 3 ); |
|
53 | + add_filter( 'gettext_with_context', [$this->editor, 'filterPostStatusLabelsWithContext'], 10, 4 ); |
|
54 | + add_filter( 'post_updated_messages', [$this->editor, 'filterUpdateMessages'] ); |
|
55 | + add_filter( 'bulk_post_updated_messages', [$this->listtable, 'filterBulkUpdateMessages'], 10, 2 ); |
|
56 | + add_filter( 'manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType'] ); |
|
57 | + add_filter( 'post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2 ); |
|
58 | + add_filter( 'default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2 ); |
|
59 | + add_filter( 'display_post_states', [$this->listtable, 'filterPostStates'], 10, 2 ); |
|
60 | + add_filter( 'post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2 ); |
|
61 | 61 | add_filter( 'manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns'] ); |
62 | - add_filter( 'ngettext', [$this->listtable, 'filterStatusText'], 10, 5 ); |
|
63 | - add_filter( 'script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2 ); |
|
64 | - add_filter( 'site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11 ); |
|
65 | - add_filter( 'query_vars', [$this->public, 'filterQueryVars'] ); |
|
66 | - add_filter( 'site-reviews/render/view', [$this->public, 'filterRenderView'] ); |
|
67 | - add_filter( 'gettext', [$this->translator, 'filterGettext'], 10, 3 ); |
|
68 | - add_filter( 'gettext_with_context', [$this->translator, 'filterGettextWithContext'], 10, 4 ); |
|
69 | - add_filter( 'ngettext', [$this->translator, 'filterNgettext'], 10, 5 ); |
|
70 | - add_filter( 'ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 10, 6 ); |
|
62 | + add_filter( 'ngettext', [$this->listtable, 'filterStatusText'], 10, 5 ); |
|
63 | + add_filter( 'script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2 ); |
|
64 | + add_filter( 'site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11 ); |
|
65 | + add_filter( 'query_vars', [$this->public, 'filterQueryVars'] ); |
|
66 | + add_filter( 'site-reviews/render/view', [$this->public, 'filterRenderView'] ); |
|
67 | + add_filter( 'gettext', [$this->translator, 'filterGettext'], 10, 3 ); |
|
68 | + add_filter( 'gettext_with_context', [$this->translator, 'filterGettextWithContext'], 10, 4 ); |
|
69 | + add_filter( 'ngettext', [$this->translator, 'filterNgettext'], 10, 5 ); |
|
70 | + add_filter( 'ngettext_with_context', [$this->translator, 'filterNgettextWithContext'], 10, 6 ); |
|
71 | 71 | } |
72 | 72 | } |