mirror of
https://github.com/WenPai-org/wptag.git
synced 2025-08-03 12:23:41 +08:00
Introduce the main admin controllers, AJAX handlers, UI partials, and core classes for the WPTag plugin. This includes admin interface components, dashboard, settings, snippet management, asset files, and localization support. These files establish the foundation for managing code snippets, templates, and plugin settings within the WordPress admin.
3.8 KiB
3.8 KiB
WPTAG - WordPress Code Tag Manager
Professional WordPress plugin for managing tracking codes, analytics scripts, and third-party integrations with advanced conditional loading.
Features
Core Functionality
- Code Snippet Management: Add, edit, and organize code snippets with categories
- Multiple Insert Positions: Head, footer, before/after content
- Smart Conditional Loading: Control when and where snippets appear
- Service Templates: Quick setup for popular services like Google Analytics, Facebook Pixel
- Performance Optimization: Built-in caching and code optimization
- Import/Export: Backup and migrate your snippets easily
Conditional Loading Options
- Page types (home, posts, pages, archives, etc.)
- User status (logged in/out, user roles)
- Device types (desktop, mobile, tablet)
- Specific posts/pages
- Categories and tags
- URL patterns
- Date/time ranges
- Custom conditions via filters
Supported Services Templates
- Google Analytics 4
- Facebook Pixel
- Google Ads Conversion
- Google Search Console
- Baidu Analytics
- And more...
Installation
- Upload the
wptag
folder to/wp-content/plugins/
- Activate the plugin through the 'Plugins' menu in WordPress
- Navigate to WPTAG in your WordPress admin
Usage
Creating a Snippet
- Go to WPTAG > Code Snippets
- Click "Add New"
- Enter snippet details:
- Name and description
- Code content
- Position (head/footer/content)
- Category and priority
- Conditions (optional)
- Save and activate
Using Templates
- Go to WPTAG > Service Templates
- Select a service (e.g., Google Analytics)
- Enter your configuration (e.g., Tracking ID)
- Click "Create Snippet"
Setting Conditions
- Add multiple conditions to control snippet visibility
- Combine conditions with AND/OR logic
- Test conditions in preview mode
Requirements
- WordPress 6.8+
- PHP 8.0+
- MySQL 5.7+ or MariaDB 10.3+
Database Tables
The plugin creates three tables:
wp_wptag_snippets
- Stores code snippetswp_wptag_templates
- Service templateswp_wptag_logs
- Activity logs
Hooks and Filters
Actions
wptag_before_render_snippet
- Before snippet outputwptag_after_render_snippet
- After snippet output
Filters
wptag_snippet_output
- Modify snippet outputwptag_custom_condition
- Add custom conditionswptag_cache_ttl
- Modify cache duration
Performance
- Intelligent caching reduces database queries
- Conditional pre-processing for faster page loads
- Code minification option
- Compatible with popular caching plugins
Security
- Input validation and sanitization
- XSS protection
- SQL injection prevention
- User capability checks
- Nonce verification for all actions
Troubleshooting
Snippets not appearing
- Check if snippet is active
- Verify conditions are met
- Clear cache (WPTAG Settings > Clear Cache)
- Enable debug mode for detailed output
Performance issues
- Reduce number of active snippets
- Enable caching
- Optimize conditions
- Use priority settings wisely
Developer Documentation
Adding Custom Conditions
add_filter('wptag_custom_condition', function($result, $type, $value, $operator, $context) {
if ($type === 'my_custom_condition') {
// Your condition logic here
return $result;
}
return $result;
}, 10, 5);
Modifying Snippet Output
add_filter('wptag_snippet_output', function($code, $snippet) {
// Modify code before output
return $code;
}, 10, 2);
Support
For support and documentation, visit wptag.com
License
GPL v2 or later
Changelog
1.0.0
- Initial release
- Core snippet management
- Conditional loading engine
- Service templates
- Caching system
- Import/export functionality