'wp_widget_aumenu', 'description' => 'AuMenu', ); parent::__construct( 'wp_widget_aumenu', 'AuMenu', $widget_ops ); } /** * Outputs the content of the widget * * @param array $args * @param array $instance */ public function widget( $args, $instance ) { add_action('wp_enqueue_scripts', 'aumenu_css_js'); $public_key = get_option('aumenu_public_key'); $secret_key = get_option('aumenu_secret_key'); $pages_settings_type = null; $pages_settings = null; $post = get_post($instance['aumenu_establishments_id']); if ($post) { $pages_settings_id = get_post_meta($post->ID, '_establishments_id', true); $pages_settings_type = get_post_meta($post->ID, '_establishments_type', true); } if ($pages_settings_id) { $establishments_id = $pages_settings_id; } else { $establishments_id = null; } if ($establishments_id) { $aumenu = new AuMenuSDK(); $aumenu->setLanguage(aumenu_get_language()); $aumenu->getToken($public_key, $secret_key); if ($pages_settings_type == 'beers') { $establishment = json_decode($aumenu->getEstablishment($establishments_id)); if ($establishment && isset($establishment->data)) { $beers = json_decode($aumenu->getBeers($establishments_id)); if ($beers && isset($beers->data)) { foreach($beers->data as $key => $section) { if ($section->data) { echo '
'; if (strlen($section->name) > 0) { echo '

'.$section->name.'

'; } echo ''; foreach($section->data as $beer) { $type = $beer->type ? $beer->type : ''; ?> '; echo ''; } } } } } else if ($pages_settings_type == 'taps') { $establishment = json_decode($aumenu->getEstablishment($establishments_id)); $taps = json_decode($aumenu->getTaps($establishments_id)); if ($taps && isset($taps->data)) { foreach($taps->data as $section) { if ($section->data) { echo '
'; if (strlen($section->name) > 0) { echo '

'.$section->name.'

'; } echo '
name ?> abv ?> %
'; foreach($section->data as $tap) { $line_no = $tap->is_cask ? 'CASK' : (!$tap->is_empty ? ($tap->line_no < 10 ? '0'.$tap->line_no : $tap->line_no).'
'.($tap->is_seasonal ? '
' : '').($tap->is_speciality ? '
' : '').'
' : ($tap->line_no < 10 ? '0'.$tap->line_no : $tap->line_no)); if (isset($tap->beer)) { $beer_establishment = json_decode($aumenu->getEstablishment($tap->beer->establishment_id)); $permalink_post = get_permalink($post->ID).$tap->beer->name_clean.'/'.$beer_establishment->data->name_clean.'/'; if ($beer_establishment->data->name_clean == $establishment->data->establishments_id) { $permalink_post = get_permalink($post->ID).$tap->beer->name_clean.'/'; } ?> '; echo ''; } } } } else if ($pages_settings_type == 'bottles') { $establishment = json_decode($aumenu->getEstablishment($establishments_id)); if ($establishment && isset($establishment->data)) { $bottles = json_decode($aumenu->getBottles($establishments_id)); if ($bottles && isset($bottles->data)) { foreach($bottles->data as $key => $section) { if ($section->data) { echo '
'; if (strlen($section->name) > 0) { echo '

'.$section->name.'

'; } echo '
beer->name ?>beer->full_name ?> - beer->type ?> beer->abv ?> %
text ?>
'; foreach($section->data as $bottle) { if (isset($bottle->beer)) { $permalink_post = get_permalink($post->ID).$bottle->beer->name_clean.'/'.$bottle->beer->establishment_name_clean.'/'; if ($bottle->beer->establishment_name_clean == $establishment->data->establishments_id) { $permalink_post = get_permalink($post->ID).$bottle->beer->name_clean.'/'; } ?> '; echo ''; } } } } } else if ($pages_settings_type == 'foods') { $foods = json_decode($aumenu->getFoods($establishments_id)); if ($foods && isset($foods->data)) { foreach($foods->data as $food_cat) { echo '
'; if (strlen($food_cat->name) > 0) { echo '

'.$food_cat->name.'

'; } echo '
beer->name ?>beer->type ?> beer->abv ?> %price_sold > 0 ? ''.$bottle->price_sold.' $' : '' ?>
text ?>
'; ?> data as $food) { ?> price > 0) { ?> '; echo ''; } } } } } /** * Outputs the options form on admin * * @param array $instance The widget options */ public function form($instance) {- $type = 'products'; $args=array( 'post_type' => 'aumenu', 'post_status' => 'publish', 'posts_per_page' => -1, 'caller_get_posts'=> 1 ); $my_query = null; $my_query = new WP_Query($args); if($instance) { $establishments_id = esc_attr($instance['aumenu_establishments_id']); } else { $establishments_id = null; } ?>

price == 0 ? ' colspan="2"' : '' ?>>name ?>description ?> price > 0 ? $food->price.' $' : '' ?>