Hooks & Filters
Premium Update Gate has no shortcodes or front-end output. Everything below is for wp-config.php, a must-use plugin or your own plugin.
Constants#
| Constant | Purpose |
|---|---|
PUG_QUARANTINE_DIR | Absolute path of the quarantine folder. Overrides automatic detection. |
PUG_STOREENGINE_PRODUCT_ID | Store product ID used for licensing. |
PUG_STOREENGINE_STORE_URL | Store that answers license checks and serves updates. |
Filters#
| Filter | Arguments | Purpose |
|---|---|---|
pug_plugin_in_scope | bool $in_scope, string $plugin, string $source, string $package_url | Change whether a plugin’s update is gated. $source is wporg, vendor or unlisted. |
pug_rules | array $rules | Change rule weights or definitions, or remove a rule. Keyed by rule ID. |
pug_benign_hosts | string[] $hosts | Hosts that never trigger the remote-new-host rule. Subdomains match too. |
pug_quarantine_base_dir | string $base | Absolute path of the quarantine folder (applied after the constant). |
pug_integrity_ignore | string[] $patterns | Regular expressions for paths the integrity check ignores. Default: ~\.log$~i. |
pug_webhook_payload | array $payload, array[] $alerts | The JSON body sent to the webhook. |
pug_storeengine_product_id | int $product_id | Store product ID used for licensing. |
pug_storeengine_store_url | string $url | Store URL for license checks and updates. |
pug_storeengine_allow_local | bool $allow | Allow license activation on local and .test sites. Default true. |
pug_store_dashboard_url | string $url | Link to the customer’s license keys on the store. |
Actions#
| Action | Arguments | Fires when |
|---|---|---|
pug_update_held | int $review_id, array $review, array $findings | An update is held for review. |
pug_update_passed | int $review_id, array $review, array $findings | An update passes the gate (Clean or Review verdict). |
pug_update_approved | int $review_id, array $review, int $trust_days | A held update is approved. |
pug_update_rejected | int $review_id, array $review | A held update is rejected. |
pug_update_installed | string $plugin, int $review_id, string $package_hash | An inspected package was installed. |
pug_gate_error | string $plugin, Exception $e, string $mode | The gate failed. $mode is open or closed. |
pug_alert_raised | int $alert_id, array $alert | A new alert is opened. |
Examples#
Never gate a plugin you build and deploy yourself:
add_filter( 'pug_plugin_in_scope', function ( $in_scope, $plugin, $source, $package_url ) {
if ( 'my-agency-tools/my-agency-tools.php' === $plugin ) {
return false;
}
return $in_scope;
}, 10, 4 );
Raise the weight of the remote-new-host rule so a new host alone holds the update:
add_filter( 'pug_rules', function ( $rules ) {
if ( isset( $rules['remote-new-host'] ) ) {
$rules['remote-new-host']['weight'] = 50;
}
return $rules;
} );
Stop your own API host from counting as a “new remote host”:
add_filter( 'pug_benign_hosts', function ( $hosts ) {
$hosts[] = 'api.example-vendor.com';
return $hosts;
} );
Ignore cache files in the integrity check:
add_filter( 'pug_integrity_ignore', function ( $patterns ) {
$patterns[] = '~/cache/~';
return $patterns;
} );
Send a Microsoft Teams-style payload instead of the Slack default:
add_filter( 'pug_webhook_payload', function ( $payload, $alerts ) {
return array(
'title' => 'Premium Update Gate',
'text' => $payload['text'],
'count' => count( $alerts ),
);
}, 10, 2 );
Log every held update to your own system:
add_action( 'pug_update_held', function ( $review_id, $review, $findings ) {
error_log( sprintf(
'PUG held %s %s (score %d, %d findings)',
$review['plugin'],
$review['new_version'],
$review['score'],
count( $findings )
) );
}, 10, 3 );
Data storage#
The plugin stores its data in custom tables created with dbDelta, network-wide on multisite: pug_reviews, pug_findings, pug_files, pug_alerts and pug_baselines. Settings, scope overrides and vendor trust are small non-autoloaded site options (pug_settings, pug_scope_overrides, pug_trusted). The daily cron event is pug_daily_scan. uninstall.php removes the tables, options, the cron event and the quarantine folders.
