PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.17
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.17
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / includes / CLI / Anon_ID_Command.php

Anon_ID_Command.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.17, at includes/CLI/Anon_ID_Command.php

57 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WP-CLI affordances for the anonymous analytics identity.
4 *
5 * @package WCPOS\WooCommercePOS\CLI
6 */
7
8 namespace WCPOS\WooCommercePOS\CLI;
9
10 use WCPOS\WooCommercePOS\Services\Anon_ID;
11
12 /**
13 * Manages the wcpos_anon_id analytics identifier.
14 */
15 class Anon_ID_Command {
16 /**
17 * Replaces the stored anonymous id with a fresh UUID.
18 *
19 * ## EXAMPLES
20 *
21 * wp wcpos anon-id rotate
22 *
23 * @param array $args Positional arguments (unused).
24 * @param array $assoc_args Associative arguments (unused).
25 */
26 public function rotate( array $args, array $assoc_args ): void {
27 $new = ( new Anon_ID() )->rotate();
28 $this->success( \sprintf( 'wcpos_anon_id rotated. New id: %s', $new ) );
29 }
30
31 /**
32 * Deletes the stored anonymous id. A new one is generated on the next
33 * landing-page load.
34 *
35 * ## EXAMPLES
36 *
37 * wp wcpos anon-id delete
38 *
39 * @param array $args Positional arguments (unused).
40 * @param array $assoc_args Associative arguments (unused).
41 */
42 public function delete( array $args, array $assoc_args ): void {
43 ( new Anon_ID() )->delete();
44 $this->success( 'wcpos_anon_id deleted.' );
45 }
46
47 /**
48 * Output seam — WP_CLI is absent in the unit-test container.
49 *
50 * @param string $message Success message.
51 */
52 protected function success( string $message ): void {
53 // @phpstan-ignore-next-line -- WP_CLI exists only under the wp-cli runtime; unit tests override this seam.
54 \WP_CLI::success( $message );
55 }
56 }
57