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

Commit 3586e60

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

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

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

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

22-
public function set_defaults(){
22+
/**
23+
* Set field defaults.
24+
*/
25+
public function set_defaults() {
2326
$defaults = array(
2427
'tiles' => false,
2528
'mode' => 'background-image',
@@ -91,7 +94,7 @@ public function render() {
9194

9295
$the_value = $k;
9396

94-
if ( ! empty( $this->field['tiles'] ) && true === (boolean) $this->field['tiles'] ) {
97+
if ( ! empty( $this->field['tiles'] ) && true === (bool) $this->field['tiles'] ) {
9598
$the_value = $v['img'];
9699
}
97100

@@ -141,7 +144,7 @@ public function render() {
141144

142145
$v['presets']['redux-backup'] = 1;
143146

144-
$presets = ' data-presets="' . esc_attr( htmlspecialchars( wp_json_encode( $v['presets'] ), ENT_QUOTES, 'UTF-8' ) ) . '"';
147+
$presets = ' data-presets="' . esc_attr( htmlspecialchars( wp_json_encode( $v['presets'] ), ENT_QUOTES ) ) . '"';
145148
$is_preset = true;
146149

147150
$this->field['class'] = trim( $this->field['class'] ) . ' redux-presets';
@@ -152,7 +155,7 @@ public function render() {
152155
$merge = '';
153156
if ( isset( $v['merge'] ) && false !== $v['merge'] ) {
154157
$merge = is_array( $v['merge'] ) ? implode( '|', $v['merge'] ) : 'true';
155-
$merge = ' data-merge="' . esc_attr( htmlspecialchars( $merge, ENT_QUOTES, 'UTF-8' ) ) . '"';
158+
$merge = ' data-merge="' . esc_attr( htmlspecialchars( $merge, ENT_QUOTES ) ) . '"';
156159
}
157160

158161
echo '<li class="redux-image-select">';
@@ -203,8 +206,7 @@ public function enqueue() {
203206
'redux-field-image-select-css',
204207
Redux_Core::$url . 'inc/fields/image_select/redux-image-select.css',
205208
array(),
206-
$this->timestamp,
207-
'all'
209+
$this->timestamp
208210
);
209211
}
210212
}
@@ -216,7 +218,7 @@ public function enqueue() {
216218
*
217219
* @return string
218220
*/
219-
public function css_style( $data ) {
221+
public function css_style( $data ): string {
220222
$css = '';
221223
$output = '';
222224

@@ -225,7 +227,7 @@ public function css_style( $data ) {
225227
if ( ! empty( $data ) && ! is_array( $data ) ) {
226228
switch ( $mode ) {
227229
case 'background-image':
228-
if ( isset($this->field['tiles'] ) && true === (boolean) $this->field['tiles'] ) {
230+
if ( isset( $this->field['tiles'] ) && true === (bool) $this->field['tiles'] ) {
229231
$img = $data;
230232
} else {
231233
$img = $this->field['options'][ $data ]['img'] ?? '';

0 commit comments

Comments
 (0)