@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function enqueueAssets() |
26 | 26 | { |
27 | - $command = new EnqueueAdminAssets([ |
|
27 | + $command = new EnqueueAdminAssets( [ |
|
28 | 28 | 'pointers' => [[ |
29 | 29 | 'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ), |
30 | 30 | 'id' => 'glsr-pointer-pinned', |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | 'target' => '#misc-pub-pinned', |
37 | 37 | 'title' => __( 'Pin Your Reviews', 'site-reviews' ), |
38 | 38 | ]], |
39 | - ]); |
|
39 | + ] ); |
|
40 | 40 | $this->execute( $command ); |
41 | 41 | } |
42 | 42 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | { |
49 | 49 | $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [ |
50 | 50 | 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ), |
51 | - ]); |
|
51 | + ] ); |
|
52 | 52 | return $links; |
53 | 53 | } |
54 | 54 | |
@@ -59,19 +59,19 @@ discard block |
||
59 | 59 | public function filterDashboardGlanceItems( array $items ) |
60 | 60 | { |
61 | 61 | $postCount = wp_count_posts( Application::POST_TYPE ); |
62 | - if( empty( $postCount->publish )) { |
|
62 | + if( empty($postCount->publish) ) { |
|
63 | 63 | return $items; |
64 | 64 | } |
65 | 65 | $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' ); |
66 | - $text = sprintf( $text, number_format_i18n( $postCount->publish )); |
|
66 | + $text = sprintf( $text, number_format_i18n( $postCount->publish ) ); |
|
67 | 67 | $items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts ) |
68 | 68 | ? glsr( Builder::class )->a( $text, [ |
69 | 69 | 'class' => 'glsr-review-count', |
70 | 70 | 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
71 | - ]) |
|
71 | + ] ) |
|
72 | 72 | : glsr( Builder::class )->span( $text, [ |
73 | 73 | 'class' => 'glsr-review-count', |
74 | - ]); |
|
74 | + ] ); |
|
75 | 75 | return $items; |
76 | 76 | } |
77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | public function filterTinymcePlugins( array $plugins ) |
83 | 83 | { |
84 | 84 | if( user_can_richedit() |
85 | - && ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ))) { |
|
85 | + && (current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) ) { |
|
86 | 86 | $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' ); |
87 | 87 | } |
88 | 88 | return $plugins; |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function registerShortcodeButtons() |
96 | 96 | { |
97 | - $command = new RegisterShortcodeButtons([ |
|
97 | + $command = new RegisterShortcodeButtons( [ |
|
98 | 98 | 'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ), |
99 | 99 | 'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ), |
100 | 100 | 'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ), |
101 | - ]); |
|
101 | + ] ); |
|
102 | 102 | $this->execute( $command ); |
103 | 103 | } |
104 | 104 | |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function renderReviewEditor( WP_Post $post ) |
110 | 110 | { |
111 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
111 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
112 | 112 | glsr()->render( 'partials/editor/review', [ |
113 | 113 | 'post' => $post, |
114 | - ]); |
|
114 | + ] ); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function renderReviewNotice( WP_Post $post ) |
122 | 122 | { |
123 | - if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ))return; |
|
124 | - glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' )); |
|
123 | + if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) )return; |
|
124 | + glsr( Notice::class )->addWarning( __( 'This review is read-only.', 'site-reviews' ) ); |
|
125 | 125 | glsr( Html::class )->renderTemplate( 'partials/editor/notice', [ |
126 | 126 | 'context' => [ |
127 | 127 | 'notices' => glsr( Notice::class )->get(), |
128 | 128 | ], |
129 | - ]); |
|
129 | + ] ); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | if( glsr_current_screen()->base != 'post' )return; |
139 | 139 | $shortcodes = []; |
140 | 140 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
141 | - if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ))continue; |
|
141 | + if( !apply_filters( sanitize_title( $shortcode ).'_condition', true ) )continue; |
|
142 | 142 | $shortcodes[$shortcode] = $values; |
143 | 143 | } |
144 | - if( empty( $shortcodes ))return; |
|
144 | + if( empty($shortcodes) )return; |
|
145 | 145 | glsr()->render( 'partials/editor/tinymce', [ |
146 | 146 | 'shortcodes' => $shortcodes, |
147 | - ]); |
|
147 | + ] ); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | public function routerClearConsole() |
154 | 154 | { |
155 | 155 | glsr( Console::class )->clear(); |
156 | - glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' )); |
|
156 | + glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) ); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | { |
164 | 164 | $counts = glsr( Database::class )->buildReviewCounts(); |
165 | 165 | glsr( OptionManager::class )->set( 'counts', $counts ); |
166 | - glsr( Notice::class )->addSuccess( __( 'Recalculated review counts.', 'site-reviews' )); |
|
166 | + glsr( Notice::class )->addSuccess( __( 'Recalculated review counts.', 'site-reviews' ) ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -197,17 +197,17 @@ discard block |
||
197 | 197 | { |
198 | 198 | $file = $_FILES['import-file']; |
199 | 199 | if( $file['error'] !== UPLOAD_ERR_OK ) { |
200 | - return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] )); |
|
200 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
201 | 201 | } |
202 | - if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) { |
|
203 | - return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' )); |
|
202 | + if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) { |
|
203 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
204 | 204 | } |
205 | 205 | $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
206 | - if( empty( $settings )) { |
|
207 | - return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' )); |
|
206 | + if( empty($settings) ) { |
|
207 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
208 | 208 | } |
209 | - glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings )); |
|
210 | - glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' )); |
|
209 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
210 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
226 | 226 | UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
227 | 227 | ]; |
228 | - return !isset( $errors[$errorCode] ) |
|
228 | + return !isset($errors[$errorCode]) |
|
229 | 229 | ? __( 'Unknown upload error.', 'site-reviews' ) |
230 | 230 | : $errors[$errorCode]; |
231 | 231 | } |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function deleteAllSessions( $sessionCookiePrefix ) |
25 | 25 | { |
26 | - return $this->db->query(" |
|
26 | + return $this->db->query( " |
|
27 | 27 | DELETE |
28 | 28 | FROM {$this->db->options} |
29 | 29 | WHERE option_name LIKE '{$sessionCookiePrefix}_%' |
30 | - "); |
|
30 | + " ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function deleteExpiredSessions( $expiredSessions ) |
38 | 38 | { |
39 | - return $this->db->query(" |
|
39 | + return $this->db->query( " |
|
40 | 40 | DELETE |
41 | 41 | FROM {$this->db->options} |
42 | 42 | WHERE option_name IN ('{$expiredSessions}') |
43 | - "); |
|
43 | + " ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function getReviewCounts( $metaKey ) |
51 | 51 | { |
52 | - return (array) $this->db->get_results(" |
|
52 | + return (array)$this->db->get_results( " |
|
53 | 53 | SELECT m.meta_value AS name, COUNT(*) num_posts |
54 | 54 | FROM {$this->db->posts} AS p |
55 | 55 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
56 | 56 | WHERE p.post_type = '{$this->postType}' |
57 | 57 | AND m.meta_key = '{$metaKey}' |
58 | 58 | GROUP BY name |
59 | - "); |
|
59 | + " ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function getExpiredSessions( $sessionCookiePrefix, $limit ) |
68 | 68 | { |
69 | - return $this->db->get_results(" |
|
69 | + return $this->db->get_results( " |
|
70 | 70 | SELECT option_name AS name, option_value AS expiration |
71 | 71 | FROM {$this->db->options} |
72 | 72 | WHERE option_name LIKE '{$sessionCookiePrefix}_expires_%' |
73 | 73 | ORDER BY option_value ASC |
74 | 74 | LIMIT 0, {$limit} |
75 | - "); |
|
75 | + " ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function getReviewPostId( $metaReviewId ) |
83 | 83 | { |
84 | - $postId = $this->db->get_var(" |
|
84 | + $postId = $this->db->get_var( " |
|
85 | 85 | SELECT p.ID |
86 | 86 | FROM {$this->db->posts} AS p |
87 | 87 | INNER JOIN {$this->db->postmeta} AS pm ON p.ID = pm.post_id |
88 | 88 | WHERE p.post_type = '{$this->postType}' |
89 | 89 | AND pm.meta_key = 'review_id' |
90 | 90 | AND pm.meta_value = '{$metaReviewId}' |
91 | - "); |
|
91 | + " ); |
|
92 | 92 | return intval( $postId ); |
93 | 93 | } |
94 | 94 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function getReviewIdsByType( $metaReviewType ) |
100 | 100 | { |
101 | - $query = $this->db->get_col(" |
|
101 | + $query = $this->db->get_col( " |
|
102 | 102 | SELECT m1.meta_value AS review_id |
103 | 103 | FROM {$this->db->posts} AS p |
104 | 104 | INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | AND m1.meta_key = 'review_id' |
108 | 108 | AND m2.meta_key = 'review_type' |
109 | 109 | AND m2.meta_value = '{$metaReviewType}' |
110 | - "); |
|
111 | - return array_keys( array_flip( $query )); |
|
110 | + " ); |
|
111 | + return array_keys( array_flip( $query ) ); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function getReviewRatings( $greaterThanId = 0, $limit = 100 ) |
120 | 120 | { |
121 | - return $this->db->get_results(" |
|
121 | + return $this->db->get_results( " |
|
122 | 122 | SELECT p.ID, m1.meta_value as rating, m2.meta_value as type |
123 | 123 | FROM {$this->db->posts} AS p |
124 | 124 | INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | public function getReviewRatingsFromIds( array $postIds, $greaterThanId = 0, $limit = 100 ) |
142 | 142 | { |
143 | 143 | sort( $postIds ); |
144 | - $postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds )), $limit ); |
|
144 | + $postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds ) ), $limit ); |
|
145 | 145 | $postIds = implode( ',', $postIds ); |
146 | - return $this->db->get_results(" |
|
146 | + return $this->db->get_results( " |
|
147 | 147 | SELECT p.ID, m.meta_value as rating |
148 | 148 | FROM {$this->db->posts} AS p |
149 | 149 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
@@ -167,13 +167,13 @@ discard block |
||
167 | 167 | $queryBuilder = glsr( QueryBuilder::class ); |
168 | 168 | $key = $queryBuilder->buildSqlOr( $key, "pm.meta_key = '%s'" ); |
169 | 169 | $status = $queryBuilder->buildSqlOr( $status, "p.post_status = '%s'" ); |
170 | - return $this->db->get_col(" |
|
170 | + return $this->db->get_col( " |
|
171 | 171 | SELECT DISTINCT pm.meta_value FROM {$this->db->postmeta} pm |
172 | 172 | LEFT JOIN {$this->db->posts} p ON p.ID = pm.post_id |
173 | 173 | WHERE p.post_type = '{$this->postType}' |
174 | 174 | AND ({$key}) |
175 | 175 | AND ({$status}) |
176 | 176 | ORDER BY pm.meta_value |
177 | - "); |
|
177 | + " ); |
|
178 | 178 | } |
179 | 179 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | if( $assignedPost instanceof WP_Post && $assignedPost->post_status == 'publish' ) { |
23 | 23 | $column = glsr( Builder::class )->a( get_the_title( $assignedPost->ID ), [ |
24 | 24 | 'href' => (string)get_the_permalink( $assignedPost->ID ), |
25 | - ]); |
|
25 | + ] ); |
|
26 | 26 | } |
27 | 27 | return $column; |
28 | 28 | } |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | $pinned = get_post_meta( $postId, 'pinned', true ) |
37 | 37 | ? 'pinned ' |
38 | 38 | : ''; |
39 | - return glsr( Builder::class )->i([ |
|
39 | + return glsr( Builder::class )->i( [ |
|
40 | 40 | 'class' => $pinned.'dashicons dashicons-sticky', |
41 | 41 | 'data-id' => $postId, |
42 | - ]); |
|
42 | + ] ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function buildColumnReviewer( $postId ) |
50 | 50 | { |
51 | - return strval( get_post_meta( $postId, 'author', true )); |
|
51 | + return strval( get_post_meta( $postId, 'author', true ) ); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | public function buildColumnRating( $postId ) |
60 | 60 | { |
61 | 61 | return glsr( Html::class )->buildPartial( 'star-rating', [ |
62 | - 'rating' => intval( get_post_meta( $postId, 'rating', true )), |
|
63 | - ]); |
|
62 | + 'rating' => intval( get_post_meta( $postId, 'rating', true ) ), |
|
63 | + ] ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | public function renderFilters( $postType ) |
83 | 83 | { |
84 | 84 | if( $postType !== Application::POST_TYPE )return; |
85 | - if( !( $status = filter_input( INPUT_GET, 'post_status' ))) { |
|
85 | + if( !($status = filter_input( INPUT_GET, 'post_status' )) ) { |
|
86 | 86 | $status = 'publish'; |
87 | 87 | } |
88 | 88 | $ratings = glsr( Database::class )->getReviewsMeta( 'rating', $status ); |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | */ |
112 | 112 | protected function renderFilterRatings( $ratings ) |
113 | 113 | { |
114 | - if( empty( $ratings ))return; |
|
115 | - $ratings = array_flip( array_reverse( $ratings )); |
|
114 | + if( empty($ratings) )return; |
|
115 | + $ratings = array_flip( array_reverse( $ratings ) ); |
|
116 | 116 | array_walk( $ratings, function( &$value, $key ) { |
117 | 117 | $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
118 | 118 | $value = sprintf( $label, $key ); |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | echo glsr( Builder::class )->label( __( 'Filter by rating', 'site-reviews' ), [ |
121 | 121 | 'class' => 'screen-reader-text', |
122 | 122 | 'for' => 'rating', |
123 | - ]); |
|
124 | - echo glsr( Builder::class )->select([ |
|
123 | + ] ); |
|
124 | + echo glsr( Builder::class )->select( [ |
|
125 | 125 | 'name' => 'rating', |
126 | 126 | 'options' => ['' => __( 'All ratings', 'site-reviews' )] + $ratings, |
127 | 127 | 'value' => filter_input( INPUT_GET, 'rating' ), |
128 | - ]); |
|
128 | + ] ); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [ |
139 | 139 | 'class' => 'screen-reader-text', |
140 | 140 | 'for' => 'review_type', |
141 | - ]); |
|
142 | - echo glsr( Builder::class )->select([ |
|
141 | + ] ); |
|
142 | + echo glsr( Builder::class )->select( [ |
|
143 | 143 | 'name' => 'review_type', |
144 | 144 | 'options' => ['' => __( 'All types', 'site-reviews' )] + glsr()->reviewTypes, |
145 | 145 | 'value' => filter_input( INPUT_GET, 'review_type' ), |
146 | - ]); |
|
146 | + ] ); |
|
147 | 147 | } |
148 | 148 | } |
@@ -48,54 +48,54 @@ |
||
48 | 48 | */ |
49 | 49 | public function run() |
50 | 50 | { |
51 | - add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
52 | - add_action( 'admin_init', [$this->admin, 'registerShortcodeButtons'] ); |
|
53 | - add_action( 'edit_form_after_title', [$this->admin, 'renderReviewEditor'] ); |
|
54 | - add_action( 'edit_form_top', [$this->admin, 'renderReviewNotice'] ); |
|
55 | - add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
56 | - add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
57 | - add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
58 | - add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
59 | - add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
60 | - add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
61 | - add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
62 | - add_action( 'before_delete_post', [$this->editor, 'onBeforeDeleteReview'] ); |
|
63 | - add_action( 'update_postmeta', [$this->editor, 'onBeforeUpdateReview'], 10, 4 ); |
|
64 | - add_action( 'site-reviews/create/review', [$this->editor, 'onCreateReview'], 10, 3 ); |
|
65 | - add_action( 'transition_post_status', [$this->editor, 'onReviewStatusChange'], 10, 3 ); |
|
66 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'onSaveReview'], 20, 3 ); |
|
67 | - add_action( 'add_meta_boxes', [$this->editor, 'registerMetaBoxes'] ); |
|
68 | - add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
69 | - add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
70 | - add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
71 | - add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
72 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
73 | - add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
74 | - add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
75 | - add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
76 | - add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
|
77 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
78 | - add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
79 | - add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
80 | - add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
81 | - add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
82 | - add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
83 | - add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
84 | - add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
85 | - add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
86 | - add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
87 | - add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
88 | - add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
89 | - add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
90 | - add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
51 | + add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
52 | + add_action( 'admin_init', [$this->admin, 'registerShortcodeButtons'] ); |
|
53 | + add_action( 'edit_form_after_title', [$this->admin, 'renderReviewEditor'] ); |
|
54 | + add_action( 'edit_form_top', [$this->admin, 'renderReviewNotice'] ); |
|
55 | + add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
56 | + add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
57 | + add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
58 | + add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
59 | + add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
60 | + add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
61 | + add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
62 | + add_action( 'before_delete_post', [$this->editor, 'onBeforeDeleteReview'] ); |
|
63 | + add_action( 'update_postmeta', [$this->editor, 'onBeforeUpdateReview'], 10, 4 ); |
|
64 | + add_action( 'site-reviews/create/review', [$this->editor, 'onCreateReview'], 10, 3 ); |
|
65 | + add_action( 'transition_post_status', [$this->editor, 'onReviewStatusChange'], 10, 3 ); |
|
66 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'onSaveReview'], 20, 3 ); |
|
67 | + add_action( 'add_meta_boxes', [$this->editor, 'registerMetaBoxes'] ); |
|
68 | + add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
69 | + add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
70 | + add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
71 | + add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
72 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
73 | + add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
74 | + add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
75 | + add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
76 | + add_action( 'manage_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
|
77 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
78 | + add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
79 | + add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
80 | + add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
81 | + add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
82 | + add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
83 | + add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
84 | + add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
85 | + add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
86 | + add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
87 | + add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
88 | + add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
89 | + add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
90 | + add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
91 | 91 | add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
92 | - add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
93 | - add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] ); |
|
94 | - add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
95 | - add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
96 | - add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
97 | - add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
98 | - add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
99 | - add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
92 | + add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
93 | + add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] ); |
|
94 | + add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
95 | + add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
96 | + add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
97 | + add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
98 | + add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
99 | + add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
100 | 100 | } |
101 | 101 | } |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | { |
21 | 21 | $counts = []; |
22 | 22 | $greaterThanId = 0; |
23 | - while( $reviews = glsr( SqlQueries::class )->getReviewRatings( $greaterThanId )) { |
|
24 | - $types = array_keys( array_flip( array_column( $reviews, 'type' ))); |
|
23 | + while( $reviews = glsr( SqlQueries::class )->getReviewRatings( $greaterThanId ) ) { |
|
24 | + $types = array_keys( array_flip( array_column( $reviews, 'type' ) ) ); |
|
25 | 25 | foreach( $types as $type ) { |
26 | - if( isset( $counts[$type] ))continue; |
|
26 | + if( isset($counts[$type]) )continue; |
|
27 | 27 | $counts[$type] = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
28 | 28 | } |
29 | 29 | foreach( $reviews as $review ) { |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | $counts = array_fill_keys( range( 0, Rating::MAX_RATING ), 0 ); |
43 | 43 | $greaterThanId = 0; |
44 | - while( $reviews = glsr( SqlQueries::class )->getReviewRatingsFromIds( $postIds, $greaterThanId )) { |
|
44 | + while( $reviews = glsr( SqlQueries::class )->getReviewRatingsFromIds( $postIds, $greaterThanId ) ) { |
|
45 | 45 | foreach( $reviews as $review ) { |
46 | 46 | $counts[$review->rating]++; |
47 | 47 | } |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function getAssignedToPost( $postId, $assignedTo = '' ) |
59 | 59 | { |
60 | - if( empty( $assignedTo )) { |
|
60 | + if( empty($assignedTo) ) { |
|
61 | 61 | $assignedTo = get_post_meta( $postId, 'assigned_to', true ); |
62 | 62 | } |
63 | - if( empty( $assignedTo ))return; |
|
63 | + if( empty($assignedTo) )return; |
|
64 | 64 | $assignedPost = get_post( $assignedTo ); |
65 | 65 | if( $assignedPost instanceof WP_Post && $assignedPost->ID != $postId ) { |
66 | 66 | return $assignedPost; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | if( !$metaValue ) { |
82 | 82 | return $counts; |
83 | 83 | } |
84 | - return isset( $counts[$metaValue] ) |
|
84 | + return isset($counts[$metaValue]) |
|
85 | 85 | ? $counts[$metaValue] |
86 | 86 | : 0; |
87 | 87 | } |
@@ -95,15 +95,15 @@ discard block |
||
95 | 95 | 'max' => Rating::MAX_RATING, |
96 | 96 | 'min' => Rating::MIN_RATING, |
97 | 97 | 'types' => 'local', |
98 | - ]); |
|
98 | + ] ); |
|
99 | 99 | $counts = array_intersect_key( |
100 | 100 | glsr( OptionManager::class )->get( 'counts', [] ), |
101 | - array_flip( array_intersect( array_keys( glsr()->reviewTypes ), (array)$args['types'] )) |
|
101 | + array_flip( array_intersect( array_keys( glsr()->reviewTypes ), (array)$args['types'] ) ) |
|
102 | 102 | ); |
103 | - array_walk( $counts, function( &$ratings ) use( $args ) { |
|
103 | + array_walk( $counts, function( &$ratings ) use($args) { |
|
104 | 104 | $ratings[0] = 0; |
105 | 105 | foreach( $ratings as $index => &$num ) { |
106 | - if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ))continue; |
|
106 | + if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ) )continue; |
|
107 | 107 | $num = 0; |
108 | 108 | } |
109 | 109 | }); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function getReviewsMeta( $key, $status = 'publish' ) |
128 | 128 | { |
129 | - if( $status == 'all' || empty( $status )) { |
|
129 | + if( $status == 'all' || empty($status) ) { |
|
130 | 130 | $status = get_post_stati( ['exclude_from_search' => false] ); |
131 | 131 | } |
132 | 132 | return glsr( SqlQueries::class )->getReviewsMeta( $key, $status ); |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | 'fields' => 'id=>name', |
142 | 142 | 'hide_empty' => false, |
143 | 143 | 'taxonomy' => Application::TAXONOMY, |
144 | - ]); |
|
145 | - unset( $args['count'] ); // we don't want a term count |
|
144 | + ] ); |
|
145 | + unset($args['count']); // we don't want a term count |
|
146 | 146 | $terms = get_terms( $args ); |
147 | - if( is_wp_error( $terms )) { |
|
147 | + if( is_wp_error( $terms ) ) { |
|
148 | 148 | glsr_log()->error( $terms->get_error_message() ); |
149 | 149 | return []; |
150 | 150 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | 'post_status' => 'publish', |
162 | 162 | 'post_type' => 'any', |
163 | 163 | ]; |
164 | - if( is_numeric( $searchTerm )) { |
|
164 | + if( is_numeric( $searchTerm ) ) { |
|
165 | 165 | $args['post__in'] = [$searchTerm]; |
166 | 166 | } |
167 | 167 | else { |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | ob_start(); |
181 | 181 | glsr()->render( 'partials/editor/search-result', [ |
182 | 182 | 'ID' => get_the_ID(), |
183 | - 'permalink' => esc_url( (string) get_permalink() ), |
|
183 | + 'permalink' => esc_url( (string)get_permalink() ), |
|
184 | 184 | 'title' => esc_attr( get_the_title() ), |
185 | - ]); |
|
185 | + ] ); |
|
186 | 186 | $results .= ob_get_clean(); |
187 | 187 | } |
188 | 188 | wp_reset_postdata(); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function saveAssignedToMetabox( $postId ) |
88 | 88 | { |
89 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ))return; |
|
89 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-assigned-to' ), 'assigned_to' ) )return; |
|
90 | 90 | $assignedTo = glsr( Helper::class )->filterInput( 'assigned_to' ); |
91 | 91 | $assignedTo || $assignedTo = ''; |
92 | 92 | if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) { |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function saveResponseMetabox( $postId ) |
103 | 103 | { |
104 | - if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ))return; |
|
104 | + if( !wp_verify_nonce( glsr( Helper::class )->filterInput( '_nonce-response' ), 'response' ) )return; |
|
105 | 105 | $response = glsr( Helper::class )->filterInput( 'response' ); |
106 | 106 | $response || $response = ''; |
107 | 107 | update_post_meta( $postId, 'response', trim( wp_kses( $response, [ |
108 | 108 | 'a' => ['href' => [], 'title' => []], |
109 | 109 | 'em' => [], |
110 | 110 | 'strong' => [], |
111 | - ]))); |
|
111 | + ] ) ) ); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function getAssignedToPostId( $postId ) |
119 | 119 | { |
120 | - $assignedTo = intval( get_post_meta( $postId, 'assigned_to', true )); |
|
121 | - if(( $post = get_post( $assignedTo )) instanceof WP_Post ) { |
|
120 | + $assignedTo = intval( get_post_meta( $postId, 'assigned_to', true ) ); |
|
121 | + if( ($post = get_post( $assignedTo )) instanceof WP_Post ) { |
|
122 | 122 | return $post->ID; |
123 | 123 | } |
124 | 124 | return false; |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | $meta = wp_parse_args( $meta, [ |
133 | 133 | 'rating' => get_post_meta( $review->ID, 'rating', true ), |
134 | 134 | 'review_type' => get_post_meta( $review->ID, 'review_type', true ), |
135 | - ]); |
|
135 | + ] ); |
|
136 | 136 | if( !array_key_exists( $meta['review_type'], glsr()->reviewTypes ) |
137 | 137 | || intval( $meta['rating'] ) > Rating::MAX_RATING |
138 | 138 | )return; |
139 | 139 | $counts = glsr( OptionManager::class )->get( 'counts.'.$meta['review_type'], [] ); |
140 | 140 | foreach( range( 0, Rating::MAX_RATING ) as $rating ) { |
141 | - if( isset( $counts[$rating] ))continue; |
|
141 | + if( isset($counts[$rating]) )continue; |
|
142 | 142 | $counts[$rating] = 0; |
143 | 143 | } |
144 | 144 | ksort( $counts ); |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | */ |
151 | 151 | protected function setReviewCounts( WP_Post $review, array $counts ) |
152 | 152 | { |
153 | - $type = strval( get_post_meta( $review->ID, 'review_type', true )); |
|
154 | - if( !array_key_exists( $type, glsr()->reviewTypes ))return; |
|
153 | + $type = strval( get_post_meta( $review->ID, 'review_type', true ) ); |
|
154 | + if( !array_key_exists( $type, glsr()->reviewTypes ) )return; |
|
155 | 155 | glsr( OptionManager::class )->set( 'counts.'.$type, $counts ); |
156 | 156 | } |
157 | 157 | |
@@ -160,10 +160,10 @@ discard block |
||
160 | 160 | */ |
161 | 161 | protected function increaseReviewCount( WP_Post $review, array $meta = [] ) |
162 | 162 | { |
163 | - if( $counts = $this->getReviewCounts( $review, $meta )) { |
|
164 | - $rating = isset( $meta['rating'] ) |
|
163 | + if( $counts = $this->getReviewCounts( $review, $meta ) ) { |
|
164 | + $rating = isset($meta['rating']) |
|
165 | 165 | ? $meta['rating'] |
166 | - : intval( get_post_meta( $review->ID, 'rating', true )); |
|
166 | + : intval( get_post_meta( $review->ID, 'rating', true ) ); |
|
167 | 167 | $counts[$rating] -= 1; |
168 | 168 | $this->setReviewCounts( $review, $counts ); |
169 | 169 | } |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | */ |
175 | 175 | protected function decreaseReviewCount( WP_Post $review, array $meta = [] ) |
176 | 176 | { |
177 | - if( $counts = $this->getReviewCounts( $review, $meta )) { |
|
178 | - $rating = intval( get_post_meta( $review->ID, 'rating', true )); |
|
177 | + if( $counts = $this->getReviewCounts( $review, $meta ) ) { |
|
178 | + $rating = intval( get_post_meta( $review->ID, 'rating', true ) ); |
|
179 | 179 | $counts[$rating] += 1; |
180 | 180 | $this->setReviewCounts( $review, $counts ); |
181 | 181 | } |
@@ -202,19 +202,19 @@ discard block |
||
202 | 202 | */ |
203 | 203 | protected function updateAssignedToPost( WP_Post $review ) |
204 | 204 | { |
205 | - if( !( $postId = $this->getAssignedToPostId( $review->ID )))return; |
|
206 | - $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
|
207 | - if( empty( $reviewIds ))return; |
|
205 | + if( !($postId = $this->getAssignedToPostId( $review->ID )) )return; |
|
206 | + $reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) ); |
|
207 | + if( empty($reviewIds) )return; |
|
208 | 208 | $this->updateReviewIdOfPost( $postId, $review, $reviewIds ); |
209 | - $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID )); |
|
210 | - if( empty( $updatedReviewIds )) { |
|
209 | + $updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) ); |
|
210 | + if( empty($updatedReviewIds) ) { |
|
211 | 211 | delete_post_meta( $postId, static::META_RANKING ); |
212 | 212 | delete_post_meta( $postId, static::META_REVIEW_ID ); |
213 | 213 | } |
214 | - else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds )) { |
|
214 | + else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds ) ) { |
|
215 | 215 | $counts = glsr( Database::class )->buildReviewCountsFromIds( $updatedReviewIds ); |
216 | - update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $counts )); |
|
217 | - update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $counts )); |
|
216 | + update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $counts ) ); |
|
217 | + update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $counts ) ); |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | if( $review->post_status != 'publish' ) { |
228 | 228 | delete_post_meta( $postId, static::META_REVIEW_ID, $review->ID ); |
229 | 229 | } |
230 | - else if( !in_array( $review->ID, $reviewIds )) { |
|
230 | + else if( !in_array( $review->ID, $reviewIds ) ) { |
|
231 | 231 | add_post_meta( $postId, static::META_REVIEW_ID, $review->ID ); |
232 | 232 | } |
233 | 233 | } |