Skip to content

Instantly share code, notes, and snippets.

@marcusig
Created October 29, 2022 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusig/8479caf5b86885acdd7d6ace40b7af9e to your computer and use it in GitHub Desktop.
Save marcusig/8479caf5b86885acdd7d6ace40b7af9e to your computer and use it in GitHub Desktop.
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