|
1 | | -# multisite-exporter |
| 1 | +# Multisite Exporter |
| 2 | + |
| 3 | +Multisite Exporter is a WordPress plugin that allows you to export content from all subsites in a WordPress multisite installation. The plugin runs the WordPress exporter on each subsite in the background using the Action Scheduler library, making it efficient even for large multisite networks. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Export content from all subsites in a WordPress multisite network |
| 8 | +- Background processing using Action Scheduler to handle large networks efficiently |
| 9 | +- Filter exports by content type, post type, and date range |
| 10 | +- Centralized export file storage for easy access to all exports |
| 11 | +- Select and download multiple export files as a zip archive |
| 12 | +- Fully translatable with .pot file included |
| 13 | +- Customizable export directory location via filter |
| 14 | + |
| 15 | +## Requirements |
| 16 | + |
| 17 | +- WordPress Multisite installation |
| 18 | +- PHP 7.0 or higher |
| 19 | +- Action Scheduler library (included via Composer) |
| 20 | + |
| 21 | +## Installation |
| 22 | + |
| 23 | +### Method 1: Composer |
| 24 | + |
| 25 | +1. Clone this repository to your WordPress plugins directory |
| 26 | +2. Navigate to the plugin directory |
| 27 | +3. Run `composer install` to install dependencies |
| 28 | +4. Activate the plugin from the WordPress Network Admin |
| 29 | + |
| 30 | +```bash |
| 31 | +cd wp-content/plugins |
| 32 | +git clone https://github.com/yourusername/multisite-exporter.git |
| 33 | +cd multisite-exporter |
| 34 | +composer install |
| 35 | +``` |
| 36 | + |
| 37 | +### Method 2: Manual Installation |
| 38 | + |
| 39 | +1. Download the plugin zip file |
| 40 | +2. Upload and extract to your WordPress plugins directory |
| 41 | +3. Make sure the Action Scheduler library is included in the vendor directory |
| 42 | +4. Activate the plugin from the WordPress Network Admin |
| 43 | + |
| 44 | +## Usage |
| 45 | + |
| 46 | +### Running an Export |
| 47 | + |
| 48 | +1. Log in to your WordPress Network Admin dashboard |
| 49 | +2. Navigate to MS Exporter → Multisite Exporter |
| 50 | +3. Configure your export settings: |
| 51 | + - Content: Choose to export all content, posts, pages, or media |
| 52 | + - Post Type: Optionally specify a custom post type |
| 53 | + - Date Range: Optionally filter by start and end date |
| 54 | +4. Click "Run Export for All Subsites" |
| 55 | +5. Exports will be processed in the background using Action Scheduler |
| 56 | + |
| 57 | +### Accessing Export Files |
| 58 | + |
| 59 | +1. Navigate to MS Exporter → Export History |
| 60 | +2. View a list of all completed exports from all subsites |
| 61 | +3. Download options: |
| 62 | + - Click the "Download" button next to an individual export |
| 63 | + - Select multiple exports using checkboxes and click "Download Selected" to get a zip file |
| 64 | + - Use "Select All" and "Download Selected" to download all exports at once |
| 65 | + |
| 66 | +## How Action Scheduler Works |
| 67 | + |
| 68 | +The Multisite Exporter plugin uses Action Scheduler, a robust background processing library for WordPress, to handle export operations efficiently across multiple sites. Here's how it works: |
| 69 | + |
| 70 | +### Overview |
| 71 | + |
| 72 | +1. **Task Scheduling**: When you click "Run Export for All Subsites," the plugin creates an individual task for each subsite in your network. |
| 73 | + |
| 74 | +2. **Background Processing**: These tasks are processed in the background using WordPress cron, without blocking user interactions or causing timeout issues. |
| 75 | + |
| 76 | +3. **Failure Handling**: If an export fails, Action Scheduler will automatically retry it based on its built-in retry logic, ensuring robust operation even in challenging environments. |
| 77 | + |
| 78 | +### Technical Details |
| 79 | + |
| 80 | +- **Storage**: Action Scheduler stores tasks in a custom table, ensuring they don't get lost even in case of server interruptions. |
| 81 | + |
| 82 | +- **Queue Processing**: Tasks are executed in a controlled manner, with rate limiting to prevent server overload. |
| 83 | + |
| 84 | +- **Admin Interface**: The plugin provides a filtered view of Action Scheduler's interface under MS Exporter → Scheduled Actions, where you can monitor the progress of exports. |
| 85 | + |
| 86 | +- **Scaling**: The architecture can handle thousands of tasks, making it perfect for large multisite networks with hundreds of subsites. |
| 87 | + |
| 88 | +### Action Scheduler Location |
| 89 | + |
| 90 | +The Action Scheduler library is included in this plugin via Composer and can be found at: |
| 91 | + |
| 92 | +``` |
| 93 | +/vendor/woocommerce/action-scheduler/ |
| 94 | +``` |
| 95 | + |
| 96 | +All Action Scheduler related files are loaded automatically when the plugin initializes. |
| 97 | + |
| 98 | +### Benefits for Multisite Exports |
| 99 | + |
| 100 | +- **No Timeout Issues**: Export processes run in the background, avoiding PHP timeout restrictions. |
| 101 | + |
| 102 | +- **Server-Friendly**: Tasks are processed in batches, preventing server resource exhaustion. |
| 103 | + |
| 104 | +- **Monitoring**: You can track the progress of exports and identify any issues that may occur. |
| 105 | + |
| 106 | +- **Reliability**: The persistent storage mechanism ensures that even if a server restarts, your export tasks will continue where they left off. |
| 107 | + |
| 108 | +## Export File Storage |
| 109 | + |
| 110 | +All export files are stored in a centralized location within your WordPress uploads directory: |
| 111 | + |
| 112 | +``` |
| 113 | +wp-content/uploads/multisite-exports/ |
| 114 | +``` |
| 115 | + |
| 116 | +This makes it easy to find and manage exports from all your subsites in one place. |
| 117 | + |
| 118 | +### Customizing Export Directory |
| 119 | + |
| 120 | +You can change the default export directory by using the `multisite_exporter_directory` filter: |
| 121 | + |
| 122 | +```php |
| 123 | +/** |
| 124 | + * Change the directory where Multisite Exporter stores exported files |
| 125 | + */ |
| 126 | +add_filter( 'multisite_exporter_directory', 'my_custom_export_directory' ); |
| 127 | +function my_custom_export_directory( $default_export_dir ) { |
| 128 | + // Define a custom location for your export files |
| 129 | + return WP_CONTENT_DIR . '/my-custom-exports'; |
| 130 | +} |
| 131 | +``` |
| 132 | + |
| 133 | +Add this code to your theme's functions.php file or a custom plugin. |
| 134 | + |
| 135 | +## Translation |
| 136 | + |
| 137 | +The plugin is fully translatable. A POT file is included in the `languages` directory to help with translations. |
| 138 | + |
| 139 | +To create a translation: |
| 140 | + |
| 141 | +1. Copy the `languages/multisite-exporter.pot` file |
| 142 | +2. Rename it to `multisite-exporter-{locale}.po` (e.g., `multisite-exporter-fr_FR.po`) |
| 143 | +3. Translate using a tool like Poedit |
| 144 | +4. Save both .po and .mo files to the languages directory |
| 145 | + |
| 146 | +## License |
| 147 | + |
| 148 | +This plugin is licensed under the GPL v2 or later. |
| 149 | + |
| 150 | +## Author |
| 151 | + |
| 152 | +[Per Søderlind](https://soderlind.no) |
0 commit comments