WP Manifestindependent plugin directory
manifest / content / material_wordpress_plugin

Materials Plugin

A comprehensive WordPress plugin for managing materials with Google Drive links, advanced search, and mobile-responsive interface.

by Your Name · github.com/saqibullahdev/material_wordpress_plugin · website

★ 0stars
0forks

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/saqibullahdev/material_wordpress_plugin/archive/refs/heads/main.zip

Materials Plugin - WordPress Plugin

A comprehensive WordPress plugin that creates a custom post type for materials with Google Drive links, advanced search functionality, and a mobile-responsive frontend interface.

🚀 Features

Core Functionality

  • Custom Post Type: "Materials" with Google Drive link integration
  • Advanced Search: Real-time AJAX search with filtering and sorting
  • Mobile Responsive: Optimized for all devices and screen sizes
  • SEO Optimized: Comprehensive SEO features and structured data
  • Analytics: Detailed tracking and reporting system
  • Security: Enterprise-grade security measures

Search & Discovery

  • Real-time search with debounced input (300ms delay)
  • Multi-level filtering: categories, subcategories, and tags
  • Dynamic subcategory loading
  • Multiple sorting options: date, title, downloads, category
  • AJAX pagination with configurable results per page
  • Grouped results display by category and subcategory

User Experience

  • Modern, polished interface with advanced animations
  • Skeleton loading animations for better perceived performance
  • Dark mode support with automatic detection
  • Accessibility compliance with WCAG guidelines
  • Enhanced keyboard navigation and focus management
  • Cross-browser compatibility and progressive enhancement

SEO & Performance

  • Custom meta titles and descriptions
  • Open Graph and Twitter Card tags
  • Schema.org structured data markup
  • XML sitemap integration
  • Breadcrumb navigation
  • Canonical URLs
  • Performance optimizations with modern CSS features

Analytics & Tracking

  • Download tracking and analytics
  • Search analytics and insights
  • User behavior tracking
  • Performance metrics
  • Data export and reporting
  • Dashboard widget for quick overview

Security Features

  • Rate limiting for AJAX requests
  • Input validation and sanitization
  • CSRF protection and nonce verification
  • Security headers (CSP, XSS Protection, etc.)
  • SQL injection prevention
  • XSS protection
  • File upload security
  • Suspicious user agent blocking

📋 Requirements

  • WordPress: 5.0 or higher
  • PHP: 7.4 or higher
  • MySQL: 5.6 or higher
  • Browser Support: Modern browsers (Chrome 60+, Firefox 55+, Safari 12+, Edge 79+)

🛠️ Installation

Method 1: WordPress Admin (Recommended)

  1. Download the plugin ZIP file
  2. Go to Plugins > Add New in your WordPress admin
  3. Click Upload Plugin and select the ZIP file
  4. Click Install Now and then Activate Plugin

Method 2: Manual Installation

  1. Extract the plugin ZIP file
  2. Upload the materials-plugin folder to /wp-content/plugins/
  3. Go to Plugins in your WordPress admin
  4. Find "Materials Plugin" and click Activate

Method 3: Git Clone

cd wp-content/plugins
git clone https://github.com/yourusername/materials-plugin.git
cd materials-plugin
composer install  # If using Composer dependencies

⚙️ Configuration

Initial Setup

  1. Activate the plugin - This will create necessary database tables
  2. Create materials - Add your first material with Google Drive links
  3. Organize content - Set up categories and tags for your materials
  4. Configure settings - Go to Materials > Settings to customize options

Plugin Settings

Navigate to Materials > Settings to configure:

General Settings

  • Materials per page (default: 12)
  • Enable download tracking
  • Enable search analytics
  • Default access level (Public/Private/Premium)

Display Settings

  • Show download count
  • Show file size
  • Group by category
  • Enable lazy loading

Search Settings

  • Search delay (default: 300ms)
  • Cache duration (default: 1 hour)
  • Enable SEO optimization
  • Validate Google Drive URLs

Database Tables

The plugin creates the following custom tables:

  • wp_materials_meta - Enhanced material metadata
  • wp_materials_search_log - Search analytics
  • wp_materials_analytics - Comprehensive analytics
  • wp_materials_user_behavior - User behavior tracking
  • wp_materials_rate_limits - Rate limiting data
  • wp_materials_security_log - Security event logging

📖 Usage

Creating Materials

Via WordPress Admin

  1. Go to Materials > Add New
  2. Enter the material title and description
  3. Required: Add Google Drive link in the Material Details meta box
  4. Optional: Set file size, access level, and other metadata
  5. Assign categories and tags
  6. Publish the material

Via Import

  1. Go to Materials > Import/Export
  2. Prepare a CSV file with required columns:
    • title (required)
    • google_drive_link (required)
    • description, file_size, file_type, category, tags (optional)
  3. Upload and import the CSV file

Frontend Display

Materials Page

The plugin automatically creates a /materials/ page with:

  • Search interface with real-time results
  • Category and tag filtering
  • Sorting options
  • Pagination
  • Mobile-responsive design

