namespace ZeroSpam\Modules;
// Security Note: Blocks direct access to the plugin PHP files.
defined( 'ABSPATH' ) || die();
public function __construct() {
add_action( 'init', array( $this, 'init' ), -1 );
* Fires after WordPress has finished loading but before any headers are sent.
add_filter( 'zerospam_setting_sections', array( $this, 'sections' ) );
add_filter( 'zerospam_settings', array( $this, 'settings' ), 10, 1 );
add_filter( 'zerospam_get_ip', array( $this, 'debug_ip' ), 10, 1 );
* Updates the visitor IP to the debug IP
* @param string $ip IP address.
public function debug_ip( $ip ) {
$debug_ip = \ZeroSpam\Core\Settings::get_settings( 'debug_ip' );
'enabled' === \ZeroSpam\Core\Settings::get_settings( 'debug' ) &&
* @param array $sections Array of admin setting sections.
public function sections( $sections ) {
$sections['debug'] = array(
'title' => __( 'Debug', 'zero-spam' ),
'icon' => 'assets/img/icon-bug.svg',
* @param array $settings Array of available settings.
public function settings( $settings ) {
$options = get_option( 'zero-spam-debug' );
$settings['debug'] = array(
'title' => __( 'Debug', 'zero-spam' ),
'desc' => __( 'When enabled, provides verbose logging & allows the site admin to test an IP address access.', 'zero-spam' ),
'value' => ! empty( $options['debug'] ) ? $options['debug'] : false,
$settings['debug_ip'] = array(
'title' => __( 'Debug IP', 'zero-spam' ),
/* translators: %s: url */
__( 'Mock an IP address for debugging. This overrides all visitor IP addresses and <strong>while enabled could block legit visitors from accessing the site</strong>.', 'zero-spam' ),
'placeholder' => '127.0.0.1',
'value' => ! empty( $options['debug_ip'] ) ? $options['debug_ip'] : false,