Skip to content

Commit

Permalink
prefix JWT package - possible conflict with other plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbot committed Nov 24, 2023
1 parent f6ced73 commit 0475ff1
Show file tree
Hide file tree
Showing 54 changed files with 7,298 additions and 205 deletions.
21 changes: 14 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
"require": {
"php": ">=7.4",
"ext-json": "*",
"firebase/php-jwt": "v6.9.0",
"ramsey/uuid": "4.2.3",
"ramsey/uuid": "^4.2",
"salesforce/handlebars-php": "3.0.1",
"vlucas/phpdotenv": "v5.5.0",
"yahnis-elsts/plugin-update-checker": "v5.2"
"vlucas/phpdotenv": "v5.5.0"
},
"config": {
"platform": {
Expand All @@ -47,12 +45,21 @@
"format": "phpcbf --standard=./.phpcs.xml.dist --report-summary --report-source",
"lint": "phpcs --standard=./.phpcs.xml.dist",
"lint-report": "phpcs --standard=./.phpcs.xml.dist --report=checkstyle",
"fix": "php-cs-fixer fix ."
"fix": "php-cs-fixer fix .",
"prefix-dependencies": [
"@composer --working-dir=php-scoper install",
"php-scoper/vendor/bin/php-scoper add-prefix --config=php-scoper/config.php --output-dir=./vendor_prefixed --force",
"@composer dump-autoload -o -a"
]
},
"autoload": {
"psr-4": {
"WCPOS\\WooCommercePOS\\": "includes/"
}
"WCPOS\\WooCommercePOS\\": "includes/"
},
"classmap": [
"vendor_prefixed/firebase/php-jwt/src",
"vendor_prefixed/yahnis-elsts/plugin-update-checker"
]
},
"autoload-dev": {
"psr-4": {
Expand Down
8 changes: 4 additions & 4 deletions includes/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ class API {
protected $controllers = array();

/**
* @var
* @var
*/
protected $wc_rest_api_handler;

/**
* @var
* @var
*/
protected $auth_service;

Expand Down Expand Up @@ -119,7 +119,7 @@ public function rest_pre_serve_request( $served, WP_HTTP_Response $result, WP_RE
Logger::log( "Warning: 'rest_pre_serve_request' filter received a non-boolean value for 'served'. Defaulting to 'false'." );
$served = false; // Default value if not provided correctly
}

$server->send_header( 'Access-Control-Allow-Origin', '*' );

return $served;
Expand Down Expand Up @@ -291,7 +291,7 @@ public function rest_dispatch_request( $dispatch_result, $request, $route, $hand
}
}
}

return $dispatch_result;
}

Expand Down
24 changes: 15 additions & 9 deletions includes/API/Traits/Uuid_Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ trait Uuid_Handler {
private function maybe_add_post_uuid( WC_Data $object ): void {
$meta_data = $object->get_meta_data();

$uuids = array_filter( $meta_data, function( WC_Meta_Data $meta ) {
return '_woocommerce_pos_uuid' === $meta->key;
});

$uuid_values = array_map( function( WC_Meta_Data $meta ) {
return $meta->value;
}, $uuids);

$uuids = array_filter(
$meta_data,
function ( WC_Meta_Data $meta ) {
return '_woocommerce_pos_uuid' === $meta->key;
}
);

$uuid_values = array_map(
function ( WC_Meta_Data $meta ) {
return $meta->value;
},
$uuids
);

// If there is no uuid, add one, i.e., new product
if ( empty( $uuid_values ) ) {
$object->update_meta_data( '_woocommerce_pos_uuid', $this->create_uuid() );
Expand All @@ -40,7 +46,7 @@ private function maybe_add_post_uuid( WC_Data $object ): void {
$object->update_meta_data( '_woocommerce_pos_uuid', $this->create_uuid() );
}
}


/**
* @param WP_User $user
Expand Down
12 changes: 6 additions & 6 deletions includes/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function init(): void {
new i18n();
new Gateways();
new Products();
// new Customers();
// new Customers();
new Orders();

// frontend only
Expand Down Expand Up @@ -136,15 +136,15 @@ public function send_headers(): void {
header( 'Access-Control-Expose-Headers: Link' );
}
}

/**
* Loads POS integrations with third party plugins.
*/
private function integrations(): void {
// // WooCommerce Bookings - http://www.woothemes.com/products/woocommerce-bookings/
// if ( class_exists( 'WC-Bookings' ) ) {
// new Integrations\Bookings();
// }
// WooCommerce Bookings - http://www.woothemes.com/products/woocommerce-bookings/
// if ( class_exists( 'WC-Bookings' ) ) {
// new Integrations\Bookings();
// }

// Yoast SEO - https://wordpress.org/plugins/wordpress-seo/
if ( class_exists( 'WPSEO_Options' ) ) {
Expand Down
Loading

0 comments on commit 0475ff1

Please sign in to comment.