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/amir-soly/wp-service-demo/archive/refs/heads/main.zipA lightweight WordPress plugin for displaying a service catalog and collecting consultation requests.
Overview
WP Service Demo is a standalone WordPress plugin that provides:
- Dynamic service catalog loaded from a JSON file.
- Responsive service cards.
- Category filtering without page reload.
- Consultation request form.
- REST API endpoints for retrieving services and submitting requests.
- Database storage for consultation requests.
- Admin page for viewing and searching submitted requests.
Requirements
- WordPress 6.4 or higher
- PHP 8.1 or higher
- MySQL or MariaDB
- A modern web browser
Installation
-
Copy the
wp-service-demodirectory into:wp-content/plugins/ -
Open the WordPress admin dashboard.
-
Navigate to Plugins.
-
Activate WP Service Demo.
Usage
Add the following shortcode to any WordPress page or post:
[wp_service_demo]
The plugin displays the service catalog and consultation request form.
Service Catalog
Services are stored in:
data/services.json
Example:
[
{
"id": "vps-basic",
"name": "VPS Basic",
"category": "VPS",
"price": 200000
}
]
Each service contains:
id: Unique service identifier.name: Service name.category: Service category.price: Service price.
REST API
Get Services
Endpoint:
GET /wp-json/demo/v1/services
Returns the available services in JSON format.
Submit Consultation Request
Endpoint:
POST /wp-json/demo/v1/requests
Content-Type:
application/json
Example request:
{
"name": "Ali Ahmadi",
"email": "ali@example.com",
"service_id": "vps-basic",
"website": ""
}
The website field is a honeypot field and must remain empty.
A successful request returns HTTP status 201.
Database
The plugin creates a custom database table:
wp_wpsd_requests
The actual table prefix depends on the WordPress database configuration.
Stored information includes:
- Request ID
- Full name
- Email address
- Service ID
- Service name
- Hashed IP address
- Request creation time in GMT
Admin Panel
Consultation requests can be viewed from:
WordPress Dashboard → مشاوره سرویسها
Access is restricted to users with the manage_options capability.
The admin page supports:
- Viewing submitted requests.
- Searching by name, email, or service.
- Pagination.
Security
The plugin implements:
- Direct-access protection using
ABSPATH. - Input sanitization and server-side validation.
- Prepared database queries.
- Output escaping.
- Honeypot spam protection.
- IP-based rate limiting.
- HMAC-SHA256 hashing of IP addresses.
- Database locking for concurrent request handling.
- Request body size validation.
Project Structure
wp-service-demo/
│
├── assets/
│ ├── css/
│ │ └── frontend.css
│ └── js/
│ └── frontend.js
│
├── data/
│ └── services.json
│
├── includes/
│ ├── class-wpsd-admin.php
│ ├── class-wpsd-catalog.php
│ ├── class-wpsd-rest.php
│ ├── class-wpsd-shortcode.php
│ └── class-wpsd-storage.php
│
├── .gitignore
├── README.md
└── wp-service-demo.php
Notes
This plugin was developed as a WordPress plugin assessment project, with an emphasis on simplicity, maintainability, security, and adherence to WordPress development practices.