Black Friday: 79% off every plugin Shop the sale →

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#

ConstantPurpose
PUG_QUARANTINE_DIRAbsolute path of the quarantine folder. Overrides automatic detection.
PUG_STOREENGINE_PRODUCT_IDStore product ID used for licensing.
PUG_STOREENGINE_STORE_URLStore that answers license checks and serves updates.

Filters#

FilterArgumentsPurpose
pug_plugin_in_scopebool $in_scope, string $plugin, string $source, string $package_urlChange whether a plugin’s update is gated. $source is wporg, vendor or unlisted.
pug_rulesarray $rulesChange rule weights or definitions, or remove a rule. Keyed by rule ID.
pug_benign_hostsstring[] $hostsHosts that never trigger the remote-new-host rule. Subdomains match too.
pug_quarantine_base_dirstring $baseAbsolute path of the quarantine folder (applied after the constant).
pug_integrity_ignorestring[] $patternsRegular expressions for paths the integrity check ignores. Default: ~\.log$~i.
pug_webhook_payloadarray $payload, array[] $alertsThe JSON body sent to the webhook.
pug_storeengine_product_idint $product_idStore product ID used for licensing.
pug_storeengine_store_urlstring $urlStore URL for license checks and updates.
pug_storeengine_allow_localbool $allowAllow license activation on local and .test sites. Default true.
pug_store_dashboard_urlstring $urlLink to the customer’s license keys on the store.

Actions#

ActionArgumentsFires when
pug_update_heldint $review_id, array $review, array $findingsAn update is held for review.
pug_update_passedint $review_id, array $review, array $findingsAn update passes the gate (Clean or Review verdict).
pug_update_approvedint $review_id, array $review, int $trust_daysA held update is approved.
pug_update_rejectedint $review_id, array $reviewA held update is rejected.
pug_update_installedstring $plugin, int $review_id, string $package_hashAn inspected package was installed.
pug_gate_errorstring $plugin, Exception $e, string $modeThe gate failed. $mode is open or closed.
pug_alert_raisedint $alert_id, array $alertA 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.

Was this article helpful?