tporret API Data Importer

Description

tporret API Data Importer gives WordPress teams an enterprise-grade ETL pipeline for importing external API data with confidence.

The plugin ships readable source for its generated admin assets. JavaScript and CSS source files are included in the src/ directory, compiled assets are in build/, and the maintained public source repository is available at https://github.com/tporret/enterprise-api-importer.

This readme is written for WordPress administrators and site owners evaluating or using the plugin from the Plugins screen.

Use tporret API Data Importer to run clean, repeatable import workflows without sacrificing flexibility:

  • Multi-Connection Job Manager for organizing and scaling imports
  • React Tabbed Import Job Workspace (Source/Auth, Data Rules, Mapping/Templating, Automation)
  • Advanced JSON array traversal and pre-stage data filtering to remove noise before insertion
  • Twig Templating Engine for complex logic, loops, and nested object mapping without drag-and-drop limitations
  • Twig-powered Post Title Templates with safe sanitization and fallback handling
  • Optional templates for new jobs (start with connection setup, add templates later)
  • Multiple API auth modes: none, bearer token, custom API-key header, and basic auth
  • Per-import Target Post Type selection (posts, pages, and public custom post types)
  • Per-import Default Target Settings (post status, post author, comment status, pingback/trackback status)
  • Per-import editing lock toggle for imported posts (allow editing or enforce read-only)
  • Time-aware batch processing via WP-Cron to reduce timeout and memory-risk scenarios
  • Multisite support with per-site importer dashboards and an optional Network Admin summary dashboard when the plugin is also active on the primary site
  • [New v1.3] Deep Module Architecture (internal):
    • Tporapdi_Validator — single validation seam for all import job fields
    • Tporapdi_Import_Runner — owns the 5-stage import lifecycle (Extract Filter Stage Transform Load)
    • Tporapdi_Template_Engine — unified Twig rendering seam for all template fields and dry-run previews
    • Tporapdi_Security_Guard — centralised SSRF, CIDR, and Twig security checks shared across save and run paths
    • Tporapdi_Job_Repository, Tporapdi_Queue_Repository, Tporapdi_Log_Repository — domain repositories hiding all SQL and cache management
    • Tporapdi_Media_Ingestor — isolated image sideload and HTML rewrite logic with idempotent deduplication
    • Tporapdi_Cleanup_Service — chunked garbage collection for staging queue and log tables
    • Reporter self-registration via glob discovery — adding a new dashboard metric requires zero edits to existing files
    • Tporapdi_Lock_Policy — single edit-lock policy seam used by all admin UI affordances
    • TPORAPDI_Defaults_Resolver::normalize() — single normalization seam for post status defaults shared by REST save and import runtime
  • [New v1.2] Tableau-Style Reporting Dashboard: Real-time metrics on environment health, security posture, and API performance with interactive charts, status indicators, and audit activity feed
  • [New] Credential Encryption & REST Masking:
    • AES-256-CBC encryption at rest for auth_token and auth_password fields
    • REST GET responses mask credentials; boolean flags indicate stored state
    • Blank credential fields on update preserve existing encrypted values
    • React UI shows saved-credential indicators with placeholder text
    • apply_filters no longer exposes raw tokens to third-party hooks
  • [New] Import Pipeline Sanitization:
    • Twig-rendered post content sanitized via wp_kses_post before wp_insert_post
    • Custom meta values sanitized via sanitize_text_field before update_post_meta
    • Admin menu pages restricted to manage_options capability (was read)
  • [New] Enterprise-Grade Security Hardening:
    • Dedicated template management capability with multisite support
    • Twig template security validation (disallowed tags, size/complexity limits, syntax checking)
    • Template change audit logging with before/after hashes and actor metadata
    • SSRF prevention via hostname and CIDR allowlisting with DNS resolution
    • Twig variable strictness is filterable, with permissive rendering used by default for resilient imports
    • Imported items locked read-only (no editing, deletion, or quick-edit)

Whether you import catalogs, directory records, listings, events, or custom business data, tporret API Data Importer provides a scalable framework for structured API-to-WordPress ETL.

