From ae6424ccca27ef2f0414d256969aadbaebb62e18 Mon Sep 17 00:00:00 2001 From: Paul Kilmurray Date: Mon, 3 Jun 2024 11:45:31 +0100 Subject: [PATCH] add version info --- includes/API.php | 12 +++++++++--- includes/Templates/Frontend.php | 3 +++ woocommerce-pos.php | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/includes/API.php b/includes/API.php index d0a56f8..373f043 100644 --- a/includes/API.php +++ b/includes/API.php @@ -17,6 +17,7 @@ use WP_REST_Response; use WP_REST_Server; + /** * */ @@ -50,7 +51,7 @@ public function __construct() { add_filter( 'determine_current_user', array( $this, 'determine_current_user' ), 20 ); add_filter( 'rest_authentication_errors', array( $this, 'rest_authentication_errors' ), 50, 1 ); - // Adds uuid for the WordPress install + // Adds info about the WordPress install add_filter( 'rest_index', array( $this, 'rest_index' ), 10, 1 ); // These filters allow changes to the WC REST API response @@ -219,9 +220,11 @@ public function get_auth_header() { } /** - * Add uuid to the WP REST API index. + * Adds info to the WP REST API index response. + * - UUID + * - Version Info * - * @param WP_REST_Response $response Response data + * @param WP_REST_Response $response Response data. * * @return WP_REST_Response */ @@ -232,6 +235,9 @@ public function rest_index( WP_REST_Response $response ): WP_REST_Response { update_option( 'woocommerce_pos_uuid', $uuid ); } $response->data['uuid'] = $uuid; + $response->data['wp_version'] = get_bloginfo( 'version' ); + $response->data['wc_version'] = WC()->version; + $response->data['wcpos_version'] = VERSION; return $response; } diff --git a/includes/Templates/Frontend.php b/includes/Templates/Frontend.php index 520c897..91490f4 100644 --- a/includes/Templates/Frontend.php +++ b/includes/Templates/Frontend.php @@ -120,6 +120,9 @@ function ( $store ) { 'home' => home_url(), 'gmt_offset' => get_option( 'gmt_offset' ), 'timezone_string' => get_option( 'timezone_string' ), + 'wp_version' => get_bloginfo( 'version' ), + 'wc_version' => WC()->version, + 'wcpos_version' => VERSION, 'wp_api_url' => get_rest_url(), 'wc_api_url' => get_rest_url( null, 'wc/v3' ), 'wc_api_auth_url' => get_rest_url( null, 'wcpos/v1/jwt' ), diff --git a/woocommerce-pos.php b/woocommerce-pos.php index 9ac2986..695b521 100644 --- a/woocommerce-pos.php +++ b/woocommerce-pos.php @@ -36,7 +36,7 @@ // minimum requirements. const WC_MIN_VERSION = '5.3'; const PHP_MIN_VERSION = '7.4'; -const MIN_PRO_VERSION = '1.4.0'; +const MIN_PRO_VERSION = '1.5.0'; // load .env flags (for development). function load_env( $file ) {