WP Manifestindependent plugin directory
manifest / content / wp-content-manager

WP Content Manager Hemant Patel

This plugin provides a lightweight Promo Blocks manager (custom post type, meta boxes, shortcode, AJAX loading, REST API and a simple caching layer).

★ 0stars

Install

Download source zip No release zip yet

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.zip
No 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:
    1. Copy the wp-content-manager folder into wp-content/plugins/.
    2. Activate the plugin from the WordPress admin > Plugins screen.
    3. Visit the plugin settings "Dynamic Content" under the settings menu to configure Max promos, Enable Promo Blocks, Cache TTL and Enable AJAX.
  • Optional: ensure the folder public/images contains no-image.jpg for 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 the promo_blocks custom 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_cache keep 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_Query uses posts_per_page + ordering by _dcm_display_priority to 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 ajax is not passed, the plugin will use the enable_ajax setting.
  • When a promo has no featured image, the shortcode uses public/images/no-image.jpg as a fallback.

Clearing Cache Manually

  • Clear transients via the promo blocks post save and plugin settings page (settings updates will flush cache automatically).

Short Video For Better understanding