Flip Menu
Create interactive flip menus using Turn.js. Upload PDFs or images to create beautiful flip-through menus for different shops.
by TCG Web & Marketing · github.com/tu787878/flip-menu · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/tu787878/flip-menu/archive/refs/heads/main.zipReadme
Flip Menu WordPress Plugin
A WordPress plugin that uses Turn.js to create interactive flip menus for different shops and restaurants. Users can upload PDFs or images to create beautiful flip-through menus.
Features
- Create multiple shops/restaurants with individual flip menus
- Upload menu images for flip display
- Upload PDF files (requires conversion to images for display)
- Easy-to-use admin interface
- Shortcode support for embedding menus anywhere
- REST API for external access
- Embeddable widget for any website
- API key authentication
- CORS support for cross-origin requests
- Responsive design
- Keyboard navigation (arrow keys)
- Touch/swipe support on mobile devices
Installation
- Upload the
flip-menufolder to the/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- Go to "Flip Menu" in your WordPress admin to start creating shops and menus
Usage
Creating a Shop
- Navigate to Flip Menu > Add New Shop in your WordPress admin
- Enter the shop name and description
- Click "Create Shop"
Adding Menu Items
- Go to Flip Menu > Manage Menus
- Select the shop from the dropdown
- Upload images or PDFs:
- Images: Upload individual menu page images with page order numbers
- PDFs: Upload a PDF file (note: requires additional setup for page conversion)
Displaying a Flip Menu
Use the shortcode in any post or page:
[flip_menu shop_id="1"]
Shortcode Attributes
shop_id(required): The ID of the shop (visible in the "All Shops" list)width(optional): Width in pixels (default: 800)height(optional): Height in pixels (default: 600)
Example with custom dimensions:
[flip_menu shop_id="1" width="1000" height="700"]
REST API & Embeddable Widget
REST API
The plugin provides a complete REST API for external access to shop and menu data.
Base URL: https://yoursite.com/wp-json/flip-menu/v1
Available Endpoints:
GET /shops- Get all shopsGET /shops/{id}- Get single shopGET /shops/{id}/menu- Get shop menu itemsGET /shops/{id}/complete- Get shop with menu items
Example:
curl -X GET "https://yoursite.com/wp-json/flip-menu/v1/shops/1/complete" \
-H "X-API-Key: your-api-key"
Embeddable Widget
Allow other websites to embed your flip menus with a simple code snippet:
<div data-flip-menu-widget
data-shop-id="1"
data-api-url="https://yoursite.com/wp-json"
data-api-key="your-api-key"
data-width="800"
data-height="600">
</div>
<script src="https://yoursite.com/wp-content/plugins/flip-menu/public/js/flip-menu-widget.js"></script>
Configuration
- Go to Flip Menu > API & Embed in WordPress admin
- Enable API access
- Generate an API key (optional, for security)
- Enable CORS for cross-domain access
- Use the embed code generator to create widget code
For complete API documentation, see API_DOCUMENTATION.md
Troubleshooting Network Errors
If you get "Network error" when using the widget from external websites:
Quick Fix:
- Go to Flip Menu > API & Embed
- Check "Enable API" ✅
- Check "Enable CORS" ✅
- Set "Allowed Origins" to
* - Save and refresh external site
For detailed troubleshooting, see NETWORK_ERROR_FIX.md
Turn.js Library
This plugin requires the Turn.js library for the flip effect. You need to:
- Download Turn.js from http://www.turnjs.com/
- Place the
turn.min.jsfile in the/public/js/directory of the plugin
Important: Turn.js has licensing requirements for commercial use. Please review their license before using this plugin in a commercial environment.
PDF Support
Converting PDFs to Images
For PDFs to display properly in the flip menu, they need to be converted to images. This requires:
- ImageMagick or Imagick PHP extension installed on your server
- Additional code to convert PDF pages to images on upload
Basic PDF Conversion Implementation
Add this to your admin/class-flip-menu-admin.php in the handle_pdf_upload method:
// After successful PDF upload
if (extension_loaded('imagick')) {
$imagick = new Imagick();
$imagick->setResolution(150, 150);
$imagick->readImage($movefile['file']);
foreach ($imagick as $page_num => $page) {
$page->setImageFormat('jpg');
$filename = 'menu-page-' . ($page_num + 1) . '.jpg';
$upload_dir = wp_upload_dir();
$image_path = $upload_dir['path'] . '/' . $filename;
$page->writeImage($image_path);
// Insert each page as a separate menu item
$wpdb->insert(
$table_name,
array(
'shop_id' => $shop_id,
'title' => sanitize_text_field($_POST['title']) . ' - Page ' . ($page_num + 1),
'source_type' => 'image',
'source_url' => $upload_dir['url'] . '/' . $filename,
'page_order' => $page_num
)
);
}
}
File Structure
flip-menu/
├── admin/
│ ├── class-flip-menu-admin.php # Admin functionality
│ ├── css/
│ │ └── flip-menu-admin.css # Admin styles
│ ├── js/
│ │ └── flip-menu-admin.js # Admin scripts
│ └── partials/
│ ├── flip-menu-admin-display.php # Shop list page
│ ├── flip-menu-admin-add-shop.php # Add shop form
│ └── flip-menu-admin-manage-menus.php # Menu management page
├── includes/
│ ├── class-flip-menu.php # Main plugin class
│ ├── class-flip-menu-activator.php # Activation hooks
│ ├── class-flip-menu-deactivator.php # Deactivation hooks
│ ├── class-flip-menu-loader.php # Hooks loader
│ └── class-flip-menu-i18n.php # Internationalization
├── public/
│ ├── class-flip-menu-public.php # Public-facing functionality
│ ├── css/
│ │ └── flip-menu-public.css # Frontend styles
│ └── js/
│ ├── turn.min.js # Turn.js library (YOU NEED TO ADD THIS)
│ └── flip-menu-public.js # Frontend scripts
├── flip-menu.php # Main plugin file
└── README.md # This file
Database Tables
The plugin creates two custom tables:
wp_flip_menu_shops
Stores shop information:
id- Shop IDname- Shop namedescription- Shop descriptioncreated_at- Creation timestampupdated_at- Update timestamp
wp_flip_menu_items
Stores menu items:
id- Item IDshop_id- Foreign key to shops tabletitle- Item titlesource_type- Type: 'image' or 'pdf'source_url- URL to the filepage_order- Display ordercreated_at- Creation timestampupdated_at- Update timestamp
Requirements
- WordPress 5.0 or higher
- PHP 7.0 or higher
- jQuery (included with WordPress)
- Turn.js library (must be added separately)
- (Optional) ImageMagick/Imagick for PDF conversion
Browser Support
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- Mobile browsers (iOS Safari, Chrome Mobile)
Customization
Styling
Customize the appearance by editing:
/public/css/flip-menu-public.css- Frontend styles/admin/css/flip-menu-admin.css- Admin styles
Turn.js Options
Modify Turn.js settings in /public/class-flip-menu-public.php in the flip_menu_shortcode method:
flipbook.turn({
width: 800,
height: 600,
autoCenter: true,
display: 'double', // 'single' or 'double' page display
acceleration: true,
gradients: true,
elevation: 50
});
Support & Development
Known Limitations
- PDF files require server-side conversion to images
- Turn.js has commercial licensing requirements
- Large images may affect performance
Future Enhancements
- Automatic PDF to image conversion
- Drag-and-drop reordering of pages
- Fullscreen mode
- Zoom functionality
- Mobile-optimized controls
- Multiple menu templates
License
This plugin is licensed under GPL v2 or later.
Note: Turn.js has its own licensing requirements. Please ensure compliance with Turn.js license terms for commercial use.
Credits
- Turn.js by Emmanuel Garcia - http://www.turnjs.com/
- WordPress Plugin Boilerplate by DevinVinson
Changelog
Version 1.0.0
- Initial release
- Shop management
- Image upload support
- PDF upload support (requires conversion)
- Shortcode implementation
- Responsive design
- Keyboard navigation
Author
Your Name or Your Company
Support
For support, please visit [your support URL]