-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Line 63 added to prevent boolean type from being passed to array_merge #48
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,8 +59,9 @@ public function get_key() { | |
* @return mixed Whatever is in those fields. | ||
*/ | ||
public function get( $field = null, $default = null ) { | ||
$option_array = get_option( $this->key, array() ); | ||
$option_array = gettype($option_array) != "array" ? [] : $option_array; | ||
$data = array_merge( $this->defaults, get_option( $this->key, array() ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You might need to use |
||
|
||
return scbForms::get_value( $field, $data, $default ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. // should be |
||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short array syntax
[]
available since PHP 5.4, what is doesn't fit the WordPress' minimal requirements.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would probably be simpler to just cast to array:
or more simply wrote:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first change, forgot to include the last line for $option_array. I agree, a cast would be easier.