For developers

For developersVersion 1.0.0Last updated:

Files

  • includes/modules/class-builder-os-svg-antispam.php (Builder_OS_SVG_Antispam): module registered in Builder_OS::MODULES.
  • includes/modules/svg-antispam/class-builder-os-svg-sanitizer.php (Builder_OS_SVG_Sanitizer): sanitizer and dimension calculation.
  • includes/modules/svg-antispam/class-builder-os-svg.php (Builder_OS_SVG): upload, file type, metadata, image_downsize and library.
  • includes/modules/svg-antispam/class-builder-os-antispam.php (Builder_OS_Antispam): comments, accounts and turning comments off.
  • includes/modules/svg-antispam/class-builder-os-antispam-admin.php (Builder_OS_Antispam_Admin): the Security sections (formerly Settings cards), admin-post actions and the Comments column. Builder_OS_Admin::MOVED_TABS and redirect_moved_tabs() (admin_init) redirect the old URLs.
  • No JavaScript of its own: the honeypot field (Builder_OS_Antispam::HONEYPOT, bos_as_hp) and the signed token (TOKEN, bos_as_rt) go in the HTML of class-builder-os-antispam.php. The Cloudflare script is loaded only with Turnstile configured.
  • admin/css/builder-os-svg-antispam.css: SVG thumbnails and sections.

Options

OptionContents
builder_os_svgenabled (bool) and roles (string[]).
builder_os_antispamenabled, comments, accounts, min_time, login_min_time, max_links, blocked_words, rate_limit, rate_window, turnstile_comments, turnstile_accounts and disable_comments.
builder_os_antispam_statstotals (comments, held, register, login, lostpassword), reasons, days (Y-m-d → blocks, 31 days) and log (last 20).
Transients bos_asrl_*Comment limit per IP.
Comment meta _bos_antispamReason: honeypot, time, token, links, words or filter.

Hooks

HookTypeUse
builder_os_svg_user_allowedfilter( bool $allowed, WP_User $user ): decides per user whether they can upload SVGs.
builder_os_svg_max_bytesfilterMaximum uncompressed SVG size (default, 10 MB).
builder_os_svg_rejectedaction( string $filename, WP_Error $error ): an SVG rejected on upload.
builder_os_antispam_comment_statusfilter( string $status, array $reasons, array $commentdata ): '', 'spam' or 'held'.
builder_os_antispam_protect_loginfilterReturn false to skip the login check; for example, if a theme has its own form that submits to wp-login.php without login_form.
builder_os_antispam_blockedaction( $channel, $reason, $outcome ): each block or hold.
builder_os_forms_client_ipfilter(From Forms.) Real IP behind a proxy; also used by the comments’ per-IP limit.

Reuse from Forms: Builder_OS_Forms::time_token() and verify_time_token() (time token), Builder_OS_Forms_Submit::js_hash() (browser token), client_ip() and turnstile_ok(), which is now public, with the Turnstile keys from builder_os_forms_settings.

PHP API:

  • Builder_OS_SVG_Sanitizer::sanitize( $svg ) returns a string or a WP_Error.
  • Builder_OS_SVG_Sanitizer::dimensions( $svg ) returns [ancho, alto].
  • Builder_OS_Antispam::verify( $context, $min ) returns '', 'honeypot', 'time' or 'token'.
  • Builder_OS_Antispam::fields_html( $context ) returns the honeypot and the token, for custom forms.

Form fields: bos_as_hp (honeypot), bos_as_rt (server token), bos_as_tk and bos_as_js (browser token).

Nginx/Apache: nothing needs to be configured. SVGs are served sanitized as image/svg+xml.