Akantio POS — landing page: a way into POS and a log of * recent order-push activity. This plugin no longer tracks connection * state itself — the WooCommerce OAuth handshake and the resulting * credential are owned by POS/LM2 (see Rest/NativeAuth.php), so there is * nothing local left to show a "connected" status for. */ class SettingsPage { public const SLUG = 'akantio-pos-settings'; private ActivityLog $activityLog; public function __construct( ActivityLog $activityLog ) { $this->activityLog = $activityLog; } public function register(): void { add_action( 'admin_menu', [ $this, 'registerMenu' ] ); } public function registerMenu(): void { add_menu_page( __( 'Akantio POS', 'akantio-pos' ), __( 'Akantio POS', 'akantio-pos' ), 'manage_woocommerce', self::SLUG, [ $this, 'render' ], 'dashicons-cart', // WooCommerce's own top-level menu registers at position 55 — 56 // places this directly below it instead of wherever no explicit // position (the prior default) happened to land it. 56 ); } public function render(): void { if ( ! current_user_can( 'manage_woocommerce' ) ) { wp_die( esc_html__( 'You do not have permission to manage this setting.', 'akantio-pos' ) ); } echo '
'; $this->renderHeader(); $this->renderActivityCard(); echo '
'; } private function renderHeader(): void { echo '

' . esc_html__( 'Akantio POS', 'akantio-pos' ) . '

'; echo '
'; echo '

' . esc_html__( 'Akantio POS', 'akantio-pos' ) . '

'; echo '
'; echo '' . esc_html__( 'Open POS', 'akantio-pos' ) . ''; echo '
'; } private function renderActivityCard(): void { $entries = $this->activityLog->recent( 20 ); echo '

' . esc_html__( 'Recent activity', 'akantio-pos' ) . '

'; if ( empty( $entries ) ) { echo '

' . esc_html__( 'No activity yet.', 'akantio-pos' ) . '

'; return; } echo ''; } /** * Renders links into whatever the activity entry's context points at — * the WooCommerce order for order_created, the affected products for * stock_synced — so "order_created" in the list isn't just a label with * no way to see which order or products it actually was. */ private function renderEntryLinks( array $entry ): string { $context = $entry['context'] ?? []; if ( 'order_created' === $entry['event'] && ! empty( $context['woo_order_id'] ) ) { $order = wc_get_order( (int) $context['woo_order_id'] ); if ( $order ) { return ' — ' . esc_html( $order->get_order_number() ) . ''; } } if ( 'stock_synced' === $entry['event'] && ! empty( $context['product_ids'] ) ) { $links = array_map( static function ( $productId ) { $editLink = get_edit_post_link( (int) $productId, 'raw' ); $product = wc_get_product( (int) $productId ); $label = $product ? $product->get_name() : '#' . $productId; return $editLink ? '' . esc_html( $label ) . '' : esc_html( $label ); }, (array) $context['product_ids'] ); return ' — ' . implode( ', ', $links ); } return ''; } }