<?php
/** convert time sources for wp recipe manager to hour / min values **/
add_filter( 'facetwp_builder_item_value', function( $value, $item ) {
if ( preg_match( '/wprm\/([a-zA-Z]+)_time/', $item['source'], $matches ) ) {
if ( !empty( $matches ) ) {
$type = $matches[1];
} else {
return $value;
}
$recipe_id = get_the_ID();
if ( 'post' == get_post_type( get_the_ID() ) ) {
$recipe_ids = WPRM_Recipe_Manager::get_recipe_ids_from_post( get_the_ID() );
if ( !empty( $recipe_ids ) ) {
$recipe_id = array_shift( $recipe_ids );
}
}
if ( 0 < $recipe_id) {
return do_shortcode( '[wprm-recipe-time type="' . $type . '" id=" ' . $recipe_id . '"]' );
}
}
return $value;
}, 10, 2 );