@@ -3,11 +3,11 @@ |
||
3 | 3 | defined( 'WP_UNINSTALL_PLUGIN' ) || die; |
4 | 4 | |
5 | 5 | require_once __DIR__.'/site-reviews.php'; |
6 | -if( !GL_Plugin_Check_v1::isValid( array( 'wordpress' => '4.7.0' )))return; |
|
6 | +if( !GL_Plugin_Check_v1::isValid( array( 'wordpress' => '4.7.0' ) ) )return; |
|
7 | 7 | |
8 | 8 | $majorVersion = explode( '.', glsr()->version ); |
9 | 9 | |
10 | -delete_option( glsr()->prefix.'-v'.array_shift( $majorVersion )); |
|
10 | +delete_option( glsr()->prefix.'-v'.array_shift( $majorVersion ) ); |
|
11 | 11 | delete_option( 'widget_'.glsr()->id.'_site-reviews' ); |
12 | 12 | delete_option( 'widget_'.glsr()->id.'_site-reviews-form' ); |
13 | 13 | delete_option( 'widget_'.glsr()->id.'_site-reviews-summary' ); |
@@ -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 { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function routeWebhookRequest() |
80 | 80 | { |
81 | - $request = filter_input( INPUT_GET, sprintf( '%s-hook', Application::ID )); |
|
81 | + $request = filter_input( INPUT_GET, sprintf( '%s-hook', Application::ID ) ); |
|
82 | 82 | if( !$request )return; |
83 | 83 | // @todo manage webhook here |
84 | 84 | } |
@@ -116,14 +116,14 @@ discard block |
||
116 | 116 | protected function normalizeAjaxRequest() |
117 | 117 | { |
118 | 118 | $request = filter_input( INPUT_POST, 'request', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
119 | - if( isset( $request[Application::ID]['action'] )) { |
|
119 | + if( isset($request[Application::ID]['action']) ) { |
|
120 | 120 | $request = $request[Application::ID]; |
121 | 121 | } |
122 | - if( !isset( $request['action'] )) { |
|
122 | + if( !isset($request['action']) ) { |
|
123 | 123 | glsr_log()->error( 'The AJAX request must include an action' )->info( $request ); |
124 | 124 | wp_die(); |
125 | 125 | } |
126 | - if( !isset( $request['nonce'] )) { |
|
126 | + if( !isset($request['nonce']) ) { |
|
127 | 127 | glsr_log()->error( 'The AJAX request must include a nonce' )->info( $request ); |
128 | 128 | wp_die(); |
129 | 129 | } |
@@ -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,8 +57,8 @@ 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 | - && !empty( $response['response']['code'] ) |
|
61 | - && in_array( $response['response']['code'], range( 200, 299 )) |
|
60 | + && !empty($response['response']['code']) |
|
61 | + && in_array( $response['response']['code'], range( 200, 299 ) ) |
|
62 | 62 | ? 'Works' |
63 | 63 | : 'Does not work'; |
64 | 64 | set_transient( Application::ID.'_remote_post_test', $test, static::EXPIRY_TIME ); |
@@ -55,20 +55,20 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function renderSettingFields( $id ) |
57 | 57 | { |
58 | - $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
|
58 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
59 | 59 | $rows = ''; |
60 | 60 | foreach( $fields as $name => $field ) { |
61 | 61 | $field = wp_parse_args( $field, [ |
62 | 62 | 'name' => $name, |
63 | 63 | 'table' => true, |
64 | - ]); |
|
65 | - $rows.= (new Field( $field ))->build(); |
|
64 | + ] ); |
|
65 | + $rows .= (new Field( $field ))->build(); |
|
66 | 66 | } |
67 | 67 | $this->render( 'pages/settings/'.$id, [ |
68 | 68 | 'context' => [ |
69 | 69 | 'rows' => $rows, |
70 | 70 | ], |
71 | - ]); |
|
71 | + ] ); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | protected function getSettingFields( $path ) |
78 | 78 | { |
79 | 79 | $settings = glsr( DefaultsManager::class )->settings(); |
80 | - return array_filter( $settings, function( $key ) use( $path ) { |
|
80 | + return array_filter( $settings, function( $key ) use($path) { |
|
81 | 81 | return glsr( Helper::class )->startsWith( $path, $key ); |
82 | 82 | }, ARRAY_FILTER_USE_KEY ); |
83 | 83 | } |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | */ |
88 | 88 | protected function normalize( array $data ) |
89 | 89 | { |
90 | - $data = wp_parse_args( $data, array_fill_keys( ['context', 'globals'], [] )); |
|
90 | + $data = wp_parse_args( $data, array_fill_keys( ['context', 'globals'], [] ) ); |
|
91 | 91 | foreach( $data as $key => $value ) { |
92 | - if( is_array( $value ))continue; |
|
92 | + if( is_array( $value ) )continue; |
|
93 | 93 | $data[$key] = []; |
94 | 94 | } |
95 | 95 | $data['template'] = $this; |
@@ -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 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | 'inactive-plugin' => 'Inactive Plugins', |
38 | 38 | 'setting' => 'Plugin Settings', |
39 | 39 | ]; |
40 | - $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use( $details ) { |
|
40 | + $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use($details) { |
|
41 | 41 | $methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' ); |
42 | 42 | if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) { |
43 | 43 | return $carry.$this->implode( $details[$key], $systemDetails ); |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | { |
55 | 55 | $plugins = get_plugins(); |
56 | 56 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
57 | - $inactive = array_diff_key( $plugins, array_flip( $activePlugins )); |
|
58 | - return $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
57 | + $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) ); |
|
58 | + return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function getInactivePluginDetails() |
80 | 80 | { |
81 | 81 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
82 | - return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ))); |
|
82 | + return $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) ); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | { |
90 | 90 | $plugins = array_merge( |
91 | 91 | get_mu_plugins(), |
92 | - get_plugins( '/../'.basename( WPMU_PLUGIN_DIR )) |
|
92 | + get_plugins( '/../'.basename( WPMU_PLUGIN_DIR ) ) |
|
93 | 93 | ); |
94 | - if( empty( $plugins ))return; |
|
94 | + if( empty($plugins) )return; |
|
95 | 95 | return $this->normalizePluginList( $plugins ); |
96 | 96 | } |
97 | 97 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function getMultisitePluginDetails() |
102 | 102 | { |
103 | - if( !is_multisite() || empty( get_site_option( 'active_sitewide_plugins', [] )))return; |
|
103 | + if( !is_multisite() || empty(get_site_option( 'active_sitewide_plugins', [] )) )return; |
|
104 | 104 | return $this->normalizePluginList( wp_get_active_network_plugins() ); |
105 | 105 | } |
106 | 106 | |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | 'Max Input Vars' => ini_get( 'max_input_vars' ), |
123 | 123 | 'Memory Limit' => ini_get( 'memory_limit' ), |
124 | 124 | 'Post Max Size' => ini_get( 'post_max_size' ), |
125 | - 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' )), |
|
126 | - 'Session Name' => esc_html( ini_get( 'session.name' )), |
|
127 | - 'Session Save Path' => esc_html( ini_get( 'session.save_path' )), |
|
128 | - 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' )), true ), |
|
129 | - 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' )), true ), |
|
125 | + 'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ), |
|
126 | + 'Session Name' => esc_html( ini_get( 'session.name' ) ), |
|
127 | + 'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ), |
|
128 | + 'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ), |
|
129 | + 'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ), |
|
130 | 130 | 'Upload Max Filesize' => ini_get( 'upload_max_filesize' ), |
131 | 131 | ]; |
132 | 132 | } |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | $settings = glsr( OptionManager::class )->get( 'settings' ); |
155 | 155 | $settings = $helper->flattenArray( $settings ); |
156 | 156 | foreach( ['submissions.recaptcha.key', 'submissions.recaptcha.secret'] as $key ) { |
157 | - if( empty( $settings[$key] ))continue; |
|
157 | + if( empty($settings[$key]) )continue; |
|
158 | 158 | $settings[$key] = str_repeat( '*', 10 ); |
159 | 159 | } |
160 | 160 | $details = []; |
161 | 161 | foreach( $settings as $key => $value ) { |
162 | - if( $helper->startsWith( 'translations', $key ) && $helper->endsWith( 'id', $key ))continue; |
|
163 | - $value = htmlspecialchars( trim( preg_replace('/\s\s+/', '\\n', $value )), ENT_QUOTES, 'UTF-8' ); |
|
162 | + if( $helper->startsWith( 'translations', $key ) && $helper->endsWith( 'id', $key ) )continue; |
|
163 | + $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' ); |
|
164 | 164 | $details[$key] = $value; |
165 | 165 | } |
166 | 166 | return $details; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | return $value; |
241 | 241 | } |
242 | 242 | } |
243 | - return implode( ',', array_filter( [DB_HOST, $serverName] )); |
|
243 | + return implode( ',', array_filter( [DB_HOST, $serverName] ) ); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | { |
262 | 262 | $plugins = get_plugins(); |
263 | 263 | $activePlugins = (array)get_option( 'active_plugins', [] ); |
264 | - $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ))); |
|
265 | - $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive )); |
|
264 | + $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) ); |
|
265 | + $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) ); |
|
266 | 266 | return $active + $inactive; |
267 | 267 | } |
268 | 268 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | protected function implode( $title, array $details ) |
274 | 274 | { |
275 | 275 | $strings = ['['.$title.']']; |
276 | - $padding = max( array_map( 'strlen', array_keys( $details )) ); |
|
276 | + $padding = max( array_map( 'strlen', array_keys( $details ) ) ); |
|
277 | 277 | $padding = max( [$padding, static::PAD] ); |
278 | 278 | foreach( $details as $key => $value ) { |
279 | 279 | $strings[] = is_string( $key ) |
@@ -22,17 +22,17 @@ discard block |
||
22 | 22 | { |
23 | 23 | global $menu, $typenow; |
24 | 24 | foreach( $menu as $key => $value ) { |
25 | - if( !isset( $value[2] ) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
25 | + if( !isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
26 | 26 | $postCount = wp_count_posts( Application::POST_TYPE ); |
27 | 27 | $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [ |
28 | 28 | 'class' => 'pending-count', |
29 | - ]); |
|
29 | + ] ); |
|
30 | 30 | $awaitingModeration = glsr( Builder::class )->span( $pendingCount, [ |
31 | 31 | 'class' => 'awaiting-mod count-'.$postCount->pending, |
32 | - ]); |
|
32 | + ] ); |
|
33 | 33 | $menu[$key][0] .= $awaitingModeration; |
34 | 34 | if( $typenow === Application::POST_TYPE ) { |
35 | - $menu[$key][4].= ' current'; |
|
35 | + $menu[$key][4] .= ' current'; |
|
36 | 36 | } |
37 | 37 | break; |
38 | 38 | } |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | 'tools' => __( 'Tools', 'site-reviews' ), |
50 | 50 | 'documentation' => __( 'Documentation', 'site-reviews' ), |
51 | 51 | 'addons' => __( 'Add-Ons', 'site-reviews' ), |
52 | - ]); |
|
52 | + ] ); |
|
53 | 53 | foreach( $pages as $slug => $title ) { |
54 | 54 | $method = glsr( Helper::class )->buildMethodName( 'render-'.$slug.'-menu' ); |
55 | 55 | $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug ); |
56 | - if( !is_callable( $callback ))continue; |
|
56 | + if( !is_callable( $callback ) )continue; |
|
57 | 57 | add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, Application::CAPABILITY, $slug, $callback ); |
58 | 58 | } |
59 | 59 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $this->renderPage( 'addons', [ |
69 | 69 | 'template' => glsr( Template::class ), |
70 | - ]); |
|
70 | + ] ); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | 'shortcodes' => __( 'Shortcodes', 'site-reviews' ), |
84 | 84 | 'hooks' => __( 'Hooks', 'site-reviews' ), |
85 | 85 | 'functions' => __( 'Functions', 'site-reviews' ), |
86 | - ]); |
|
86 | + ] ); |
|
87 | 87 | $this->renderPage( 'documentation', [ |
88 | 88 | 'tabs' => $tabs, |
89 | - ]); |
|
89 | + ] ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | 'schema' => __( 'Schema', 'site-reviews' ), |
104 | 104 | 'translations' => __( 'Translations', 'site-reviews' ), |
105 | 105 | 'licenses' => __( 'Licenses', 'site-reviews' ), |
106 | - ]); |
|
107 | - if( !apply_filters( 'site-reviews/addon/licenses', false )) { |
|
108 | - unset( $tabs['licenses'] ); |
|
106 | + ] ); |
|
107 | + if( !apply_filters( 'site-reviews/addon/licenses', false ) ) { |
|
108 | + unset($tabs['licenses']); |
|
109 | 109 | } |
110 | 110 | $this->renderPage( 'settings', [ |
111 | 111 | 'tabs' => $tabs, |
112 | 112 | 'template' => glsr( Template::class ), |
113 | - ]); |
|
113 | + ] ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | 'import-export' => __( 'Import/Export', 'site-reviews' ), |
125 | 125 | 'logging' => __( 'Logging', 'site-reviews' ), |
126 | 126 | 'system-info' => __( 'System Info', 'site-reviews' ), |
127 | - ]); |
|
127 | + ] ); |
|
128 | 128 | $this->renderPage( 'tools', [ |
129 | 129 | 'data' => [ |
130 | 130 | 'id' => Application::ID, |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | ], |
135 | 135 | 'html' => glsr( Html::class ), |
136 | 136 | 'tabs' => $tabs, |
137 | - ]); |
|
137 | + ] ); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |