Smart Task Manager
A lightweight task manager that stores tasks as a custom post type with a dedicated admin dashboard.
by Smart Task Manager · github.com/md-abu-bakker-siddik/smart-task-manager · website
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/md-abu-bakker-siddik/smart-task-manager/archive/refs/heads/main.zipA WordPress plugin that provides a simple admin dashboard for creating and viewing tasks. Tasks are stored as a Custom Post Type (smart_task) for scalability, efficient querying, and alignment with WordPress core patterns.
Part 1: Plan First
What This Plugin Does
Smart Task Manager adds a Task Manager item to the WordPress admin menu. Administrators can:
- Create tasks using a form with Task Title and Task Status (Pending or Completed).
- View all tasks in a table listing each task's title and status.
Tasks persist in the database as smart_task posts with status stored in post meta. The plugin does not expose tasks on the front end.
File Structure
smart-task-manager/
├── smart-task-manager.php # Main plugin file (header, constants, bootstrap)
├── includes/
│ ├── class-smart-task-manager.php # Core singleton; loads classes and registers hooks
│ ├── class-cpt.php # Registers the smart_task custom post type
│ ├── class-admin.php # Admin menu, form, task table, notices
│ └── class-form-handler.php # Secure form processing via admin_post_
├── uninstall.php # Removes all tasks when the plugin is deleted
└── README.md # This file
Design notes:
- Single entry point — Only
smart-task-manager.phpcontains the plugin header. - Separation of concerns — CPT registration, admin UI, and form handling live in dedicated classes.
- No hardcoded magic strings in templates — Post type slug, meta keys, menu slug, nonce names, and status options are defined once as class constants or methods and reused throughout the codebase.
Why Custom Post Type Instead of WP Options?
WordPress offers several storage mechanisms. For a task manager that may grow over time, a Custom Post Type (CPT) is the better choice over wp_options:
| Concern | WP Options | Custom Post Type (smart_task) |
|---|---|---|
| Scalability | Options are key/value pairs, often stored as serialized arrays. Loading or saving a large task list means reading/writing one bloated option row, which does not scale well. | Each task is its own row in wp_posts. Adding tasks does not inflate a single option. WordPress handles large datasets efficiently with indexed queries. |
| Querying | Filtering, sorting, or paginating tasks requires loading the entire option and processing it in PHP. | Native WP_Query supports ordering by date, pagination, search, and meta queries out of the box. |
| Status management | Custom status logic must be built and maintained manually inside serialized data. | WordPress provides built-in post statuses (publish, draft, trash, etc.) for lifecycle management. Task-specific statuses (Pending, Completed) are stored in post meta with validation via a single source of truth. |
| Data integrity | One corrupted serialization breaks the entire task list. | Each task is independent; one bad record does not affect others. |
| Extensibility | Hard to attach per-task metadata, revisions, or REST API exposure. | Post meta, hooks, and the REST API ecosystem integrate naturally. |
For a small demo with two tasks, options might seem simpler. For a real task manager, CPT aligns with WordPress architecture and avoids performance and maintenance problems as usage grows.
Security Practices
This plugin follows WordPress security best practices:
- Direct access prevention — Every PHP file checks
ABSPATH(orWP_UNINSTALL_PLUGINfor uninstall) before executing. - Capability checks — Only users with
manage_optionscan view the admin page and submit the form. - Nonces — Form submissions include a WordPress nonce verified with
wp_verify_nonce()to prevent CSRF attacks. - Input sanitization — All user input is sanitized (
sanitize_text_field,sanitize_key) before use. - Output escaping — All output uses
esc_html,esc_attr, oresc_urlas appropriate. - Safe redirects — After form submission,
wp_safe_redirect()sends users back to the admin page. - Validated status values — Status is whitelisted against allowed options; unknown values default to
pending. - WordPress hooks — Uses
initfor CPT registration,admin_menufor the dashboard, andadmin_post_{action}for form handling (no raw$_POSTprocessing in template files).
Part 2: Installation and Usage
Requirements
- WordPress 6.0 or higher
- PHP 7.4 or higher
Installation
- Copy the
smart-task-managerfolder into your WordPresswp-content/plugins/directory. - Log in to the WordPress admin dashboard.
- Go to Plugins → Installed Plugins.
- Find Smart Task Manager and click Activate.
On activation, the plugin registers the smart_task custom post type. No additional configuration is required.
Creating a Task
- In the admin sidebar, click Task Manager.
- Enter a Task Title in the text field.
- Select Pending or Completed from the Task Status dropdown.
- Click Add Task.
A success notice appears at the top of the page, and the new task appears in the All Tasks table below the form.
Viewing Tasks
All created tasks are listed in the table on the Task Manager page, sorted by creation date (newest first). Each row shows the task title and its human-readable status.
Uninstallation
When you delete the plugin from Plugins → Installed Plugins, WordPress runs uninstall.php, which permanently removes all smart_task posts and their metadata from the database.
Deactivating the plugin does not delete tasks; they remain in the database until the plugin is deleted.
Development
Hooks Used
| Hook | Purpose |
|---|---|
init |
Register the smart_task custom post type |
admin_menu |
Add the Task Manager admin menu page |
admin_notices |
Display success/error messages after form submission |
admin_post_stm_create_task |
Process the create-task form securely |
Extending the Plugin
Common extension points:
- Add more status options in
STM_CPT::get_status_options(). - Hook into
save_post_smart_taskto run actions when tasks are created. - Use
WP_Querywithpost_type => smart_taskto build reports or widgets.
AI Tools Disclosure
This plugin was developed with assistance from Cursor Pro, using AI models including Claude 3.5 Sonnet and GPT-4o, for scaffolding code structure, implementing WordPress coding standards, and drafting documentation.
License
GPL-2.0-or-later. See LICENSE.