コード例 #1
0
function erm_setup_post_types()
{
    global $wp_version;
    // Post type menu
    $labels_menu = apply_filters('erm_menu_labels', array('name' => __('Menus', 'post type general name', 'erm'), 'singular_name' => __('Menu', 'post type singular name', 'erm'), 'add_new' => __('Add New', 'erm'), 'add_new_item' => __('Add New Menu', 'erm'), 'edit_item' => __('Edit Menu', 'erm'), 'new_item' => __('New Menu', 'erm'), 'all_items' => __('All menus', 'erm'), 'view_item' => __('View menus', 'erm'), 'search_items' => __('Search Menus', 'erm'), 'not_found' => __('No Menus found', 'erm'), 'not_found_in_trash' => __('No Menus found in Trash', 'erm'), 'parent_item_colon' => '', 'menu_name' => __('Rest. Menus', 'menu post type menu name', 'erm')));
    $slug = defined('ERM_MENU_SLUG') ? ERM_MENU_SLUG : 'menu';
    $has_archive = defined('ERM_MENU_HAS_ARCHIVE') && ERM_MENU_HAS_ARCHIVE ? true : false;
    $rewrite = defined('ERM_DISABLE_REWRITE') && ERM_DISABLE_REWRITE ? false : array('slug' => $slug, 'with_front' => false);
    $args_menu = array('labels' => $labels_menu, 'public' => true, 'publicly_queryable' => false, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => $rewrite, 'map_meta_cap' => true, 'has_archive' => $has_archive, 'hierarchical' => false, 'supports' => apply_filters('erm_menu_supports', array('title', 'editor', 'revisions', 'author')));
    if (version_compare($wp_version, '3.8-RC', '>=') || version_compare($wp_version, '3.8', '>=')) {
        $args_menu['menu_icon'] = 'dashicons-list-view';
    }
    register_post_type('erm_menu', apply_filters('erm_menu_post_type_args', $args_menu));
    // Post type menu_item
    $labels_menu_item = apply_filters('erm_menu_item_labels', array('name' => __('Menu Items', 'post type general name', 'erm'), 'singular_name' => __('Menu Item', 'post type singular name', 'erm'), 'add_new' => __('Add New', 'erm'), 'add_new_item' => __('Add New Menu Item', 'erm'), 'edit_item' => __('Edit Menu Item', 'erm'), 'new_item' => __('New Menu Item', 'erm'), 'all_items' => __('All Menu Items', 'erm'), 'view_item' => __('View Menu Item', 'erm'), 'search_items' => __('Search Menu Items', 'erm'), 'not_found' => __('No Menu Item found', 'erm'), 'not_found_in_trash' => __('No Menu Items found in Trash', 'erm'), 'parent_item_colon' => '', 'menu_name' => __('Rest. Menu Items', 'erm')));
    $args_menu_item = array('labels' => $labels_menu_item, 'public' => ERM()->settings->get('erm_show_dashboard_menu_items') == 1 ? true : false, 'publicly_queryable' => false, 'query_var' => false, 'rewrite' => false, 'capabilities' => array('create_posts' => false), 'map_meta_cap' => true, 'has_archive' => false, 'hierarchical' => false, 'supports' => apply_filters('erm_menu_item_supports', array('title', 'editor', 'thumbnail', 'revisions', 'author')));
    if (version_compare($wp_version, '3.8-RC', '>=') || version_compare($wp_version, '3.8', '>=')) {
        $args_menu_item['menu_icon'] = 'dashicons-exerpt-view';
    }
    register_post_type('erm_menu_item', apply_filters('erm_menu_item_post_type_args', $args_menu_item));
    // Post type menu_week
    $labels_menu_week = apply_filters('erm_menu_week_labels', array('name' => __('Weekly Menus', 'post type general name', 'erm'), 'singular_name' => __('Weekly Menu', 'post type singular name', 'erm'), 'add_new' => __('Add New', 'erm'), 'add_new_item' => __('Add New Weekly Menu', 'erm'), 'edit_item' => __('Edit Weekly Menu', 'erm'), 'new_item' => __('New Weekly Menu', 'erm'), 'all_items' => __('All Weekly Menus', 'erm'), 'view_item' => __('View Weekly Menu', 'erm'), 'search_items' => __('Search Weekly Menus', 'erm'), 'not_found' => __('No Weekly Menu found', 'erm'), 'not_found_in_trash' => __('No Weekly Menus found in Trash', 'erm'), 'parent_item_colon' => '', 'menu_name' => __('Rest. Menus Week', 'erm')));
    $args_menu_week = array('labels' => $labels_menu_week, 'public' => true, 'publicly_queryable' => false, 'query_var' => false, 'rewrite' => false, 'map_meta_cap' => true, 'has_archive' => false, 'hierarchical' => false, 'supports' => apply_filters('erm_menu_week_supports', array('title')));
    if (version_compare($wp_version, '3.8-RC', '>=') || version_compare($wp_version, '3.8', '>=')) {
        $args_menu_week['menu_icon'] = 'dashicons-exerpt-view';
    }
    register_post_type('erm_menu_week', apply_filters('erm_menu_week_post_type_args', $args_menu_week));
}
コード例 #2
0
/**
 * Filter price to add currency
 *
 * @since 1.0
 * @param $price
 * @return string
 */
