Exemplo n.º 1
0
/**
 *  Output RSS 2 version of a specified menu.
 */
function wpermm_rss2($menu_id)
{
    $menu = WPRMM_Menu::get_by_id($menu_id);
    if ($menu['rss2']) {
        $categories = WPRMM_Category::get_all((int) $menu['id']);
        $items = WPRMM_Item::get_all((int) $menu['id']);
        header('Content-Type: text/xml');
        $s = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
        $s .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">' . "\n";
        $s .= '<channel>' . "\n";
        $s .= '<title>' . ermm_xmlen($menu['name']) . '</title>' . "\n";
        $s .= '<description>' . ermm_xmlen($menu['description']) . '</description>' . "\n";
        $s .= '<link>' . ermm_xmlen($menu['print_url']) . '</link>' . "\n";
        foreach ($categories as $category) {
            if ($category->active) {
                foreach ($items as $i) {
                    if ($i->category_id == $category->id && $i->active) {
                        $s .= '<item>' . "\n";
                        $s .= '<title>' . ermm_xmlen($i->name) . '</title>' . "\n";
                        $s .= '<category>' . ermm_xmlen($category->name) . '</category>' . "\n";
                        $s .= '<description><![CDATA[' . "\n";
                        if (!empty($i->image)) {
                            $s .= '<img src="' . $i->image . '" alt="' . ermm_xmlen($i->name) . '" class="center" />' . "\n";
                        }
                        if ($i->show_price) {
                            $s .= '<p>Price: ' . $i->price . '</p>' . "\n";
                            if (!empty($i->second_price)) {
                                $s .= '<p>Alternate Price: ' . $i->second_price . '</p>' . "\n";
                            }
                        }
                        if (!empty($i->icon_image)) {
                            $s .= '<p>' . "\n";
                            $s .= '<img alt="' . $i->icon_description . '" src="' . $i->icon_image . '" />  ';
                            $s .= '<span>' . $i->icon_description . '</span>' . "\n";
                            $s .= '</p>' . "\n";
                        }
                        $s .= '<p>' . nl2br($i->description) . '</p>' . "\n";
                        $s .= ']]></description>' . "\n";
                        $s .= '<guid isPermaLink="false">item_' . $i->id . '</guid>' . "\n";
                        $s .= '</item>' . "\n";
                    }
                }
            }
        }
        $s .= '</channel>' . "\n";
        $s .= '</rss>' . "\n";
        return $s;
    } else {
        return "RSS2 Feed not turned on for this menu.";
    }
}
Exemplo n.º 2
0
/** 
 * Displays HTML Menu on frontend.
 *
 * @param int $atts['id'] is the menu id
 * @param $categories array of category ids to pull else pull all from menu.
 */
function wprmm_get_menu($atts, $category_ids = 'all')
{
    global $wpdb;
    $menu_id = $atts['id'];
    if (empty($atts['id']) || !is_numeric($atts['id'])) {
        return '';
    }
    /* Get Menu, Categories, and Items */
    $menu = WPRMM_Menu::get_by_id($menu_id);
    if (empty($menu['id'])) {
        return "Menu not found.";
    }
    $categories = WPRMM_Category::get_all((int) $menu['id'], $category_ids);
    $items = WPRMM_Item::get_all((int) $menu['id']);
    /* Build HTML Output for menu */
    $m = '<!-- SAI Digital Restaurant Menu Manager -->' . "\r\n";
    $m .= '<div id="wprmm_menu_' . $menu['id'] . '" class="wprmm_menu">' . "\r\n";
    $m .= '<div class="menu_manager">' . "\r\n";
    if ($menu['show_title']) {
        $m .= '<h1>' . $menu['name'] . '</h1>' . "\r\n";
    }
    $m .= '<p class="menu_desc">' . nl2br($menu['description']) . '</p>' . "\r\n";
    $m .= '<div class="menu_manager">' . "\r\n";
    foreach ($categories as $cat) {
        if ($cat->active) {
            $m .= '<div id="' . wprmm_css_name($cat->name) . '" class="menu_category">' . "\r\n";
            if ($cat->show_title) {
                $m .= '<h2>' . $cat->name . '</h2>' . "\r\n";
            }
            if ($cat->show_description) {
                $m .= '<p class="menu_category_desc">' . nl2br($cat->description) . '</p>' . "\r\n";
            }
            $m .= wprmm_view_items($cat, $items);
            $m .= '</div>' . "\r\n";
        }
    }
    if ($menu['show_link']) {
        $m .= '<p class="wprmm_print"><a href="' . $menu['print_url'] . '" target="_blank">Print</a></p>';
    }
    $m .= '</div>';
    $m .= '</div>';
    $m .= '</div>';
    return $m;
}
     }
 }
 /* Save New Item */
 if (!empty($_POST['wprmm_crud']['item'])) {
     if ($_POST['wprmm_crud']['item'] == 'new') {
         $item_id = WPRMM_Item::create($_POST['wprmm']);
         #$category_id = (int) $_POST['wprmm_crud']['category_id'];
         #$menu_id = (int) $_POST['wprmm_crud']['menu_id'];
         wp_redirect(wprmm_admin_url('item', 'edit-item', $item_id));
         exit;
     }
     /* Delete Item */
     if ($_POST['wprmm_crud']['item'] == 'Delete') {
         $item_id = (int) $_POST['wprmm_crud']['item_id'];
         $menu_id = (int) $_POST['wprmm_crud']['menu_id'];
         WPRMM_Item::destroy($item_id);
         wp_redirect(wprmm_admin_url('menu', 'index-item', $menu_id));
         exit;
     }
 }
 /* Save New Icon */
 if (!empty($_POST['wprmm_crud']['icon'])) {
     if ($_POST['wprmm_crud']['icon'] == 'new') {
         $icon_id = WPRMM_ICON::create($_POST['wprmm']);
         wp_redirect(wprmm_admin_icon_url('icon', 'edit-icon', $icon_id));
         exit;
     }
     /* Delete Icon */
     if ($_POST['wprmm_crud']['icon'] == 'Delete') {
         $icon_id = (int) $_POST['wprmm_crud']['icon_id'];
         WPRMM_ICON::destroy($icon_id);
<?php

defined('WPRMM_PATH') or die;
$menu = new WPRMM_Menu((int) $_GET['menu_id']);
$item = new WPRMM_Item();
$items = $item->get_all($menu->id);
$category = new WPRMM_Category();
$categories = $category->get_all($menu->id);
?>
<div class="wrap wprmm">
  <img class="left" style="margin:0 15px 0 0" src="<?php 
echo WPRMM_URL . 'images/menumanagericon_50x50.jpg';
?>
" />
  <h2 class="left">Restaurant Menu Manager - Setup Items</h2>
  <div class="clear"></div>
  <hr />

  <?php 
wprmm_get_help();
?>

  <p class="wprmm-breadcrumb">
    <a href="<?php 
echo admin_url('admin.php?page=' . WPRMM_ADMIN_URL);
?>
">Menus</a> &raquo; 
    <a href="<?php 
echo wprmm_admin_url('menu', 'edit-menu', $menu->id);
?>
"><?php