PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.18
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.18
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
← All changes | includes/Admin.php +28 -0 1.10.11.10.18 View file →
@@ -30,8 +30,16 @@
30 30 * Admin class.
31 31 */
32 32 class Admin {
33 33 /**
34 + * Script handle for the api-fetch `_method` shim (assets/js/api-fetch-method-param.js).
35 + *
36 + * Pro references this handle by its string value, guarded by
37 + * wp_script_is( ..., 'registered' ), so the value is a compatibility contract.
38 + */
39 + public const API_FETCH_METHOD_PARAM_HANDLE = 'wcpos-api-fetch-method-param';
40 +
41 + /**
34 42 * POS Menu IDs.
35 43 *
36 44 * @var string[] Unique menu identifier.
37 45 */
@@ -56,8 +64,9 @@
56 64 */
57 65 public function __construct() {
58 66 add_action( 'admin_menu', array( $this, 'admin_menu' ), 5 );
59 67 add_action( 'admin_init', array( $this, 'init' ) );
68 + add_action( 'admin_init', array( $this, 'register_scripts' ) );
60 69 add_action( 'current_screen', array( $this, 'current_screen' ) );
61 70
62 71 // register the screen handlers.
63 72 $this->screen_handlers = array(
@@ -77,8 +86,27 @@
77 86 * Load admin subclasses.
78 87 */
79 88 public function init(): void {
80 89 new Notices();
90 + }
91 +
92 + /**
93 + * Register the shared admin scripts that WCPOS bundles depend on.
94 + *
95 + * The api-fetch shim routes PUT/PATCH/DELETE through POST + `?_method=`
96 + * so wp-admin mutations survive hosts that 403 the bare verbs or the
97 + * `X-HTTP-Method-Override` header (see the shim's header comment). It is
98 + * only registered here; each bundle that uses `wp.apiFetch` enqueues it
99 + * by listing self::API_FETCH_METHOD_PARAM_HANDLE as a dependency.
100 + */
101 + public function register_scripts(): void {
102 + wp_register_script(
103 + self::API_FETCH_METHOD_PARAM_HANDLE,
104 + PLUGIN_URL . 'assets/js/api-fetch-method-param.js',
105 + array( 'wp-api-fetch' ),
106 + VERSION,
107 + true
108 + );
81 109 }
82 110
83 111 /**
84 112 * Fires before the administration menu loads in the admin.