Shortcodes

Use the [materials_search_page] shortcode to display the search interface anywhere:

[materials_search_page]

Template Integration

Include materials in your theme templates:

<?php
$materials = new WP_Query(array(
    'post_type' => 'materials',
    'posts_per_page' => 10
));

if ($materials->have_posts()) :
    while ($materials->have_posts()) : $materials->the_post();
        // Display material content
        echo '<h2>' . get_the_title() . '</h2>';
        echo '<p>' . get_the_excerpt() . '</p>';

        $drive_link = get_post_meta(get_the_ID(), '_google_drive_link', true);
        if ($drive_link) {
            echo '<a href="' . esc_url($drive_link) . '" target="_blank">Download</a>';
        }
    endwhile;
    wp_reset_postdata();
endif;
?>

Search Functionality

Basic Search

Users can search materials by:

  • Text content (title, description, content)
  • Categories and subcategories
  • Tags
  • File type
  • Access level

Advanced Features

  • Real-time results: Updates as users type
  • Smart filtering: Combines multiple criteria
  • Results grouping: Organized by category and subcategory
  • Performance optimized: Cached results and efficient queries

🔧 Developer Guide

Plugin Structure

materials-plugin/
├── materials-plugin.php          # Main plugin file
├── includes/                     # Core classes
│   ├── class-materials-plugin.php
│   ├── class-materials-post-type.php
│   ├── class-materials-ajax-handler.php
│   ├── class-materials-frontend.php
│   ├── class-materials-seo.php
│   ├── class-materials-analytics.php
│   └── class-materials-security.php
├── admin/                        # Admin interface
│   ├── class-materials-admin.php
│   └── class-materials-meta-boxes.php
├── public/                       # Frontend assets
│   ├── css/
│   ├── js/
│   └── templates/
├── assets/                       # Plugin assets
└── languages/                    # Translation files

Hooks and Filters

Actions

// Fired when plugin initializes
do_action('materials_plugin_init');

// Fired when material is created
do_action('materials_material_created', $post_id);

// Fired when material is downloaded
do_action('materials_material_downloaded', $post_id, $user_id);

// Fired when search is performed
do_action('materials_search_performed', $search_term, $results);

Filters

// Modify material query arguments
$args = apply_filters('materials_query_args', $args);

// Customize material display
$content = apply_filters('materials_display_content', $content, $post_id);

// Modify search results
$results = apply_filters('materials_search_results', $results, $search_term);

// Customize SEO meta
$meta = apply_filters('materials_seo_meta', $meta, $post_id);

Custom Post Type

// Register custom post type
$post_type = new Materials_Post_Type();

// Get materials
$materials = get_posts(array(
    'post_type' => 'materials',
    'post_status' => 'publish',
    'posts_per_page' => -1
));

// Get material meta
$drive_link = get_post_meta($post_id, '_google_drive_link', true);
$file_size = get_post_meta($post_id, '_file_size', true);
$access_level = get_post_meta($post_id, '_access_level', true);

AJAX Integration

// Handle custom AJAX requests
add_action('wp_ajax_my_custom_action', 'handle_custom_action');
add_action('wp_ajax_nopriv_my_custom_action', 'handle_custom_action');

function handle_custom_action() {
    // Verify nonce
    if (!wp_verify_nonce($_POST['nonce'], 'materials_ajax_nonce')) {
        wp_send_json_error('Security check failed');
    }

    // Process request
    $result = process_custom_action($_POST);

    // Send response
    wp_send_json_success($result);
}

Custom Fields

// Add custom meta box
add_action('add_meta_boxes', 'add_custom_meta_box');

function add_custom_meta_box() {
    add_meta_box(
        'custom_meta_box',
        'Custom Fields',
        'render_custom_meta_box',
        'materials',
        'normal',
        'high'
    );
}

// Save custom meta
add_action('save_post', 'save_custom_meta');

function save_custom_meta($post_id) {
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
    if (!current_user_can('edit_post', $post_id)) return;

    if (isset($_POST['custom_field'])) {
        update_post_meta($post_id, '_custom_field', sanitize_text_field($_POST['custom_field']));
    }
}

Styling and JavaScript

// Enqueue custom styles
add_action('wp_enqueue_scripts', 'enqueue_custom_styles');

function enqueue_custom_styles() {
    wp_enqueue_style(
        'custom-materials-style',
        get_template_directory_uri() . '/css/custom-materials.css',
        array('materials-frontend'),
        '1.0.0'
    );
}

// Customize JavaScript
add_action('wp_enqueue_scripts', 'enqueue_custom_scripts');

function enqueue_custom_scripts() {
    wp_enqueue_script(
        'custom-materials-script',
        get_template_directory_uri() . '/js/custom-materials.js',
        array('materials-search'),
        '1.0.0',
        true
    );

    // Localize script with custom data
    wp_localize_script('custom-materials-script', 'customMaterials', array(
        'ajaxUrl' => admin_url('admin-ajax.php'),
        'nonce' => wp_create_nonce('materials_ajax_nonce')
    ));
}

