PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.1
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.1
2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.2 All 57 releases
← All changes | includes/Providers/ClientServiceProvider.php +17 -10 2.3.32.4.1 View file →
@@ -27,19 +27,26 @@
27 27 /**
28 28 * Register client services
29 29 */
30 30 public function register() {
31 - // Register the `customer` role on init:1.
31 + // Register the `customer` role.
32 32 //
33 - // This was previously hooked to `after_setup_theme` from inside
34 - // a callback that itself only runs on init:10 — so by the time
35 - // add_action() was called, `after_setup_theme` had already fired
36 - // and the registration silently never ran. On sites without
37 - // WooCommerce (which also registers `customer`), the role stayed
38 - // unregistered, WP_User::roles filtered it out as unknown, and
39 - // the Clients page fell back to a "Client" label while WC sites
40 - // showed "Customer" for the same data.
41 - add_action('init', [$this, 'registerClientRole'], 1);
33 + // This provider is constructed from easy_invoice_init(), which
34 + // itself runs on init:10 — so hooking `after_setup_theme` (the
35 + // original code) or `init` at priority 1 (the first fix) both
36 + // registered a callback for a point WordPress had already passed,
37 + // and the role was never created. On sites without WooCommerce
38 + // (which also registers `customer`) the role stayed unregistered:
39 + // WP_User::roles filtered it out as unknown, the Clients page fell
40 + // back to a "Client" label, and Pro's Client Portal — which
41 + // recognises a client by `in_array('customer', $user->roles)` —
42 + // could not see the client at all. Register it now when `init`
43 + // is already in progress, otherwise on init:1 as before.
44 + if (did_action('init')) {
45 + $this->registerClientRole();
46 + } else {
47 + add_action('init', [$this, 'registerClientRole'], 1);
48 + }
42 49
43 50 // Register client repository
44 51 $this->registerClientRepository();
45 52 }