Skip to content

Code. Add get params to bot detector wrapper#50

Open
alexander-b-clean wants to merge 2 commits into
devfrom
add-get-to-url.ab
Open

Code. Add get params to bot detector wrapper#50
alexander-b-clean wants to merge 2 commits into
devfrom
add-get-to-url.ab

Conversation

@alexander-b-clean
Copy link
Copy Markdown
Contributor

Comment thread lib/CleantalkAntispam.php Outdated
public static function getFrontendHTMLCode($warn_if_js_disabled = false)
{
$warn = $warn_if_js_disabled ? '<noscript><div>Please, enable JavaScript in the browser to process the form</div></noscript>' : '';
$url = static::BOT_DETECTOR_LIBRARY_URL . '?ver=' . gmdate('Ymd');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gmdate('Ymd');

This will drop the browser cache, you can use constant APBCT_VERSION instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixid

Copy link
Copy Markdown
Member

@Glomberg Glomberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread lib/CleantalkAntispam.php Outdated
public static function getFrontendHTMLCode($warn_if_js_disabled = false)
{
$warn = $warn_if_js_disabled ? '<noscript><div>Please, enable JavaScript in the browser to process the form</div></noscript>' : '';
$url = static::BOT_DETECTOR_LIBRARY_URL . '?ver=' . gmdate('Ymd');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the remark

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixid

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a manually maintained library version and appends it as a query parameter to the bot detector wrapper URL for frontend cache/version tracking.

Changes:

  • Introduces APBCT_VERSION in the package entrypoint.
  • Uses that version in getFrontendHTMLCode() when building the bot detector script URL.
  • Documents the manual version bump process in the README.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
README.md Documents where the library version is defined and how it is updated.
cleantalk-antispam.php Adds the APBCT_VERSION constant.
lib/CleantalkAntispam.php Appends the version query parameter to the bot detector script URL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/CleantalkAntispam.php
public static function getFrontendHTMLCode($warn_if_js_disabled = false)
{
$warn = $warn_if_js_disabled ? '<noscript><div>Please, enable JavaScript in the browser to process the form</div></noscript>' : '';
$version = defined('APBCT_VERSION') ? \APBCT_VERSION : '1.0';
Comment thread cleantalk-antispam.php
@@ -1,5 +1,7 @@
<?php

const APBCT_VERSION = '4.4';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants