# Download Helper

A WordPress plugin that adds download buttons for plugins and themes in the WordPress admin dashboard, with support for bulk downloads.

## Description

Download Helper makes it easy to download plugins and themes directly from your WordPress admin dashboard. It adds download buttons to both individual plugins/themes and supports bulk downloads of multiple items at once.

### Features

- Download individual plugins and themes with a single click
- Bulk download multiple plugins or themes
- Automatic size checking to prevent server overload
- Rate limiting to prevent abuse
- Configurable download size limits
- Clean and intuitive interface
- Secure downloads with nonce verification
- Proper cleanup of temporary files

## Installation

1. Upload the `download-helper` folder to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. The download buttons will automatically appear in the plugins and themes pages

## Usage

### Individual Downloads

1. Go to Plugins or Themes page in WordPress admin
2. Find the plugin or theme you want to download
3. Click the "Download" link in the row actions
4. The plugin/theme will be downloaded as a ZIP file

### Bulk Downloads

1. Go to Plugins or Themes page in WordPress admin
2. Select multiple items using the checkboxes
3. Choose "Download Selected" from the bulk actions dropdown
4. Click "Apply"
5. The selected items will be downloaded as a ZIP file

## Configuration

### Download Size Limit

By default, the plugin limits downloads to 500MB. You can modify this limit using the `download_helper_max_size` filter:

```php
add_filter( 'download_helper_max_size', function( $max_size ) {
    return 1024 * MB_IN_BYTES; // Set to 1GB
} );
```

### Rate Limiting

The plugin includes rate limiting to prevent abuse. By default, users are limited to 5 downloads per minute. This can be modified by changing the `DOWNLOAD_HELPER_RATE_LIMIT` constant in the main plugin file.

## Security

The plugin implements several security measures:

- Nonce verification for all download actions
- Capability checks to ensure only administrators can download
- Rate limiting to prevent abuse
- Size limits to prevent server overload
- Proper sanitization of all inputs
- Secure file handling and cleanup

## Hooks and Filters

### Filters

- `download_helper_max_size`: Modify the maximum allowed download size
  ```php
  add_filter( 'download_helper_max_size', function( $max_size ) {
      return 1024 * MB_IN_BYTES; // Set to 1GB
  } );
  ```

### Actions

- `download_helper_before_download`: Fires before a download starts
  ```php
  add_action( 'download_helper_before_download', function( $type, $item ) {
      // $type can be 'plugin' or 'theme'
      // $item is the plugin file or theme slug
  }, 10, 2 );
  ```

- `download_helper_after_download`: Fires after a download completes
  ```php
  add_action( 'download_helper_after_download', function( $type, $item ) {
      // $type can be 'plugin' or 'theme'
      // $item is the plugin file or theme slug
  }, 10, 2 );
  ```

## Requirements

- WordPress 5.0 or higher
- PHP 7.2 or higher
- ZIP extension enabled in PHP

## Frequently Asked Questions

### Why is there a size limit?

The size limit helps prevent server overload and ensures smooth downloads. You can modify the limit using the `download_helper_max_size` filter.

### Can I download multiple plugins/themes at once?

Yes! Use the bulk actions feature to select and download multiple items at once.

### Is it secure?

Yes, the plugin implements several security measures including nonce verification, capability checks, and rate limiting.

### What happens to temporary files?

Temporary files are automatically cleaned up after each download. The plugin also cleans up any leftover temporary files during deactivation.

## Changelog

### 1.0.0
- Initial release
- Individual plugin and theme downloads
- Bulk download support
- Size limit checks
- Rate limiting
- Security measures

## Credits

Developed by [Your Name]

## License

This plugin is licensed under the GPL v2 or later.

```php
/*
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.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
``` 