Plugin Directory

Changeset 3303097


Ignore:
Timestamp:
05/29/2025 04:12:42 PM (7 months ago)
Author:
checkview
Message:

Update to version 2.0.18 from GitHub

Location:
checkview
Files:
12 edited
1 copied

Legend:

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

    r3296900 r3303097  
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
    10 Stable tag: 2.0.17
     10Stable tag: 2.0.18
    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.18 =
     89* Improve logging when querying for available test results.
     90* Increase JWT leeway.
     91* Remove unreachable/unnecessary code.
     92* Retrieve WooCommerce order IDs via method instead of protected property.
     93
    8894= 2.0.17 =
    8995* Add polyfill for array_find function.
     
    354360
    355361== Upgrade Notice ==
     362= 2.0.18 =
     363* Improve logging when querying for available test results.
     364* Increase JWT leeway.
     365* Remove unreachable/unnecessary code.
     366* Retrieve WooCommerce order IDs via method instead of protected property.
     367
    356368= 2.0.17 =
    357369* Add polyfill for array_find function.
  • checkview/tags/2.0.18/checkview.php

    r3296900 r3303097  
    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.17
     14 * Version:           2.0.18
    1515 * Author:            CheckView
    1616 * Author URI:        https://checkview.io/
     
    3636 * @link https://semver.org
    3737 */
    38 define( 'CHECKVIEW_VERSION', '2.0.17' );
     38define( 'CHECKVIEW_VERSION', '2.0.18' );
    3939
    4040if ( ! defined( 'CHECKVIEW_BASE_DIR' ) ) {
  • checkview/tags/2.0.18/includes/API/class-checkview-api.php

    r3236719 r3303097  
    1919class CheckView_Api {
    2020    /**
    21      * Plugin name.
     21     * Woo Helper class.
    2222     *
    2323     * @since 1.0.0
    2424     * @access private
    2525     *
    26      * @var string $plugin_name The ID of this plugin.
    27      */
    28     private $plugin_name;
    29 
    30     /**
    31      * Plugin version.
     26     * @var bool/Checkview_Woo_Automated_Testing $woo_helper The woo helper of this plugin.
     27     */
     28    private $woo_helper;
     29    /**
     30     * Holds the JWT error.
     31     *
     32     * @var WP_Error
     33     */
     34    public $jwt_error = null;
     35    /**
     36     * Constructor.
     37     *
     38     * Sets class properties.
    3239     *
    3340     * @since 1.0.0
    34      * @access private
    35      *
    36      * @var string $version The current version of this plugin.
    37      */
    38     private $version;
    39 
    40     /**
    41      * Woo Helper class.
    42      *
    43      * @since 1.0.0
    44      * @access private
    45      *
    46      * @var bool/Checkview_Woo_Automated_Testing $woo_helper The woo helper of this plugin.
    47      */
    48     private $woo_helper;
    49     /**
    50      * Holds the JWT error.
    51      *
    52      * @var WP_Error
    53      */
    54     public $jwt_error = null;
    55     /**
    56      * Constructor.
    57      *
    58      * Sets class properties.
    59      *
    60      * @since 1.0.0
    61      *
    62      * @param string $plugin_name The name of the plugin.
    63      * @param string $version The version of this plugin.
    64      * @param class  $woo_helper The woohelper class.
    65      */
    66     public function __construct( $plugin_name, $version, $woo_helper = '' ) {
    67 
    68         $this->plugin_name = $plugin_name;
    69         $this->version     = $version;
     41     *
     42     * @param Checkview_Woo_Automated_Testing $woo_helper The woohelper class.
     43     */
     44    public function __construct( $woo_helper = '' ) {
    7045        $this->woo_helper  = $woo_helper;
    7146    }
     47
    7248    /**
    7349     * Registers API routes.
     
    456432            )
    457433        );// end checkview_register_rest_route.
    458 
    459         register_rest_route(
    460             'checkview/v1',
    461             '/confirm-site',
    462             array(
    463                 'methods'             => 'POST',
    464                 'callback'            => array( $this, 'checkview_confirm_site_callback' ),
    465                 'permission_callback' => '__return_true', // Restrict access as needed.
    466             )
    467         );
    468434    }
    469435
     
    476442     *
    477443     * @param WP_REST_Request $request Request object.
    478      * @return WP_REST_Response/json
     444     * @return WP_REST_Response|WP_Error
    479445     */
    480446    public function checkview_get_available_orders( WP_REST_Request $request ) {
    481447        if ( ! class_exists( 'WooCommerce' ) ) {
    482448            Checkview_Admin_Logs::add( 'api-logs', 'WooCommerce not found.' );
     449
    483450            return new WP_REST_Response(
    484451                array(
     
    504471        if ( isset( $this->jwt_error ) && null !== $this->jwt_error ) {
    505472            Checkview_Admin_Logs::add( 'api-logs', $this->jwt_error );
     473
    506474            return new WP_Error(
    507475                400,
    508476                esc_html__( 'Invalid request.', 'checkview' ),
    509477            );
    510             wp_die();
    511478        }
    512479
     
    519486                )
    520487            );
    521             wp_die();
    522488        }
    523489        $orders = array();
     
    526492        }
    527493
    528         $per_page = -1;
     494        $per_page = - 1;
    529495
    530496        $params = array();
    531497
    532498        $args = array(
    533             'limit'          => -1,
     499            'limit'          => - 1,
    534500            'payment_method' => 'checkview',
    535501            'meta_query'     => array(
     
    564530            if ( $wc_orders ) {
    565531                foreach ( $wc_orders as $order ) {
    566                     $order_object                 = new WC_Order( $order->id );
    567                     $order_details['order_id']    = $order->id;
     532                    $order_object                 = new WC_Order( $order->get_id() );
     533                    $order_details['order_id']    = $order->get_id();
    568534                    $order_details['customer_id'] = $order_object->get_customer_id();
    569535                    $orders[]                     = $order_details;
     
    575541        if ( $orders && ! empty( $orders ) && false !== $orders && '' !== $orders ) {
    576542            set_transient( 'checkview_store_orders_transient', $orders, 12 * HOUR_IN_SECONDS );
     543
    577544            return new WP_REST_Response(
    578545                array(
     
    591558            );
    592559        }
    593         wp_die();
    594560    }
    595561
     
    598564     *
    599565     * @param WP_REST_Request $request Request object.
    600      * @return WP_REST_Response/json
     566     * @return WP_REST_Response|WP_Error
    601567     */
    602568    public function checkview_get_available_order_details( WP_REST_Request $request ) {
     
    620586                esc_html__( 'Invalid request.', 'checkview' ),
    621587            );
    622             wp_die();
    623588        }
    624589
     
    775740            );
    776741        }
    777         wp_die();
    778742    }
    779743    /**
     
    781745     *
    782746     * @param WP_REST_Request $request Request object.
    783      * @return WP_REST_Response/json
     747     * @return WP_REST_Response|WP_Error
    784748     */
    785749    public function checkview_get_available_products( WP_REST_Request $request ) {
     
    806770                esc_html__( 'Invalid request.', 'checkview' ),
    807771            );
    808             wp_die();
    809772        }
    810773        if ( '' !== $products && null !== $products && false !== $products ) {
     
    816779                )
    817780            );
    818             wp_die();
    819781        }
    820782        $products = array();
     
    905867            );
    906868        }
    907         wp_die();
    908869    }
    909870
     
    913874     * Firstly, attempts to retrieve details from the cache.
    914875     *
    915      * @return WP_REST_Response
     876     * @return WP_REST_Response|WP_Error
    916877     */
    917878    public function checkview_get_available_shipping_details() {
     
    935896                esc_html__( 'Invalid request.', 'checkview' ),
    936897            );
    937             wp_die();
    938898        }
    939899        if ( '' !== $shipping_details && null !== $shipping_details && false !== $shipping_details ) {
     
    945905                )
    946906            );
    947             wp_die();
    948907        }
    949908        $country_class                   = new WC_Countries();
     
    1028987            );
    1029988        }
    1030         wp_die();
    1031989    }
    1032990    /**
     
    1034992     *
    1035993     * @param WP_REST_Request $request Request object.
    1036      * @return WP_REST_Response/WP_Error/json
     994     * @return WP_REST_Response|WP_Error
    1037995     */
    1038996    public function checkview_delete_orders( WP_REST_Request $request ) {
     
    10531011                esc_html__( 'Invalid request.', 'checkview' ),
    10541012            );
    1055             wp_die();
    10561013        }
    10571014        global $wpdb;
     
    10991056                )
    11001057            );
    1101             wp_die();
    11021058        } else {
    11031059            Checkview_Admin_Logs::add( 'api-logs', 'Empty records.' );
     
    11061062                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    11071063            );
    1108             wp_die();
    11091064        }
    11101065    }
     
    11131068     * Retrieves information from the site's WooCommerce API cart endpoint.
    11141069     *
    1115      * @return WP_REST_Response/WP_Error/json
     1070     * @return WP_REST_Response|WP_Error
    11161071     */
    11171072    public function checkview_get_cart_details() {
     
    11321087                esc_html__( 'Invalid request.', 'checkview' ),
    11331088            );
    1134             wp_die();
    11351089        }
    11361090        $url     = home_url( 'wp-json/wc/store/v1/cart' );
     
    11591113                esc_html__( 'There was a technical issue while processing your request', 'checkview' ),
    11601114            );
    1161             wp_die();
    11621115        } else {
    11631116            $body         = wp_remote_retrieve_body( $response );
     
    11751128                )
    11761129            );
    1177             wp_die();
    11781130        } else {
    11791131            return new WP_Error(
     
    11811133                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    11821134            );
    1183             wp_die();
    11841135        }
    11851136    }
     
    11881139     * Retrieves a list of active payment gateways.
    11891140     *
    1190      * @return WP_REST_Response/WP_Error/json
     1141     * @return WP_REST_Response|WP_Error
    11911142     */
    11921143    public function checkview_get_active_payment_gateways() {
     
    12071158                esc_html__( 'Invalid request.', 'checkview' ),
    12081159            );
    1209             wp_die();
    12101160        }
    12111161        $active_gateways = $this->woo_helper->get_active_payment_gateways();
     
    12181168                )
    12191169            );
    1220             wp_die();
    12211170        } else {
    12221171            // Log the detailed error for internal use.
     
    12291178                ),
    12301179            );
    1231             wp_die();
    12321180        }
    12331181    }
     
    12361184     * Creates the testing customer.
    12371185     *
    1238      * @return WP_REST_Response/WP_Error/json
     1186     * @return WP_REST_Response|WP_Error
    12391187     */
    12401188    public function checkview_create_test_customer() {
     
    12551203                esc_html__( 'Invalid request.', 'checkview' ),
    12561204            );
    1257             wp_die();
    12581205        }
    12591206        $customer = $this->woo_helper->checkview_create_test_customer();
     
    12661213                )
    12671214            );
    1268             wp_die();
    12691215        } else {
    12701216            Checkview_Admin_Logs::add( 'api-logs', 'Failed to create the customer.' );
     
    12731219                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    12741220            );
    1275             wp_die();
    12761221        }
    12771222    }
     
    12801225     * Retrieves credentials about the testing customer.
    12811226     *
    1282      * @return WP_REST_Response/WP_Error/json
     1227     * @return WP_REST_Response|WP_Error
    12831228     */
    12841229    public function checkview_get_test_customer_credentials() {
     
    12991244                esc_html__( 'Invalid request.', 'checkview' ),
    13001245            );
    1301             wp_die();
    13021246        }
    13031247        $customer = $this->woo_helper->checkview_get_test_credentials();
     
    13101254                )
    13111255            );
    1312             wp_die();
    13131256        } else {
    13141257            Checkview_Admin_Logs::add( 'api-logs', 'Failed to retrieve the customer.' );
     
    13171260                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    13181261            );
    1319             wp_die();
    13201262        }
    13211263    }
     
    13271269     *
    13281270     * @param WP_REST_Request $request Request object.
    1329      * @return WP_REST_Response/WP_Error/json
     1271     * @return WP_REST_Response|WP_Error
    13301272     */
    13311273    public function checkview_verify_test_user_credentials( WP_REST_Request $request ) {
     
    13361278                esc_html__( 'Invalid request.', 'checkview' ),
    13371279            );
    1338             wp_die();
    13391280        }
    13401281        $user_email = $request->get_param( 'user_email' );
    1341         $user_email = isset( $user_email ) ? sanitize_email( user_email ) : null;
     1282        $user_email = isset( $user_email ) ? sanitize_email( $user_email ) : null;
    13421283        if ( null === $user_email || empty( $user_email ) ) {
    13431284            return new WP_Error(
     
    13451286                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    13461287            );
    1347             wp_die();
    13481288        }
    13491289        $user = email_exists( $user_email );
     
    13571297                )
    13581298            );
    1359             wp_die();
    13601299        } else {
    13611300            Checkview_Admin_Logs::add( 'api-logs', 'Failed to retrieve the user.' );
     
    13641303                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    13651304            );
    1366             wp_die();
    13671305        }
    13681306    }
     
    13721310     *
    13731311     * @param WP_REST_Request $request Request object.
    1374      * @return WP_REST_Response/WP_Error/json
     1312     * @return WP_REST_Response|WP_Error
    13751313     */
    13761314    public function checkview_delete_test_user_credentials( WP_REST_Request $request ) {
     
    13811319                esc_html__( 'Invalid request.', 'checkview' ),
    13821320            );
    1383             wp_die();
    13841321        }
    13851322        $user_email = $request->get_param( 'user_email' );
    1386         $user_email = isset( $user_email ) ? sanitize_email( user_email ) : null;
     1323        $user_email = isset( $user_email ) ? sanitize_email( $user_email ) : null;
    13871324        if ( null === $user_email || empty( $user_email ) ) {
    13881325            return new WP_Error(
     
    13901327                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    13911328            );
    1392             wp_die();
    13931329        }
    13941330        $user = email_exists( $user_email );
     
    14061342                    )
    14071343                );
    1408                 wp_die();
    14091344            } else {
    14101345                Checkview_Admin_Logs::add( 'api-logs', 'Failed to delete the user.' );
     
    14131348                    esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    14141349                );
    1415                 wp_die();
    1416             }
    1417             wp_die();
     1350            }
    14181351        } else {
    14191352            Checkview_Admin_Logs::add( 'api-logs', 'Failed to retrieve the user.' );
     
    14221355                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    14231356            );
    1424             wp_die();
    14251357        }
    14261358    }
     
    14311363     * Retrieves a list of shipping and selling locations.
    14321364     *
    1433      * @return WP_REST_Response/json
     1365     * @return WP_REST_Response|WP_Error
    14341366     */
    14351367    public function checkview_get_store_locations() {
     
    14501382                esc_html__( 'Invalid request.', 'checkview' ),
    14511383            );
    1452             wp_die();
    14531384        }
    14541385        $selling_locations = array();
     
    14741405                )
    14751406            );
    1476             wp_die();
    14771407        } else {
    14781408            Checkview_Admin_Logs::add( 'api-logs', 'Failed to retrieve the store locations.' );
     
    14811411                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    14821412            );
    1483             wp_die();
    14841413        }
    14851414    }
     
    14881417     * Retrieves the permalink of the test product.
    14891418     *
    1490      * @return WP_REST_Response/json
     1419     * @return WP_REST_Response|WP_Error
    14911420     */
    14921421    public function checkview_get_store_test_product() {
     
    15071436                esc_html__( 'Invalid request.', 'checkview' ),
    15081437            );
    1509             wp_die();
    15101438        }
    15111439        $product                              = $this->woo_helper->checkview_get_test_product();
     
    15191447                )
    15201448            );
    1521             wp_die();
    15221449        } else {
    15231450            Checkview_Admin_Logs::add( 'api-logs', 'Failed to retrieve the test product.' );
     
    15261453                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    15271454            );
    1528             wp_die();
    15291455        }
    15301456    }
     
    15331459     * Retrieves a list of supported forms used throughout the site.
    15341460     *
    1535      * @return WP_REST_Response/json
     1461     * @return WP_REST_Response|WP_Error
    15361462     */
    15371463    public function checkview_get_available_forms_list() {
     
    15441470                esc_html__( 'Invalid request.', 'checkview' ),
    15451471            );
    1546             wp_die();
    15471472        }
    15481473        // Temporarily suppress errors.
     
    15571482                )
    15581483            );
    1559             wp_die();
    15601484        }
    15611485        $forms = array();
     
    20031927            );
    20041928        }
    2005         wp_die();
    20061929    }
    20071930
     
    20101933     *
    20111934     * @param WP_REST_Request $request Request param with the API call.
    2012      * @return WP_REST_Response/WP_Error/json
     1935     * @return WP_REST_Response|WP_Error
    20131936     */
    20141937    public function checkview_get_available_forms_test_results( WP_REST_Request $request ) {
    20151938        global $wpdb;
     1939
    20161940        $uid     = $request->get_param( 'uid' );
    20171941        $uid     = isset( $uid ) ? sanitize_text_field( $uid ) : null;
    20181942        $results = array();
     1943
    20191944        if ( '' === $uid || null === $uid ) {
    20201945            Checkview_Admin_Logs::add( 'api-logs', $this->jwt_error );
    2021             return new WP_Error(
    2022                 400,
    2023                 esc_html__( 'Insuficient data.', 'checkview' ),
    2024             );
    2025             wp_die();
     1946
     1947            return new WP_Error(
     1948                400,
     1949                esc_html__( 'Insufficient data.', 'checkview' ),
     1950            );
    20261951        } else {
    2027             $tablename = $wpdb->prefix . 'cv_entry';
    2028             $result    = $wpdb->get_row( $wpdb->prepare( 'Select * from ' . $tablename . ' where uid=%s', $uid ) );
    2029             $tablename = $wpdb->prefix . 'cv_entry_meta';
    2030             $rows      = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where uid=%s order by id ASC', $uid ) );
    2031             if ( $rows ) {
    2032                 foreach ( $rows as $row ) {
    2033                     if ( 'gravityforms' === strtolower( $result->form_type ) ) {
    2034                         $results[] = array(
    2035                             'field_id'    => 'input_' . $row->form_id . '_' . str_replace( '.', '_', $row->meta_key ),
    2036                             'field_value' => $row->meta_value,
    2037                         );
    2038 
    2039                     } elseif ( 'cf7' === strtolower( $result->form_type ) ) {
    2040                         $value = $row->meta_value;
    2041                         if ( strpos( $value, 'htt' ) !== false ) {
    2042                             $value = html_entity_decode( $value );
    2043                         }
    2044                         $results[] = array(
    2045                             'field_id'    => '',
    2046                             'field_name'  => $row->meta_key,
    2047                             'field_value' => $value,
    2048                         );
    2049                     } elseif ( 'Forminator' === $result->form_type ) {
    2050                         $value = $row->meta_value;
    2051                         if ( strpos( $value, 'htt' ) !== false ) {
    2052                             $value = html_entity_decode( $value );
    2053                         }
    2054                         $results[] = array(
    2055                             'field_id'    => '',
    2056                             'field_name'  => $row->meta_key,
    2057                             'field_value' => $value,
    2058                         );
    2059                     } else {
    2060 
    2061                         $results[] = array(
    2062                             'field_id'    => $row->meta_key,
    2063                             'field_value' => maybe_unserialize( $row->meta_value ),
    2064                         );
     1952            $table_name    = $wpdb->prefix . 'cv_entry';
     1953            $query         = $wpdb->prepare( 'Select * from ' . $table_name . ' where uid=%s', $uid );
     1954            $query_as_json = wp_json_encode( array( 'query' => $query ) );
     1955            $result        = $wpdb->get_row( $query ); // We expect an object
     1956
     1957            if ( is_null( $result ) ) {
     1958                Checkview_Admin_Logs::add( 'api-logs', 'Failed to find test results (query [' . $query_as_json . '] returned null).' );
     1959
     1960                return new WP_Error(
     1961                    400,
     1962                    esc_html__( 'Failed to find test results (query [' . $query_as_json . '] returned null).', 'checkview' ),
     1963                );
     1964            }
     1965
     1966            if ( ! is_object( $result ) ) {
     1967                Checkview_Admin_Logs::add( 'api-logs', 'Failed to find test results (query [' . $query_as_json . '] returned unexpected type [' . gettype( $result ) . ']).' );
     1968
     1969                return new WP_Error(
     1970                    400,
     1971                    esc_html__( 'Failed to find test results (query [' . $query_as_json . '] returned unexpected type [' . gettype( $result ) . ']).', 'checkview' ),
     1972                );
     1973            }
     1974
     1975            $table_name         = $wpdb->prefix . 'cv_entry_meta';
     1976            $query              = $wpdb->prepare( 'Select * from ' . $table_name . ' where uid=%s order by id ASC', $uid );
     1977            $meta_query_as_json = wp_json_encode( array( 'query' => $query ) );
     1978            $rows               = $wpdb->get_results( $query ); // We expect an array of objects
     1979
     1980            if ( is_null( $rows ) ) {
     1981                Checkview_Admin_Logs::add( 'api-logs', 'Failed to find test results (query [' . $meta_query_as_json . '] returned null).' );
     1982
     1983                return new WP_Error(
     1984                    400,
     1985                    esc_html__( 'Failed to find test results (query [' . $meta_query_as_json . '] returned null).', 'checkview' ),
     1986                );
     1987            }
     1988
     1989            if ( ! is_array( $rows ) ) {
     1990                Checkview_Admin_Logs::add( 'api-logs', 'Failed to find test results (query [' . $meta_query_as_json . '] returned unexpected type [' . gettype( $rows ) . ']).' );
     1991
     1992                return new WP_Error(
     1993                    400,
     1994                    esc_html__( 'Failed to find test results (query [' . $meta_query_as_json . '] returned unexpected type [' . gettype( $rows ) . ']).', 'checkview' ),
     1995                );
     1996            }
     1997
     1998            foreach ( $rows as $row ) {
     1999                if ( 'gravityforms' === strtolower( $result->form_type ) ) {
     2000                    $results[] = array(
     2001                        'field_id'    => 'input_' . $row->form_id . '_' . str_replace( '.', '_', $row->meta_key ),
     2002                        'field_value' => $row->meta_value,
     2003                    );
     2004                } elseif ( 'cf7' === strtolower( $result->form_type ) ) {
     2005                    $value = $row->meta_value;
     2006
     2007                    if ( strpos( $value, 'htt' ) !== false ) {
     2008                        $value = html_entity_decode( $value );
    20652009                    }
    2066                 }
    2067                 if ( ! empty( $results ) && false !== $results ) {
    2068                     return new WP_REST_Response(
    2069                         array(
    2070                             'status'        => 200,
    2071                             'response'      => esc_html__( 'Successfully retrieved the results.', 'checkview' ),
    2072                             'body_response' => $results,
    2073                         )
     2010
     2011                    $results[] = array(
     2012                        'field_id'    => '',
     2013                        'field_name'  => $row->meta_key,
     2014                        'field_value' => $value,
     2015                    );
     2016                } elseif ( 'Forminator' === $result->form_type ) {
     2017                    $value = $row->meta_value;
     2018
     2019                    if ( strpos( $value, 'htt' ) !== false ) {
     2020                        $value = html_entity_decode( $value );
     2021                    }
     2022
     2023                    $results[] = array(
     2024                        'field_id'    => '',
     2025                        'field_name'  => $row->meta_key,
     2026                        'field_value' => $value,
    20742027                    );
    20752028                } else {
    2076                     Checkview_Admin_Logs::add( 'api-logs', 'Failed to retrieve the results.' );
    2077                     return new WP_Error(
    2078                         400,
    2079                         esc_html__( 'An error occurred while processing your request.', 'checkview' ),
     2029                    $results[] = array(
     2030                        'field_id'    => $row->meta_key,
     2031                        'field_value' => maybe_unserialize( $row->meta_value ),
    20802032                    );
    20812033                }
    2082                 wp_die();
    2083             } else {
    2084                 Checkview_Admin_Logs::add( 'api-logs', 'Failed to retrieve the results.' );
    2085                 return new WP_Error(
    2086                     400,
    2087                     esc_html__( 'An error occurred while processing your request.', 'checkview' ),
     2034            }
     2035
     2036            if ( ! empty( $results ) ) {
     2037                return new WP_REST_Response(
     2038                    array(
     2039                        'status'        => 200,
     2040                        'response'      => esc_html__( 'Successfully retrieved the results.', 'checkview' ),
     2041                        'body_response' => $results,
     2042                    )
    20882043                );
    2089                 wp_die();
    2090             }
     2044            }
     2045            Checkview_Admin_Logs::add( 'api-logs', 'Failed to find test results (rows were found, but results were determined to be empty).' );
     2046
     2047            return new WP_Error(
     2048                400,
     2049                esc_html__( 'Failed to find test results (rows were found, but results were determined to be empty).', 'checkview' ),
     2050            );
    20912051        }
    20922052    }
     
    20982058     *
    20992059     * @param WP_REST_Request $request Object with the API call.
    2100      * @return WP_REST_Response/WP_Error
     2060     * @return WP_REST_Response|WP_Error
    21012061     */
    21022062    public function checkview_register_form_test( WP_REST_Request $request ) {
     
    21242084                )
    21252085            );
    2126             wp_die();
    21272086        } else {
    21282087            Checkview_Admin_Logs::add( 'api-logs', sanitize_text_field( 'Details to register form test are not correct.' ) );
     
    21312090                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    21322091            );
    2133             wp_die();
    21342092        }
    21352093    }
     
    21412099     *
    21422100     * @param WP_REST_Request $request Request param with the API call.
    2143      * @return WP_REST_Response/WP_Error/json
     2101     * @return WP_REST_Response|WP_Error
    21442102     */
    21452103    public function checkview_delete_forms_test_results( WP_REST_Request $request ) {
     
    21602118                esc_html__( 'Insuficient data.', 'checkview' ),
    21612119            );
    2162             wp_die();
    21632120        } else {
    21642121            $rows = true;
     
    21712128                    )
    21722129                );
    2173                 wp_die();
    21742130            } else {
    21752131                Checkview_Admin_Logs::add( 'api-logs', sanitize_text_field( 'Failed to remove the results.' ) );
     
    21782134                    esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    21792135                );
    2180                 wp_die();
    21812136            }
    21822137        }
     
    21892144     * version, and the admin AJAX url.
    21902145     *
    2191      * @return WP_Rest_Response Forms details.
     2146     * @return WP_Rest_Response|WP_Error
    21922147     */
    21932148    public function checkview_saas_get_site_info() {
     
    22742229     *
    22752230     * @param WP_REST_Request $request WP_Request object.
    2276      * @return Json/WP Error
     2231     * @return WP_REST_Response|WP_Error
    22772232     */
    22782233    public function checkview_saas_get_plugin_version( WP_REST_Request $request ) {
     
    22842239                esc_html__( 'Invalid request.', 'checkview' ),
    22852240            );
    2286             wp_die();
    22872241        }
    22882242        // Get all plugins.
     
    23412295     * Returns plugin logs.
    23422296     *
    2343      * @return WP_Rest_Response log details.
     2297     * @return WP_REST_Response|WP_Error
    23442298     */
    23452299    public function checkview_saas_get_helper_logs() {
     
    24002354     * Sets status for helper plugin.
    24012355     *
    2402      * @param \WP_REST_Request $request wp request object.
    2403      * @return WP_Error/WP_REST_RESPONSE
     2356     * @param WP_REST_Request $request wp request object.
     2357     * @return WP_REST_Response|WP_Error
    24042358     */
    24052359    public function checkview_saas_set_helper_status( \WP_REST_Request $request ) {
     
    24302384
    24312385    /**
    2432      * Sets status for test product..
    2433      *
    2434      * @param \WP_REST_Request $request wp request object.
    2435      * @return WP_Error/WP_REST_RESPONSE
     2386     * Sets status for test product.
     2387     *
     2388     * @param WP_REST_Request $request wp request object.
     2389     * @return WP_REST_Response|WP_Error
    24362390     */
    24372391    public function checkview_saas_set_test_product_status( \WP_REST_Request $request ) {
     
    24522406                esc_html__( 'Invalid request.', 'checkview' ),
    24532407            );
    2454             wp_die();
    24552408        }
    24562409        // Get the status from the request parameters.
     
    24922445     * On success, stores the nonce token so it will not be used again.
    24932446     *
    2494      * @param \WP_REST_Request $request request data with the api call.
    2495      * @return json/array
     2447     * @param WP_REST_Request $request request data with the api call.
     2448     * @return WP_Error|array
    24962449     */
    24972450    public function checkview_get_items_permissions_check( \WP_REST_Request $request ) {
     
    25082461                ''
    25092462            );
    2510             wp_die();
    25112463        }
    25122464
     
    25182470                array( 'status' => 400 )
    25192471            );
    2520             wp_die();
    25212472        }
    25222473        $nonce_token = checkview_validate_jwt_token( $auth_header );
     
    25312482                ''
    25322483            );
    2533             wp_die();
    25342484        }
    25352485        if ( ! checkview_is_valid_uuid( $nonce_token ) ) {
     
    25402490                ''
    25412491            );
    2542             wp_die();
    25432492        }
    25442493        global $wpdb;
     
    25872536                ''
    25882537            );
    2589             wp_die();
    25902538        } else {
    25912539            // Store the nonce in the database.
     
    26032551                    )
    26042552                );
    2605                 wp_die();
    26062553            }
    26072554        }
  • checkview/tags/2.0.18/includes/checkview-functions.php

    r3296900 r3303097  
    7575        try {
    7676            // Allow one-second leeway for JWT tokens
    77             JWT::$leeway = 1;
     77            JWT::$leeway = 5;
    7878            $decoded = JWT::decode( $token, new Key( $key, 'RS256' ) );
    7979        } catch ( Exception $e ) {
  • checkview/tags/2.0.18/includes/class-checkview.php

    r3296900 r3303097  
    5555     * @access private
    5656     *
    57      * @var class $instance The instance of the class.
     57     * @var Checkview $instance The instance of the class.
    5858     */
    5959
     
    7171            $this->version = CHECKVIEW_VERSION;
    7272        } else {
    73             $this->version = '2.0.17';
     73            $this->version = '2.0.18';
    7474        }
    7575        $this->plugin_name = 'checkview';
     
    154154
    155155        // Initialize the plugin's API.
    156         $plugin_api = new CheckView_Api( $this->get_plugin_name(), $this->get_version(), $woo_helper );
     156        $plugin_api = new CheckView_Api( $woo_helper );
    157157
    158158        // Hook our routes into WordPress.
  • checkview/tags/2.0.18/includes/woocommercehelper/class-checkview-woo-automated-testing.php

    r3283610 r3303097  
    7373     * @param string $plugin_name The name of this plugin.
    7474     * @param string $version The version of this plugin.
    75      * @param string $loader Loads the hooks.
     75     * @param Checkview_Loader $loader Loads the hooks.
    7676     */
    7777    public function __construct( $plugin_name, $version, $loader ) {
    78 
    7978        $this->plugin_name      = $plugin_name;
    8079        $this->version          = $version;
     
    8281        $this->suppress_email   = get_option( 'disable_email_receipt', false );
    8382        $this->suppress_webhook = get_option( 'disable_webhooks', false );
     83
    8484        if ( $this->loader ) {
    8585            $this->loader->add_action(
  • checkview/trunk/README.txt

    r3296900 r3303097  
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
    10 Stable tag: 2.0.17
     10Stable tag: 2.0.18
    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.18 =
     89* Improve logging when querying for available test results.
     90* Increase JWT leeway.
     91* Remove unreachable/unnecessary code.
     92* Retrieve WooCommerce order IDs via method instead of protected property.
     93
    8894= 2.0.17 =
    8995* Add polyfill for array_find function.
     
    354360
    355361== Upgrade Notice ==
     362= 2.0.18 =
     363* Improve logging when querying for available test results.
     364* Increase JWT leeway.
     365* Remove unreachable/unnecessary code.
     366* Retrieve WooCommerce order IDs via method instead of protected property.
     367
    356368= 2.0.17 =
    357369* Add polyfill for array_find function.
  • checkview/trunk/checkview.php

    r3296900 r3303097  
    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.17
     14 * Version:           2.0.18
    1515 * Author:            CheckView
    1616 * Author URI:        https://checkview.io/
     
    3636 * @link https://semver.org
    3737 */
    38 define( 'CHECKVIEW_VERSION', '2.0.17' );
     38define( 'CHECKVIEW_VERSION', '2.0.18' );
    3939
    4040if ( ! defined( 'CHECKVIEW_BASE_DIR' ) ) {
  • checkview/trunk/includes/API/class-checkview-api.php

    r3236719 r3303097  
    1919class CheckView_Api {
    2020    /**
    21      * Plugin name.
     21     * Woo Helper class.
    2222     *
    2323     * @since 1.0.0
    2424     * @access private
    2525     *
    26      * @var string $plugin_name The ID of this plugin.
    27      */
    28     private $plugin_name;
    29 
    30     /**
    31      * Plugin version.
     26     * @var bool/Checkview_Woo_Automated_Testing $woo_helper The woo helper of this plugin.
     27     */
     28    private $woo_helper;
     29    /**
     30     * Holds the JWT error.
     31     *
     32     * @var WP_Error
     33     */
     34    public $jwt_error = null;
     35    /**
     36     * Constructor.
     37     *
     38     * Sets class properties.
    3239     *
    3340     * @since 1.0.0
    34      * @access private
    35      *
    36      * @var string $version The current version of this plugin.
    37      */
    38     private $version;
    39 
    40     /**
    41      * Woo Helper class.
    42      *
    43      * @since 1.0.0
    44      * @access private
    45      *
    46      * @var bool/Checkview_Woo_Automated_Testing $woo_helper The woo helper of this plugin.
    47      */
    48     private $woo_helper;
    49     /**
    50      * Holds the JWT error.
    51      *
    52      * @var WP_Error
    53      */
    54     public $jwt_error = null;
    55     /**
    56      * Constructor.
    57      *
    58      * Sets class properties.
    59      *
    60      * @since 1.0.0
    61      *
    62      * @param string $plugin_name The name of the plugin.
    63      * @param string $version The version of this plugin.
    64      * @param class  $woo_helper The woohelper class.
    65      */
    66     public function __construct( $plugin_name, $version, $woo_helper = '' ) {
    67 
    68         $this->plugin_name = $plugin_name;
    69         $this->version     = $version;
     41     *
     42     * @param Checkview_Woo_Automated_Testing $woo_helper The woohelper class.
     43     */
     44    public function __construct( $woo_helper = '' ) {
    7045        $this->woo_helper  = $woo_helper;
    7146    }
     47
    7248    /**
    7349     * Registers API routes.
     
    456432            )
    457433        );// end checkview_register_rest_route.
    458 
    459         register_rest_route(
    460             'checkview/v1',
    461             '/confirm-site',
    462             array(
    463                 'methods'             => 'POST',
    464                 'callback'            => array( $this, 'checkview_confirm_site_callback' ),
    465                 'permission_callback' => '__return_true', // Restrict access as needed.
    466             )
    467         );
    468434    }
    469435
     
    476442     *
    477443     * @param WP_REST_Request $request Request object.
    478      * @return WP_REST_Response/json
     444     * @return WP_REST_Response|WP_Error
    479445     */
    480446    public function checkview_get_available_orders( WP_REST_Request $request ) {
    481447        if ( ! class_exists( 'WooCommerce' ) ) {
    482448            Checkview_Admin_Logs::add( 'api-logs', 'WooCommerce not found.' );
     449
    483450            return new WP_REST_Response(
    484451                array(
     
    504471        if ( isset( $this->jwt_error ) && null !== $this->jwt_error ) {
    505472            Checkview_Admin_Logs::add( 'api-logs', $this->jwt_error );
     473
    506474            return new WP_Error(
    507475                400,
    508476                esc_html__( 'Invalid request.', 'checkview' ),
    509477            );
    510             wp_die();
    511478        }
    512479
     
    519486                )
    520487            );
    521             wp_die();
    522488        }
    523489        $orders = array();
     
    526492        }
    527493
    528         $per_page = -1;
     494        $per_page = - 1;
    529495
    530496        $params = array();
    531497
    532498        $args = array(
    533             'limit'          => -1,
     499            'limit'          => - 1,
    534500            'payment_method' => 'checkview',
    535501            'meta_query'     => array(
     
    564530            if ( $wc_orders ) {
    565531                foreach ( $wc_orders as $order ) {
    566                     $order_object                 = new WC_Order( $order->id );
    567                     $order_details['order_id']    = $order->id;
     532                    $order_object                 = new WC_Order( $order->get_id() );
     533                    $order_details['order_id']    = $order->get_id();
    568534                    $order_details['customer_id'] = $order_object->get_customer_id();
    569535                    $orders[]                     = $order_details;
     
    575541        if ( $orders && ! empty( $orders ) && false !== $orders && '' !== $orders ) {
    576542            set_transient( 'checkview_store_orders_transient', $orders, 12 * HOUR_IN_SECONDS );
     543
    577544            return new WP_REST_Response(
    578545                array(
     
    591558            );
    592559        }
    593         wp_die();
    594560    }
    595561
     
    598564     *
    599565     * @param WP_REST_Request $request Request object.
    600      * @return WP_REST_Response/json
     566     * @return WP_REST_Response|WP_Error
    601567     */
    602568    public function checkview_get_available_order_details( WP_REST_Request $request ) {
     
    620586                esc_html__( 'Invalid request.', 'checkview' ),
    621587            );
    622             wp_die();
    623588        }
    624589
     
    775740            );
    776741        }
    777         wp_die();
    778742    }
    779743    /**
     
    781745     *
    782746     * @param WP_REST_Request $request Request object.
    783      * @return WP_REST_Response/json
     747     * @return WP_REST_Response|WP_Error
    784748     */
    785749    public function checkview_get_available_products( WP_REST_Request $request ) {
     
    806770                esc_html__( 'Invalid request.', 'checkview' ),
    807771            );
    808             wp_die();
    809772        }
    810773        if ( '' !== $products && null !== $products && false !== $products ) {
     
    816779                )
    817780            );
    818             wp_die();
    819781        }
    820782        $products = array();
     
    905867            );
    906868        }
    907         wp_die();
    908869    }
    909870
     
    913874     * Firstly, attempts to retrieve details from the cache.
    914875     *
    915      * @return WP_REST_Response
     876     * @return WP_REST_Response|WP_Error
    916877     */
    917878    public function checkview_get_available_shipping_details() {
     
    935896                esc_html__( 'Invalid request.', 'checkview' ),
    936897            );
    937             wp_die();
    938898        }
    939899        if ( '' !== $shipping_details && null !== $shipping_details && false !== $shipping_details ) {
     
    945905                )
    946906            );
    947             wp_die();
    948907        }
    949908        $country_class                   = new WC_Countries();
     
    1028987            );
    1029988        }
    1030         wp_die();
    1031989    }
    1032990    /**
     
    1034992     *
    1035993     * @param WP_REST_Request $request Request object.
    1036      * @return WP_REST_Response/WP_Error/json
     994     * @return WP_REST_Response|WP_Error
    1037995     */
    1038996    public function checkview_delete_orders( WP_REST_Request $request ) {
     
    10531011                esc_html__( 'Invalid request.', 'checkview' ),
    10541012            );
    1055             wp_die();
    10561013        }
    10571014        global $wpdb;
     
    10991056                )
    11001057            );
    1101             wp_die();
    11021058        } else {
    11031059            Checkview_Admin_Logs::add( 'api-logs', 'Empty records.' );
     
    11061062                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    11071063            );
    1108             wp_die();
    11091064        }
    11101065    }
     
    11131068     * Retrieves information from the site's WooCommerce API cart endpoint.
    11141069     *
    1115      * @return WP_REST_Response/WP_Error/json
     1070     * @return WP_REST_Response|WP_Error
    11161071     */
    11171072    public function checkview_get_cart_details() {
     
    11321087                esc_html__( 'Invalid request.', 'checkview' ),
    11331088            );
    1134             wp_die();
    11351089        }
    11361090        $url     = home_url( 'wp-json/wc/store/v1/cart' );
     
    11591113                esc_html__( 'There was a technical issue while processing your request', 'checkview' ),
    11601114            );
    1161             wp_die();
    11621115        } else {
    11631116            $body         = wp_remote_retrieve_body( $response );
     
    11751128                )
    11761129            );
    1177             wp_die();
    11781130        } else {
    11791131            return new WP_Error(
     
    11811133                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    11821134            );
    1183             wp_die();
    11841135        }
    11851136    }
     
    11881139     * Retrieves a list of active payment gateways.
    11891140     *
    1190      * @return WP_REST_Response/WP_Error/json
     1141     * @return WP_REST_Response|WP_Error
    11911142     */
    11921143    public function checkview_get_active_payment_gateways() {
     
    12071158                esc_html__( 'Invalid request.', 'checkview' ),
    12081159            );
    1209             wp_die();
    12101160        }
    12111161        $active_gateways = $this->woo_helper->get_active_payment_gateways();
     
    12181168                )
    12191169            );
    1220             wp_die();
    12211170        } else {
    12221171            // Log the detailed error for internal use.
     
    12291178                ),
    12301179            );
    1231             wp_die();
    12321180        }
    12331181    }
     
    12361184     * Creates the testing customer.
    12371185     *
    1238      * @return WP_REST_Response/WP_Error/json
     1186     * @return WP_REST_Response|WP_Error
    12391187     */
    12401188    public function checkview_create_test_customer() {
     
    12551203                esc_html__( 'Invalid request.', 'checkview' ),
    12561204            );
    1257             wp_die();
    12581205        }
    12591206        $customer = $this->woo_helper->checkview_create_test_customer();
     
    12661213                )
    12671214            );
    1268             wp_die();
    12691215        } else {
    12701216            Checkview_Admin_Logs::add( 'api-logs', 'Failed to create the customer.' );
     
    12731219                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    12741220            );
    1275             wp_die();
    12761221        }
    12771222    }
     
    12801225     * Retrieves credentials about the testing customer.
    12811226     *
    1282      * @return WP_REST_Response/WP_Error/json
     1227     * @return WP_REST_Response|WP_Error
    12831228     */
    12841229    public function checkview_get_test_customer_credentials() {
     
    12991244                esc_html__( 'Invalid request.', 'checkview' ),
    13001245            );
    1301             wp_die();
    13021246        }
    13031247        $customer = $this->woo_helper->checkview_get_test_credentials();
     
    13101254                )
    13111255            );
    1312             wp_die();
    13131256        } else {
    13141257            Checkview_Admin_Logs::add( 'api-logs', 'Failed to retrieve the customer.' );
     
    13171260                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    13181261            );
    1319             wp_die();
    13201262        }
    13211263    }
     
    13271269     *
    13281270     * @param WP_REST_Request $request Request object.
    1329      * @return WP_REST_Response/WP_Error/json
     1271     * @return WP_REST_Response|WP_Error
    13301272     */
    13311273    public function checkview_verify_test_user_credentials( WP_REST_Request $request ) {
     
    13361278                esc_html__( 'Invalid request.', 'checkview' ),
    13371279            );
    1338             wp_die();
    13391280        }
    13401281        $user_email = $request->get_param( 'user_email' );
    1341         $user_email = isset( $user_email ) ? sanitize_email( user_email ) : null;
     1282        $user_email = isset( $user_email ) ? sanitize_email( $user_email ) : null;
    13421283        if ( null === $user_email || empty( $user_email ) ) {
    13431284            return new WP_Error(
     
    13451286                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    13461287            );
    1347             wp_die();
    13481288        }
    13491289        $user = email_exists( $user_email );
     
    13571297                )
    13581298            );
    1359             wp_die();
    13601299        } else {
    13611300            Checkview_Admin_Logs::add( 'api-logs', 'Failed to retrieve the user.' );
     
    13641303                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    13651304            );
    1366             wp_die();
    13671305        }
    13681306    }
     
    13721310     *
    13731311     * @param WP_REST_Request $request Request object.
    1374      * @return WP_REST_Response/WP_Error/json
     1312     * @return WP_REST_Response|WP_Error
    13751313     */
    13761314    public function checkview_delete_test_user_credentials( WP_REST_Request $request ) {
     
    13811319                esc_html__( 'Invalid request.', 'checkview' ),
    13821320            );
    1383             wp_die();
    13841321        }
    13851322        $user_email = $request->get_param( 'user_email' );
    1386         $user_email = isset( $user_email ) ? sanitize_email( user_email ) : null;
     1323        $user_email = isset( $user_email ) ? sanitize_email( $user_email ) : null;
    13871324        if ( null === $user_email || empty( $user_email ) ) {
    13881325            return new WP_Error(
     
    13901327                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    13911328            );
    1392             wp_die();
    13931329        }
    13941330        $user = email_exists( $user_email );
     
    14061342                    )
    14071343                );
    1408                 wp_die();
    14091344            } else {
    14101345                Checkview_Admin_Logs::add( 'api-logs', 'Failed to delete the user.' );
     
    14131348                    esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    14141349                );
    1415                 wp_die();
    1416             }
    1417             wp_die();
     1350            }
    14181351        } else {
    14191352            Checkview_Admin_Logs::add( 'api-logs', 'Failed to retrieve the user.' );
     
    14221355                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    14231356            );
    1424             wp_die();
    14251357        }
    14261358    }
     
    14311363     * Retrieves a list of shipping and selling locations.
    14321364     *
    1433      * @return WP_REST_Response/json
     1365     * @return WP_REST_Response|WP_Error
    14341366     */
    14351367    public function checkview_get_store_locations() {
     
    14501382                esc_html__( 'Invalid request.', 'checkview' ),
    14511383            );
    1452             wp_die();
    14531384        }
    14541385        $selling_locations = array();
     
    14741405                )
    14751406            );
    1476             wp_die();
    14771407        } else {
    14781408            Checkview_Admin_Logs::add( 'api-logs', 'Failed to retrieve the store locations.' );
     
    14811411                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    14821412            );
    1483             wp_die();
    14841413        }
    14851414    }
     
    14881417     * Retrieves the permalink of the test product.
    14891418     *
    1490      * @return WP_REST_Response/json
     1419     * @return WP_REST_Response|WP_Error
    14911420     */
    14921421    public function checkview_get_store_test_product() {
     
    15071436                esc_html__( 'Invalid request.', 'checkview' ),
    15081437            );
    1509             wp_die();
    15101438        }
    15111439        $product                              = $this->woo_helper->checkview_get_test_product();
     
    15191447                )
    15201448            );
    1521             wp_die();
    15221449        } else {
    15231450            Checkview_Admin_Logs::add( 'api-logs', 'Failed to retrieve the test product.' );
     
    15261453                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    15271454            );
    1528             wp_die();
    15291455        }
    15301456    }
     
    15331459     * Retrieves a list of supported forms used throughout the site.
    15341460     *
    1535      * @return WP_REST_Response/json
     1461     * @return WP_REST_Response|WP_Error
    15361462     */
    15371463    public function checkview_get_available_forms_list() {
     
    15441470                esc_html__( 'Invalid request.', 'checkview' ),
    15451471            );
    1546             wp_die();
    15471472        }
    15481473        // Temporarily suppress errors.
     
    15571482                )
    15581483            );
    1559             wp_die();
    15601484        }
    15611485        $forms = array();
     
    20031927            );
    20041928        }
    2005         wp_die();
    20061929    }
    20071930
     
    20101933     *
    20111934     * @param WP_REST_Request $request Request param with the API call.
    2012      * @return WP_REST_Response/WP_Error/json
     1935     * @return WP_REST_Response|WP_Error
    20131936     */
    20141937    public function checkview_get_available_forms_test_results( WP_REST_Request $request ) {
    20151938        global $wpdb;
     1939
    20161940        $uid     = $request->get_param( 'uid' );
    20171941        $uid     = isset( $uid ) ? sanitize_text_field( $uid ) : null;
    20181942        $results = array();
     1943
    20191944        if ( '' === $uid || null === $uid ) {
    20201945            Checkview_Admin_Logs::add( 'api-logs', $this->jwt_error );
    2021             return new WP_Error(
    2022                 400,
    2023                 esc_html__( 'Insuficient data.', 'checkview' ),
    2024             );
    2025             wp_die();
     1946
     1947            return new WP_Error(
     1948                400,
     1949                esc_html__( 'Insufficient data.', 'checkview' ),
     1950            );
    20261951        } else {
    2027             $tablename = $wpdb->prefix . 'cv_entry';
    2028             $result    = $wpdb->get_row( $wpdb->prepare( 'Select * from ' . $tablename . ' where uid=%s', $uid ) );
    2029             $tablename = $wpdb->prefix . 'cv_entry_meta';
    2030             $rows      = $wpdb->get_results( $wpdb->prepare( 'Select * from ' . $tablename . ' where uid=%s order by id ASC', $uid ) );
    2031             if ( $rows ) {
    2032                 foreach ( $rows as $row ) {
    2033                     if ( 'gravityforms' === strtolower( $result->form_type ) ) {
    2034                         $results[] = array(
    2035                             'field_id'    => 'input_' . $row->form_id . '_' . str_replace( '.', '_', $row->meta_key ),
    2036                             'field_value' => $row->meta_value,
    2037                         );
    2038 
    2039                     } elseif ( 'cf7' === strtolower( $result->form_type ) ) {
    2040                         $value = $row->meta_value;
    2041                         if ( strpos( $value, 'htt' ) !== false ) {
    2042                             $value = html_entity_decode( $value );
    2043                         }
    2044                         $results[] = array(
    2045                             'field_id'    => '',
    2046                             'field_name'  => $row->meta_key,
    2047                             'field_value' => $value,
    2048                         );
    2049                     } elseif ( 'Forminator' === $result->form_type ) {
    2050                         $value = $row->meta_value;
    2051                         if ( strpos( $value, 'htt' ) !== false ) {
    2052                             $value = html_entity_decode( $value );
    2053                         }
    2054                         $results[] = array(
    2055                             'field_id'    => '',
    2056                             'field_name'  => $row->meta_key,
    2057                             'field_value' => $value,
    2058                         );
    2059                     } else {
    2060 
    2061                         $results[] = array(
    2062                             'field_id'    => $row->meta_key,
    2063                             'field_value' => maybe_unserialize( $row->meta_value ),
    2064                         );
     1952            $table_name    = $wpdb->prefix . 'cv_entry';
     1953            $query         = $wpdb->prepare( 'Select * from ' . $table_name . ' where uid=%s', $uid );
     1954            $query_as_json = wp_json_encode( array( 'query' => $query ) );
     1955            $result        = $wpdb->get_row( $query ); // We expect an object
     1956
     1957            if ( is_null( $result ) ) {
     1958                Checkview_Admin_Logs::add( 'api-logs', 'Failed to find test results (query [' . $query_as_json . '] returned null).' );
     1959
     1960                return new WP_Error(
     1961                    400,
     1962                    esc_html__( 'Failed to find test results (query [' . $query_as_json . '] returned null).', 'checkview' ),
     1963                );
     1964            }
     1965
     1966            if ( ! is_object( $result ) ) {
     1967                Checkview_Admin_Logs::add( 'api-logs', 'Failed to find test results (query [' . $query_as_json . '] returned unexpected type [' . gettype( $result ) . ']).' );
     1968
     1969                return new WP_Error(
     1970                    400,
     1971                    esc_html__( 'Failed to find test results (query [' . $query_as_json . '] returned unexpected type [' . gettype( $result ) . ']).', 'checkview' ),
     1972                );
     1973            }
     1974
     1975            $table_name         = $wpdb->prefix . 'cv_entry_meta';
     1976            $query              = $wpdb->prepare( 'Select * from ' . $table_name . ' where uid=%s order by id ASC', $uid );
     1977            $meta_query_as_json = wp_json_encode( array( 'query' => $query ) );
     1978            $rows               = $wpdb->get_results( $query ); // We expect an array of objects
     1979
     1980            if ( is_null( $rows ) ) {
     1981                Checkview_Admin_Logs::add( 'api-logs', 'Failed to find test results (query [' . $meta_query_as_json . '] returned null).' );
     1982
     1983                return new WP_Error(
     1984                    400,
     1985                    esc_html__( 'Failed to find test results (query [' . $meta_query_as_json . '] returned null).', 'checkview' ),
     1986                );
     1987            }
     1988
     1989            if ( ! is_array( $rows ) ) {
     1990                Checkview_Admin_Logs::add( 'api-logs', 'Failed to find test results (query [' . $meta_query_as_json . '] returned unexpected type [' . gettype( $rows ) . ']).' );
     1991
     1992                return new WP_Error(
     1993                    400,
     1994                    esc_html__( 'Failed to find test results (query [' . $meta_query_as_json . '] returned unexpected type [' . gettype( $rows ) . ']).', 'checkview' ),
     1995                );
     1996            }
     1997
     1998            foreach ( $rows as $row ) {
     1999                if ( 'gravityforms' === strtolower( $result->form_type ) ) {
     2000                    $results[] = array(
     2001                        'field_id'    => 'input_' . $row->form_id . '_' . str_replace( '.', '_', $row->meta_key ),
     2002                        'field_value' => $row->meta_value,
     2003                    );
     2004                } elseif ( 'cf7' === strtolower( $result->form_type ) ) {
     2005                    $value = $row->meta_value;
     2006
     2007                    if ( strpos( $value, 'htt' ) !== false ) {
     2008                        $value = html_entity_decode( $value );
    20652009                    }
    2066                 }
    2067                 if ( ! empty( $results ) && false !== $results ) {
    2068                     return new WP_REST_Response(
    2069                         array(
    2070                             'status'        => 200,
    2071                             'response'      => esc_html__( 'Successfully retrieved the results.', 'checkview' ),
    2072                             'body_response' => $results,
    2073                         )
     2010
     2011                    $results[] = array(
     2012                        'field_id'    => '',
     2013                        'field_name'  => $row->meta_key,
     2014                        'field_value' => $value,
     2015                    );
     2016                } elseif ( 'Forminator' === $result->form_type ) {
     2017                    $value = $row->meta_value;
     2018
     2019                    if ( strpos( $value, 'htt' ) !== false ) {
     2020                        $value = html_entity_decode( $value );
     2021                    }
     2022
     2023                    $results[] = array(
     2024                        'field_id'    => '',
     2025                        'field_name'  => $row->meta_key,
     2026                        'field_value' => $value,
    20742027                    );
    20752028                } else {
    2076                     Checkview_Admin_Logs::add( 'api-logs', 'Failed to retrieve the results.' );
    2077                     return new WP_Error(
    2078                         400,
    2079                         esc_html__( 'An error occurred while processing your request.', 'checkview' ),
     2029                    $results[] = array(
     2030                        'field_id'    => $row->meta_key,
     2031                        'field_value' => maybe_unserialize( $row->meta_value ),
    20802032                    );
    20812033                }
    2082                 wp_die();
    2083             } else {
    2084                 Checkview_Admin_Logs::add( 'api-logs', 'Failed to retrieve the results.' );
    2085                 return new WP_Error(
    2086                     400,
    2087                     esc_html__( 'An error occurred while processing your request.', 'checkview' ),
     2034            }
     2035
     2036            if ( ! empty( $results ) ) {
     2037                return new WP_REST_Response(
     2038                    array(
     2039                        'status'        => 200,
     2040                        'response'      => esc_html__( 'Successfully retrieved the results.', 'checkview' ),
     2041                        'body_response' => $results,
     2042                    )
    20882043                );
    2089                 wp_die();
    2090             }
     2044            }
     2045            Checkview_Admin_Logs::add( 'api-logs', 'Failed to find test results (rows were found, but results were determined to be empty).' );
     2046
     2047            return new WP_Error(
     2048                400,
     2049                esc_html__( 'Failed to find test results (rows were found, but results were determined to be empty).', 'checkview' ),
     2050            );
    20912051        }
    20922052    }
     
    20982058     *
    20992059     * @param WP_REST_Request $request Object with the API call.
    2100      * @return WP_REST_Response/WP_Error
     2060     * @return WP_REST_Response|WP_Error
    21012061     */
    21022062    public function checkview_register_form_test( WP_REST_Request $request ) {
     
    21242084                )
    21252085            );
    2126             wp_die();
    21272086        } else {
    21282087            Checkview_Admin_Logs::add( 'api-logs', sanitize_text_field( 'Details to register form test are not correct.' ) );
     
    21312090                esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    21322091            );
    2133             wp_die();
    21342092        }
    21352093    }
     
    21412099     *
    21422100     * @param WP_REST_Request $request Request param with the API call.
    2143      * @return WP_REST_Response/WP_Error/json
     2101     * @return WP_REST_Response|WP_Error
    21442102     */
    21452103    public function checkview_delete_forms_test_results( WP_REST_Request $request ) {
     
    21602118                esc_html__( 'Insuficient data.', 'checkview' ),
    21612119            );
    2162             wp_die();
    21632120        } else {
    21642121            $rows = true;
     
    21712128                    )
    21722129                );
    2173                 wp_die();
    21742130            } else {
    21752131                Checkview_Admin_Logs::add( 'api-logs', sanitize_text_field( 'Failed to remove the results.' ) );
     
    21782134                    esc_html__( 'An error occurred while processing your request.', 'checkview' ),
    21792135                );
    2180                 wp_die();
    21812136            }
    21822137        }
     
    21892144     * version, and the admin AJAX url.
    21902145     *
    2191      * @return WP_Rest_Response Forms details.
     2146     * @return WP_Rest_Response|WP_Error
    21922147     */
    21932148    public function checkview_saas_get_site_info() {
     
    22742229     *
    22752230     * @param WP_REST_Request $request WP_Request object.
    2276      * @return Json/WP Error
     2231     * @return WP_REST_Response|WP_Error
    22772232     */
    22782233    public function checkview_saas_get_plugin_version( WP_REST_Request $request ) {
     
    22842239                esc_html__( 'Invalid request.', 'checkview' ),
    22852240            );
    2286             wp_die();
    22872241        }
    22882242        // Get all plugins.
     
    23412295     * Returns plugin logs.
    23422296     *
    2343      * @return WP_Rest_Response log details.
     2297     * @return WP_REST_Response|WP_Error
    23442298     */
    23452299    public function checkview_saas_get_helper_logs() {
     
    24002354     * Sets status for helper plugin.
    24012355     *
    2402      * @param \WP_REST_Request $request wp request object.
    2403      * @return WP_Error/WP_REST_RESPONSE
     2356     * @param WP_REST_Request $request wp request object.
     2357     * @return WP_REST_Response|WP_Error
    24042358     */
    24052359    public function checkview_saas_set_helper_status( \WP_REST_Request $request ) {
     
    24302384
    24312385    /**
    2432      * Sets status for test product..
    2433      *
    2434      * @param \WP_REST_Request $request wp request object.
    2435      * @return WP_Error/WP_REST_RESPONSE
     2386     * Sets status for test product.
     2387     *
     2388     * @param WP_REST_Request $request wp request object.
     2389     * @return WP_REST_Response|WP_Error
    24362390     */
    24372391    public function checkview_saas_set_test_product_status( \WP_REST_Request $request ) {
     
    24522406                esc_html__( 'Invalid request.', 'checkview' ),
    24532407            );
    2454             wp_die();
    24552408        }
    24562409        // Get the status from the request parameters.
     
    24922445     * On success, stores the nonce token so it will not be used again.
    24932446     *
    2494      * @param \WP_REST_Request $request request data with the api call.
    2495      * @return json/array
     2447     * @param WP_REST_Request $request request data with the api call.
     2448     * @return WP_Error|array
    24962449     */
    24972450    public function checkview_get_items_permissions_check( \WP_REST_Request $request ) {
     
    25082461                ''
    25092462            );
    2510             wp_die();
    25112463        }
    25122464
     
    25182470                array( 'status' => 400 )
    25192471            );
    2520             wp_die();
    25212472        }
    25222473        $nonce_token = checkview_validate_jwt_token( $auth_header );
     
    25312482                ''
    25322483            );
    2533             wp_die();
    25342484        }
    25352485        if ( ! checkview_is_valid_uuid( $nonce_token ) ) {
     
    25402490                ''
    25412491            );
    2542             wp_die();
    25432492        }
    25442493        global $wpdb;
     
    25872536                ''
    25882537            );
    2589             wp_die();
    25902538        } else {
    25912539            // Store the nonce in the database.
     
    26032551                    )
    26042552                );
    2605                 wp_die();
    26062553            }
    26072554        }
  • checkview/trunk/includes/checkview-functions.php

    r3296900 r3303097  
    7575        try {
    7676            // Allow one-second leeway for JWT tokens
    77             JWT::$leeway = 1;
     77            JWT::$leeway = 5;
    7878            $decoded = JWT::decode( $token, new Key( $key, 'RS256' ) );
    7979        } catch ( Exception $e ) {
  • checkview/trunk/includes/class-checkview.php

    r3296900 r3303097  
    5555     * @access private
    5656     *
    57      * @var class $instance The instance of the class.
     57     * @var Checkview $instance The instance of the class.
    5858     */
    5959
     
    7171            $this->version = CHECKVIEW_VERSION;
    7272        } else {
    73             $this->version = '2.0.17';
     73            $this->version = '2.0.18';
    7474        }
    7575        $this->plugin_name = 'checkview';
     
    154154
    155155        // Initialize the plugin's API.
    156         $plugin_api = new CheckView_Api( $this->get_plugin_name(), $this->get_version(), $woo_helper );
     156        $plugin_api = new CheckView_Api( $woo_helper );
    157157
    158158        // Hook our routes into WordPress.
  • checkview/trunk/includes/woocommercehelper/class-checkview-woo-automated-testing.php

    r3283610 r3303097  
    7373     * @param string $plugin_name The name of this plugin.
    7474     * @param string $version The version of this plugin.
    75      * @param string $loader Loads the hooks.
     75     * @param Checkview_Loader $loader Loads the hooks.
    7676     */
    7777    public function __construct( $plugin_name, $version, $loader ) {
    78 
    7978        $this->plugin_name      = $plugin_name;
    8079        $this->version          = $version;
     
    8281        $this->suppress_email   = get_option( 'disable_email_receipt', false );
    8382        $this->suppress_webhook = get_option( 'disable_webhooks', false );
     83
    8484        if ( $this->loader ) {
    8585            $this->loader->add_action(
Note: See TracChangeset for help on using the changeset viewer.