Plugin Directory

Changeset 3335533


Ignore:
Timestamp:
07/28/2025 06:27:19 PM (5 months ago)
Author:
checkview
Message:

Update to version 2.0.20 from GitHub

Location:
checkview
Files:
6 deleted
18 edited
1 copied

Legend:

Unmodified
Added
Removed
  • checkview/tags/2.0.20/README.txt

    r3323842 r3335533  
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
    10 Stable tag: 2.0.19
     10Stable tag: 2.0.20
    1111
    1212[CheckView](https://checkview.io/) is the friendly WordPress automated testing platform for everyone, from developers, shop owners to agencies. 
     
    8686
    8787== Changelog ==
     88= 2.0.20 =
     89* Only run testing code for requests with newly required cookie.
     90* Only run relevant test code for the specified test type in the newly required cookie.
     91* Add check for WS Forms before attempting to run code.
     92* Better handle page ID retrieval.
     93* Extract all code from I18n class into a single function.
     94* Extract all code from Public class into a single function.
     95* Make helper methods of Woo class static.
     96* Improve logging.
     97
    8898= 2.0.19 =
    89 * Improve logging
    90 * Add hooks for disabling WP Forms CAPTCHAs/Turnstiles for tests
    91 * Disable test-related hooks on API requests
    92 * Disable Fluent Forms token-based spam prevention for tests
    93 * Remove Fluent Forms CAPTCHA/Turnstile key swap
    94 * Disable Fluent Forms CAPTCHAs using newly provided hook
     99* Improve logging.
     100* Add hooks for disabling WP Forms CAPTCHAs/Turnstiles for tests.
     101* Disable test-related hooks on API requests.
     102* Disable Fluent Forms token-based spam prevention for tests.
     103* Remove Fluent Forms CAPTCHA/Turnstile key swap.
     104* Disable Fluent Forms CAPTCHAs using newly provided hook.
    95105
    96106= 2.0.18 =
     
    368378
    369379== Upgrade Notice ==
     380= 2.0.20 =
     381* Only run testing code for requests with newly required cookie.
     382* Only run relevant test code for the specified test type in the newly required cookie.
     383* Add check for WS Forms before attempting to run code.
     384* Better handle page ID retrieval.
     385* Extract all code from I18n class into a single function.
     386* Extract all code from Public class into a single function.
     387* Make helper methods of Woo class static.
     388* Improve logging.
     389
    370390= 2.0.19 =
    371391* Improve logging
  • checkview/tags/2.0.20/admin/class-checkview-admin.php

    r3323842 r3335533  
    204204     * Initializes a test.
    205205     *
     206     * Should only be called if the request is a verified CheckView bot.
     207     *
    206208     * @return void
    207209     */
     
    217219        }
    218220
    219         // Current Visitor IP.
    220221        $visitor_ip = checkview_get_visitor_ip();
    221         // Check view Bot IP.
    222         $cv_bot_ip = checkview_get_api_ip();
    223 
    224         // Skip if visitor ip not equal to CV Bot IP.
    225         if ( is_array( $cv_bot_ip ) && ! in_array( $visitor_ip, $cv_bot_ip ) ) {
    226             if ( isset( $_REQUEST['checkview_test_id'] ) ) {
    227                 Checkview_Admin_Logs::add( 'ip-logs', 'Although checkview_test_id is set in the request, exiting test init due to visitor IP [' . $visitor_ip . '] failing bot IP check [' . implode(', ', $cv_bot_ip) . '].' );
    228             }
    229 
    230             if ( 'true' !== get_option( 'cv_ff_keys_set_turnstile' ) ) {
    231                 return;
    232             }
    233 
    234             return;
    235         }
    236 
    237         Checkview_Admin_Logs::add( 'ip-logs', 'Visitor IP [' . $visitor_ip . '] determined to be in bot IP list, continuing.' );
     222
     223        Checkview_Admin_Logs::add( 'ip-logs', 'Visitor IP [' . $visitor_ip . '] determined to be in bot IP list, continuing with test code.' );
    238224
    239225        if ( is_plugin_active( 'cleantalk-spam-protect/cleantalk.php' ) ) {
  • checkview/tags/2.0.20/checkview.php

    r3323842 r3335533  
    1212 * Plugin URI:        https://checkview.io
    1313 * Description:       CheckView is the #1 fully automated solution to test your WordPress forms and detect form problems fast.  Automatically test your WordPress forms to ensure you never miss a lead again.
    14  * Version:           2.0.19
     14 * Version:           2.0.20
    1515 * Author:            CheckView
    1616 * Author URI:        https://checkview.io/
     
    3636 * @link https://semver.org
    3737 */
    38 define( 'CHECKVIEW_VERSION', '2.0.19' );
     38define( 'CHECKVIEW_VERSION', '2.0.20' );
    3939
    4040if ( ! defined( 'CHECKVIEW_BASE_DIR' ) ) {
     
    7878    Checkview_Activator::activate();
    7979}
     80register_activation_hook( __FILE__, 'activate_checkview' );
    8081
    8182/**
     
    8687    Checkview_Deactivator::deactivate();
    8788}
     89register_deactivation_hook( __FILE__, 'deactivate_checkview' );
    8890
    89 register_activation_hook( __FILE__, 'activate_checkview' );
    90 register_deactivation_hook( __FILE__, 'deactivate_checkview' );
    9191if ( ! function_exists( 'is_plugin_active' ) ) {
    9292    require_once ABSPATH . 'wp-admin/includes/plugin.php';
    9393}
     94
    9495// Load CheckView Helper Plugins.
    9596require plugin_dir_path( __FILE__ ) . 'includes/checkview-helper-functions.php';
     
    104105 */
    105106function run_checkview() {
    106     $plugin = Checkview::get_instance();
     107    $plugin = CheckView::get_instance();
    107108    $plugin->run();
    108109}
  • checkview/tags/2.0.20/composer.json

    r3111331 r3335533  
    1818        "php": "^5.6 || ^7.0 || ^8.0",
    1919        "firebase/php-jwt": "^6.5",
    20         "paragonie/sodium_compat": "^1.20"
     20        "paragonie/sodium_compat": "^1.20",
     21        "ext-json": "*"
    2122    },
    2223    "require-dev": {
  • checkview/tags/2.0.20/includes/API/class-checkview-api.php

    r3303097 r3335533  
    1919class CheckView_Api {
    2020    /**
    21      * Woo Helper class.
    22      *
    23      * @since 1.0.0
    24      * @access private
    25      *
    26      * @var bool/Checkview_Woo_Automated_Testing $woo_helper The woo helper of this plugin.
    27      */
    28     private $woo_helper;
    29     /**
    3021     * Holds the JWT error.
    3122     *
     
    3324     */
    3425    public $jwt_error = null;
    35     /**
    36      * Constructor.
    37      *
    38      * Sets class properties.
    39      *
    40      * @since 1.0.0
    41      *
    42      * @param Checkview_Woo_Automated_Testing $woo_helper The woohelper class.
    43      */
    44     public function __construct( $woo_helper = '' ) {
    45         $this->woo_helper  = $woo_helper;
    46     }
    4726
    4827    /**
     
    1016995        $order_id = isset( $order_id ) ? intval( $order_id ) : null;
    1017996        if ( null === $order_id || empty( $order_id ) ) {
    1018             $results = $this->woo_helper->delete_orders_from_backend();
     997            $results = Checkview_Woo_Automated_Testing::delete_orders_from_backend();
    1019998        } else {
    1020999            try {
     
    10471026                }
    10481027                Checkview_Admin_Logs::add( 'api-logs', 'API failed to delete customer.' );
     1028
     1029                $results = false;
    10491030            }
    10501031        }
     
    11591140            );
    11601141        }
    1161         $active_gateways = $this->woo_helper->get_active_payment_gateways();
     1142        $active_gateways = Checkview_Woo_Automated_Testing::get_active_payment_gateways();
    11621143        if ( $active_gateways ) {
    11631144            return new WP_REST_Response(
     
    12041185            );
    12051186        }
    1206         $customer = $this->woo_helper->checkview_create_test_customer();
     1187        $customer = Checkview_Woo_Automated_Testing::checkview_create_test_customer();
    12071188        if ( $customer ) {
    12081189            return new WP_REST_Response(
     
    12451226            );
    12461227        }
    1247         $customer = $this->woo_helper->checkview_get_test_credentials();
     1228        $customer = Checkview_Woo_Automated_Testing::checkview_get_test_credentials();
    12481229        if ( $customer ) {
    12491230            return new WP_REST_Response(
     
    14371418            );
    14381419        }
    1439         $product                              = $this->woo_helper->checkview_get_test_product();
     1420        $product = Checkview_Woo_Automated_Testing::checkview_get_test_product();
    14401421        $product_details['checkview_product'] = $product ? get_permalink( $product->get_id() ) : false;
    14411422        if ( ! empty( $product_details ) && false !== $product_details['checkview_product'] ) {
     
    24192400            );
    24202401        }
    2421         $product    = $this->woo_helper->checkview_get_test_product();
     2402        $product = Checkview_Woo_Automated_Testing::checkview_get_test_product();
    24222403        $product_id = ! empty( $product->get_id() ) ? $product->get_id() : false;
    2423         $status     = checkview_update_woocommerce_product_status( $product_id, $checkview_status );
     2404        $status = checkview_update_woocommerce_product_status( $product_id, $checkview_status );
    24242405        if ( 0 != $status && ! is_wp_error( $product_id ) ) {
    24252406            return new WP_REST_Response(
  • checkview/tags/2.0.20/includes/checkview-functions.php

    r3323842 r3335533  
    119119     */
    120120    function get_checkview_test_id() {
    121         global $wpdb;
    122 
    123121        $cv_test_id = isset( $_REQUEST['checkview_test_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['checkview_test_id'] ) ) : '';
    124122
     
    155153     * @return void
    156154     */
    157     function complete_checkview_test( $checkview_test_id = '' ) {
     155    function complete_checkview_test( string $checkview_test_id = '' ) {
    158156        global $wpdb;
    159157
     
    191189
    192190        if ( ! empty( $form_id ) && ! empty( $entry_id ) ) {
    193             $ws_form_submit = new WS_Form_Submit();
    194             $ws_form_submit->id = $entry_id;
    195             $ws_form_submit->form_id = $form_id;
    196             $ws_form_submit->db_delete( true, true, true );
     191            if ( class_exists( 'WS_Form_Submit' ) ) {
     192                $ws_form_submit = new WS_Form_Submit();
     193                $ws_form_submit->id = $entry_id;
     194                $ws_form_submit->form_id = $form_id;
     195                $ws_form_submit->db_delete( true, true, true );
     196            } else {
     197                Checkview_Admin_Logs::add( 'ip-logs', 'WS_Form_Submit class does not exist.' );
     198            }
    197199        }
    198200
     
    666668        $is_sub_directory = explode( '/', str_replace( '//', '|', $current_url ) );
    667669        if ( count( $is_sub_directory ) > 1 ) {
    668             // remove subdiretory from home url.
     670            // remove subdirectory from home url.
    669671            $current_url = str_replace( '/' . $is_sub_directory[1], '', $current_url );
    670672        }
     
    687689        $current_url = $url[0];
    688690        $page_id     = '';
     691
    689692        // Retrieve the current post's ID based on its URL.
    690         if ( $current_url ) {
    691             $page_id = get_page_by_path( $current_url );
    692             $page_id = $page_id->ID;
     693        if ( ! $current_url ) {
     694            global $post;
     695
     696            if ( $post instanceof WP_Post ) {
     697                $page_id = $post->ID;
     698            }
    693699        } else {
    694             global $post;
    695             if ( $post ) {
    696                 $page_id = $post->ID;
    697             }
    698         }
     700            $page = get_page_by_path( $current_url );
     701
     702            if ( $page instanceof WP_Post ) {
     703                $page_id = $page->ID;
     704            } else {
     705                global $post;
     706
     707                if ( $post instanceof WP_Post ) {
     708                    $page_id = $post->ID;
     709                } else {
     710                    $page_id = get_the_ID();
     711                }
     712            }
     713        }
     714
    699715        $session_table = $wpdb->prefix . 'cv_session';
    700716        $test_key      = 'CF_TEST_' . $page_id;
     
    10131029     */
    10141030    function checkview_get_option_data_handler() {
    1015         if ( ! isset( $_POST['_checkview_token'] ) || empty( $_POST['_checkview_token'] ) ) {
     1031        if ( empty( $_POST['_checkview_token'] ) ) {
    10161032            Checkview_Admin_Logs::add( 'api-logs', 'Token absent.' );
    10171033            wp_send_json_error( esc_html__( 'There was a technical error while processing your request.', 'checkview' ) );
     
    10311047
    10321048        // Checking for JWT token.
    1033         if ( ! isset( $nonce_token ) || empty( $nonce_token ) || is_wp_error( $nonce_token ) ) {
    1034             $this->jwt_error = $nonce_token;
    1035             // Log the detailed error for internal use.
     1049        if ( empty( $nonce_token ) || is_wp_error( $nonce_token ) ) {
    10361050            Checkview_Admin_Logs::add( 'api-logs', 'Invalid token.' );
    10371051            wp_send_json_error( esc_html__( 'There was a technical error while processing your request.', 'checkview' ) );
     
    11331147     * @return mixed The first matching element, or null if none found.
    11341148     */
    1135     function array_find(array $array, callable $callback): mixed {
     1149    function array_find(array $array, callable $callback) {
    11361150        foreach ($array as $key => $value) {
    11371151            if ($callback($value, $key)) {
  • checkview/tags/2.0.20/includes/checkview-helper-functions.php

    r3247217 r3335533  
    1717     * Validates an IP address.
    1818     *
    19      * @param IP $ip IP address.
     19     * @param string $ip IP address.
    2020     * @return bool
    2121     */
    22     function checkview_validate_ip( $ip ) {
     22    function checkview_validate_ip( string $ip ): bool {
    2323        // Validate that the input is a valid IP address.
    2424        if ( ! empty( $ip ) && ! filter_var( $ip, FILTER_VALIDATE_IP ) ) {
  • checkview/tags/2.0.20/includes/class-checkview.php

    r3323842 r3335533  
    1717 * @author Check View <[email protected]>
    1818 */
    19 class Checkview {
     19class CheckView {
    2020
    2121    /**
     
    5555     * @access private
    5656     *
    57      * @var Checkview $instance The instance of the class.
     57     * @var CheckView $instance The instance of the class.
    5858     */
    5959
    6060    private static $instance = null;
     61
     62    /**
     63     * Bot cookie name.
     64     *
     65     * @since 2.0.20
     66     * @access private
     67     *
     68     * @var string $bot_cookie Bot cookie name.
     69     */
     70    private static string $bot_cookie = 'cv_running';
    6171
    6272    /**
     
    7181            $this->version = CHECKVIEW_VERSION;
    7282        } else {
    73             $this->version = '2.0.19';
     83            $this->version = '2.0.20';
    7484        }
    7585        $this->plugin_name = 'checkview';
    7686
    7787        $this->load_dependencies();
    78         $this->define_public_hooks();
    79         $this->set_locale();
     88
     89        $this->loader->add_action( 'init', $this, 'load_textdomain' );
     90        $this->loader->add_action( 'wp_enqueue_scripts', $this, 'dequeue_scripts', 20 );
     91
    8092        $this->define_admin_hooks();
    8193    }
     
    92104    public static function get_instance() {
    93105        if ( null === self::$instance ) {
    94             self::$instance = new Checkview();
     106            self::$instance = new CheckView();
    95107        }
    96108
    97109        return self::$instance;
     110    }
     111
     112    /**
     113     * Determine if the request contains the cookie necessary for running testing code.
     114     *
     115     * Returns one of `woo_checkout`, `form`, or `custom`. False if not set or invalid value.
     116     *
     117     * @return string|false Validated cookie value, or false.
     118     */
     119    public static function has_cookie() {
     120        $valid_values = array('woo_checkout', 'form', 'custom');
     121
     122        if ( isset( $_COOKIE[self::$bot_cookie] ) && in_array( $_COOKIE[self::$bot_cookie], $valid_values ) ) {
     123            return $_COOKIE[self::$bot_cookie];
     124        }
     125
     126        return false;
     127    }
     128
     129    /**
     130     * Determine if the current request is a CheckView bot.
     131     *
     132     * @return bool
     133     */
     134    public static function is_bot(): bool {
     135        $visitor_ip = checkview_get_visitor_ip();
     136        $cv_bot_ip = checkview_get_api_ip();
     137        $ip_verified = is_array( $cv_bot_ip ) && in_array( $visitor_ip, $cv_bot_ip );
     138
     139        if ( isset( $_REQUEST['checkview_test_id'] ) && ! $ip_verified ) {
     140            Checkview_Admin_Logs::add( 'ip-logs', 'Although checkview_test_id is set in the request, failing bot check due to visitor IP [' . $visitor_ip . '] not existing in bot IP list [' . implode(', ', $cv_bot_ip) . '].' );
     141
     142            return false;
     143        }
     144
     145        $has_cookie = self::has_cookie();
     146
     147        return $has_cookie && $ip_verified;
    98148    }
    99149
     
    124174        require_once plugin_dir_path( __DIR__ ) . 'includes/checkview-functions.php';
    125175        require_once plugin_dir_path( __DIR__ ) . 'includes/class-checkview-loader.php';
    126         require_once plugin_dir_path( __DIR__ ) . 'includes/class-checkview-i18n.php';
    127176        require_once plugin_dir_path( __DIR__ ) . 'admin/class-checkview-admin.php';
    128177        require_once plugin_dir_path( __DIR__ ) . 'admin/class-checkview-admin-logs.php';
    129178        require_once plugin_dir_path( __DIR__ ) . 'admin/settings/class-checkview-admin-settings.php';
    130         require_once plugin_dir_path( __DIR__ ) . 'public/class-checkview-public.php';
    131179
    132180        $this->loader = new Checkview_Loader();
    133181
    134         // Current Vsitor IP.
     182        // Current visitor IP.
    135183        $visitor_ip = checkview_get_visitor_ip();
    136184        $woo_helper = '';
    137185        // Check view Bot IP.
    138186        $cv_bot_ip = checkview_get_api_ip();
     187
     188        // TODO: What is this for?
    139189        if ( ( 'checkview-saas' === get_option( $visitor_ip ) || isset( $_REQUEST['checkview_test_id'] ) || ( is_array( $cv_bot_ip ) && in_array( $visitor_ip, $cv_bot_ip ) ) ) ) {
    140190            update_option( $visitor_ip, 'checkview-saas', true );
    141191        }
     192
    142193        if ( class_exists( 'WooCommerce' ) ) {
    143194            require_once plugin_dir_path( __DIR__ ) . 'includes/woocommercehelper/class-checkview-woo-automated-testing.php';
     195
    144196            $woo_helper = new Checkview_Woo_Automated_Testing( $this->get_plugin_name(), $this->get_version(), $this->loader );
    145197        }
     198
    146199        $this->loader->add_filter(
    147200            'plugin_action_links_' . CHECKVIEW_BASE_DIR,
     
    154207
    155208        // Initialize the plugin's API.
    156         $plugin_api = new CheckView_Api( $woo_helper );
     209        $plugin_api = new CheckView_Api();
    157210
    158211        // Hook our routes into WordPress.
     
    165218
    166219    /**
    167      * Sets up i18n.
    168      *
    169      * @since 1.0.0
    170      * @access private
    171      */
    172     private function set_locale() {
    173 
    174         $plugin_i18n = new Checkview_i18n();
    175         $plugin_i18n->load_plugin_textdomain();
    176         add_action(
    177             'plugins_loaded',
    178             array( $plugin_i18n, 'load_plugin_textdomain' )
     220     * Loads the CheckView text domain.
     221     *
     222     * @since 1.0.0
     223     */
     224    public function load_textdomain() {
     225        load_plugin_textdomain(
     226            'checkview',
     227            false,
     228            dirname( plugin_basename( __FILE__ ) ) . '/languages/'
    179229        );
    180230    }
     
    263313            );
    264314        }
    265         $this->loader->add_action(
    266             'init',
    267             $plugin_admin,
    268             'checkview_init_current_test'
    269         );
     315
     316        if ( self::is_bot() ) {
     317            $this->loader->add_action(
     318                'init',
     319                $plugin_admin,
     320                'checkview_init_current_test'
     321            );
     322        }
     323
    270324        $this->loader->add_action(
    271325            'upgrader_process_complete',
     
    285339     * @access private
    286340     */
    287     private function define_public_hooks() {
    288 
    289         $plugin_public = new Checkview_Public( $this->get_plugin_name(), $this->get_version() );
    290         $this->loader->add_action(
    291             'wp_enqueue_scripts',
    292             $plugin_public,
    293             'enqueue_scripts'
    294         );
    295 
    296         // Current Vsitor IP.
    297         $visitor_ip = checkview_get_visitor_ip();
    298         // Check view Bot IP.
    299         $cv_bot_ip = checkview_get_api_ip();
    300 
    301         // Proceed if visitor IP is in SaaS IPs.
    302         if ( is_array( $cv_bot_ip ) && in_array( $visitor_ip, $cv_bot_ip ) ) {
     341    public function dequeue_scripts() {
     342        if ( self::is_bot() ) {
     343            wp_dequeue_script( 'contact-form-7' );
     344            wp_dequeue_style( 'contact-form-7' );
     345            wp_dequeue_script( 'wpcf7-recaptcha' );
     346            wp_dequeue_style( 'wpcf7-recaptcha' );
     347
    303348            $this->loader->add_action(
    304349                'pre_option_require_name_email',
  • checkview/tags/2.0.20/includes/woocommercehelper/class-checkview-woo-automated-testing.php

    r3323842 r3335533  
    204204        }
    205205
    206         // add_filter( 'wp_mail', array( $this, 'checkview_filter_wp_mail' ), 99 );
    207206        $this->checkview_test_mode();
    208207    }
     
    262261     * @return array
    263262     */
    264     public function get_active_payment_gateways() {
     263    public static function get_active_payment_gateways() {
    265264        $active_gateways  = array();
    266265        $payment_gateways = WC_Payment_Gateways::instance()->payment_gateways();
     
    285284     * @return WC_Customer
    286285     */
    287     public function checkview_create_test_customer() {
    288         $customer = $this->checkview_get_test_customer();
     286    public static function checkview_create_test_customer() {
     287        $customer = self::checkview_get_test_customer();
    289288        $email    = CHECKVIEW_EMAIL;
    290289
     
    318317     * @return WC_Customer|false
    319318     */
    320     public function checkview_get_test_customer() {
     319    public static function checkview_get_test_customer() {
    321320        $customer_id = get_option( 'checkview_test_user', false );
    322321
     
    360359     * @type string $password The newly-generated password for the test user.
    361360     */
    362     public function checkview_get_test_credentials() {
     361    public static function checkview_get_test_credentials() {
    363362        add_filter( 'pre_wp_mail', '__return_false', PHP_INT_MAX );
    364363
    365364        $password = wp_generate_password();
    366         $customer = $this->checkview_get_test_customer();
     365        $customer = self::checkview_get_test_customer();
    367366
    368367        if ( ! $customer ) {
    369             $customer = $this->checkview_create_test_customer();
     368            $customer = self::checkview_create_test_customer();
    370369        }
    371370
     
    374373
    375374        // Schedule the password to be rotated 15min from now.
    376         $this->checkview_rotate_password_cron();
     375        self::checkview_rotate_password_cron();
    377376
    378377        return array(
     
    389388        add_filter( 'pre_wp_mail', '__return_false', PHP_INT_MAX );
    390389
    391         $customer = $this->checkview_get_test_customer();
     390        $customer = self::checkview_get_test_customer();
    392391
    393392        if ( ! $customer ) {
     
    404403     * @return void
    405404     */
    406     public function checkview_rotate_password_cron() {
     405    public static function checkview_rotate_password_cron() {
    407406        wp_schedule_single_event( time() + 15 * MINUTE_IN_SECONDS, 'checkview_rotate_user_credentials' );
    408407    }
     
    415414     * @return WC_Product/bool
    416415     */
    417     public function checkview_get_test_product() {
     416    public static function checkview_get_test_product() {
    418417        $product_id = get_option( 'checkview_woo_product_id' );
    419418        if ( $product_id ) {
     
    564563     */
    565564    public function checkview_test_mode() {
    566         $visitor_ip = checkview_get_visitor_ip();
    567         $cv_bot_ip = checkview_get_api_ip();
    568 
    569         if ( ! is_array( $cv_bot_ip ) || ! in_array( $visitor_ip, $cv_bot_ip ) ) {
     565        $is_bot = CheckView::is_bot();
     566
     567        if ( ! $is_bot ) {
    570568            return;
    571569        }
    572570
    573         Checkview_Admin_Logs::add( 'ip-logs', 'Running Woo test mode hooks, visitor IP [' . $visitor_ip . '] matched a bot IP.' );
     571        $cookie = CheckView::has_cookie();
     572
     573        if ( $cookie !== 'woo_checkout' ) {
     574            return;
     575        }
     576
     577        Checkview_Admin_Logs::add( 'ip-logs', 'Running Woo test mode hooks, visitor is bot and cookie value equals [' . $cookie . '].' );
    574578
    575579        if ( ! is_admin() && class_exists( 'WooCommerce' ) ) {
     
    783787     * Doesn't run on AJAX requests.
    784788     *
    785      * @return void
    786      */
    787     public function delete_orders_from_backend() {
     789     * @return boolean
     790     */
     791    public static function delete_orders_from_backend() {
    788792        if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
    789             return;
    790         }
    791 
    792         return $this->checkview_delete_orders();
     793            return false;
     794        }
     795
     796        return self::checkview_delete_orders();
    793797    }
    794798
     
    799803     * @return bool
    800804     */
    801     public function checkview_delete_orders( $order_id = '' ) {
     805    public static function checkview_delete_orders( $order_id = '' ) {
    802806        Checkview_Admin_Logs::add( 'ip-logs', 'Deleting CheckView orders from the database...' );
    803807
  • checkview/trunk/README.txt

    r3323842 r3335533  
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
    10 Stable tag: 2.0.19
     10Stable tag: 2.0.20
    1111
    1212[CheckView](https://checkview.io/) is the friendly WordPress automated testing platform for everyone, from developers, shop owners to agencies. 
     
    8686
    8787== Changelog ==
     88= 2.0.20 =
     89* Only run testing code for requests with newly required cookie.
     90* Only run relevant test code for the specified test type in the newly required cookie.
     91* Add check for WS Forms before attempting to run code.
     92* Better handle page ID retrieval.
     93* Extract all code from I18n class into a single function.
     94* Extract all code from Public class into a single function.
     95* Make helper methods of Woo class static.
     96* Improve logging.
     97
    8898= 2.0.19 =
    89 * Improve logging
    90 * Add hooks for disabling WP Forms CAPTCHAs/Turnstiles for tests
    91 * Disable test-related hooks on API requests
    92 * Disable Fluent Forms token-based spam prevention for tests
    93 * Remove Fluent Forms CAPTCHA/Turnstile key swap
    94 * Disable Fluent Forms CAPTCHAs using newly provided hook
     99* Improve logging.
     100* Add hooks for disabling WP Forms CAPTCHAs/Turnstiles for tests.
     101* Disable test-related hooks on API requests.
     102* Disable Fluent Forms token-based spam prevention for tests.
     103* Remove Fluent Forms CAPTCHA/Turnstile key swap.
     104* Disable Fluent Forms CAPTCHAs using newly provided hook.
    95105
    96106= 2.0.18 =
     
    368378
    369379== Upgrade Notice ==
     380= 2.0.20 =
     381* Only run testing code for requests with newly required cookie.
     382* Only run relevant test code for the specified test type in the newly required cookie.
     383* Add check for WS Forms before attempting to run code.
     384* Better handle page ID retrieval.
     385* Extract all code from I18n class into a single function.
     386* Extract all code from Public class into a single function.
     387* Make helper methods of Woo class static.
     388* Improve logging.
     389
    370390= 2.0.19 =
    371391* Improve logging
  • checkview/trunk/admin/class-checkview-admin.php

    r3323842 r3335533  
    204204     * Initializes a test.
    205205     *
     206     * Should only be called if the request is a verified CheckView bot.
     207     *
    206208     * @return void
    207209     */
     
    217219        }
    218220
    219         // Current Visitor IP.
    220221        $visitor_ip = checkview_get_visitor_ip();
    221         // Check view Bot IP.
    222         $cv_bot_ip = checkview_get_api_ip();
    223 
    224         // Skip if visitor ip not equal to CV Bot IP.
    225         if ( is_array( $cv_bot_ip ) && ! in_array( $visitor_ip, $cv_bot_ip ) ) {
    226             if ( isset( $_REQUEST['checkview_test_id'] ) ) {
    227                 Checkview_Admin_Logs::add( 'ip-logs', 'Although checkview_test_id is set in the request, exiting test init due to visitor IP [' . $visitor_ip . '] failing bot IP check [' . implode(', ', $cv_bot_ip) . '].' );
    228             }
    229 
    230             if ( 'true' !== get_option( 'cv_ff_keys_set_turnstile' ) ) {
    231                 return;
    232             }
    233 
    234             return;
    235         }
    236 
    237         Checkview_Admin_Logs::add( 'ip-logs', 'Visitor IP [' . $visitor_ip . '] determined to be in bot IP list, continuing.' );
     222
     223        Checkview_Admin_Logs::add( 'ip-logs', 'Visitor IP [' . $visitor_ip . '] determined to be in bot IP list, continuing with test code.' );
    238224
    239225        if ( is_plugin_active( 'cleantalk-spam-protect/cleantalk.php' ) ) {
  • checkview/trunk/checkview.php

    r3323842 r3335533  
    1212 * Plugin URI:        https://checkview.io
    1313 * Description:       CheckView is the #1 fully automated solution to test your WordPress forms and detect form problems fast.  Automatically test your WordPress forms to ensure you never miss a lead again.
    14  * Version:           2.0.19
     14 * Version:           2.0.20
    1515 * Author:            CheckView
    1616 * Author URI:        https://checkview.io/
     
    3636 * @link https://semver.org
    3737 */
    38 define( 'CHECKVIEW_VERSION', '2.0.19' );
     38define( 'CHECKVIEW_VERSION', '2.0.20' );
    3939
    4040if ( ! defined( 'CHECKVIEW_BASE_DIR' ) ) {
     
    7878    Checkview_Activator::activate();
    7979}
     80register_activation_hook( __FILE__, 'activate_checkview' );
    8081
    8182/**
     
    8687    Checkview_Deactivator::deactivate();
    8788}
     89register_deactivation_hook( __FILE__, 'deactivate_checkview' );
    8890
    89 register_activation_hook( __FILE__, 'activate_checkview' );
    90 register_deactivation_hook( __FILE__, 'deactivate_checkview' );
    9191if ( ! function_exists( 'is_plugin_active' ) ) {
    9292    require_once ABSPATH . 'wp-admin/includes/plugin.php';
    9393}
     94
    9495// Load CheckView Helper Plugins.
    9596require plugin_dir_path( __FILE__ ) . 'includes/checkview-helper-functions.php';
     
    104105 */
    105106function run_checkview() {
    106     $plugin = Checkview::get_instance();
     107    $plugin = CheckView::get_instance();
    107108    $plugin->run();
    108109}
  • checkview/trunk/composer.json

    r3111331 r3335533  
    1818        "php": "^5.6 || ^7.0 || ^8.0",
    1919        "firebase/php-jwt": "^6.5",
    20         "paragonie/sodium_compat": "^1.20"
     20        "paragonie/sodium_compat": "^1.20",
     21        "ext-json": "*"
    2122    },
    2223    "require-dev": {
  • checkview/trunk/includes/API/class-checkview-api.php

    r3303097 r3335533  
    1919class CheckView_Api {
    2020    /**
    21      * Woo Helper class.
    22      *
    23      * @since 1.0.0
    24      * @access private
    25      *
    26      * @var bool/Checkview_Woo_Automated_Testing $woo_helper The woo helper of this plugin.
    27      */
    28     private $woo_helper;
    29     /**
    3021     * Holds the JWT error.
    3122     *
     
    3324     */
    3425    public $jwt_error = null;
    35     /**
    36      * Constructor.
    37      *
    38      * Sets class properties.
    39      *
    40      * @since 1.0.0
    41      *
    42      * @param Checkview_Woo_Automated_Testing $woo_helper The woohelper class.
    43      */
    44     public function __construct( $woo_helper = '' ) {
    45         $this->woo_helper  = $woo_helper;
    46     }
    4726
    4827    /**
     
    1016995        $order_id = isset( $order_id ) ? intval( $order_id ) : null;
    1017996        if ( null === $order_id || empty( $order_id ) ) {
    1018             $results = $this->woo_helper->delete_orders_from_backend();
     997            $results = Checkview_Woo_Automated_Testing::delete_orders_from_backend();
    1019998        } else {
    1020999            try {
     
    10471026                }
    10481027                Checkview_Admin_Logs::add( 'api-logs', 'API failed to delete customer.' );
     1028
     1029                $results = false;
    10491030            }
    10501031        }
     
    11591140            );
    11601141        }
    1161         $active_gateways = $this->woo_helper->get_active_payment_gateways();
     1142        $active_gateways = Checkview_Woo_Automated_Testing::get_active_payment_gateways();
    11621143        if ( $active_gateways ) {
    11631144            return new WP_REST_Response(
     
    12041185            );
    12051186        }
    1206         $customer = $this->woo_helper->checkview_create_test_customer();
     1187        $customer = Checkview_Woo_Automated_Testing::checkview_create_test_customer();
    12071188        if ( $customer ) {
    12081189            return new WP_REST_Response(
     
    12451226            );
    12461227        }
    1247         $customer = $this->woo_helper->checkview_get_test_credentials();
     1228        $customer = Checkview_Woo_Automated_Testing::checkview_get_test_credentials();
    12481229        if ( $customer ) {
    12491230            return new WP_REST_Response(
     
    14371418            );
    14381419        }
    1439         $product                              = $this->woo_helper->checkview_get_test_product();
     1420        $product = Checkview_Woo_Automated_Testing::checkview_get_test_product();
    14401421        $product_details['checkview_product'] = $product ? get_permalink( $product->get_id() ) : false;
    14411422        if ( ! empty( $product_details ) && false !== $product_details['checkview_product'] ) {
     
    24192400            );
    24202401        }
    2421         $product    = $this->woo_helper->checkview_get_test_product();
     2402        $product = Checkview_Woo_Automated_Testing::checkview_get_test_product();
    24222403        $product_id = ! empty( $product->get_id() ) ? $product->get_id() : false;
    2423         $status     = checkview_update_woocommerce_product_status( $product_id, $checkview_status );
     2404        $status = checkview_update_woocommerce_product_status( $product_id, $checkview_status );
    24242405        if ( 0 != $status && ! is_wp_error( $product_id ) ) {
    24252406            return new WP_REST_Response(
  • checkview/trunk/includes/checkview-functions.php

    r3323842 r3335533  
    119119     */
    120120    function get_checkview_test_id() {
    121         global $wpdb;
    122 
    123121        $cv_test_id = isset( $_REQUEST['checkview_test_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['checkview_test_id'] ) ) : '';
    124122
     
    155153     * @return void
    156154     */
    157     function complete_checkview_test( $checkview_test_id = '' ) {
     155    function complete_checkview_test( string $checkview_test_id = '' ) {
    158156        global $wpdb;
    159157
     
    191189
    192190        if ( ! empty( $form_id ) && ! empty( $entry_id ) ) {
    193             $ws_form_submit = new WS_Form_Submit();
    194             $ws_form_submit->id = $entry_id;
    195             $ws_form_submit->form_id = $form_id;
    196             $ws_form_submit->db_delete( true, true, true );
     191            if ( class_exists( 'WS_Form_Submit' ) ) {
     192                $ws_form_submit = new WS_Form_Submit();
     193                $ws_form_submit->id = $entry_id;
     194                $ws_form_submit->form_id = $form_id;
     195                $ws_form_submit->db_delete( true, true, true );
     196            } else {
     197                Checkview_Admin_Logs::add( 'ip-logs', 'WS_Form_Submit class does not exist.' );
     198            }
    197199        }
    198200
     
    666668        $is_sub_directory = explode( '/', str_replace( '//', '|', $current_url ) );
    667669        if ( count( $is_sub_directory ) > 1 ) {
    668             // remove subdiretory from home url.
     670            // remove subdirectory from home url.
    669671            $current_url = str_replace( '/' . $is_sub_directory[1], '', $current_url );
    670672        }
     
    687689        $current_url = $url[0];
    688690        $page_id     = '';
     691
    689692        // Retrieve the current post's ID based on its URL.
    690         if ( $current_url ) {
    691             $page_id = get_page_by_path( $current_url );
    692             $page_id = $page_id->ID;
     693        if ( ! $current_url ) {
     694            global $post;
     695
     696            if ( $post instanceof WP_Post ) {
     697                $page_id = $post->ID;
     698            }
    693699        } else {
    694             global $post;
    695             if ( $post ) {
    696                 $page_id = $post->ID;
    697             }
    698         }
     700            $page = get_page_by_path( $current_url );
     701
     702            if ( $page instanceof WP_Post ) {
     703                $page_id = $page->ID;
     704            } else {
     705                global $post;
     706
     707                if ( $post instanceof WP_Post ) {
     708                    $page_id = $post->ID;
     709                } else {
     710                    $page_id = get_the_ID();
     711                }
     712            }
     713        }
     714
    699715        $session_table = $wpdb->prefix . 'cv_session';
    700716        $test_key      = 'CF_TEST_' . $page_id;
     
    10131029     */
    10141030    function checkview_get_option_data_handler() {
    1015         if ( ! isset( $_POST['_checkview_token'] ) || empty( $_POST['_checkview_token'] ) ) {
     1031        if ( empty( $_POST['_checkview_token'] ) ) {
    10161032            Checkview_Admin_Logs::add( 'api-logs', 'Token absent.' );
    10171033            wp_send_json_error( esc_html__( 'There was a technical error while processing your request.', 'checkview' ) );
     
    10311047
    10321048        // Checking for JWT token.
    1033         if ( ! isset( $nonce_token ) || empty( $nonce_token ) || is_wp_error( $nonce_token ) ) {
    1034             $this->jwt_error = $nonce_token;
    1035             // Log the detailed error for internal use.
     1049        if ( empty( $nonce_token ) || is_wp_error( $nonce_token ) ) {
    10361050            Checkview_Admin_Logs::add( 'api-logs', 'Invalid token.' );
    10371051            wp_send_json_error( esc_html__( 'There was a technical error while processing your request.', 'checkview' ) );
     
    11331147     * @return mixed The first matching element, or null if none found.
    11341148     */
    1135     function array_find(array $array, callable $callback): mixed {
     1149    function array_find(array $array, callable $callback) {
    11361150        foreach ($array as $key => $value) {
    11371151            if ($callback($value, $key)) {
  • checkview/trunk/includes/checkview-helper-functions.php

    r3247217 r3335533  
    1717     * Validates an IP address.
    1818     *
    19      * @param IP $ip IP address.
     19     * @param string $ip IP address.
    2020     * @return bool
    2121     */
    22     function checkview_validate_ip( $ip ) {
     22    function checkview_validate_ip( string $ip ): bool {
    2323        // Validate that the input is a valid IP address.
    2424        if ( ! empty( $ip ) && ! filter_var( $ip, FILTER_VALIDATE_IP ) ) {
  • checkview/trunk/includes/class-checkview.php

    r3323842 r3335533  
    1717 * @author Check View <[email protected]>
    1818 */
    19 class Checkview {
     19class CheckView {
    2020
    2121    /**
     
    5555     * @access private
    5656     *
    57      * @var Checkview $instance The instance of the class.
     57     * @var CheckView $instance The instance of the class.
    5858     */
    5959
    6060    private static $instance = null;
     61
     62    /**
     63     * Bot cookie name.
     64     *
     65     * @since 2.0.20
     66     * @access private
     67     *
     68     * @var string $bot_cookie Bot cookie name.
     69     */
     70    private static string $bot_cookie = 'cv_running';
    6171
    6272    /**
     
    7181            $this->version = CHECKVIEW_VERSION;
    7282        } else {
    73             $this->version = '2.0.19';
     83            $this->version = '2.0.20';
    7484        }
    7585        $this->plugin_name = 'checkview';
    7686
    7787        $this->load_dependencies();
    78         $this->define_public_hooks();
    79         $this->set_locale();
     88
     89        $this->loader->add_action( 'init', $this, 'load_textdomain' );
     90        $this->loader->add_action( 'wp_enqueue_scripts', $this, 'dequeue_scripts', 20 );
     91
    8092        $this->define_admin_hooks();
    8193    }
     
    92104    public static function get_instance() {
    93105        if ( null === self::$instance ) {
    94             self::$instance = new Checkview();
     106            self::$instance = new CheckView();
    95107        }
    96108
    97109        return self::$instance;
     110    }
     111
     112    /**
     113     * Determine if the request contains the cookie necessary for running testing code.
     114     *
     115     * Returns one of `woo_checkout`, `form`, or `custom`. False if not set or invalid value.
     116     *
     117     * @return string|false Validated cookie value, or false.
     118     */
     119    public static function has_cookie() {
     120        $valid_values = array('woo_checkout', 'form', 'custom');
     121
     122        if ( isset( $_COOKIE[self::$bot_cookie] ) && in_array( $_COOKIE[self::$bot_cookie], $valid_values ) ) {
     123            return $_COOKIE[self::$bot_cookie];
     124        }
     125
     126        return false;
     127    }
     128
     129    /**
     130     * Determine if the current request is a CheckView bot.
     131     *
     132     * @return bool
     133     */
     134    public static function is_bot(): bool {
     135        $visitor_ip = checkview_get_visitor_ip();
     136        $cv_bot_ip = checkview_get_api_ip();
     137        $ip_verified = is_array( $cv_bot_ip ) && in_array( $visitor_ip, $cv_bot_ip );
     138
     139        if ( isset( $_REQUEST['checkview_test_id'] ) && ! $ip_verified ) {
     140            Checkview_Admin_Logs::add( 'ip-logs', 'Although checkview_test_id is set in the request, failing bot check due to visitor IP [' . $visitor_ip . '] not existing in bot IP list [' . implode(', ', $cv_bot_ip) . '].' );
     141
     142            return false;
     143        }
     144
     145        $has_cookie = self::has_cookie();
     146
     147        return $has_cookie && $ip_verified;
    98148    }
    99149
     
    124174        require_once plugin_dir_path( __DIR__ ) . 'includes/checkview-functions.php';
    125175        require_once plugin_dir_path( __DIR__ ) . 'includes/class-checkview-loader.php';
    126         require_once plugin_dir_path( __DIR__ ) . 'includes/class-checkview-i18n.php';
    127176        require_once plugin_dir_path( __DIR__ ) . 'admin/class-checkview-admin.php';
    128177        require_once plugin_dir_path( __DIR__ ) . 'admin/class-checkview-admin-logs.php';
    129178        require_once plugin_dir_path( __DIR__ ) . 'admin/settings/class-checkview-admin-settings.php';
    130         require_once plugin_dir_path( __DIR__ ) . 'public/class-checkview-public.php';
    131179
    132180        $this->loader = new Checkview_Loader();
    133181
    134         // Current Vsitor IP.
     182        // Current visitor IP.
    135183        $visitor_ip = checkview_get_visitor_ip();
    136184        $woo_helper = '';
    137185        // Check view Bot IP.
    138186        $cv_bot_ip = checkview_get_api_ip();
     187
     188        // TODO: What is this for?
    139189        if ( ( 'checkview-saas' === get_option( $visitor_ip ) || isset( $_REQUEST['checkview_test_id'] ) || ( is_array( $cv_bot_ip ) && in_array( $visitor_ip, $cv_bot_ip ) ) ) ) {
    140190            update_option( $visitor_ip, 'checkview-saas', true );
    141191        }
     192
    142193        if ( class_exists( 'WooCommerce' ) ) {
    143194            require_once plugin_dir_path( __DIR__ ) . 'includes/woocommercehelper/class-checkview-woo-automated-testing.php';
     195
    144196            $woo_helper = new Checkview_Woo_Automated_Testing( $this->get_plugin_name(), $this->get_version(), $this->loader );
    145197        }
     198
    146199        $this->loader->add_filter(
    147200            'plugin_action_links_' . CHECKVIEW_BASE_DIR,
     
    154207
    155208        // Initialize the plugin's API.
    156         $plugin_api = new CheckView_Api( $woo_helper );
     209        $plugin_api = new CheckView_Api();
    157210
    158211        // Hook our routes into WordPress.
     
    165218
    166219    /**
    167      * Sets up i18n.
    168      *
    169      * @since 1.0.0
    170      * @access private
    171      */
    172     private function set_locale() {
    173 
    174         $plugin_i18n = new Checkview_i18n();
    175         $plugin_i18n->load_plugin_textdomain();
    176         add_action(
    177             'plugins_loaded',
    178             array( $plugin_i18n, 'load_plugin_textdomain' )
     220     * Loads the CheckView text domain.
     221     *
     222     * @since 1.0.0
     223     */
     224    public function load_textdomain() {
     225        load_plugin_textdomain(
     226            'checkview',
     227            false,
     228            dirname( plugin_basename( __FILE__ ) ) . '/languages/'
    179229        );
    180230    }
     
    263313            );
    264314        }
    265         $this->loader->add_action(
    266             'init',
    267             $plugin_admin,
    268             'checkview_init_current_test'
    269         );
     315
     316        if ( self::is_bot() ) {
     317            $this->loader->add_action(
     318                'init',
     319                $plugin_admin,
     320                'checkview_init_current_test'
     321            );
     322        }
     323
    270324        $this->loader->add_action(
    271325            'upgrader_process_complete',
     
    285339     * @access private
    286340     */
    287     private function define_public_hooks() {
    288 
    289         $plugin_public = new Checkview_Public( $this->get_plugin_name(), $this->get_version() );
    290         $this->loader->add_action(
    291             'wp_enqueue_scripts',
    292             $plugin_public,
    293             'enqueue_scripts'
    294         );
    295 
    296         // Current Vsitor IP.
    297         $visitor_ip = checkview_get_visitor_ip();
    298         // Check view Bot IP.
    299         $cv_bot_ip = checkview_get_api_ip();
    300 
    301         // Proceed if visitor IP is in SaaS IPs.
    302         if ( is_array( $cv_bot_ip ) && in_array( $visitor_ip, $cv_bot_ip ) ) {
     341    public function dequeue_scripts() {
     342        if ( self::is_bot() ) {
     343            wp_dequeue_script( 'contact-form-7' );
     344            wp_dequeue_style( 'contact-form-7' );
     345            wp_dequeue_script( 'wpcf7-recaptcha' );
     346            wp_dequeue_style( 'wpcf7-recaptcha' );
     347
    303348            $this->loader->add_action(
    304349                'pre_option_require_name_email',
  • checkview/trunk/includes/woocommercehelper/class-checkview-woo-automated-testing.php

    r3323842 r3335533  
    204204        }
    205205
    206         // add_filter( 'wp_mail', array( $this, 'checkview_filter_wp_mail' ), 99 );
    207206        $this->checkview_test_mode();
    208207    }
     
    262261     * @return array
    263262     */
    264     public function get_active_payment_gateways() {
     263    public static function get_active_payment_gateways() {
    265264        $active_gateways  = array();
    266265        $payment_gateways = WC_Payment_Gateways::instance()->payment_gateways();
     
    285284     * @return WC_Customer
    286285     */
    287     public function checkview_create_test_customer() {
    288         $customer = $this->checkview_get_test_customer();
     286    public static function checkview_create_test_customer() {
     287        $customer = self::checkview_get_test_customer();
    289288        $email    = CHECKVIEW_EMAIL;
    290289
     
    318317     * @return WC_Customer|false
    319318     */
    320     public function checkview_get_test_customer() {
     319    public static function checkview_get_test_customer() {
    321320        $customer_id = get_option( 'checkview_test_user', false );
    322321
     
    360359     * @type string $password The newly-generated password for the test user.
    361360     */
    362     public function checkview_get_test_credentials() {
     361    public static function checkview_get_test_credentials() {
    363362        add_filter( 'pre_wp_mail', '__return_false', PHP_INT_MAX );
    364363
    365364        $password = wp_generate_password();
    366         $customer = $this->checkview_get_test_customer();
     365        $customer = self::checkview_get_test_customer();
    367366
    368367        if ( ! $customer ) {
    369             $customer = $this->checkview_create_test_customer();
     368            $customer = self::checkview_create_test_customer();
    370369        }
    371370
     
    374373
    375374        // Schedule the password to be rotated 15min from now.
    376         $this->checkview_rotate_password_cron();
     375        self::checkview_rotate_password_cron();
    377376
    378377        return array(
     
    389388        add_filter( 'pre_wp_mail', '__return_false', PHP_INT_MAX );
    390389
    391         $customer = $this->checkview_get_test_customer();
     390        $customer = self::checkview_get_test_customer();
    392391
    393392        if ( ! $customer ) {
     
    404403     * @return void
    405404     */
    406     public function checkview_rotate_password_cron() {
     405    public static function checkview_rotate_password_cron() {
    407406        wp_schedule_single_event( time() + 15 * MINUTE_IN_SECONDS, 'checkview_rotate_user_credentials' );
    408407    }
     
    415414     * @return WC_Product/bool
    416415     */
    417     public function checkview_get_test_product() {
     416    public static function checkview_get_test_product() {
    418417        $product_id = get_option( 'checkview_woo_product_id' );
    419418        if ( $product_id ) {
     
    564563     */
    565564    public function checkview_test_mode() {
    566         $visitor_ip = checkview_get_visitor_ip();
    567         $cv_bot_ip = checkview_get_api_ip();
    568 
    569         if ( ! is_array( $cv_bot_ip ) || ! in_array( $visitor_ip, $cv_bot_ip ) ) {
     565        $is_bot = CheckView::is_bot();
     566
     567        if ( ! $is_bot ) {
    570568            return;
    571569        }
    572570
    573         Checkview_Admin_Logs::add( 'ip-logs', 'Running Woo test mode hooks, visitor IP [' . $visitor_ip . '] matched a bot IP.' );
     571        $cookie = CheckView::has_cookie();
     572
     573        if ( $cookie !== 'woo_checkout' ) {
     574            return;
     575        }
     576
     577        Checkview_Admin_Logs::add( 'ip-logs', 'Running Woo test mode hooks, visitor is bot and cookie value equals [' . $cookie . '].' );
    574578
    575579        if ( ! is_admin() && class_exists( 'WooCommerce' ) ) {
     
    783787     * Doesn't run on AJAX requests.
    784788     *
    785      * @return void
    786      */
    787     public function delete_orders_from_backend() {
     789     * @return boolean
     790     */
     791    public static function delete_orders_from_backend() {
    788792        if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
    789             return;
    790         }
    791 
    792         return $this->checkview_delete_orders();
     793            return false;
     794        }
     795
     796        return self::checkview_delete_orders();
    793797    }
    794798
     
    799803     * @return bool
    800804     */
    801     public function checkview_delete_orders( $order_id = '' ) {
     805    public static function checkview_delete_orders( $order_id = '' ) {
    802806        Checkview_Admin_Logs::add( 'ip-logs', 'Deleting CheckView orders from the database...' );
    803807
Note: See TracChangeset for help on using the changeset viewer.