Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/johanneswilm/animal-sponsorship/archive/refs/heads/main.zip4H Animal Sponsorship WordPress Plugin
A comprehensive WordPress plugin for managing animal sponsorships at 4H farms in Sweden. This plugin allows visitors to sponsor animals with SWISH payments and provides farm administrators with tools to manage sponsorships, verify payments, and track statistics.
Features
🐾 Animal Management
- Custom post type for animals with detailed information
- Photo uploads and galleries
- Species, age, and pricing management
- Sponsorship status tracking
💳 SWISH Payment Integration
- QR code generation for SWISH payments
- Mobile-friendly payment links
- Manual payment verification
- Payment timeout handling
👥 Sponsorship Types
- Individual sponsorships
- Family sponsorships
- Corporate sponsorships
- Custom sponsor information display
📊 Admin Dashboard
- Real-time statistics
- Payment verification tools
- Sponsorship management
- Export functionality
- Email notifications
🌍 Swedish Localization
- Complete Swedish translation
- Swedish phone number validation
- SEK currency formatting
- SWISH integration optimized for Sweden
Installation
Requirements
- WordPress 5.0 or higher
- PHP 7.4 or higher
- MySQL 5.6 or higher
- SWISH account for payment processing
Manual Installation
-
Download the plugin
git clone https://github.com/4h-sweden/animal-sponsorship.git -
Upload to WordPress
- Upload the
animal-sponsorshipfolder to/wp-content/plugins/ - Activate the plugin through the 'Plugins' menu in WordPress
- Upload the
-
Configure settings
- Go to
Animals > Settingsin your WordPress admin - Enter your SWISH phone number
- Configure email settings
- Set farm information
- Go to
Configuration
Basic Setup
-
SWISH Configuration
- Navigate to
Animals > Settings > Payment Settings - Enter your SWISH phone number (format: 070-123 45 67)
- Test with small amounts first
- Navigate to
-
Email Settings
- Set admin email for notifications
- Configure email from name and address
- Enable/disable email notifications
-
General Settings
- Set farm name
- Configure sponsorship year (default: 2026)
- Set currency symbol
Adding Animals
-
Go to
Animals > Add New -
Fill in animal information:
- Name and description
- Species and age
- Sponsorship price
- Upload photos
-
Publish the animal to make it available for sponsorship
Usage
Display Animals on Your Website
Use these shortcodes to display animals on your pages:
Animals Grid
[animal_sponsorship_list per_page="12" show_sponsored="yes"]
Parameters:
per_page: Number of animals per page (default: 12)show_sponsored: Show sponsored animals (yes/no, default: yes)
Sponsorship Form
[animal_sponsorship_form animal_id="123"]
Parameters:
animal_id: ID of the specific animal to sponsor
Managing Sponsorships
-
View Sponsorships
- Go to
Animals > Sponsorships - Filter by status, sponsor type, or date
- Export data to CSV
- Go to
-
Verify Payments
- Check your SWISH app for incoming payments
- Match payment details with sponsorship requests
- Click "Verify Payment" to confirm sponsorship
-
Cancel Sponsorships
- Use the "Cancel" button for invalid or duplicate requests
- Cancelled sponsorships free up the animal for other sponsors
SWISH Integration
How It Works
- Visitor selects an animal to sponsor
- Fills out sponsorship form
- Receives QR code for SWISH payment
- Makes payment using SWISH app
- Admin verifies payment manually
- Sponsorship is confirmed and displayed
Payment Verification
Important: This plugin does not automatically verify SWISH payments. You must:
- Check your SWISH app for incoming payments
- Match payment amount and reference number
- Manually verify payments in the admin panel
Security Notes
- Never share your SWISH login credentials
- Regularly check for suspicious payment requests
- Keep the plugin updated for security patches
Customization
Styling
The plugin includes comprehensive CSS that can be customized:
- Frontend:
assets/css/public.css - Admin:
assets/css/admin.css
Templates
Override templates by copying them to your theme:
your-theme/animal-sponsorship/animals-grid.php
your-theme/animal-sponsorship/sponsorship-form.php
Hooks and Filters
Actions
// Before sponsorship creation
do_action('animal_sponsorship_before_create', $sponsorship_data);
// After sponsorship confirmation
do_action('animal_sponsorship_confirmed', $sponsorship_id);
// Before sending emails
do_action('animal_sponsorship_before_email', $email_type, $sponsorship_id);
Filters
// Modify sponsorship data
$data = apply_filters('animal_sponsorship_data', $data);
// Customize email content
$message = apply_filters('animal_sponsorship_email_message', $message, $type);
// Modify QR code settings
$qr_settings = apply_filters('animal_sponsorship_qr_settings', $settings);
Translation
The plugin is fully translatable and includes Swedish translation files:
languages/animal-sponsorship-sv_SE.polanguages/animal-sponsorship-sv_SE.mo
To create additional translations:
- Use a tool like Poedit
- Load the
.potfile from thelanguagesdirectory - Translate all strings
- Save as
animal-sponsorship-{locale}.poand.mo
Troubleshooting
Common Issues
SWISH QR Codes Not Working
- Verify your SWISH phone number is correct
- Test QR codes with the SWISH app
- Check that your website is accessible via HTTPS
Email Notifications Not Sending
- Verify SMTP settings in WordPress
- Check spam folders
- Test with a simple email plugin first
Animals Not Displaying
- Check that animals are published
- Verify shortcode syntax
- Clear any caching plugins
Payment Verification Issues
- Ensure you have admin privileges
- Check browser console for JavaScript errors
- Verify AJAX requests are working
Debug Mode
Enable debugging by adding to wp-config.php:
define('ANIMAL_SPONSORSHIP_DEBUG', true);
This will log additional information to help diagnose issues.
Getting Help
- Check the Issues page
- Search existing issues before creating new ones
- Include WordPress version, PHP version, and error messages
- Provide steps to reproduce the problem
Contributing
We welcome contributions! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Development Setup
# Clone the repository
git clone https://github.com/4h-sweden/animal-sponsorship.git
# Install dependencies (if any)
cd animal-sponsorship
npm install # For any build tools
# Set up local WordPress environment
# Use Local, XAMPP, or Docker
Code Standards
- Follow WordPress coding standards
- Use proper sanitization and validation
- Add inline documentation
- Include translation strings
License
This plugin is licensed under the GPL v2 or later.
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.
Credits
- Developed for 4H Sweden
- SWISH integration for Swedish payments
- Built with WordPress best practices
- Uses modern PHP and JavaScript
Changelog
Version 1.0.0
- Initial release
- Animal management system
- SWISH payment integration
- Swedish localization
- Admin dashboard
- Email notifications
- Export functionality
Support
For support and questions:
Note: This plugin requires manual payment verification through the SWISH app. It does not automatically process payments or connect to banking APIs for security reasons.