@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function enqueueAssets() |
| 25 | 25 | { |
| 26 | - $command = new EnqueueAdminAssets([ |
|
| 26 | + $command = new EnqueueAdminAssets( [ |
|
| 27 | 27 | 'pointers' => [[ |
| 28 | 28 | 'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ), |
| 29 | 29 | 'id' => 'glsr-pointer-pinned', |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | 'target' => '#misc-pub-pinned', |
| 36 | 36 | 'title' => __( 'Pin Your Reviews', 'site-reviews' ), |
| 37 | 37 | ]], |
| 38 | - ]); |
|
| 38 | + ] ); |
|
| 39 | 39 | $this->execute( $command ); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [ |
| 49 | 49 | 'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ), |
| 50 | - ]); |
|
| 50 | + ] ); |
|
| 51 | 51 | return $links; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -58,19 +58,19 @@ discard block |
||
| 58 | 58 | public function filterDashboardGlanceItems( array $items ) |
| 59 | 59 | { |
| 60 | 60 | $postCount = wp_count_posts( Application::POST_TYPE ); |
| 61 | - if( empty( $postCount->publish )) { |
|
| 61 | + if( empty($postCount->publish) ) { |
|
| 62 | 62 | return $items; |
| 63 | 63 | } |
| 64 | 64 | $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' ); |
| 65 | - $text = sprintf( $text, number_format_i18n( $postCount->publish )); |
|
| 65 | + $text = sprintf( $text, number_format_i18n( $postCount->publish ) ); |
|
| 66 | 66 | $items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts ) |
| 67 | 67 | ? glsr( Builder::class )->a( $text, [ |
| 68 | 68 | 'class' => 'glsr-review-count', |
| 69 | 69 | 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
| 70 | - ]) |
|
| 70 | + ] ) |
|
| 71 | 71 | : glsr( Builder::class )->span( $text, [ |
| 72 | 72 | 'class' => 'glsr-review-count', |
| 73 | - ]); |
|
| 73 | + ] ); |
|
| 74 | 74 | return $items; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function filterTinymcePlugins( array $plugins ) |
| 82 | 82 | { |
| 83 | - if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) { |
|
| 83 | + if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) { |
|
| 84 | 84 | $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' ); |
| 85 | 85 | } |
| 86 | 86 | return $plugins; |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function registerTinymcePopups() |
| 94 | 94 | { |
| 95 | - $command = new RegisterTinymcePopups([ |
|
| 95 | + $command = new RegisterTinymcePopups( [ |
|
| 96 | 96 | 'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ), |
| 97 | 97 | 'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ), |
| 98 | 98 | 'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ), |
| 99 | - ]); |
|
| 99 | + ] ); |
|
| 100 | 100 | $this->execute( $command ); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -108,15 +108,15 @@ discard block |
||
| 108 | 108 | public function renderTinymceButton( $editorId ) |
| 109 | 109 | { |
| 110 | 110 | $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'] ); |
| 111 | - if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ))return; |
|
| 111 | + if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ) )return; |
|
| 112 | 112 | $shortcodes = []; |
| 113 | 113 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
| 114 | 114 | $shortcodes[$shortcode] = $values; |
| 115 | 115 | } |
| 116 | - if( empty( $shortcodes ))return; |
|
| 116 | + if( empty($shortcodes) )return; |
|
| 117 | 117 | glsr()->render( 'partials/editor/tinymce', [ |
| 118 | 118 | 'shortcodes' => $shortcodes, |
| 119 | - ]); |
|
| 119 | + ] ); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | public function routerClearConsole() |
| 126 | 126 | { |
| 127 | 127 | glsr( Console::class )->clear(); |
| 128 | - glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' )); |
|
| 128 | + glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) ); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function routerFetchConsole() |
| 135 | 135 | { |
| 136 | - glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' )); |
|
| 136 | + glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) ); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -143,22 +143,22 @@ discard block |
||
| 143 | 143 | public function routerCountReviews( $showNotice = true ) |
| 144 | 144 | { |
| 145 | 145 | $countManager = glsr( CountsManager::class ); |
| 146 | - $terms = get_terms([ |
|
| 146 | + $terms = get_terms( [ |
|
| 147 | 147 | 'hide_empty' => true, |
| 148 | 148 | 'taxonomy' => Application::TAXONOMY, |
| 149 | - ]); |
|
| 149 | + ] ); |
|
| 150 | 150 | foreach( $terms as $term ) { |
| 151 | - $countManager->setTermCounts( $term->term_id, $countManager->buildTermCounts( $term->term_id )); |
|
| 151 | + $countManager->setTermCounts( $term->term_id, $countManager->buildTermCounts( $term->term_id ) ); |
|
| 152 | 152 | } |
| 153 | 153 | $postIds = glsr( SqlQueries::class )->getReviewsMeta( 'assigned_to' ); |
| 154 | 154 | foreach( $postIds as $postId ) { |
| 155 | - $countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId )); |
|
| 155 | + $countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ) ); |
|
| 156 | 156 | } |
| 157 | 157 | $countManager->setCounts( $countManager->buildCounts() ); |
| 158 | 158 | if( $showNotice ) { |
| 159 | - glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' )); |
|
| 159 | + glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
| 160 | 160 | } |
| 161 | - glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' )); |
|
| 161 | + glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ) ); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -192,17 +192,17 @@ discard block |
||
| 192 | 192 | { |
| 193 | 193 | $file = $_FILES['import-file']; |
| 194 | 194 | if( $file['error'] !== UPLOAD_ERR_OK ) { |
| 195 | - return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] )); |
|
| 195 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
| 196 | 196 | } |
| 197 | - if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) { |
|
| 198 | - return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' )); |
|
| 197 | + if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) { |
|
| 198 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
| 199 | 199 | } |
| 200 | 200 | $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
| 201 | - if( empty( $settings )) { |
|
| 202 | - return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' )); |
|
| 201 | + if( empty($settings) ) { |
|
| 202 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
| 203 | 203 | } |
| 204 | - glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings )); |
|
| 205 | - glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' )); |
|
| 204 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
| 205 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
| 221 | 221 | UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
| 222 | 222 | ]; |
| 223 | - return !isset( $errors[$errorCode] ) |
|
| 223 | + return !isset($errors[$errorCode]) |
|
| 224 | 224 | ? __( 'Unknown upload error.', 'site-reviews' ) |
| 225 | 225 | : $errors[$errorCode]; |
| 226 | 226 | } |
@@ -108,12 +108,16 @@ |
||
| 108 | 108 | public function renderTinymceButton( $editorId ) |
| 109 | 109 | { |
| 110 | 110 | $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'] ); |
| 111 | - if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ))return; |
|
| 111 | + if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors )) { |
|
| 112 | + return; |
|
| 113 | + } |
|
| 112 | 114 | $shortcodes = []; |
| 113 | 115 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
| 114 | 116 | $shortcodes[$shortcode] = $values; |
| 115 | 117 | } |
| 116 | - if( empty( $shortcodes ))return; |
|
| 118 | + if( empty( $shortcodes )) { |
|
| 119 | + return; |
|
| 120 | + } |
|
| 117 | 121 | glsr()->render( 'partials/editor/tinymce', [ |
| 118 | 122 | 'shortcodes' => $shortcodes, |
| 119 | 123 | ]); |
@@ -31,25 +31,25 @@ discard block |
||
| 31 | 31 | public function __construct( $input ) |
| 32 | 32 | { |
| 33 | 33 | $this->request = $input; |
| 34 | - $this->ajax_request = isset( $input['_ajax_request'] ); |
|
| 34 | + $this->ajax_request = isset($input['_ajax_request']); |
|
| 35 | 35 | $this->assigned_to = $this->getNumeric( 'assign_to' ); |
| 36 | - $this->author = sanitize_text_field( $this->getUser( 'name' )); |
|
| 36 | + $this->author = sanitize_text_field( $this->getUser( 'name' ) ); |
|
| 37 | 37 | $this->avatar = $this->getAvatar(); |
| 38 | - $this->blacklisted = isset( $input['blacklisted'] ); |
|
| 39 | - $this->category = sanitize_key( $this->get( 'category' )); |
|
| 40 | - $this->content = sanitize_textarea_field( $this->get( 'content' )); |
|
| 38 | + $this->blacklisted = isset($input['blacklisted']); |
|
| 39 | + $this->category = sanitize_key( $this->get( 'category' ) ); |
|
| 40 | + $this->content = sanitize_textarea_field( $this->get( 'content' ) ); |
|
| 41 | 41 | $this->custom = $this->getCustom(); |
| 42 | 42 | $this->date = $this->getDate( 'date' ); |
| 43 | - $this->email = sanitize_email( $this->getUser( 'email' )); |
|
| 44 | - $this->form_id = sanitize_key( $this->get( 'form_id' )); |
|
| 43 | + $this->email = sanitize_email( $this->getUser( 'email' ) ); |
|
| 44 | + $this->form_id = sanitize_key( $this->get( 'form_id' ) ); |
|
| 45 | 45 | $this->ip_address = $this->get( 'ip_address' ); |
| 46 | - $this->post_id = intval( $this->get( '_post_id' )); |
|
| 47 | - $this->rating = intval( $this->get( 'rating' )); |
|
| 46 | + $this->post_id = intval( $this->get( '_post_id' ) ); |
|
| 47 | + $this->rating = intval( $this->get( 'rating' ) ); |
|
| 48 | 48 | $this->referer = $this->get( '_referer' ); |
| 49 | - $this->response = sanitize_textarea_field( $this->get( 'response' )); |
|
| 50 | - $this->terms = !empty( $input['terms'] ); |
|
| 51 | - $this->title = sanitize_text_field( $this->get( 'title' )); |
|
| 52 | - $this->url = esc_url_raw( $this->get( 'url' )); |
|
| 49 | + $this->response = sanitize_textarea_field( $this->get( 'response' ) ); |
|
| 50 | + $this->terms = !empty($input['terms']); |
|
| 51 | + $this->title = sanitize_text_field( $this->get( 'title' ) ); |
|
| 52 | + $this->url = esc_url_raw( $this->get( 'url' ) ); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | protected function get( $key ) |
| 60 | 60 | { |
| 61 | - return isset( $this->request[$key] ) |
|
| 61 | + return isset($this->request[$key]) |
|
| 62 | 62 | ? (string)$this->request[$key] |
| 63 | 63 | : ''; |
| 64 | 64 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | $avatar = $this->get( 'avatar' ); |
| 72 | 72 | return !filter_var( $avatar, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED | FILTER_FLAG_PATH_REQUIRED ) |
| 73 | - ? (string)get_avatar_url( $this->get( 'email' )) |
|
| 73 | + ? (string)get_avatar_url( $this->get( 'email' ) ) |
|
| 74 | 74 | : $avatar; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | ]; |
| 87 | 87 | $custom = $this->request; |
| 88 | 88 | foreach( $unset as $value ) { |
| 89 | - unset( $custom[$value] ); |
|
| 89 | + unset($custom[$value]); |
|
| 90 | 90 | } |
| 91 | 91 | return $custom; |
| 92 | 92 | } |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | protected function getDate( $key ) |
| 99 | 99 | { |
| 100 | - $date = strtotime( $this->get( $key )); |
|
| 100 | + $date = strtotime( $this->get( $key ) ); |
|
| 101 | 101 | if( $date === false ) { |
| 102 | 102 | $date = time(); |
| 103 | 103 | } |
| 104 | - return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date )); |
|
| 104 | + return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ) ); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -111,13 +111,13 @@ discard block |
||
| 111 | 111 | protected function getUser( $key ) |
| 112 | 112 | { |
| 113 | 113 | $value = $this->get( $key ); |
| 114 | - if( empty( $value )) { |
|
| 114 | + if( empty($value) ) { |
|
| 115 | 115 | $user = wp_get_current_user(); |
| 116 | 116 | $userValues = [ |
| 117 | 117 | 'email' => 'user_email', |
| 118 | 118 | 'name' => 'display_name', |
| 119 | 119 | ]; |
| 120 | - if( $user->exists() && array_key_exists( $key, $userValues )) { |
|
| 120 | + if( $user->exists() && array_key_exists( $key, $userValues ) ) { |
|
| 121 | 121 | return $user->{$userValues[$key]}; |
| 122 | 122 | } |
| 123 | 123 | } |