@@ -21,17 +21,17 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | global $menu, $typenow; |
| 23 | 23 | foreach( $menu as $key => $value ) { |
| 24 | - if( !isset( $value[2] ) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
| 24 | + if( !isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE )continue; |
|
| 25 | 25 | $postCount = wp_count_posts( Application::POST_TYPE ); |
| 26 | 26 | $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [ |
| 27 | 27 | 'class' => 'pending-count', |
| 28 | - ]); |
|
| 28 | + ] ); |
|
| 29 | 29 | $awaitingModeration = glsr( Builder::class )->span( $pendingCount, [ |
| 30 | 30 | 'class' => 'awaiting-mod count-'.$postCount->pending, |
| 31 | - ]); |
|
| 31 | + ] ); |
|
| 32 | 32 | $menu[$key][0] .= ' '.$awaitingModeration; |
| 33 | 33 | if( $typenow === Application::POST_TYPE ) { |
| 34 | - $menu[$key][4].= ' current'; |
|
| 34 | + $menu[$key][4] .= ' current'; |
|
| 35 | 35 | } |
| 36 | 36 | break; |
| 37 | 37 | } |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | 'tools' => __( 'Tools', 'site-reviews' ), |
| 49 | 49 | 'addons' => __( 'Add-Ons', 'site-reviews' ), |
| 50 | 50 | 'documentation' => __( 'Documentation', 'site-reviews' ), |
| 51 | - ]); |
|
| 51 | + ] ); |
|
| 52 | 52 | foreach( $pages as $slug => $title ) { |
| 53 | 53 | $method = glsr( Helper::class )->buildMethodName( 'render-'.$slug.'-menu' ); |
| 54 | 54 | $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug ); |
| 55 | - if( !is_callable( $callback ))continue; |
|
| 55 | + if( !is_callable( $callback ) )continue; |
|
| 56 | 56 | add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, Application::CAPABILITY, $slug, $callback ); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | { |
| 67 | 67 | $this->renderPage( 'addons', [ |
| 68 | 68 | 'template' => glsr( Template::class ), |
| 69 | - ]); |
|
| 69 | + ] ); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -82,10 +82,10 @@ discard block |
||
| 82 | 82 | 'shortcodes' => __( 'Shortcodes', 'site-reviews' ), |
| 83 | 83 | 'hooks' => __( 'Hooks', 'site-reviews' ), |
| 84 | 84 | 'functions' => __( 'Functions', 'site-reviews' ), |
| 85 | - ]); |
|
| 85 | + ] ); |
|
| 86 | 86 | $this->renderPage( 'documentation', [ |
| 87 | 87 | 'tabs' => $tabs, |
| 88 | - ]); |
|
| 88 | + ] ); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | 'schema' => __( 'Schema', 'site-reviews' ), |
| 103 | 103 | 'translations' => __( 'Translations', 'site-reviews' ), |
| 104 | 104 | 'licenses' => __( 'Licenses', 'site-reviews' ), |
| 105 | - ]); |
|
| 106 | - if( !apply_filters( 'site-reviews/addon/licenses', false )) { |
|
| 107 | - unset( $tabs['licenses'] ); |
|
| 105 | + ] ); |
|
| 106 | + if( !apply_filters( 'site-reviews/addon/licenses', false ) ) { |
|
| 107 | + unset($tabs['licenses']); |
|
| 108 | 108 | } |
| 109 | 109 | $this->renderPage( 'settings', [ |
| 110 | 110 | 'html' => glsr( Html::class ), |
| 111 | 111 | 'tabs' => $tabs, |
| 112 | - ]); |
|
| 112 | + ] ); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | 'import-export' => __( 'Import/Export', 'site-reviews' ), |
| 124 | 124 | 'logging' => __( 'Logging', 'site-reviews' ), |
| 125 | 125 | 'system-info' => __( 'System Info', 'site-reviews' ), |
| 126 | - ]); |
|
| 126 | + ] ); |
|
| 127 | 127 | $this->renderPage( 'tools', [ |
| 128 | 128 | 'data' => [ |
| 129 | 129 | 'context' => [ |
@@ -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 | /** |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | 'submit_button' => $this->buildSubmitButton(), |
| 31 | 31 | ], |
| 32 | 32 | 'fields' => $this->getFields(), |
| 33 | - ]); |
|
| 33 | + ] ); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | { |
| 49 | 49 | return glsr( Builder::class )->button( '<span></span>'.__( 'Submit your review', 'site-reviews' ), [ |
| 50 | 50 | 'type' => 'submit', |
| 51 | - ]); |
|
| 51 | + ] ); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -82,25 +82,25 @@ discard block |
||
| 82 | 82 | $fields = [[ |
| 83 | 83 | 'name' => 'assign_to', |
| 84 | 84 | 'value' => $this->args['assign_to'], |
| 85 | - ],[ |
|
| 85 | + ], [ |
|
| 86 | 86 | 'name' => 'category', |
| 87 | 87 | 'value' => $this->args['category'], |
| 88 | - ],[ |
|
| 88 | + ], [ |
|
| 89 | 89 | 'name' => 'excluded', |
| 90 | 90 | 'value' => $this->args['excluded'], |
| 91 | - ],[ |
|
| 91 | + ], [ |
|
| 92 | 92 | 'name' => 'id', |
| 93 | 93 | 'value' => $this->args['id'], |
| 94 | - ],[ |
|
| 94 | + ], [ |
|
| 95 | 95 | 'name' => '_wp_http_referer', |
| 96 | 96 | 'value' => wp_get_referer(), |
| 97 | - ],[ |
|
| 97 | + ], [ |
|
| 98 | 98 | 'name' => '_wpnonce', |
| 99 | 99 | 'value' => wp_create_nonce( 'post-review' ), |
| 100 | 100 | ]]; |
| 101 | 101 | return array_values( array_map( function( $field ) { |
| 102 | - return new Field( wp_parse_args( $field, ['type' => 'hidden'] )); |
|
| 103 | - }, $fields )); |
|
| 102 | + return new Field( wp_parse_args( $field, ['type' => 'hidden'] ) ); |
|
| 103 | + }, $fields ) ); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | protected function getHoneypotField() |
| 110 | 110 | { |
| 111 | - return new Field([ |
|
| 111 | + return new Field( [ |
|
| 112 | 112 | 'name' => 'gotcha', |
| 113 | 113 | 'type' => 'honeypot', |
| 114 | - ]); |
|
| 114 | + ] ); |
|
| 115 | 115 | } |
| 116 | 116 | } |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function __call( $method, $args ) |
| 65 | 65 | { |
| 66 | - $instance = new static( $this->globals ); |
|
| 66 | + $instance = new static($this->globals); |
|
| 67 | 67 | $instance->setTagFromMethod( $method ); |
| 68 | - call_user_func_array( [$instance, 'normalize'], $args += ['',''] ); |
|
| 68 | + call_user_func_array( [$instance, 'normalize'], $args += ['', ''] ); |
|
| 69 | 69 | $tags = array_merge( static::TAGS_FORM, static::TAGS_SINGLE, static::TAGS_STRUCTURE, static::TAGS_TEXT ); |
| 70 | 70 | $generatedTag = in_array( $instance->tag, $tags ) |
| 71 | 71 | ? $instance->buildTag() |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | 'render' => 'is_bool', |
| 90 | 90 | 'tag' => 'is_string', |
| 91 | 91 | ]; |
| 92 | - if( !isset( $properties[$property] ) |
|
| 93 | - || empty( array_filter( [$value], $properties[$property] )) |
|
| 92 | + if( !isset($properties[$property]) |
|
| 93 | + || empty(array_filter( [$value], $properties[$property] )) |
|
| 94 | 94 | )return; |
| 95 | 95 | $this->$property = $value; |
| 96 | 96 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function getOpeningTag() |
| 110 | 110 | { |
| 111 | - $attributes = glsr( Attributes::class )->{$this->tag}( $this->args )->toString(); |
|
| 111 | + $attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString(); |
|
| 112 | 112 | return '<'.trim( $this->tag.' '.$attributes ).'>'; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | protected function buildDefaultTag( $text = '' ) |
| 130 | 130 | { |
| 131 | - if( empty( $text )) { |
|
| 131 | + if( empty($text) ) { |
|
| 132 | 132 | $text = $this->args['text']; |
| 133 | 133 | } |
| 134 | 134 | return $this->getOpeningTag().$text.$this->getClosingTag(); |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | protected function buildFieldDescription() |
| 141 | 141 | { |
| 142 | - if( empty( $this->args['description'] ))return; |
|
| 143 | - if( !empty( $this->globals['is_widget'] )) { |
|
| 142 | + if( empty($this->args['description']) )return; |
|
| 143 | + if( !empty($this->globals['is_widget']) ) { |
|
| 144 | 144 | return $this->small( $this->args['description'] ); |
| 145 | 145 | } |
| 146 | 146 | return $this->p( $this->args['description'], ['class' => 'description'] ); |
@@ -151,10 +151,10 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | protected function buildFormInput() |
| 153 | 153 | { |
| 154 | - if( !in_array( $this->args['type'], ['checkbox', 'radio'] )) { |
|
| 154 | + if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) { |
|
| 155 | 155 | return $this->buildFormLabel().$this->getOpeningTag(); |
| 156 | 156 | } |
| 157 | - return empty( $this->args['options'] ) |
|
| 157 | + return empty($this->args['options']) |
|
| 158 | 158 | ? $this->buildFormInputChoice() |
| 159 | 159 | : $this->buildFormInputMultiChoice(); |
| 160 | 160 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | protected function buildFormInputMultiChoice() |
| 174 | 174 | { |
| 175 | 175 | if( $this->args['type'] == 'checkbox' ) { |
| 176 | - $this->args['name'].= '[]'; |
|
| 176 | + $this->args['name'] .= '[]'; |
|
| 177 | 177 | } |
| 178 | 178 | $options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) { |
| 179 | 179 | return $carry.$this->li( $this->{$this->args['type']}([ |
@@ -181,12 +181,12 @@ discard block |
||
| 181 | 181 | 'name' => $this->args['name'], |
| 182 | 182 | 'text' => $this->args['options'][$key], |
| 183 | 183 | 'value' => $key, |
| 184 | - ])); |
|
| 184 | + ]) ); |
|
| 185 | 185 | }); |
| 186 | 186 | return $this->ul( $options, [ |
| 187 | 187 | 'class' => $this->args['class'], |
| 188 | 188 | 'id' => $this->args['id'], |
| 189 | - ]); |
|
| 189 | + ] ); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | protected function buildFormLabel() |
| 196 | 196 | { |
| 197 | - if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return; |
|
| 198 | - return $this->label([ |
|
| 197 | + if( empty($this->args['label']) || $this->args['type'] == 'hidden' )return; |
|
| 198 | + return $this->label( [ |
|
| 199 | 199 | 'for' => $this->args['id'], |
| 200 | 200 | 'text' => $this->args['label'], |
| 201 | - ]); |
|
| 201 | + ] ); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -215,11 +215,11 @@ discard block |
||
| 215 | 215 | protected function buildFormSelectOptions() |
| 216 | 216 | { |
| 217 | 217 | return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) { |
| 218 | - return $carry.$this->option([ |
|
| 218 | + return $carry.$this->option( [ |
|
| 219 | 219 | 'selected' => $this->args['value'] == $key, |
| 220 | 220 | 'text' => $this->args['options'][$key], |
| 221 | 221 | 'value' => $key, |
| 222 | - ]); |
|
| 222 | + ] ); |
|
| 223 | 223 | }); |
| 224 | 224 | } |
| 225 | 225 | |
@@ -236,10 +236,10 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | protected function buildTag() |
| 238 | 238 | { |
| 239 | - if( in_array( $this->tag, static::TAGS_SINGLE )) { |
|
| 239 | + if( in_array( $this->tag, static::TAGS_SINGLE ) ) { |
|
| 240 | 240 | return $this->getOpeningTag(); |
| 241 | 241 | } |
| 242 | - if( !in_array( $this->tag, static::TAGS_FORM )) { |
|
| 242 | + if( !in_array( $this->tag, static::TAGS_FORM ) ) { |
|
| 243 | 243 | return $this->buildDefaultTag(); |
| 244 | 244 | } |
| 245 | 245 | return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription(); |
@@ -274,13 +274,13 @@ discard block |
||
| 274 | 274 | */ |
| 275 | 275 | protected function normalize( ...$params ) |
| 276 | 276 | { |
| 277 | - if( is_string( $params[0] ) || is_numeric( $params[0] )) { |
|
| 277 | + if( is_string( $params[0] ) || is_numeric( $params[0] ) ) { |
|
| 278 | 278 | $this->setNameOrTextAttributeForTag( $params[0] ); |
| 279 | 279 | } |
| 280 | - if( is_array( $params[0] )) { |
|
| 280 | + if( is_array( $params[0] ) ) { |
|
| 281 | 281 | $this->args += $params[0]; |
| 282 | 282 | } |
| 283 | - else if( is_array( $params[1] )) { |
|
| 283 | + else if( is_array( $params[1] ) ) { |
|
| 284 | 284 | $this->args += $params[1]; |
| 285 | 285 | } |
| 286 | 286 | $this->mergeArgsWithRequiredDefaults(); |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | protected function setTagFromMethod( $method ) |
| 306 | 306 | { |
| 307 | 307 | $this->tag = strtolower( $method ); |
| 308 | - if( in_array( $this->tag, static::INPUT_TYPES )) { |
|
| 308 | + if( in_array( $this->tag, static::INPUT_TYPES ) ) { |
|
| 309 | 309 | $this->args['type'] = $this->tag; |
| 310 | 310 | $this->tag = 'input'; |
| 311 | 311 | } |
@@ -27,13 +27,13 @@ |
||
| 27 | 27 | public function getFields( $id ) |
| 28 | 28 | { |
| 29 | 29 | $fields = []; |
| 30 | - $configPath = glsr()->path( 'config/'.$id.'.php' );; |
|
| 30 | + $configPath = glsr()->path( 'config/'.$id.'.php' ); ; |
|
| 31 | 31 | $values = file_exists( $configPath ) |
| 32 | 32 | ? include $configPath |
| 33 | 33 | : []; |
| 34 | 34 | $values = apply_filters( 'site-reviews/form/fields', $values ); |
| 35 | 35 | foreach( $values as $name => $field ) { |
| 36 | - $fields[] = new Field( wp_parse_args( $field, ['name' => $name] )); |
|
| 36 | + $fields[] = new Field( wp_parse_args( $field, ['name' => $name] ) ); |
|
| 37 | 37 | } |
| 38 | 38 | return $fields; |
| 39 | 39 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | : $this->$method( $id ); |
| 24 | 24 | return glsr( Template::class )->build( 'pages/settings/'.$id, [ |
| 25 | 25 | 'context' => $context, |
| 26 | - ]); |
|
| 26 | + ] ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | protected function getSettingFields( $path ) |
| 42 | 42 | { |
| 43 | 43 | $settings = glsr( DefaultsManager::class )->settings(); |
| 44 | - return array_filter( $settings, function( $key ) use( $path ) { |
|
| 44 | + return array_filter( $settings, function( $key ) use($path) { |
|
| 45 | 45 | return glsr( Helper::class )->startsWith( $path, $key ); |
| 46 | 46 | }, ARRAY_FILTER_USE_KEY ); |
| 47 | 47 | } |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | protected function getTemplateContext( $id ) |
| 54 | 54 | { |
| 55 | - $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
|
| 55 | + $fields = $this->getSettingFields( $this->normalizeSettingPath( $id ) ); |
|
| 56 | 56 | $rows = ''; |
| 57 | 57 | foreach( $fields as $name => $field ) { |
| 58 | 58 | $field = wp_parse_args( $field, [ |
| 59 | 59 | 'is_setting' => true, |
| 60 | 60 | 'name' => $name, |
| 61 | - ]); |
|
| 62 | - $rows.= new Field( $field ); |
|
| 61 | + ] ); |
|
| 62 | + $rows .= new Field( $field ); |
|
| 63 | 63 | } |
| 64 | 64 | return [ |
| 65 | 65 | 'rows' => $rows, |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | protected function getTemplateContextForTranslations() |
| 73 | 73 | { |
| 74 | 74 | $translations = glsr( Translator::class )->renderAll(); |
| 75 | - $class = empty( $translations ) |
|
| 75 | + $class = empty($translations) |
|
| 76 | 76 | ? 'glsr-hidden' |
| 77 | 77 | : ''; |
| 78 | 78 | return [ |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | { |
| 14 | 14 | $this->builder->args = wp_parse_args( $this->builder->args, [ |
| 15 | 15 | 'name' => $this->builder->args['text'], |
| 16 | - ]); |
|
| 16 | + ] ); |
|
| 17 | 17 | $this->mergeFieldArgs(); |
| 18 | 18 | $this->builder->tag = 'input'; |
| 19 | 19 | return $this->builder->getOpeningTag(); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | 'is_setting' => false, |
| 26 | 26 | 'is_valid' => true, |
| 27 | 27 | 'path' => '', |
| 28 | - ]); |
|
| 28 | + ] ); |
|
| 29 | 29 | $this->normalize(); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | return glsr( Template::class )->build( 'partials/form/field', [ |
| 72 | 72 | 'context' => [ |
| 73 | 73 | 'class' => $this->getFieldClass(), |
| 74 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
| 74 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
| 75 | 75 | ], |
| 76 | - ]); |
|
| 76 | + ] ); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -85,10 +85,10 @@ discard block |
||
| 85 | 85 | return glsr( Template::class )->build( 'partials/form/table-row', [ |
| 86 | 86 | 'context' => [ |
| 87 | 87 | 'class' => $this->getFieldClass(), |
| 88 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
| 88 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
| 89 | 89 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
| 90 | 90 | ], |
| 91 | - ]); |
|
| 91 | + ] ); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | 'context' => [ |
| 101 | 101 | 'class' => $this->getFieldClass(), |
| 102 | 102 | 'depends_on' => $this->getFieldDependsOn(), |
| 103 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
| 103 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
| 104 | 104 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
| 105 | 105 | 'legend' => $this->field['legend'], |
| 106 | 106 | ], |
| 107 | - ]); |
|
| 107 | + ] ); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | if( $this->field['is_hidden'] ) { |
| 117 | 117 | $classes[] = 'hidden'; |
| 118 | 118 | } |
| 119 | - if( !empty( $this->field['required'] )) { |
|
| 119 | + if( !empty($this->field['required']) ) { |
|
| 120 | 120 | $classes[] = 'glsr-required'; |
| 121 | 121 | } |
| 122 | 122 | return implode( ' ', $classes ); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | protected function getFieldDefault() |
| 129 | 129 | { |
| 130 | - return isset( $this->field['default'] ) |
|
| 130 | + return isset($this->field['default']) |
|
| 131 | 131 | ? $this->field['default'] |
| 132 | 132 | : ''; |
| 133 | 133 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | protected function getFieldDependsOn() |
| 139 | 139 | { |
| 140 | - return !empty( $this->field['depends_on'] ) |
|
| 140 | + return !empty($this->field['depends_on']) |
|
| 141 | 141 | ? $this->field['depends_on'] |
| 142 | 142 | : ''; |
| 143 | 143 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $path, |
| 164 | 164 | glsr( Helper::class )->getPathValue( $path, glsr()->defaults ) |
| 165 | 165 | ); |
| 166 | - if( is_array( $expectedValue )) { |
|
| 166 | + if( is_array( $expectedValue ) ) { |
|
| 167 | 167 | return !in_array( $optionValue, $expectedValue ); |
| 168 | 168 | } |
| 169 | 169 | return $optionValue != $expectedValue; |
@@ -181,13 +181,13 @@ discard block |
||
| 181 | 181 | 'name', 'type', |
| 182 | 182 | ]; |
| 183 | 183 | foreach( $requiredValues as $value ) { |
| 184 | - if( isset( $this->field[$value] ))continue; |
|
| 184 | + if( isset($this->field[$value]) )continue; |
|
| 185 | 185 | $missingValues[] = $value; |
| 186 | 186 | $isValid = $this->field['is_valid'] = false; |
| 187 | 187 | } |
| 188 | - if( !empty( $missingValues )) { |
|
| 188 | + if( !empty($missingValues) ) { |
|
| 189 | 189 | glsr_log() |
| 190 | - ->warning( 'Field is missing: '.implode( ', ', $missingValues )) |
|
| 190 | + ->warning( 'Field is missing: '.implode( ', ', $missingValues ) ) |
|
| 191 | 191 | ->info( $this->field ); |
| 192 | 192 | } |
| 193 | 193 | return $isValid; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $field = $this->field; |
| 203 | 203 | foreach( $field as $key => $value ) { |
| 204 | 204 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
| 205 | - if( !method_exists( $this, $methodName ))continue; |
|
| 205 | + if( !method_exists( $this, $methodName ) )continue; |
|
| 206 | 206 | $this->$methodName(); |
| 207 | 207 | } |
| 208 | 208 | $this->normalizeFieldId(); |
@@ -215,13 +215,13 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | protected function normalizeDependsOn() |
| 217 | 217 | { |
| 218 | - if( empty( $this->field['depends_on'] ) || !is_array( $this->field['depends_on'] ))return; |
|
| 218 | + if( empty($this->field['depends_on']) || !is_array( $this->field['depends_on'] ) )return; |
|
| 219 | 219 | $path = key( $this->field['depends_on'] ); |
| 220 | 220 | $value = $this->field['depends_on'][$path]; |
| 221 | - $this->field['depends_on'] = json_encode([ |
|
| 221 | + $this->field['depends_on'] = json_encode( [ |
|
| 222 | 222 | 'name' => glsr( Helper::class )->convertPathToName( $path, OptionManager::databaseKey() ), |
| 223 | 223 | 'value' => $value, |
| 224 | - ], JSON_HEX_APOS|JSON_HEX_QUOT ); |
|
| 224 | + ], JSON_HEX_APOS | JSON_HEX_QUOT ); |
|
| 225 | 225 | $this->field['is_hidden'] = $this->isFieldHidden( $path, $value ); |
| 226 | 226 | } |
| 227 | 227 | |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | protected function normalizeFieldId() |
| 232 | 232 | { |
| 233 | - if( isset( $this->field['id'] ) || empty( $this->field['label'] ))return; |
|
| 233 | + if( isset($this->field['id']) || empty($this->field['label']) )return; |
|
| 234 | 234 | $this->field['id'] = glsr( Helper::class )->convertNameToId( $this->field['name'] ); |
| 235 | 235 | } |
| 236 | 236 | |
@@ -240,13 +240,13 @@ discard block |
||
| 240 | 240 | protected function normalizeFieldType() |
| 241 | 241 | { |
| 242 | 242 | $className = glsr( Helper::class )->buildClassName( $this->field['type'], __NAMESPACE__.'\Fields' ); |
| 243 | - if( class_exists( $className )) { |
|
| 243 | + if( class_exists( $className ) ) { |
|
| 244 | 244 | $this->field = array_merge( |
| 245 | 245 | wp_parse_args( $this->field, $className::defaults() ), |
| 246 | 246 | $className::required() |
| 247 | 247 | ); |
| 248 | 248 | } |
| 249 | - if( in_array( $this->field['type'], static::MULTI_FIELD_TYPES )) { |
|
| 249 | + if( in_array( $this->field['type'], static::MULTI_FIELD_TYPES ) ) { |
|
| 250 | 250 | $this->field['is_multi'] = true; |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | protected function normalizeFieldValue() |
| 258 | 258 | { |
| 259 | - if( isset( $this->field['value'] ))return; |
|
| 259 | + if( isset($this->field['value']) )return; |
|
| 260 | 260 | $this->field['value'] = glsr( OptionManager::class )->get( |
| 261 | 261 | $this->field['path'], |
| 262 | 262 | $this->getFieldDefault() |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | { |
| 271 | 271 | if( !$this->field['is_setting'] )return; |
| 272 | 272 | $this->field['legend'] = $this->field['label']; |
| 273 | - unset( $this->field['label'] ); |
|
| 273 | + unset($this->field['label']); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -42,7 +42,9 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function build() |
| 44 | 44 | { |
| 45 | - if( !$this->field['is_valid'] )return; |
|
| 45 | + if( !$this->field['is_valid'] ) { |
|
| 46 | + return; |
|
| 47 | + } |
|
| 46 | 48 | if( $this->field['type'] == 'hidden' ) { |
| 47 | 49 | return glsr( Builder::class )->hidden( $this->field ); |
| 48 | 50 | } |
@@ -181,7 +183,9 @@ discard block |
||
| 181 | 183 | 'name', 'type', |
| 182 | 184 | ]; |
| 183 | 185 | foreach( $requiredValues as $value ) { |
| 184 | - if( isset( $this->field[$value] ))continue; |
|
| 186 | + if( isset( $this->field[$value] )) { |
|
| 187 | + continue; |
|
| 188 | + } |
|
| 185 | 189 | $missingValues[] = $value; |
| 186 | 190 | $isValid = $this->field['is_valid'] = false; |
| 187 | 191 | } |
@@ -198,11 +202,15 @@ discard block |
||
| 198 | 202 | */ |
| 199 | 203 | protected function normalize() |
| 200 | 204 | { |
| 201 | - if( !$this->isFieldValid() )return; |
|
| 205 | + if( !$this->isFieldValid() ) { |
|
| 206 | + return; |
|
| 207 | + } |
|
| 202 | 208 | $field = $this->field; |
| 203 | 209 | foreach( $field as $key => $value ) { |
| 204 | 210 | $methodName = glsr( Helper::class )->buildMethodName( $key, 'normalize' ); |
| 205 | - if( !method_exists( $this, $methodName ))continue; |
|
| 211 | + if( !method_exists( $this, $methodName )) { |
|
| 212 | + continue; |
|
| 213 | + } |
|
| 206 | 214 | $this->$methodName(); |
| 207 | 215 | } |
| 208 | 216 | $this->normalizeFieldId(); |
@@ -215,7 +223,9 @@ discard block |
||
| 215 | 223 | */ |
| 216 | 224 | protected function normalizeDependsOn() |
| 217 | 225 | { |
| 218 | - if( empty( $this->field['depends_on'] ) || !is_array( $this->field['depends_on'] ))return; |
|
| 226 | + if( empty( $this->field['depends_on'] ) || !is_array( $this->field['depends_on'] )) { |
|
| 227 | + return; |
|
| 228 | + } |
|
| 219 | 229 | $path = key( $this->field['depends_on'] ); |
| 220 | 230 | $value = $this->field['depends_on'][$path]; |
| 221 | 231 | $this->field['depends_on'] = json_encode([ |
@@ -230,7 +240,9 @@ discard block |
||
| 230 | 240 | */ |
| 231 | 241 | protected function normalizeFieldId() |
| 232 | 242 | { |
| 233 | - if( isset( $this->field['id'] ) || empty( $this->field['label'] ))return; |
|
| 243 | + if( isset( $this->field['id'] ) || empty( $this->field['label'] )) { |
|
| 244 | + return; |
|
| 245 | + } |
|
| 234 | 246 | $this->field['id'] = glsr( Helper::class )->convertNameToId( $this->field['name'] ); |
| 235 | 247 | } |
| 236 | 248 | |
@@ -256,7 +268,9 @@ discard block |
||
| 256 | 268 | */ |
| 257 | 269 | protected function normalizeFieldValue() |
| 258 | 270 | { |
| 259 | - if( isset( $this->field['value'] ))return; |
|
| 271 | + if( isset( $this->field['value'] )) { |
|
| 272 | + return; |
|
| 273 | + } |
|
| 260 | 274 | $this->field['value'] = glsr( OptionManager::class )->get( |
| 261 | 275 | $this->field['path'], |
| 262 | 276 | $this->getFieldDefault() |
@@ -268,7 +282,9 @@ discard block |
||
| 268 | 282 | */ |
| 269 | 283 | protected function normalizeLabel() |
| 270 | 284 | { |
| 271 | - if( !$this->field['is_setting'] )return; |
|
| 285 | + if( !$this->field['is_setting'] ) { |
|
| 286 | + return; |
|
| 287 | + } |
|
| 272 | 288 | $this->field['legend'] = $this->field['label']; |
| 273 | 289 | unset( $this->field['label'] ); |
| 274 | 290 | } |