Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Execute shortcodes found in the description fields, by applying the WP filter 'the_content'
<?php
add_filter( 'mkl_product_configurator_get_front_end_data', function( $data ) {
// Filter the choices
if ( isset( $data['content'] ) && is_array( $data['content'] ) ) {
foreach( $data['content'] as $lin => $layer ) {
foreach( $layer['choices'] as $cin => $choice ) {
if ( isset( $choice['description'] ) ) {
$data['content'][$lin]['choices'][$cin]['description'] = apply_filters( 'the_content', $choice['description'] );
}
}
}
}
// Filter the layers
if ( isset( $data['layers'] ) && is_array( $data['layers'] ) ) {
foreach( $data['layers'] as $lind => $layer ) {
if ( isset( $layer['description'] ) ) {
$data['layers'][$lind]['description'] = apply_filters( 'the_content', $layer['description'] );
}
}
}
return $data;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment