Product Models Block
A Gutenberg block for displaying product models with tabs, image galleries, and accordion sections.
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/yanivcoweb/product-models/archive/refs/heads/claude%2Fproduct-models-gutenberg-block-MJbNY.zipProduct Models Gutenberg Block Plugin
A powerful WordPress Gutenberg block for displaying product models with dynamic tabs, image galleries, and collapsible accordion sections.
Features
1. Dynamic Tab System
- Add/remove unlimited tabs
- Customizable tab labels
- Drag-and-drop tab reordering
- Active tab indicator with bottom border
- Smooth tab switching without page reload
2. Product Management
- Add unlimited products per tab
- Assign products to specific tabs
- Drag-and-drop product reordering
- Duplicate products
- Delete products with confirmation
3. Image Gallery
- Multiple images per product
- Main image display with thumbnail navigation
- Previous/Next arrow navigation
- Click thumbnail to view
- Keyboard navigation support (arrow keys)
- Responsive design
4. Accordion Sections
- Multiple collapsible sections per product
- First section open by default
- Only one section open at a time
- Smooth expand/collapse animations
- Custom section titles
- Rich text descriptions
- Repeatable bullet points
5. Call-to-Action Button
- Customizable button text
- URL configuration
- Open in same/new window option
- Hover effects and animations
Installation
-
Clone or download this repository into your WordPress plugins directory:
cd wp-content/plugins/ git clone <repository-url> product-models-block cd product-models-block -
Install dependencies:
npm install -
Build the block:
npm run build -
Activate the plugin in WordPress admin panel (Plugins → Installed Plugins → Activate "Product Models Block")
Development
Start Development Mode
npm start
This will start the development server with hot reloading.
Build for Production
npm run build
Other Commands
npm run format # Format code
npm run lint:js # Lint JavaScript
npm run lint:css # Lint CSS
npm run plugin-zip # Create plugin zip file
Usage
Adding the Block
- In the WordPress editor, click the (+) button to add a new block
- Search for "Product Models"
- Click to insert the block
Configuring Tabs
- Open the block settings panel on the right
- Under "Tab Management":
- Edit tab names
- Use ↑/↓ buttons to reorder tabs
- Click "Delete" to remove a tab
- Click "+ Add New Tab" to create a new tab
Adding Products
- Select the tab where you want to add a product
- In the settings panel, click "+ Add Product to Current Tab"
- Configure the product:
- Set product title
- Assign to a tab
- Add images
- Configure accordion sections
- Set up CTA button
Managing Images
- Click "Add Images" or "Edit Images"
- Select multiple images from media library
- Images will display with:
- First image as main view
- Thumbnails below for navigation
- Arrow navigation for cycling through images
Accordion Sections
- Each product can have multiple accordion sections
- First section is open by default on page load
- Clicking a section opens it and closes others
- Add bullet points within sections for features/specs
- Use "+ Add Accordion Section" to add more sections
CTA Button
- Set button text (e.g., "Order Now", "Learn More")
- Set destination URL
- Choose to open in same window or new tab
Block Structure
product-models-block/
├── product-models-block.php # Main plugin file
├── src/
│ ├── block.json # Block metadata
│ ├── index.js # Block registration
│ ├── edit.js # Editor component
│ ├── save.js # Frontend render
│ ├── frontend.js # Frontend interactions
│ ├── style.scss # Frontend styles
│ └── editor.scss # Editor styles
├── build/ # Compiled files (generated)
├── package.json # Dependencies
└── README.md # This file
Browser Support
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
WordPress Requirements
- WordPress 6.0 or higher
- PHP 7.4 or higher
Customization
Styling
The block uses BEM-style CSS classes for easy customization:
.product-models-block /* Main container */
.tab-navigation /* Tab container */
.tab-button /* Individual tab */
.tab-button.active /* Active tab */
.product-item /* Product container */
.product-images /* Image section */
.main-image /* Main image display */
.thumbnail-images /* Thumbnail container */
.product-details /* Product info section */
.accordion-item /* Accordion container */
.accordion-header /* Accordion toggle */
.accordion-content /* Accordion body */
.cta-button /* Call-to-action button */
Add custom CSS in your theme's stylesheet to override default styles.
Troubleshooting
Block doesn't appear in editor
- Make sure plugin is activated
- Clear browser cache
- Check browser console for errors
Images not displaying
- Verify image URLs are correct
- Check media library permissions
- Ensure images are properly uploaded
Accordion not working
- Check browser console for JavaScript errors
- Ensure frontend.js is being loaded
- Clear cache and reload page
Build errors
- Delete node_modules and reinstall:
rm -rf node_modules && npm install - Check Node.js version (requires Node 14+)
- Run
npm run buildagain
License
GPL-2.0-or-later
Support
For issues, questions, or contributions, please open an issue in the repository.
Credits
Built with:
- WordPress Gutenberg
- React
- @wordpress/scripts