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/Services/Print_Job_Service.php +9 -2 1.10.31.10.19 View file →
@@ -66,12 +66,19 @@
66 66 const STATUS_FAILED = 'failed';
67 67 const STATUS_CANCELLED = 'cancelled';
68 68
69 69 /**
70 - * Constructor — register the CPT on init.
70 + * Constructor — register the CPT on init, or at once when init has passed.
71 + *
72 + * On a storefront request this service is constructed lazily by the first
73 + * order write, long after `init`; a hook added then would never fire.
71 74 */
72 75 public function __construct() {
73 - add_action( 'init', array( $this, 'register_post_type' ) );
76 + if ( did_action( 'init' ) ) {
77 + $this->register_post_type();
78 + } else {
79 + add_action( 'init', array( $this, 'register_post_type' ) );
80 + }
74 81 // A static callback: several services construct Print_Job_Service on
75 82 // every request, and WordPress dedupes identical static callbacks, so
76 83 // the purge runs exactly once per cron event.
77 84 add_action( self::PURGE_HOOK, array( __CLASS__, 'run_purge' ) );