function erm_filter_price($price)
{
    $currency = ERM()->settings->get('erm_currency');
    if (empty($currency)) {
        return $price;
    }
    $position = ERM()->settings->get('erm_currency_position');
    if ($position == 'before') {
        return $currency . $price;
    } else {
        return $price . $currency;
    }
}
コード例 #3
0
/**
 * Load Scripts front End
 *
 * @since 1.0
 * @updated 1.1
 */
function erm_load_scripts()
{
    global $wp_version, $post;
    if (!isset($post->post_content)) {
        return;
    }
    $js_dir = ERM_PLUGIN_URL . 'assets/js/';
    $css_dir = ERM_PLUGIN_URL . 'assets/css/';
    if (has_shortcode($post->post_content, 'erm_menu') || has_shortcode($post->post_content, 'erm_menu_week')) {
        wp_enqueue_style('font-oswald', 'http://fonts.googleapis.com/css?family=Oswald:400,700');
        wp_enqueue_style('magnific-popup', $css_dir . 'magnific-popup.css');
        wp_enqueue_style('erm-front', $css_dir . 'erm-front.css', array(), ERM_VERSION);
        $inject_custom_css = ERM()->settings->get('erm_custom_css_display');
        if ($inject_custom_css) {
            $custom_css = ERM()->settings->get('erm_custom_css');
            if (!empty($custom_css)) {
                wp_add_inline_style('erm-front', $custom_css);
            }
        }
        wp_enqueue_script('magnific-popup', $js_dir . 'jquery.magnific-popup.min.js', array('jquery'), '1.0.0', true);
        wp_enqueue_script('erm-front', $js_dir . 'erm-front-scripts.js', array('magnific-popup'), '1.0.0', true);
    }
}
コード例 #4
0
                require_once ERM_PLUGIN_DIR . 'includes/admin/ajax-functions.php';
                require_once ERM_PLUGIN_DIR . 'includes/admin/actions.php';
                require_once ERM_PLUGIN_DIR . 'includes/admin/menu-settings.php';
                require_once ERM_PLUGIN_DIR . 'includes/admin/table-columns.php';
            }
        }
        /**
         * Language files
         *
         * @since 1.0
         */
        public function load_textdomain()
        {
            load_plugin_textdomain('erm', false, plugin_basename(dirname(__FILE__)) . "/languages/");
        }
    }
}
// End if
/**
 * Use this function to return the Singleton
 *
 * @since 1.0
 * @return the singleton object Easy_Restaurant_Menu
 */
function ERM()
{
    return El_Restaurant_Menu::singleton();
}
// Create singleton
ERM();
コード例 #5
0
?>
">

    <h1 class="erm_title"><?php 
echo $menu_post->post_title;
?>
</h1>
    <div class="erm_desc"><?php 
echo apply_filters('the_content', $menu_post->post_content);
?>
</div>

    <ul class="erm_menu_content">
        <?php 
