| @@ -63,17 +63,20 @@ | ||
| 63 | 63 | * |
| 64 | 64 | * @return string |
| 65 | 65 | */ |
| 66 | 66 | public function render_field( $field_type, $args ) { |
| 67 | - $args = wp_parse_args( $args, array( | |
| 68 | - 'name' => '', | |
| 69 | - 'value' => '', | |
| 70 | - 'options' => array(), | |
| 71 | - 'description' => '', | |
| 72 | - 'classes' => '', | |
| 73 | - 'data' => array(), | |
| 74 | - 'multiple' => false, | |
| 75 | - ) ); | |
| 67 | + $args = wp_parse_args( | |
| 68 | + $args, | |
| 69 | + array( | |
| 70 | + 'name' => '', | |
| 71 | + 'value' => '', | |
| 72 | + 'options' => array(), | |
| 73 | + 'description' => '', | |
| 74 | + 'classes' => '', | |
| 75 | + 'data' => array(), | |
| 76 | + 'multiple' => false, | |
| 77 | + ) | |
| 78 | + ); | |
| 76 | 79 | |
| 77 | 80 | $output = ''; |
| 78 | 81 | switch ( $field_type ) { |
| 79 | 82 | case 'text': |
| @@ -94,9 +97,9 @@ | ||
| 94 | 97 | break; |
| 95 | 98 | case 'select': |
| 96 | 99 | $current_value = $args['value']; |
| 97 | 100 | |
| 98 | - $output = sprintf( | |
| 101 | + $output = sprintf( | |
| 99 | 102 | '<select name="%1$s" class="%2$s" id="%1$s">', |
| 100 | 103 | esc_attr( $args['name'] ), |
| 101 | 104 | esc_attr( $args['classes'] ) |
| 102 | 105 | ); |
| @@ -114,9 +117,9 @@ | ||
| 114 | 117 | case 'select2': |
| 115 | 118 | $values = array(); |
| 116 | 119 | |
| 117 | 120 | $multiple = ( $args['multiple'] ) ? 'multiple ' : ''; |
| 118 | - $output = sprintf( | |
| 121 | + $output = sprintf( | |
| 119 | 122 | '<select name="%1$s" id="%1$s" class="select2-select %2$s" %3$s%4$s>', |
| 120 | 123 | esc_attr( $args['name'] ), |
| 121 | 124 | esc_attr( $args['classes'] ), |
| 122 | 125 | $this->prepare_data_attributes_string( $args['data'] ), |
| @@ -127,13 +130,16 @@ | ||
| 127 | 130 | $output .= '<option value=""></option>'; |
| 128 | 131 | } |
| 129 | 132 | |
| 130 | 133 | foreach ( $args['options'] as $parent ) { |
| 131 | - $parent = wp_parse_args( $parent, array( | |
| 132 | - 'value' => '', | |
| 133 | - 'text' => '', | |
| 134 | - 'children' => array(), | |
| 135 | - ) ); | |
| 134 | + $parent = wp_parse_args( | |
| 135 | + $parent, | |
| 136 | + array( | |
| 137 | + 'value' => '', | |
| 138 | + 'text' => '', | |
| 139 | + 'children' => array(), | |
| 140 | + ) | |
| 141 | + ); | |
| 136 | 142 | if ( empty( $parent['value'] ) ) { |
| 137 | 143 | continue; |
| 138 | 144 | } |
| 139 | 145 | if ( is_array( $args['value'] ) ) { |
| @@ -140,9 +146,9 @@ | ||
| 140 | 146 | $selected = selected( in_array( $parent['value'], $args['value'], true ), true, false ); |
| 141 | 147 | } else { |
| 142 | 148 | $selected = selected( $args['value'], $parent['value'], false ); |
| 143 | 149 | } |
| 144 | - $output .= sprintf( | |
| 150 | + $output .= sprintf( | |
| 145 | 151 | '<option class="parent" value="%1$s" %3$s>%2$s</option>', |
| 146 | 152 | $parent['value'], |
| 147 | 153 | $parent['text'], |
| 148 | 154 | $selected |
| @@ -149,9 +155,9 @@ | ||
| 149 | 155 | ); |
| 150 | 156 | $values[] = $parent['value']; |
| 151 | 157 | if ( ! empty( $parent['children'] ) ) { |
| 152 | 158 | foreach ( $parent['children'] as $child ) { |
| 153 | - $output .= sprintf( | |
| 159 | + $output .= sprintf( | |
| 154 | 160 | '<option class="child" value="%1$s" %3$s>%2$s</option>', |
| 155 | 161 | $child['value'], |
| 156 | 162 | $child['text'], |
| 157 | 163 | selected( $args['value'], $child['value'], false ) |
| @@ -187,9 +193,9 @@ | ||
| 187 | 193 | $output = apply_filters( 'wp_stream_form_render_field', $output, $field_type, $args ); |
| 188 | 194 | break; |
| 189 | 195 | } |
| 190 | 196 | |
| 191 | - $output .= ! empty( $args['description'] ) ? wp_kses_post( sprintf( '<p class="description">%s</p>', $args['description'] ) ) : null; | |
| 197 | + $output .= ! empty( $args['description'] ) ? sprintf( '<p class="description">%s</p>', $args['description'] ) : null; | |
| 192 | 198 | |
| 193 | 199 | return $output; |
| 194 | 200 | } |
| 195 | 201 | |
| @@ -201,9 +207,9 @@ | ||
| 201 | 207 | */ |
| 202 | 208 | public function prepare_data_attributes_string( $data ) { |
| 203 | 209 | $output = ''; |
| 204 | 210 | foreach ( $data as $key => $value ) { |
| 205 | - $key = 'data-' . esc_attr( $key ); | |
| 211 | + $key = 'data-' . esc_attr( $key ); | |
| 206 | 212 | $output .= $key . '="' . esc_attr( $value ) . '" '; |
| 207 | 213 | } |
| 208 | 214 | return $output; |
| 209 | 215 | } |