Skip to content
This repository was archived by the owner on Dec 2, 2022. It is now read-only.

Commit 00087f5

Browse files
committed
Add set_default function to prevent field[argument] index errors.
Signed-off-by: Kevin Provance <kevin.provance@gmail.com>
1 parent 09f9290 commit 00087f5

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

redux-core/inc/fields/image_select/class-redux-image-select.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@
1919
*/
2020
class Redux_Image_Select extends Redux_Field {
2121

22+
public function set_defaults(){
23+
$defaults = array(
24+
'tiles' => false,
25+
'mode' => 'background-image',
26+
'presets' => false,
27+
'options' => array(),
28+
'width' => '',
29+
'height' => '',
30+
);
31+
32+
$this->field = wp_parse_args( $this->field, $defaults );
33+
}
34+
2235
/**
2336
* Field Render Function.
2437
* Takes the vars and outputs the HTML for the field in the settings
@@ -78,7 +91,7 @@ public function render() {
7891

7992
$the_value = $k;
8093

81-
if ( ! empty( $this->field['tiles'] ) && true === $this->field['tiles'] ) {
94+
if ( ! empty( $this->field['tiles'] ) && true === (boolean) $this->field['tiles'] ) {
8295
$the_value = $v['img'];
8396
}
8497

@@ -212,7 +225,7 @@ public function css_style( $data ) {
212225
if ( ! empty( $data ) && ! is_array( $data ) ) {
213226
switch ( $mode ) {
214227
case 'background-image':
215-
if ( $this->field['tiles'] ) {
228+
if ( isset($this->field['tiles'] ) && true === (boolean) $this->field['tiles'] ) {
216229
$img = $data;
217230
} else {
218231
$img = $this->field['options'][ $data ]['img'] ?? '';

0 commit comments

Comments
 (0)