Skip to content

Instantly share code, notes, and snippets.

@paulgoodchild
Created June 11, 2019 08:59
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/b60e483082ba183671a4d94a03c08c6c to your computer and use it in GitHub Desktop.
Save paulgoodchild/b60e483082ba183671a4d94a03c08c6c to your computer and use it in GitHub Desktop.
[Shield Security] Fire custom security offences. Use this to trigger an offence against an IP address for custom actions that you'd like to consider an offence.
<?php
/**
* Trigger Custom Shield Offense.
*
* Use a WP do_action() call to register a custom offense against an IP address.
* Supported in Shield Security 7.5+
*
* Parameters:
* 1) The action name that we use to register your custom offense. This never changes.
* 2) The custom message that you'd like to appear in the Shield audit trail.
* 3) The value by which to increment the total offenses for this IP address.
* - Default: 1
* 4) Boolean to indicate whether logged-in users should be included
* - Default: true (i.e. all users affected)
* - set to `false` to excluded logged-in users
*/
do_action( 'shield_security_offense', 'My Custom Shield Offense', 1, true );
/**
* - An example of creating your own custom shortcode that you can place in a particular page
* to register an offense.
*
* - We've provided some example defaults within the shortcode, but you can fully customize these.
*
* - Regardless of how you customize this shortcode example, you must always call
* do_action('shield_security_offense') with the parameters you'd like.
*
*/
add_shortcode( 'SHIELD_OFFENCE', 'trigger_shield_offense' );
function trigger_shield_offense( $aAtts ) {
$aAtts = shortcode_atts(
[
'message' => 'Custom Shield Offense',
'count' => 1,
'loggedin' => true,
],
$aAtts
);
do_action( 'shield_security_offense', $aAtts[ 'message' ], $aAtts[ 'count' ], $aAtts[ 'loggedin' ] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment