@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | public function defaults() |
14 | 14 | { |
15 | 15 | $settings = $this->settings(); |
16 | - $defaults = array_combine( array_keys( $settings ), array_column( $settings, 'default' )); |
|
16 | + $defaults = array_combine( array_keys( $settings ), array_column( $settings, 'default' ) ); |
|
17 | 17 | return wp_parse_args( $defaults, [ |
18 | 18 | 'version' => '', |
19 | 19 | 'version_upgraded_from' => '', |
20 | - ]); |
|
20 | + ] ); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | protected function normalize( array $settings ) |
58 | 58 | { |
59 | 59 | array_walk( $settings, function( &$setting ) { |
60 | - if( isset( $setting['default'] ))return; |
|
60 | + if( isset($setting['default']) )return; |
|
61 | 61 | $setting['default'] = ''; |
62 | 62 | }); |
63 | 63 | return $settings; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | public function all() |
25 | 25 | { |
26 | 26 | $options = get_option( static::databaseKey(), [] ); |
27 | - if( !is_array( $options )) { |
|
27 | + if( !is_array( $options ) ) { |
|
28 | 28 | delete_option( static::databaseKey() ); |
29 | 29 | $options = ['settings' => []]; |
30 | 30 | } |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | $options = $this->all(); |
43 | 43 | $pointer = &$options; |
44 | 44 | foreach( $keys as $key ) { |
45 | - if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] ))continue; |
|
45 | + if( !isset($pointer[$key]) || !is_array( $pointer[$key] ) )continue; |
|
46 | 46 | $pointer = &$pointer[$key]; |
47 | 47 | } |
48 | - unset( $pointer[$last] ); |
|
48 | + unset($pointer[$last]); |
|
49 | 49 | return $this->set( $options ); |
50 | 50 | } |
51 | 51 | |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | glsr( DefaultsManager::class )->defaults() |
78 | 78 | ); |
79 | 79 | array_walk( $options, function( &$value, $key ) { |
80 | - if( !is_string( $value ))return; |
|
81 | - $value = wp_kses( $value, wp_kses_allowed_html( 'post' )); |
|
80 | + if( !is_string( $value ) )return; |
|
81 | + $value = wp_kses( $value, wp_kses_allowed_html( 'post' ) ); |
|
82 | 82 | }); |
83 | 83 | return glsr( Helper::class )->convertDotNotationArray( $options ); |
84 | 84 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function set( $pathOrOptions, $value = '' ) |
92 | 92 | { |
93 | - if( is_string( $pathOrOptions )) { |
|
93 | + if( is_string( $pathOrOptions ) ) { |
|
94 | 94 | $pathOrOptions = glsr( Helper::class )->setPathValue( $pathOrOptions, $value, $this->all() ); |
95 | 95 | } |
96 | 96 | return update_option( static::databaseKey(), (array)$pathOrOptions ); |
@@ -42,7 +42,9 @@ discard block |
||
42 | 42 | $options = $this->all(); |
43 | 43 | $pointer = &$options; |
44 | 44 | foreach( $keys as $key ) { |
45 | - if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] ))continue; |
|
45 | + if( !isset( $pointer[$key] ) || !is_array( $pointer[$key] )) { |
|
46 | + continue; |
|
47 | + } |
|
46 | 48 | $pointer = &$pointer[$key]; |
47 | 49 | } |
48 | 50 | unset( $pointer[$last] ); |
@@ -77,7 +79,9 @@ discard block |
||
77 | 79 | glsr( DefaultsManager::class )->defaults() |
78 | 80 | ); |
79 | 81 | array_walk( $options, function( &$value, $key ) { |
80 | - if( !is_string( $value ))return; |
|
82 | + if( !is_string( $value )) { |
|
83 | + return; |
|
84 | + } |
|
81 | 85 | $value = wp_kses( $value, wp_kses_allowed_html( 'post' )); |
82 | 86 | }); |
83 | 87 | return glsr( Helper::class )->convertDotNotationArray( $options ); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | $links[] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [ |
36 | 36 | 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ), |
37 | - ]); |
|
37 | + ] ); |
|
38 | 38 | return $links; |
39 | 39 | } |
40 | 40 | |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | { |
47 | 47 | $postType = Application::POST_TYPE; |
48 | 48 | $postCount = wp_count_posts( $postType ); |
49 | - if( !isset( $postCount->publish ) || !$postCount->publish ) { |
|
49 | + if( !isset($postCount->publish) || !$postCount->publish ) { |
|
50 | 50 | return $items; |
51 | 51 | } |
52 | 52 | $postTypeObject = get_post_type_object( $postType ); |
53 | 53 | $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' ); |
54 | - $text = sprintf( $text, number_format_i18n( $postCount->publish )); |
|
54 | + $text = sprintf( $text, number_format_i18n( $postCount->publish ) ); |
|
55 | 55 | $items[] = $postTypeObject && current_user_can( $postTypeObject->cap->edit_posts ) |
56 | 56 | ? sprintf( '<a class="glsr-review-count" href="edit.php?post_type=%s">%s</a>', $postType, $text ) |
57 | 57 | : sprintf( '<span class="glsr-review-count">%s</span>', $text ); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | public function filterTinymcePlugins( array $plugins ) |
66 | 66 | { |
67 | 67 | if( user_can_richedit() |
68 | - && ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ))) { |
|
68 | + && (current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) ) { |
|
69 | 69 | $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' ); |
70 | 70 | } |
71 | 71 | return $plugins; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function registerPointers() |
79 | 79 | { |
80 | - $command = new RegisterPointers([[ |
|
80 | + $command = new RegisterPointers( [[ |
|
81 | 81 | 'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ), |
82 | 82 | 'id' => 'glsr-pointer-pinned', |
83 | 83 | 'position' => [ |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | 'screen' => Application::POST_TYPE, |
88 | 88 | 'target' => '#misc-pub-pinned', |
89 | 89 | 'title' => __( 'Pin Your Reviews', 'site-reviews' ), |
90 | - ]]); |
|
90 | + ]] ); |
|
91 | 91 | $this->execute( $command ); |
92 | 92 | } |
93 | 93 | |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function registerShortcodeButtons() |
99 | 99 | { |
100 | - $command = new RegisterShortcodeButtons([ |
|
100 | + $command = new RegisterShortcodeButtons( [ |
|
101 | 101 | 'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ), |
102 | 102 | 'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ), |
103 | 103 | 'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ), |
104 | - ]); |
|
104 | + ] ); |
|
105 | 105 | $this->execute( $command ); |
106 | 106 | } |
107 | 107 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | if( !$this->isReviewEditable( $post ) )return; |
115 | 115 | glsr()->render( 'partials/editor/review', [ |
116 | 116 | 'post' => $post, |
117 | - ]); |
|
117 | + ] ); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | public function renderReviewNotice( WP_Post $post ) |
125 | 125 | { |
126 | 126 | if( !$this->isReviewEditable( $post ) )return; |
127 | - glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' )); |
|
127 | + glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' ) ); |
|
128 | 128 | glsr()->render( 'partials/editor/notice' ); |
129 | 129 | } |
130 | 130 | |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | if( glsr_current_screen()->base != 'post' )return; |
138 | 138 | $shortcodes = []; |
139 | 139 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
140 | - if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ))continue; |
|
140 | + if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ) )continue; |
|
141 | 141 | $shortcodes[$shortcode] = $values; |
142 | 142 | } |
143 | - if( empty( $shortcodes ))return; |
|
143 | + if( empty($shortcodes) )return; |
|
144 | 144 | glsr()->render( 'partials/editor/tinymce', [ |
145 | 145 | 'shortcodes' => $shortcodes, |
146 | - ]); |
|
146 | + ] ); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | public function routerClearLog() |
153 | 153 | { |
154 | 154 | glsr( Logger::class )->clear(); |
155 | - glsr( Notice::class )->addSuccess( __( 'Log cleared.', 'site-reviews' )); |
|
155 | + glsr( Notice::class )->addSuccess( __( 'Log cleared.', 'site-reviews' ) ); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -186,17 +186,17 @@ discard block |
||
186 | 186 | { |
187 | 187 | $file = $_FILES['import-file']; |
188 | 188 | if( $file['error'] !== UPLOAD_ERR_OK ) { |
189 | - return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] )); |
|
189 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
190 | 190 | } |
191 | - if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) { |
|
192 | - return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' )); |
|
191 | + if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) { |
|
192 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
193 | 193 | } |
194 | 194 | $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
195 | - if( empty( $settings )) { |
|
196 | - return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' )); |
|
195 | + if( empty($settings) ) { |
|
196 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
197 | 197 | } |
198 | - glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings )); |
|
199 | - glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' )); |
|
198 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
199 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
215 | 215 | UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
216 | 216 | ]; |
217 | - return !isset( $errors[$errorCode] ) |
|
217 | + return !isset($errors[$errorCode]) |
|
218 | 218 | ? __( 'Unknown upload error.', 'site-reviews' ) |
219 | 219 | : $errors[$errorCode]; |
220 | 220 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function download( $filename, $content ) |
17 | 17 | { |
18 | - if( !current_user_can( Application::CAPABILITY ))return; |
|
18 | + if( !current_user_can( Application::CAPABILITY ) )return; |
|
19 | 19 | nocache_headers(); |
20 | 20 | header( 'Content-Type: text/plain' ); |
21 | 21 | header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function execute( $command ) |
32 | 32 | { |
33 | - $handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command )); |
|
34 | - if( !class_exists( $handlerClass )) { |
|
33 | + $handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command ) ); |
|
34 | + if( !class_exists( $handlerClass ) ) { |
|
35 | 35 | throw new InvalidArgumentException( 'Handler '.$handlerClass.' not found.' ); |
36 | 36 | } |
37 | 37 | try { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | catch( Exception $e ) { |
41 | 41 | status_header( 400 ); |
42 | - glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() )); |
|
42 | + glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() ) ); |
|
43 | 43 | glsr_log()->error( $e->getMessage() ); |
44 | 44 | } |
45 | 45 | } |
@@ -49,6 +49,6 @@ discard block |
||
49 | 49 | */ |
50 | 50 | protected function getPostId() |
51 | 51 | { |
52 | - return intval( filter_input( INPUT_GET, 'post' )); |
|
52 | + return intval( filter_input( INPUT_GET, 'post' ) ); |
|
53 | 53 | } |
54 | 54 | } |