@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | public function build() |
| 23 | 23 | { |
| 24 | - glsr_log()->error( 'Build method is not implemented for '.get_class( $this )); |
|
| 24 | + glsr_log()->error( 'Build method is not implemented for '.get_class( $this ) ); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | wp_parse_args( $args, static::defaults() ), |
| 42 | 42 | static::required() |
| 43 | 43 | ); |
| 44 | - $merged['class'] = implode( ' ', static::mergedAttribute( 'class', ' ', $args )); |
|
| 45 | - $merged['style'] = implode( ';', static::mergedAttribute( 'style', ';', $args )); |
|
| 44 | + $merged['class'] = implode( ' ', static::mergedAttribute( 'class', ' ', $args ) ); |
|
| 45 | + $merged['style'] = implode( ';', static::mergedAttribute( 'style', ';', $args ) ); |
|
| 46 | 46 | return $merged; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | public static function mergedAttribute( $key, $delimiter, array $args ) |
| 55 | 55 | { |
| 56 | 56 | return array_filter( array_merge( |
| 57 | - explode( $delimiter, glsr_get( $args, $key )), |
|
| 58 | - explode( $delimiter, glsr_get( static::defaults(), $key )), |
|
| 59 | - explode( $delimiter, glsr_get( static::required(), $key )) |
|
| 60 | - )); |
|
| 57 | + explode( $delimiter, glsr_get( $args, $key ) ), |
|
| 58 | + explode( $delimiter, glsr_get( static::defaults(), $key ) ), |
|
| 59 | + explode( $delimiter, glsr_get( static::required(), $key ) ) |
|
| 60 | + ) ); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | 'is_valid' => true, |
| 28 | 28 | 'is_widget' => false, |
| 29 | 29 | 'path' => '', |
| 30 | - ]); |
|
| 30 | + ] ); |
|
| 31 | 31 | $this->normalize(); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | if( !$this->field['is_valid'] )return; |
| 48 | 48 | if( $this->field['is_raw'] ) { |
| 49 | - return glsr( Builder::class )->{$this->field['type']}( $this->field ); |
|
| 49 | + return glsr( Builder::class )->{$this->field['type']}($this->field); |
|
| 50 | 50 | } |
| 51 | 51 | if( !$this->field['is_setting'] ) { |
| 52 | 52 | return $this->buildField(); |
@@ -75,15 +75,15 @@ discard block |
||
| 75 | 75 | 'class' => $this->getFieldClass(), |
| 76 | 76 | 'errors' => $this->getFieldErrors(), |
| 77 | 77 | 'field' => glsr( Builder::class )->raw( $this->field ), |
| 78 | - 'label' => glsr( Builder::class )->label([ |
|
| 78 | + 'label' => glsr( Builder::class )->label( [ |
|
| 79 | 79 | 'class' => 'glsr-'.$this->field['type'].'-label', |
| 80 | 80 | 'for' => $this->field['id'], |
| 81 | 81 | 'is_public' => $this->field['is_public'], |
| 82 | 82 | 'text' => $this->field['label'].'<span></span>', |
| 83 | 83 | 'type' => $this->field['type'], |
| 84 | - ]), |
|
| 84 | + ] ), |
|
| 85 | 85 | ], |
| 86 | - ]); |
|
| 86 | + ] ); |
|
| 87 | 87 | return apply_filters( 'site-reviews/rendered/field', $field, $this->field['type'], $this->field ); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | return glsr( Template::class )->build( 'partials/form/table-row', [ |
| 96 | 96 | 'context' => [ |
| 97 | 97 | 'class' => $this->getFieldClass(), |
| 98 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
| 98 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
| 99 | 99 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
| 100 | 100 | ], |
| 101 | - ]); |
|
| 101 | + ] ); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -107,16 +107,16 @@ discard block |
||
| 107 | 107 | protected function buildSettingMultiField() |
| 108 | 108 | { |
| 109 | 109 | $dependsOn = $this->getFieldDependsOn(); |
| 110 | - unset( $this->field['data-depends'] ); |
|
| 110 | + unset($this->field['data-depends']); |
|
| 111 | 111 | return glsr( Template::class )->build( 'partials/form/table-row-multiple', [ |
| 112 | 112 | 'context' => [ |
| 113 | 113 | 'class' => $this->getFieldClass(), |
| 114 | 114 | 'depends_on' => $dependsOn, |
| 115 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
| 115 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
| 116 | 116 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
| 117 | 117 | 'legend' => $this->field['legend'], |
| 118 | 118 | ], |
| 119 | - ]); |
|
| 119 | + ] ); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -125,13 +125,13 @@ discard block |
||
| 125 | 125 | protected function getFieldClass() |
| 126 | 126 | { |
| 127 | 127 | $classes = []; |
| 128 | - if( !empty( $this->field['errors'] )) { |
|
| 128 | + if( !empty($this->field['errors']) ) { |
|
| 129 | 129 | $classes[] = 'glsr-has-error'; |
| 130 | 130 | } |
| 131 | 131 | if( $this->field['is_hidden'] ) { |
| 132 | 132 | $classes[] = 'hidden'; |
| 133 | 133 | } |
| 134 | - if( !empty( $this->field['required'] )) { |
|
| 134 | + if( !empty($this->field['required']) ) { |
|
| 135 | 135 | $classes[] = 'glsr-required'; |
| 136 | 136 | } |
| 137 | 137 | $classes = apply_filters( 'site-reviews/rendered/field/classes', $classes, $this->field ); |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | protected function getFieldDependsOn() |
| 145 | 145 | { |
| 146 | - return !empty( $this->field['data-depends'] ) |
|
| 146 | + return !empty($this->field['data-depends']) |
|
| 147 | 147 | ? $this->field['data-depends'] |
| 148 | 148 | : ''; |
| 149 | 149 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | protected function getFieldErrors() |
| 155 | 155 | { |
| 156 | - if( empty( $this->field['errors'] ) || !is_array( $this->field['errors'] ))return; |
|
| 156 | + if( empty($this->field['errors']) || !is_array( $this->field['errors'] ) )return; |
|
| 157 | 157 | $errors = array_reduce( $this->field['errors'], function( $carry, $error ) { |
| 158 | 158 | return $carry.glsr( Builder::class )->span( $error, ['class' => 'glsr-field-error'] ); |
| 159 | 159 | }); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | 'context' => [ |
| 162 | 162 | 'errors' => $errors, |
| 163 | 163 | ], |
| 164 | - ]); |
|
| 164 | + ] ); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -184,13 +184,13 @@ discard block |
||
| 184 | 184 | 'name', 'type', |
| 185 | 185 | ]; |
| 186 | 186 | foreach( $requiredValues as $value ) { |
| 187 | - if( isset( $this->field[$value] ))continue; |
|
| 187 | + if( isset($this->field[$value]) )continue; |
|
| 188 | 188 | $missingValues[] = $value; |
| 189 | 189 | $this->field['is_valid'] = false; |
| 190 | 190 | } |
| 191 | - if( !empty( $missingValues )) { |
|
| 191 | + if( !empty($missingValues) ) { |
|
| 192 | 192 | glsr_log() |
| 193 | - ->warning( 'Field is missing: '.implode( ', ', $missingValues )) |
|
| 193 | + ->warning( 'Field is missing: '.implode( ', ', $missingValues ) ) |
|
| 194 | 194 | ->debug( $this->field ); |
| 195 | 195 | } |
| 196 | 196 | return $this->field['is_valid']; |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | if( !$this->isFieldValid() )return; |
| 205 | 205 | $this->field['path'] = $this->field['name']; |
| 206 | 206 | $className = glsr( Helper::class )->buildClassName( $this->field['type'], __NAMESPACE__.'\Fields' ); |
| 207 | - if( class_exists( $className )) { |
|
| 207 | + if( class_exists( $className ) ) { |
|
| 208 | 208 | $this->field = $className::merge( $this->field ); |
| 209 | 209 | } |
| 210 | 210 | $this->normalizeFieldId(); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | protected function normalizeFieldId() |
| 218 | 218 | { |
| 219 | - if( isset( $this->field['id'] ) || $this->field['is_raw'] )return; |
|
| 219 | + if( isset($this->field['id']) || $this->field['is_raw'] )return; |
|
| 220 | 220 | $this->field['id'] = glsr( Helper::class )->convertPathToId( |
| 221 | 221 | $this->field['path'], |
| 222 | 222 | $this->getFieldPrefix() |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | { |
| 67 | 67 | $instance = new static; |
| 68 | 68 | $instance->setTagFromMethod( $method ); |
| 69 | - call_user_func_array( [$instance, 'normalize'], $args += ['',''] ); |
|
| 69 | + call_user_func_array( [$instance, 'normalize'], $args += ['', ''] ); |
|
| 70 | 70 | $tags = array_merge( static::TAGS_FORM, static::TAGS_SINGLE, static::TAGS_STRUCTURE, static::TAGS_TEXT ); |
| 71 | 71 | do_action_ref_array( 'site-reviews/builder', [$instance] ); |
| 72 | 72 | $generatedTag = in_array( $instance->tag, $tags ) |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | 'render' => 'is_bool', |
| 92 | 92 | 'tag' => 'is_string', |
| 93 | 93 | ]; |
| 94 | - if( !isset( $properties[$property] ) |
|
| 95 | - || empty( array_filter( [$value], $properties[$property] )) |
|
| 94 | + if( !isset($properties[$property]) |
|
| 95 | + || empty(array_filter( [$value], $properties[$property] )) |
|
| 96 | 96 | )return; |
| 97 | 97 | $this->$property = $value; |
| 98 | 98 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function getClosingTag() |
| 104 | 104 | { |
| 105 | - if( empty( $this->tag ))return; |
|
| 105 | + if( empty($this->tag) )return; |
|
| 106 | 106 | return '</'.$this->tag.'>'; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | public function getOpeningTag() |
| 113 | 113 | { |
| 114 | - if( empty( $this->tag ))return; |
|
| 115 | - $attributes = glsr( Attributes::class )->{$this->tag}( $this->args )->toString(); |
|
| 114 | + if( empty($this->tag) )return; |
|
| 115 | + $attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString(); |
|
| 116 | 116 | return '<'.trim( $this->tag.' '.$attributes ).'>'; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function getTag() |
| 123 | 123 | { |
| 124 | - if( in_array( $this->tag, static::TAGS_SINGLE )) { |
|
| 124 | + if( in_array( $this->tag, static::TAGS_SINGLE ) ) { |
|
| 125 | 125 | return $this->getOpeningTag(); |
| 126 | 126 | } |
| 127 | - if( !in_array( $this->tag, static::TAGS_FORM )) { |
|
| 127 | + if( !in_array( $this->tag, static::TAGS_FORM ) ) { |
|
| 128 | 128 | return $this->buildDefaultTag(); |
| 129 | 129 | } |
| 130 | 130 | return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription(); |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | public function raw( array $field ) |
| 137 | 137 | { |
| 138 | - unset( $field['label'] ); |
|
| 139 | - return $this->{$field['type']}( $field ); |
|
| 138 | + unset($field['label']); |
|
| 139 | + return $this->{$field['type']}($field); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | protected function buildCustomField() |
| 146 | 146 | { |
| 147 | 147 | $className = $this->getCustomFieldClassName(); |
| 148 | - if( class_exists( $className )) { |
|
| 148 | + if( class_exists( $className ) ) { |
|
| 149 | 149 | return (new $className( $this ))->build(); |
| 150 | 150 | } |
| 151 | 151 | glsr_log()->error( 'Field missing: '.$className ); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | protected function buildDefaultTag( $text = '' ) |
| 158 | 158 | { |
| 159 | - if( empty( $text )) { |
|
| 159 | + if( empty($text) ) { |
|
| 160 | 160 | $text = $this->args['text']; |
| 161 | 161 | } |
| 162 | 162 | return $this->getOpeningTag().$text.$this->getClosingTag(); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | protected function buildFieldDescription() |
| 169 | 169 | { |
| 170 | - if( empty( $this->args['description'] ))return; |
|
| 170 | + if( empty($this->args['description']) )return; |
|
| 171 | 171 | if( $this->args['is_widget'] ) { |
| 172 | 172 | return $this->small( $this->args['description'] ); |
| 173 | 173 | } |
@@ -179,13 +179,13 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | protected function buildFormInput() |
| 181 | 181 | { |
| 182 | - if( !in_array( $this->args['type'], ['checkbox', 'radio'] )) { |
|
| 183 | - if( isset( $this->args['multiple'] )) { |
|
| 184 | - $this->args['name'].= '[]'; |
|
| 182 | + if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) { |
|
| 183 | + if( isset($this->args['multiple']) ) { |
|
| 184 | + $this->args['name'] .= '[]'; |
|
| 185 | 185 | } |
| 186 | 186 | return $this->buildFormLabel().$this->getOpeningTag(); |
| 187 | 187 | } |
| 188 | - return empty( $this->args['options'] ) |
|
| 188 | + return empty($this->args['options']) |
|
| 189 | 189 | ? $this->buildFormInputChoice() |
| 190 | 190 | : $this->buildFormInputMultiChoice(); |
| 191 | 191 | } |
@@ -195,19 +195,19 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | protected function buildFormInputChoice() |
| 197 | 197 | { |
| 198 | - if( !empty( $this->args['text'] )) { |
|
| 198 | + if( !empty($this->args['text']) ) { |
|
| 199 | 199 | $this->args['label'] = $this->args['text']; |
| 200 | 200 | } |
| 201 | 201 | if( !$this->args['is_public'] ) { |
| 202 | - return $this->buildFormLabel([ |
|
| 202 | + return $this->buildFormLabel( [ |
|
| 203 | 203 | 'class' => 'glsr-'.$this->args['type'].'-label', |
| 204 | 204 | 'text' => $this->getOpeningTag().' '.$this->args['label'].'<span></span>', |
| 205 | - ]); |
|
| 205 | + ] ); |
|
| 206 | 206 | } |
| 207 | - return $this->getOpeningTag().$this->buildFormLabel([ |
|
| 207 | + return $this->getOpeningTag().$this->buildFormLabel( [ |
|
| 208 | 208 | 'class' => 'glsr-'.$this->args['type'].'-label', |
| 209 | 209 | 'text' => $this->args['label'].'<span></span>', |
| 210 | - ]); |
|
| 210 | + ] ); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -216,22 +216,22 @@ discard block |
||
| 216 | 216 | protected function buildFormInputMultiChoice() |
| 217 | 217 | { |
| 218 | 218 | if( $this->args['type'] == 'checkbox' ) { |
| 219 | - $this->args['name'].= '[]'; |
|
| 219 | + $this->args['name'] .= '[]'; |
|
| 220 | 220 | } |
| 221 | 221 | $index = 0; |
| 222 | - $options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) use( &$index ) { |
|
| 222 | + $options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) use(&$index) { |
|
| 223 | 223 | return $carry.$this->li( $this->{$this->args['type']}([ |
| 224 | 224 | 'checked' => in_array( $key, (array)$this->args['value'] ), |
| 225 | 225 | 'id' => $this->args['id'].'-'.$index++, |
| 226 | 226 | 'name' => $this->args['name'], |
| 227 | 227 | 'text' => $this->args['options'][$key], |
| 228 | 228 | 'value' => $key, |
| 229 | - ])); |
|
| 229 | + ]) ); |
|
| 230 | 230 | }); |
| 231 | 231 | return $this->ul( $options, [ |
| 232 | 232 | 'class' => $this->args['class'], |
| 233 | 233 | 'id' => $this->args['id'], |
| 234 | - ]); |
|
| 234 | + ] ); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -239,13 +239,13 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | protected function buildFormLabel( array $customArgs = [] ) |
| 241 | 241 | { |
| 242 | - if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return; |
|
| 242 | + if( empty($this->args['label']) || $this->args['type'] == 'hidden' )return; |
|
| 243 | 243 | return $this->label( wp_parse_args( $customArgs, [ |
| 244 | 244 | 'for' => $this->args['id'], |
| 245 | 245 | 'is_public' => $this->args['is_public'], |
| 246 | 246 | 'text' => $this->args['label'], |
| 247 | 247 | 'type' => $this->args['type'], |
| 248 | - ])); |
|
| 248 | + ] ) ); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -262,11 +262,11 @@ discard block |
||
| 262 | 262 | protected function buildFormSelectOptions() |
| 263 | 263 | { |
| 264 | 264 | return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) { |
| 265 | - return $carry.$this->option([ |
|
| 265 | + return $carry.$this->option( [ |
|
| 266 | 266 | 'selected' => $this->args['value'] == $key, |
| 267 | 267 | 'text' => $this->args['options'][$key], |
| 268 | 268 | 'value' => $key, |
| 269 | - ]); |
|
| 269 | + ] ); |
|
| 270 | 270 | }); |
| 271 | 271 | } |
| 272 | 272 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | protected function mergeArgsWithRequiredDefaults() |
| 303 | 303 | { |
| 304 | 304 | $className = $this->getCustomFieldClassName(); |
| 305 | - if( class_exists( $className )) { |
|
| 305 | + if( class_exists( $className ) ) { |
|
| 306 | 306 | $this->args = $className::merge( $this->args ); |
| 307 | 307 | } |
| 308 | 308 | $this->args = glsr( BuilderDefaults::class )->merge( $this->args ); |
@@ -314,16 +314,16 @@ discard block |
||
| 314 | 314 | */ |
| 315 | 315 | protected function normalize( ...$params ) |
| 316 | 316 | { |
| 317 | - if( is_string( $params[0] ) || is_numeric( $params[0] )) { |
|
| 317 | + if( is_string( $params[0] ) || is_numeric( $params[0] ) ) { |
|
| 318 | 318 | $this->setNameOrTextAttributeForTag( $params[0] ); |
| 319 | 319 | } |
| 320 | - if( is_array( $params[0] )) { |
|
| 320 | + if( is_array( $params[0] ) ) { |
|
| 321 | 321 | $this->args += $params[0]; |
| 322 | 322 | } |
| 323 | - else if( is_array( $params[1] )) { |
|
| 323 | + else if( is_array( $params[1] ) ) { |
|
| 324 | 324 | $this->args += $params[1]; |
| 325 | 325 | } |
| 326 | - if( !isset( $this->args['is_public'] )) { |
|
| 326 | + if( !isset($this->args['is_public']) ) { |
|
| 327 | 327 | $this->args['is_public'] = false; |
| 328 | 328 | } |
| 329 | 329 | } |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | protected function setTagFromMethod( $method ) |
| 348 | 348 | { |
| 349 | 349 | $this->tag = strtolower( $method ); |
| 350 | - if( in_array( $this->tag, static::INPUT_TYPES )) { |
|
| 350 | + if( in_array( $this->tag, static::INPUT_TYPES ) ) { |
|
| 351 | 351 | $this->args['type'] = $this->tag; |
| 352 | 352 | $this->tag = 'input'; |
| 353 | 353 | } |
@@ -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 = glsr_get( $this->fields, $key, glsr_get( $this->fields, $instance->tag )); |
|
| 111 | + $classes = glsr_get( $this->fields, $key, glsr_get( $this->fields, $instance->tag ) ); |
|
| 112 | 112 | $instance->args['class'] = trim( $args['class'].' '.$classes ); |
| 113 | 113 | do_action_ref_array( 'site-reviews/customize/'.$this->style, [$instance] ); |
| 114 | 114 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $args = wp_parse_args( $instance->args, [ |
| 141 | 141 | 'is_public' => false, |
| 142 | 142 | 'is_raw' => false, |
| 143 | - ]); |
|
| 143 | + ] ); |
|
| 144 | 144 | if( is_admin() || !$args['is_public'] || $args['is_raw'] ) { |
| 145 | 145 | return false; |
| 146 | 146 | } |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | sort( $newTTIds ); |
| 28 | 28 | sort( $oldTTIds ); |
| 29 | - if( $newTTIds === $oldTTIds || !$this->isReviewPostId( $postId ))return; |
|
| 30 | - $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
|
| 29 | + if( $newTTIds === $oldTTIds || !$this->isReviewPostId( $postId ) )return; |
|
| 30 | + $review = glsr( ReviewManager::class )->single( get_post( $postId ) ); |
|
| 31 | 31 | $ignoredIds = array_intersect( $oldTTIds, $newTTIds ); |
| 32 | 32 | $decreasedIds = array_diff( $oldTTIds, $ignoredIds ); |
| 33 | 33 | $increasedIds = array_diff( $newTTIds, $ignoredIds ); |
| 34 | - if( $review->term_ids = glsr( Database::class )->getTermIds( $decreasedIds, 'term_taxonomy_id' )) { |
|
| 34 | + if( $review->term_ids = glsr( Database::class )->getTermIds( $decreasedIds, 'term_taxonomy_id' ) ) { |
|
| 35 | 35 | glsr( CountsManager::class )->decreaseTermCounts( $review ); |
| 36 | 36 | } |
| 37 | - if( $review->term_ids = glsr( Database::class )->getTermIds( $increasedIds, 'term_taxonomy_id' )) { |
|
| 37 | + if( $review->term_ids = glsr( Database::class )->getTermIds( $increasedIds, 'term_taxonomy_id' ) ) { |
|
| 38 | 38 | glsr( CountsManager::class )->increaseTermCounts( $review ); |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function onAfterChangeStatus( $newStatus, $oldStatus, $post ) |
| 50 | 50 | { |
| 51 | - if( glsr_get( $post, 'post_type') != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ))return; |
|
| 52 | - $review = glsr( ReviewManager::class )->single( get_post( $post->ID )); |
|
| 51 | + if( glsr_get( $post, 'post_type' ) != Application::POST_TYPE || in_array( $oldStatus, ['new', $newStatus] ) )return; |
|
| 52 | + $review = glsr( ReviewManager::class )->single( get_post( $post->ID ) ); |
|
| 53 | 53 | if( $post->post_status == 'publish' ) { |
| 54 | 54 | glsr( CountsManager::class )->increase( $review ); |
| 55 | 55 | } |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function onBeforeDelete( $postId ) |
| 77 | 77 | { |
| 78 | - if( !$this->isReviewPostId( $postId ))return; |
|
| 79 | - $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
|
| 78 | + if( !$this->isReviewPostId( $postId ) )return; |
|
| 79 | + $review = glsr( ReviewManager::class )->single( get_post( $postId ) ); |
|
| 80 | 80 | glsr( CountsManager::class )->decrease( $review ); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | if( !$this->isReviewPostId( $postId ) |
| 94 | 94 | || !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) |
| 95 | 95 | )return; |
| 96 | - $review = glsr( ReviewManager::class )->single( get_post( $postId )); |
|
| 96 | + $review = glsr( ReviewManager::class )->single( get_post( $postId ) ); |
|
| 97 | 97 | if( $review->$metaKey == $metaValue )return; |
| 98 | 98 | $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' ); |
| 99 | 99 | call_user_func( [$this, $method], $review, $metaValue ); |
@@ -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 | /** |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | public function routerCountReviews( $showNotice = true ) |
| 149 | 149 | { |
| 150 | 150 | glsr( CountsManager::class )->countAll(); |
| 151 | - glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' )); |
|
| 151 | + glsr( OptionManager::class )->set( 'last_review_count', current_time( 'timestamp' ) ); |
|
| 152 | 152 | if( $showNotice ) { |
| 153 | - glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' )); |
|
| 153 | + glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
@@ -185,17 +185,17 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | $file = $_FILES['import-file']; |
| 187 | 187 | if( $file['error'] !== UPLOAD_ERR_OK ) { |
| 188 | - return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] )); |
|
| 188 | + return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) ); |
|
| 189 | 189 | } |
| 190 | - if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] )) { |
|
| 191 | - return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' )); |
|
| 190 | + if( $file['type'] !== 'application/json' || !glsr( Helper::class )->endsWith( '.json', $file['name'] ) ) { |
|
| 191 | + return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) ); |
|
| 192 | 192 | } |
| 193 | 193 | $settings = json_decode( file_get_contents( $file['tmp_name'] ), true ); |
| 194 | - if( empty( $settings )) { |
|
| 195 | - return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' )); |
|
| 194 | + if( empty($settings) ) { |
|
| 195 | + return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) ); |
|
| 196 | 196 | } |
| 197 | - glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings )); |
|
| 198 | - glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' )); |
|
| 197 | + glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) ); |
|
| 198 | + glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) ); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -213,6 +213,6 @@ discard block |
||
| 213 | 213 | UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ), |
| 214 | 214 | UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ), |
| 215 | 215 | ]; |
| 216 | - return glsr_get( $errors, $errorCode, __( 'Unknown upload error.', 'site-reviews' )); |
|
| 216 | + return glsr_get( $errors, $errorCode, __( 'Unknown upload error.', 'site-reviews' ) ); |
|
| 217 | 217 | } |
| 218 | 218 | } |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function renderTaxonomyFilter() |
| 37 | 37 | { |
| 38 | - if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ))return; |
|
| 38 | + if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ) )return; |
|
| 39 | 39 | echo glsr( Builder::class )->label( __( 'Filter by category', 'site-reviews' ), [ |
| 40 | 40 | 'class' => 'screen-reader-text', |
| 41 | 41 | 'for' => Application::TAXONOMY, |
| 42 | - ]); |
|
| 43 | - wp_dropdown_categories([ |
|
| 42 | + ] ); |
|
| 43 | + wp_dropdown_categories( [ |
|
| 44 | 44 | 'depth' => 3, |
| 45 | 45 | 'hide_empty' => true, |
| 46 | 46 | 'hide_if_empty' => true, |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | 'show_option_all' => $this->getShowOptionAll(), |
| 53 | 53 | 'taxonomy' => Application::TAXONOMY, |
| 54 | 54 | 'value_field' => 'slug', |
| 55 | - ]); |
|
| 55 | + ] ); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | { |
| 70 | 70 | if( $taxonomy != Application::TAXONOMY || count( $newTTIds ) <= 1 )return; |
| 71 | 71 | $diff = array_diff( $newTTIds, $oldTTIds ); |
| 72 | - if( empty( $newTerm = array_shift( $diff ))) { |
|
| 72 | + if( empty($newTerm = array_shift( $diff )) ) { |
|
| 73 | 73 | $newTerm = array_shift( $newTTIds ); |
| 74 | 74 | } |
| 75 | 75 | if( $newTerm ) { |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | { |
| 94 | 94 | $taxonomy = get_taxonomy( Application::TAXONOMY ); |
| 95 | 95 | return $taxonomy |
| 96 | - ? ucfirst( strtolower( $taxonomy->labels->all_items )) |
|
| 96 | + ? ucfirst( strtolower( $taxonomy->labels->all_items ) ) |
|
| 97 | 97 | : ''; |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -57,60 +57,60 @@ |
||
| 57 | 57 | */ |
| 58 | 58 | public function run() |
| 59 | 59 | { |
| 60 | - add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
| 61 | - add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] ); |
|
| 62 | - add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
| 63 | - add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
| 64 | - add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
| 65 | - add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
| 66 | - add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
| 67 | - add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
| 68 | - add_action( 'init', [$this->blocks, 'registerAssets'], 9 ); |
|
| 69 | - add_action( 'init', [$this->blocks, 'registerBlocks'] ); |
|
| 70 | - add_action( 'admin_footer', [$this->console, 'logOnce'] ); |
|
| 71 | - add_action( 'wp_footer', [$this->console, 'logOnce'] ); |
|
| 72 | - add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
| 73 | - add_action( 'add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes'] ); |
|
| 74 | - add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
| 75 | - add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
| 76 | - add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] ); |
|
| 77 | - add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
| 78 | - add_action( 'admin_head', [$this->editor, 'renderReviewFields'] ); |
|
| 79 | - add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
| 80 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
| 81 | - add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
| 82 | - add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
| 83 | - add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
| 60 | + add_action( 'admin_enqueue_scripts', [$this->admin, 'enqueueAssets'] ); |
|
| 61 | + add_action( 'admin_init', [$this->admin, 'registerTinymcePopups'] ); |
|
| 62 | + add_action( 'media_buttons', [$this->admin, 'renderTinymceButton'], 11 ); |
|
| 63 | + add_action( 'plugins_loaded', [$this->app, 'getDefaults'], 11 ); |
|
| 64 | + add_action( 'plugins_loaded', [$this->app, 'registerAddons'] ); |
|
| 65 | + add_action( 'plugins_loaded', [$this->app, 'registerLanguages'] ); |
|
| 66 | + add_action( 'plugins_loaded', [$this->app, 'registerReviewTypes'] ); |
|
| 67 | + add_action( 'upgrader_process_complete', [$this->app, 'upgraded'], 10, 2 ); |
|
| 68 | + add_action( 'init', [$this->blocks, 'registerAssets'], 9 ); |
|
| 69 | + add_action( 'init', [$this->blocks, 'registerBlocks'] ); |
|
| 70 | + add_action( 'admin_footer', [$this->console, 'logOnce'] ); |
|
| 71 | + add_action( 'wp_footer', [$this->console, 'logOnce'] ); |
|
| 72 | + add_action( 'admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels'] ); |
|
| 73 | + add_action( 'add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes'] ); |
|
| 74 | + add_action( 'admin_print_scripts', [$this->editor, 'removeAutosave'], 999 ); |
|
| 75 | + add_action( 'admin_menu', [$this->editor, 'removeMetaBoxes'] ); |
|
| 76 | + add_action( 'current_screen', [$this->editor, 'removePostTypeSupport'] ); |
|
| 77 | + add_action( 'post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox'] ); |
|
| 78 | + add_action( 'admin_head', [$this->editor, 'renderReviewFields'] ); |
|
| 79 | + add_action( 'admin_action_revert', [$this->editor, 'revertReview'] ); |
|
| 80 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'] ); |
|
| 81 | + add_action( 'admin_action_approve', [$this->listtable, 'approve'] ); |
|
| 82 | + add_action( 'bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2 ); |
|
| 83 | + add_action( 'restrict_manage_posts', [$this->listtable, 'renderColumnFilters'] ); |
|
| 84 | 84 | add_action( 'manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2 ); |
| 85 | - add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
| 86 | - add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
| 87 | - add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
| 88 | - add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
| 89 | - add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
| 90 | - add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
| 91 | - add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
| 92 | - add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
| 93 | - add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
| 94 | - add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
| 95 | - add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
| 96 | - add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] ); |
|
| 97 | - add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
| 98 | - add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 ); |
|
| 99 | - add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 ); |
|
| 100 | - add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] ); |
|
| 101 | - add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] ); |
|
| 102 | - add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 ); |
|
| 103 | - add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
| 104 | - add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
| 85 | + add_action( 'save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields'] ); |
|
| 86 | + add_action( 'pre_get_posts', [$this->listtable, 'setQueryForColumn'] ); |
|
| 87 | + add_action( 'admin_action_unapprove', [$this->listtable, 'unapprove'] ); |
|
| 88 | + add_action( 'init', [$this->main, 'registerPostType'], 8 ); |
|
| 89 | + add_action( 'init', [$this->main, 'registerShortcodes'] ); |
|
| 90 | + add_action( 'init', [$this->main, 'registerTaxonomy'] ); |
|
| 91 | + add_action( 'widgets_init', [$this->main, 'registerWidgets'] ); |
|
| 92 | + add_action( 'admin_menu', [$this->menu, 'registerMenuCount'] ); |
|
| 93 | + add_action( 'admin_menu', [$this->menu, 'registerSubMenus'] ); |
|
| 94 | + add_action( 'admin_init', [$this->menu, 'setCustomPermissions'], 999 ); |
|
| 95 | + add_action( 'wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999 ); |
|
| 96 | + add_filter( 'site-reviews/builder', [$this->public, 'modifyBuilder'] ); |
|
| 97 | + add_action( 'wp_footer', [$this->public, 'renderSchema'] ); |
|
| 98 | + add_action( 'set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6 ); |
|
| 99 | + add_action( 'transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3 ); |
|
| 100 | + add_action( 'site-reviews/review/created', [$this->review, 'onAfterCreate'] ); |
|
| 101 | + add_action( 'before_delete_post', [$this->review, 'onBeforeDelete'] ); |
|
| 102 | + add_action( 'update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4 ); |
|
| 103 | + add_action( 'admin_init', [$this->router, 'routeAdminPostRequest'] ); |
|
| 104 | + add_action( 'wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
|
| 105 | 105 | add_action( 'wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest'] ); |
| 106 | - add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
| 107 | - add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] ); |
|
| 108 | - add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
| 109 | - add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
| 110 | - add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
| 111 | - add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
| 112 | - add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
| 113 | - add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
| 114 | - add_action( 'set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6 ); |
|
| 106 | + add_action( 'init', [$this->router, 'routePublicPostRequest'] ); |
|
| 107 | + add_action( 'site-reviews/schedule/session/purge', [$this->session, 'deleteExpiredSessions'] ); |
|
| 108 | + add_action( 'admin_init', [$this->settings, 'registerSettings'] ); |
|
| 109 | + add_action( Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents'] ); |
|
| 110 | + add_action( Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents'] ); |
|
| 111 | + add_action( Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents'] ); |
|
| 112 | + add_action( Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents'] ); |
|
| 113 | + add_action( 'restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9 ); |
|
| 114 | + add_action( 'set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6 ); |
|
| 115 | 115 | } |
| 116 | 116 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | public function send() |
| 74 | 74 | { |
| 75 | 75 | if( !$this->message || !$this->subject || !$this->to )return; |
| 76 | - add_action( 'wp_mail_failed', [$this, 'logMailError']); |
|
| 76 | + add_action( 'wp_mail_failed', [$this, 'logMailError'] ); |
|
| 77 | 77 | $sent = wp_mail( |
| 78 | 78 | $this->to, |
| 79 | 79 | $this->subject, |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $this->headers, |
| 82 | 82 | $this->attachments |
| 83 | 83 | ); |
| 84 | - remove_action( 'wp_mail_failed', [$this, 'logMailError']); |
|
| 84 | + remove_action( 'wp_mail_failed', [$this, 'logMailError'] ); |
|
| 85 | 85 | $this->reset(); |
| 86 | 86 | return $sent; |
| 87 | 87 | } |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function buildPlainTextMessage( PHPMailer $phpmailer ) |
| 94 | 94 | { |
| 95 | - if( empty( $this->email ))return; |
|
| 96 | - if( $phpmailer->ContentType === 'text/plain' || !empty( $phpmailer->AltBody ))return; |
|
| 95 | + if( empty($this->email) )return; |
|
| 96 | + if( $phpmailer->ContentType === 'text/plain' || !empty($phpmailer->AltBody) )return; |
|
| 97 | 97 | $message = $this->stripHtmlTags( $phpmailer->Body ); |
| 98 | 98 | $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
| 99 | 99 | } |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | $allowed = [ |
| 107 | 107 | 'bcc', 'cc', 'from', 'reply-to', |
| 108 | 108 | ]; |
| 109 | - $headers = array_intersect_key( $this->email, array_flip( $allowed )); |
|
| 109 | + $headers = array_intersect_key( $this->email, array_flip( $allowed ) ); |
|
| 110 | 110 | $headers = array_filter( $headers ); |
| 111 | 111 | foreach( $headers as $key => $value ) { |
| 112 | - unset( $headers[$key] ); |
|
| 112 | + unset($headers[$key]); |
|
| 113 | 113 | $headers[] = $key.': '.$value; |
| 114 | 114 | } |
| 115 | 115 | $headers[] = 'Content-Type: text/html'; |
@@ -121,16 +121,16 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | protected function buildHtmlMessage() |
| 123 | 123 | { |
| 124 | - $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' )); |
|
| 125 | - if( !empty( $template )) { |
|
| 124 | + $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' ) ); |
|
| 125 | + if( !empty($template) ) { |
|
| 126 | 126 | $message = glsr( Template::class )->interpolate( $template, $this->email['template-tags'], $this->email['template'] ); |
| 127 | 127 | } |
| 128 | 128 | else if( $this->email['template'] ) { |
| 129 | 129 | $message = glsr( Template::class )->build( 'templates/'.$this->email['template'], [ |
| 130 | 130 | 'context' => $this->email['template-tags'], |
| 131 | - ]); |
|
| 131 | + ] ); |
|
| 132 | 132 | } |
| 133 | - if( !isset( $message )) { |
|
| 133 | + if( !isset($message) ) { |
|
| 134 | 134 | $message = $this->email['message']; |
| 135 | 135 | } |
| 136 | 136 | $message = $this->email['before'].$message.$this->email['after']; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $message = str_replace( ']]>', ']]>', $message ); |
| 142 | 142 | $message = glsr( Template::class )->build( 'partials/email/index', [ |
| 143 | 143 | 'context' => ['message' => $message], |
| 144 | - ]); |
|
| 144 | + ] ); |
|
| 145 | 145 | return apply_filters( 'site-reviews/email/message', stripslashes( $message ), 'html', $this ); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | protected function normalize( array $email = [] ) |
| 163 | 163 | { |
| 164 | 164 | $email = shortcode_atts( glsr( EmailDefaults::class )->defaults(), $email ); |
| 165 | - if( empty( $email['reply-to'] )) { |
|
| 165 | + if( empty($email['reply-to']) ) { |
|
| 166 | 166 | $email['reply-to'] = $email['from']; |
| 167 | 167 | } |
| 168 | 168 | $this->email = apply_filters( 'site-reviews/email/compose', $email, $this ); |