Built for real-world production workflows:

  • Title templates are rendered via Twig and sanitized before save
  • Target post type safely falls back to post if invalid or unavailable
  • Attachment is excluded by default from target post type selection
  • Default target post settings are validated and applied at load time for consistent publishing/discussion behavior
  • Imports are staged and processed in queue batches for safer long-running jobs
  • Imported items are cryptographically linked to their origin import (read-only)
  • Template configuration changes are audit-logged with full actor context
  • Endpoints validated against configurable SSRF allowlists and HTTPS enforcement
  • Inline API connection testing, sample payload preview, and template dry-run rendering from the edit workspace

Development

To rebuild generated admin assets from source:

  1. Install Node.js dependencies: npm install
  2. Build production assets: npm run build (uses @wordpress/scripts / webpack)
  3. For a watch/dev build: npm start
  • JavaScript/CSS source lives in src/
  • Production assets are generated into build/
  • The public source repository is https://github.com/tporret/enterprise-api-importer

External services

This plugin connects to external APIs that you configure in each import job.

The plugin does not hardcode any third-party API vendor. Data destination, terms, and privacy practices depend on the endpoint(s) you configure.

Screenshots

  • The Twig Mapping Interface for transforming JSON data.
  • API Connection and Data Filtering rules.

Installation

  1. Upload the plugin folder to the /wp-content/plugins/ directory, or install it through the WordPress Plugins screen.
  2. Activate the plugin through the Plugins screen in WordPress.
  3. Go to tporret API Data Importer Manage Imports to configure your API connections, filtering rules, target post type, and Twig templates.

Multisite note: activate the plugin on each subsite that should run imports. If you also want the Network Admin summary dashboard, activate it on the primary site too. Do not use Network Activate; that mode is intentionally not supported.

FAQ

Does this require WP-CLI?

No. It uses native WP-Cron scheduling, but supports CLI triggers.

Can I parse nested JSON arrays?

Yes. Nested objects and arrays can be parsed and transformed through Twig templating.

Does it handle API authentication?

Yes. It supports four modes per import job: none, bearer token, custom API-key header, and basic auth.

Can I set dynamic titles for imported posts?

Yes. Use Post Title Template with Twig syntax. If left blank, the importer falls back to Imported Item {ID}.

Can I import into custom post types?

Yes. Select any public post type from Target Post Type. If the selected post type becomes unavailable, imports safely fall back to post.

How does this work on multisite?

Each subsite keeps its own import jobs, schedules, settings, and dashboard. A separate Network Admin dashboard can summarize active subsites when the plugin is also active on the primary site. Activate the plugin per site; Network Activate is intentionally blocked.

Does this import media attachments automatically from URL fields?

The plugin includes a secure media sideload helper foundation with source URL deduplication. Full field-level media mapping workflows can be added on top of this helper.

Who can edit imported items and templates?

Template configuration requires the tporapdi_manage_templates capability or manage_options role. Multisite super admins always have access. Imported item editing can now be controlled per import job with the “Lock editing of imported posts” setting.

What Twig features are blocked for security?

The following Twig tags are disallowed to prevent file inclusion and code injection: include, source, import, from, embed, extends, use, macro.

Can I allow imports from internal/private networks?

Yes, but not recommended for production. Go to Settings Allow Internal Endpoints to permit RFC1918 and loopback addresses. For whitelisting specific hosts/CIDR blocks, use Settings Allowed Endpoint Hosts and Settings Allowed Endpoint CIDR Blocks.

Why does the dashboard show a security warning on a new install?

The SSRF Hardening check starts in a warning state until you configure Allowed Endpoint Hosts or Allowed Endpoint CIDR Blocks. That warning is there to remind you that outbound API access is still open until you add an allowlist.

What should I configure in tporret API Data Importer Settings first?

Start with Allowed Endpoint Hosts and list only trusted API domains. Leave Allow Internal Endpoints disabled unless you intentionally import from internal services. Add CIDR blocks only when you need additional IP-range restrictions.

Where are template changes logged?

All template configuration changes are logged to the wp_custom_import_logs database table with before/after hashes, actor information, and precise timestamps. Review logs via tporret API Data Importer Manage Imports Import edit screen.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“tporret API Data Importer” adalah perisian sumber terbuka. Orang-orang berikut telah menyumbang kepada pemalam ini.

