MikroTik YouTube Videos
Displays YouTube videos on the MikroTik WooCommerce category page with custom styling
by Mustafa Hasanain · github.com/mustafahasanain/youtube-import-videos · 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/mustafahasanain/youtube-import-videos/archive/refs/heads/main.zipA WordPress plugin that automatically displays YouTube videos from a specified channel on your WooCommerce MikroTik category page with elegant styling and smooth animations.
Description
MikroTik YouTube Videos seamlessly integrates YouTube content into your WooCommerce store by automatically fetching and displaying videos from your YouTube channel. The plugin is specifically designed to enhance the MikroTik product category page with engaging video content, helping customers better understand your products through visual demonstrations.
Features
- Automatic Video Sync - Daily automated updates via WordPress cron jobs
- YouTube API Integration - Fetches latest videos using YouTube Data API v3
- Flexible Channel Input - Supports channel IDs, URLs, handles (@username), and custom URLs
- Smart Display - Auto-injects videos into sidebar on MikroTik category pages
- Shortcode Support - Use
[mikrotik_videos]anywhere on your site - Custom Widget - Drag-and-drop widget for sidebar placement
- Lazy Loading - Optimized thumbnail loading for better performance
- Load More Functionality - Progressive video loading with smooth animations
- Manual Refresh - Admin button to fetch videos on-demand
- Responsive Design - Mobile-friendly layout with touch optimization
- Theme Compatible - Works with WooCommerce, Flatsome, and most WordPress themes
- Error Handling - Comprehensive error reporting and API status monitoring
Requirements
- WordPress 5.0 or higher
- WooCommerce 3.0 or higher
- PHP 7.2 or higher
- YouTube Data API v3 key
- A YouTube channel
Installation
Via WordPress Admin
- Download the plugin zip file
- Navigate to Plugins > Add New in WordPress admin
- Click Upload Plugin and select the downloaded zip file
- Click Install Now and then Activate
Manual Installation
- Extract the plugin files
- Upload the
mikrotik-youtube-videosfolder to/wp-content/plugins/ - Activate the plugin through the Plugins menu in WordPress
First-Time Setup
- Go to MikroTik Videos in your WordPress admin menu
- Enter your YouTube Data API v3 key
- Enter your channel URL, ID, or handle
- Set the maximum number of videos to fetch (5-50)
- Click Save Settings & Fetch Videos
Configuration
Getting a YouTube API Key
- Visit Google Cloud Console
- Create a new project or select an existing one
- Enable the YouTube Data API v3
- Create credentials (API key)
- Copy the API key and paste it in the plugin settings
Learn more about getting started with YouTube API
Channel Configuration Options
The plugin accepts multiple channel input formats:
Channel ID: UC1234567890abcdefghij
Channel URL: https://youtube.com/channel/UC1234567890abcdefghij
Handle: @YourChannelName
Handle URL: https://youtube.com/@YourChannelName
Custom URL: https://youtube.com/c/YourCustomName
User URL: https://youtube.com/user/YourUsername
Settings Overview
- YouTube API Key - Your Google Cloud Console API key (required)
- YouTube Channel - Channel identifier in any supported format (required)
- Max Videos to Fetch - Number of latest videos to retrieve (5-50, default: 20)
Usage
Automatic Display
Videos automatically appear in the sidebar on your WooCommerce MikroTik product category page. No additional configuration needed.
Shortcode
Display videos anywhere on your site using the shortcode:
[mikrotik_videos]
Shortcode Attributes
initial - Number of videos to display initially (default: 3)
[mikrotik_videos initial="5"]
Widget
- Navigate to Appearance > Widgets
- Find MikroTik YouTube Videos widget
- Drag it to your desired sidebar
- The widget automatically displays only on MikroTik category pages
Manual Video Refresh
- Go to MikroTik Videos in admin menu
- Scroll to Status & Management section
- Click Refresh Videos Now button
- Videos will be fetched immediately
Programmatic Usage
Access the plugin instance in your theme or plugin:
global $mikrotik_youtube_plugin;
echo $mikrotik_youtube_plugin->render_videos(array('initial' => 5));
File Structure
mikrotik-youtube-videos/
├── mikrotik-youtube-videos.php # Main plugin file
├── assets/
│ ├── style.css # Custom styles
│ ├── script.js # Load more functionality
│ └── index.php # Security file
├── index.php # Root security file
└── README.md # Documentation
Hooks and Filters
The plugin provides several hooks for customization:
Actions
woocommerce_sidebar- Auto-display in WooCommerce sidebarflatsome_sidebar- Auto-display in Flatsome theme sidebardynamic_sidebar_before- Auto-display before dynamic sidebarsmikrotik_youtube_daily_sync- Cron job for daily video sync
AJAX Actions
wp_ajax_mikrotik_refresh_videos- Manual video refresh endpoint
Frequently Asked Questions
How often are videos updated?
Videos are automatically synced daily via WordPress cron. The next scheduled update time is displayed in the admin panel under Status & Management.
Can I use this plugin on multiple category pages?
The plugin is specifically designed for the MikroTik category page. However, you can use the shortcode [mikrotik_videos] to display videos on any page or post.
What happens if my API key expires or quota is exceeded?
The plugin will display the error message in the admin panel under Last Error. Videos cached from the previous successful sync will continue to display until you resolve the API issue.
How many API requests does this plugin make?
The plugin makes one API request during initial setup, one request per manual refresh, and one request per day for automatic sync. Each request consumes quota units from your YouTube API daily limit.
Can I customize the video display styling?
Yes! The plugin uses standard CSS classes that you can override in your theme's custom CSS:
.mikrotik-youtube-container- Main container.mikrotik-youtube-header- Header section.mikrotik-video-item- Individual video item.mikrotik-load-more-btn- Load more button
Does this plugin work with page builders?
Yes! Use the shortcode [mikrotik_videos] in any page builder that supports WordPress shortcodes (Elementor, WPBakery, Beaver Builder, etc.).
What video information is stored?
The plugin caches the following data for each video:
- Title
- URL
- Video ID
- Published date
- Description
No personal data is collected or stored.
Troubleshooting
Videos not displaying
- Verify API key is correct in settings
- Check that channel ID/URL is valid
- Review Last Error message in admin panel
- Ensure you're on the MikroTik category page
- Check that videos were successfully fetched (see Videos Cached count)
API errors
- Invalid API key - Verify your API key from Google Cloud Console
- Quota exceeded - YouTube API has daily quota limits; wait 24 hours or increase quota
- Invalid channel - Verify channel URL/ID format is correct
Styling issues
- Clear browser cache and WordPress cache
- Check for theme CSS conflicts
- Verify plugin version is 2.1.1 or higher
Changelog
Version 2.1.1
- Added support for YouTube handles (@username)
- Improved channel ID extraction from various URL formats
- Enhanced error handling and reporting
- Added manual refresh button in admin panel
- Fixed thumbnail loading issues
- Improved responsive design
- Added lazy loading for better performance
Security
- Nonce verification on all form submissions
- Capability checks for admin functions
- Sanitized input and escaped output
- Secure API key storage
- Protected against SQL injection and XSS
Performance
- Caching system reduces API calls
- Lazy loading for images
- Conditional asset loading (only on required pages)
- Optimized database queries
- Minimal HTTP requests
Browser Support
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
- Mobile browsers (iOS Safari, Chrome Mobile)
Credits
Developed with care for WooCommerce stores showcasing MikroTik products.
License
This plugin is licensed under the GPL v2 or later.
Copyright (C) 2025 Mustafa Hasanain
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Author
Mustafa Hasanain
- Website: mustafahasanain.com
- GitHub: github.com/mustafahasanain/mikrotik-youtube-videos
Support
For bug reports, feature requests, or support questions:
- Open an issue on GitHub
- Visit the plugin documentation
- Contact the author through the website
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request