PluginProbe
PostNL for WooCommerce / trunk
PostNL for WooCommerce vtrunk
5.9.11 5.9.10 5.9.9 5.9.8 5.9.7 5.9.6 trunk 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.1.4 3.1.5 3.1.6 3.1.7 4.0.0 4.0.1 4.0.2 4.3.2 4.3.3 4.4.0 4.4.1 4.4.2 All 71 releases
woo-postnl / src / Rest_API / Router.php

Router.php in PostNL for WooCommerce trunk, at src/Rest_API/Router.php

67 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class Rest_API/Router file.
4 *
5 * @package PostNLWooCommerce\Rest_API
6 */
7
8 declare( strict_types = 1 );
9
10 namespace PostNLWooCommerce\Rest_API;
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 /**
17 * Class Router
18 *
19 * Decides per-flow whether the new PostNL SDK is wired up. Every supported
20 * flow is gated behind its own filter so flows can be toggled independently
21 * during the v4 migration.
22 *
23 * @package PostNLWooCommerce\Rest_API
24 * @since 5.9.6
25 */
26 class Router {
27
28 /**
29 * Flows that may be enabled for the PostNL SDK.
30 *
31 * postcode_check is intentionally absent — it stays on the legacy REST path.
32 *
33 * @since 5.9.6
34 * @var string[]
35 */
36 const SUPPORTED_FLOWS = array(
37 'barcode',
38 'timeframe',
39 'pickup_location',
40 'checkout',
41 'label',
42 'return_label',
43 'letterbox',
44 'shipment_and_return',
45 'smart_returns',
46 );
47
48 /**
49 * Return whether the SDK is enabled for a given flow.
50 *
51 * Flows not in SUPPORTED_FLOWS always return false without invoking any filter.
52 * Every flow defaults to false; site owners opt in via the filter.
53 *
54 * @since 5.9.6
55 *
56 * @param string $flow Flow identifier.
57 * @return bool
58 */
59 public static function sdk_enabled_for( string $flow ): bool {
60 if ( ! in_array( $flow, self::SUPPORTED_FLOWS, true ) ) {
61 return false;
62 }
63
64 return (bool) apply_filters( "postnl_sdk_enable_{$flow}", false );
65 }
66 }
67