/** * Returns the main menu image. * @param string $size (default: 'food_thumbnail') * @return string */ private function get_image($size = 'food_thumbnail', $attr = array()) { global $post; if (has_post_thumbnail($post->ID)) { $image = get_the_post_thumbnail($post->ID, $size, $attr); } elseif (($parent_id = wp_get_post_parent_id($post->ID)) && has_post_thumbnail($parent_id)) { $image = get_the_post_thumbnail($parent_id, $size, $attr); } else { $image = rp_placeholder_img($size); } return $image; }
/** * Data Storage for food menu. * @param array $food_group * @param array $food_data * @return array * @access private */ private static function food_menu_data($food_group, $food_data) { global $post; $food_terms = get_the_terms($post->ID, 'food_menu_cat'); if ($food_terms && !is_wp_error($food_terms)) { $title = get_the_title(); $content = get_the_content(); $price = get_post_meta($post->ID, 'food_item_price', true); $chef_badge = get_post_meta($post->ID, 'chef_badge_item', true); $image_id = get_post_thumbnail_id($post->ID); $attach_url = wp_get_attachment_url($image_id); if (has_post_thumbnail()) { $image = get_the_post_thumbnail($post->ID, 'food_thumbnail'); $image_grid = get_the_post_thumbnail($post->ID, 'food_grid'); $popup = 'yes'; } else { $image = rp_placeholder_img(); $image_grid = rp_placeholder_img('food_grid'); $popup = 'no'; } foreach ($food_terms as $term) { if (in_array($term->term_id, $food_group)) { $food_data[$term->term_id][] = array('title' => $title, 'content' => $content, 'price' => $price, 'image' => $image, 'image_grid' => $image_grid, 'popup' => $popup, 'chef_badge' => $chef_badge, 'attach_url' => $attach_url); } } } return $food_data; }