This WordPress plugin fetches regulation HTML from https://cloud.ntpusu.org and exposes it locally so editors can refresh the rendered markup with one click.
This repository is a standalone WordPress plugin, so the practical local setup is:
- Install a local WordPress environment with PHP, MySQL, and a web server. Good options are Local, Laragon, XAMPP, or a Docker-based WordPress stack.
- Use a PHP version that matches your WordPress site. WordPress current recommendations are typically PHP 8.x, but you should match production first.
- Place this repository under your WordPress plugins directory:
wp-content/plugins/ntpusu-regulation-sync - Activate the plugin in the WordPress admin.
- For development, edit the plugin files directly from this repo and refresh the WordPress site.
- If you want syntax checks, run:
php -l wp-content/plugins/ntpusu-regulation-sync/ntpusu-regulation-sync.php
php -l wp-content/plugins/ntpusu-regulation-sync/includes/helpers.php
php -l wp-content/plugins/ntpusu-regulation-sync/includes/sync-service.php
php -l wp-content/plugins/ntpusu-regulation-sync/includes/admin.php
php -l wp-content/plugins/ntpusu-regulation-sync/includes/shortcode.php- Visit Regulation Sync in the WordPress admin.
- Choose a source: Enter a regulation ID, pick one from the fetched regulation list, or paste a custom URL.
- Optionally select the WordPress page or post that should receive the synced content.
- Press Sync Now.
- If the source URL matches a regulation page or regulation API URL, the plugin calls the cloud API and stores the
fullTextpayload from the single-regulation endpoint. - Place
[ntpusu_regulation]anywhere on the front end. By default it uses the current post, or you can override it with[ntpusu_regulation post_id="123"].
The plugin now uses the documented regulation API from:
https://github.com/NTPU-Student-Headquarters/ntpush-cloud/blob/main/docs/api/regulation.md
Current endpoints:
https://cloud.ntpusu.org/api/regulation/listReturns[id, titleShort]pairs.https://cloud.ntpusu.org/api/regulation/single/{id}ReturnstitleFull,titleShort,modifiedType,modifiedDate,history, andfullText.
- The regulation list is loaded from the JSON API instead of scraping the front-end page.
- When the API returns
modifiedDate, the plugin uses it to update the mapped WordPress post's publish date. - The plugin sanitizes stored HTML with
wp_kses, but it still allows the tags needed for remote assets to load. - If the PHP DOM extension is unavailable, the plugin still stores remote markup, but it cannot trim the response to the
<body>content or rewrite relative asset URLs.