Penyumbang

Changelog

1.3.0

  • Architectural deepening release — no breaking changes to existing import jobs, REST API, or admin UI.
  • Extracted Tporapdi_Validator module: single entry point for all import job field validation (auth, recurrence, templates, post defaults, meta mappings) replacing scattered inline checks in rest.php.
  • Extracted Tporapdi_Import_Runner module: owns the full 5-stage import lifecycle (Extract, Filter, Stage, Transform, Load) with state transitions and failure semantics in one place.
  • Extracted Tporapdi_Template_Engine module: single render() seam used by both live import runs and dry-run previews, guaranteeing identical Twig security and output behaviour across all template fields.
  • Extracted Tporapdi_Security_Guard module: centralises SSRF, CIDR, and Twig security validation — same rules enforced at save time and run time.
  • Extracted three domain repositories (Tporapdi_Job_Repository, Tporapdi_Queue_Repository, Tporapdi_Log_Repository): all SQL and cache management moved out of db.php, which is now a thin backwards-compatible shim layer.
  • Extracted Tporapdi_Media_Ingestor module: image sideload, deduplication, and HTML content rewriting isolated from lifecycle cleanup.
  • Extracted Tporapdi_Cleanup_Service module: chunked garbage collection for staging queue and log tables, independent of media handling.
  • Reporting Discovery Engine: reporters now self-register via TPORAPDI_Reporting_Aggregator::register(); reporting.php uses glob-based auto-discovery so new reporters require no edits to existing files.
  • Extracted Tporapdi_Lock_Policy module: single is_locked(int $post_id) seam for all import-managed post edit-locking; all content.php hook callbacks route through this one policy.
  • Deepened TPORAPDI_Defaults_Resolver: new normalize(string $post_type, array $raw_input) static method is the single seam for post status/comment status/ping status normalization — used identically by the REST save path and the import runtime.
  • Updated the public plugin name to tporret API Data Importer for WordPress.org resubmission.

1.2.4

  • Aligned Twig dry-run template normalization with save-time normalization so preview output matches persisted output.

1.2.3

  • Added multisite Network Admin dashboard support while preserving per-site importer dashboards.
  • Added multisite activation safeguards so unsupported Network Activate attempts are blocked and reverted.
  • Added multisite admin guidance for primary-site activation requirements and network dashboard availability.
  • Softened the SSRF Hardening reporter so fresh installs show a warning until an endpoint allowlist is configured.
  • Tightened and de-duplicated release packaging workflows.

1.2.2

  • Security hardening release.
  • Encrypted credential storage at rest for auth_token and auth_password.
  • REST import-job GET now masks credentials and returns has_auth_token / has_auth_password flags.
  • Update handlers preserve existing encrypted credentials when masked fields are submitted blank.
  • Removed raw token exposure from tporapdi_remote_request_args filter context.
  • Added post-content sanitization with wp_kses_post before post insert/update.
  • Added custom-meta sanitization with sanitize_text_field before update_post_meta.
  • Tightened admin menu capability from read to manage_options.

1.2.1

  • Maintenance release from cleaned git history.
  • Removed accidentally committed documentation/test-data directories from repository history and release packaging.
  • No runtime feature changes.

1.2.0

  • Updated: React Import Job Workspace
    • Replaced the legacy linear create/edit form with a tabbed workspace in wp-admin.
    • Added sticky footer actions for save, run now, and update existing item content.
  • Updated: REST Import Job CRUD + actions
    • Added REST routes for create/read/update import jobs and run/template sync actions.
    • Added centralized sanitization for import job payloads used by create/update handlers.
  • Updated: API validation and preview tooling
    • Added in-workspace API test button with sample record preview support.
    • Added Twig dry-run test support from the Mapping & Templating tab.
  • Updated: Authentication model
    • Added four auth methods per import job: none, bearer, custom API-key header, and basic auth.
  • Updated: Optional templates for new imports
    • New imports can be created without title or mapping templates; templates can be added later.
  • Updated: Per-import editing lock control
    • Added “Lock editing of imported posts” toggle in Mapping & Templating.
    • Edit/delete restrictions now apply by import configuration and can be disabled per job.
  • Updated: Default target post settings
    • Added per-import defaults for Post Status, Post Author, Comment Status, and Pingback/Trackback Status in Mapping & Templating.
    • Added REST sanitization and persistence for these fields in import job create/update handlers.
    • Import load now applies these defaults during wp_insert_post() and sync updates discussion settings during wp_update_post().
  • New: Enterprise Reporting Dashboard (Tableau-Style)
    • Real-time operations command center with global health status badge and force-refresh controls.
    • Nine enterprise-grade metrics across three pillars:
    • Environment Health: Cron heartbeat, queue depth, daily success rate.
    • Security & Compliance: SSRF hardening status, audit integrity tracking, protocol enforcement (HTTPS vs HTTP).
    • Connectivity & Performance: API latency trends, active endpoint count, hourly throughput.
    • High-performance React UI with Recharts data visualization and Lucide icons.
    • Responsive grid layout with KPI stat cards (sparkline trends), status lists, donut charts, area charts, and system pulse marquee.
    • REST API endpoints: /wp-json/eapi/v1/dashboard (metrics) and /wp-json/eapi/v1/dashboard/history (time-series data).
    • Transient-backed caching (600s TTL) with force-refresh capability.
    • Shimmer loading states and dark/light theme-aware styling via Tailwind CSS (namespaced to avoid wp-admin conflicts).
    • Menu: EAPI Dashboard (requires read capability).
  • Credential Encryption & Data Sanitization
    • Credential fields (auth_token, auth_password) are now encrypted at rest with AES-256-CBC using a key derived from wp_salt(‘auth’).
    • REST GET responses mask credential values and expose boolean has_auth_token / has_auth_password flags.
    • Credential preservation on update: blank credential fields retain existing encrypted values.
    • React auth fields show “Credential saved” indicators with placeholder text for stored credentials.
    • apply_filters(‘tporapdi_remote_request_args’) no longer passes raw token — passes auth_method instead.
    • Twig-rendered post content now passes through wp_kses_post() before wp_insert_post() (stored XSS prevention).
    • Twig-compiled custom meta values now pass through sanitize_text_field() before update_post_meta().
    • Admin menu pages capability changed from ‘read’ to ‘manage_options’ (subscriber access blocked).
  • Enhanced Security Hardening (Enterprise-Grade)
    • Added dedicated tporapdi_manage_templates capability for template configuration access (separate from manage_options).
    • Implemented multisite-aware permission system: tporapdi_manage_templates OR manage_options OR is_super_admin().
    • Locked imported items as read-only (no editing, deletion, or quick-edit permissions via map_meta_cap).
    • Added comprehensive Twig template security validator:
    • Disallowed tags: include, source, import, from, embed, extends, use, macro (prevents SSTI and file inclusion).
    • Size limits: 50 KB for mapping templates, 2 KB for title templates (filterable).
    • Expression count limit: 250 default (filterable).
    • Nesting depth limit: 12 levels default (filterable).
    • Parse-time syntax validation via Twig tokenizer.
    • Added template change audit logging:
    • Logs to wp_custom_import_logs with before/after SHA256 hashes.
    • Captures actor metadata (user login, role, display name).
    • Tracks template lengths and create vs. update distinction.
    • Implemented SSRF prevention via allowlist system:
    • Hostname allowlisting (exact + wildcard *.example.com support).
    • CIDR allowlisting (IPv4 and IPv6 support).
    • DNS resolution for hostname validation.
    • Settings UI for managing allowed hosts and CIDR blocks.
    • Twig variable strictness is filterable; permissive rendering now avoids row failures when a template references a missing key.
    • Added Settings page (EAPI Settings) for endpoint security configuration.

1.0.0

  • Initial Release.
  • Added dynamic Twig Post Title Template support with sanitization and fallback logic.
  • Added Target Post Type selector for loading imports into posts, pages, or public custom post types.
  • Added runtime fallback to post when target post type is invalid or missing.
  • Added secure media sideload helper foundation with source URL deduplication metadata.