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/hemantwpdev/wp-content-manager/archive/refs/heads/main.zipNo built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.
WP Content Manager (Promo Blocks)
This plugin provides a lightweight Promo Blocks manager (custom post type, meta boxes, shortcode, AJAX loading, REST API and a simple caching layer).
Setup Instructions
- Install:
- Copy the
wp-content-managerfolder intowp-content/plugins/. - Activate the plugin from the WordPress admin > Plugins screen.
- Visit the plugin settings "Dynamic Content" under the settings menu to configure
Max promos,Enable Promo Blocks,Cache TTLandEnable AJAX.
- Copy the
- Optional: ensure the folder
public/imagescontainsno-image.jpgfor fallback thumbnails.
Architecture
- Plugin root files: main bootstrap and activation/deactivation handlers.
includes/— core classes used both in admin and public:class-wp-content-manager.php— main loader that initializes components.class-wp-content-manager-cpt.php— registers thepromo_blockscustom post type.class-wp-content-manager-meta-box.php— registers meta boxes and saves promo meta (CTA, URL, priority, expiry).class-wp-content-manager-cache.php— simplified cache helper.- other helpers: activator, deactivator, i18n, loader.
admin/— admin UI and settings pages (settings sanitization, capability checks).public/— frontend functionality:class-wp-content-manager-public.php— public hooks and asset registration.class-wp-content-manager-shortcode.php— shortcode rendering, AJAX handler, fallback image support.class-wp-content-manager-rest-api.php— REST endpoint/wp-json/dcm/v1/promos.
Performance Optimizations Applied
- Simplified transient caching: a single transient key
promo_blocks_cachekeep cache logic simple. - Configurable TTL via plugin settings (
cache_ttl) to control freshness. - Cache invalidation triggers on post save and delete (hooks attached), and settings update triggers a cache clear.
- AJAX endpoint check cache first and only query the DB on cache miss.
- Query efficiency:
WP_Queryusesposts_per_page+ ordering by_dcm_display_priorityto limit rows returned. - Nonces and capability checks used for AJAX and admin operations to avoid unnecessary processing for unauthorized requests.
All features
- When plugin activate Promo Blocks CPT hasa been created.
- All the meta boxes has been created and stored there data throw nonce and sanitization.
- Dynamic Content settings page has been created. In this Enable Promo Blocks, Maximum Promo Blocks, Cache TTL (minutes) and Enable AJAX Loading settings are created.
- For display data in front-end i have created a short-code and REST API Endpoint.
- In a front-end non-expired promo blocks has been displayed with order by display priority.
- Shown limited promo blocks based on settings. Shown a no-image when feature image has not selected.
- Implemented a transiant cache mecanisam.
- Loaded CSS and JS only on those page when short-code will available.
- Applied a lazy loading to images.
- From setting page is admin has unchecked a 'Enable Promo Blocks' setting then short-code and REST API will be disable.
Sample Shortcode Usage
- Basic (default settings):
[dynamic_promo]
- Limit promos to 3:
[dynamic_promo limit="3"]
- Use AJAX loading (placeholder + client fetch):
[dynamic_promo ajax="true"]
Notes:
- If
ajaxis not passed, the plugin will use theenable_ajaxsetting. - When a promo has no featured image, the shortcode uses
public/images/no-image.jpgas a fallback.
Clearing Cache Manually
- Clear transients via the promo blocks post save and plugin settings page (settings updates will flush cache automatically).