Plugin Directory

Changeset 3128164


Ignore:
Timestamp:
07/30/2024 01:11:43 PM (20 months ago)
Author:
Wigster
Message:

0.76 - confirmed compatibility with new WC HPOS

Location:
block-specific-spam-woo-orders
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • block-specific-spam-woo-orders/trunk/readme.txt

    r3090692 r3128164  
    1 === Block Specific Spam Woo Orders ===
     1=== Plugin Name ===
    22Contributors: wigster
    3 Tags: woocommerce,woo,block,spam,orders
     3Tags: woocommerce, woo, block, spam, orders
    44Requires at least: 5.1
    5 Tested up to: 6.5.2
     5Tested up to: 6.6.1
    66Requires PHP: 5.4
    7 Stable tag: 0.75
     7Stable tag: 0.76
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1414
    1515This plugin prevents a specific set of WooCommerce fake/spam orders.
    16 Simply install and activate the plugin, there are no settings or tweaks to be made.
     16Simply install and activate the plugin; there are no settings or tweaks to be made.
    1717The plugin extends WooCommerce's built-in checkout validations to check for a specific set of known spam email accounts and names. If triggered, the spam bot simply cannot checkout and importantly does not get to the account creation stage.
    18 The names/emails it checks for are only used by spam bots, so there is no need to worry about false positives.
    19 
    20 If you've found this plugin useful, you can support my work by buying me a coffee at:
    21 [Buy Me a Coffee](https://buymeacoffee.com/alexwigmore).
     18The names/emails it checks for would only be used by spam bots, so there is no need to worry about false positives.
    2219
    2320== Frequently Asked Questions ==
     
    2825== Changelog ==
    2926
     27= 0.76 =
     28* Tested compatibility with WP 6.6.1 and WC 9+
     29* Added confirmation that this plugin is compliant with the new WooCommerce HPOS (High-Performance Order Storage) / Custom Order Tables (COT) systems.
     30
    3031= 0.75 =
    31 * Tested Compatibility with WP 6.5.2 + WC
     32* Tested compatibility with WP 6.5.2 and WC
    3233
    3334= 0.7 =
    34 * Update logic slightly to simplify checks. Names are now also array-based if people wanted to manually extend.
    35 * Added ability to translate/localize the Spam Validation message with typical language translators (WPML etc).
    36 * Confirming support with WP 6.4 and Latest WooCommerce
     35* Updated logic slightly to simplify checks. Names are now also array-based if people want to manually extend.
     36* Added ability to translate/localize the Spam Validation message with typical language translators (WPML, etc.).
     37* Confirmed support with WP 6.4 and the latest WooCommerce
    3738
    3839= 0.6 =
    3940* Added a new function to handle checking against multiple blocked domains, now including ["@fakemail"]
    40 * Confirming support with WP 6.1 and Latest WooCommerce
     41* Confirmed support with WP 6.1 and the latest WooCommerce
    4142
    4243= 0.55 =
    43 * Tested support with WP 6.0 and latest WC - works fine.
     44* Tested support with WP 6.0 and the latest WC - works fine.
    4445
    4546= 0.54 =
    46 * Updating supported versions for WP and WooCommerce
     47* Updated supported versions for WP and WooCommerce
    4748
    4849= 0.53 =
    49 * Adding support for readme.txt changelogs.
     50* Added support for readme.txt changelogs.
    5051
    5152= 0.52 =
    52 * Updating support for WooCommerce - no code changes, minor updates to comment wording.
     53* Updated support for WooCommerce - no code changes, minor updates to comment wording.
    5354
    5455= 0.51 =
  • block-specific-spam-woo-orders/trunk/woo-block-spam-orders.php

    r3081329 r3128164  
    66* Description: A quick plugin to block on-going issues with spam WooCommerce orders November 2020
    77* Author: guwii
    8 * Version: 0.75
     8* Version: 0.76
    99* Author URI: https://guwii.com
    1010* License: GPL3+
    1111* Text Domain: guwii-woo-block-spam-orders
    1212* WC requires at least: 4.3
    13 * WC tested up to: 8.8.3
     13* WC tested up to: 9.1.4
    1414*/
    1515
    1616// Only use this plugin if WooCommerce is active
    1717if (in_array('woocommerce/woocommerce.php', get_option('active_plugins'))) {
    18   // Add our custom checks to the built in WooCommerce checkout validation:
     18
     19  // Add our custom checks to the built-in WooCommerce checkout validation:
    1920  add_action('woocommerce_after_checkout_validation', 'action_woocommerce_validate_spam_checkout', 10, 2);
    2021
     
    3435    $is_a_spam_order = false;
    3536
    36     // Compare users email domain with our list of blocked email domains:
     37    // Compare user's email domain with our list of blocked email domains:
    3738    foreach ($blocked_email_domains as $blocked_email_domain) {
    38       // If a blocked email domain exists in the users billing email, return spam=true;
     39      // If a blocked email domain exists in the user's billing email, return spam=true;
    3940      if (strpos($billing_email, $blocked_email_domain) !== false) {
    4041        $is_a_spam_order = true;
     42        break; // No need to check further if one match is found
    4143      }
    4244    }
    43     foreach ($blocked_names as $blocked_name) {
    44       // If a blocked Name exists in the users billing first name, return spam=true;
    45       if (strpos($billing_first_name, $blocked_name) !== false) {
    46         $is_a_spam_order = true;
     45
     46    // If not spam by email, check names
     47    if (!$is_a_spam_order) {
     48      foreach ($blocked_names as $blocked_name) {
     49        // If a blocked Name exists in the user's billing first name, return spam=true;
     50        if (strpos($billing_first_name, $blocked_name) !== false) {
     51          $is_a_spam_order = true;
     52          break; // No need to check further if one match is found
     53        }
    4754      }
    4855    }
     56
    4957    return $is_a_spam_order;
    5058  }
    51   // Run the customers name & billing email through our func, report "Spam" if true:
     59
     60  // Run the customer's name & billing email through our func, report "Spam" if true:
    5261  function action_woocommerce_validate_spam_checkout($fields, $errors)
    5362  {
    54     if ((bssorders_is_a_spam_order($fields) == true)) {
     63    if (bssorders_is_a_spam_order($fields)) {
    5564      $errors->add('validation', __('Spam.', 'guwii-woo-block-spam-orders'));
    5665    }
    5766  }
     67
     68  // Optional: Indicate HPOS compatibility
     69  add_action('before_woocommerce_init', function () {
     70    if (class_exists('\Automattic\WooCommerce\Utilities\FeaturesUtil')) {
     71      \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
     72    }
     73  });
    5874}
Note: See TracChangeset for help on using the changeset viewer.