PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.19
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.19
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 -2 1.9.161.10.19 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(
@@ -80,8 +89,27 @@
80 89 new Notices();
81 90 }
82 91
83 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 + );
109 + }
110 +
111 + /**
84 112 * Fires before the administration menu loads in the admin.
85 113 */
86 114 public function admin_menu(): void {
87 115 $menu = new Admin\Menu();
@@ -95,10 +123,8 @@
95 123 }
96 124
97 125 /**
98 126 * Conditionally load subclasses based on admin screen.
99 - *
100 - * @TODO - I need to register the instances to allow remove_action/remove_filter.
101 127 *
102 128 * @param WP_Screen $current_screen Current screen object.
103 129 */
104 130 public function current_screen( $current_screen ): void {