📊 Analytics and Reporting

Dashboard Widget

The plugin adds a dashboard widget showing:

  • Today's activity (downloads, views, searches)
  • This week's statistics
  • Quick access to full analytics

Analytics Page

Navigate to Materials > Analytics for detailed reports:

  • Overview statistics
  • Popular materials
  • Search analytics
  • Device and browser statistics
  • Export functionality

Data Export

Export analytics data in multiple formats:

  • CSV: For spreadsheet analysis
  • JSON: For API integration
  • Custom periods: 7, 30, 90, 365 days

🔒 Security Features

Rate Limiting

  • Search requests: 30 per minute
  • Downloads: 10 per minute
  • Views: 100 per minute
  • General requests: 100 per minute

Input Validation

  • Comprehensive input sanitization
  • Type-specific validation (URL, email, int, float, filename, HTML)
  • Maximum field size limits
  • Dangerous content detection

Security Headers

  • Content Security Policy (CSP)
  • XSS Protection
  • Content Type Options
  • Frame Options
  • Referrer Policy
  • HSTS (on HTTPS)

File Upload Security

  • Restricted MIME types
  • File size limits (50MB max)
  • Malicious content scanning
  • Path traversal prevention

🚀 Performance Optimization

Caching Strategy

  • Object caching: Taxonomy terms and post queries
  • Transient caching: Search results for 5 minutes
  • Database optimization: Proper indexing on custom tables
  • AJAX pagination: Load results in chunks

Code Optimization

  • Lazy loading: Load content on scroll
  • Minified assets: Compressed CSS and JS files
  • CDN integration: Support for CDN delivery
  • Database queries: Optimized WP_Query parameters

Modern CSS Features

  • CSS custom properties for theming
  • Container queries for responsive design
  • Backdrop filters for modern effects
  • Reduced motion support for accessibility

🌐 Internationalization

Translation Support

The plugin is fully translatable:

  • Text domain: materials-plugin
  • Translation files in /languages/ directory
  • Support for RTL languages
  • Localized date and number formats

Adding Translations

  1. Create translation files using Poedit or similar tools
  2. Place .po and .mo files in /languages/ directory
  3. Use __(), _e(), and esc_html__() functions for translatable strings

🧪 Testing

Unit Testing

# Run PHPUnit tests
composer test

# Run specific test suite
vendor/bin/phpunit --testsuite=unit

Integration Testing

# Run integration tests
vendor/bin/phpunit --testsuite=integration

# Run with WordPress test environment
vendor/bin/phpunit --testsuite=wordpress

Browser Testing

  • Desktop: Chrome, Firefox, Safari, Edge
  • Mobile: iOS Safari, Chrome Mobile, Samsung Internet
  • Tablet: iPad, Android tablets

🐛 Troubleshooting

Common Issues

Plugin Not Activating

  • Check PHP version (7.4+ required)
  • Verify WordPress version (5.0+ required)
  • Check for plugin conflicts
  • Review error logs

Search Not Working

  • Verify AJAX is enabled
  • Check nonce verification
  • Review browser console for JavaScript errors
  • Verify database tables exist

Performance Issues

  • Enable caching plugins
  • Check database query performance
  • Optimize images and assets
  • Review server configuration

Security Warnings

  • Update WordPress and plugins
  • Check file permissions
  • Review security logs
  • Enable security plugins

Debug Mode

Enable WordPress debug mode for detailed error information:

// In wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

Support Resources

📈 Roadmap

Version 1.1 (Q2 2024)

  • [ ] Advanced reporting dashboard
  • [ ] Email notifications
  • [ ] Bulk operations
  • [ ] API endpoints

Version 1.2 (Q3 2024)

  • [ ] Multi-site support
  • [ ] Advanced caching
  • [ ] Performance monitoring
  • [ ] Mobile app integration

Version 2.0 (Q4 2024)

  • [ ] Cloud storage integration
  • [ ] Advanced analytics
  • [ ] Machine learning features
  • [ ] Enterprise features

🤝 Contributing

Development Setup

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

Coding Standards

  • Follow WordPress coding standards
  • Use PHP 7.4+ features
  • Write comprehensive documentation
  • Include unit tests for new features

Code Review Process

  1. Automated checks (PHPCS, PHPUnit)
  2. Manual code review
  3. Testing in staging environment
  4. Merge to development branch
  5. Release to production

📄 License

This plugin is licensed under the GPL v2 or later.

Copyright (C) 2024 Your Name

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.

🙏 Acknowledgments

  • WordPress community for the excellent platform
  • Contributors and beta testers
  • Open source projects that made this possible
  • Users who provided feedback and suggestions

📞 Support

For support, questions, or feature requests:


Thank you for using Materials Plugin! 🎉

If you find this plugin helpful, please consider:

  • ⭐ Rating it on WordPress.org
  • 📝 Writing a review
  • 💰 Making a donation
  • 🔗 Sharing it with others