← All changes
|
includes/integrations/elementor/class-convertkit-elementor-widget.php
+15
-2
2.3.1
→
3.4.3
View file →
| @@ -177,13 +177,26 @@ | ||
| 177 | 177 | 'placeholder' => ( isset( $field['placeholder'] ) ? $field['placeholder'] : '' ), |
| 178 | 178 | 'desc' => ( isset( $field['description'] ) ? $field['description'] : '' ), |
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | + // Add conditional field, if defined. | |
| 182 | + if ( isset( $field['display_if'] ) ) { | |
| 183 | + $control = array_merge( | |
| 184 | + $control, | |
| 185 | + array( | |
| 186 | + 'condition' => array( | |
| 187 | + $field['display_if']['key'] => $field['display_if']['value'] ? 'yes' : 'no', | |
| 188 | + ), | |
| 189 | + ) | |
| 190 | + ); | |
| 191 | + } | |
| 192 | + | |
| 181 | 193 | // Add control depending on the field type. |
| 182 | 194 | switch ( $field['type'] ) { |
| 183 | 195 | /** |
| 184 | 196 | * Select |
| 185 | 197 | */ |
| 198 | + case 'resource': | |
| 186 | 199 | case 'select': |
| 187 | 200 | $control = array_merge( |
| 188 | 201 | $control, |
| 189 | 202 | array( |
| @@ -260,9 +273,9 @@ | ||
| 260 | 273 | } |
| 261 | 274 | |
| 262 | 275 | // Render using Block class' render() function. |
| 263 | 276 | // Output is already escaped in render() function. |
| 264 | - echo WP_ConvertKit()->get_class( 'blocks_convertkit_' . $this->get_block_name() )->render( $this->get_settings_for_display() ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 277 | + echo WP_ConvertKit()->get_class( 'blocks_convertkit_' . $this->get_block_name() )->render( $this->get_settings_for_display() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 265 | 278 | |
| 266 | 279 | } |
| 267 | 280 | |
| 268 | 281 | /** |
| @@ -277,9 +290,9 @@ | ||
| 277 | 290 | // Get blocks. |
| 278 | 291 | $blocks = convertkit_get_blocks(); |
| 279 | 292 | |
| 280 | 293 | // Bail if no blocks are available. |
| 281 | - if ( ! is_array( $blocks ) || ! count( $blocks ) ) { | |
| 294 | + if ( ! count( $blocks ) ) { | |
| 282 | 295 | return new WP_Error( 'convertkit_elementor_widget_get_block_error', __( 'No blocks are registered. Register blocks using the `convertkit_blocks` filter.', 'convertkit' ) ); |
| 283 | 296 | } |
| 284 | 297 | |
| 285 | 298 | // Bail if block doesn't exist. |