// Thumb size
$option_thumb_size = ERM()->settings->get('erm_menu_thumb_size');
if (empty($option_thumb_size)) {
    $option_thumb_size = 'medium';
}
// Menu items
$menu_items = get_post_meta($post_id, '_erm_menu_items', true);
if (!empty($menu_items)) {
    $menu_items = preg_split('/,/', $menu_items);
    foreach ($menu_items as $item_id) {
        // Visible item
        if (get_post_meta($item_id, '_erm_visible', true) != 1) {
            continue;
        }
        // Get the post item
        $the_post = get_post($item_id);
        $type = get_post_meta($item_id, '_erm_type', true);
コード例 #6
0
/**
 * Shortcode Menu one column
 *
 * @since 1.0
 */
function erm_shortcode_menu($atts, $content = null)
{
    global $post;
    $post_id = is_object($post) ? $post->ID : 0;
    $atts = shortcode_atts(array('id' => $post_id), $atts, 'erm_menu');
    $post_id = $atts['id'];
    if (get_post_type($post_id) != 'erm_menu') {
        return;
    }
    // Title & description Menu
    $menu_post = get_post($post_id);
    $html = '<div class="erm_menu">';
    $html .= '<h1 class="erm_title">' . $menu_post->post_title . '</h1>';
    $html .= '<div class="erm_desc">' . apply_filters('the_content', $menu_post->post_content) . '</div>';
    // Menu items
    $menu_items = get_post_meta($post_id, '_erm_menu_items', true);
    if (empty($menu_items)) {
        return;
    }
    $menu_items = preg_split('/,/', $menu_items);
    $html .= '<ul class="erm_menu_content">';
    // Need to know if menu is using thumbnails
    $has_some_thumbnails = false;
    $option_thumb_size = ERM()->settings->get('erm_menu_thumb_size');
    if (empty($option_thumb_size)) {
        $option_thumb_size = 'medium';
    }
    foreach ($menu_items as $item_id) {
        $visible = get_post_meta($item_id, '_erm_visible', true);
        if ($visible != 1) {
            continue;
        }
        $the_post = get_post($item_id);
        $type = get_post_meta($item_id, '_erm_type', true);
        if ($type == 'section') {
            $html .= '<li class="erm_section">';
            $html .= '<h2 class="erm_section_title">' . $the_post->post_title . '</h2>';
            $html .= '<div class="erm_section_desc">' . apply_filters('the_content', $the_post->post_content) . '</div>';
            $html .= '</li>';
        } else {
            if ($type == 'product') {
                $has_thumbnail = has_post_thumbnail($item_id);
                $html .= '<li class="erm_product ' . ($has_thumbnail ? 'with_image' : 'no_image') . '">';
                if ($has_thumbnail) {
                    $image_id = get_post_thumbnail_id($item_id);
                    $src_thumb = erm_get_image_src($image_id, $option_thumb_size);
                    $src_full = erm_get_image_src($image_id, 'full');
                    $alt = get_post_meta($image_id, '_wp_attachment_image_alt', true);
                    $post_image = get_post($image_id);
                    $caption = $post_image->post_excerpt;
                    $desc = $post_image->post_content;
                    $html .= '<a class="image-popup" target="_blank" href="' . $src_full . '" data-caption="' . esc_attr($caption) . '" data-desc="' . esc_attr($desc) . '"><img class="erm_product_image" alt="' . esc_attr($alt) . '" src="' . $src_thumb . '"></a>';
                    $has_some_thumbnails = true;
                } else {
                    $html .= '<div class="erm_product_image"></div>';
                }
                $html .= '<h3 class="erm_product_title">' . $the_post->post_title . '</h3>';
                $html .= '<div class="erm_product_price">';
                $prices = get_post_meta($item_id, '_erm_prices', true);
                if (!empty($prices)) {
                    $html .= '<ul>';
                    foreach ($prices as $price) {
                        $html .= '<li><span class="name">' . $price['name'] . '</span><span class="price">' . apply_filters('erm_filter_price', $price['value']) . '</span></li>';
                    }
                    $html .= '</ul>';
                }
                $html .= '</div>';
                $html .= '<div class="erm_product_desc">' . apply_filters('the_content', $the_post->post_content) . '</div>';
                $html .= '<div class="clear"></div>';
                $html .= '</li>';
            }
        }
    }
    $html .= '</ul>';
    $html .= '<div class="erm_footer_desc">' . apply_filters('the_content', get_post_meta($menu_post->ID, '_erm_footer_menu', true)) . '</div>';
    $html .= '</div>';
    // Clean left column with thumbnails if don't exists
    if (!$has_some_thumbnails) {
        $html = '<style>.erm_product .image-popup, .erm_product .erm_product_image { display: block !important; } </style>' . $html;
    }
    // No need of this
    //wp_reset_postdata();
    return $html;
}