|
@@ -166,7 +166,7 @@ discard block |
|
|
block discarded – undo |
|
166
|
166
|
* @return \GV\Field The field implementation from configuration (\GV\GF_Field, \GV\Internal_Field). |
|
167
|
167
|
*/ |
|
168
|
168
|
public static function from_configuration( $configuration ) { |
|
169
|
|
- if ( empty( $configuration['id'] ) ) { |
|
|
169
|
+ if ( empty( $configuration[ 'id' ] ) ) { |
|
170
|
170
|
$field = new self(); |
|
171
|
171
|
gravityview()->log->error( 'Trying to get field from configuration without a field ID.', array( 'data' => $configuration ) ); |
|
172
|
172
|
$field->update_configuration( $configuration ); |
|
@@ -179,8 +179,8 @@ discard block |
|
|
block discarded – undo |
|
179
|
179
|
} else { |
|
180
|
180
|
$trace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); |
|
181
|
181
|
} |
|
182
|
|
- $trace = $trace[1]; |
|
183
|
|
- if ( $trace['function'] == 'from_configuration' && $trace['class'] == __CLASS__ ) { |
|
|
182
|
+ $trace = $trace[ 1 ]; |
|
|
183
|
+ if ( $trace[ 'function' ] == 'from_configuration' && $trace[ 'class' ] == __CLASS__ ) { |
|
184
|
184
|
$field = new self(); |
|
185
|
185
|
gravityview()->log->error( 'Infinite loop protection tripped. Returning default class here.' ); |
|
186
|
186
|
$field->update_configuration( $configuration ); |
|
@@ -188,7 +188,7 @@ discard block |
|
|
block discarded – undo |
|
188
|
188
|
} |
|
189
|
189
|
|
|
190
|
190
|
/** Determine the field implementation to use, and try to use. */ |
|
191
|
|
- $field_class = is_numeric( $configuration['id'] ) ? '\GV\GF_Field' : '\GV\Internal_Field'; |
|
|
191
|
+ $field_class = is_numeric( $configuration[ 'id' ] ) ? '\GV\GF_Field' : '\GV\Internal_Field'; |
|
192
|
192
|
|
|
193
|
193
|
/** |
|
194
|
194
|
* @filter `gravityview/field/class` Filter the field class about to be created from the configuration. |
|
@@ -227,24 +227,24 @@ discard block |
|
|
block discarded – undo |
|
227
|
227
|
public function update_configuration( $configuration ) { |
|
228
|
228
|
$configuration = wp_parse_args( $configuration, $this->as_configuration() ); |
|
229
|
229
|
|
|
230
|
|
- if ( $this->ID != $configuration['id'] ) { |
|
|
230
|
+ if ( $this->ID != $configuration[ 'id' ] ) { |
|
231
|
231
|
/** Smelling trouble here... */ |
|
232
|
232
|
gravityview()->log->warning( 'ID is being changed for {field_class} instance, but implementation is not. Use ::from_configuration instead', array( 'field_class', __CLASS__ ) ); |
|
233
|
233
|
} |
|
234
|
234
|
|
|
235
|
|
- $this->ID = $configuration['id']; |
|
236
|
|
- $this->label = $configuration['label']; |
|
237
|
|
- $this->show_label = $configuration['show_label'] == '1'; |
|
238
|
|
- $this->custom_label = $configuration['custom_label']; |
|
239
|
|
- $this->custom_class = $configuration['custom_class']; |
|
240
|
|
- $this->cap = $configuration['only_loggedin'] == '1' ? $configuration['only_loggedin_cap'] : ''; |
|
241
|
|
- $this->search_filter = $configuration['search_filter'] == '1'; |
|
242
|
|
- $this->show_as_link = $configuration['show_as_link'] == '1'; |
|
|
235
|
+ $this->ID = $configuration[ 'id' ]; |
|
|
236
|
+ $this->label = $configuration[ 'label' ]; |
|
|
237
|
+ $this->show_label = $configuration[ 'show_label' ] == '1'; |
|
|
238
|
+ $this->custom_label = $configuration[ 'custom_label' ]; |
|
|
239
|
+ $this->custom_class = $configuration[ 'custom_class' ]; |
|
|
240
|
+ $this->cap = $configuration[ 'only_loggedin' ] == '1' ? $configuration[ 'only_loggedin_cap' ] : ''; |
|
|
241
|
+ $this->search_filter = $configuration[ 'search_filter' ] == '1'; |
|
|
242
|
+ $this->show_as_link = $configuration[ 'show_as_link' ] == '1'; |
|
243
|
243
|
|
|
244
|
244
|
/** Shared among all field types (sort of). */ |
|
245
|
245
|
$shared_configuration_keys = array( |
|
246
|
246
|
'id', 'label', 'show_label', 'custom_label', 'custom_class', |
|
247
|
|
- 'only_loggedin' ,'only_loggedin_cap', 'search_filter', 'show_as_link', |
|
|
247
|
+ 'only_loggedin', 'only_loggedin_cap', 'search_filter', 'show_as_link', |
|
248
|
248
|
); |
|
249
|
249
|
|
|
250
|
250
|
/** Everything else goes into the properties for now. @todo subclasses! */ |
|
@@ -273,7 +273,7 @@ discard block |
|
|
block discarded – undo |
|
273
|
273
|
|
|
274
|
274
|
/** A custom label is available. */ |
|
275
|
275
|
if ( ! empty( $this->custom_label ) ) { |
|
276
|
|
- return \GravityView_API::replace_variables( $this->custom_label, $source ? $source->form ? : null : null, $entry ? $entry->as_entry() : null ); |
|
|
276
|
+ return \GravityView_API::replace_variables( $this->custom_label, $source ? $source->form ?: null : null, $entry ? $entry->as_entry() : null ); |
|
277
|
277
|
} |
|
278
|
278
|
|
|
279
|
279
|
return ''; |
|
@@ -350,7 +350,7 @@ discard block |
|
|
block discarded – undo |
|
350
|
350
|
* @return mixed|null The value for the given configuration key, null if doesn't exist. |
|
351
|
351
|
*/ |
|
352
|
352
|
public function __get( $key ) { |
|
353
|
|
- switch( $key ): |
|
|
353
|
+ switch ( $key ): |
|
354
|
354
|
default: |
|
355
|
355
|
if ( isset( $this->configuration[ $key ] ) ) { |
|
356
|
356
|
return $this->configuration[ $key ]; |
|
@@ -366,7 +366,7 @@ discard block |
|
|
block discarded – undo |
|
366
|
366
|
* @return boolean Whether this $key is set or not. |
|
367
|
367
|
*/ |
|
368
|
368
|
public function __isset( $key ) { |
|
369
|
|
- switch( $key ): |
|
|
369
|
+ switch ( $key ): |
|
370
|
370
|
default: |
|
371
|
371
|
return isset( $this->configuration[ $key ] ); |
|
372
|
372
|
endswitch; |