Skip to content

Instantly share code, notes, and snippets.

@paulgoodchild
Created August 9, 2023 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulgoodchild/47b805de8b1ed42dac6da3e2bdd37f25 to your computer and use it in GitHub Desktop.
Save paulgoodchild/47b805de8b1ed42dac6da3e2bdd37f25 to your computer and use it in GitHub Desktop.
Triggering on-demand scans on Shield Security Pro for WordPress
<?php declare( strict_types=1 );
use FernleafSystems\Wordpress\Plugin\Shield\Modules\HackGuard\Scan\Controller;
/**
* Launching on-demand scans for Shield Security can be done using the function outlined below.
* It requires a single array parameter that contains the so-called "slugs" of the respective scans.
*
* Shield currently has 3 distinct scan types, namely:
* - AFS: file scanner, (WordPress, plugin, themes, malware scan)
* - APC: abandoned plugin scanner,
* - WPV: vulnerability scanner
*
* They are each uniquely identified throughout the system by their SCAN_SLUG property. These slugs are what
* is needed to be passed to the function. There is no need to pass them all, just pass the ones you need.
*
* Use of this function requires an active ShieldPRO Plus+ license or higher.
*
* You can call this function at any time after the 'plugins_loaded' hook has been triggered, to ensure that
* the Shield plugin has been initialised. If you know you might be calling it early, use `function_exists()`
* to determine whether it's available, to avoid errors.
*
* The example below triggers an on-demand scan for all 3 scan type. Again, supply only the scan types you need.
*
* @since 18.2.7
*/
// ... my custom code
if ( \function_exists( 'shield_start_scans' ) ) {
shield_start_scans( [
Controller\Afs::SCAN_SLUG, // Shield's file scanner
Controller\Apc::SCAN_SLUG, // Shield's abandoned plugin scanner
Controller\Wpv::SCAN_SLUG, // Shield's vulnerability scanner
] );
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment