Skip to content

Commit dd4f3c9

Browse files
committed
Change plugin name to WCPOS
1 parent 0ad6c37 commit dd4f3c9

31 files changed

+333
-371
lines changed

.github/hookdoc-tmpl/layout.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<?js= content ?>
2828

2929
<footer>
30-
<a href="https://wcpos.com/">WooCommerce POS</a> &bull;
30+
<a href="https://wcpos.com/">WCPOS</a> &bull;
3131
<a href="https://github.com/wcpos/woocommerce-pos/">GitHub</a> &bull;
3232
<a href="https://github.com/wcpos/discord">Discord Chat</a>
3333
</footer>

.github/workflows/update-pot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
wp package install wp-cli/i18n-command:2.2.8
2828
2929
- name: Update POT file
30-
run: wp i18n make-pot . languages/woocommerce-pos.pot --domain=woocommerce-pos --slug=woocommerce-pos --package-name="WooCommerce POS" --headers="{\"Report-Msgid-Bugs-To\":\"https://github.com/wcpos/woocommerce-pos/issues\"}"
30+
run: wp i18n make-pot . languages/woocommerce-pos.pot --domain=woocommerce-pos --slug=woocommerce-pos --package-name="WCPOS" --headers="{\"Report-Msgid-Bugs-To\":\"https://github.com/wcpos/woocommerce-pos/issues\"}"
3131

3232
- name: Check for changes
3333
id: git-diff

.phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WooCommerce POS" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WCPOS" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
33
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
44
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
55
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/WordPress-Core/ruleset.xml -->

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div align="center">
2-
<h1><a href="https://wcpos.com">WooCommerce POS</a> plugin</h1>
2+
<h1><a href="https://wcpos.com">WCPOS</a> – Point of Sale (POS) plugin for WooCommerce</h1>
33
<p>A WordPress plugin for taking WooCommerce orders at the Point of Sale.</p>
44
<p>
55
<a href="https://github.com/wcpos/woocommerce-pos/actions/workflows/tests.yml">
@@ -40,7 +40,7 @@ Coming soon.
4040
## 👷 Workflows
4141

4242
We recommend [LocalWP](https://localwp.com/) for creating a WordPress install on your local machine.
43-
You can either clone the WooCommerce POS repository into the `/wp-content/plugins/` folder or create a symbolic link (recommended).
43+
You can either clone the WCPOS repository into the `/wp-content/plugins/` folder or create a symbolic link (recommended).
4444

4545
```sh
4646
git clone https://github.com/wcpos/woocommerce-pos.git

includes/API.php

Lines changed: 71 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?php
22
/**
3-
* WooCommerce POS REST API Class, ie: /wcpos/v1/ endpoints.
3+
* WCPOS REST API Class, ie: /wcpos/v1/ endpoints.
44
*
55
* @author Paul Kilmurray <[email protected]>
66
*
77
* @see http://wcpos.com
8-
* @package WCPOS\WooCommercePOS
98
*/
109

1110
namespace WCPOS\WooCommercePOS;
@@ -17,10 +16,6 @@
1716
use WP_REST_Response;
1817
use WP_REST_Server;
1918

20-
21-
/**
22-
*
23-
*/
2419
class API {
2520
/**
2621
* WCPOS REST API namespaces and endpoints.
@@ -62,35 +57,35 @@ public function __construct() {
6257
/**
6358
* Register routes for all controllers.
6459
*/
65-
public function register_routes() {
60+
public function register_routes(): void {
6661
/**
67-
* Filter the list of controller classes used in the WooCommerce POS REST API.
62+
* Filter the list of controller classes used in the WCPOS REST API.
6863
*
6964
* This filter allows customizing or extending the set of controller classes that handle
70-
* REST API routes for the WooCommerce POS. By filtering these controllers, plugins can
65+
* REST API routes for the WCPOS. By filtering these controllers, plugins can
7166
* modify existing endpoints or add new controllers for additional functionality.
7267
*
7368
* @since 1.5.0
7469
*
7570
* @param array $controllers Associative array of controller identifiers to their corresponding class names.
76-
* - 'auth' => Fully qualified name of the class handling authentication.
77-
* - 'settings' => Fully qualified name of the class handling settings.
78-
* - 'stores' => Fully qualified name of the class handling stores management.
79-
* - 'products' => Fully qualified name of the class handling products.
80-
* - 'product_variations' => Fully qualified name of the class handling product variations.
81-
* - 'orders' => Fully qualified name of the class handling orders.
82-
* - 'customers' => Fully qualified name of the class handling customers.
83-
* - 'product_tags' => Fully qualified name of the class handling product tags.
84-
* - 'product_categories' => Fully qualified name of the class handling product categories.
85-
* - 'taxes' => Fully qualified name of the class handling taxes.
86-
* - 'shipping_methods' => Fully qualified name of the class handling shipping methods.
87-
* - 'tax_classes' => Fully qualified name of the class handling tax classes.
88-
* - 'order_statuses' => Fully qualified name of the class handling order statuses.
71+
* - 'auth' => Fully qualified name of the class handling authentication.
72+
* - 'settings' => Fully qualified name of the class handling settings.
73+
* - 'stores' => Fully qualified name of the class handling stores management.
74+
* - 'products' => Fully qualified name of the class handling products.
75+
* - 'product_variations' => Fully qualified name of the class handling product variations.
76+
* - 'orders' => Fully qualified name of the class handling orders.
77+
* - 'customers' => Fully qualified name of the class handling customers.
78+
* - 'product_tags' => Fully qualified name of the class handling product tags.
79+
* - 'product_categories' => Fully qualified name of the class handling product categories.
80+
* - 'taxes' => Fully qualified name of the class handling taxes.
81+
* - 'shipping_methods' => Fully qualified name of the class handling shipping methods.
82+
* - 'tax_classes' => Fully qualified name of the class handling tax classes.
83+
* - 'order_statuses' => Fully qualified name of the class handling order statuses.
8984
*/
9085
$classes = apply_filters(
9186
'woocommerce_pos_rest_api_controllers',
9287
array(
93-
// woocommerce pos rest api controllers.
88+
// WCPOS rest api controllers.
9489
'auth' => API\Auth::class,
9590
'settings' => API\Settings::class,
9691
'stores' => API\Stores::class,
@@ -197,7 +192,7 @@ public function rest_authentication_errors( $errors ) {
197192
/**
198193
* Extract the Authorization Bearer token from the request.
199194
*
200-
* @return string|false
195+
* @return false|string
201196
*/
202197
public function get_auth_header() {
203198
// Check if HTTP_AUTHORIZATION is set in $_SERVER
@@ -222,7 +217,7 @@ public function get_auth_header() {
222217
/**
223218
* Adds info to the WP REST API index response.
224219
* - UUID
225-
* - Version Info
220+
* - Version Info.
226221
*
227222
* @param WP_REST_Response $response Response data.
228223
*
@@ -234,10 +229,10 @@ public function rest_index( WP_REST_Response $response ): WP_REST_Response {
234229
$uuid = Uuid::uuid4()->toString();
235230
update_option( 'woocommerce_pos_uuid', $uuid );
236231
}
237-
$response->data['uuid'] = $uuid;
238-
$response->data['wp_version'] = get_bloginfo( 'version' );
239-
$response->data['wc_version'] = WC()->version;
240-
$response->data['wcpos_version'] = VERSION;
232+
$response->data['uuid'] = $uuid;
233+
$response->data['wp_version'] = get_bloginfo( 'version' );
234+
$response->data['wc_version'] = WC()->version;
235+
$response->data['wcpos_version'] = VERSION;
241236
$response->data['use_jwt_as_param'] = woocommerce_pos_get_settings( 'tools', 'use_jwt_as_param' );
242237

243238
/**
@@ -289,44 +284,6 @@ public function rest_pre_dispatch( $result, $server, $request ) {
289284
return $result;
290285
}
291286

292-
/**
293-
* Some servers have a limit on the number of include/exclude we can use in a request.
294-
* Worst thing is there is often no error message, the request returns an empty response.
295-
*
296-
* For example, WP Engine has a limit of 1024 characters?
297-
* https://wpengine.com/support/using-dev-tools/#Long_Queries_in_wp_db
298-
*
299-
* @TODO - For long queries, I should find a better solution than this.
300-
*
301-
* @param string|array $param_value
302-
* @param int $max_length
303-
* @return array
304-
*/
305-
private function shorten_param_array( $param_value, $max_length ) {
306-
$param_array = is_array( $param_value ) ? $param_value : explode( ',', $param_value );
307-
$param_string = implode( ',', $param_array );
308-
309-
if ( strlen( $param_string ) > $max_length ) {
310-
shuffle( $param_array ); // Shuffle to randomize
311-
312-
$new_param_string = '';
313-
$random_param_array = array();
314-
315-
foreach ( $param_array as $id ) {
316-
if ( strlen( $new_param_string . $id ) < $max_length ) {
317-
$new_param_string .= $id . ',';
318-
$random_param_array[] = $id;
319-
} else {
320-
break; // Stop when maximum length is reached
321-
}
322-
}
323-
324-
return $random_param_array;
325-
}
326-
327-
return $param_array;
328-
}
329-
330287
/**
331288
* Filters the REST API dispatch request result.
332289
*
@@ -338,13 +295,13 @@ private function shorten_param_array( $param_value, $max_length ) {
338295
* @return mixed
339296
*/
340297
public function rest_dispatch_request( $dispatch_result, $request, $route, $handler ) {
341-
if ( isset( $handler['callback'] ) && is_array( $handler['callback'] ) && isset( $handler['callback'][0] ) ) {
298+
if ( isset( $handler['callback'] ) && \is_array( $handler['callback'] ) && isset( $handler['callback'][0] ) ) {
342299
$controller = $handler['callback'][0];
343300

344301
// Check if the controller object is one of our registered controllers.
345302
foreach ( $this->controllers as $key => $wcpos_controller ) {
346303
if ( $controller === $wcpos_controller ) {
347-
/**
304+
/*
348305
* I'm adding some additional PHP settings before the response. Placing them here so they only apply to the POS API.
349306
*
350307
* - error_reporting(0) - Turn off error reporting
@@ -365,6 +322,7 @@ public function rest_dispatch_request( $dispatch_result, $request, $route, $hand
365322
if ( method_exists( $controller, 'wcpos_dispatch_request' ) ) {
366323
return $controller->wcpos_dispatch_request( $dispatch_result, $request, $route, $handler );
367324
}
325+
368326
break;
369327
}
370328
}
@@ -373,6 +331,45 @@ public function rest_dispatch_request( $dispatch_result, $request, $route, $hand
373331
return $dispatch_result;
374332
}
375333

334+
/**
335+
* Some servers have a limit on the number of include/exclude we can use in a request.
336+
* Worst thing is there is often no error message, the request returns an empty response.
337+
*
338+
* For example, WP Engine has a limit of 1024 characters?
339+
* https://wpengine.com/support/using-dev-tools/#Long_Queries_in_wp_db
340+
*
341+
* @TODO - For long queries, I should find a better solution than this.
342+
*
343+
* @param array|string $param_value
344+
* @param int $max_length
345+
*
346+
* @return array
347+
*/
348+
private function shorten_param_array( $param_value, $max_length ) {
349+
$param_array = \is_array( $param_value ) ? $param_value : explode( ',', $param_value );
350+
$param_string = implode( ',', $param_array );
351+
352+
if ( \strlen( $param_string ) > $max_length ) {
353+
shuffle( $param_array ); // Shuffle to randomize
354+
355+
$new_param_string = '';
356+
$random_param_array = array();
357+
358+
foreach ( $param_array as $id ) {
359+
if ( \strlen( $new_param_string . $id ) < $max_length ) {
360+
$new_param_string .= $id . ',';
361+
$random_param_array[] = $id;
362+
} else {
363+
break; // Stop when maximum length is reached
364+
}
365+
}
366+
367+
return $random_param_array;
368+
}
369+
370+
return $param_array;
371+
}
372+
376373
/**
377374
* Check the Authorization header for a Bearer token.
378375
*
@@ -383,25 +380,26 @@ public function rest_dispatch_request( $dispatch_result, $request, $route, $hand
383380
private function authenticate( $user_id ) {
384381
// check if there is an auth header
385382
$auth_header = $this->get_auth_header();
386-
if ( ! is_string( $auth_header ) ) {
383+
if ( ! \is_string( $auth_header ) ) {
387384
return $user_id;
388385
}
389386

390387
// Extract Bearer token from Authorization Header
391388
list($token) = sscanf( $auth_header, 'Bearer %s' );
392389

393390
if ( $token ) {
394-
$auth_service = Auth::instance();
391+
$auth_service = Auth::instance();
395392
$decoded_token = $auth_service->validate_token( $token );
396393

397394
// Check if validate_token returned WP_Error and user_id is null
398-
if ( is_wp_error( $decoded_token ) && $user_id === null ) {
399-
return $decoded_token;
395+
if ( is_wp_error( $decoded_token ) && null === $user_id ) {
396+
return $decoded_token;
400397
}
401398

402399
// If the token is valid, set the user_id
403400
if ( ! is_wp_error( $decoded_token ) ) {
404401
$user_id = $decoded_token->data->user->id;
402+
405403
return absint( $user_id );
406404
}
407405
}

includes/API/Orders_Controller.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ public function wcpos_send_email( WP_REST_Request $request ) {
534534
if ( 'billing' == $request['save_to'] ) {
535535
$order->set_billing_email( $email );
536536
$order->save();
537-
$order->add_order_note( \sprintf( __( 'Email address %s added to billing details from WooCommerce POS.', 'woocommerce-pos' ), $email ), false, true );
537+
$order->add_order_note( \sprintf( __( 'Email address %s added to billing details from WCPOS.', 'woocommerce-pos' ), $email ), false, true );
538538
}
539539

540540
do_action( 'woocommerce_before_resend_order_emails', $order, 'customer_invoice' );
@@ -546,7 +546,7 @@ public function wcpos_send_email( WP_REST_Request $request ) {
546546
WC()->mailer()->customer_invoice( $order );
547547

548548
// Note the event.
549-
$order->add_order_note( \sprintf( __( 'Order details manually sent to %s from WooCommerce POS.', 'woocommerce-pos' ), $email ), false, true );
549+
$order->add_order_note( \sprintf( __( 'Order details manually sent to %s from WCPOS.', 'woocommerce-pos' ), $email ), false, true );
550550

551551
do_action( 'woocommerce_after_resend_order_email', $order, 'customer_invoice' );
552552

@@ -683,7 +683,7 @@ public function wcpos_order_get_items( array $items, WC_Abstract_Order $order, a
683683
}
684684

685685
/**
686-
* Add extra data for woocommerce pos orders.
686+
* Add extra data for wcpos orders.
687687
* - Add custom 'created_via' prop for POS orders, used in WC Admin display.
688688
*
689689
* @param WC_Abstract_Order $order The object being saved.

0 commit comments

Comments
 (0)