@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | public function __construct() |
| 34 | 34 | { |
| 35 | 35 | static::$instance = $this; |
| 36 | - $this->file = realpath( trailingslashit( dirname( __DIR__ )).static::ID.'.php' ); |
|
| 36 | + $this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' ); |
|
| 37 | 37 | $plugin = get_file_data( $this->file, [ |
| 38 | 38 | 'languages' => 'Domain Path', |
| 39 | 39 | 'name' => 'Plugin Name', |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | $constant = 'static::'.$property; |
| 87 | 87 | return defined( $constant ) |
| 88 | - ? apply_filters( 'site-reviews/const/'.$property, constant( $constant )) |
|
| 88 | + ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) ) |
|
| 89 | 89 | : ''; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -103,15 +103,15 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function file( $view ) |
| 105 | 105 | { |
| 106 | - $view.= '.php'; |
|
| 106 | + $view .= '.php'; |
|
| 107 | 107 | $filePaths = []; |
| 108 | - if( glsr( Helper::class )->startsWith( 'templates/', $view )) { |
|
| 109 | - $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view )); |
|
| 108 | + if( glsr( Helper::class )->startsWith( 'templates/', $view ) ) { |
|
| 109 | + $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view ) ); |
|
| 110 | 110 | } |
| 111 | 111 | $filePaths[] = $this->path( $view ); |
| 112 | 112 | $filePaths[] = $this->path( 'views/'.$view ); |
| 113 | 113 | foreach( $filePaths as $file ) { |
| 114 | - if( !file_exists( $file ))continue; |
|
| 114 | + if( !file_exists( $file ) )continue; |
|
| 115 | 115 | return $file; |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function getDefaults() |
| 123 | 123 | { |
| 124 | - if( empty( $this->defaults )) { |
|
| 124 | + if( empty($this->defaults) ) { |
|
| 125 | 125 | $this->defaults = $this->make( DefaultsManager::class )->get(); |
| 126 | 126 | $this->upgrade(); |
| 127 | 127 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | public function hasPermission() |
| 135 | 135 | { |
| 136 | 136 | $isAdmin = $this->isAdmin(); |
| 137 | - return !$isAdmin || ( $isAdmin && current_user_can( $this->constant( 'CAPABILITY' ))); |
|
| 137 | + return !$isAdmin || ($isAdmin && current_user_can( $this->constant( 'CAPABILITY' ) )); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $types = apply_filters( 'site-reviews/addon/types', [] ); |
| 191 | 191 | $this->reviewTypes = wp_parse_args( $types, [ |
| 192 | 192 | 'local' => __( 'Local', 'site-reviews' ), |
| 193 | - ]); |
|
| 193 | + ] ); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | { |
| 202 | 202 | $view = apply_filters( 'site-reviews/render/view', $view, $data ); |
| 203 | 203 | $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data ); |
| 204 | - if( !file_exists( $file )) { |
|
| 204 | + if( !file_exists( $file ) ) { |
|
| 205 | 205 | glsr_log()->error( 'File not found: '.$file ); |
| 206 | 206 | return; |
| 207 | 207 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | public function scheduleCronJob() |
| 217 | 217 | { |
| 218 | - if( wp_next_scheduled( static::CRON_EVENT ))return; |
|
| 218 | + if( wp_next_scheduled( static::CRON_EVENT ) )return; |
|
| 219 | 219 | wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT ); |
| 220 | 220 | } |
| 221 | 221 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | public function unscheduleCronJob() |
| 235 | 235 | { |
| 236 | - wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT )), static::CRON_EVENT ); |
|
| 236 | + wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT ); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | */ |
| 266 | 266 | public function url( $path = '' ) |
| 267 | 267 | { |
| 268 | - $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' )); |
|
| 268 | + $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) ); |
|
| 269 | 269 | return apply_filters( 'site-reviews/url', $url, $path ); |
| 270 | 270 | } |
| 271 | 271 | } |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | 'templates/form/submit-button', |
| 51 | 51 | 'templates/reviews-form', |
| 52 | 52 | ]; |
| 53 | - if( !preg_match( '('.implode( '|', $styledViews ).')', $view )) { |
|
| 53 | + if( !preg_match( '('.implode( '|', $styledViews ).')', $view ) ) { |
|
| 54 | 54 | return $view; |
| 55 | 55 | } |
| 56 | 56 | $views = $this->generatePossibleViews( $view ); |
| 57 | 57 | foreach( $views as $possibleView ) { |
| 58 | - if( !file_exists( glsr()->file( $possibleView )))continue; |
|
| 58 | + if( !file_exists( glsr()->file( $possibleView ) ) )continue; |
|
| 59 | 59 | return glsr( Helper::class )->removePrefix( 'views/', $possibleView ); |
| 60 | 60 | } |
| 61 | 61 | return $view; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function modifyField( Builder $instance ) |
| 90 | 90 | { |
| 91 | - if( !$this->isPublicInstance( $instance ) || empty( array_filter( $this->fields )))return; |
|
| 91 | + if( !$this->isPublicInstance( $instance ) || empty(array_filter( $this->fields )) )return; |
|
| 92 | 92 | call_user_func_array( [$this, 'customize'], [&$instance] ); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | protected function customize( Builder $instance ) |
| 107 | 107 | { |
| 108 | - if( !array_key_exists( $instance->tag, $this->fields ))return; |
|
| 109 | - $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' )); |
|
| 108 | + if( !array_key_exists( $instance->tag, $this->fields ) )return; |
|
| 109 | + $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) ); |
|
| 110 | 110 | $key = $instance->tag.'_'.$args['type']; |
| 111 | - $classes = !isset( $this->fields[$key] ) |
|
| 111 | + $classes = !isset($this->fields[$key]) |
|
| 112 | 112 | ? $this->fields[$instance->tag] |
| 113 | 113 | : $this->fields[$key]; |
| 114 | 114 | $instance->args['class'] = trim( $args['class'].' '.$classes ); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $args = wp_parse_args( $instance->args, [ |
| 143 | 143 | 'is_public' => false, |
| 144 | 144 | 'is_raw' => false, |
| 145 | - ]); |
|
| 145 | + ] ); |
|
| 146 | 146 | if( is_admin() || !$args['is_public'] || $args['is_raw'] ) { |
| 147 | 147 | return false; |
| 148 | 148 | } |
@@ -20,16 +20,16 @@ discard block |
||
| 20 | 20 | foreach( array_keys( $ipAddresses ) as $version ) { |
| 21 | 21 | $url = 'https://www.cloudflare.com/ips-'.$version; |
| 22 | 22 | $response = wp_remote_get( $url ); |
| 23 | - if( is_wp_error( $response )) { |
|
| 23 | + if( is_wp_error( $response ) ) { |
|
| 24 | 24 | glsr_log()->error( $response->get_error_message() ); |
| 25 | 25 | continue; |
| 26 | 26 | } |
| 27 | - if(( $statusCode = wp_remote_retrieve_response_code( $response )) != '200' ) { |
|
| 27 | + if( ($statusCode = wp_remote_retrieve_response_code( $response )) != '200' ) { |
|
| 28 | 28 | glsr_log()->error( 'Unable to connect to '.$url.' ['.$statusCode.']' ); |
| 29 | 29 | continue; |
| 30 | 30 | } |
| 31 | 31 | $ipAddresses[$version] = array_filter( |
| 32 | - (array)preg_split( '/\R/', wp_remote_retrieve_body( $response )) |
|
| 32 | + (array)preg_split( '/\R/', wp_remote_retrieve_body( $response ) ) |
|
| 33 | 33 | ); |
| 34 | 34 | } |
| 35 | 35 | set_transient( Application::ID.'_cloudflare_ips', $ipAddresses, static::EXPIRY_TIME ); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | if( $test === false ) { |
| 65 | 65 | $response = wp_remote_post( 'https://api.wordpress.org/stats/php/1.0/' ); |
| 66 | 66 | $test = !is_wp_error( $response ) |
| 67 | - && in_array( $response['response']['code'], range( 200, 299 )) |
|
| 67 | + && in_array( $response['response']['code'], range( 200, 299 ) ) |
|
| 68 | 68 | ? 'Works' |
| 69 | 69 | : 'Does not work'; |
| 70 | 70 | set_transient( Application::ID.'_remote_post_test', $test, static::EXPIRY_TIME ); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | public function __construct( array $values = [] ) |
| 16 | 16 | { |
| 17 | 17 | $this->values = $values; |
| 18 | - parent::__construct( $values, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
| 18 | + parent::__construct( $values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function __toString() |
| 35 | 35 | { |
| 36 | - if( empty( $this->values ))return; |
|
| 36 | + if( empty($this->values) )return; |
|
| 37 | 37 | return glsr( Template::class )->build( 'templates/review', [ |
| 38 | 38 | 'context' => $this->values, |
| 39 | - ]); |
|
| 39 | + ] ); |
|
| 40 | 40 | } |
| 41 | 41 | } |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | $this->args = $args; |
| 30 | 30 | $this->max_num_pages = $maxPageCount; |
| 31 | 31 | $this->results = $reviews; |
| 32 | - parent::__construct( $reviews, ArrayObject::STD_PROP_LIST|ArrayObject::ARRAY_AS_PROPS ); |
|
| 32 | + parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS ); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function build( array $args = [] ) |
| 70 | 70 | { |
| 71 | - if( empty( $this->ID )) { |
|
| 71 | + if( empty($this->ID) ) { |
|
| 72 | 72 | return new ReviewHtml; |
| 73 | 73 | } |
| 74 | 74 | $partial = glsr( SiteReviewsPartial::class ); |
@@ -92,10 +92,10 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function offsetGet( $key ) |
| 94 | 94 | { |
| 95 | - if( property_exists( $this, $key )) { |
|
| 95 | + if( property_exists( $this, $key ) ) { |
|
| 96 | 96 | return $this->$key; |
| 97 | 97 | } |
| 98 | - if( array_key_exists( $key, (array)$this->custom )) { |
|
| 98 | + if( array_key_exists( $key, (array)$this->custom ) ) { |
|
| 99 | 99 | return $this->custom[$key]; |
| 100 | 100 | } |
| 101 | 101 | return null; |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function offsetSet( $key, $value ) |
| 110 | 110 | { |
| 111 | - if( property_exists( $this, $key )) { |
|
| 111 | + if( property_exists( $this, $key ) ) { |
|
| 112 | 112 | $this->$key = $value; |
| 113 | 113 | return; |
| 114 | 114 | } |
| 115 | - if( !is_array( $this->custom )) { |
|
| 115 | + if( !is_array( $this->custom ) ) { |
|
| 116 | 116 | $this->custom = array_filter( (array)$this->custom ); |
| 117 | 117 | } |
| 118 | 118 | $this->custom[$key] = $value; |
@@ -157,13 +157,13 @@ discard block |
||
| 157 | 157 | 'review_type' => 'local', |
| 158 | 158 | ]; |
| 159 | 159 | $meta = array_filter( |
| 160 | - array_map( 'array_shift', array_filter((array)get_post_meta( $post->ID ))), |
|
| 160 | + array_map( 'array_shift', array_filter( (array)get_post_meta( $post->ID ) ) ), |
|
| 161 | 161 | 'strlen' |
| 162 | 162 | ); |
| 163 | - $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta )); |
|
| 163 | + $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) ); |
|
| 164 | 164 | $this->modified = $this->isModified( $properties ); |
| 165 | 165 | array_walk( $properties, function( $value, $key ) { |
| 166 | - if( !property_exists( $this, $key ) || isset( $this->$key ))return; |
|
| 166 | + if( !property_exists( $this, $key ) || isset($this->$key) )return; |
|
| 167 | 167 | $this->$key = maybe_unserialize( $value ); |
| 168 | 168 | }); |
| 169 | 169 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | protected function setTermIds( WP_Post $post ) |
| 175 | 175 | { |
| 176 | 176 | $this->term_ids = []; |
| 177 | - if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY )))return; |
|
| 177 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) )return; |
|
| 178 | 178 | foreach( $terms as $term ) { |
| 179 | 179 | $this->term_ids[] = $term->term_id; |
| 180 | 180 | } |
@@ -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 | |
@@ -60,20 +60,20 @@ discard block |
||
| 60 | 60 | public function filterDashboardGlanceItems( $items ) |
| 61 | 61 | { |
| 62 | 62 | $postCount = wp_count_posts( Application::POST_TYPE ); |
| 63 | - if( empty( $postCount->publish )) { |
|
| 63 | + if( empty($postCount->publish) ) { |
|
| 64 | 64 | return $items; |
| 65 | 65 | } |
| 66 | 66 | $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' ); |
| 67 | - $text = sprintf( $text, number_format_i18n( $postCount->publish )); |
|
| 67 | + $text = sprintf( $text, number_format_i18n( $postCount->publish ) ); |
|
| 68 | 68 | $items = glsr( Helper::class )->consolidateArray( $items ); |
| 69 | 69 | $items[] = current_user_can( get_post_type_object( Application::POST_TYPE )->cap->edit_posts ) |
| 70 | 70 | ? glsr( Builder::class )->a( $text, [ |
| 71 | 71 | 'class' => 'glsr-review-count', |
| 72 | 72 | 'href' => 'edit.php?post_type='.Application::POST_TYPE, |
| 73 | - ]) |
|
| 73 | + ] ) |
|
| 74 | 74 | : glsr( Builder::class )->span( $text, [ |
| 75 | 75 | 'class' => 'glsr-review-count', |
| 76 | - ]); |
|
| 76 | + ] ); |
|
| 77 | 77 | return $items; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function filterTinymcePlugins( $plugins ) |
| 86 | 86 | { |
| 87 | - if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' )) { |
|
| 87 | + if( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) { |
|
| 88 | 88 | $plugins = glsr( Helper::class )->consolidateArray( $plugins ); |
| 89 | 89 | $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' ); |
| 90 | 90 | } |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function registerTinymcePopups() |
| 99 | 99 | { |
| 100 | - $command = new RegisterTinymcePopups([ |
|
| 100 | + $command = new RegisterTinymcePopups( [ |
|
| 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 | |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | public function renderTinymceButton( $editorId ) |
| 114 | 114 | { |
| 115 | 115 | $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId ); |
| 116 | - if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ))return; |
|
| 116 | + if( glsr_current_screen()->base != 'post' || !in_array( $editorId, $allowedEditors ) )return; |
|
| 117 | 117 | $shortcodes = []; |
| 118 | 118 | foreach( glsr()->mceShortcodes as $shortcode => $values ) { |
| 119 | 119 | $shortcodes[$shortcode] = $values; |
| 120 | 120 | } |
| 121 | - if( empty( $shortcodes ))return; |
|
| 121 | + if( empty($shortcodes) )return; |
|
| 122 | 122 | glsr()->render( 'partials/editor/tinymce', [ |
| 123 | 123 | 'shortcodes' => $shortcodes, |
| 124 | - ]); |
|
| 124 | + ] ); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | public function routerClearConsole() |
| 131 | 131 | { |
| 132 | 132 | glsr( Console::class )->clear(); |
| 133 | - glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' )); |
|
| 133 | + glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) ); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function routerFetchConsole() |
| 140 | 140 | { |
| 141 | - glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' )); |
|
| 141 | + glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) ); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -157,13 +157,13 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | $postIds = glsr( SqlQueries::class )->getReviewsMeta( 'assigned_to' ); |
| 159 | 159 | foreach( $postIds as $postId ) { |
| 160 | - $countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId )); |
|
| 160 | + $countManager->setPostCounts( $postId, $countManager->buildPostCounts( $postId ) ); |
|
| 161 | 161 | } |
| 162 | 162 | $countManager->setCounts( $countManager->buildCounts() ); |
| 163 | 163 | if( $showNotice ) { |
| 164 | - glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' )); |
|
| 164 | + glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
| 165 | 165 | } |
| 166 | - glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' )); |
|
| 166 | + glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ) ); |
|
| 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 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function routerChangeStatus( array $request ) |
| 24 | 24 | { |
| 25 | - wp_send_json_success( $this->execute( new ChangeStatus( $request ))); |
|
| 25 | + wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) ); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | public function routerClearConsole() |
| 32 | 32 | { |
| 33 | 33 | glsr( AdminController::class )->routerClearConsole(); |
| 34 | - wp_send_json_success([ |
|
| 34 | + wp_send_json_success( [ |
|
| 35 | 35 | 'console' => glsr( Console::class )->get(), |
| 36 | 36 | 'notices' => glsr( Notice::class )->get(), |
| 37 | - ]); |
|
| 37 | + ] ); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | public function routerCountReviews() |
| 44 | 44 | { |
| 45 | 45 | glsr( AdminController::class )->routerCountReviews(); |
| 46 | - wp_send_json_success([ |
|
| 46 | + wp_send_json_success( [ |
|
| 47 | 47 | 'notices' => glsr( Notice::class )->get(), |
| 48 | - ]); |
|
| 48 | + ] ); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | $shortcode = $request['shortcode']; |
| 57 | 57 | $response = false; |
| 58 | - if( array_key_exists( $shortcode, glsr()->mceShortcodes )) { |
|
| 58 | + if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) { |
|
| 59 | 59 | $data = glsr()->mceShortcodes[$shortcode]; |
| 60 | - if( !empty( $data['errors'] )) { |
|
| 60 | + if( !empty($data['errors']) ) { |
|
| 61 | 61 | $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )]; |
| 62 | 62 | } |
| 63 | 63 | $response = [ |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | public function routerFetchConsole() |
| 78 | 78 | { |
| 79 | 79 | glsr( AdminController::class )->routerFetchConsole(); |
| 80 | - wp_send_json_success([ |
|
| 80 | + wp_send_json_success( [ |
|
| 81 | 81 | 'console' => glsr( Console::class )->get(), |
| 82 | 82 | 'notices' => glsr( Notice::class )->get(), |
| 83 | - ]); |
|
| 83 | + ] ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | public function routerSearchPosts( array $request ) |
| 90 | 90 | { |
| 91 | 91 | $results = glsr( Database::class )->searchPosts( $request['search'] ); |
| 92 | - wp_send_json_success([ |
|
| 92 | + wp_send_json_success( [ |
|
| 93 | 93 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
| 94 | 94 | 'items' => $results, |
| 95 | - ]); |
|
| 95 | + ] ); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | public function routerSearchTranslations( array $request ) |
| 102 | 102 | { |
| 103 | - if( empty( $request['exclude'] )) { |
|
| 103 | + if( empty($request['exclude']) ) { |
|
| 104 | 104 | $request['exclude'] = []; |
| 105 | 105 | } |
| 106 | 106 | $results = glsr( Translation::class ) |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | ->exclude() |
| 109 | 109 | ->exclude( $request['exclude'] ) |
| 110 | 110 | ->renderResults(); |
| 111 | - wp_send_json_success([ |
|
| 111 | + wp_send_json_success( [ |
|
| 112 | 112 | 'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>', |
| 113 | 113 | 'items' => $results, |
| 114 | - ]); |
|
| 114 | + ] ); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | public function routerSubmitReview( array $request ) |
| 121 | 121 | { |
| 122 | 122 | $command = glsr( PublicController::class )->routerSubmitReview( $request ); |
| 123 | - $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ))); |
|
| 123 | + $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) ); |
|
| 124 | 124 | $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command ); |
| 125 | 125 | $data = [ |
| 126 | 126 | 'errors' => glsr( Session::class )->get( $command->form_id.'errors', false, true ), |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function routerTogglePinned( array $request ) |
| 142 | 142 | { |
| 143 | - $isPinned = $this->execute( new TogglePinned( $request )); |
|
| 144 | - wp_send_json_success([ |
|
| 143 | + $isPinned = $this->execute( new TogglePinned( $request ) ); |
|
| 144 | + wp_send_json_success( [ |
|
| 145 | 145 | 'notices' => glsr( Notice::class )->get(), |
| 146 | 146 | 'pinned' => $isPinned, |
| 147 | - ]); |
|
| 147 | + ] ); |
|
| 148 | 148 | } |
| 149 | 149 | } |
@@ -33,10 +33,10 @@ discard block |
||
| 33 | 33 | public function filterEnqueuedScripts( $tag, $handle ) |
| 34 | 34 | { |
| 35 | 35 | $scripts = [Application::ID.'/google-recaptcha']; |
| 36 | - if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ))) { |
|
| 36 | + if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ) ) ) { |
|
| 37 | 37 | $tag = str_replace( ' src=', ' async src=', $tag ); |
| 38 | 38 | } |
| 39 | - if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ))) { |
|
| 39 | + if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ) ) ) { |
|
| 40 | 40 | $tag = str_replace( ' src=', ' defer src=', $tag ); |
| 41 | 41 | } |
| 42 | 42 | return $tag; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function filterFieldOrder( array $config ) |
| 51 | 51 | { |
| 52 | - $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config )); |
|
| 52 | + $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config ) ); |
|
| 53 | 53 | return array_intersect_key( array_merge( array_flip( $order ), $config ), $config ); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | { |
| 101 | 101 | $validated = glsr( ValidateReview::class )->validate( $request ); |
| 102 | 102 | $command = new CreateReview( $validated->request ); |
| 103 | - if( empty( $validated->error ) && !$validated->recaptchaIsUnset ) { |
|
| 103 | + if( empty($validated->error) && !$validated->recaptchaIsUnset ) { |
|
| 104 | 104 | $this->execute( $command ); |
| 105 | 105 | } |
| 106 | 106 | return $command; |